@gentbajko/slopify 1.0.0 → 1.0.1

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.
@@ -95,11 +95,11 @@ Error generating stack: `+e.message+`
95
95
 
96
96
  `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=Jy,c=!Bb.jitless,l=c&&Yy.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?dC([],p,i,f,d,e):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function hC(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!db(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>gb(e,r,Vb())))}),t)}var gC=U(`$ZodUnion`,(e,t)=>{hS.init(e,t),Ab(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),Ab(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),Ab(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),Ab(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>Vy(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>hC(t,r,e,i)):hC(o,r,e,i)}}),_C=U(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,gC.init(e,t);let n=e._zod.parse;Ab(e,`propValues`,e=>{let t={};for(let n of e.def.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(n)}"`);for(let[e,n]of Object.entries(r)){Object.prototype.hasOwnProperty.call(t,e)||Uy(t,e,new Set);for(let r of n)t[e].add(r)}}return t}),t.options.forEach((e,n)=>{let r=fC.get(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=zy(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!Jy(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),vC=U(`$ZodIntersection`,(e,t)=>{hS.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>bC(e,t,n)):bC(e,i,a)}});function yC(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Xy(e)&&Xy(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=yC(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=yC(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function bC(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=yC(t.value,n.value);if(!c.valid){if(db(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var xC=U(`$ZodRecord`,(e,t)=>{hS.init(e,t);let n=Bb.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Xy(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>gb(e,i,Vb())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...pb(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...pb(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&Wx.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>gb(e,i,Vb())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...pb(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...pb(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),SC=U(`$ZodEnum`,(e,t)=>{hS.init(e,t);let n=Iy(t.entries),r=new Set(n);e._zod.values=r;let i=n.filter(e=>Qy.has(typeof e));e._zod.pattern=RegExp(i.length?`^(${i.map(e=>$y(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),CC=U(`$ZodLiteral`,(e,t)=>{hS.init(e,t);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(t.values.length?`^(${t.values.map(e=>typeof e==`string`?$y(e):e?$y(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),wC=U(`$ZodTransform`,(e,t)=>{hS.init(e,t),e._zod.optin=`optional`,Bb.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new zb(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Rb;return n.value=i,n}});function TC(e,t){return e.value=t.issues.length?void 0:t.value,e}var EC=U(`$ZodOptional`,(e,t)=>{hS.init(e,t),Ab(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,Ab(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),Ab(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Vy(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>TC(e,t)):TC(e,r)}return t.innerType._zod.run(e,n)}}),DC=U(`$ZodExactOptional`,(e,t)=>{EC.init(e,t),Ab(e,`values`,e=>e.def.innerType._zod.values),Ab(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),OC=U(`$ZodNullable`,(e,t)=>{hS.init(e,t),Ab(e,`optin`,e=>e.def.innerType._zod.optin),Ab(e,`optout`,e=>e.def.innerType._zod.optout),Ab(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Vy(t.source)}|null)$`):void 0}),Ab(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),kC=U(`$ZodDefault`,(e,t)=>{hS.init(e,t),e._zod.optin=`defaulted`,Ab(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>AC(e,t)):AC(r,t)}});function AC(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var jC=U(`$ZodPrefault`,(e,t)=>{hS.init(e,t),e._zod.optin=`defaulted`,Ab(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),MC=U(`$ZodNonOptional`,(e,t)=>{hS.init(e,t),Ab(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>NC(t,e)):NC(i,e)}});function NC(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function PC(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>gb(e,r,Vb()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var FC=U(`$ZodCatch`,(e,t)=>{hS.init(e,t),Ab(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),Ab(e,`optout`,e=>e.def.innerType._zod.optout),Ab(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>PC(e,r,t,n)):PC(e,r,t,n)}}),IC=U(`$ZodPipe`,(e,t)=>{hS.init(e,t),Ab(e,`values`,e=>e.def.in._zod.values),Ab(e,`optin`,e=>e.def.in._zod.optin),Ab(e,`optout`,e=>e.def.out._zod.optout),Ab(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>LC(e,t.in,n)):LC(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>LC(e,t.out,n)):LC(r,t.out,n)}});function LC(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var RC=U(`$ZodReadonly`,(e,t)=>{hS.init(e,t),Ab(e,`propValues`,e=>e.def.innerType._zod.propValues),Ab(e,`values`,e=>e.def.innerType._zod.values),Ab(e,`optin`,e=>e.def.innerType?._zod?.optin),Ab(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(zC):zC(r)}});function zC(e){return e.memo||(e.value=Object.freeze(e.value)),e}var BC=U(`$ZodCustom`,(e,t)=>{Yx.init(e,t),hS.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>VC(t,n,r,e));VC(i,n,r,e)}});function VC(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(xb(e))}}var HC=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},UC=`~memo`,WC=[];function GC(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var KC=new WeakMap;function qC(e,t){let n=KC.get(e);if(n!==void 0)return n;if(t.has(e))return!0;t.add(e);let r=!1,i=e=>{!r&&e?._zod&&qC(e,t)&&(r=!0)},a=e._zod.def;switch(a.type){case`object`:for(let e of Reflect.ownKeys(a.shape))i(a.shape[e]);i(a.catchall);break;case`array`:i(a.element);break;case`tuple`:for(let e of a.items)i(e);i(a.rest);break;case`record`:case`map`:i(a.keyType),i(a.valueType);break;case`set`:i(a.valueType);break;case`union`:for(let e of a.options)i(e);break;case`intersection`:i(a.left),i(a.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:i(a.innerType);break;case`pipe`:i(a.in),i(a.out);break;case`function`:i(a.input),i(a.output);break;case`lazy`:i(e._zod.innerType);break;case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in a){let t=Object.getOwnPropertyDescriptor(a,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)i(n);else if(Array.isArray(n))for(let e of n)i(e)}}}return t.delete(e),KC.set(e,r),r}function JC(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}var YC,XC=[],ZC={alloc(e,t,n){let r=YC;if(!r)return n;YC=void 0;let i={value:n,issues:null};return r.set(t.value,i),XC.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&$C(n,e.value))throw new HC;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,a=(o,s)=>{if(n===void 0&&(n=qC(e,new Set),!n))return e._zod.parse=t,e._zod.run===a&&(e._zod.run=t),t(o,s);let c=o.value;if(typeof c!=`object`||!c)return t(o,s);let l=s[UC];l||(l={buckets:new Map,backEdges:void 0},s[UC]=l);let u;r===s?u=i:(u=JC(l,e),r=s,i=u);let d=u.get(c);if(d)return o.value=d.value,d.issues?d.issues.length&&o.issues.push(...GC(d.issues)):(o.memo=!0,l.backEdges??(l.backEdges=new Set),l.backEdges.add(d.value)),o;YC=u;let f=XC.length,p=t(o,s);YC=void 0;let m=XC.length>f?XC.pop():void 0;return p instanceof Promise?p.then(e=>(m&&(m.issues=e.issues.length?GC(e.issues):WC),e)):(m&&(m.issues=p.issues.length?GC(p.issues):WC),p)};e._zod.parse=a,e._zod.run===t&&(e._zod.run=a)})}};function QC(){return ZC}function $C(e,t){let n=e[UC]?.backEdges;return n!==void 0&&typeof t==`object`&&!!t&&n.has(t)}var ew=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,credit_card:`credit card number`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(bb(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${tb(e.values[0])}`:`Invalid option: expected one of ${Ly(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${Ly(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function tw(){return{localeError:ew()}}var nw,rw=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function iw(){return new rw}(nw=globalThis).__zod_globalRegistry??(nw.__zod_globalRegistry=iw());var aw=globalThis.__zod_globalRegistry;function ow(e,t){return new e({type:`string`,...H(t)})}function sw(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...H(t)})}function cw(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...H(t)})}function lw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...H(t)})}function uw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...H(t)})}function dw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...H(t)})}function fw(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...H(t)})}function pw(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...H(t)})}function mw(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...H(t)})}function hw(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...H(t)})}function gw(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...H(t)})}function _w(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...H(t)})}function vw(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...H(t)})}function yw(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...H(t)})}function bw(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...H(t)})}function xw(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...H(t)})}function Sw(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...H(t)})}function Cw(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...H(t)})}function ww(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...H(t)})}function Tw(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...H(t)})}function Ew(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...H(t)})}function Dw(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...H(t)})}function Ow(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...H(t)})}function kw(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...H(t)})}function Aw(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...H(t)})}function jw(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...H(t)})}function Mw(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...H(t)})}function Nw(e,t){return new e({type:`number`,checks:[],...H(t)})}function Pw(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...H(t)})}function Fw(e,t){return new e({type:`boolean`,...H(t)})}function Iw(e,t){return new e({type:`null`,...H(t)})}function Lw(e){return new e({type:`unknown`})}function Rw(e,t){return new e({type:`never`,...H(t)})}function zw(e,t){return new Qx({check:`less_than`,...H(t),value:e,inclusive:!1})}function Bw(e,t){return new Qx({check:`less_than`,...H(t),value:e,inclusive:!0})}function Vw(e,t){return new $x({check:`greater_than`,...H(t),value:e,inclusive:!1})}function Hw(e,t){return new $x({check:`greater_than`,...H(t),value:e,inclusive:!0})}function Uw(e,t){return new eS({check:`multiple_of`,...H(t),value:e})}function Ww(e,t){return new nS({check:`max_length`,...H(t),maximum:e})}function Gw(e,t){return new rS({check:`min_length`,...H(t),minimum:e})}function Kw(e,t){return new iS({check:`length_equals`,...H(t),length:e})}function qw(e,t){return new oS({check:`string_format`,format:`regex`,...H(t),pattern:e})}function Jw(e){return new sS({check:`string_format`,format:`lowercase`,...H(e)})}function Yw(e){return new cS({check:`string_format`,format:`uppercase`,...H(e)})}function Xw(e,t){return new lS({check:`string_format`,format:`includes`,...H(t),includes:e})}function Zw(e,t){return new uS({check:`string_format`,format:`starts_with`,...H(t),prefix:e})}function Qw(e,t){return new dS({check:`string_format`,format:`ends_with`,...H(t),suffix:e})}function $w(e){return new fS({check:`overwrite`,tx:e})}function eT(e){return $w(t=>t.normalize(e))}function tT(){return $w(e=>e.trim())}function nT(){return $w(e=>e.toLowerCase())}function rT(){return $w(e=>e.toUpperCase())}function iT(){return $w(e=>Ky(e))}function aT(e,t,n){return new e({type:`array`,element:t,...H(n)})}function oT(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...H(n)})}function sT(e,t){let n=cT(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(xb(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(xb(r))}},e(t.value,t)),t);return n}function cT(e,t){let n=new Yx({check:`custom`,...H(t)});return n._zod.check=e,n}function lT(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Uy(e,t,n[t]);return e}function uT(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??aw,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function dT(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function fT(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,fT(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&lT(o.schema,c),t.io===`input`&&ST(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function pT(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function mT(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${pT(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+pT(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
97
97
 
98
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function hT(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;hT(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var gT=new Set([`type`,`properties`,`required`,`additionalProperties`]),_T=[`oneOf`,`anyOf`];function vT(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function yT(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!gT.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??vT(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Uy(n,r,e.length===1?e[0]:yT(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=vT(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function bT(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of gT)if(t in e)return;let n=t.filter(e=>_T.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=yT(t);else{let e=n[0],i=_T.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>yT([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,lT(e,r))}function xT(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):lT(i,s),lT(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())hT(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])bT(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}lT(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Uy(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:wT(t,`input`,e.processors),output:wT(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function ST(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return ST(r.element,n);if(r.type===`set`)return ST(r.valueType,n);if(r.type===`lazy`)return ST(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return ST(r.innerType,n);if(r.type===`intersection`)return ST(r.left,n)||ST(r.right,n);if(r.type===`record`||r.type===`map`)return ST(r.keyType,n)||ST(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:ST(r.in,n)||ST(r.out,n);if(r.type===`object`){for(let e in r.shape)if(ST(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(ST(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(ST(e,n))return!0;return!!(r.rest&&ST(r.rest,n))}return!1}var CT=(e,t={})=>n=>{let r=uT({...n,processors:t});return fT(e,r),mT(r,e),xT(r,e)},wT=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=uT({...i??{},target:a,io:t,processors:n});return fT(e,o),mT(o,e),xT(o,e)},TT={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ET=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=TT[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},DT=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(Number.isFinite(c)&&c!==0?i.multipleOf=Math.abs(c):dT(e,t,i,r,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`))},OT=(e,t,n,r)=>{n.type=`boolean`},kT=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},AT=(e,t,n,r)=>{n.not={}},jT=(e,t,n,r)=>{let i=e._zod.def,a=Iy(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},MT=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(dT(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(dT(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},NT=(e,t,n,r)=>{dT(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},PT=(e,t,n,r)=>{dT(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},FT=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=fT(a.element,t,{...r,path:[...r.path,`items`]})};function IT(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?IT(t.out):t.type===`catch`?IT(t.innerType):e._zod.optin}var LT=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&dT(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Uy(i.properties,e,fT(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e];return t.io===`input`?IT(n)===void 0:n._zod.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=fT(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},RT=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>fT(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},zT=(e,t,n,r)=>{let i=e._zod.def,a=fT(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=fT(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function BT(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=BT(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>BT(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i?(p.type=`string`,a||(p.pattern=(r.includes(`number`)?Wx:Ux).source),p):p}var VT=new WeakMap;function HT(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of VT.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=BT(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var UT=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=fT(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)Uy(i.patternProperties,t.source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=fT(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=VT.get(t);n||(n=[],VT.set(t,n),t.deferred.push(()=>HT(t))),n.push(e)}i.additionalProperties=fT(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&IT(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},WT=(e,t,n,r)=>{let i=e._zod.def,a=fT(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},GT=(e,t,n,r)=>{let i=e._zod.def;fT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},KT=Symbol();function qT(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(dT(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),KT):JSON.parse(o)}var JT=(e,t,n,r)=>{let i=e._zod.def;fT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=qT(i.defaultValue,e,t,n,r);o!==KT&&(n.default=o)},YT=(e,t,n,r)=>{let i=e._zod.def;fT(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=qT(i.defaultValue,e,t,n,r);o!==KT&&(n._prefault=o)},XT=(e,t,n,r)=>{let i=e._zod.def;fT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{dT(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},ZT=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;fT(o,t,r);let s=t.seen.get(e);s.ref=o},QT=(e,t,n,r)=>{let i=e._zod.def;fT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},$T=(e,t,n,r)=>{let i=e._zod.def;fT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},eE=new WeakSet([Object.prototype,Error.prototype]);function tE(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var nE=U(`ZodError`,(e,t)=>{Yb.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);eE.has(n)||(eE.add(n),tE(n,`format`,e=>t=>$b(e,t)),tE(n,`flatten`,e=>t=>Qb(e,t)),tE(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ry,2)}),tE(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ry,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),rE=tx(nE),iE=nx(nE),aE=rx(nE),oE=ax(nE),sE=sx(nE),cE=cx(nE),lE=lx(nE),uE=ux(nE),dE=dx(nE),fE=fx(nE),pE=px(nE),mE=mx(nE);function hE(){Bb.localeError||Vb(tw())}function gE(){Bb.memoizer||Vb({memoizer:QC()})}var _E=U(`ZodType`,(e,t)=>(hE(),hS.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Wy(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return eb(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(LD(e,t))},superRefine(e,t){return this.check(RD(e,t))},overwrite(e){return this.check($w(e))},optional(){return yD(this)},exactOptional(){return xD(this)},nullable(){return CD(this)},nullish(){return yD(CD(this))},nonoptional(e){return kD(this,e)},array(){return G(this)},or(e){return oD([this,e])},and(e){return uD(this,e)},transform(e){return ND(this,_D(e))},default(e){return TD(this,e)},prefault(e){return DD(this,e)},catch(e){return jD(this,e)},pipe(e){return ND(this,e)},readonly(){return FD(this)},describe(e){let t=this.clone();return aw.add(t,{description:e}),t},meta(...e){if(e.length===0)return aw.get(this);let t=this.clone();return aw.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return wb(this,`~standard`,{..._S(this),jsonSchema:{input:wT(this,`input`),output:wT(this,`output`)}})},set"~standard"(e){Cb(this,`~standard`,e)},parse:function e(t,n){return rE(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await iE(this,t,n,{callee:e})},safeParse(e,t){return aE(this,e,t)},async safeParseAsync(e,t){return oE(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Cb(this,`spa`,e)},encode:function e(t,n){return sE(this,t,n,{callee:e})},decode:function e(t,n){return cE(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await lE(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await uE(this,t,n,{callee:e})},safeEncode(e,t){return dE(this,e,t)},safeDecode(e,t){return fE(this,e,t)},async safeEncodeAsync(e,t){return pE(this,e,t)},async safeDecodeAsync(e,t){return mE(this,e,t)},toJSONSchema(e){return CT(this,{})(e)},get description(){return aw.get(this)?.description},get _def(){return this._zod.def}}),vE=U(`_ZodString`,(e,t)=>{vS.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ET(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null},{regex(...e){return this.check(qw(...e))},includes(...e){return this.check(Xw(...e))},startsWith(...e){return this.check(Zw(...e))},endsWith(...e){return this.check(Qw(...e))},min(...e){return this.check(Gw(...e))},max(...e){return this.check(Ww(...e))},length(...e){return this.check(Kw(...e))},nonempty(...e){return this.check(Gw(1,...e))},lowercase(e){return this.check(Jw(e))},uppercase(e){return this.check(Yw(e))},trim(){return this.check(tT())},normalize(...e){return this.check(eT(...e))},toLowerCase(){return this.check(nT())},toUpperCase(){return this.check(rT())},slugify(){return this.check(iT())}}),yE=U(`ZodString`,(e,t)=>{vS.init(e,t),vE.init(e,t)},{email(e){return this.check(sw(TE,e))},url(e){return this.check(pw(kE,e))},jwt(e){return this.check(Ow(WE,e))},emoji(e){return this.check(mw(AE,e))},guid(e){return this.check(cw(EE,e))},uuid(e){return this.check(lw(DE,e))},uuidv4(e){return this.check(uw(DE,e))},uuidv6(e){return this.check(dw(DE,e))},uuidv7(e){return this.check(fw(DE,e))},nanoid(e){return this.check(hw(jE,e))},cuid(e){return this.check(gw(ME,e))},cuid2(e){return this.check(_w(NE,e))},ulid(e){return this.check(vw(PE,e))},base64(e){return this.check(Tw(VE,e))},base64url(e){return this.check(Ew(HE,e))},xid(e){return this.check(yw(FE,e))},ksuid(e){return this.check(bw(IE,e))},ipv4(e){return this.check(xw(LE,e))},ipv6(e){return this.check(Sw(RE,e))},cidrv4(e){return this.check(Cw(zE,e))},cidrv6(e){return this.check(ww(BE,e))},e164(e){return this.check(Dw(UE,e))},datetime(e){return this.check(kw(xE,e))},date(e){return this.check(Aw(SE,e))},time(e){return this.check(jw(CE,e))},duration(e){return this.check(Mw(wE,e))}});function W(e){return ow(yE,e)}var bE=U(`ZodStringFormat`,(e,t)=>{yS.init(e,t),vE.init(e,t)}),xE=U(`ZodISODateTime`,(e,t)=>{IS.init(e,t),bE.init(e,t)}),SE=U(`ZodISODate`,(e,t)=>{LS.init(e,t),bE.init(e,t)}),CE=U(`ZodISOTime`,(e,t)=>{RS.init(e,t),bE.init(e,t)}),wE=U(`ZodISODuration`,(e,t)=>{zS.init(e,t),bE.init(e,t)}),TE=U(`ZodEmail`,(e,t)=>{SS.init(e,t),bE.init(e,t)}),EE=U(`ZodGUID`,(e,t)=>{bS.init(e,t),bE.init(e,t)}),DE=U(`ZodUUID`,(e,t)=>{xS.init(e,t),bE.init(e,t)});function OE(e){return lw(DE,e)}var kE=U(`ZodURL`,(e,t)=>{OS.init(e,t),bE.init(e,t)}),AE=U(`ZodEmoji`,(e,t)=>{kS.init(e,t),bE.init(e,t)}),jE=U(`ZodNanoID`,(e,t)=>{AS.init(e,t),bE.init(e,t)}),ME=U(`ZodCUID`,(e,t)=>{jS.init(e,t),bE.init(e,t)}),NE=U(`ZodCUID2`,(e,t)=>{MS.init(e,t),bE.init(e,t)}),PE=U(`ZodULID`,(e,t)=>{NS.init(e,t),bE.init(e,t)}),FE=U(`ZodXID`,(e,t)=>{PS.init(e,t),bE.init(e,t)}),IE=U(`ZodKSUID`,(e,t)=>{FS.init(e,t),bE.init(e,t)}),LE=U(`ZodIPv4`,(e,t)=>{BS.init(e,t),bE.init(e,t)}),RE=U(`ZodIPv6`,(e,t)=>{US.init(e,t),bE.init(e,t)}),zE=U(`ZodCIDRv4`,(e,t)=>{WS.init(e,t),bE.init(e,t)}),BE=U(`ZodCIDRv6`,(e,t)=>{KS.init(e,t),bE.init(e,t)}),VE=U(`ZodBase64`,(e,t)=>{JS.init(e,t),bE.init(e,t)}),HE=U(`ZodBase64URL`,(e,t)=>{XS.init(e,t),bE.init(e,t)}),UE=U(`ZodE164`,(e,t)=>{ZS.init(e,t),bE.init(e,t)}),WE=U(`ZodJWT`,(e,t)=>{$S.init(e,t),bE.init(e,t)}),GE=U(`ZodNumber`,(e,t)=>{eC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>DT(e,t,n,r);let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null},{gt(e,t){return this.check(Vw(e,t))},gte(e,t){return this.check(Hw(e,t))},min(e,t){return this.check(Hw(e,t))},lt(e,t){return this.check(zw(e,t))},lte(e,t){return this.check(Bw(e,t))},max(e,t){return this.check(Bw(e,t))},int(e){return this.check(JE(e))},safe(e){return this.check(JE(e))},positive(e){return this.check(Vw(0,e))},nonnegative(e){return this.check(Hw(0,e))},negative(e){return this.check(zw(0,e))},nonpositive(e){return this.check(Bw(0,e))},multipleOf(e,t){return this.check(Uw(e,t))},step(e,t){return this.check(Uw(e,t))},finite(){return this}});function KE(e){return Nw(GE,e)}var qE=U(`ZodNumberFormat`,(e,t)=>{tC.init(e,t),GE.init(e,t)});function JE(e){return Pw(qE,e)}var YE=U(`ZodBoolean`,(e,t)=>{nC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>OT(e,t,n,r)});function XE(e){return Fw(YE,e)}var ZE=U(`ZodNull`,(e,t)=>{rC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kT(e,t,n,r)});function QE(e){return Iw(ZE,e)}var $E=U(`ZodUnknown`,(e,t)=>{iC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function eD(){return Lw($E)}var tD=U(`ZodNever`,(e,t)=>{aC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>AT(e,t,n,r)});function nD(e){return Rw(tD,e)}var rD=U(`ZodArray`,(e,t)=>{gE(),sC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>FT(e,t,n,r),e.element=t.element},{min(e,t){return this.check(Gw(e,t))},nonempty(e){return this.check(Gw(1,e))},max(e,t){return this.check(Ww(e,t))},length(e,t){return this.check(Kw(e,t))},unwrap(){return this.element}});function G(e,t){return aT(rD,e,t)}var iD=U(`ZodObject`,(e,t)=>{gE(),mC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>LT(e,t,n,r),jb(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return q(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:eD()})},loose(){return this.clone({...this._zod.def,catchall:eD()})},strict(){return this.clone({...this._zod.def,catchall:nD()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return ob(this,e)},safeExtend(e){return sb(this,e)},merge(e){return cb(this,e)},pick(e){return ib(this,e)},omit(e){return ab(this,e)},partial(...e){return lb(vD,this,e[0])},exactPartial(...e){return lb(bD,this,e[0],`exactPartial`)},required(...e){return ub(OD,this,e[0])}});function K(e,t){return new iD({type:`object`,shape:e??{},...H(t)})}var aD=U(`ZodUnion`,(e,t)=>{gC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>RT(e,t,n,r),e.options=t.options});function oD(e,t){return new aD({type:`union`,options:e,...H(t)})}var sD=U(`ZodDiscriminatedUnion`,(e,t)=>{aD.init(e,t),_C.init(e,t)});function cD(e,t,n){return new sD({type:`union`,options:t,discriminator:e,...H(n)})}var lD=U(`ZodIntersection`,(e,t)=>{vC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zT(e,t,n,r)});function uD(e,t){return new lD({type:`intersection`,left:e,right:t})}var dD=U(`ZodRecord`,(e,t)=>{gE(),xC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>UT(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function fD(e,t,n){return!t||!t._zod?new dD({type:`record`,keyType:W(),valueType:e,...H(t)}):new dD({type:`record`,keyType:e,valueType:t,...H(n)})}var pD=U(`ZodEnum`,(e,t)=>{SC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jT(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new pD({...t,checks:[],...H(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new pD({...t,checks:[],...H(r),entries:i})}});function q(e,t){return new pD({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...H(t)})}var mD=U(`ZodLiteral`,(e,t)=>{CC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>MT(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function hD(e,t){return new mD({type:`literal`,values:Array.isArray(e)?e:[e],...H(t)})}var gD=U(`ZodTransform`,(e,t)=>{gE(),wC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>PT(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new zb(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(xb(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(xb(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function _D(e){return new gD({type:`transform`,transform:e})}var vD=U(`ZodOptional`,(e,t)=>{EC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$T(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function yD(e){return new vD({type:`optional`,innerType:e})}var bD=U(`ZodExactOptional`,(e,t)=>{DC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$T(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function xD(e){return new bD({type:`optional`,innerType:e})}var SD=U(`ZodNullable`,(e,t)=>{OC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>WT(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function CD(e){return new SD({type:`nullable`,innerType:e})}var wD=U(`ZodDefault`,(e,t)=>{kC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>JT(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function TD(e,t){return new wD({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Zy(t)}})}var ED=U(`ZodPrefault`,(e,t)=>{jC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>YT(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function DD(e,t){return new ED({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Zy(t)}})}var OD=U(`ZodNonOptional`,(e,t)=>{MC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>GT(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function kD(e,t){return new OD({type:`nonoptional`,innerType:e,...H(t)})}var AD=U(`ZodCatch`,(e,t)=>{FC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>XT(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function jD(e,t){return new AD({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Nb(t)})}var MD=U(`ZodPipe`,(e,t)=>{IC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ZT(e,t,n,r),e.in=t.in,e.out=t.out});function ND(e,t){return new MD({type:`pipe`,in:e,out:t})}var PD=U(`ZodReadonly`,(e,t)=>{RC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>QT(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function FD(e){return new PD({type:`readonly`,innerType:e})}var ID=U(`ZodCustom`,(e,t)=>{BC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>NT(e,t,n,r)});function LD(e,t={}){return oT(ID,e,t)}function RD(e,t){return sT(e,t)}function zD(e){return kw(xE,e)}var BD=[`16:9`,`9:16`],VD=[`research`,`article`,`audio`,`images`,`thumbnail`,`video`],HD=[`off`,`low`,`medium`,`high`,`xhigh`],UD=[`generate`,`provide`,`off`,`from_prompt`,`prompt_by_llm`],WD=[`text`,`llm`],GD=W().min(1),KD=W().regex(/^[a-f0-9]{64}$/),qD=q([`audio`,`images`,`video`]),JD=K({projectId:GD,revisionId:GD,checkpointId:GD,stage:qD,workId:GD,fingerprint:KD,state:q([`configured`,`pending-review`,`held`,`released`,`satisfied`,`invalidated`,`canceled`]),createdAt:zD(),approvedAt:zD().nullable()}).strict().readonly();K({projectId:GD,revisionId:GD,checkpoints:G(K({checkpointId:GD,stage:qD,workId:GD,fingerprint:KD,state:q([`configured`,`pending-review`,`held`])}).strict().readonly()).max(3).readonly(),createdAt:zD()}).strict().readonly();var YD=K({projectId:GD,revisionId:GD,checkpointId:GD,fingerprint:KD,idempotencyKey:OE(),approvedAt:zD()}).strict().readonly(),XD=[`whole`,`paragraph`,`words`,`characters`],ZD=[`off`,`files`,`burn-in`],QD=[`top`,`upper-middle`,`center`,`lower-middle`,`bottom`],$D=K({mode:q(ZD),language:hD(`en`).default(`en`),fontId:W().max(160).regex(/^[A-Za-z0-9_-]+$/).default(`default`),position:q(QD).default(`bottom`),fontSize:KE().int().min(16).max(120).default(48)}),eO={mode:`off`,language:`en`,fontId:`default`,fontSize:48,position:`bottom`},tO=K({provider:W(),model:W(),thinking:q(HD).optional()}),nO=K({name:W(),mode:q(WD)}),rO=K({checkpoints:G(qD).max(3).refine(e=>new Set(e).size===e.length).readonly().optional(),title:W(),format:q(BD),sources:K({research:q(UD),article:q(UD),audio:q(UD),images:q(UD),thumbnail:q(UD),video:q(UD)}),llm:tO.optional(),audio:tO.extend({voice:W()}).optional(),images:tO.optional(),articlePrompt:W().optional(),imagePrompts:G(K({name:W(),number:KE()})),thumbnailPrompt:W().optional(),intro:nO.optional(),outro:nO.optional(),values:fD(W(),W()),provided:K({research:W().optional(),article:W().optional(),audio:W().optional(),images:G(W()).optional(),thumbnail:W().optional()}),chunking:K({mode:q(XD),words:KE().optional(),characters:KE().int().min(1).max(1e6).optional()}).optional(),silenceGapSeconds:KE(),subtitles:$D.optional()}),iO=rO.extend({rendered:fD(W(),W())}),aO=[`article`,`image`,`thumbnail`],oO=[`intro`,`outro`],sO=1e5;K({id:W(),kind:q(aO),name:W(),body:W(),slots:W(),updated_at:W()}),K({id:W(),category:q(oO),mode:q(WD),name:W(),body:W(),slots:W(),updated_at:W()});var cO=K({id:W(),name:W(),body:W(),slots:G(W()).readonly(),updatedAt:W()}),lO=K({prompts:G(cO.extend({kind:q(aO)}).strict().readonly()).readonly(),entries:G(cO.extend({category:q(oO),mode:q(WD)}).strict().readonly()).readonly()}).strict().readonly(),uO=OE(),dO=W(),fO=fD(dO,dO).readonly(),pO=K({provider:dO,model:dO,thinking:q(HD).optional()}).strict(),mO=K({attachmentId:uO,name:dO}).strict().readonly(),hO=K({title:dO,checkpoints:rO.shape.checkpoints,format:q(BD),sources:K({research:q(UD),article:q(UD),audio:q(UD),images:q(UD),thumbnail:q(UD),video:q(UD)}).strict().readonly(),llm:pO.readonly(),audio:pO.extend({voice:dO}).readonly(),images:pO.readonly(),articlePrompt:dO,imagePrompts:G(K({name:dO,number:dO}).strict().readonly()).readonly(),thumbnailPrompt:dO,intro:dO,outro:dO,chunking:K({mode:q(XD),words:dO,characters:dO}).strict().readonly(),subtitles:K({mode:q(ZD),language:hD(`en`),fontId:dO,fontSize:dO,position:q(QD)}).strict().readonly(),values:fO,provided:K({research:dO,article:dO,audio:mO.nullable(),thumbnail:mO.nullable(),images:G(mO).readonly()}).strict().readonly()}).strict().readonly(),gO=K({schemaVersion:hD(1),librarySnapshot:lO.optional(),templateSource:K({id:uO,version:KE().int().positive()}).strict().readonly().optional(),form:hO,section:q([`content`,`outputs`,`style`,`review`]),variants:G(K({id:uO,title:dO,values:fO}).strict().readonly()).readonly(),expectedWords:dO,previewText:dO,fontUpload:K({operationId:uO,name:dO}).strict().readonly().nullable()}).strict().readonly(),_O=K({id:uO,document:gO}).strict().readonly(),vO=_O.unwrap().extend({baseVersion:KE().int().positive(),mutationId:uO}).strict().readonly(),yO=_O.unwrap().extend({sourceId:uO}).strict().readonly(),bO=K({id:uO,baseVersion:KE().int().positive()}).strict().readonly(),xO=K({id:uO,kind:q([`audio`,`images`,`thumbnail`]),name:dO,state:q([`pending`,`copying`,`ready`,`reattach`]),stagedFileId:dO.nullable(),bytes:KE().nonnegative(),error:dO.nullable()}).strict().readonly(),SO=K({id:uO,version:KE().int().positive(),createdAt:dO,updatedAt:dO,document:gO}).strict().readonly(),CO=K({checkpointSet:G(JD.unwrap().extend({reviewedFingerprint:dO}).strict().readonly()).readonly().optional(),requestId:uO,projectIds:G(dO).readonly(),queue:G(K({projectId:dO,batchId:dO,position:KE(),state:q([`queued`,`active`,`finished`])}).strict().readonly()).readonly(),replayed:XE()}).strict().readonly(),wO=K({currency:hD(`USD`),rows:G(K({stage:dO,low:KE().nullable(),high:KE().nullable(),detail:dO}).strict().readonly()).readonly(),low:KE(),high:KE(),unknown:KE(),expectedWords:KE(),catalogueDate:dO.nullable(),assumptions:G(dO).readonly()}).strict().readonly(),TO=K({checkpointSet:G(K({runIndex:KE().int().nonnegative(),checkpointId:dO,stage:qD,fingerprint:dO,workKeys:G(dO).readonly(),dependents:G(q([`research`,`article`,`audio`,`images`,`thumbnail`,`video`])).readonly()}).strict().readonly()).readonly().optional(),id:uO,draftId:uO,draftVersion:KE().int().positive(),fingerprint:dO,runs:G(K({draft:rO,rendered:fO,templates:fO}).strict().readonly()).readonly(),estimates:G(wO).readonly()}).strict().readonly(),EO=K({draft:SO,attachments:G(xO).readonly(),review:TO.nullable(),pendingStart:K({reviewId:uO,draftVersion:KE().int().positive()}).strict().readonly().nullable(),start:CO.nullable()}).strict().readonly(),DO=K({title:W(),status:KE(),detail:W().optional(),reason:W().optional(),currentVersion:KE().int().positive().nullable().optional(),reviewId:OE().optional(),fields:G(K({field:W(),message:W()})).optional(),errors:G(K({path:W(),message:W()})).optional()}),OO=K({drafts:G(K({id:OE(),title:W(),version:KE().int().positive(),updatedAt:W(),readable:XE()}).strict()).readonly()}).strict(),kO=bO.unwrap().omit({id:!0}).extend({draftId:OE(),reviewId:OE()}).strict();async function AO(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=DO.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,currentVersion:i.currentVersion??null,fields:i.fields??i.errors?.map(e=>({field:e.path,message:e.message}))??[],...i.reviewId===void 0?{}:{reviewId:i.reviewId}}}async function jO(e,t,n,r,i){return AO(await e.fetch(`${e.origin}/api/drafts${t}`,{method:n,...i===void 0?{}:{headers:{"content-type":`application/json`},body:JSON.stringify(i)}}),r)}function MO(e){return`/${encodeURIComponent(OE().parse(e))}`}async function NO(e){return jO(e,``,`GET`,OO)}async function PO(e,t){return jO(e,``,`POST`,EO,_O.parse(t))}async function FO(e,t){return jO(e,MO(t),`GET`,EO)}async function IO(e,t){let{id:n,...r}=vO.parse(t);return jO(e,MO(n),`PUT`,EO,r)}async function LO(e,t){let{sourceId:n,...r}=yO.parse(t);return jO(e,`${MO(n)}/fork`,`POST`,EO,r)}async function RO(e,t){let{id:n,...r}=bO.parse(t);return jO(e,MO(n),`DELETE`,K({discarded:hD(!0)}).strict(),r)}async function zO(e,t){let{id:n,...r}=bO.parse(t);return jO(e,`${MO(n)}/review`,`POST`,TO,r)}async function BO(e,t){let{draftId:n,...r}=kO.parse(t);return jO(e,`${MO(n)}/start`,`POST`,CO,r)}function VO(e,t,n){return`${e.origin}/api/drafts${MO(t)}/attachments/${encodeURIComponent(OE().parse(n))}/file`}async function HO(e,t,n,r,i){let a=new FormData;return a.set(`file`,r),AO(await e.fetch(VO(e,t,n),{method:`PUT`,body:a,...i?{signal:i}:{}}),xO)}var UO=[`fonts`];async function WO(e){return eo(await e.fetch(`${e.origin}/api/fonts`))}async function GO(e,t){let n=new FormData;return n.set(`file`,t),eo(await e.fetch(`${e.origin}/api/fonts`,{method:`POST`,body:n}))}function KO(e,t){return`${e.origin}/api/fonts/${encodeURIComponent(t)}/file`}var qO=`slopify.play-draft`;function JO(e){try{e?window.localStorage?.setItem(qO,e):window.localStorage?.removeItem(qO)}catch(e){console.warn(`Active draft browser storage is unavailable`,e)}}function YO(){try{return window.localStorage?.getItem(qO)??null}catch(e){return console.warn(`Active draft browser storage is unavailable`,e),null}}async function XO(e,t){let n=await Promise.allSettled([t.fetchQuery({...vy(e),staleTime:0}),t.fetchQuery({...by(e),staleTime:0}),t.fetchQuery({...xy(e),staleTime:0}),t.fetchQuery({...Sy(e),staleTime:0}),t.fetchQuery({...yy(e),staleTime:0}),t.fetchQuery({queryKey:UO,queryFn:()=>WO(e),staleTime:0})]);for(let e of n)e.status===`rejected`&&console.warn(`Draft choices could not refresh`,e.reason)}var ZO={research:[`off`,`generate`,`provide`],article:[`generate`,`provide`],audio:[`off`,`generate`,`provide`],images:[`off`,`generate`,`provide`],thumbnail:[`off`,`from_prompt`,`prompt_by_llm`,`provide`],video:[`off`,`generate`]};function QO(e){let t=[],n=$O(e.draft),{sources:r}=n;n.title===``?t.push({field:`title`,message:`A title is required.`}):n.title.length>200&&t.push({field:`title`,message:`A title is at most 200 characters.`});for(let e of VD)ZO[e].includes(r[e])||t.push({field:`sources.${e}`,message:`The ${e} stage cannot be set to ${r[e]}.`});(r.research===`generate`||r.article===`generate`||r.thumbnail===`prompt_by_llm`||n.intro?.mode===`llm`||n.outro?.mode===`llm`)&&!ak(n.llm)&&t.push({field:`llm`,message:`Pick an LLM provider and model.`}),r.article===`generate`&&ik(n.articlePrompt)&&t.push({field:`articlePrompt`,message:`Pick an article prompt.`});let i=n.audio;return r.audio===`generate`&&(i===void 0||!ak(i)?t.push({field:`audio`,message:`Pick a narration provider and model.`}):i.voice.trim()===``&&t.push({field:`audio.voice`,message:`Pick a voice.`})),r.images===`generate`&&ek(n,t),(r.images===`generate`||r.thumbnail===`from_prompt`||r.thumbnail===`prompt_by_llm`)&&!ak(n.images)&&t.push({field:`images`,message:`Pick an image provider and model.`}),(r.thumbnail===`from_prompt`||r.thumbnail===`prompt_by_llm`)&&ik(n.thumbnailPrompt)&&t.push({field:`thumbnailPrompt`,message:`Pick a thumbnail prompt.`}),r.audio===`off`&&n.subtitles!==void 0&&n.subtitles.mode!==`off`&&t.push({field:`subtitles.mode`,message:`Subtitles need narration audio.`}),tk(n,e.staged,t),rk(n,e.requiredSlots,t),(!Number.isFinite(n.silenceGapSeconds)||n.silenceGapSeconds<0||n.silenceGapSeconds>30)&&t.push({field:`silenceGapSeconds`,message:`The silence gap is between 0 and 30 seconds.`}),t.length===0?{ok:!0,draft:n}:{ok:!1,fields:t}}function $O(e){let t={...e.sources};t.article===`provide`&&(t.research=`off`),t.images===`off`&&t.video===`generate`&&(t.video=`off`);let n=Object.create(null);for(let[t,r]of Object.entries(e.values))n[t]=r.trim();return{...e,title:e.title.trim(),subtitles:t.video===`off`&&e.subtitles?.mode===`burn-in`?{...e.subtitles,mode:`files`}:e.subtitles,sources:t,values:n,intro:t.audio===`generate`?e.intro:void 0,outro:t.audio===`generate`?e.outro:void 0}}function ek(e,t){if(e.imagePrompts.length===0){t.push({field:`imagePrompts`,message:`Tick at least one image prompt.`});return}let n=0;for(let[r,i]of e.imagePrompts.entries())n+=i.number,ik(i.name)&&t.push({field:`imagePrompts.${r}.name`,message:`Pick an image prompt.`}),(!Number.isInteger(i.number)||i.number<1||i.number>20)&&t.push({field:`imagePrompts.${r}.number`,message:`Number is between 1 and 20.`});n>60&&t.push({field:`imagePrompts`,message:`A run makes at most 60 images; this one asks for ${n}.`})}function tk(e,t,n){let{sources:r,provided:i}=e;if(r.research===`provide`&&ik(i.research)&&n.push({field:`provided.research`,message:`Paste the research notes.`}),r.article===`provide`&&ik(i.article)&&n.push({field:`provided.article`,message:`Paste the article.`}),r.audio===`provide`&&nk(t,i.audio,`audio`,`provided.audio`,`Pick an audio file.`,n),r.thumbnail===`provide`&&nk(t,i.thumbnail,`thumbnail`,`provided.thumbnail`,`Pick a thumbnail image.`,n),r.images===`provide`){let e=i.images??[];e.length===0?n.push({field:`provided.images`,message:`Pick at least one image.`}):e.length>60&&n.push({field:`provided.images`,message:`A run holds at most 60 images.`}),new Set(e).size!==e.length&&n.push({field:`provided.images`,message:`The same image was picked twice.`});for(let[r,i]of e.entries())nk(t,i,`images`,`provided.images.${r}`,`Pick an image.`,n)}}function nk(e,t,n,r,i,a){if(t===void 0||t===``){a.push({field:r,message:i});return}let o=e.find(e=>e.id===t);if(o===void 0||o.stageKind!==n){a.push({field:r,message:`That upload is no longer available; pick the file again.`});return}o.state!==`staged`&&a.push({field:r,message:`This upload is still copying.`})}function rk(e,t,n){for(let r of t){let t=Object.hasOwn(e.values,r)?e.values[r]:void 0;if(t===void 0||t===``){n.push({field:`values.${r}`,message:`This field is required.`});continue}t.length>200&&n.push({field:`values.${r}`,message:`A value is at most 200 characters.`}),/[\n\r]/.test(t)&&n.push({field:`values.${r}`,message:`A value is a single line.`})}}function ik(e){return e===void 0||e.trim()===``}function ak(e){return e!==void 0&&e.provider.trim()!==``&&e.model.trim()!==``}var ok=gO.parse({schemaVersion:1,form:{title:``,format:`16:9`,sources:{research:`off`,article:`generate`,audio:`generate`,images:`generate`,thumbnail:`off`,video:`generate`},llm:{provider:``,model:``},audio:{provider:``,model:``,voice:``},images:{provider:``,model:``},articlePrompt:``,imagePrompts:[],thumbnailPrompt:``,intro:``,outro:``,chunking:{mode:`whole`,words:`500`,characters:`3000`},subtitles:{...eO,fontSize:`48`},values:{},provided:{research:``,article:``,audio:null,images:[],thumbnail:null}},section:`content`,variants:[],expectedWords:`1500`,previewText:`Every story begins with a word.`,fontUpload:null});function sk(e){let t={...e.sources,...e.sources.article===`provide`?{research:`off`}:{},...e.sources.images===`off`?{video:`off`}:{}},n=t.audio===`off`?`off`:t.video===`off`&&e.subtitles.mode===`burn-in`?`files`:e.subtitles.mode;return{...e,sources:t,subtitles:{...e.subtitles,mode:n}}}function ck(e){let t=gO.parse(e);return JSON.stringify({...t,form:sk(t.form)})}function lk(e,t,n){return{...e,acknowledged:Math.max(e.acknowledged,t),version:n}}function uk(e,t){return t.type===`edit`?{...e,edited:e.edited+1}:lk(e,t.generation,t.version)}function dk(e,t,n){return{mutationId:n,document:gO.parse(JSON.parse(ck(e))),generation:t.edited,baseVersion:t.version}}function fk(){return{document:ok,view:null,clock:{edited:0,acknowledged:0,version:0},id:null,recoveryId:null,pending:null,status:`unsaved`,error:null,reveal:null}}function pk(e,t,n){let r=e.form.provided,i=t.form.provided,a=new Map;for(let[e,t]of[[r.audio,i.audio],[r.thumbnail,i.thumbnail],...r.images.map((e,t)=>[e,i.images[t]])])e&&t&&a.set(e.attachmentId,t.attachmentId);let o=e=>e?{...e,attachmentId:a.get(e.attachmentId)??e.attachmentId}:null;return{...n,form:{...n.form,provided:{...n.form.provided,audio:o(n.form.provided.audio),thumbnail:o(n.form.provided.thumbnail),images:n.form.provided.images.map(e=>({...e,attachmentId:a.get(e.attachmentId)??e.attachmentId}))}}}}function mk(e,t){if(e.draft.id!==t.id)return e;let n=t.document.form.provided,r=new Set([n.audio,n.thumbnail,...n.images].flatMap(e=>e?[e.attachmentId]:[]));return{...e,attachments:e.attachments.filter(e=>r.has(e.id)).map(e=>{let n=t.view?.attachments.find(t=>t.id===e.id);return(e.state===`pending`||e.state===`copying`)&&(n?.state===`ready`||n?.state===`reattach`)?n:e})}}function hk(e,t){return e?.draftId===t.draftId&&e.version===t.version&&e.editGeneration===t.editGeneration}function gk({api:e,queryClient:t,current:n,flush:r,render:i}){let a={receipt:null,pending:!1,starting:!1,uncertain:!1,valid:!1,error:null,fields:[],created:null},o,s=0,c=0,l=null,u=e=>{a={...a,...e},i()},d=()=>({draftId:n().id??``,version:n().clock.version,editGeneration:n().clock.edited}),f=()=>hk(o,d())&&n().clock.edited===n().clock.acknowledged,p=(e=!1)=>{s++,o=void 0,u({valid:!1,...e?{fields:[],error:null}:{}})},m=e=>u({error:e.message,fields:e.fields,valid:!1}),h=e=>{l=null,u({created:e,uncertain:!1,starting:!1,valid:!1})},g=async()=>{let t=l?.draftId;if(!t)return;let n=await FO(e,t);if(!n.ok){m(n);return}n.value.start&&h(n.value.start)};return{reset:()=>{s++,c++,o=void 0,l=null,a={receipt:null,pending:!1,starting:!1,uncertain:!1,valid:!1,error:null,fields:[],created:null},i()},state:()=>({...a,valid:a.valid&&f()}),invalidate:p,restore:e=>{s++,c++,o=void 0,l=e.pendingStart?{draftId:e.draft.id,baseVersion:e.pendingStart.draftVersion,reviewId:e.pendingStart.reviewId}:null,a={receipt:null,pending:!1,starting:!1,uncertain:l!==null,valid:!1,error:null,fields:[],created:e.start},i()},review:async()=>{if(a.pending||a.starting||a.uncertain||a.created)return;let i=++c;u({pending:!0,valid:!1,error:null,fields:[]});try{if(await Promise.all([XO(e,t),t.refetchQueries({queryKey:[`provider-models`]})]),i!==c||!await r()||!n().id)return;let a=d(),l=s,f=await zO(e,{id:a.draftId,baseVersion:a.version});if(i!==c||l!==s||!hk(a,d()))return;if(!f.ok){m(f);return}if(f.value.draftId!==a.draftId||f.value.draftVersion!==a.version)return;o=a,u({receipt:f.value,valid:!0})}catch(e){i===c&&u({error:e instanceof Error?e.message:`Couldn't review this draft`})}finally{i===c&&u({pending:!1})}},start:async()=>{if(a.starting||a.created||n().document.section!==`review`||!l&&(!a.valid||!f()||a.pending||!a.receipt||_k(n().document,n().view)!==void 0)||(!l&&a.receipt&&(l={draftId:a.receipt.draftId,baseVersion:a.receipt.draftVersion,reviewId:a.receipt.id}),!l))return;let t=l;JO(t.draftId),u({starting:!0,error:null});try{if(a.uncertain&&(await g(),a.created))return;let n=await BO(e,t);if(n.ok){h(n.value);return}n.reason===`pending-start`||n.reason===`already-started`?(u({uncertain:!0}),await g()):(l=null,u({uncertain:!1}),m(n))}catch(e){u({uncertain:!0,valid:!1,error:`${e instanceof Error?e.message:`Start response was lost`}. The result is uncertain. Check the same Start receipt before trying a new run.`})}finally{u({starting:!1})}}}}function _k(e,t){if(e.fontUpload!==null)return`subtitles.fontUpload`;let{sources:n,provided:r}=e.form;return[...n.audio===`provide`&&r.audio?[{ref:r.audio,field:`provided.audio`}]:[],...n.thumbnail===`provide`&&r.thumbnail?[{ref:r.thumbnail,field:`provided.thumbnail`}]:[],...n.images===`provide`?r.images.map((e,t)=>({ref:e,field:`provided.images.${t}`})):[]].find(({ref:e})=>t?.attachments.find(t=>t.id===e.attachmentId)?.state!==`ready`)?.field}function vk(e,t){return e?.draftId===t.draftId&&e.attachmentId===t.attachmentId}function yk({api:e,queryClient:t,state:n,edit:r,flush:i,generation:a,publish:o,render:s}){let c=(0,m.useRef)(0),l=(0,m.useRef)(null),u=(0,m.useRef)(null),d=(0,m.useRef)(new Map),f=(0,m.useRef)(new Map),p=e=>{let t=n.current.document.form.provided,r=[t.audio,t.thumbnail,...t.images].find(t=>t?.attachmentId===e.attachmentId);return vk(r&&n.current.id?{draftId:n.current.id,attachmentId:r.attachmentId}:void 0,e)};(0,m.useEffect)(()=>{for(let[e,t]of d.current)t!==a()&&d.current.delete(e);for(let[e,t]of f.current)(!p(t.owner)||t.generation!==a())&&(t.controller.abort(),f.current.delete(e))}),(0,m.useEffect)(()=>{let e=f.current,t=d.current;return()=>{c.current++,t.clear();for(let t of e.values())t.controller.abort();e.clear()}},[]);let h=async(t,l,u)=>{if(l.length===0)return;let m=t===`images`&&!u?l:l.slice(-1),h=m.map(e=>({attachmentId:crypto.randomUUID(),name:e.name})),g=c.current,_=a();for(let e of h)d.current.set(e.attachmentId,_);let v=n.current.document,y=v.form.provided;r({...v,form:{...v.form,provided:t===`images`?{...y,images:u?y.images.flatMap(e=>e.attachmentId===u?h:[e]):[...y.images,...h]}:{...y,[t]:h.at(-1)??null}}});let b=await i();for(let e of h)d.current.delete(e.attachmentId);if(!b||_!==a()||g!==c.current){s();return}let x=n.current.id;x&&await Promise.all(h.map(async(r,i)=>{let s=m[i],l={draftId:x,attachmentId:r.attachmentId};if(!s||!p(l))return;let u=new AbortController;f.current.set(r.attachmentId,{owner:l,controller:u,generation:_});let d=e=>{let t=n.current.view;_===a()&&g===c.current&&t?.draft.id===x&&p(l)&&!u.signal.aborted&&o({view:{...t,review:null,attachments:[...t.attachments.filter(e=>e.id!==r.attachmentId),e]}})};try{let n=await HO(e,x,r.attachmentId,s,u.signal);n.ok?d(n.value):d({id:r.attachmentId,kind:t,name:r.name,state:`reattach`,stagedFileId:null,bytes:0,error:n.message})}catch(e){d({id:r.attachmentId,kind:t,name:r.name,state:`reattach`,stagedFileId:null,bytes:0,error:e instanceof Error?e.message:`Reattach this file`})}finally{f.current.delete(r.attachmentId)}}))},g=e=>{l.current=null;let t=n.current.document;r({...t,fontUpload:null,form:{...t.form,subtitles:{...t.form.subtitles,fontId:e}}})},_=async o=>{let d=crypto.randomUUID();l.current=d,r({...n.current.document,fontUpload:{operationId:d,name:o.name}});let f=c.current,p=a();if(!await i()||p!==a()||f!==c.current){l.current===d&&(l.current=null),s();return}if(n.current.document.fontUpload?.operationId===d)try{let{font:r}=await GO(e,o);if(p!==a()||f!==c.current||n.current.document.fontUpload?.operationId!==d)return;t.setQueryData(UO,e=>({fonts:[...(e?.fonts??[]).filter(e=>e.id!==r.id),r]})),g(r.id),await i()}catch(e){p===a()&&f===c.current&&n.current.document.fontUpload?.operationId===d&&(u.current={operationId:d,message:e instanceof Error?e.message:`Reattach this font`},s())}finally{l.current===d&&(l.current=null,s())}},v=l.current!==null&&l.current===n.current.document.fontUpload?.operationId;return{attachmentUploading:e=>{let t=f.current.get(e);return d.current.get(e)===a()||t!==void 0&&t.generation===a()&&p(t.owner)&&!t.controller.signal.aborted},fontUpload:{pending:v,error:u.current?.operationId===n.current.document.fontUpload?.operationId?u.current?.message:void 0,pick:e=>{_(e)}},attach:h,selectFont:g,uploadSubtitleFont:_,fontUploading:v}}function bk(e,t,n){(0,m.useEffect)(()=>{let r=e=>[`prompts`,`entries`,`providers`,`provider-models`,`fonts`,`settings`].includes(String(e[0])),i=t.getQueryCache().subscribe(e=>{e.type===`updated`&&r(e.query.queryKey)&&(e.action.type===`success`||e.action.type===`invalidate`)&&n.invalidate()}),a=()=>{n.invalidate(),XO(e,t),t.refetchQueries({queryKey:[`provider-models`]})};return window.addEventListener(`focus`,a),()=>{i(),window.removeEventListener(`focus`,a)}},[e,t,n])}function xk(){let{api:e}=I(),t=_(),[,n]=(0,m.useReducer)(e=>e+1,0),r=(0,m.useRef)(fk()),i=(0,m.useMemo)(()=>{let i,a=null,o=!1,s=0,c=!1,l=null,u=!0,d=e=>{r.current={...r.current,...e},u&&n()},f=()=>{clearTimeout(i),i=void 0},p=()=>{t.invalidateQueries({queryKey:[`play-drafts`]})},m=e=>{d({status:`error`,error:e instanceof Error?e.message:`Couldn't save draft`})},h=e=>e.ok?!0:(d({status:e.reason===`conflict`?`conflict`:`error`,error:e.message}),!1),g=e=>{b.restore(e),d({...fk(),document:e.draft.document,view:e,id:e.draft.id,clock:{edited:0,acknowledged:0,version:e.draft.version},status:`saved`}),JO(e.draft.id),p()},_=async()=>{let t=s;for(;r.current.clock.edited>r.current.clock.acknowledged;){if(r.current.status===`conflict`||t!==s||l!==null&&l===r.current.id)return!1;let n=r.current,i=n.id??crypto.randomUUID(),a=n.pending??dk(n.document,n.clock,crypto.randomUUID());d({id:i,pending:a,status:`saving`,error:null});try{let n=a.baseVersion===0?await PO(e,{id:i,document:a.document}):await IO(e,{id:i,baseVersion:a.baseVersion,mutationId:a.mutationId,document:a.document});if(t!==s)return!1;if(!h(n))return n.reason!==`conflict`&&d({pending:null}),!1;let c=uk(r.current.clock,{type:`acknowledge`,generation:a.generation,version:n.value.draft.version});if(d({clock:c,view:{...mk(n.value,r.current),review:c.edited>c.acknowledged?null:n.value.review},pending:null,status:c.edited>c.acknowledged?`unsaved`:`saved`,error:null}),JO(i),p(),!o)return!0}catch(e){return t===s&&m(e),!1}}return r.current.status!==`conflict`&&r.current.status!==`error`},v=()=>c?Promise.resolve(!1):a||(r.current.clock.edited===r.current.clock.acknowledged?Promise.resolve(!0):l!==null&&l===r.current.id?Promise.resolve(!1):(a=_().finally(()=>{a=null}),a)),y=()=>(f(),o=!0,v()),b=gk({api:e,queryClient:t,current:()=>r.current,flush:y,render:()=>{u&&n()}}),x=e=>{if(b.state().starting||b.state().uncertain||b.state().created)return;b.invalidate(JSON.stringify({...e,section:r.current.document.section})!==JSON.stringify(r.current.document));let t=r.current;d({document:e,clock:uk(t.clock,{type:`edit`}),view:t.view?{...t.view,review:null}:null,status:t.status===`conflict`||t.status===`error`?t.status:`unsaved`}),f(),!(c||l!==null&&l===t.id||t.status===`conflict`||t.status===`error`)&&(t.id?i=setTimeout(()=>{y()},500):(o=!1,v()))},S=async(n,i=()=>!0)=>{if(b.state().starting||b.state().uncertain||b.state().created||(r.current.id!==n||r.current.status!==`conflict`)&&!await y()||!i())return!1;let a=++s,o=r.current.clock.edited;f();try{let c=await FO(e,n);return a!==s||o!==r.current.clock.edited||!i()?!1:h(c)?(T=null,g(c.value),await XO(e,t),i()):(r.current.id||d({recoveryId:n}),!1)}catch(e){return a===s&&o===r.current.clock.edited&&(m(e),r.current.id||d({recoveryId:n})),!1}},C=async()=>{if(b.state().starting||b.state().uncertain||b.state().created)return;let e=s;await y()&&e===s&&(s++,T=null,d(fk()),b.reset(),JO(null))},w=async({id:t,version:n})=>{if(b.state().starting||b.state().uncertain||b.state().created)throw Error(`Resolve the pending Start before discarding a draft`);if(c||l!==null)throw Error(`Wait for the current draft operation before discarding`);let i=s;l=t,(r.current.id??r.current.recoveryId)===t&&f();try{a&&await a;let o=await RO(e,{id:t,baseVersion:n});if(!o.ok&&o.reason!==`not-found`)throw Error(o.message);if(p(),i!==s||(r.current.id??r.current.recoveryId)!==t)return;f(),s++,T=null,d(fk()),b.reset(),JO(null)}finally{l=null}},T=null;return{review:b,takeCreated:()=>{let e=b.state().created;if(!e)return null;s++,d(fk()),b.reset(),JO(null);for(let e of[[`projects`],[`staging`],[`play-drafts`]])t.invalidateQueries({queryKey:e});return e},edit:x,flush:y,open:S,newDraft:C,discard:w,saveAsNew:async()=>{if(b.state().starting||b.state().uncertain||b.state().created||(f(),c||l!==null))return;a&&await a;let t=r.current;if(!t.id||!t.view&&t.status!==`conflict`){await y();return}let n=s;T?.sourceId!==t.id&&(T=null),T??={sourceId:t.id,id:crypto.randomUUID(),document:dk(t.document,t.clock,crypto.randomUUID()).document,generation:t.clock.edited};let i=T;c=!0;try{let t=await LO(e,{sourceId:i.sourceId,id:i.id,document:i.document});if(n!==s)return;if(!h(t)){t.reason===`conflict`&&(T=null);return}let a=r.current.clock.edited>i.generation?r.current.document:null;s++,g(t.value),T=null,c=!1,a&&x(pk(i.document,t.value.draft.document,a))}catch(e){n===s&&m(e)}finally{c=!1}},navigate:async(e,t)=>{let n=s,i={...r.current.document,section:e};r.current.id||r.current.clock.edited>0?x(i):d({document:i}),await y()&&n===s&&d({reveal:{section:e,...t===void 0?{}:{field:t},sequence:(r.current.reveal?.sequence??0)+1}})},generation:()=>s,publish:d,start:()=>{u=!0;let e=YO();e&&S(e)},stop:()=>{u=!1,f()}}},[e,t]);(0,m.useEffect)(()=>(i.start(),i.stop),[i]),bk(e,t,i.review);let a=yk({api:e,queryClient:t,state:r,edit:i.edit,flush:i.flush,generation:i.generation,publish:i.publish,render:n}),o=r.current;return{...a,review:i.review.state(),reviewDraft:i.review.review,startRun:i.review.start,invalidateReview:i.review.invalidate,takeCreated:i.takeCreated,document:o.document,section:o.document.section,view:o.view,status:o.status,error:o.error,edited:o.clock.edited,acknowledged:o.clock.acknowledged,reveal:o.reveal,edit:i.edit,flush:i.flush,open:i.open,generation:i.generation,newDraft:i.newDraft,discard:i.discard,saveAsNew:i.saveAsNew,navigate:i.navigate,activeId:o.id??o.recoveryId}}var Sk=(0,m.createContext)(null);function Ck({children:e}){let t=xk();return(0,h.jsx)(Sk.Provider,{value:t,children:e})}function wk(){let e=(0,m.useContext)(Sk);if(!e)throw Error(`PlayDraftProvider is required`);return e}var Tk=(0,m.createContext)(void 0);function Ek({children:e}){let[t,n]=(0,m.useState)(()=>new Map),r=(0,m.useCallback)((e,t)=>{n(n=>{let r=n.get(e),i=typeof t==`function`?t(r):t;if(r===i)return n;let a=new Map(n);return i===void 0?a.delete(e):a.set(e,i),a})},[]),i=(0,m.useMemo)(()=>({prompts:t,updatePrompt:r}),[t,r]);return(0,h.jsx)(Tk.Provider,{value:i,children:e})}function Dk(e){let t=(0,m.useContext)(Tk),[n,r]=(0,m.useState)(void 0),i=t?.updatePrompt,a=(0,m.useCallback)(t=>{i?i(e,t):r(t)},[e,i]);return[t?t.prompts.get(e):n,a]}function Ok(){let e=wk(),t=(0,m.useRef)(e);t.current=e;let n=e.document.form,r=t=>{if(!t)return;let n=e.view?.attachments.find(e=>e.id===t.attachmentId),r=n?.state===`ready`&&n.stagedFileId?{id:n.stagedFileId,stageKind:n.kind,path:n.stagedFileId,originalFilename:n.name,bytes:n.bytes,state:`staged`,createdAt:e.view?.draft.createdAt??``}:void 0;return{key:t.attachmentId,name:t.name,file:r,error:n?.error??(n?.state===`reattach`||!r&&!e.attachmentUploading(t.attachmentId)?`Reattach this file`:void 0)}},i={...n,imagePrompts:n.imagePrompts.map(e=>({...e,number:Number(e.number)})),chunking:n.chunking.mode===`words`?{mode:`words`,...n.chunking.words===``?{}:{words:Number(n.chunking.words)}}:n.chunking.mode===`characters`?{mode:`characters`,...n.chunking.characters===``?{}:{characters:Number(n.chunking.characters)}}:{mode:n.chunking.mode},subtitles:{...n.subtitles,fontSize:Number(n.subtitles.fontSize)},provided:{...n.provided,audio:r(n.provided.audio),thumbnail:r(n.provided.thumbnail),images:n.provided.images.flatMap(e=>{let t=r(e);return t?[t]:[]})}},a=(0,m.useRef)(i);return a.current=i,[i,(0,m.useCallback)(e=>{let n=t.current.document,r=typeof e==`function`?e(a.current):e;a.current=r;let i=(e,t)=>e===void 0?``:Object.is(e,Number(t))?t:String(e),o=e=>e?{attachmentId:e.key,name:e.name}:null;t.current.edit({...n,form:{...r,imagePrompts:r.imagePrompts.map(e=>({...e,number:i(e.number,n.form.imagePrompts.find(t=>t.name===e.name)?.number??String(e.number))})),chunking:{...n.form.chunking,mode:r.chunking.mode,...r.chunking.mode===`words`?{words:i(r.chunking.words,n.form.chunking.words)}:{},...r.chunking.mode===`characters`?{characters:i(r.chunking.characters,n.form.chunking.characters)}:{}},subtitles:{...n.form.subtitles,...r.subtitles,fontSize:i(r.subtitles.fontSize,n.form.subtitles.fontSize)},provided:{...r.provided,audio:o(r.provided.audio),thumbnail:o(r.provided.thumbnail),images:r.provided.images.map(e=>({attachmentId:e.key,name:e.name}))}}})},[])]}function kk(e,t){if(e===void 0)return;if(t.type===`project.state`)return{...e,project:{...e.project,status:t.state}};let n=e.stages.findIndex(e=>e.kind===t.stage),r=e.stages[n];return r===void 0?e:{...e,stages:e.stages.with(n,Ak(r,t))}}function Ak(e,t){return t.type===`stage.progress`?{...e,progressCurrent:t.current,progressTotal:t.total}:{...e,state:t.state,failureReason:t.failureReason??e.failureReason}}function jk(e,t){let n,r=!1,i=()=>{n=void 0,r&&(r=!1,e(),a())},a=()=>{n=setTimeout(i,t)};return{ask:()=>{if(n!==void 0){r=!0;return}e(),a()},stop:()=>{n!==void 0&&clearTimeout(n),n=void 0,r=!1}}}var Mk=[{id:`text-key`,title:`1. Connect a text provider`,target:`keys-llm`,page:`settings`},{id:`audio-key`,title:`2. Connect a voice provider`,target:`keys-tts`,page:`settings`},{id:`image-key`,title:`3. Connect an image provider`,target:`keys-image`,page:`settings`},{id:`voice`,title:`4. Add a narration voice`,target:`voices`,page:`settings`},{id:`article-name`,title:`5. Name your article prompt`,target:`prompt-name`,page:`article`},{id:`article-body`,title:`6. Write instructions with keywords`,target:`prompt-body`,page:`article`},{id:`article-keywords`,title:`7. Check the detected keywords`,target:`prompt-slots`,page:`article`},{id:`article-save`,title:`8. Save your article prompt`,target:`prompt-save`,page:`article`},{id:`image-prompt`,title:`9. Create an image prompt`,target:`prompt-editor`,page:`image`},{id:`image-save`,title:`10. Save your image prompt`,target:`prompt-save`,page:`image`},{id:`play-options`,title:`11. Name the project and choose text generation`,target:`play-options`,page:`play`},{id:`play-article`,title:`12. Choose your article`,target:`play-article`,page:`play`},{id:`play-keywords`,title:`13. Fill in your keywords`,target:`play-keywords`,page:`play`},{id:`play-audio`,title:`14. Choose narration`,target:`play-audio`,page:`play`},{id:`play-images`,title:`15. Choose images`,target:`play-images`,page:`play`},{id:`play-video`,title:`16. Choose video output`,target:`play-video`,page:`play`},{id:`play-subtitles`,title:`17. Style optional subtitles`,target:`play-subtitles`,page:`play`},{id:`play-start`,title:`18. Review and start your run`,target:`play-start`,page:`play`},{id:`project`,title:`19. Follow and control the run`,target:`project-controls`,page:`project`},{id:`download`,title:`20. Download your results`,target:`project-video`,page:`project`}];function Nk(e,t){return e.active?t.type===`project-created`?{...e,projectId:t.id,step:Mk.findIndex(e=>e.id===`project`)}:t.kind===`article`?{...e,articleId:t.id}:t.kind===`image`?{...e,imageId:t.id}:e:e}function Pk(e){let t=Mk.findIndex(t=>t.id===e);return t<0?void 0:t}var Fk={"play-options":`content`,"play-article":`content`,"play-keywords":`content`,"play-audio":`outputs`,"play-images":`outputs`,"play-video":`outputs`,"play-subtitles":`style`,"play-start":`review`};function Ik(e){return e.kind===`keyed`?e.hasKey:e.installed&&e.issue===void 0}var Lk={research:`Research`,article:`Article`,audio:`Audio`,images:`Images`,thumbnail:`Thumbnail`,video:`Video`};function Rk(e){return e.sources.video===`off`?e.sources.audio===`off`?`article`:`audio`:`video`}function zk(e,t){return e===`video`&&Rk(t)===`audio`?`Audio export`:Lk[e]}function Bk(e,t){return e.kind===`video`&&e.state===`running`&&t.subtitles!==void 0&&t.subtitles.mode!==`off`&&e.progressTotal===100&&(e.progressCurrent??0)<=35}var Vk={research:(e,t)=>`chapter ${String(e)} of ${String(t)}`,article:(e,t)=>`${String(e)} of ${String(t)}`,audio:(e,t)=>`chunk ${String(e)} of ${String(t)}`,images:(e,t)=>`image ${String(e)} of ${String(t)}`,thumbnail:(e,t)=>`${String(e)} of ${String(t)}`,video:(e,t)=>`${String(Yk(e,t))}% rendered`},Hk={audio_intro:`intro`,audio_body:`body`,audio_outro:`outro`};function Uk(e,t,n){let r=t.filter(t=>t.stageKind===e.kind);switch(e.state){case`skipped`:return`Not part of this run`;case`pending`:return n.status===`paused`?`Waiting for Resume`:e.kind===`images`||e.kind===`thumbnail`&&e.source===`from_prompt`?`Ready to run`:`Waits for the stages above`;case`provided`:return Kk(r)??`Provided`;case`failed`:return`Stopped after ${Wk(e)}`;case`canceled`:return`Canceled by user`;case`running`:return Bk(e,n.config)?`Preparing subtitles · ${String(Yk(e.progressCurrent??0,35))}%`:e.kind===`video`&&Rk(n.config)===`audio`?`Exporting combined audio`:e.progressTotal===null||e.progressTotal<=0?`Running`:Vk[e.kind](e.progressCurrent??0,e.progressTotal);case`done`:return Gk(e.kind,r,n)}}function Wk(e){return e.attemptCount===1?`1 attempt`:`${String(e.attemptCount)} attempts`}function Gk(e,t,n){switch(e){case`research`:return`Notes ready`;case`article`:{let e=t.filter(e=>e.role===`sources`||e.role===`glossary`);return e.length===0?`Article ready`:`Article and ${String(e.length)} end-matter files`}case`audio`:return $k([Zk(t.flatMap(e=>{let t=Hk[e.role];return t===void 0?[]:[t]})),Jk(qk(t))]);case`images`:return Xk(t.filter(e=>e.role===`image`).length,`image`);case`thumbnail`:return t.length===0?`Thumbnail ready`:`1 image`;case`video`:return $k([Jk(qk(t)),Rk(n.config)===`audio`?`WAV · stereo · 48 kHz`:n.format])}}function Kk(e){let t=e.flatMap(e=>e.originalFilename===null?[]:[e.originalFilename]);return t.length===0?void 0:t.join(`, `)}function qk(e){let t=Math.max(0,...e.map(e=>e.durationMs??0));return t===0?void 0:t}function Jk(e){if(e===void 0||!Number.isFinite(e)||e<=0)return;let t=Math.round(e/1e3),n=[Math.floor(t/60)%60,t%60].map(e=>String(e).padStart(2,`0`)),r=Math.floor(t/3600);return r===0?n.join(`:`):[String(r),...n].join(`:`)}function Yk(e,t){return t<=0?0:Math.min(100,Math.max(0,Math.round(e/t*100)))}function Xk(e,t){return e===1?`1 ${t}`:`${String(e)} ${t}s`}function Zk(e){if(e.length!==0)return e.length===1?Qk(e[0]??``):Qk(`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]??``}`)}function Qk(e){return e.charAt(0).toUpperCase()+e.slice(1)}function $k(e){return e.filter(e=>e!==void 0&&e!==``).join(` · `)}var eA=12,tA=16;function nA(e,t,n){return Math.max(t,Math.min(e,Math.max(t,n)))}function rA(e,t,n){let r=Math.min(n.width,t.width-24),i=nA(e?.left??(t.width-r)/2,eA,t.width-r-eA),a=nA((e?.top??0)+((e?.height??t.height)-n.height)/2,eA,t.height-n.height-eA),o=t.height-n.height-eA;if(!e)return{left:i,top:a,width:r,docked:!1};let s=e.left+e.width,c=e.top+e.height;return s+tA+r<=t.width-eA?{left:s+tA,top:a,width:r,docked:!1}:e.left-tA-r>=eA?{left:e.left-tA-r,top:a,width:r,docked:!1}:c>=eA&&c+tA+n.height<=t.height-eA?{left:i,top:c+tA,width:r,docked:!1}:e.top-tA-n.height>=eA&&e.top<=t.height-eA?{left:i,top:e.top-tA-n.height,width:r,docked:!1}:{left:t.width-r-eA,top:Math.max(eA,o),width:r,docked:!0}}function iA(e,t,n=t.height){let r=nA(e.left-6,0,t.width),i=nA(e.top-6,0,Math.min(n,t.height)),a=nA(e.left+e.width+6,0,t.width),o=nA(e.top+e.height+6,0,Math.min(n,t.height));return a>r&&o>i?{left:r,top:i,width:a-r,height:o-i}:null}var aA=`[data-slot="select-content"], [data-slot="dropdown-menu-content"]`;function oA(e){try{return document.querySelector(e)}catch{return null}}function sA(){return[...document.querySelectorAll(`[data-slot="dialog-content"][data-state="open"]`)].at(-1)??null}function cA(e){if(!e)return[];let t=[e,...e.querySelectorAll(`[aria-controls]`)],n=new Set(t.flatMap(e=>(e.getAttribute(`aria-controls`)??``).split(` `)));return[...document.querySelectorAll(aA)].filter(e=>n.has(e.id))}function lA(e){let t=e.getBoundingClientRect();return t.width>0&&t.height>0?{left:t.left,top:t.top,width:t.width,height:t.height}:null}var uA=`a[href], button, input, select, textarea, summary, [tabindex], [contenteditable="true"]`;function dA(e,t,n,r){let i=(0,m.useRef)(document.activeElement),a=(0,m.useRef)(t);a.current=t,(0,m.useEffect)(()=>{let e=i.current;return()=>{queueMicrotask(()=>{e instanceof HTMLElement&&e.isConnected&&!n.current&&e.focus({preventScroll:!0})})}},[n]),(0,m.useEffect)(()=>{let t=()=>{let t=oA(e);return[t,n.current,...cA(t)].filter(e=>e!==null)},i=e=>e instanceof Node&&t().some(t=>t.contains(e)),o=e=>{sA()||i(e.target)||(e.preventDefault(),e.stopImmediatePropagation())},s=e=>{sA()||i(e.target)||e.target instanceof HTMLElement&&e.target.hasAttribute(`data-radix-focus-guard`)||r.current?.focus({preventScroll:!0})},c=n=>{if(sA())return;let r=cA(oA(e));if(n.key===`Escape`){if(r.length>0)return;n.preventDefault(),n.stopImmediatePropagation(),a.current();return}if(n.key!==`Tab`){i(n.target)||o(n);return}if(r.length>0)return;let s=t().flatMap(e=>[e,...e.querySelectorAll(uA)]).filter((e,t,n)=>n.indexOf(e)===t&&e.tabIndex>=0&&!e.matches(`:disabled, [hidden], [aria-hidden='true']`)&&!e.closest(`[hidden], [inert]`)&&(!e.closest(`details:not([open])`)||e.closest(`summary`)!==null));if(s.length===0)return;let c=s.indexOf(document.activeElement),l=c===-1?n.shiftKey?s.length-1:0:(c+(n.shiftKey?-1:1)+s.length)%s.length;n.preventDefault(),s[l]?.focus()},l=[`pointerdown`,`pointerup`,`mousedown`,`mouseup`,`click`,`dblclick`,`contextmenu`];for(let e of l)window.addEventListener(e,o,!0);return window.addEventListener(`keydown`,c,!0),window.addEventListener(`focusin`,s,!0),()=>{for(let e of l)window.removeEventListener(e,o,!0);window.removeEventListener(`keydown`,c,!0),window.removeEventListener(`focusin`,s,!0)}},[e,n,r])}function fA(e,t,n,r,i,a){let[o,s]=(0,m.useState)(()=>({key:e,target:null,portals:[],width:window.innerWidth,height:window.innerHeight,cardHeight:260,modalOpen:sA()!==null}));return(0,m.useLayoutEffect)(()=>{let o=0,c=0,l=null,u=null,d=new Map,f=new ResizeObserver(()=>h()),p=e=>{for(let[t,n]of d)e.has(t)||(t.style.zIndex=n,d.delete(t))},m=()=>{o=0;let r=oA(t);r!==u&&(u&&f.unobserve(u),r&&f.observe(r),u=r);let i=r?lA(r):null;r&&i&&l!==r&&(l=r,cancelAnimationFrame(c),c=requestAnimationFrame(()=>{c=0,r.isConnected&&(r.scrollIntoView({block:`start`,inline:`nearest`,behavior:`instant`}),m())}));let a=cA(r),h=new Set;for(let e of a){let t=e.closest(`[data-radix-popper-content-wrapper]`)??e;h.add(t),d.has(t)||(d.set(t,t.style.zIndex),t.style.zIndex=`102`)}p(h);let g={key:e,target:i,portals:a.map(lA).filter(e=>e!==null),width:window.innerWidth,height:window.innerHeight,cardHeight:n.current?.getBoundingClientRect().height||260,modalOpen:sA()!==null};s(e=>JSON.stringify(e)===JSON.stringify(g)?e:g)};function h(){o||=requestAnimationFrame(m)}let g=new MutationObserver(e=>{e.some(e=>!i.current?.contains(e.target)&&e.target!==a.current)&&h()});return g.observe(document.body,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`id`,`class`,`style`,`hidden`,`aria-controls`,`data-state`,`data-tour`]}),n.current&&f.observe(n.current),f.observe(document.documentElement),window.addEventListener(`resize`,h),window.addEventListener(`scroll`,h,!0),window.visualViewport?.addEventListener(`resize`,h),window.visualViewport?.addEventListener(`scroll`,h),m(),sA()||r.current?.focus({preventScroll:!0}),()=>{cancelAnimationFrame(o),cancelAnimationFrame(c),f.disconnect(),g.disconnect(),window.removeEventListener(`resize`,h),window.removeEventListener(`scroll`,h,!0),window.visualViewport?.removeEventListener(`resize`,h),window.visualViewport?.removeEventListener(`scroll`,h),p(new Set)}},[e,t,n,r,i,a]),o}function pA({stepId:e,target:t,title:n,children:r,progress:i,onNext:a,onBack:o,onClose:s,nextLabel:c=`Next`,nextDisabled:l=!1,onSkip:u,skipLabel:d=`Skip this step`}){let f=(0,m.useId)(),p=`${e}:${t}`,g=(0,m.useRef)(null),_=(0,m.useRef)(null),v=(0,m.useRef)(null),y=(0,m.useRef)(null),b=fA(p,t,g,_,v,y);dA(t,s,g,_);let[x,S]=(0,m.useState)({key:p,height:0}),C=b.key===p?b.target:null,w={width:b.width,height:b.height},T={width:Math.min(360,w.width-24),height:b.cardHeight},E=rA(C,w,T),D=C?iA(C,w,E.docked?E.top-12:w.height):null,O=b.key===p?b.portals.map(e=>iA(e,w)).filter(e=>e!==null):[],k=[...D?[D]:[],...O],A=`M0 0H${w.width}V${w.height}H0Z`+(D?`M${D.left} ${D.top}H${D.left+D.width}V${D.top+D.height}H${D.left}Z`:``);(0,m.useLayoutEffect)(()=>{S(e=>{let t=Math.max(e.key===p?e.height:0,E.docked?T.height+24:0);return e.key===p&&e.height===t?e:{key:p,height:t}})},[p,E.docked,T.height]);let j=x.key===p?x.height:0;return(0,m.useEffect)(()=>{let e=document.documentElement,t=e.style.scrollPaddingBottom;return e.style.scrollPaddingBottom=`${j}px`,()=>{e.style.scrollPaddingBottom=t}},[j]),(0,cl.createPortal)((0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`div`,{ref:y,"aria-hidden":`true`,style:{height:j}}),(0,h.jsxs)(`div`,{ref:v,hidden:b.modalOpen,"data-tutorial":`spotlight`,className:`pointer-events-none fixed inset-0 z-[100] font-sans`,children:[(0,h.jsxs)(`svg`,{"aria-hidden":`true`,className:`absolute inset-0 h-full w-full`,width:w.width,height:w.height,children:[(0,h.jsx)(`defs`,{children:(0,h.jsxs)(`mask`,{id:`${f}-mask`,children:[(0,h.jsx)(`rect`,{width:`100%`,height:`100%`,fill:`white`}),k.map(e=>(0,h.jsx)(`rect`,{x:e.left,y:e.top,width:e.width,height:e.height,rx:`6`,fill:`black`},`${e.left}:${e.top}:${e.width}:${e.height}`))]})}),(0,h.jsx)(`rect`,{width:`100%`,height:`100%`,fill:`rgb(0 0 0 / 0.72)`,mask:`url(#${f}-mask)`}),(0,h.jsx)(`path`,{d:A,fill:`transparent`,fillRule:`evenodd`,pointerEvents:`fill`}),D&&(0,h.jsx)(`rect`,{"data-tutorial":`hole`,x:D.left,y:D.top,width:D.width,height:D.height,rx:`6`,fill:`none`,stroke:`var(--color-accent)`,strokeWidth:`2`})]}),(0,h.jsxs)(`section`,{ref:g,"aria-label":`Interactive getting started guide`,"aria-describedby":`${f}-instructions`,"data-tutorial":`card`,className:`pointer-events-auto fixed z-[101] flex flex-col gap-3 rounded-panel border border-line2 bg-panel p-4 text-body text-ink shadow-[0_8px_24px_var(--color-shadow)]`,style:{left:E.left,top:E.top,width:E.width,maxHeight:Math.min(w.height-24,Math.max(160,Math.min(420,w.height*.48)))},children:[(0,h.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3`,children:[(0,h.jsxs)(`span`,{className:`engraved text-run-text`,children:[`Getting started · `,i]}),(0,h.jsx)(B,{variant:`ghost`,onClick:s,"aria-label":`Exit guide`,className:`h-7 px-2`,children:`Exit`})]}),(0,h.jsx)(`h2`,{ref:_,id:`${f}-title`,tabIndex:-1,className:`shrink-0 text-title font-bold outline-none`,children:n}),(0,h.jsxs)(`div`,{id:`${f}-instructions`,className:`min-h-0 overflow-y-auto text-ink2 [&_p+p]:mt-2 [&_code]:text-ink`,children:[r,!C&&(0,h.jsx)(`p`,{role:`status`,className:`mt-3 text-amber`,children:`This section is not available yet. Wait for the page to load, go back, or exit the guide.`}),E.docked&&C&&(0,h.jsx)(`p`,{className:`mt-3 text-small`,children:`Scroll the page to work through the highlighted section.`})]}),(0,h.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-line pt-3`,children:[o&&(0,h.jsx)(B,{onClick:o,children:`Back`}),u&&(0,h.jsx)(B,{variant:`ghost`,onClick:u,className:`px-2`,children:d}),(0,h.jsx)(B,{variant:`primary`,onClick:a,disabled:l||!C,className:`ml-auto`,children:c})]})]})]})]}),document.body)}function mA({href:e,children:t}){return(0,h.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`text-ink underline underline-offset-2`,children:t})}function hA({text:e}){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)(!1);return(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(`p`,{className:`select-text rounded-control border border-line2 bg-panel2 p-3 text-small leading-relaxed`,children:e}),(0,h.jsx)(B,{onClick:()=>{if(i(!1),!navigator.clipboard){i(!0);return}navigator.clipboard.writeText(e).then(()=>n(!0),()=>i(!0))},children:t?`Copied`:`Copy example`}),r?(0,h.jsx)(`p`,{role:`status`,children:`Select the example above and copy it manually.`}):null]})}function gA({step:e}){switch(e){case`text-key`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`First, choose what will write your scripts. You only need one text provider.`}),(0,h.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5`,children:[(0,h.jsxs)(`li`,{children:[`Sign in to `,(0,h.jsx)(mA,{href:`https://openrouter.ai/settings/keys`,children:`OpenRouter`}),`, create an API key, and make sure the account can use your chosen model.`]}),(0,h.jsxs)(`li`,{children:[`Paste it into OpenRouter’s `,(0,h.jsx)(`strong`,{children:`API key`}),` field here and press`,` `,(0,h.jsx)(`strong`,{children:`Save`}),`.`]})]}),(0,h.jsx)(`p`,{children:`Already using Claude Code, Codex or Gemini CLI? You can use its existing CLI login instead. “Installed” means Slopify found the CLI; sign in through that CLI before generating. If it is missing, enter its executable path and save to check again.`}),(0,h.jsx)(`p`,{className:`text-ink3`,children:`These are the real Settings controls. The tutorial never reads your key. Skip any step you have already handled.`})]});case`audio-key`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`The voice provider turns the finished article into audio. Choose`,` `,(0,h.jsx)(`strong`,{children:`ElevenLabs`}),`, `,(0,h.jsx)(`strong`,{children:`OpenAI`}),`, or `,(0,h.jsx)(`strong`,{children:`Cartesia`}),`; you do not need all three.`]}),(0,h.jsxs)(`p`,{children:[`Create a key in your provider’s account, enable the API access or credits it requires, then paste the key into its row and press `,(0,h.jsx)(`strong`,{children:`Save`}),`.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(mA,{href:`https://elevenlabs.io/app/developers/api-keys`,children:`ElevenLabs keys`}),` `,`· `,(0,h.jsx)(mA,{href:`https://platform.openai.com/api-keys`,children:`OpenAI keys`}),` ·`,` `,(0,h.jsx)(mA,{href:`https://play.cartesia.ai/keys`,children:`Cartesia keys`})]}),(0,h.jsx)(`p`,{children:`Next, you’ll add the exact voice that this provider should use. Skip voice setup if you plan to provide your own narration or turn Audio Off.`})]});case`image-key`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Choose one image provider, create a key in its dashboard, paste it into the matching row, and press `,(0,h.jsx)(`strong`,{children:`Save`}),`.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(mA,{href:`https://fal.ai/dashboard/keys`,children:`fal.ai`}),` ·`,` `,(0,h.jsx)(mA,{href:`https://replicate.com/account/api-tokens`,children:`Replicate`}),` ·`,` `,(0,h.jsx)(mA,{href:`https://aistudio.google.com/apikey`,children:`Google AI Studio`}),` ·`,` `,(0,h.jsx)(mA,{href:`https://platform.openai.com/api-keys`,children:`OpenAI`})]}),(0,h.jsxs)(`p`,{children:[`A saved key is not a billing check. The selected image model needs available quota. If Google reports `,(0,h.jsx)(`strong`,{children:`limit: 0`}),`, check the key’s project, billing and image-model quota before retrying.`]}),(0,h.jsx)(`p`,{children:`OpenAI’s voice and image rows are saved separately, even when you use the same API key. Skip this step if you plan to provide your own images or turn Images and Thumbnail Off.`})]});case`voice`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5`,children:[(0,h.jsxs)(`li`,{children:[`Enter a `,(0,h.jsx)(`strong`,{children:`Voice name`}),` you will recognize, such as “Travel narrator.”`]}),(0,h.jsxs)(`li`,{children:[`Select the `,(0,h.jsx)(`strong`,{children:`Provider`}),` whose voice key you saved.`]}),(0,h.jsxs)(`li`,{children:[`Copy the exact `,(0,h.jsx)(`strong`,{children:`Voice ID`}),` from that provider’s voice library or documentation.`]}),(0,h.jsxs)(`li`,{children:[`Press `,(0,h.jsx)(`strong`,{children:`Add voice`}),`.`]})]}),(0,h.jsx)(`p`,{children:`The name is your label; the ID tells the provider which voice to use. Slopify checks the ID with the provider when narration runs. A voice is only required when Audio is set to Generate.`})]})}}var _A=`Write a 150-word narration about {{topic}} for {{audience}}. Open with an interesting fact, explain three highlights, and end with one memorable takeaway. Use natural spoken English. Return only the narration, without headings or stage directions.`,vA=`A cinematic editorial photograph of {{topic}}, with natural light, a clear focal point, rich detail, and no text or logos. Compose it for a travel video.`;function yA({step:e,output:t=`video`}){switch(e){case`text-key`:case`audio-key`:case`image-key`:case`voice`:return(0,h.jsx)(gA,{step:e});case`article-name`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`A prompt is a reusable set of instructions. This one will write the narration for each video.`}),(0,h.jsxs)(`p`,{children:[`Give it a recognizable name, such as `,(0,h.jsx)(`strong`,{children:`Short travel narration`}),`. This is the prompt’s library name, not your video’s title.`]}),(0,h.jsx)(`p`,{children:`The next steps will add its instructions and reusable keywords.`})]});case`article-body`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`Tell the model what to write, who it is for, the length, and the style. Put anything you want to change between runs inside double braces.`}),(0,h.jsx)(hA,{text:_A}),(0,h.jsxs)(`p`,{children:[`Paste or write the instructions in `,(0,h.jsx)(`strong`,{children:`Body`}),`. `,(0,h.jsx)(`strong`,{children:`{{topic}}`}),` `,`and `,(0,h.jsx)(`strong`,{children:`{{audience}}`}),` will become fields on Play.`]})]});case`article-keywords`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`This panel detects your keywords as you type. With the example, it should list`,` `,(0,h.jsx)(`strong`,{children:`topic`}),` and `,(0,h.jsx)(`strong`,{children:`audience`}),`.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`strong`,{children:`{{topic}}`}),` is a field name, not the value. You will enter “Albania” on Play later. Repeated names use the same value; names are case-sensitive, so`,` `,(0,h.jsx)(`strong`,{children:`topic`}),` and `,(0,h.jsx)(`strong`,{children:`Topic`}),` are different.`]}),(0,h.jsxs)(`p`,{children:[`There are no automatic keywords: `,(0,h.jsx)(`strong`,{children:`{{title}}`}),` would also ask you for a value. Fix any keyword warnings in Body before saving.`]})]});case`article-save`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Press the highlighted `,(0,h.jsx)(`strong`,{children:`Save`}),` button in the editor. The prompt will appear in your Article library.`]}),(0,h.jsx)(`p`,{children:`The tour continues when the save succeeds and the editor returns to the prompt list. If a name is already taken, go Back and choose another.`})]});case`image-prompt`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Keep `,(0,h.jsx)(`strong`,{children:`Kind`}),` on `,(0,h.jsx)(`strong`,{children:`Image`}),`. Name this prompt`,` `,(0,h.jsx)(`strong`,{children:`Travel imagery`}),`, then enter this example or your own visual instructions.`]}),(0,h.jsx)(hA,{text:vA}),(0,h.jsxs)(`p`,{children:[`Using `,(0,h.jsx)(`strong`,{children:`{{topic}}`}),` in both prompts creates one shared field on Play. Image prompts describe the picture directly; they do not automatically receive your article.`]})]});case`image-save`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Press `,(0,h.jsx)(`strong`,{children:`Save`}),` to add this to your Image library. Next you will combine both prompts on Play.`]}),(0,h.jsx)(`p`,{children:`You can create more prompts later for different subjects, styles, lengths, or languages.`})]});case`play-article`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Play is where you configure one project. Leave `,(0,h.jsx)(`strong`,{children:`Article`}),` on`,` `,(0,h.jsx)(`strong`,{children:`Generate`}),`, then select the article prompt you saved.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`strong`,{children:`Provide`}),` is for an article you already have. For this first run, use Generate and keep the script short. Article is required; every other stage can be Off.`]}),(0,h.jsx)(`p`,{children:`Research starts Off. You can turn it on in a later run for web-grounded notes that are automatically passed to the article writer.`})]});case`play-audio`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Leave `,(0,h.jsx)(`strong`,{children:`Audio`}),` on `,(0,h.jsx)(`strong`,{children:`Generate`}),`. Pick your voice`,` `,(0,h.jsx)(`strong`,{children:`TTS`}),` provider, a `,(0,h.jsx)(`strong`,{children:`TTS model`}),`, then the saved`,` `,(0,h.jsx)(`strong`,{children:`Voice`}),`.`]}),(0,h.jsxs)(`p`,{children:[`Keep chunking on `,(0,h.jsx)(`strong`,{children:`Whole`}),` for the short example: the narration is sent as one request. Other chunking modes split longer text into pieces.`]}),(0,h.jsx)(`p`,{children:`Use Provide to upload existing narration, including any intro and outro in that file, or Off to skip narration. Video can still run silently, with each image shown for 5 seconds.`})]});case`play-images`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Leave `,(0,h.jsx)(`strong`,{children:`Images`}),` on `,(0,h.jsx)(`strong`,{children:`Generate`}),`. Choose the image`,` `,(0,h.jsx)(`strong`,{children:`Provider`}),` and `,(0,h.jsx)(`strong`,{children:`Model`}),`, select your image prompt, and set`,` `,(0,h.jsx)(`strong`,{children:`Number`}),` to 2 for a small first run.`]}),(0,h.jsx)(`p`,{children:`Number means separate images made from that same prompt. It does not make one scene per article paragraph. Add more image prompts when you want different scenes.`}),(0,h.jsx)(`p`,{children:`Use Provide for your own images or Off to skip them. Turning Images Off also turns Video Off. Thumbnail remains independent; keep it Off for this first run.`})]});case`play-video`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Choose `,(0,h.jsx)(`strong`,{children:`Generate`}),` for an MP4 slideshow. It needs generated or provided images. With Audio Off, the video is silent and each image lasts 5 seconds.`]}),(0,h.jsxs)(`p`,{children:[`Choose `,(0,h.jsx)(`strong`,{children:`Off`}),` to skip video. If Audio is active, Slopify exports one combined `,(0,h.jsx)(`strong`,{children:`WAV`}),` with the intro, body, outro and configured gaps.`]}),(0,h.jsx)(`p`,{children:`If both Audio and Video are Off, download the article and any other enabled outputs individually.`})]});case`play-subtitles`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Subtitles are optional and start `,(0,h.jsx)(`strong`,{children:`Off`}),`. Choose`,` `,(0,h.jsx)(`strong`,{children:`Subtitle files`}),` for SRT and VTT downloads, or`,` `,(0,h.jsx)(`strong`,{children:`Burn into video + files`}),` to keep captions visible in an MP4.`]}),(0,h.jsxs)(`p`,{children:[`English captions are timed locally from your narration with no paid API. First use downloads an approximately `,(0,h.jsx)(`strong`,{children:`95 MB`}),` speech model. Audio must be active; WAV exports support separate subtitle files.`]}),(0,h.jsx)(`p`,{children:`Pick a font or upload a TTF/OTF file, then adjust its size in the preview. Styling applies to burned captions. You can also add or change subtitles on a completed project later without regenerating its narration.`})]});case`play-options`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Enter a `,(0,h.jsx)(`strong`,{children:`Project title`}),`, such as “A quick trip to Albania.” Set the title in Content.`]}),(0,h.jsxs)(`p`,{children:[`Select the text `,(0,h.jsx)(`strong`,{children:`LLM`}),` and `,(0,h.jsx)(`strong`,{children:`Text model`}),`. The model list loads for your provider. Use `,(0,h.jsx)(`strong`,{children:`Refresh`}),` for updated choices or`,` `,(0,h.jsx)(`strong`,{children:`Custom ID`}),`to enter an exact model ID when supported.`]}),(0,h.jsx)(`p`,{children:`Intro and Outro are available in Outputs when Audio is Generate. The LLM controls appear only when an enabled stage needs text generation.`})]});case`play-keywords`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`The prompts you picked created these fields. For the examples, enter`,` `,(0,h.jsx)(`strong`,{children:`Albania`}),` for `,(0,h.jsx)(`strong`,{children:`topic`}),` and`,` `,(0,h.jsx)(`strong`,{children:`first-time travelers`}),` for `,(0,h.jsx)(`strong`,{children:`audience`}),`.`]}),(0,h.jsxs)(`p`,{children:[`A field under `,(0,h.jsx)(`strong`,{children:`Common`}),` feeds both the article and images. Changing it changes both prompts for this run.`]}),(0,h.jsx)(`p`,{children:`Fill every visible field. Each value must fit on one line and be no more than 200 characters. Your saved prompt keeps its braces so you can reuse it next time.`})]});case`play-start`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`Review the enabled outputs, costs and readiness in Review. If anything is missing, use Back to fix the highlighted section.`}),(0,h.jsxs)(`p`,{children:[`When ready, press the real `,(0,h.jsx)(`strong`,{children:`Start run`}),` or `,(0,h.jsx)(`strong`,{children:`Queue N`}),` `,`button. This creates a project and sends generation requests to your chosen providers, which may charge your account.`]}),(0,h.jsx)(`p`,{children:`The tour will follow you to the project. You can also finish the tutorial without generating anything.`})]});case`project`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Overall progress stays above the workspace. Select a stage from `,(0,h.jsx)(`strong`,{children:`Stages`}),` `,`to see its results or live writing. Press `,(0,h.jsx)(`strong`,{children:`Pause`}),` to stop active requests safely and keep finished work.`]}),(0,h.jsxs)(`p`,{children:[`Open `,(0,h.jsx)(`strong`,{children:`Edit project`}),` to change providers, models, voice, prompts or optional steps.`,(0,h.jsx)(`strong`,{children:` Save changes`}),` keeps a new revision without starting generation. Then use `,(0,h.jsx)(`strong`,{children:`Rebuild affected outputs`}),` to review the required work and cost before starting. Finished outputs remain available in `,(0,h.jsx)(`strong`,{children:`History`}),`.`]}),(0,h.jsxs)(`p`,{children:[`Select a failed stage and open `,(0,h.jsx)(`strong`,{children:`Error details`}),` to read the provider’s message. Review `,(0,h.jsx)(`strong`,{children:`Rebuild affected outputs`}),` to retry the necessary work. Unchanged outputs are reused.`]})]});case`download`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[t===`audio`?(0,h.jsxs)(h.Fragment,{children:[`When Audio export finishes, press `,(0,h.jsx)(`strong`,{children:`Download .wav`}),` for the combined narration.`]}):t===`article`?(0,h.jsxs)(h.Fragment,{children:[`Use `,(0,h.jsx)(`strong`,{children:`Download`}),` here to save the article. Audio and Video are Off for this project.`]}):(0,h.jsxs)(h.Fragment,{children:[`When Video finishes, press `,(0,h.jsx)(`strong`,{children:`Download .mp4`}),`.`]}),` `,`The completed project stays in `,(0,h.jsx)(`strong`,{children:`Projects`}),` so you can return to it.`]}),(0,h.jsxs)(`p`,{children:[`Select Article, Audio or Images in `,(0,h.jsx)(`strong`,{children:`Stages`}),` to download their outputs.`,` `,(0,h.jsx)(`strong`,{children:`Download all`}),` under Images gives an image ZIP, not the video.`]}),(0,h.jsxs)(`p`,{children:[`If subtitles are enabled, download the `,(0,h.jsx)(`strong`,{children:`.srt`}),` or `,(0,h.jsx)(`strong`,{children:`.vtt`}),` `,`files beside the final export. File-mode captions are also available in the video player.`]}),(0,h.jsxs)(`p`,{children:[`You have reached the end. Open `,(0,h.jsx)(`strong`,{children:`Tutorial`}),` in the navigation anytime to walk through these steps again.`]})]})}}function bA(e){return Ik(e.readiness)}function xA({session:e,progress:t,update:n}){let{api:r}=I(),i=wk(),a=Gi(),o=Ma(),s=nt(gy(r)),c=nt(vy(r)),l=nt(yy(r)),u=nt({...hy(r,e.projectId??``),enabled:e.projectId!==void 0}),[d,f]=(0,m.useState)(null),p=(0,m.useRef)(null),g=Mk[e.step],_=s.data?.seen===!0;if((0,m.useEffect)(()=>{if(_&&g&&p.current!==e.step){if(p.current=e.step,g.page===`settings`&&o.pathname!==`/settings`&&a({to:`/settings`}),g.page===`article`||g.page===`image`){let t=g.page===`article`?e.articleId:e.imageId,n=o.pathname===`/prompts/new`&&o.searchStr.includes(`kind=${g.page}`);t&&o.pathname!==`/prompts/${t}`?a({to:`/prompts/$promptId`,params:{promptId:t}}):!t&&!n&&a({to:`/prompts/new`,search:{kind:g.page}})}g.page===`play`&&o.pathname!==`/play`&&a({to:`/play`}),g.page===`project`&&e.projectId&&o.pathname!==`/projects/${e.projectId}`&&a({to:`/projects/$projectId`,params:{projectId:e.projectId}})}},[_,g,e.step,e.articleId,e.imageId,e.projectId,o.pathname,o.searchStr,a]),(0,m.useEffect)(()=>{if(!_||g?.page!==`play`||o.pathname!==`/play`)return;let e=!0;return f(null),i.navigate(Fk[g.id]).then(()=>{e&&f(g.id)}),()=>{e=!1}},[_,g,o.pathname,i.navigate]),(0,m.useEffect)(()=>{o.pathname===`/prompts`&&(g?.id===`image-prompt`&&e.imageId?n(e=>({...e,step:Mk.findIndex(e=>e.id===`play-options`)})):(g?.id===`article-save`&&e.articleId||g?.id===`image-save`&&e.imageId)&&n(e=>({...e,step:e.step+1})))},[o.pathname,g?.id,e.articleId,e.imageId,n]),!_||!g||g.page===`play`&&(d!==g.id||i.section!==Fk[g.id]))return null;let v=c.data?.providers??[],y=e=>v.some(t=>t.family===e&&bA(t)),b=(l.data?.voices??[]).some(e=>v.some(t=>t.id===e.provider&&bA(t))),x={"text-key":y(`llm`),"audio-key":y(`tts`),"image-key":y(`image`),voice:b,"article-name":t.promptIsArticle===!0&&t.promptNamed===!0,"article-body":t.promptIsArticle===!0&&t.promptBodyReady===!0&&t.promptHasKeywords===!0,"article-keywords":t.promptHasKeywords===!0,"article-save":!1,"image-prompt":t.promptIsImage===!0&&t.promptSaveReady===!0&&t.promptHasKeywords===!0,"image-save":!1,"play-article":t.playArticleReady===!0,"play-audio":t.playAudioReady===!0,"play-images":t.playImagesReady===!0,"play-video":t.playVideoReady===!0,"play-subtitles":t.playSubtitlesReady===!0,"play-options":t.playOptionsReady===!0,"play-keywords":t.playKeywordsReady===!0,"play-start":!1},S=()=>n(e=>({...e,active:!1})),C=()=>{e.step===Mk.length-1||g.id===`play-start`?S():n(e=>({...e,step:e.step+1}))},w=u.data?Rk(u.data.project.config):`video`,T=g.id===`download`&&w===`article`?`project-article`:g.id===`play-keywords`&&t.playHasKeywords===!1?`play-options`:g.target,E=g.id===`article-save`||g.id===`image-save`,D=(g.page===`article`||g.page===`image`)&&t.promptSaving===!0;return(0,h.jsxs)(pA,{stepId:g.id,target:`[data-tour="${T}"]`,title:g.title,progress:`${e.step+1} of ${Mk.length} · First project`,onClose:S,...e.step===0||g.id===`project`||D?{}:{onBack:()=>n(e=>({...e,step:e.step-1}))},onNext:C,nextDisabled:D||x[g.id]===!1,nextLabel:E?`Use Save in the editor`:g.id===`play-start`?`Use Start run / Queue N on the page`:g.id===`download`?`Finish tutorial`:`Next`,...D?{}:{onSkip:C},skipLabel:g.id===`play-start`?`Finish without generating`:E?`Skip without saving`:`Skip this step`,children:[(0,h.jsx)(yA,{step:g.id,output:w}),c.error||l.error?(0,h.jsx)(`p`,{className:`text-red`,children:c.error?.message??l.error?.message}):null]})}var SA=K({schemaVersion:hD(1),active:XE(),stepId:q([`text-key`,`audio-key`,`image-key`,`voice`,`article-name`,`article-body`,`article-keywords`,`article-save`,`image-prompt`,`image-save`,`play-options`,`play-article`,`play-keywords`,`play-audio`,`play-images`,`play-video`,`play-subtitles`,`play-start`,`project`,`download`]),articleId:W().optional(),imageId:W().optional(),projectId:W().optional()}).strict();K({baseVersion:KE().int().nonnegative(),mutationId:OE(),session:SA}).strict();var CA=K({version:KE().int().nonnegative(),session:SA,readable:XE()}).strict();async function wA(e){let t=await eo(await e.client.tutorial.$get()),n=CA.safeParse(t);return n.success?n.data:{version:0,readable:!1,session:{schemaVersion:1,active:!1,stepId:`text-key`}}}async function TA(e,t){return CA.parse(await eo(await e.client.tutorial.$put({json:t})))}async function EA(e){let t=await e.client.tutorial.$delete();if(!t.ok)throw await ro(t)}function DA(){let{api:e}=I(),[t,n]=(0,m.useState)({active:!1,step:0}),[r,i]=(0,m.useState)(null),a=(0,m.useMemo)(()=>{let t={active:!1,step:0},r=0,a=!1,o=!1,s=0,c=!0,l=!1,u=!1,d=null,f=[],p=[],m=e=>i(e instanceof Error?e.message:`Tutorial progress could not be saved.`),h=async()=>{if(!u&&a&&c){u=!0;try{for(;d||p.length>0;){if(!d){let e=p.shift();if(!e)break;let t=Mk[e.step];if(!t)throw Error(`Unknown tutorial step. Restart tutorial to recover.`);let{step:n,...i}=e;d={baseVersion:r,mutationId:crypto.randomUUID(),session:{...i,schemaVersion:1,stepId:t.id}}}r=(await TA(e,d)).version,d=null}i(null)}catch(e){m(e)}finally{u=!1}}},g=e=>{if(!a){f.push(e);return}let r=typeof e==`function`?e(t):e;r!==t&&(t=r,n(t),p.push(t),h())},_=()=>{if(!a){l=!0;return}if(!c){i(`Saved tutorial progress cannot be read. Choose Restart tutorial to recover.`);return}g({active:!0,step:0})},v=async()=>{if(o||a)return;o=!0;let u=s;try{let o=await wA(e);if(u!==s)return;if(r=o.version,c=o.readable,c||(a=!0),!c){i(`Saved tutorial progress cannot be read. Choose Restart tutorial to recover.`);return}let{schemaVersion:d,stepId:p,...m}=o.session;if(t={active:m.active,step:Pk(p)??0,...m.articleId===void 0?{}:{articleId:m.articleId},...m.imageId===void 0?{}:{imageId:m.imageId},...m.projectId===void 0?{}:{projectId:m.projectId}},t.articleId||t.imageId){let{prompts:n}=await Ao(e),{articleId:r,imageId:i,...a}=t;t={...a,...r!==void 0&&n.some(e=>e.id===r&&e.kind===`article`)?{articleId:r}:{},...i!==void 0&&n.some(e=>e.id===i&&e.kind===`image`)?{imageId:i}:{}}}if(t.projectId&&await co(e,t.projectId),u!==s)return;a=!0,n(t);for(let e of f.splice(0))g(e);l&&_(),i(null)}catch(e){u===s&&m(e)}finally{o=!1}},y=async()=>{if(!u){u=!0,s++,f.length=0,l=!1;try{await EA(e),r=0,c=!0,a=!0,d=null,p.length=0,t={active:!0,step:0},n(t),p.push(t),i(null)}catch(e){m(e)}finally{u=!1}await h()}};return{update:g,start:_,restore:v,retry:()=>{a?h():v()},restart:()=>{y()}}},[e]);return(0,m.useEffect)(()=>{a.restore()},[a]),{session:t,update:a.update,start:a.start,retry:a.retry,restart:a.restart,error:r}}var OA=(0,m.createContext)(void 0);function kA({children:e}){let{session:t,update:n,start:r,retry:i,restart:a,error:o}=DA(),[s,c]=(0,m.useState)({}),l=(0,m.useCallback)(e=>{c(t=>Object.entries(e).every(([e,n])=>t[e]===n)?t:{...t,...e})},[]),u=(0,m.useCallback)(e=>{c(t=>Object.fromEntries(Object.entries(t).filter(([t])=>!e.includes(t))))},[]),d=(0,m.useCallback)(e=>{n(t=>Nk(t,e))},[n]),f=Mk[t.step]?.id,p=t.active&&(f===`project`||f===`download`)?f:void 0,g=(0,m.useMemo)(()=>({active:t.active,projectId:t.projectId,projectStep:p,start:r,report:l,clear:u,event:d}),[t.active,t.projectId,p,r,l,u,d]);return(0,h.jsxs)(OA.Provider,{value:g,children:[e,o?(0,h.jsxs)(`div`,{role:`alert`,className:`fixed bottom-4 left-4 z-[100] rounded-panel border border-line bg-panel p-4 text-ink`,children:[(0,h.jsx)(`p`,{children:o}),(0,h.jsx)(B,{type:`button`,onClick:i,children:`Retry tutorial save`}),(0,h.jsx)(B,{type:`button`,onClick:a,children:`Restart tutorial`})]}):null,t.active?(0,h.jsx)(xA,{session:t,progress:s,update:n}):null]})}function AA(){return(0,m.useContext)(OA)}function jA(e){let t=(0,m.useContext)(OA),n=t?.report,r=t?.clear,i=(0,m.useRef)(e);i.current=e,(0,m.useEffect)(()=>{n?.(e)},[n,e]),(0,m.useEffect)(()=>()=>{r?.(Object.keys(i.current))},[r])}function MA(){let e=(0,m.useContext)(OA);return(0,m.useCallback)(t=>{e?.event(t)},[e?.event])}function NA(e){let t=(0,m.useContext)(OA);return t?.projectId===e?t.projectStep:void 0}var PA=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),FA=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),IA=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),LA=e=>{let t=IA(e);return t.charAt(0).toUpperCase()+t.slice(1)},RA={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},zA=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},BA=(0,m.createContext)({}),VA=()=>(0,m.useContext)(BA),HA=(0,m.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=VA()??{},h=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,m.createElement)(`svg`,{ref:c,...RA,width:t??l??RA.width,height:t??l??RA.height,stroke:e??f,strokeWidth:h,className:PA(`lucide`,p,i),...!a&&!zA(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,m.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),UA=(e,t)=>{let n=(0,m.forwardRef)(({className:n,...r},i)=>(0,m.createElement)(HA,{ref:i,iconNode:t,className:PA(`lucide-${FA(LA(e))}`,`lucide-${e}`,n),...r}));return n.displayName=LA(e),n},WA=UA(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338`,key:`7hb8p4`}],[`path`,{d:`M3 9h5.859`,key:`numkqi`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),GA=UA(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),KA=UA(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),qA=UA(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),JA=UA(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),YA=UA(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),XA=UA(`circle-pause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),ZA=UA(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),QA=UA(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),$A=UA(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),ej=UA(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),tj=UA(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),nj=UA(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),rj=UA(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),ij=UA(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),aj=UA(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function oj(){let e=AA();return e?(0,h.jsxs)(`button`,{type:`button`,className:`flex shrink-0 items-center gap-[6px] whitespace-nowrap text-ink2 hover:text-ink`,onClick:e.start,disabled:e.active,"aria-label":`Start interactive tutorial`,title:`Start interactive tutorial`,children:[(0,h.jsx)(ZA,{className:`size-4`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`sr-only min-[1280px]:not-sr-only`,children:`Tutorial`})]}):null}function sj(){let e=AA();return!e||e.active?null:(0,h.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-4 rounded-panel border border-line bg-panel px-4 py-[14px]`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`h2`,{className:`font-semibold`,children:`Make your first video`}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:`An interactive walkthrough of API keys, reusable prompts, keywords, and Play. Each step highlights the real controls you will use.`})]}),(0,h.jsx)(B,{variant:`accent`,onClick:e.start,children:`Start tutorial`})]})}function cj(){let[e,t]=(0,m.useState)(20);return(0,m.useEffect)(()=>{let e=0,n=()=>{let e=document.getElementById(`app-footer`)?.getBoundingClientRect();t(e!==void 0&&e.bottom>0?Math.max(20,window.innerHeight-e.top+12):20)},r=()=>{cancelAnimationFrame(e),e=requestAnimationFrame(n)},i=new ResizeObserver(r);return i.observe(document.body),window.addEventListener(`scroll`,r,!0),window.addEventListener(`resize`,r),n(),()=>{cancelAnimationFrame(e),i.disconnect(),window.removeEventListener(`scroll`,r,!0),window.removeEventListener(`resize`,r)}},[]),e}var lj=[`app-update`],uj=9e5,dj=2e3,fj=12e4;async function pj(e,t=!1,n){let r=AbortSignal.timeout(2e4);return eo(await e.fetch(`${e.origin}/api/update${t?`?refresh=1`:``}`,{signal:n===void 0?r:AbortSignal.any([n,r]),cache:`no-store`}))}async function mj(e){return eo(await e.fetch(`${e.origin}/api/update`,{method:`POST`,signal:AbortSignal.timeout(2e4)}))}function hj(e){let{api:t}=I(),n=_(),[r,i]=(0,m.useState)(null),[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(),l=(0,m.useRef)(!1),u=nt({queryKey:lj,queryFn:({signal:e})=>pj(t,!1,e),staleTime:uj,refetchOnWindowFocus:`always`,refetchInterval:e=>!a&&(r!==null||e.state.data?.status===`checking`||e.state.data?.status===`installing`||e.state.data?.status===`restarting`)?dj:uj,retry:!1}),d=it({mutationFn:()=>pj(t,!0),onMutate:()=>(o(!1),c(void 0),n.cancelQueries({queryKey:lj})),onSuccess:e=>n.setQueryData(lj,e),retry:!1}),f=it({mutationFn:()=>mj(t),onMutate:()=>(o(!1),c(void 0),n.cancelQueries({queryKey:lj})),onSuccess:e=>{i(e.currentVersion),o(!1),c(void 0),n.setQueryData(lj,e)},onError:()=>{n.invalidateQueries({queryKey:lj})},retry:!1}),p=r!==null||u.data?.status===`installing`||u.data?.status===`restarting`;(0,m.useEffect)(()=>{if(!p||a)return;let e=window.setTimeout(()=>{i(null),o(!0),c(`The update did not finish. Restart Slopify and try again.`)},fj);return()=>window.clearTimeout(e)},[p,a]),(0,m.useEffect)(()=>{if(r===null||u.data===void 0)return;let t=u.data.status===`idle`||u.data.status===`error`;u.data.currentVersion!==r&&t&&!l.current?(l.current=!0,i(null),o(!1),c(void 0),e()):t&&(i(null),o(!1),c(void 0))},[r,e,u.data]);let h=!a&&(r!==null||u.data?.status===`installing`||u.data?.status===`restarting`),g=s??f.error?.message??d.error?.message??(h?void 0:u.error?.message??u.data?.error);return{info:u.data,updating:h,checking:u.isFetching||d.isPending||u.data?.status===`checking`,installing:f.isPending,reconnecting:h&&u.isError,error:g,refresh:()=>{f.reset(),o(!1),c(void 0),d.mutate()},install:()=>{d.reset(),o(!1),c(void 0),f.mutate()}}}function gj({reload:e}){let t=hj(e),n=cj(),{info:r,updating:i,installing:a,reconnecting:o,checking:s,error:c}=t,l=i||a,u=r?.blockedReason??(r?.busy?`Pause running projects before updating.`:void 0),d=`Slopify updates: ${r?r.available?`Your version: ${r.currentVersion} · Newest: ${r.latestVersion}`:`Slopify ${r.currentVersion}`:`Slopify`}. ${o?`Reconnecting after update…`:l?`Updating…`:s?`Checking for updates…`:c??u??(r?.available?`Click to download and install the update.`:`Click to check for updates.`)}`;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":d,title:d,disabled:l||s,style:{bottom:n},onClick:()=>{r?.available&&r.canUpdate&&!u?t.install():t.refresh()},className:z(`fixed right-0 z-30 flex size-10 items-center justify-center rounded-full bg-transparent text-ink2 hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent sm:right-5`,c&&`text-amber`),children:[(0,h.jsx)(ij,{"aria-hidden":`true`,size:20,className:z((l||s)&&`animate-spin motion-reduce:animate-none`)}),r?.available&&!l?(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`absolute top-1 right-1 size-1.5 rounded-full bg-lamp-run`}):null]}),(0,h.jsx)(`span`,{className:`sr-only`,role:c?`alert`:`status`,children:d})]})}var _j=[{to:`/`,label:`Projects`,exact:!0},{to:`/play`,label:`Play`,exact:!0},{to:`/templates`,label:`Templates`,exact:!0},{to:`/schedules`,label:`Schedules`,exact:!0},{to:`/prompts`,label:`Prompts`,exact:!1},{to:`/entries`,label:`Intros & Outros`,exact:!1},{to:`/settings`,label:`Settings`,exact:!0},{to:`/usage`,label:`Usage`,exact:!0}],vj=[{href:`https://github.com/GentBajko/slopify`,label:`GitHub`,glyph:`github`,tone:``},{href:`https://www.patreon.com/cw/GentBajko`,label:`Patreon`,glyph:`patreon`,tone:`text-lamp-run`},{href:`https://buymeacoffee.com/gentbajko`,label:`Buy Me a Coffee`,glyph:`coffee`,tone:`text-lamp-run`}];function yj(){return(0,h.jsx)(Ek,{children:(0,h.jsx)(Ck,{children:(0,h.jsx)(kA,{children:(0,h.jsx)(bj,{})})})})}function bj(){let{api:e,openEvents:t}=I(),n=_(),[r,i]=(0,m.useState)(0);return(0,m.useEffect)(()=>{let r=jk(()=>{n.invalidateQueries({queryKey:V.projects})},200),a=Ny(t,Io(e,`global`),{tally:i,stagingChanged:()=>{n.invalidateQueries({queryKey:V.staging})},refetch:e=>{e===void 0?n.invalidateQueries():r.ask()}});return()=>{a(),r.stop()}},[e,t,n]),(0,h.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,h.jsxs)(`header`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-center gap-x-3 border-b border-line bg-panel px-4 min-[1280px]:flex min-[1280px]:h-14 min-[1280px]:gap-7 min-[1280px]:px-7`,children:[(0,h.jsxs)(sa,{to:`/`,className:`flex h-14 shrink-0 items-center gap-[10px] text-wordmark font-extrabold tracking-[-0.02em] text-ink`,children:[(0,h.jsx)(Fc,{className:`relative top-[3px] text-lamp-run`}),`Slopify`]}),(0,h.jsx)(`nav`,{"aria-label":`Main navigation`,className:`col-span-2 row-start-2 flex min-w-0 items-center gap-6 overflow-x-auto [scrollbar-width:thin] min-[1280px]:flex-1 min-[1280px]:gap-7`,children:_j.map(e=>(0,h.jsx)(sa,{to:e.to,activeOptions:{exact:e.exact},className:`shrink-0 whitespace-nowrap border-b-2 border-transparent py-3 text-ink2 hover:text-ink focus-visible:outline-offset-[-3px] min-[1280px]:py-[18px]`,activeProps:{className:`!border-lamp-run !text-ink`},children:e.label},e.to))}),(0,h.jsxs)(`div`,{className:`col-start-2 row-start-1 ml-auto flex items-center gap-1 sm:gap-4 min-[1280px]:gap-7 [&_button]:min-h-8 [&_button]:min-w-8`,children:[(0,h.jsx)(oj,{}),r===0?null:(0,h.jsxs)(sa,{to:`/`,"aria-label":`${String(r)} running`,title:`${String(r)} running`,className:`engraved flex min-h-8 items-center whitespace-nowrap text-ink3 hover:text-ink2`,children:[String(r),(0,h.jsx)(`span`,{className:`sr-only sm:not-sr-only`,children:`\xA0running`})]}),vj.map(e=>(0,h.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,title:e.label,className:`flex min-h-8 min-w-8 shrink-0 items-center justify-center gap-[6px] whitespace-nowrap text-ink2 hover:text-ink`,children:[(0,h.jsx)(Lc,{name:e.glyph,className:e.tone}),(0,h.jsx)(`span`,{className:`sr-only min-[1100px]:not-sr-only`,children:e.label})]},e.href))]})]}),(0,h.jsx)(`main`,{className:`min-w-0 flex-1 px-4 py-6 pb-20 sm:px-7`,children:(0,h.jsx)(Sa,{})}),(0,h.jsx)(`footer`,{id:`app-footer`,className:`flex items-center gap-[18px] border-t border-line px-4 py-[14px] text-label sm:px-7 text-ink3`,children:(0,h.jsx)(`span`,{children:`Free. Your keys, your machine.`})}),(0,h.jsx)(gj,{reload:()=>window.location.reload()}),(0,h.jsx)(Oy,{}),(0,h.jsx)(Ty,{}),(0,h.jsx)(ky,{reload:()=>{window.location.reload()}})]})}var xj=oO.map(e=>({value:e,label:Cj(e)})),Sj=WD.map(e=>({value:e,label:wj(e)}));function Cj(e){switch(e){case`intro`:return`Intro`;case`outro`:return`Outro`}}function wj(e){switch(e){case`text`:return`Text`;case`llm`:return`LLM`}}function Tj(e){switch(e){case`text`:return`Text is narrated as written.`;case`llm`:return`LLM is an instruction whose answer is narrated.`}}function Ej(e){switch(e){case`text`:return`No slots. This text is narrated as written.`;case`llm`:return`No slots. This instruction runs as written.`}}function Dj(e){return oO.find(t=>t===e)??`intro`}var Oj=aO.map(e=>({value:e,label:kj(e)}));function kj(e){switch(e){case`article`:return`Article`;case`image`:return`Image`;case`thumbnail`:return`Thumbnail`}}function Aj(e){return aO.find(t=>t===e)??`article`}function jj({open:e,title:t,consequence:n,verb:r,dismiss:i=`Cancel`,pending:a=!1,onConfirm:o,onCancel:s}){return(0,h.jsx)(cy,{open:e,onOpenChange:e=>{e||s()},children:(0,h.jsxs)(dy,{children:[(0,h.jsx)(fy,{children:t}),(0,h.jsx)(py,{children:n}),(0,h.jsxs)(`div`,{className:`flex justify-end gap-[10px]`,children:[(0,h.jsx)(B,{autoFocus:!0,onClick:s,children:i}),(0,h.jsx)(B,{variant:`danger`,disabled:a,onClick:o,children:r})]})]})})}function Mj({children:e,className:t,"data-tour":n}){return(0,h.jsx)(`div`,{"data-tour":n,className:z(`overflow-hidden rounded-panel border border-line bg-panel`,t),children:e})}function Nj({children:e,className:t,"data-tour":n}){return(0,h.jsx)(`div`,{"data-tour":n,className:z(`relative flex items-center gap-[14px] border-b border-line px-4 py-[14px] last:border-b-0`,t),children:e})}function Pj({current:e,total:t}){let n=t<=0?0:Math.min(1,Math.max(0,e/t));return(0,h.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`rail-meter`,className:`absolute inset-x-0 bottom-0 h-[2px] bg-lamp-run transition-[width] duration-[250ms] ease-out motion-reduce:transition-none`,style:{width:`${String(Math.round(n*100))}%`}})}function Fj({name:e,className:t}){return(0,h.jsx)(`span`,{"data-slot-chip":e,className:z(`engraved animate-tick-in rounded-control border border-line2 bg-panel2 px-[7px] py-[2px] text-ink2 motion-reduce:animate-none`,t),children:e})}var Ij=T_,Lj=E_;function Rj({className:e,sideOffset:t=4,align:n=`end`,...r}){return(0,h.jsx)(D_,{children:(0,h.jsx)(O_,{"data-slot":`dropdown-menu-content`,sideOffset:t,align:n,className:z(`z-50 min-w-[160px] overflow-hidden rounded-panel border border-line bg-panel p-1`,`shadow-[0_8px_24px_var(--color-shadow)]`,e),...r})})}function zj({className:e,...t}){return(0,h.jsx)(k_,{"data-slot":`dropdown-menu-item`,className:z(`flex cursor-default items-center rounded-control px-[10px] py-[5px] text-small text-ink`,`outline-hidden select-none focus:bg-panel2 data-highlighted:bg-panel2`,e),...t})}function Bj({className:e,...t}){return(0,h.jsx)(Xv,{"data-slot":`toggle-group`,className:z(`inline-flex w-fit items-stretch overflow-hidden rounded-control border border-line2`,e),...t})}function Vj({className:e,...t}){return(0,h.jsx)(ay,{"data-slot":`toggle-group-item`,className:z(`min-h-8 shrink-0 border-r border-line2 px-[10px] py-[5px] text-label text-ink2 last:border-r-0`,`transition-colors duration-150 ease-out motion-reduce:transition-none hover:bg-panel2 hover:text-ink`,`data-[state=on]:bg-panel2 data-[state=on]:text-ink data-[state=on]:shadow-[inset_0_-2px_0_var(--color-lamp-run)]`,`disabled:cursor-not-allowed disabled:opacity-40`,e),...t})}var Hj=`grid grid-cols-[minmax(0,1fr)_auto_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_70px_minmax(0,1fr)_auto_32px]`,Uj=`col-span-4 col-start-1 row-start-2 flex flex-wrap gap-[6px] md:col-span-1 md:col-start-3 md:row-start-1`;function Wj({category:e,onCategory:t}){let{api:n}=I(),r=_(),i=nt(xy(n)),[a,o]=(0,m.useState)(void 0),s=it({mutationFn:e=>Fo(n,e),onSettled:async()=>{o(void 0),await r.invalidateQueries({queryKey:V.entries})}}),c=i.data?.entries.filter(t=>t.category===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:`Intros & Outros`}),(0,h.jsxs)(`div`,{className:`mb-4 flex items-center gap-4`,children:[(0,h.jsx)(Bj,{type:`single`,value:e,"aria-label":`Entry category`,onValueChange:e=>{let n=xj.find(t=>t.value===e);n!==void 0&&t(n.value)},children:xj.map(e=>(0,h.jsx)(Vj,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsx)(B,{asChild:!0,children:(0,h.jsxs)(sa,{to:`/entries/new`,search:{category:e},children:[(0,h.jsx)(rj,{"aria-hidden":`true`,className:`size-[14px]`}),`New entry`]})})]}),i.error===null?null:(0,h.jsx)(Mj,{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)(Jj,{}):null:c.length===0?(0,h.jsx)(Kj,{category:e}):(0,h.jsx)(Mj,{children:c.map(e=>(0,h.jsxs)(`div`,{className:Hj,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 font-semibold`,children:e.name}),(0,h.jsx)(Gj,{mode:e.mode}),(0,h.jsx)(`span`,{className:Uj,children:e.slots.map(e=>(0,h.jsx)(Fj,{name:e},e))}),(0,h.jsx)(B,{className:`col-start-3 row-start-1 md:col-start-4`,asChild:!0,children:(0,h.jsx)(sa,{to:`/entries/$entryId`,params:{entryId:e.id},children:`Edit`})}),(0,h.jsx)(qj,{entry: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)(jj,{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 Gj({mode:e}){return(0,h.jsx)(`span`,{"data-entry-mode":e,className:`engraved col-start-2 row-start-1 justify-self-start rounded-control border border-line2 bg-panel2 px-[7px] py-[2px] font-bold text-ink`,children:wj(e)})}function Kj({category:e}){return(0,h.jsx)(Mj,{children:(0,h.jsx)(`p`,{className:`max-w-[75ch] px-4 py-7 text-ink2`,children:`No ${e}s yet. An ${e} is narrated ${e===`intro`?`before`:`after`} the body in the run's voice.`})})}function qj({entry:e,onDelete:t}){return(0,h.jsxs)(Ij,{children:[(0,h.jsx)(Lj,{asChild:!0,children:(0,h.jsx)(B,{variant:`ghost`,"aria-label":`More for ${e.name}`,className:`col-start-4 row-start-1 size-8 p-0 md:col-start-5`,children:(0,h.jsx)($A,{"aria-hidden":`true`,className:`size-4`})})}),(0,h.jsxs)(Rj,{children:[(0,h.jsx)(zj,{asChild:!0,children:(0,h.jsx)(sa,{to:`/entries/new`,search:{category:e.category,from:e.id},children:`Duplicate`})}),(0,h.jsx)(zj,{onSelect:t,children:`Delete`})]})]})}function Jj(){return(0,h.jsx)(Mj,{children:[0,1,2].map(e=>(0,h.jsxs)(`div`,{className:Hj,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 h-3 w-40 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`col-start-2 row-start-1 h-[18px] w-10 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:Uj,children:(0,h.jsx)(`span`,{className:`h-[18px] w-14 rounded-control bg-panel2`})}),(0,h.jsx)(`span`,{className:`col-start-3 row-start-1 h-7 w-12 rounded-control bg-panel2 md:col-start-4`})]},e))})}function Yj({slots:e,body:t,lint:n,lintId:r,noSlots:i=`No slots. This prompt runs as written.`}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`h2`,{className:`engraved text-ink3`,children:`Detected slots`}),e.length>0?(0,h.jsx)(`div`,{className:`flex flex-wrap gap-[6px]`,children:e.map(e=>(0,h.jsx)(Fj,{name:e,className:`px-2 py-[3px]`},e))}):t.trim()===``?(0,h.jsx)(`p`,{className:`text-small text-ink3`,children:`Slots appear here as you type {{name}}.`}):(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:i}),n.length===0?null:(0,h.jsxs)(`div`,{id:r,className:`flex flex-col gap-[6px] border-t border-line pt-3`,children:[(0,h.jsx)(`span`,{className:`engraved text-red`,children:n.length===1?`1 slot error`:`${String(n.length)} slot errors`}),n.map(e=>(0,h.jsx)(`span`,{className:`text-small text-red`,children:e.message},e.message))]})]})}var Xj=2e3;function Zj(e,t){let n=(0,m.useRef)(t);(0,m.useEffect)(()=>{n.current=t}),(0,m.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>{n.current()},Xj);return()=>{clearTimeout(t)}},[e])}function Qj(){return(0,h.jsxs)(`span`,{className:`inline-flex animate-tick-in items-center gap-1 text-label text-done motion-reduce:animate-none`,children:[(0,h.jsx)(GA,{"aria-hidden":`true`,className:`size-[14px]`}),`Saved`]})}function $j({onDelete:e,blocked:t,blockedId:n,pending:r,saved:i,cancel:a,errors:o,onSave:s}){let c=t!==void 0||r||i;return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-[10px] border-t border-line pt-[14px]`,children:[e===void 0?null:(0,h.jsx)(B,{className:`bg-transparent`,onClick:e,children:`Delete`}),(0,h.jsx)(`span`,{className:`flex-1`}),i?(0,h.jsx)(Qj,{}):null,t===void 0?null:(0,h.jsx)(`span`,{id:n,className:`text-small text-ink2`,children:t}),a,(0,h.jsx)(B,{variant:`primary`,"aria-disabled":c,"aria-describedby":t===void 0?void 0:n,onClick:()=>{c||s()},children:`Save`}),o.map(e=>(0,h.jsx)(`p`,{className:`basis-full text-label text-red`,children:e},e))]})}var eM=`rounded-panel border border-line bg-panel p-[18px]`;function tM(){return(0,h.jsxs)(`div`,{className:`mx-auto grid max-w-[1440px] grid-cols-[minmax(0,1fr)] gap-6 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,h.jsxs)(`div`,{className:`${eM} flex flex-col gap-[14px]`,children:[(0,h.jsx)(`span`,{className:`h-8 w-64 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-[520px] rounded-control bg-panel2`})]}),(0,h.jsx)(`div`,{className:`${eM} flex flex-col gap-3`,children:(0,h.jsx)(`span`,{className:`h-3 w-28 rounded-control bg-panel2`})})]})}function nM({children:e,back:t}){return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsx)(Mj,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:e})}),t]})}var rM=`mt-[10px] inline-block text-small text-run-text underline`;function iM({className:e,...t}){return(0,h.jsx)(j_,{"data-slot":`label`,className:z(`engraved block select-none text-ink3`,e),...t})}function aM({label:e,value:t,options:n,describedBy:r,onPick:i}){let a=(0,m.useId)();return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(iM,{id:a,className:`mb-[5px]`,children:e}),(0,h.jsx)(Bj,{type:`single`,value:t,"aria-labelledby":a,"aria-describedby":r,onValueChange:e=>{let t=n.find(t=>t.value===e);t!==void 0&&i(t.value)},children:n.map(e=>(0,h.jsx)(Vj,{value:e.value,children:e.label},e.value))})]})}function oM({className:e,...t}){return(0,h.jsx)(`input`,{"data-slot":`input`,className:z(`h-8 w-full min-w-0 rounded-control border border-line2 bg-panel2 px-[10px] text-small text-ink`,`placeholder:text-ink3 aria-invalid:border-red`,e),...t})}function sM({className:e,...t}){return(0,h.jsx)(`textarea`,{"data-slot":`textarea`,className:z(`w-full min-w-0 rounded-control border border-line2 bg-panel2 px-[10px] py-2 text-small text-ink`,`placeholder:text-ink3 aria-invalid:border-red`,e),...t})}var cM=/\{\{([^{}\n]*)\}\}/g,lM=`{{`,uM=`}}`;function dM(e){let t=[],n=[],r=e.indexOf(lM);for(;r!==-1;){let i=e.indexOf(`
98
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function hT(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;hT(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var gT=new Set([`type`,`properties`,`required`,`additionalProperties`]),_T=[`oneOf`,`anyOf`];function vT(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function yT(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!gT.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??vT(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Uy(n,r,e.length===1?e[0]:yT(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=vT(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function bT(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of gT)if(t in e)return;let n=t.filter(e=>_T.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=yT(t);else{let e=n[0],i=_T.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>yT([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,lT(e,r))}function xT(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):lT(i,s),lT(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())hT(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])bT(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}lT(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Uy(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:wT(t,`input`,e.processors),output:wT(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function ST(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return ST(r.element,n);if(r.type===`set`)return ST(r.valueType,n);if(r.type===`lazy`)return ST(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return ST(r.innerType,n);if(r.type===`intersection`)return ST(r.left,n)||ST(r.right,n);if(r.type===`record`||r.type===`map`)return ST(r.keyType,n)||ST(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:ST(r.in,n)||ST(r.out,n);if(r.type===`object`){for(let e in r.shape)if(ST(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(ST(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(ST(e,n))return!0;return!!(r.rest&&ST(r.rest,n))}return!1}var CT=(e,t={})=>n=>{let r=uT({...n,processors:t});return fT(e,r),mT(r,e),xT(r,e)},wT=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=uT({...i??{},target:a,io:t,processors:n});return fT(e,o),mT(o,e),xT(o,e)},TT={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ET=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=TT[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},DT=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(Number.isFinite(c)&&c!==0?i.multipleOf=Math.abs(c):dT(e,t,i,r,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`))},OT=(e,t,n,r)=>{n.type=`boolean`},kT=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},AT=(e,t,n,r)=>{n.not={}},jT=(e,t,n,r)=>{let i=e._zod.def,a=Iy(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},MT=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(dT(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(dT(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},NT=(e,t,n,r)=>{dT(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},PT=(e,t,n,r)=>{dT(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},FT=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=fT(a.element,t,{...r,path:[...r.path,`items`]})};function IT(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?IT(t.out):t.type===`catch`?IT(t.innerType):e._zod.optin}var LT=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&dT(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Uy(i.properties,e,fT(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e];return t.io===`input`?IT(n)===void 0:n._zod.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=fT(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},RT=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>fT(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},zT=(e,t,n,r)=>{let i=e._zod.def,a=fT(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=fT(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function BT(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=BT(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>BT(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i?(p.type=`string`,a||(p.pattern=(r.includes(`number`)?Wx:Ux).source),p):p}var VT=new WeakMap;function HT(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of VT.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=BT(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var UT=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=fT(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)Uy(i.patternProperties,t.source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=fT(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=VT.get(t);n||(n=[],VT.set(t,n),t.deferred.push(()=>HT(t))),n.push(e)}i.additionalProperties=fT(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&IT(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},WT=(e,t,n,r)=>{let i=e._zod.def,a=fT(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},GT=(e,t,n,r)=>{let i=e._zod.def;fT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},KT=Symbol();function qT(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(dT(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),KT):JSON.parse(o)}var JT=(e,t,n,r)=>{let i=e._zod.def;fT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=qT(i.defaultValue,e,t,n,r);o!==KT&&(n.default=o)},YT=(e,t,n,r)=>{let i=e._zod.def;fT(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=qT(i.defaultValue,e,t,n,r);o!==KT&&(n._prefault=o)},XT=(e,t,n,r)=>{let i=e._zod.def;fT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{dT(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},ZT=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;fT(o,t,r);let s=t.seen.get(e);s.ref=o},QT=(e,t,n,r)=>{let i=e._zod.def;fT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},$T=(e,t,n,r)=>{let i=e._zod.def;fT(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},eE=new WeakSet([Object.prototype,Error.prototype]);function tE(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var nE=U(`ZodError`,(e,t)=>{Yb.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);eE.has(n)||(eE.add(n),tE(n,`format`,e=>t=>$b(e,t)),tE(n,`flatten`,e=>t=>Qb(e,t)),tE(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ry,2)}),tE(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ry,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),rE=tx(nE),iE=nx(nE),aE=rx(nE),oE=ax(nE),sE=sx(nE),cE=cx(nE),lE=lx(nE),uE=ux(nE),dE=dx(nE),fE=fx(nE),pE=px(nE),mE=mx(nE);function hE(){Bb.localeError||Vb(tw())}function gE(){Bb.memoizer||Vb({memoizer:QC()})}var _E=U(`ZodType`,(e,t)=>(hE(),hS.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Wy(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return eb(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(LD(e,t))},superRefine(e,t){return this.check(RD(e,t))},overwrite(e){return this.check($w(e))},optional(){return yD(this)},exactOptional(){return xD(this)},nullable(){return CD(this)},nullish(){return yD(CD(this))},nonoptional(e){return kD(this,e)},array(){return G(this)},or(e){return oD([this,e])},and(e){return uD(this,e)},transform(e){return ND(this,_D(e))},default(e){return TD(this,e)},prefault(e){return DD(this,e)},catch(e){return jD(this,e)},pipe(e){return ND(this,e)},readonly(){return FD(this)},describe(e){let t=this.clone();return aw.add(t,{description:e}),t},meta(...e){if(e.length===0)return aw.get(this);let t=this.clone();return aw.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return wb(this,`~standard`,{..._S(this),jsonSchema:{input:wT(this,`input`),output:wT(this,`output`)}})},set"~standard"(e){Cb(this,`~standard`,e)},parse:function e(t,n){return rE(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await iE(this,t,n,{callee:e})},safeParse(e,t){return aE(this,e,t)},async safeParseAsync(e,t){return oE(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Cb(this,`spa`,e)},encode:function e(t,n){return sE(this,t,n,{callee:e})},decode:function e(t,n){return cE(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await lE(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await uE(this,t,n,{callee:e})},safeEncode(e,t){return dE(this,e,t)},safeDecode(e,t){return fE(this,e,t)},async safeEncodeAsync(e,t){return pE(this,e,t)},async safeDecodeAsync(e,t){return mE(this,e,t)},toJSONSchema(e){return CT(this,{})(e)},get description(){return aw.get(this)?.description},get _def(){return this._zod.def}}),vE=U(`_ZodString`,(e,t)=>{vS.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ET(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null},{regex(...e){return this.check(qw(...e))},includes(...e){return this.check(Xw(...e))},startsWith(...e){return this.check(Zw(...e))},endsWith(...e){return this.check(Qw(...e))},min(...e){return this.check(Gw(...e))},max(...e){return this.check(Ww(...e))},length(...e){return this.check(Kw(...e))},nonempty(...e){return this.check(Gw(1,...e))},lowercase(e){return this.check(Jw(e))},uppercase(e){return this.check(Yw(e))},trim(){return this.check(tT())},normalize(...e){return this.check(eT(...e))},toLowerCase(){return this.check(nT())},toUpperCase(){return this.check(rT())},slugify(){return this.check(iT())}}),yE=U(`ZodString`,(e,t)=>{vS.init(e,t),vE.init(e,t)},{email(e){return this.check(sw(TE,e))},url(e){return this.check(pw(kE,e))},jwt(e){return this.check(Ow(WE,e))},emoji(e){return this.check(mw(AE,e))},guid(e){return this.check(cw(EE,e))},uuid(e){return this.check(lw(DE,e))},uuidv4(e){return this.check(uw(DE,e))},uuidv6(e){return this.check(dw(DE,e))},uuidv7(e){return this.check(fw(DE,e))},nanoid(e){return this.check(hw(jE,e))},cuid(e){return this.check(gw(ME,e))},cuid2(e){return this.check(_w(NE,e))},ulid(e){return this.check(vw(PE,e))},base64(e){return this.check(Tw(VE,e))},base64url(e){return this.check(Ew(HE,e))},xid(e){return this.check(yw(FE,e))},ksuid(e){return this.check(bw(IE,e))},ipv4(e){return this.check(xw(LE,e))},ipv6(e){return this.check(Sw(RE,e))},cidrv4(e){return this.check(Cw(zE,e))},cidrv6(e){return this.check(ww(BE,e))},e164(e){return this.check(Dw(UE,e))},datetime(e){return this.check(kw(xE,e))},date(e){return this.check(Aw(SE,e))},time(e){return this.check(jw(CE,e))},duration(e){return this.check(Mw(wE,e))}});function W(e){return ow(yE,e)}var bE=U(`ZodStringFormat`,(e,t)=>{yS.init(e,t),vE.init(e,t)}),xE=U(`ZodISODateTime`,(e,t)=>{IS.init(e,t),bE.init(e,t)}),SE=U(`ZodISODate`,(e,t)=>{LS.init(e,t),bE.init(e,t)}),CE=U(`ZodISOTime`,(e,t)=>{RS.init(e,t),bE.init(e,t)}),wE=U(`ZodISODuration`,(e,t)=>{zS.init(e,t),bE.init(e,t)}),TE=U(`ZodEmail`,(e,t)=>{SS.init(e,t),bE.init(e,t)}),EE=U(`ZodGUID`,(e,t)=>{bS.init(e,t),bE.init(e,t)}),DE=U(`ZodUUID`,(e,t)=>{xS.init(e,t),bE.init(e,t)});function OE(e){return lw(DE,e)}var kE=U(`ZodURL`,(e,t)=>{OS.init(e,t),bE.init(e,t)}),AE=U(`ZodEmoji`,(e,t)=>{kS.init(e,t),bE.init(e,t)}),jE=U(`ZodNanoID`,(e,t)=>{AS.init(e,t),bE.init(e,t)}),ME=U(`ZodCUID`,(e,t)=>{jS.init(e,t),bE.init(e,t)}),NE=U(`ZodCUID2`,(e,t)=>{MS.init(e,t),bE.init(e,t)}),PE=U(`ZodULID`,(e,t)=>{NS.init(e,t),bE.init(e,t)}),FE=U(`ZodXID`,(e,t)=>{PS.init(e,t),bE.init(e,t)}),IE=U(`ZodKSUID`,(e,t)=>{FS.init(e,t),bE.init(e,t)}),LE=U(`ZodIPv4`,(e,t)=>{BS.init(e,t),bE.init(e,t)}),RE=U(`ZodIPv6`,(e,t)=>{US.init(e,t),bE.init(e,t)}),zE=U(`ZodCIDRv4`,(e,t)=>{WS.init(e,t),bE.init(e,t)}),BE=U(`ZodCIDRv6`,(e,t)=>{KS.init(e,t),bE.init(e,t)}),VE=U(`ZodBase64`,(e,t)=>{JS.init(e,t),bE.init(e,t)}),HE=U(`ZodBase64URL`,(e,t)=>{XS.init(e,t),bE.init(e,t)}),UE=U(`ZodE164`,(e,t)=>{ZS.init(e,t),bE.init(e,t)}),WE=U(`ZodJWT`,(e,t)=>{$S.init(e,t),bE.init(e,t)}),GE=U(`ZodNumber`,(e,t)=>{eC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>DT(e,t,n,r);let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null},{gt(e,t){return this.check(Vw(e,t))},gte(e,t){return this.check(Hw(e,t))},min(e,t){return this.check(Hw(e,t))},lt(e,t){return this.check(zw(e,t))},lte(e,t){return this.check(Bw(e,t))},max(e,t){return this.check(Bw(e,t))},int(e){return this.check(JE(e))},safe(e){return this.check(JE(e))},positive(e){return this.check(Vw(0,e))},nonnegative(e){return this.check(Hw(0,e))},negative(e){return this.check(zw(0,e))},nonpositive(e){return this.check(Bw(0,e))},multipleOf(e,t){return this.check(Uw(e,t))},step(e,t){return this.check(Uw(e,t))},finite(){return this}});function KE(e){return Nw(GE,e)}var qE=U(`ZodNumberFormat`,(e,t)=>{tC.init(e,t),GE.init(e,t)});function JE(e){return Pw(qE,e)}var YE=U(`ZodBoolean`,(e,t)=>{nC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>OT(e,t,n,r)});function XE(e){return Fw(YE,e)}var ZE=U(`ZodNull`,(e,t)=>{rC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kT(e,t,n,r)});function QE(e){return Iw(ZE,e)}var $E=U(`ZodUnknown`,(e,t)=>{iC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function eD(){return Lw($E)}var tD=U(`ZodNever`,(e,t)=>{aC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>AT(e,t,n,r)});function nD(e){return Rw(tD,e)}var rD=U(`ZodArray`,(e,t)=>{gE(),sC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>FT(e,t,n,r),e.element=t.element},{min(e,t){return this.check(Gw(e,t))},nonempty(e){return this.check(Gw(1,e))},max(e,t){return this.check(Ww(e,t))},length(e,t){return this.check(Kw(e,t))},unwrap(){return this.element}});function G(e,t){return aT(rD,e,t)}var iD=U(`ZodObject`,(e,t)=>{gE(),mC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>LT(e,t,n,r),jb(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return q(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:eD()})},loose(){return this.clone({...this._zod.def,catchall:eD()})},strict(){return this.clone({...this._zod.def,catchall:nD()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return ob(this,e)},safeExtend(e){return sb(this,e)},merge(e){return cb(this,e)},pick(e){return ib(this,e)},omit(e){return ab(this,e)},partial(...e){return lb(vD,this,e[0])},exactPartial(...e){return lb(bD,this,e[0],`exactPartial`)},required(...e){return ub(OD,this,e[0])}});function K(e,t){return new iD({type:`object`,shape:e??{},...H(t)})}var aD=U(`ZodUnion`,(e,t)=>{gC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>RT(e,t,n,r),e.options=t.options});function oD(e,t){return new aD({type:`union`,options:e,...H(t)})}var sD=U(`ZodDiscriminatedUnion`,(e,t)=>{aD.init(e,t),_C.init(e,t)});function cD(e,t,n){return new sD({type:`union`,options:t,discriminator:e,...H(n)})}var lD=U(`ZodIntersection`,(e,t)=>{vC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zT(e,t,n,r)});function uD(e,t){return new lD({type:`intersection`,left:e,right:t})}var dD=U(`ZodRecord`,(e,t)=>{gE(),xC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>UT(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function fD(e,t,n){return!t||!t._zod?new dD({type:`record`,keyType:W(),valueType:e,...H(t)}):new dD({type:`record`,keyType:e,valueType:t,...H(n)})}var pD=U(`ZodEnum`,(e,t)=>{SC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jT(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new pD({...t,checks:[],...H(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new pD({...t,checks:[],...H(r),entries:i})}});function q(e,t){return new pD({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...H(t)})}var mD=U(`ZodLiteral`,(e,t)=>{CC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>MT(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function hD(e,t){return new mD({type:`literal`,values:Array.isArray(e)?e:[e],...H(t)})}var gD=U(`ZodTransform`,(e,t)=>{gE(),wC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>PT(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new zb(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(xb(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(xb(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function _D(e){return new gD({type:`transform`,transform:e})}var vD=U(`ZodOptional`,(e,t)=>{EC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$T(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function yD(e){return new vD({type:`optional`,innerType:e})}var bD=U(`ZodExactOptional`,(e,t)=>{DC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$T(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function xD(e){return new bD({type:`optional`,innerType:e})}var SD=U(`ZodNullable`,(e,t)=>{OC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>WT(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function CD(e){return new SD({type:`nullable`,innerType:e})}var wD=U(`ZodDefault`,(e,t)=>{kC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>JT(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function TD(e,t){return new wD({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Zy(t)}})}var ED=U(`ZodPrefault`,(e,t)=>{jC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>YT(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function DD(e,t){return new ED({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Zy(t)}})}var OD=U(`ZodNonOptional`,(e,t)=>{MC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>GT(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function kD(e,t){return new OD({type:`nonoptional`,innerType:e,...H(t)})}var AD=U(`ZodCatch`,(e,t)=>{FC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>XT(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function jD(e,t){return new AD({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Nb(t)})}var MD=U(`ZodPipe`,(e,t)=>{IC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ZT(e,t,n,r),e.in=t.in,e.out=t.out});function ND(e,t){return new MD({type:`pipe`,in:e,out:t})}var PD=U(`ZodReadonly`,(e,t)=>{RC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>QT(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function FD(e){return new PD({type:`readonly`,innerType:e})}var ID=U(`ZodCustom`,(e,t)=>{BC.init(e,t),_E.init(e,t),e._zod.processJSONSchema=(t,n,r)=>NT(e,t,n,r)});function LD(e,t={}){return oT(ID,e,t)}function RD(e,t){return sT(e,t)}function zD(e){return kw(xE,e)}var BD=[`16:9`,`9:16`],VD=[`research`,`article`,`audio`,`images`,`thumbnail`,`video`],HD=[`off`,`low`,`medium`,`high`,`xhigh`],UD=[`generate`,`provide`,`off`,`from_prompt`,`prompt_by_llm`],WD=[`text`,`llm`],GD=W().min(1),KD=W().regex(/^[a-f0-9]{64}$/),qD=q([`audio`,`images`,`video`]),JD=K({projectId:GD,revisionId:GD,checkpointId:GD,stage:qD,workId:GD,fingerprint:KD,state:q([`configured`,`pending-review`,`held`,`released`,`satisfied`,`invalidated`,`canceled`]),createdAt:zD(),approvedAt:zD().nullable()}).strict().readonly();K({projectId:GD,revisionId:GD,checkpoints:G(K({checkpointId:GD,stage:qD,workId:GD,fingerprint:KD,state:q([`configured`,`pending-review`,`held`])}).strict().readonly()).max(3).readonly(),createdAt:zD()}).strict().readonly();var YD=K({projectId:GD,revisionId:GD,checkpointId:GD,fingerprint:KD,idempotencyKey:OE(),approvedAt:zD()}).strict().readonly(),XD=[`whole`,`paragraph`,`words`,`characters`],ZD=[`off`,`files`,`burn-in`],QD=[`top`,`upper-middle`,`center`,`lower-middle`,`bottom`],$D=K({mode:q(ZD),language:hD(`en`).default(`en`),fontId:W().max(160).regex(/^[A-Za-z0-9_-]+$/).default(`default`),position:q(QD).default(`bottom`),fontSize:KE().int().min(16).max(120).default(48)}),eO={mode:`off`,language:`en`,fontId:`default`,fontSize:48,position:`bottom`},tO=K({provider:W(),model:W(),thinking:q(HD).optional()}),nO=K({name:W(),mode:q(WD)}),rO=K({checkpoints:G(qD).max(3).refine(e=>new Set(e).size===e.length).readonly().optional(),title:W(),format:q(BD),sources:K({research:q(UD),article:q(UD),audio:q(UD),images:q(UD),thumbnail:q(UD),video:q(UD)}),llm:tO.optional(),audio:tO.extend({voice:W()}).optional(),images:tO.optional(),articlePrompt:W().optional(),imagePrompts:G(K({name:W(),number:KE()})),thumbnailPrompt:W().optional(),intro:nO.optional(),outro:nO.optional(),values:fD(W(),W()),provided:K({research:W().optional(),article:W().optional(),audio:W().optional(),images:G(W()).optional(),thumbnail:W().optional()}),chunking:K({mode:q(XD),words:KE().optional(),characters:KE().int().min(1).max(1e6).optional()}).optional(),silenceGapSeconds:KE(),subtitles:$D.optional()}),iO=rO.extend({rendered:fD(W(),W())}),aO=[`article`,`image`,`thumbnail`],oO=[`intro`,`outro`],sO=1e5;K({id:W(),kind:q(aO),name:W(),body:W(),slots:W(),updated_at:W()}),K({id:W(),category:q(oO),mode:q(WD),name:W(),body:W(),slots:W(),updated_at:W()});var cO=K({id:W(),name:W(),body:W(),slots:G(W()).readonly(),updatedAt:W()}),lO=K({prompts:G(cO.extend({kind:q(aO)}).strict().readonly()).readonly(),entries:G(cO.extend({category:q(oO),mode:q(WD)}).strict().readonly()).readonly()}).strict().readonly(),uO=OE(),dO=W(),fO=fD(dO,dO).readonly(),pO=K({provider:dO,model:dO,thinking:q(HD).optional()}).strict(),mO=K({attachmentId:uO,name:dO}).strict().readonly(),hO=K({title:dO,checkpoints:rO.shape.checkpoints,format:q(BD),sources:K({research:q(UD),article:q(UD),audio:q(UD),images:q(UD),thumbnail:q(UD),video:q(UD)}).strict().readonly(),llm:pO.readonly(),audio:pO.extend({voice:dO}).readonly(),images:pO.readonly(),articlePrompt:dO,imagePrompts:G(K({name:dO,number:dO}).strict().readonly()).readonly(),thumbnailPrompt:dO,intro:dO,outro:dO,chunking:K({mode:q(XD),words:dO,characters:dO}).strict().readonly(),subtitles:K({mode:q(ZD),language:hD(`en`),fontId:dO,fontSize:dO,position:q(QD)}).strict().readonly(),values:fO,provided:K({research:dO,article:dO,audio:mO.nullable(),thumbnail:mO.nullable(),images:G(mO).readonly()}).strict().readonly()}).strict().readonly(),gO=K({schemaVersion:hD(1),librarySnapshot:lO.optional(),templateSource:K({id:uO,version:KE().int().positive()}).strict().readonly().optional(),form:hO,section:q([`content`,`outputs`,`style`,`review`]),variants:G(K({id:uO,title:dO,values:fO}).strict().readonly()).readonly(),expectedWords:dO,previewText:dO,fontUpload:K({operationId:uO,name:dO}).strict().readonly().nullable()}).strict().readonly(),_O=K({id:uO,document:gO}).strict().readonly(),vO=_O.unwrap().extend({baseVersion:KE().int().positive(),mutationId:uO}).strict().readonly(),yO=_O.unwrap().extend({sourceId:uO}).strict().readonly(),bO=K({id:uO,baseVersion:KE().int().positive()}).strict().readonly(),xO=K({id:uO,kind:q([`audio`,`images`,`thumbnail`]),name:dO,state:q([`pending`,`copying`,`ready`,`reattach`]),stagedFileId:dO.nullable(),bytes:KE().nonnegative(),error:dO.nullable()}).strict().readonly(),SO=K({id:uO,version:KE().int().positive(),createdAt:dO,updatedAt:dO,document:gO}).strict().readonly(),CO=K({checkpointSet:G(JD.unwrap().extend({reviewedFingerprint:dO}).strict().readonly()).readonly().optional(),requestId:uO,projectIds:G(dO).readonly(),queue:G(K({projectId:dO,batchId:dO,position:KE(),state:q([`queued`,`active`,`finished`])}).strict().readonly()).readonly(),replayed:XE()}).strict().readonly(),wO=K({currency:hD(`USD`),rows:G(K({stage:dO,low:KE().nullable(),high:KE().nullable(),detail:dO}).strict().readonly()).readonly(),low:KE(),high:KE(),unknown:KE(),expectedWords:KE(),catalogueDate:dO.nullable(),assumptions:G(dO).readonly()}).strict().readonly(),TO=K({checkpointSet:G(K({runIndex:KE().int().nonnegative(),checkpointId:dO,stage:qD,fingerprint:dO,workKeys:G(dO).readonly(),dependents:G(q([`research`,`article`,`audio`,`images`,`thumbnail`,`video`])).readonly()}).strict().readonly()).readonly().optional(),id:uO,draftId:uO,draftVersion:KE().int().positive(),fingerprint:dO,runs:G(K({draft:rO,rendered:fO,templates:fO}).strict().readonly()).readonly(),estimates:G(wO).readonly()}).strict().readonly(),EO=K({draft:SO,attachments:G(xO).readonly(),review:TO.nullable(),pendingStart:K({reviewId:uO,draftVersion:KE().int().positive()}).strict().readonly().nullable(),start:CO.nullable()}).strict().readonly(),DO=K({title:W(),status:KE(),detail:W().optional(),reason:W().optional(),currentVersion:KE().int().positive().nullable().optional(),reviewId:OE().optional(),fields:G(K({field:W(),message:W()})).optional(),errors:G(K({path:W(),message:W()})).optional()}),OO=K({drafts:G(K({id:OE(),title:W(),version:KE().int().positive(),updatedAt:W(),readable:XE()}).strict()).readonly()}).strict(),kO=bO.unwrap().omit({id:!0}).extend({draftId:OE(),reviewId:OE()}).strict();async function AO(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=DO.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,currentVersion:i.currentVersion??null,fields:i.fields??i.errors?.map(e=>({field:e.path,message:e.message}))??[],...i.reviewId===void 0?{}:{reviewId:i.reviewId}}}async function jO(e,t,n,r,i){return AO(await e.fetch(`${e.origin}/api/drafts${t}`,{method:n,...i===void 0?{}:{headers:{"content-type":`application/json`},body:JSON.stringify(i)}}),r)}function MO(e){return`/${encodeURIComponent(OE().parse(e))}`}async function NO(e){return jO(e,``,`GET`,OO)}async function PO(e,t){return jO(e,``,`POST`,EO,_O.parse(t))}async function FO(e,t){return jO(e,MO(t),`GET`,EO)}async function IO(e,t){let{id:n,...r}=vO.parse(t);return jO(e,MO(n),`PUT`,EO,r)}async function LO(e,t){let{sourceId:n,...r}=yO.parse(t);return jO(e,`${MO(n)}/fork`,`POST`,EO,r)}async function RO(e,t){let{id:n,...r}=bO.parse(t);return jO(e,MO(n),`DELETE`,K({discarded:hD(!0)}).strict(),r)}async function zO(e,t){let{id:n,...r}=bO.parse(t);return jO(e,`${MO(n)}/review`,`POST`,TO,r)}async function BO(e,t){let{draftId:n,...r}=kO.parse(t);return jO(e,`${MO(n)}/start`,`POST`,CO,r)}function VO(e,t,n){return`${e.origin}/api/drafts${MO(t)}/attachments/${encodeURIComponent(OE().parse(n))}/file`}async function HO(e,t,n,r,i){let a=new FormData;return a.set(`file`,r),AO(await e.fetch(VO(e,t,n),{method:`PUT`,body:a,...i?{signal:i}:{}}),xO)}var UO=[`fonts`];async function WO(e){return eo(await e.fetch(`${e.origin}/api/fonts`))}async function GO(e,t){let n=new FormData;return n.set(`file`,t),eo(await e.fetch(`${e.origin}/api/fonts`,{method:`POST`,body:n}))}function KO(e,t){return`${e.origin}/api/fonts/${encodeURIComponent(t)}/file`}var qO=`slopify.play-draft`;function JO(e){try{e?window.localStorage?.setItem(qO,e):window.localStorage?.removeItem(qO)}catch(e){console.warn(`Active draft browser storage is unavailable`,e)}}function YO(){try{return window.localStorage?.getItem(qO)??null}catch(e){return console.warn(`Active draft browser storage is unavailable`,e),null}}async function XO(e,t){let n=await Promise.allSettled([t.fetchQuery({...vy(e),staleTime:0}),t.fetchQuery({...by(e),staleTime:0}),t.fetchQuery({...xy(e),staleTime:0}),t.fetchQuery({...Sy(e),staleTime:0}),t.fetchQuery({...yy(e),staleTime:0}),t.fetchQuery({queryKey:UO,queryFn:()=>WO(e),staleTime:0})]);for(let e of n)e.status===`rejected`&&console.warn(`Draft choices could not refresh`,e.reason)}var ZO={research:[`off`,`generate`,`provide`],article:[`generate`,`provide`],audio:[`off`,`generate`,`provide`],images:[`off`,`generate`,`provide`],thumbnail:[`off`,`from_prompt`,`prompt_by_llm`,`provide`],video:[`off`,`generate`]};function QO(e){let t=[],n=$O(e.draft),{sources:r}=n;n.title===``?t.push({field:`title`,message:`A title is required.`}):n.title.length>200&&t.push({field:`title`,message:`A title is at most 200 characters.`});for(let e of VD)ZO[e].includes(r[e])||t.push({field:`sources.${e}`,message:`The ${e} stage cannot be set to ${r[e]}.`});(r.research===`generate`||r.article===`generate`||r.thumbnail===`prompt_by_llm`||n.intro?.mode===`llm`||n.outro?.mode===`llm`)&&!ak(n.llm)&&t.push({field:`llm`,message:`Pick an LLM provider and model.`}),r.article===`generate`&&ik(n.articlePrompt)&&t.push({field:`articlePrompt`,message:`Pick an article prompt.`});let i=n.audio;return r.audio===`generate`&&(i===void 0||!ak(i)?t.push({field:`audio`,message:`Pick a narration provider and model.`}):i.voice.trim()===``&&t.push({field:`audio.voice`,message:`Pick a voice.`})),r.images===`generate`&&ek(n,t),(r.images===`generate`||r.thumbnail===`from_prompt`||r.thumbnail===`prompt_by_llm`)&&!ak(n.images)&&t.push({field:`images`,message:`Pick an image provider and model.`}),(r.thumbnail===`from_prompt`||r.thumbnail===`prompt_by_llm`)&&ik(n.thumbnailPrompt)&&t.push({field:`thumbnailPrompt`,message:`Pick a thumbnail prompt.`}),r.audio===`off`&&n.subtitles!==void 0&&n.subtitles.mode!==`off`&&t.push({field:`subtitles.mode`,message:`Subtitles need narration audio.`}),tk(n,e.staged,t),rk(n,e.requiredSlots,t),(!Number.isFinite(n.silenceGapSeconds)||n.silenceGapSeconds<0||n.silenceGapSeconds>30)&&t.push({field:`silenceGapSeconds`,message:`The silence gap is between 0 and 30 seconds.`}),t.length===0?{ok:!0,draft:n}:{ok:!1,fields:t}}function $O(e){let t={...e.sources};t.article===`provide`&&(t.research=`off`),t.images===`off`&&t.video===`generate`&&(t.video=`off`);let n=Object.create(null);for(let[t,r]of Object.entries(e.values))n[t]=r.trim();return{...e,title:e.title.trim(),subtitles:t.video===`off`&&e.subtitles?.mode===`burn-in`?{...e.subtitles,mode:`files`}:e.subtitles,sources:t,values:n,intro:t.audio===`generate`?e.intro:void 0,outro:t.audio===`generate`?e.outro:void 0}}function ek(e,t){if(e.imagePrompts.length===0){t.push({field:`imagePrompts`,message:`Tick at least one image prompt.`});return}let n=0;for(let[r,i]of e.imagePrompts.entries())n+=i.number,ik(i.name)&&t.push({field:`imagePrompts.${r}.name`,message:`Pick an image prompt.`}),(!Number.isInteger(i.number)||i.number<1||i.number>20)&&t.push({field:`imagePrompts.${r}.number`,message:`Number is between 1 and 20.`});n>60&&t.push({field:`imagePrompts`,message:`A run makes at most 60 images; this one asks for ${n}.`})}function tk(e,t,n){let{sources:r,provided:i}=e;if(r.research===`provide`&&ik(i.research)&&n.push({field:`provided.research`,message:`Paste the research notes.`}),r.article===`provide`&&ik(i.article)&&n.push({field:`provided.article`,message:`Paste the article.`}),r.audio===`provide`&&nk(t,i.audio,`audio`,`provided.audio`,`Pick an audio file.`,n),r.thumbnail===`provide`&&nk(t,i.thumbnail,`thumbnail`,`provided.thumbnail`,`Pick a thumbnail image.`,n),r.images===`provide`){let e=i.images??[];e.length===0?n.push({field:`provided.images`,message:`Pick at least one image.`}):e.length>60&&n.push({field:`provided.images`,message:`A run holds at most 60 images.`}),new Set(e).size!==e.length&&n.push({field:`provided.images`,message:`The same image was picked twice.`});for(let[r,i]of e.entries())nk(t,i,`images`,`provided.images.${r}`,`Pick an image.`,n)}}function nk(e,t,n,r,i,a){if(t===void 0||t===``){a.push({field:r,message:i});return}let o=e.find(e=>e.id===t);if(o===void 0||o.stageKind!==n){a.push({field:r,message:`That upload is no longer available; pick the file again.`});return}o.state!==`staged`&&a.push({field:r,message:`This upload is still copying.`})}function rk(e,t,n){for(let r of t){let t=Object.hasOwn(e.values,r)?e.values[r]:void 0;if(t===void 0||t===``){n.push({field:`values.${r}`,message:`This field is required.`});continue}t.length>200&&n.push({field:`values.${r}`,message:`A value is at most 200 characters.`}),/[\n\r]/.test(t)&&n.push({field:`values.${r}`,message:`A value is a single line.`})}}function ik(e){return e===void 0||e.trim()===``}function ak(e){return e!==void 0&&e.provider.trim()!==``&&e.model.trim()!==``}var ok=gO.parse({schemaVersion:1,form:{title:``,format:`16:9`,sources:{research:`off`,article:`generate`,audio:`generate`,images:`generate`,thumbnail:`off`,video:`generate`},llm:{provider:``,model:``},audio:{provider:``,model:``,voice:``},images:{provider:``,model:``},articlePrompt:``,imagePrompts:[],thumbnailPrompt:``,intro:``,outro:``,chunking:{mode:`whole`,words:`500`,characters:`3000`},subtitles:{...eO,fontSize:`48`},values:{},provided:{research:``,article:``,audio:null,images:[],thumbnail:null}},section:`content`,variants:[],expectedWords:`1500`,previewText:`Every story begins with a word.`,fontUpload:null});function sk(e){let t={...e.sources,...e.sources.article===`provide`?{research:`off`}:{},...e.sources.images===`off`?{video:`off`}:{}},n=t.audio===`off`?`off`:t.video===`off`&&e.subtitles.mode===`burn-in`?`files`:e.subtitles.mode;return{...e,sources:t,subtitles:{...e.subtitles,mode:n}}}function ck(e){let t=gO.parse(e);return JSON.stringify({...t,form:sk(t.form)})}function lk(e,t,n){return{...e,acknowledged:Math.max(e.acknowledged,t),version:n}}function uk(e,t){return t.type===`edit`?{...e,edited:e.edited+1}:lk(e,t.generation,t.version)}function dk(e,t,n){return{mutationId:n,document:gO.parse(JSON.parse(ck(e))),generation:t.edited,baseVersion:t.version}}function fk(){return{document:ok,view:null,clock:{edited:0,acknowledged:0,version:0},id:null,recoveryId:null,pending:null,status:`unsaved`,error:null,reveal:null}}function pk(e,t,n){let r=e.form.provided,i=t.form.provided,a=new Map;for(let[e,t]of[[r.audio,i.audio],[r.thumbnail,i.thumbnail],...r.images.map((e,t)=>[e,i.images[t]])])e&&t&&a.set(e.attachmentId,t.attachmentId);let o=e=>e?{...e,attachmentId:a.get(e.attachmentId)??e.attachmentId}:null;return{...n,form:{...n.form,provided:{...n.form.provided,audio:o(n.form.provided.audio),thumbnail:o(n.form.provided.thumbnail),images:n.form.provided.images.map(e=>({...e,attachmentId:a.get(e.attachmentId)??e.attachmentId}))}}}}function mk(e,t){if(e.draft.id!==t.id)return e;let n=t.document.form.provided,r=new Set([n.audio,n.thumbnail,...n.images].flatMap(e=>e?[e.attachmentId]:[]));return{...e,attachments:e.attachments.filter(e=>r.has(e.id)).map(e=>{let n=t.view?.attachments.find(t=>t.id===e.id);return(e.state===`pending`||e.state===`copying`)&&(n?.state===`ready`||n?.state===`reattach`)?n:e})}}function hk(e,t){return e?.draftId===t.draftId&&e.version===t.version&&e.editGeneration===t.editGeneration}function gk({api:e,queryClient:t,current:n,flush:r,render:i}){let a={receipt:null,pending:!1,starting:!1,uncertain:!1,valid:!1,error:null,fields:[],created:null},o,s=0,c=0,l=null,u=e=>{a={...a,...e},i()},d=()=>({draftId:n().id??``,version:n().clock.version,editGeneration:n().clock.edited}),f=()=>hk(o,d())&&n().clock.edited===n().clock.acknowledged,p=(e=!1)=>{s++,o=void 0,u({valid:!1,...e?{fields:[],error:null}:{}})},m=e=>u({error:e.message,fields:e.fields,valid:!1}),h=e=>{l=null,u({created:e,uncertain:!1,starting:!1,valid:!1})},g=async()=>{let t=l?.draftId;if(!t)return;let n=await FO(e,t);if(!n.ok){m(n);return}n.value.start&&h(n.value.start)};return{reset:()=>{s++,c++,o=void 0,l=null,a={receipt:null,pending:!1,starting:!1,uncertain:!1,valid:!1,error:null,fields:[],created:null},i()},state:()=>({...a,valid:a.valid&&f()}),invalidate:p,restore:e=>{s++,c++,o=void 0,l=e.pendingStart?{draftId:e.draft.id,baseVersion:e.pendingStart.draftVersion,reviewId:e.pendingStart.reviewId}:null,a={receipt:null,pending:!1,starting:!1,uncertain:l!==null,valid:!1,error:null,fields:[],created:e.start},i()},review:async()=>{if(a.pending||a.starting||a.uncertain||a.created)return;let i=++c;u({pending:!0,valid:!1,error:null,fields:[]});try{if(await Promise.all([XO(e,t),t.refetchQueries({queryKey:[`provider-models`]})]),i!==c||!await r()||!n().id)return;let a=d(),l=s,f=await zO(e,{id:a.draftId,baseVersion:a.version});if(i!==c||l!==s||!hk(a,d()))return;if(!f.ok){m(f);return}if(f.value.draftId!==a.draftId||f.value.draftVersion!==a.version)return;o=a,u({receipt:f.value,valid:!0})}catch(e){i===c&&u({error:e instanceof Error?e.message:`Couldn't review this draft`})}finally{i===c&&u({pending:!1})}},start:async()=>{if(a.starting||a.created||n().document.section!==`review`||!l&&(!a.valid||!f()||a.pending||!a.receipt||_k(n().document,n().view)!==void 0)||(!l&&a.receipt&&(l={draftId:a.receipt.draftId,baseVersion:a.receipt.draftVersion,reviewId:a.receipt.id}),!l))return;let t=l;JO(t.draftId),u({starting:!0,error:null});try{if(a.uncertain&&(await g(),a.created))return;let n=await BO(e,t);if(n.ok){h(n.value);return}n.reason===`pending-start`||n.reason===`already-started`?(u({uncertain:!0}),await g()):(l=null,u({uncertain:!1}),m(n))}catch(e){u({uncertain:!0,valid:!1,error:`${e instanceof Error?e.message:`Start response was lost`}. The result is uncertain. Check the same Start receipt before trying a new run.`})}finally{u({starting:!1})}}}}function _k(e,t){if(e.fontUpload!==null)return`subtitles.fontUpload`;let{sources:n,provided:r}=e.form;return[...n.audio===`provide`&&r.audio?[{ref:r.audio,field:`provided.audio`}]:[],...n.thumbnail===`provide`&&r.thumbnail?[{ref:r.thumbnail,field:`provided.thumbnail`}]:[],...n.images===`provide`?r.images.map((e,t)=>({ref:e,field:`provided.images.${t}`})):[]].find(({ref:e})=>t?.attachments.find(t=>t.id===e.attachmentId)?.state!==`ready`)?.field}function vk(e,t){return e?.draftId===t.draftId&&e.attachmentId===t.attachmentId}function yk({api:e,queryClient:t,state:n,edit:r,flush:i,generation:a,publish:o,render:s}){let c=(0,m.useRef)(0),l=(0,m.useRef)(null),u=(0,m.useRef)(null),d=(0,m.useRef)(new Map),f=(0,m.useRef)(new Map),p=e=>{let t=n.current.document.form.provided,r=[t.audio,t.thumbnail,...t.images].find(t=>t?.attachmentId===e.attachmentId);return vk(r&&n.current.id?{draftId:n.current.id,attachmentId:r.attachmentId}:void 0,e)};(0,m.useEffect)(()=>{for(let[e,t]of d.current)t!==a()&&d.current.delete(e);for(let[e,t]of f.current)(!p(t.owner)||t.generation!==a())&&(t.controller.abort(),f.current.delete(e))}),(0,m.useEffect)(()=>{let e=f.current,t=d.current;return()=>{c.current++,t.clear();for(let t of e.values())t.controller.abort();e.clear()}},[]);let h=async(t,l,u)=>{if(l.length===0)return;let m=t===`images`&&!u?l:l.slice(-1),h=m.map(e=>({attachmentId:crypto.randomUUID(),name:e.name})),g=c.current,_=a();for(let e of h)d.current.set(e.attachmentId,_);let v=n.current.document,y=v.form.provided;r({...v,form:{...v.form,provided:t===`images`?{...y,images:u?y.images.flatMap(e=>e.attachmentId===u?h:[e]):[...y.images,...h]}:{...y,[t]:h.at(-1)??null}}});let b=await i();for(let e of h)d.current.delete(e.attachmentId);if(!b||_!==a()||g!==c.current){s();return}let x=n.current.id;x&&await Promise.all(h.map(async(r,i)=>{let s=m[i],l={draftId:x,attachmentId:r.attachmentId};if(!s||!p(l))return;let u=new AbortController;f.current.set(r.attachmentId,{owner:l,controller:u,generation:_});let d=e=>{let t=n.current.view;_===a()&&g===c.current&&t?.draft.id===x&&p(l)&&!u.signal.aborted&&o({view:{...t,review:null,attachments:[...t.attachments.filter(e=>e.id!==r.attachmentId),e]}})};try{let n=await HO(e,x,r.attachmentId,s,u.signal);n.ok?d(n.value):d({id:r.attachmentId,kind:t,name:r.name,state:`reattach`,stagedFileId:null,bytes:0,error:n.message})}catch(e){d({id:r.attachmentId,kind:t,name:r.name,state:`reattach`,stagedFileId:null,bytes:0,error:e instanceof Error?e.message:`Reattach this file`})}finally{f.current.delete(r.attachmentId)}}))},g=e=>{l.current=null;let t=n.current.document;r({...t,fontUpload:null,form:{...t.form,subtitles:{...t.form.subtitles,fontId:e}}})},_=async o=>{let d=crypto.randomUUID();l.current=d,r({...n.current.document,fontUpload:{operationId:d,name:o.name}});let f=c.current,p=a();if(!await i()||p!==a()||f!==c.current){l.current===d&&(l.current=null),s();return}if(n.current.document.fontUpload?.operationId===d)try{let{font:r}=await GO(e,o);if(p!==a()||f!==c.current||n.current.document.fontUpload?.operationId!==d)return;t.setQueryData(UO,e=>({fonts:[...(e?.fonts??[]).filter(e=>e.id!==r.id),r]})),g(r.id),await i()}catch(e){p===a()&&f===c.current&&n.current.document.fontUpload?.operationId===d&&(u.current={operationId:d,message:e instanceof Error?e.message:`Reattach this font`},s())}finally{l.current===d&&(l.current=null,s())}},v=l.current!==null&&l.current===n.current.document.fontUpload?.operationId;return{attachmentUploading:e=>{let t=f.current.get(e);return d.current.get(e)===a()||t!==void 0&&t.generation===a()&&p(t.owner)&&!t.controller.signal.aborted},fontUpload:{pending:v,error:u.current?.operationId===n.current.document.fontUpload?.operationId?u.current?.message:void 0,pick:e=>{_(e)}},attach:h,selectFont:g,uploadSubtitleFont:_,fontUploading:v}}function bk(e,t,n){(0,m.useEffect)(()=>{let r=e=>[`prompts`,`entries`,`providers`,`provider-models`,`fonts`,`settings`].includes(String(e[0])),i=t.getQueryCache().subscribe(e=>{e.type===`updated`&&r(e.query.queryKey)&&(e.action.type===`success`||e.action.type===`invalidate`)&&n.invalidate()}),a=()=>{n.invalidate(),XO(e,t),t.refetchQueries({queryKey:[`provider-models`]})};return window.addEventListener(`focus`,a),()=>{i(),window.removeEventListener(`focus`,a)}},[e,t,n])}function xk(){let{api:e}=I(),t=_(),[,n]=(0,m.useReducer)(e=>e+1,0),r=(0,m.useRef)(fk()),i=(0,m.useMemo)(()=>{let i,a=null,o=!1,s=0,c=!1,l=null,u=!0,d=e=>{r.current={...r.current,...e},u&&n()},f=()=>{clearTimeout(i),i=void 0},p=()=>{t.invalidateQueries({queryKey:[`play-drafts`]})},m=e=>{d({status:`error`,error:e instanceof Error?e.message:`Couldn't save draft`})},h=e=>e.ok?!0:(d({status:e.reason===`conflict`?`conflict`:`error`,error:e.message}),!1),g=e=>{b.restore(e),d({...fk(),document:e.draft.document,view:e,id:e.draft.id,clock:{edited:0,acknowledged:0,version:e.draft.version},status:`saved`}),JO(e.draft.id),p()},_=async()=>{let t=s;for(;r.current.clock.edited>r.current.clock.acknowledged;){if(r.current.status===`conflict`||t!==s||l!==null&&l===r.current.id)return!1;let n=r.current,i=n.id??crypto.randomUUID(),a=n.pending??dk(n.document,n.clock,crypto.randomUUID());d({id:i,pending:a,status:`saving`,error:null});try{let n=a.baseVersion===0?await PO(e,{id:i,document:a.document}):await IO(e,{id:i,baseVersion:a.baseVersion,mutationId:a.mutationId,document:a.document});if(t!==s)return!1;if(!h(n))return n.reason!==`conflict`&&d({pending:null}),!1;let c=uk(r.current.clock,{type:`acknowledge`,generation:a.generation,version:n.value.draft.version});if(d({clock:c,view:{...mk(n.value,r.current),review:c.edited>c.acknowledged?null:n.value.review},pending:null,status:c.edited>c.acknowledged?`unsaved`:`saved`,error:null}),JO(i),p(),!o)return!0}catch(e){return t===s&&m(e),!1}}return r.current.status!==`conflict`&&r.current.status!==`error`},v=()=>c?Promise.resolve(!1):a||(r.current.clock.edited===r.current.clock.acknowledged?Promise.resolve(!0):l!==null&&l===r.current.id?Promise.resolve(!1):(a=_().finally(()=>{a=null}),a)),y=()=>(f(),o=!0,v()),b=gk({api:e,queryClient:t,current:()=>r.current,flush:y,render:()=>{u&&n()}}),x=e=>{if(b.state().starting||b.state().uncertain||b.state().created)return;b.invalidate(JSON.stringify({...e,section:r.current.document.section})!==JSON.stringify(r.current.document));let t=r.current;d({document:e,clock:uk(t.clock,{type:`edit`}),view:t.view?{...t.view,review:null}:null,status:t.status===`conflict`||t.status===`error`?t.status:`unsaved`}),f(),!(c||l!==null&&l===t.id||t.status===`conflict`||t.status===`error`)&&(t.id?i=setTimeout(()=>{y()},500):(o=!1,v()))},S=async(n,i=()=>!0)=>{if(b.state().starting||b.state().uncertain||b.state().created||(r.current.id!==n||r.current.status!==`conflict`)&&!await y()||!i())return!1;let a=++s,o=r.current.clock.edited;f();try{let c=await FO(e,n);return a!==s||o!==r.current.clock.edited||!i()?!1:h(c)?(T=null,g(c.value),await XO(e,t),i()):(r.current.id||d({recoveryId:n}),!1)}catch(e){return a===s&&o===r.current.clock.edited&&(m(e),r.current.id||d({recoveryId:n})),!1}},C=async()=>{if(b.state().starting||b.state().uncertain||b.state().created)return;let e=s;await y()&&e===s&&(s++,T=null,d(fk()),b.reset(),JO(null))},w=async({id:t,version:n})=>{if(b.state().starting||b.state().uncertain||b.state().created)throw Error(`Resolve the pending Start before discarding a draft`);if(c||l!==null)throw Error(`Wait for the current draft operation before discarding`);let i=s;l=t,(r.current.id??r.current.recoveryId)===t&&f();try{a&&await a;let o=await RO(e,{id:t,baseVersion:n});if(!o.ok&&o.reason!==`not-found`)throw Error(o.message);if(p(),i!==s||(r.current.id??r.current.recoveryId)!==t)return;f(),s++,T=null,d(fk()),b.reset(),JO(null)}finally{l=null}},T=null;return{review:b,takeCreated:()=>{let e=b.state().created;if(!e)return null;s++,d(fk()),b.reset(),JO(null);for(let e of[[`projects`],[`staging`],[`play-drafts`]])t.invalidateQueries({queryKey:e});return e},edit:x,flush:y,open:S,newDraft:C,discard:w,saveAsNew:async()=>{if(b.state().starting||b.state().uncertain||b.state().created||(f(),c||l!==null))return;a&&await a;let t=r.current;if(!t.id||!t.view&&t.status!==`conflict`){await y();return}let n=s;T?.sourceId!==t.id&&(T=null),T??={sourceId:t.id,id:crypto.randomUUID(),document:dk(t.document,t.clock,crypto.randomUUID()).document,generation:t.clock.edited};let i=T;c=!0;try{let t=await LO(e,{sourceId:i.sourceId,id:i.id,document:i.document});if(n!==s)return;if(!h(t)){t.reason===`conflict`&&(T=null);return}let a=r.current.clock.edited>i.generation?r.current.document:null;s++,g(t.value),T=null,c=!1,a&&x(pk(i.document,t.value.draft.document,a))}catch(e){n===s&&m(e)}finally{c=!1}},navigate:async(e,t)=>{let n=s,i={...r.current.document,section:e};r.current.id||r.current.clock.edited>0?x(i):d({document:i}),await y()&&n===s&&d({reveal:{section:e,...t===void 0?{}:{field:t},sequence:(r.current.reveal?.sequence??0)+1}})},generation:()=>s,publish:d,start:()=>{u=!0;let e=YO();e&&S(e)},stop:()=>{u=!1,f()}}},[e,t]);(0,m.useEffect)(()=>(i.start(),i.stop),[i]),bk(e,t,i.review);let a=yk({api:e,queryClient:t,state:r,edit:i.edit,flush:i.flush,generation:i.generation,publish:i.publish,render:n}),o=r.current;return{...a,review:i.review.state(),reviewDraft:i.review.review,startRun:i.review.start,invalidateReview:i.review.invalidate,takeCreated:i.takeCreated,document:o.document,section:o.document.section,view:o.view,status:o.status,error:o.error,edited:o.clock.edited,acknowledged:o.clock.acknowledged,reveal:o.reveal,edit:i.edit,flush:i.flush,open:i.open,generation:i.generation,newDraft:i.newDraft,discard:i.discard,saveAsNew:i.saveAsNew,navigate:i.navigate,activeId:o.id??o.recoveryId}}var Sk=(0,m.createContext)(null);function Ck({children:e}){let t=xk();return(0,h.jsx)(Sk.Provider,{value:t,children:e})}function wk(){let e=(0,m.useContext)(Sk);if(!e)throw Error(`PlayDraftProvider is required`);return e}var Tk=(0,m.createContext)(void 0);function Ek({children:e}){let[t,n]=(0,m.useState)(()=>new Map),r=(0,m.useCallback)((e,t)=>{n(n=>{let r=n.get(e),i=typeof t==`function`?t(r):t;if(r===i)return n;let a=new Map(n);return i===void 0?a.delete(e):a.set(e,i),a})},[]),i=(0,m.useMemo)(()=>({prompts:t,updatePrompt:r}),[t,r]);return(0,h.jsx)(Tk.Provider,{value:i,children:e})}function Dk(e){let t=(0,m.useContext)(Tk),[n,r]=(0,m.useState)(void 0),i=t?.updatePrompt,a=(0,m.useCallback)(t=>{i?i(e,t):r(t)},[e,i]);return[t?t.prompts.get(e):n,a]}function Ok(){let e=wk(),t=(0,m.useRef)(e);t.current=e;let n=e.document.form,r=t=>{if(!t)return;let n=e.view?.attachments.find(e=>e.id===t.attachmentId),r=n?.state===`ready`&&n.stagedFileId?{id:n.stagedFileId,stageKind:n.kind,path:n.stagedFileId,originalFilename:n.name,bytes:n.bytes,state:`staged`,createdAt:e.view?.draft.createdAt??``}:void 0;return{key:t.attachmentId,name:t.name,file:r,error:n?.error??(n?.state===`reattach`||!r&&!e.attachmentUploading(t.attachmentId)?`Reattach this file`:void 0)}},i={...n,imagePrompts:n.imagePrompts.map(e=>({...e,number:Number(e.number)})),chunking:n.chunking.mode===`words`?{mode:`words`,...n.chunking.words===``?{}:{words:Number(n.chunking.words)}}:n.chunking.mode===`characters`?{mode:`characters`,...n.chunking.characters===``?{}:{characters:Number(n.chunking.characters)}}:{mode:n.chunking.mode},subtitles:{...n.subtitles,fontSize:Number(n.subtitles.fontSize)},provided:{...n.provided,audio:r(n.provided.audio),thumbnail:r(n.provided.thumbnail),images:n.provided.images.flatMap(e=>{let t=r(e);return t?[t]:[]})}},a=(0,m.useRef)(i);return a.current=i,[i,(0,m.useCallback)(e=>{let n=t.current.document,r=typeof e==`function`?e(a.current):e;a.current=r;let i=(e,t)=>e===void 0?``:Object.is(e,Number(t))?t:String(e),o=e=>e?{attachmentId:e.key,name:e.name}:null;t.current.edit({...n,form:{...r,imagePrompts:r.imagePrompts.map(e=>({...e,number:i(e.number,n.form.imagePrompts.find(t=>t.name===e.name)?.number??String(e.number))})),chunking:{...n.form.chunking,mode:r.chunking.mode,...r.chunking.mode===`words`?{words:i(r.chunking.words,n.form.chunking.words)}:{},...r.chunking.mode===`characters`?{characters:i(r.chunking.characters,n.form.chunking.characters)}:{}},subtitles:{...n.form.subtitles,...r.subtitles,fontSize:i(r.subtitles.fontSize,n.form.subtitles.fontSize)},provided:{...r.provided,audio:o(r.provided.audio),thumbnail:o(r.provided.thumbnail),images:r.provided.images.map(e=>({attachmentId:e.key,name:e.name}))}}})},[])]}function kk(e,t){if(e===void 0)return;if(t.type===`project.state`)return{...e,project:{...e.project,status:t.state}};let n=e.stages.findIndex(e=>e.kind===t.stage),r=e.stages[n];return r===void 0?e:{...e,stages:e.stages.with(n,Ak(r,t))}}function Ak(e,t){return t.type===`stage.progress`?{...e,progressCurrent:t.current,progressTotal:t.total}:{...e,state:t.state,failureReason:t.failureReason??e.failureReason}}function jk(e,t){let n,r=!1,i=()=>{n=void 0,r&&(r=!1,e(),a())},a=()=>{n=setTimeout(i,t)};return{ask:()=>{if(n!==void 0){r=!0;return}e(),a()},stop:()=>{n!==void 0&&clearTimeout(n),n=void 0,r=!1}}}var Mk=[{id:`text-key`,title:`1. Connect a text provider`,target:`keys-llm`,page:`settings`},{id:`audio-key`,title:`2. Connect a voice provider`,target:`keys-tts`,page:`settings`},{id:`image-key`,title:`3. Connect an image provider`,target:`keys-image`,page:`settings`},{id:`voice`,title:`4. Add a narration voice`,target:`voices`,page:`settings`},{id:`article-name`,title:`5. Name your article prompt`,target:`prompt-name`,page:`article`},{id:`article-body`,title:`6. Write instructions with keywords`,target:`prompt-body`,page:`article`},{id:`article-keywords`,title:`7. Check the detected keywords`,target:`prompt-slots`,page:`article`},{id:`article-save`,title:`8. Save your article prompt`,target:`prompt-save`,page:`article`},{id:`image-prompt`,title:`9. Create an image prompt`,target:`prompt-editor`,page:`image`},{id:`image-save`,title:`10. Save your image prompt`,target:`prompt-save`,page:`image`},{id:`play-options`,title:`11. Name the project and choose text generation`,target:`play-options`,page:`play`},{id:`play-article`,title:`12. Choose your article`,target:`play-article`,page:`play`},{id:`play-keywords`,title:`13. Fill in your keywords`,target:`play-keywords`,page:`play`},{id:`play-audio`,title:`14. Choose narration`,target:`play-audio`,page:`play`},{id:`play-images`,title:`15. Choose images`,target:`play-images`,page:`play`},{id:`play-video`,title:`16. Choose video output`,target:`play-video`,page:`play`},{id:`play-subtitles`,title:`17. Style optional subtitles`,target:`play-subtitles`,page:`play`},{id:`play-start`,title:`18. Review and start your run`,target:`play-start`,page:`play`},{id:`project`,title:`19. Follow and control the run`,target:`project-controls`,page:`project`},{id:`download`,title:`20. Download your results`,target:`project-video`,page:`project`}];function Nk(e,t){return e.active?t.type===`project-created`?{...e,projectId:t.id,step:Mk.findIndex(e=>e.id===`project`)}:t.kind===`article`?{...e,articleId:t.id}:t.kind===`image`?{...e,imageId:t.id}:e:e}function Pk(e){let t=Mk.findIndex(t=>t.id===e);return t<0?void 0:t}var Fk={"play-options":`content`,"play-article":`content`,"play-keywords":`content`,"play-audio":`outputs`,"play-images":`outputs`,"play-video":`outputs`,"play-subtitles":`style`,"play-start":`review`};function Ik(e){return e.kind===`keyed`?e.hasKey:e.installed&&e.issue===void 0}var Lk={research:`Research`,article:`Article`,audio:`Audio`,images:`Images`,thumbnail:`Thumbnail`,video:`Video`};function Rk(e){return e.sources.video===`off`?e.sources.audio===`off`?`article`:`audio`:`video`}function zk(e,t){return e===`video`&&Rk(t)===`audio`?`Audio export`:Lk[e]}function Bk(e,t){return e.kind===`video`&&e.state===`running`&&t.subtitles!==void 0&&t.subtitles.mode!==`off`&&e.progressTotal===100&&(e.progressCurrent??0)<=35}var Vk={research:(e,t)=>`chapter ${String(e)} of ${String(t)}`,article:(e,t)=>`${String(e)} of ${String(t)}`,audio:(e,t)=>`chunk ${String(e)} of ${String(t)}`,images:(e,t)=>`image ${String(e)} of ${String(t)}`,thumbnail:(e,t)=>`${String(e)} of ${String(t)}`,video:(e,t)=>`${String(Yk(e,t))}% rendered`},Hk={audio_intro:`intro`,audio_body:`body`,audio_outro:`outro`};function Uk(e,t,n){let r=t.filter(t=>t.stageKind===e.kind);switch(e.state){case`skipped`:return`Not part of this run`;case`pending`:return n.status===`paused`?`Waiting for Resume`:e.kind===`images`||e.kind===`thumbnail`&&e.source===`from_prompt`?`Ready to run`:`Waits for the stages above`;case`provided`:return Kk(r)??`Provided`;case`failed`:return`Stopped after ${Wk(e)}`;case`canceled`:return`Canceled by user`;case`running`:return Bk(e,n.config)?`Preparing subtitles · ${String(Yk(e.progressCurrent??0,35))}%`:e.kind===`video`&&Rk(n.config)===`audio`?`Exporting combined audio`:e.progressTotal===null||e.progressTotal<=0?`Running`:Vk[e.kind](e.progressCurrent??0,e.progressTotal);case`done`:return Gk(e.kind,r,n)}}function Wk(e){return e.attemptCount===1?`1 attempt`:`${String(e.attemptCount)} attempts`}function Gk(e,t,n){switch(e){case`research`:return`Notes ready`;case`article`:{let e=t.filter(e=>e.role===`sources`||e.role===`glossary`);return e.length===0?`Article ready`:`Article and ${String(e.length)} end-matter files`}case`audio`:return $k([Zk(t.flatMap(e=>{let t=Hk[e.role];return t===void 0?[]:[t]})),Jk(qk(t))]);case`images`:return Xk(t.filter(e=>e.role===`image`).length,`image`);case`thumbnail`:return t.length===0?`Thumbnail ready`:`1 image`;case`video`:return $k([Jk(qk(t)),Rk(n.config)===`audio`?`WAV · stereo · 48 kHz`:n.format])}}function Kk(e){let t=e.flatMap(e=>e.originalFilename===null?[]:[e.originalFilename]);return t.length===0?void 0:t.join(`, `)}function qk(e){let t=Math.max(0,...e.map(e=>e.durationMs??0));return t===0?void 0:t}function Jk(e){if(e===void 0||!Number.isFinite(e)||e<=0)return;let t=Math.round(e/1e3),n=[Math.floor(t/60)%60,t%60].map(e=>String(e).padStart(2,`0`)),r=Math.floor(t/3600);return r===0?n.join(`:`):[String(r),...n].join(`:`)}function Yk(e,t){return t<=0?0:Math.min(100,Math.max(0,Math.round(e/t*100)))}function Xk(e,t){return e===1?`1 ${t}`:`${String(e)} ${t}s`}function Zk(e){if(e.length!==0)return e.length===1?Qk(e[0]??``):Qk(`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]??``}`)}function Qk(e){return e.charAt(0).toUpperCase()+e.slice(1)}function $k(e){return e.filter(e=>e!==void 0&&e!==``).join(` · `)}var eA=12,tA=16;function nA(e,t,n){return Math.max(t,Math.min(e,Math.max(t,n)))}function rA(e,t,n){let r=Math.min(n.width,t.width-24),i=nA(e?.left??(t.width-r)/2,eA,t.width-r-eA),a=nA((e?.top??0)+((e?.height??t.height)-n.height)/2,eA,t.height-n.height-eA),o=t.height-n.height-eA;if(!e)return{left:i,top:a,width:r,docked:!1};let s=e.left+e.width,c=e.top+e.height;return s+tA+r<=t.width-eA?{left:s+tA,top:a,width:r,docked:!1}:e.left-tA-r>=eA?{left:e.left-tA-r,top:a,width:r,docked:!1}:c>=eA&&c+tA+n.height<=t.height-eA?{left:i,top:c+tA,width:r,docked:!1}:e.top-tA-n.height>=eA&&e.top<=t.height-eA?{left:i,top:e.top-tA-n.height,width:r,docked:!1}:{left:t.width-r-eA,top:Math.max(eA,o),width:r,docked:!0}}function iA(e,t,n=t.height){let r=nA(e.left-6,0,t.width),i=nA(e.top-6,0,Math.min(n,t.height)),a=nA(e.left+e.width+6,0,t.width),o=nA(e.top+e.height+6,0,Math.min(n,t.height));return a>r&&o>i?{left:r,top:i,width:a-r,height:o-i}:null}var aA=`[data-slot="select-content"], [data-slot="dropdown-menu-content"]`;function oA(e){try{return document.querySelector(e)}catch{return null}}function sA(){return[...document.querySelectorAll(`[data-slot="dialog-content"][data-state="open"]`)].at(-1)??null}function cA(e){if(!e)return[];let t=[e,...e.querySelectorAll(`[aria-controls]`)],n=new Set(t.flatMap(e=>(e.getAttribute(`aria-controls`)??``).split(` `)));return[...document.querySelectorAll(aA)].filter(e=>n.has(e.id))}function lA(e){let t=e.getBoundingClientRect();return t.width>0&&t.height>0?{left:t.left,top:t.top,width:t.width,height:t.height}:null}var uA=`a[href], button, input, select, textarea, summary, [tabindex], [contenteditable="true"]`;function dA(e,t,n,r){let i=(0,m.useRef)(document.activeElement),a=(0,m.useRef)(t);a.current=t,(0,m.useEffect)(()=>{let e=i.current;return()=>{queueMicrotask(()=>{e instanceof HTMLElement&&e.isConnected&&!n.current&&e.focus({preventScroll:!0})})}},[n]),(0,m.useEffect)(()=>{let t=()=>{let t=oA(e);return[t,n.current,...cA(t)].filter(e=>e!==null)},i=e=>e instanceof Node&&t().some(t=>t.contains(e)),o=e=>{sA()||i(e.target)||(e.preventDefault(),e.stopImmediatePropagation())},s=e=>{sA()||i(e.target)||e.target instanceof HTMLElement&&e.target.hasAttribute(`data-radix-focus-guard`)||r.current?.focus({preventScroll:!0})},c=n=>{if(sA())return;let r=cA(oA(e));if(n.key===`Escape`){if(r.length>0)return;n.preventDefault(),n.stopImmediatePropagation(),a.current();return}if(n.key!==`Tab`){i(n.target)||o(n);return}if(r.length>0)return;let s=t().flatMap(e=>[e,...e.querySelectorAll(uA)]).filter((e,t,n)=>n.indexOf(e)===t&&e.tabIndex>=0&&!e.matches(`:disabled, [hidden], [aria-hidden='true']`)&&!e.closest(`[hidden], [inert]`)&&(!e.closest(`details:not([open])`)||e.closest(`summary`)!==null));if(s.length===0)return;let c=s.indexOf(document.activeElement),l=c===-1?n.shiftKey?s.length-1:0:(c+(n.shiftKey?-1:1)+s.length)%s.length;n.preventDefault(),s[l]?.focus()},l=[`pointerdown`,`pointerup`,`mousedown`,`mouseup`,`click`,`dblclick`,`contextmenu`];for(let e of l)window.addEventListener(e,o,!0);return window.addEventListener(`keydown`,c,!0),window.addEventListener(`focusin`,s,!0),()=>{for(let e of l)window.removeEventListener(e,o,!0);window.removeEventListener(`keydown`,c,!0),window.removeEventListener(`focusin`,s,!0)}},[e,n,r])}function fA(e,t,n,r,i,a){let[o,s]=(0,m.useState)(()=>({key:e,target:null,portals:[],width:window.innerWidth,height:window.innerHeight,cardHeight:260,modalOpen:sA()!==null}));return(0,m.useLayoutEffect)(()=>{let o=0,c=0,l=null,u=null,d=new Map,f=new ResizeObserver(()=>h()),p=e=>{for(let[t,n]of d)e.has(t)||(t.style.zIndex=n,d.delete(t))},m=()=>{o=0;let r=oA(t);r!==u&&(u&&f.unobserve(u),r&&f.observe(r),u=r);let i=r?lA(r):null;r&&i&&l!==r&&(l=r,cancelAnimationFrame(c),c=requestAnimationFrame(()=>{c=0,r.isConnected&&(r.scrollIntoView({block:`start`,inline:`nearest`,behavior:`instant`}),m())}));let a=cA(r),h=new Set;for(let e of a){let t=e.closest(`[data-radix-popper-content-wrapper]`)??e;h.add(t),d.has(t)||(d.set(t,t.style.zIndex),t.style.zIndex=`102`)}p(h);let g={key:e,target:i,portals:a.map(lA).filter(e=>e!==null),width:window.innerWidth,height:window.innerHeight,cardHeight:n.current?.getBoundingClientRect().height||260,modalOpen:sA()!==null};s(e=>JSON.stringify(e)===JSON.stringify(g)?e:g)};function h(){o||=requestAnimationFrame(m)}let g=new MutationObserver(e=>{e.some(e=>!i.current?.contains(e.target)&&e.target!==a.current)&&h()});return g.observe(document.body,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`id`,`class`,`style`,`hidden`,`aria-controls`,`data-state`,`data-tour`]}),n.current&&f.observe(n.current),f.observe(document.documentElement),window.addEventListener(`resize`,h),window.addEventListener(`scroll`,h,!0),window.visualViewport?.addEventListener(`resize`,h),window.visualViewport?.addEventListener(`scroll`,h),m(),sA()||r.current?.focus({preventScroll:!0}),()=>{cancelAnimationFrame(o),cancelAnimationFrame(c),f.disconnect(),g.disconnect(),window.removeEventListener(`resize`,h),window.removeEventListener(`scroll`,h,!0),window.visualViewport?.removeEventListener(`resize`,h),window.visualViewport?.removeEventListener(`scroll`,h),p(new Set)}},[e,t,n,r,i,a]),o}function pA({stepId:e,target:t,title:n,children:r,progress:i,onNext:a,onBack:o,onClose:s,nextLabel:c=`Next`,nextDisabled:l=!1,onSkip:u,skipLabel:d=`Skip this step`}){let f=(0,m.useId)(),p=`${e}:${t}`,g=(0,m.useRef)(null),_=(0,m.useRef)(null),v=(0,m.useRef)(null),y=(0,m.useRef)(null),b=fA(p,t,g,_,v,y);dA(t,s,g,_);let[x,S]=(0,m.useState)({key:p,height:0}),C=b.key===p?b.target:null,w={width:b.width,height:b.height},T={width:Math.min(360,w.width-24),height:b.cardHeight},E=rA(C,w,T),D=C?iA(C,w,E.docked?E.top-12:w.height):null,O=b.key===p?b.portals.map(e=>iA(e,w)).filter(e=>e!==null):[],k=[...D?[D]:[],...O],A=`M0 0H${w.width}V${w.height}H0Z`+(D?`M${D.left} ${D.top}H${D.left+D.width}V${D.top+D.height}H${D.left}Z`:``);(0,m.useLayoutEffect)(()=>{S(e=>{let t=Math.max(e.key===p?e.height:0,E.docked?T.height+24:0);return e.key===p&&e.height===t?e:{key:p,height:t}})},[p,E.docked,T.height]);let j=x.key===p?x.height:0;return(0,m.useEffect)(()=>{let e=document.documentElement,t=e.style.scrollPaddingBottom;return e.style.scrollPaddingBottom=`${j}px`,()=>{e.style.scrollPaddingBottom=t}},[j]),(0,cl.createPortal)((0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`div`,{ref:y,"aria-hidden":`true`,style:{height:j}}),(0,h.jsxs)(`div`,{ref:v,hidden:b.modalOpen,"data-tutorial":`spotlight`,className:`pointer-events-none fixed inset-0 z-[100] font-sans`,children:[(0,h.jsxs)(`svg`,{"aria-hidden":`true`,className:`absolute inset-0 h-full w-full`,width:w.width,height:w.height,children:[(0,h.jsx)(`defs`,{children:(0,h.jsxs)(`mask`,{id:`${f}-mask`,children:[(0,h.jsx)(`rect`,{width:`100%`,height:`100%`,fill:`white`}),k.map(e=>(0,h.jsx)(`rect`,{x:e.left,y:e.top,width:e.width,height:e.height,rx:`6`,fill:`black`},`${e.left}:${e.top}:${e.width}:${e.height}`))]})}),(0,h.jsx)(`rect`,{width:`100%`,height:`100%`,fill:`rgb(0 0 0 / 0.72)`,mask:`url(#${f}-mask)`}),(0,h.jsx)(`path`,{d:A,fill:`transparent`,fillRule:`evenodd`,pointerEvents:`fill`}),D&&(0,h.jsx)(`rect`,{"data-tutorial":`hole`,x:D.left,y:D.top,width:D.width,height:D.height,rx:`6`,fill:`none`,stroke:`var(--color-accent)`,strokeWidth:`2`})]}),(0,h.jsxs)(`section`,{ref:g,"aria-label":`Interactive getting started guide`,"aria-describedby":`${f}-instructions`,"data-tutorial":`card`,className:`pointer-events-auto fixed z-[101] flex flex-col gap-3 rounded-panel border border-line2 bg-panel p-4 text-body text-ink shadow-[0_8px_24px_var(--color-shadow)]`,style:{left:E.left,top:E.top,width:E.width,maxHeight:Math.min(w.height-24,Math.max(160,Math.min(420,w.height*.48)))},children:[(0,h.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3`,children:[(0,h.jsxs)(`span`,{className:`engraved text-run-text`,children:[`Getting started · `,i]}),(0,h.jsx)(B,{variant:`ghost`,onClick:s,"aria-label":`Exit guide`,className:`h-7 px-2`,children:`Exit`})]}),(0,h.jsx)(`h2`,{ref:_,id:`${f}-title`,tabIndex:-1,className:`shrink-0 text-title font-bold outline-none`,children:n}),(0,h.jsxs)(`div`,{id:`${f}-instructions`,className:`min-h-0 overflow-y-auto text-ink2 [&_p+p]:mt-2 [&_code]:text-ink`,children:[r,!C&&(0,h.jsx)(`p`,{role:`status`,className:`mt-3 text-amber`,children:`This section is not available yet. Wait for the page to load, go back, or exit the guide.`}),E.docked&&C&&(0,h.jsx)(`p`,{className:`mt-3 text-small`,children:`Scroll the page to work through the highlighted section.`})]}),(0,h.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-line pt-3`,children:[o&&(0,h.jsx)(B,{onClick:o,children:`Back`}),u&&(0,h.jsx)(B,{variant:`ghost`,onClick:u,className:`px-2`,children:d}),(0,h.jsx)(B,{variant:`primary`,onClick:a,disabled:l||!C,className:`ml-auto`,children:c})]})]})]})]}),document.body)}function mA({href:e,children:t}){return(0,h.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`text-ink underline underline-offset-2`,children:t})}function hA({text:e}){let[t,n]=(0,m.useState)(!1),[r,i]=(0,m.useState)(!1);return(0,h.jsxs)(`div`,{className:`space-y-2`,children:[(0,h.jsx)(`p`,{className:`select-text rounded-control border border-line2 bg-panel2 p-3 text-small leading-relaxed`,children:e}),(0,h.jsx)(B,{onClick:()=>{if(i(!1),!navigator.clipboard){i(!0);return}navigator.clipboard.writeText(e).then(()=>n(!0),()=>i(!0))},children:t?`Copied`:`Copy example`}),r?(0,h.jsx)(`p`,{role:`status`,children:`Select the example above and copy it manually.`}):null]})}function gA({step:e}){switch(e){case`text-key`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`First, choose what will write your scripts. You only need one text provider.`}),(0,h.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5`,children:[(0,h.jsxs)(`li`,{children:[`Sign in to `,(0,h.jsx)(mA,{href:`https://openrouter.ai/settings/keys`,children:`OpenRouter`}),`, create an API key, and make sure the account can use your chosen model.`]}),(0,h.jsxs)(`li`,{children:[`Paste it into OpenRouter’s `,(0,h.jsx)(`strong`,{children:`API key`}),` field here and press`,` `,(0,h.jsx)(`strong`,{children:`Save`}),`.`]})]}),(0,h.jsx)(`p`,{children:`Already using Claude Code, Codex or Gemini CLI? You can use its existing CLI login instead. “Installed” means Slopify found the CLI; sign in through that CLI before generating. If it is missing, enter its executable path and save to check again.`}),(0,h.jsx)(`p`,{className:`text-ink3`,children:`These are the real Settings controls. The tutorial never reads your key. Skip any step you have already handled.`})]});case`audio-key`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`The voice provider turns the finished article into audio. Choose`,` `,(0,h.jsx)(`strong`,{children:`ElevenLabs`}),`, `,(0,h.jsx)(`strong`,{children:`OpenAI`}),`, or `,(0,h.jsx)(`strong`,{children:`Cartesia`}),`; you do not need all three.`]}),(0,h.jsxs)(`p`,{children:[`Create a key in your provider’s account, enable the API access or credits it requires, then paste the key into its row and press `,(0,h.jsx)(`strong`,{children:`Save`}),`.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(mA,{href:`https://elevenlabs.io/app/developers/api-keys`,children:`ElevenLabs keys`}),` `,`· `,(0,h.jsx)(mA,{href:`https://platform.openai.com/api-keys`,children:`OpenAI keys`}),` ·`,` `,(0,h.jsx)(mA,{href:`https://play.cartesia.ai/keys`,children:`Cartesia keys`})]}),(0,h.jsx)(`p`,{children:`Next, you’ll add the exact voice that this provider should use. Skip voice setup if you plan to provide your own narration or turn Audio Off.`})]});case`image-key`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Choose one image provider, create a key in its dashboard, paste it into the matching row, and press `,(0,h.jsx)(`strong`,{children:`Save`}),`.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(mA,{href:`https://fal.ai/dashboard/keys`,children:`fal.ai`}),` ·`,` `,(0,h.jsx)(mA,{href:`https://replicate.com/account/api-tokens`,children:`Replicate`}),` ·`,` `,(0,h.jsx)(mA,{href:`https://aistudio.google.com/apikey`,children:`Google AI Studio`}),` ·`,` `,(0,h.jsx)(mA,{href:`https://platform.openai.com/api-keys`,children:`OpenAI`})]}),(0,h.jsxs)(`p`,{children:[`A saved key is not a billing check. The selected image model needs available quota. If Google reports `,(0,h.jsx)(`strong`,{children:`limit: 0`}),`, check the key’s project, billing and image-model quota before retrying.`]}),(0,h.jsx)(`p`,{children:`OpenAI’s voice and image rows are saved separately, even when you use the same API key. Skip this step if you plan to provide your own images or turn Images and Thumbnail Off.`})]});case`voice`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5`,children:[(0,h.jsxs)(`li`,{children:[`Enter a `,(0,h.jsx)(`strong`,{children:`Voice name`}),` you will recognize, such as “Travel narrator.”`]}),(0,h.jsxs)(`li`,{children:[`Select the `,(0,h.jsx)(`strong`,{children:`Provider`}),` whose voice key you saved.`]}),(0,h.jsxs)(`li`,{children:[`Copy the exact `,(0,h.jsx)(`strong`,{children:`Voice ID`}),` from that provider’s voice library or documentation.`]}),(0,h.jsxs)(`li`,{children:[`Press `,(0,h.jsx)(`strong`,{children:`Add voice`}),`.`]})]}),(0,h.jsx)(`p`,{children:`The name is your label; the ID tells the provider which voice to use. Slopify checks the ID with the provider when narration runs. A voice is only required when Audio is set to Generate.`})]})}}var _A=`Write a 150-word narration about {{topic}} for {{audience}}. Open with an interesting fact, explain three highlights, and end with one memorable takeaway. Use natural spoken English. Return only the narration, without headings or stage directions.`,vA=`A cinematic editorial photograph of {{topic}}, with natural light, a clear focal point, rich detail, and no text or logos. Compose it for a travel video.`;function yA({step:e,output:t=`video`}){switch(e){case`text-key`:case`audio-key`:case`image-key`:case`voice`:return(0,h.jsx)(gA,{step:e});case`article-name`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`A prompt is a reusable set of instructions. This one will write the narration for each video.`}),(0,h.jsxs)(`p`,{children:[`Give it a recognizable name, such as `,(0,h.jsx)(`strong`,{children:`Short travel narration`}),`. This is the prompt’s library name, not your video’s title.`]}),(0,h.jsx)(`p`,{children:`The next steps will add its instructions and reusable keywords.`})]});case`article-body`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`Tell the model what to write, who it is for, the length, and the style. Put anything you want to change between runs inside double braces.`}),(0,h.jsx)(hA,{text:_A}),(0,h.jsxs)(`p`,{children:[`Paste or write the instructions in `,(0,h.jsx)(`strong`,{children:`Body`}),`. `,(0,h.jsx)(`strong`,{children:`{{topic}}`}),` `,`and `,(0,h.jsx)(`strong`,{children:`{{audience}}`}),` will become fields on Play.`]})]});case`article-keywords`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`This panel detects your keywords as you type. With the example, it should list`,` `,(0,h.jsx)(`strong`,{children:`topic`}),` and `,(0,h.jsx)(`strong`,{children:`audience`}),`.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`strong`,{children:`{{topic}}`}),` is a field name, not the value. You will enter “Albania” on Play later. Repeated names use the same value; names are case-sensitive, so`,` `,(0,h.jsx)(`strong`,{children:`topic`}),` and `,(0,h.jsx)(`strong`,{children:`Topic`}),` are different.`]}),(0,h.jsxs)(`p`,{children:[`There are no automatic keywords: `,(0,h.jsx)(`strong`,{children:`{{title}}`}),` would also ask you for a value. Fix any keyword warnings in Body before saving.`]})]});case`article-save`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Press the highlighted `,(0,h.jsx)(`strong`,{children:`Save`}),` button in the editor. The prompt will appear in your Article library.`]}),(0,h.jsx)(`p`,{children:`The tour continues when the save succeeds and the editor returns to the prompt list. If a name is already taken, go Back and choose another.`})]});case`image-prompt`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Keep `,(0,h.jsx)(`strong`,{children:`Kind`}),` on `,(0,h.jsx)(`strong`,{children:`Image`}),`. Name this prompt`,` `,(0,h.jsx)(`strong`,{children:`Travel imagery`}),`, then enter this example or your own visual instructions.`]}),(0,h.jsx)(hA,{text:vA}),(0,h.jsxs)(`p`,{children:[`Using `,(0,h.jsx)(`strong`,{children:`{{topic}}`}),` in both prompts creates one shared field on Play. Image prompts describe the picture directly; they do not automatically receive your article.`]})]});case`image-save`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Press `,(0,h.jsx)(`strong`,{children:`Save`}),` to add this to your Image library. Next you will combine both prompts on Play.`]}),(0,h.jsx)(`p`,{children:`You can create more prompts later for different subjects, styles, lengths, or languages.`})]});case`play-article`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Play is where you configure one project. Leave `,(0,h.jsx)(`strong`,{children:`Article`}),` on`,` `,(0,h.jsx)(`strong`,{children:`Generate`}),`, then select the article prompt you saved.`]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`strong`,{children:`Provide`}),` is for an article you already have. For this first run, use Generate and keep the script short. Article is required; every other stage can be Off.`]}),(0,h.jsx)(`p`,{children:`Research starts Off. You can turn it on in a later run for web-grounded notes that are automatically passed to the article writer.`})]});case`play-audio`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Leave `,(0,h.jsx)(`strong`,{children:`Audio`}),` on `,(0,h.jsx)(`strong`,{children:`Generate`}),`. Pick your voice`,` `,(0,h.jsx)(`strong`,{children:`TTS`}),` provider, a `,(0,h.jsx)(`strong`,{children:`TTS model`}),`, then the saved`,` `,(0,h.jsx)(`strong`,{children:`Voice`}),`.`]}),(0,h.jsxs)(`p`,{children:[`Keep chunking on `,(0,h.jsx)(`strong`,{children:`Whole`}),` for the short example: the narration is sent as one request. Other chunking modes split longer text into pieces.`]}),(0,h.jsx)(`p`,{children:`Use Provide to upload existing narration, including any intro and outro in that file, or Off to skip narration. Video can still run silently, with each image shown for 5 seconds.`})]});case`play-images`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Leave `,(0,h.jsx)(`strong`,{children:`Images`}),` on `,(0,h.jsx)(`strong`,{children:`Generate`}),`. Choose the image`,` `,(0,h.jsx)(`strong`,{children:`Provider`}),` and `,(0,h.jsx)(`strong`,{children:`Model`}),`, select your image prompt, and set`,` `,(0,h.jsx)(`strong`,{children:`Number`}),` to 2 for a small first run.`]}),(0,h.jsx)(`p`,{children:`Number means separate images made from that same prompt. It does not make one scene per article paragraph. Add more image prompts when you want different scenes.`}),(0,h.jsx)(`p`,{children:`Use Provide for your own images or Off to skip them. Turning Images Off also turns Video Off. Thumbnail remains independent; keep it Off for this first run.`})]});case`play-video`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Choose `,(0,h.jsx)(`strong`,{children:`Generate`}),` for an MP4 slideshow. It needs generated or provided images. With Audio Off, the video is silent and each image lasts 5 seconds.`]}),(0,h.jsxs)(`p`,{children:[`Choose `,(0,h.jsx)(`strong`,{children:`Off`}),` to skip video. If Audio is active, Slopify exports one combined `,(0,h.jsx)(`strong`,{children:`WAV`}),` with the intro, body, outro and configured gaps.`]}),(0,h.jsx)(`p`,{children:`If both Audio and Video are Off, download the article and any other enabled outputs individually.`})]});case`play-subtitles`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Subtitles are optional and start `,(0,h.jsx)(`strong`,{children:`Off`}),`. Choose`,` `,(0,h.jsx)(`strong`,{children:`Subtitle files`}),` for SRT and VTT downloads, or`,` `,(0,h.jsx)(`strong`,{children:`Burn into video + files`}),` to keep captions visible in an MP4.`]}),(0,h.jsxs)(`p`,{children:[`English captions are timed locally from your narration with no paid API. First use downloads an approximately `,(0,h.jsx)(`strong`,{children:`95 MB`}),` speech model. Audio must be active; WAV exports support separate subtitle files.`]}),(0,h.jsx)(`p`,{children:`Pick a font or upload a TTF/OTF file, then adjust its size in the preview. Styling applies to burned captions. You can also add or change subtitles on a completed project later without regenerating its narration.`})]});case`play-options`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Enter a `,(0,h.jsx)(`strong`,{children:`Project title`}),`, such as “A quick trip to Albania.” Set the title in Content.`]}),(0,h.jsxs)(`p`,{children:[`Select the text `,(0,h.jsx)(`strong`,{children:`LLM`}),` and `,(0,h.jsx)(`strong`,{children:`Text model`}),`. The model list loads for your provider. Use `,(0,h.jsx)(`strong`,{children:`Refresh`}),` for updated choices or`,` `,(0,h.jsx)(`strong`,{children:`Custom ID`}),`to enter an exact model ID when supported.`]}),(0,h.jsx)(`p`,{children:`Intro and Outro are available in Outputs when Audio is Generate. The LLM controls appear only when an enabled stage needs text generation.`})]});case`play-keywords`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`The prompts you picked created these fields. For the examples, enter`,` `,(0,h.jsx)(`strong`,{children:`Albania`}),` for `,(0,h.jsx)(`strong`,{children:`topic`}),` and`,` `,(0,h.jsx)(`strong`,{children:`first-time travelers`}),` for `,(0,h.jsx)(`strong`,{children:`audience`}),`.`]}),(0,h.jsxs)(`p`,{children:[`A field under `,(0,h.jsx)(`strong`,{children:`Common`}),` feeds both the article and images. Changing it changes both prompts for this run.`]}),(0,h.jsx)(`p`,{children:`Fill every visible field. Each value must fit on one line and be no more than 200 characters. Your saved prompt keeps its braces so you can reuse it next time.`})]});case`play-start`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:`Review the enabled outputs, costs and readiness in Review. If anything is missing, use Back to fix the highlighted section.`}),(0,h.jsxs)(`p`,{children:[`When ready, press the real `,(0,h.jsx)(`strong`,{children:`Start run`}),` or `,(0,h.jsx)(`strong`,{children:`Queue N`}),` `,`button. This creates a project and sends generation requests to your chosen providers, which may charge your account.`]}),(0,h.jsx)(`p`,{children:`The tour will follow you to the project. You can also finish the tutorial without generating anything.`})]});case`project`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[`Overall progress stays above the workspace. Select a stage from `,(0,h.jsx)(`strong`,{children:`Stages`}),` `,`to see its results or live writing. Press `,(0,h.jsx)(`strong`,{children:`Pause`}),` to stop active requests safely and keep finished work.`]}),(0,h.jsxs)(`p`,{children:[`Open `,(0,h.jsx)(`strong`,{children:`Edit project`}),` to change providers, models, voice, prompts or optional steps.`,(0,h.jsx)(`strong`,{children:` Save changes`}),` keeps a new revision without starting generation. Then use `,(0,h.jsx)(`strong`,{children:`Rebuild affected outputs`}),` to review the required work and cost before starting. Finished outputs remain available in `,(0,h.jsx)(`strong`,{children:`History`}),`.`]}),(0,h.jsxs)(`p`,{children:[`Select a failed stage and open `,(0,h.jsx)(`strong`,{children:`Error details`}),` to read the provider’s message. Review `,(0,h.jsx)(`strong`,{children:`Rebuild affected outputs`}),` to retry the necessary work. Unchanged outputs are reused.`]})]});case`download`:return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`p`,{children:[t===`audio`?(0,h.jsxs)(h.Fragment,{children:[`When Audio export finishes, press `,(0,h.jsx)(`strong`,{children:`Download .wav`}),` for the combined narration.`]}):t===`article`?(0,h.jsxs)(h.Fragment,{children:[`Use `,(0,h.jsx)(`strong`,{children:`Download`}),` here to save the article. Audio and Video are Off for this project.`]}):(0,h.jsxs)(h.Fragment,{children:[`When Video finishes, press `,(0,h.jsx)(`strong`,{children:`Download .mp4`}),`.`]}),` `,`The completed project stays in `,(0,h.jsx)(`strong`,{children:`Projects`}),` so you can return to it.`]}),(0,h.jsxs)(`p`,{children:[`Select Article, Audio or Images in `,(0,h.jsx)(`strong`,{children:`Stages`}),` to download their outputs.`,` `,(0,h.jsx)(`strong`,{children:`Download all`}),` under Images gives an image ZIP, not the video.`]}),(0,h.jsxs)(`p`,{children:[`If subtitles are enabled, download the `,(0,h.jsx)(`strong`,{children:`.srt`}),` or `,(0,h.jsx)(`strong`,{children:`.vtt`}),` `,`files beside the final export. File-mode captions are also available in the video player.`]}),(0,h.jsxs)(`p`,{children:[`You have reached the end. Open `,(0,h.jsx)(`strong`,{children:`Tutorial`}),` in the navigation anytime to walk through these steps again.`]})]})}}function bA(e){return Ik(e.readiness)}function xA({session:e,progress:t,update:n}){let{api:r}=I(),i=wk(),a=Gi(),o=Ma(),s=nt(gy(r)),c=nt(vy(r)),l=nt(yy(r)),u=nt({...hy(r,e.projectId??``),enabled:e.projectId!==void 0}),[d,f]=(0,m.useState)(null),p=(0,m.useRef)(null),g=Mk[e.step],_=s.data?.seen===!0;if((0,m.useEffect)(()=>{if(_&&g&&p.current!==e.step){if(p.current=e.step,g.page===`settings`&&o.pathname!==`/settings`&&a({to:`/settings`}),g.page===`article`||g.page===`image`){let t=g.page===`article`?e.articleId:e.imageId,n=o.pathname===`/prompts/new`&&o.searchStr.includes(`kind=${g.page}`);t&&o.pathname!==`/prompts/${t}`?a({to:`/prompts/$promptId`,params:{promptId:t}}):!t&&!n&&a({to:`/prompts/new`,search:{kind:g.page}})}g.page===`play`&&o.pathname!==`/play`&&a({to:`/play`}),g.page===`project`&&e.projectId&&o.pathname!==`/projects/${e.projectId}`&&a({to:`/projects/$projectId`,params:{projectId:e.projectId}})}},[_,g,e.step,e.articleId,e.imageId,e.projectId,o.pathname,o.searchStr,a]),(0,m.useEffect)(()=>{if(!_||g?.page!==`play`||o.pathname!==`/play`)return;let e=!0;return f(null),i.navigate(Fk[g.id]).then(()=>{e&&f(g.id)}),()=>{e=!1}},[_,g,o.pathname,i.navigate]),(0,m.useEffect)(()=>{o.pathname===`/prompts`&&(g?.id===`image-prompt`&&e.imageId?n(e=>({...e,step:Mk.findIndex(e=>e.id===`play-options`)})):(g?.id===`article-save`&&e.articleId||g?.id===`image-save`&&e.imageId)&&n(e=>({...e,step:e.step+1})))},[o.pathname,g?.id,e.articleId,e.imageId,n]),!_||!g||g.page===`play`&&(d!==g.id||i.section!==Fk[g.id]))return null;let v=c.data?.providers??[],y=e=>v.some(t=>t.family===e&&bA(t)),b=(l.data?.voices??[]).some(e=>v.some(t=>t.id===e.provider&&bA(t))),x={"text-key":y(`llm`),"audio-key":y(`tts`),"image-key":y(`image`),voice:b,"article-name":t.promptIsArticle===!0&&t.promptNamed===!0,"article-body":t.promptIsArticle===!0&&t.promptBodyReady===!0&&t.promptHasKeywords===!0,"article-keywords":t.promptHasKeywords===!0,"article-save":!1,"image-prompt":t.promptIsImage===!0&&t.promptSaveReady===!0&&t.promptHasKeywords===!0,"image-save":!1,"play-article":t.playArticleReady===!0,"play-audio":t.playAudioReady===!0,"play-images":t.playImagesReady===!0,"play-video":t.playVideoReady===!0,"play-subtitles":t.playSubtitlesReady===!0,"play-options":t.playOptionsReady===!0,"play-keywords":t.playKeywordsReady===!0,"play-start":!1},S=()=>n(e=>({...e,active:!1})),C=()=>{e.step===Mk.length-1||g.id===`play-start`?S():n(e=>({...e,step:e.step+1}))},w=u.data?Rk(u.data.project.config):`video`,T=g.id===`download`&&w===`article`?`project-article`:g.id===`play-keywords`&&t.playHasKeywords===!1?`play-options`:g.target,E=g.id===`article-save`||g.id===`image-save`,D=(g.page===`article`||g.page===`image`)&&t.promptSaving===!0;return(0,h.jsxs)(pA,{stepId:g.id,target:`[data-tour="${T}"]`,title:g.title,progress:`${e.step+1} of ${Mk.length} · First project`,onClose:S,...e.step===0||g.id===`project`||D?{}:{onBack:()=>n(e=>({...e,step:e.step-1}))},onNext:C,nextDisabled:D||x[g.id]===!1,nextLabel:E?`Use Save in the editor`:g.id===`play-start`?`Use Start run / Queue N on the page`:g.id===`download`?`Finish tutorial`:`Next`,...D?{}:{onSkip:C},skipLabel:g.id===`play-start`?`Finish without generating`:E?`Skip without saving`:`Skip this step`,children:[(0,h.jsx)(yA,{step:g.id,output:w}),c.error||l.error?(0,h.jsx)(`p`,{className:`text-red`,children:c.error?.message??l.error?.message}):null]})}var SA=K({schemaVersion:hD(1),active:XE(),stepId:q([`text-key`,`audio-key`,`image-key`,`voice`,`article-name`,`article-body`,`article-keywords`,`article-save`,`image-prompt`,`image-save`,`play-options`,`play-article`,`play-keywords`,`play-audio`,`play-images`,`play-video`,`play-subtitles`,`play-start`,`project`,`download`]),articleId:W().optional(),imageId:W().optional(),projectId:W().optional()}).strict();K({baseVersion:KE().int().nonnegative(),mutationId:OE(),session:SA}).strict();var CA=K({version:KE().int().nonnegative(),session:SA,readable:XE()}).strict();async function wA(e){let t=await eo(await e.client.tutorial.$get()),n=CA.safeParse(t);return n.success?n.data:{version:0,readable:!1,session:{schemaVersion:1,active:!1,stepId:`text-key`}}}async function TA(e,t){return CA.parse(await eo(await e.client.tutorial.$put({json:t})))}async function EA(e){let t=await e.client.tutorial.$delete();if(!t.ok)throw await ro(t)}function DA(){let{api:e}=I(),[t,n]=(0,m.useState)({active:!1,step:0}),[r,i]=(0,m.useState)(null),a=(0,m.useMemo)(()=>{let t={active:!1,step:0},r=0,a=!1,o=!1,s=0,c=!0,l=!1,u=!1,d=null,f=[],p=[],m=e=>i(e instanceof Error?e.message:`Tutorial progress could not be saved.`),h=async()=>{if(!u&&a&&c){u=!0;try{for(;d||p.length>0;){if(!d){let e=p.shift();if(!e)break;let t=Mk[e.step];if(!t)throw Error(`Unknown tutorial step. Restart tutorial to recover.`);let{step:n,...i}=e;d={baseVersion:r,mutationId:crypto.randomUUID(),session:{...i,schemaVersion:1,stepId:t.id}}}r=(await TA(e,d)).version,d=null}i(null)}catch(e){m(e)}finally{u=!1}}},g=e=>{if(!a){f.push(e);return}let r=typeof e==`function`?e(t):e;r!==t&&(t=r,n(t),p.push(t),h())},_=()=>{if(!a){l=!0;return}if(!c){i(`Saved tutorial progress cannot be read. Choose Restart tutorial to recover.`);return}g({active:!0,step:0})},v=async()=>{if(o||a)return;o=!0;let u=s;try{let o=await wA(e);if(u!==s)return;if(r=o.version,c=o.readable,c||(a=!0),!c){i(`Saved tutorial progress cannot be read. Choose Restart tutorial to recover.`);return}let{schemaVersion:d,stepId:p,...m}=o.session;if(t={active:m.active,step:Pk(p)??0,...m.articleId===void 0?{}:{articleId:m.articleId},...m.imageId===void 0?{}:{imageId:m.imageId},...m.projectId===void 0?{}:{projectId:m.projectId}},t.articleId||t.imageId){let{prompts:n}=await Ao(e),{articleId:r,imageId:i,...a}=t;t={...a,...r!==void 0&&n.some(e=>e.id===r&&e.kind===`article`)?{articleId:r}:{},...i!==void 0&&n.some(e=>e.id===i&&e.kind===`image`)?{imageId:i}:{}}}if(t.projectId&&await co(e,t.projectId),u!==s)return;a=!0,n(t);for(let e of f.splice(0))g(e);l&&_(),i(null)}catch(e){u===s&&m(e)}finally{o=!1}},y=async()=>{if(!u){u=!0,s++,f.length=0,l=!1;try{await EA(e),r=0,c=!0,a=!0,d=null,p.length=0,t={active:!0,step:0},n(t),p.push(t),i(null)}catch(e){m(e)}finally{u=!1}await h()}};return{update:g,start:_,restore:v,retry:()=>{a?h():v()},restart:()=>{y()}}},[e]);return(0,m.useEffect)(()=>{a.restore()},[a]),{session:t,update:a.update,start:a.start,retry:a.retry,restart:a.restart,error:r}}var OA=(0,m.createContext)(void 0);function kA({children:e}){let{session:t,update:n,start:r,retry:i,restart:a,error:o}=DA(),[s,c]=(0,m.useState)({}),l=(0,m.useCallback)(e=>{c(t=>Object.entries(e).every(([e,n])=>t[e]===n)?t:{...t,...e})},[]),u=(0,m.useCallback)(e=>{c(t=>Object.fromEntries(Object.entries(t).filter(([t])=>!e.includes(t))))},[]),d=(0,m.useCallback)(e=>{n(t=>Nk(t,e))},[n]),f=Mk[t.step]?.id,p=t.active&&(f===`project`||f===`download`)?f:void 0,g=(0,m.useMemo)(()=>({active:t.active,projectId:t.projectId,projectStep:p,start:r,report:l,clear:u,event:d}),[t.active,t.projectId,p,r,l,u,d]);return(0,h.jsxs)(OA.Provider,{value:g,children:[e,o?(0,h.jsxs)(`div`,{role:`alert`,className:`fixed bottom-4 left-4 z-[100] rounded-panel border border-line bg-panel p-4 text-ink`,children:[(0,h.jsx)(`p`,{children:o}),(0,h.jsx)(B,{type:`button`,onClick:i,children:`Retry tutorial save`}),(0,h.jsx)(B,{type:`button`,onClick:a,children:`Restart tutorial`})]}):null,t.active?(0,h.jsx)(xA,{session:t,progress:s,update:n}):null]})}function AA(){return(0,m.useContext)(OA)}function jA(e){let t=(0,m.useContext)(OA),n=t?.report,r=t?.clear,i=(0,m.useRef)(e);i.current=e,(0,m.useEffect)(()=>{n?.(e)},[n,e]),(0,m.useEffect)(()=>()=>{r?.(Object.keys(i.current))},[r])}function MA(){let e=(0,m.useContext)(OA);return(0,m.useCallback)(t=>{e?.event(t)},[e?.event])}function NA(e){let t=(0,m.useContext)(OA);return t?.projectId===e?t.projectStep:void 0}var PA=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),FA=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),IA=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),LA=e=>{let t=IA(e);return t.charAt(0).toUpperCase()+t.slice(1)},RA={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},zA=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},BA=(0,m.createContext)({}),VA=()=>(0,m.useContext)(BA),HA=(0,m.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=VA()??{},h=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,m.createElement)(`svg`,{ref:c,...RA,width:t??l??RA.width,height:t??l??RA.height,stroke:e??f,strokeWidth:h,className:PA(`lucide`,p,i),...!a&&!zA(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,m.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),UA=(e,t)=>{let n=(0,m.forwardRef)(({className:n,...r},i)=>(0,m.createElement)(HA,{ref:i,iconNode:t,className:PA(`lucide-${FA(LA(e))}`,`lucide-${e}`,n),...r}));return n.displayName=LA(e),n},WA=UA(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v3`,key:`otl347`}],[`path`,{d:`M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338`,key:`7hb8p4`}],[`path`,{d:`M3 9h5.859`,key:`numkqi`}],[`path`,{d:`M8 2v3`,key:`1ioesn`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),GA=UA(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),KA=UA(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),qA=UA(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),JA=UA(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),YA=UA(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),XA=UA(`circle-pause`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`10`,x2:`10`,y1:`15`,y2:`9`,key:`c1nkhi`}],[`line`,{x1:`14`,x2:`14`,y1:`15`,y2:`9`,key:`h65svq`}]]),ZA=UA(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),QA=UA(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),$A=UA(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),ej=UA(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),tj=UA(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),nj=UA(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),rj=UA(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),ij=UA(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),aj=UA(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function oj(){let e=AA();return e?(0,h.jsxs)(`button`,{type:`button`,className:`flex shrink-0 items-center gap-[6px] whitespace-nowrap text-ink2 hover:text-ink`,onClick:e.start,disabled:e.active,"aria-label":`Start interactive tutorial`,title:`Start interactive tutorial`,children:[(0,h.jsx)(ZA,{className:`size-4`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`sr-only min-[1280px]:not-sr-only`,children:`Tutorial`})]}):null}function sj(){let e=AA();return!e||e.active?null:(0,h.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-4 rounded-panel border border-line bg-panel px-4 py-[14px]`,children:[(0,h.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,h.jsx)(`h2`,{className:`font-semibold`,children:`Make your first video`}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:`An interactive walkthrough of API keys, reusable prompts, keywords, and Play. Each step highlights the real controls you will use.`})]}),(0,h.jsx)(B,{variant:`accent`,onClick:e.start,children:`Start tutorial`})]})}function cj(){let[e,t]=(0,m.useState)(20);return(0,m.useEffect)(()=>{let e=0,n=()=>{let e=document.getElementById(`app-footer`)?.getBoundingClientRect();t(e!==void 0&&e.bottom>0?Math.max(20,window.innerHeight-e.top+12):20)},r=()=>{cancelAnimationFrame(e),e=requestAnimationFrame(n)},i=new ResizeObserver(r);return i.observe(document.body),window.addEventListener(`scroll`,r,!0),window.addEventListener(`resize`,r),n(),()=>{cancelAnimationFrame(e),i.disconnect(),window.removeEventListener(`scroll`,r,!0),window.removeEventListener(`resize`,r)}},[]),e}var lj=[`app-update`],uj=9e5,dj=2e3,fj=12e4;async function pj(e,t=!1,n){let r=AbortSignal.timeout(2e4);return eo(await e.fetch(`${e.origin}/api/update${t?`?refresh=1`:``}`,{signal:n===void 0?r:AbortSignal.any([n,r]),cache:`no-store`}))}async function mj(e){return eo(await e.fetch(`${e.origin}/api/update`,{method:`POST`,signal:AbortSignal.timeout(2e4)}))}function hj(e){let{api:t}=I(),n=_(),[r,i]=(0,m.useState)(null),[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(),l=(0,m.useRef)(!1),u=nt({queryKey:lj,queryFn:({signal:e})=>pj(t,!1,e),staleTime:uj,refetchOnWindowFocus:`always`,refetchInterval:e=>!a&&(r!==null||e.state.data?.status===`checking`||e.state.data?.status===`installing`||e.state.data?.status===`restarting`)?dj:uj,retry:!1}),d=it({mutationFn:()=>pj(t,!0),onMutate:()=>(o(!1),c(void 0),n.cancelQueries({queryKey:lj})),onSuccess:e=>n.setQueryData(lj,e),retry:!1}),f=it({mutationFn:()=>mj(t),onMutate:()=>(o(!1),c(void 0),n.cancelQueries({queryKey:lj})),onSuccess:e=>{i(e.currentVersion),o(!1),c(void 0),n.setQueryData(lj,e)},onError:()=>{n.invalidateQueries({queryKey:lj})},retry:!1}),p=r!==null||u.data?.status===`installing`||u.data?.status===`restarting`;(0,m.useEffect)(()=>{if(!p||a)return;let e=window.setTimeout(()=>{i(null),o(!0),c(`The update did not finish. Restart Slopify and try again.`)},fj);return()=>window.clearTimeout(e)},[p,a]),(0,m.useEffect)(()=>{if(r===null||u.data===void 0)return;let t=u.data.status===`idle`||u.data.status===`error`;u.data.currentVersion!==r&&t&&!l.current?(l.current=!0,i(null),o(!1),c(void 0),e()):t&&(i(null),o(!1),c(void 0))},[r,e,u.data]);let h=!a&&(r!==null||u.data?.status===`installing`||u.data?.status===`restarting`),g=s??f.error?.message??d.error?.message??(h?void 0:u.error?.message??u.data?.error);return{info:u.data,updating:h,checking:u.isFetching||d.isPending||u.data?.status===`checking`,installing:f.isPending,reconnecting:h&&u.isError,error:g,refresh:()=>{f.reset(),o(!1),c(void 0),d.mutate()},install:()=>{d.reset(),o(!1),c(void 0),f.mutate()}}}function gj({reload:e}){let t=hj(e),n=cj(),{info:r,updating:i,installing:a,reconnecting:o,checking:s,error:c}=t,l=i||a,u=r?.blockedReason??(r?.busy?`Pause running projects before updating.`:void 0),d=`Slopify updates: ${r?r.available?`Your version: ${r.currentVersion} · Newest: ${r.latestVersion}`:`Slopify ${r.currentVersion}`:`Slopify`}. ${o?`Reconnecting after update…`:l?`Updating…`:s?`Checking for updates…`:c??u??(r?.available?`Click to download and install the update.`:`Click to check for updates.`)}`;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":d,title:d,disabled:l||s,style:{bottom:n},onClick:()=>{r?.available&&r.canUpdate&&!u?t.install():t.refresh()},className:z(`fixed right-0 z-30 flex size-10 items-center justify-center rounded-full bg-transparent text-ink2 hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent sm:right-5`,c&&`text-amber`),children:[(0,h.jsx)(ij,{"aria-hidden":`true`,size:20,className:z((l||s)&&`animate-spin motion-reduce:animate-none`)}),r?.available&&!l?(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`absolute top-1 right-1 size-1.5 rounded-full bg-lamp-run`}):null]}),(0,h.jsx)(`span`,{className:`sr-only`,role:c?`alert`:`status`,children:d})]})}var _j=[{to:`/`,label:`Projects`,exact:!0},{to:`/play`,label:`Play`,exact:!0},{to:`/templates`,label:`Templates`,exact:!0},{to:`/schedules`,label:`Schedules`,exact:!0},{to:`/prompts`,label:`Prompts`,exact:!1},{to:`/entries`,label:`Intros & Outros`,exact:!1},{to:`/settings`,label:`Settings`,exact:!0},{to:`/usage`,label:`Usage`,exact:!0}],vj=[{href:`https://github.com/GentBajko/slopify`,label:`GitHub`,glyph:`github`,tone:``},{href:`https://www.patreon.com/cw/GentBajko`,label:`Patreon`,glyph:`patreon`,tone:`text-lamp-run`},{href:`https://buymeacoffee.com/gentbajko`,label:`Buy Me a Coffee`,glyph:`coffee`,tone:`text-lamp-run`}];function yj(){return(0,h.jsx)(Ek,{children:(0,h.jsx)(Ck,{children:(0,h.jsx)(kA,{children:(0,h.jsx)(bj,{})})})})}function bj(){let{api:e,openEvents:t}=I(),n=_(),[r,i]=(0,m.useState)(0);return(0,m.useEffect)(()=>{let r=jk(()=>{n.invalidateQueries({queryKey:V.projects})},200),a=Ny(t,Io(e,`global`),{tally:i,stagingChanged:()=>{n.invalidateQueries({queryKey:V.staging})},refetch:e=>{e===void 0?n.invalidateQueries():r.ask()}});return()=>{a(),r.stop()}},[e,t,n]),(0,h.jsxs)(`div`,{className:`flex min-h-screen flex-col`,children:[(0,h.jsxs)(`header`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] items-center gap-x-3 border-b border-line bg-panel px-4 min-[1280px]:flex min-[1280px]:h-14 min-[1280px]:gap-7 min-[1280px]:px-7`,children:[(0,h.jsxs)(sa,{to:`/`,className:`flex h-14 shrink-0 items-center gap-[10px] text-wordmark font-extrabold tracking-[-0.02em] text-ink`,children:[(0,h.jsx)(Fc,{className:`relative top-[3px] text-lamp-run`}),`Slopify`]}),(0,h.jsx)(`nav`,{"aria-label":`Main navigation`,className:`col-span-2 row-start-2 flex min-w-0 items-center gap-6 overflow-x-auto [scrollbar-width:thin] min-[1280px]:flex-1 min-[1280px]:gap-7`,children:_j.map(e=>(0,h.jsx)(sa,{to:e.to,activeOptions:{exact:e.exact},className:`shrink-0 whitespace-nowrap border-b-2 border-transparent py-3 text-ink2 hover:text-ink focus-visible:outline-offset-[-3px] min-[1280px]:py-[18px]`,activeProps:{className:`!border-lamp-run !text-ink`},children:e.label},e.to))}),(0,h.jsxs)(`div`,{className:`col-start-2 row-start-1 ml-auto flex items-center gap-1 sm:gap-4 min-[1280px]:gap-7 [&_button]:min-h-8 [&_button]:min-w-8`,children:[(0,h.jsx)(oj,{}),r===0?null:(0,h.jsxs)(sa,{to:`/`,"aria-label":`${String(r)} running`,title:`${String(r)} running`,className:`engraved flex min-h-8 items-center whitespace-nowrap text-ink3 hover:text-ink2`,children:[String(r),(0,h.jsx)(`span`,{className:`sr-only sm:not-sr-only`,children:`\xA0running`})]}),vj.map(e=>(0,h.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,title:e.label,className:`flex min-h-8 min-w-8 shrink-0 items-center justify-center gap-[6px] whitespace-nowrap text-ink2 hover:text-ink`,children:[(0,h.jsx)(Lc,{name:e.glyph,className:e.tone}),(0,h.jsx)(`span`,{className:`sr-only min-[1100px]:not-sr-only`,children:e.label})]},e.href))]})]}),(0,h.jsx)(`main`,{className:`min-w-0 flex-1 px-4 py-6 pb-20 sm:px-7`,children:(0,h.jsx)(Sa,{})}),(0,h.jsx)(`footer`,{id:`app-footer`,className:`flex items-center gap-[18px] border-t border-line px-4 py-[14px] text-label sm:px-7 text-ink3`,children:(0,h.jsx)(`span`,{children:`Free. Your keys, your machine.`})}),(0,h.jsx)(gj,{reload:()=>window.location.reload()}),(0,h.jsx)(Oy,{}),(0,h.jsx)(Ty,{}),(0,h.jsx)(ky,{reload:()=>{window.location.reload()}})]})}var xj=oO.map(e=>({value:e,label:Cj(e)})),Sj=WD.map(e=>({value:e,label:wj(e)}));function Cj(e){switch(e){case`intro`:return`Intro`;case`outro`:return`Outro`}}function wj(e){switch(e){case`text`:return`Text`;case`llm`:return`LLM`}}function Tj(e){switch(e){case`text`:return`Text is narrated as written.`;case`llm`:return`LLM is an instruction whose answer is narrated.`}}function Ej(e){switch(e){case`text`:return`No slots. This text is narrated as written.`;case`llm`:return`No slots. This instruction runs as written.`}}function Dj(e){return oO.find(t=>t===e)??`intro`}var Oj=aO.map(e=>({value:e,label:kj(e)}));function kj(e){switch(e){case`article`:return`Article`;case`image`:return`Image`;case`thumbnail`:return`Thumbnail`}}function Aj(e){return aO.find(t=>t===e)??`article`}function jj({open:e,title:t,consequence:n,verb:r,dismiss:i=`Cancel`,pending:a=!1,onConfirm:o,onCancel:s}){return(0,h.jsx)(cy,{open:e,onOpenChange:e=>{e||s()},children:(0,h.jsxs)(dy,{children:[(0,h.jsx)(fy,{children:t}),(0,h.jsx)(py,{children:n}),(0,h.jsxs)(`div`,{className:`flex justify-end gap-[10px]`,children:[(0,h.jsx)(B,{type:`button`,autoFocus:!0,onClick:s,children:i}),(0,h.jsx)(B,{type:`button`,variant:`danger`,disabled:a,onClick:o,children:r})]})]})})}function Mj({children:e,className:t,"data-tour":n}){return(0,h.jsx)(`div`,{"data-tour":n,className:z(`overflow-hidden rounded-panel border border-line bg-panel`,t),children:e})}function Nj({children:e,className:t,"data-tour":n}){return(0,h.jsx)(`div`,{"data-tour":n,className:z(`relative flex items-center gap-[14px] border-b border-line px-4 py-[14px] last:border-b-0`,t),children:e})}function Pj({current:e,total:t}){let n=t<=0?0:Math.min(1,Math.max(0,e/t));return(0,h.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`rail-meter`,className:`absolute inset-x-0 bottom-0 h-[2px] bg-lamp-run transition-[width] duration-[250ms] ease-out motion-reduce:transition-none`,style:{width:`${String(Math.round(n*100))}%`}})}function Fj({name:e,className:t}){return(0,h.jsx)(`span`,{"data-slot-chip":e,className:z(`engraved animate-tick-in rounded-control border border-line2 bg-panel2 px-[7px] py-[2px] text-ink2 motion-reduce:animate-none`,t),children:e})}var Ij=T_,Lj=E_;function Rj({className:e,sideOffset:t=4,align:n=`end`,...r}){return(0,h.jsx)(D_,{children:(0,h.jsx)(O_,{"data-slot":`dropdown-menu-content`,sideOffset:t,align:n,className:z(`z-50 min-w-[160px] overflow-hidden rounded-panel border border-line bg-panel p-1`,`shadow-[0_8px_24px_var(--color-shadow)]`,e),...r})})}function zj({className:e,...t}){return(0,h.jsx)(k_,{"data-slot":`dropdown-menu-item`,className:z(`flex cursor-default items-center rounded-control px-[10px] py-[5px] text-small text-ink`,`outline-hidden select-none focus:bg-panel2 data-highlighted:bg-panel2`,e),...t})}function Bj({className:e,...t}){return(0,h.jsx)(Xv,{"data-slot":`toggle-group`,className:z(`inline-flex w-fit items-stretch overflow-hidden rounded-control border border-line2`,e),...t})}function Vj({className:e,...t}){return(0,h.jsx)(ay,{"data-slot":`toggle-group-item`,className:z(`min-h-8 shrink-0 border-r border-line2 px-[10px] py-[5px] text-label text-ink2 last:border-r-0`,`transition-colors duration-150 ease-out motion-reduce:transition-none hover:bg-panel2 hover:text-ink`,`data-[state=on]:bg-panel2 data-[state=on]:text-ink data-[state=on]:shadow-[inset_0_-2px_0_var(--color-lamp-run)]`,`disabled:cursor-not-allowed disabled:opacity-40`,e),...t})}var Hj=`grid grid-cols-[minmax(0,1fr)_auto_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_70px_minmax(0,1fr)_auto_32px]`,Uj=`col-span-4 col-start-1 row-start-2 flex flex-wrap gap-[6px] md:col-span-1 md:col-start-3 md:row-start-1`;function Wj({category:e,onCategory:t}){let{api:n}=I(),r=_(),i=nt(xy(n)),[a,o]=(0,m.useState)(void 0),s=it({mutationFn:e=>Fo(n,e),onSettled:async()=>{o(void 0),await r.invalidateQueries({queryKey:V.entries})}}),c=i.data?.entries.filter(t=>t.category===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:`Intros & Outros`}),(0,h.jsxs)(`div`,{className:`mb-4 flex items-center gap-4`,children:[(0,h.jsx)(Bj,{type:`single`,value:e,"aria-label":`Entry category`,onValueChange:e=>{let n=xj.find(t=>t.value===e);n!==void 0&&t(n.value)},children:xj.map(e=>(0,h.jsx)(Vj,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsx)(B,{asChild:!0,children:(0,h.jsxs)(sa,{to:`/entries/new`,search:{category:e},children:[(0,h.jsx)(rj,{"aria-hidden":`true`,className:`size-[14px]`}),`New entry`]})})]}),i.error===null?null:(0,h.jsx)(Mj,{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)(Jj,{}):null:c.length===0?(0,h.jsx)(Kj,{category:e}):(0,h.jsx)(Mj,{children:c.map(e=>(0,h.jsxs)(`div`,{className:Hj,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 font-semibold`,children:e.name}),(0,h.jsx)(Gj,{mode:e.mode}),(0,h.jsx)(`span`,{className:Uj,children:e.slots.map(e=>(0,h.jsx)(Fj,{name:e},e))}),(0,h.jsx)(B,{className:`col-start-3 row-start-1 md:col-start-4`,asChild:!0,children:(0,h.jsx)(sa,{to:`/entries/$entryId`,params:{entryId:e.id},children:`Edit`})}),(0,h.jsx)(qj,{entry: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)(jj,{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 Gj({mode:e}){return(0,h.jsx)(`span`,{"data-entry-mode":e,className:`engraved col-start-2 row-start-1 justify-self-start rounded-control border border-line2 bg-panel2 px-[7px] py-[2px] font-bold text-ink`,children:wj(e)})}function Kj({category:e}){return(0,h.jsx)(Mj,{children:(0,h.jsx)(`p`,{className:`max-w-[75ch] px-4 py-7 text-ink2`,children:`No ${e}s yet. An ${e} is narrated ${e===`intro`?`before`:`after`} the body in the run's voice.`})})}function qj({entry:e,onDelete:t}){return(0,h.jsxs)(Ij,{children:[(0,h.jsx)(Lj,{asChild:!0,children:(0,h.jsx)(B,{variant:`ghost`,"aria-label":`More for ${e.name}`,className:`col-start-4 row-start-1 size-8 p-0 md:col-start-5`,children:(0,h.jsx)($A,{"aria-hidden":`true`,className:`size-4`})})}),(0,h.jsxs)(Rj,{children:[(0,h.jsx)(zj,{asChild:!0,children:(0,h.jsx)(sa,{to:`/entries/new`,search:{category:e.category,from:e.id},children:`Duplicate`})}),(0,h.jsx)(zj,{onSelect:t,children:`Delete`})]})]})}function Jj(){return(0,h.jsx)(Mj,{children:[0,1,2].map(e=>(0,h.jsxs)(`div`,{className:Hj,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 h-3 w-40 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`col-start-2 row-start-1 h-[18px] w-10 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:Uj,children:(0,h.jsx)(`span`,{className:`h-[18px] w-14 rounded-control bg-panel2`})}),(0,h.jsx)(`span`,{className:`col-start-3 row-start-1 h-7 w-12 rounded-control bg-panel2 md:col-start-4`})]},e))})}function Yj({slots:e,body:t,lint:n,lintId:r,noSlots:i=`No slots. This prompt runs as written.`}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`h2`,{className:`engraved text-ink3`,children:`Detected slots`}),e.length>0?(0,h.jsx)(`div`,{className:`flex flex-wrap gap-[6px]`,children:e.map(e=>(0,h.jsx)(Fj,{name:e,className:`px-2 py-[3px]`},e))}):t.trim()===``?(0,h.jsx)(`p`,{className:`text-small text-ink3`,children:`Slots appear here as you type {{name}}.`}):(0,h.jsx)(`p`,{className:`text-small text-ink2`,children:i}),n.length===0?null:(0,h.jsxs)(`div`,{id:r,className:`flex flex-col gap-[6px] border-t border-line pt-3`,children:[(0,h.jsx)(`span`,{className:`engraved text-red`,children:n.length===1?`1 slot error`:`${String(n.length)} slot errors`}),n.map(e=>(0,h.jsx)(`span`,{className:`text-small text-red`,children:e.message},e.message))]})]})}var Xj=2e3;function Zj(e,t){let n=(0,m.useRef)(t);(0,m.useEffect)(()=>{n.current=t}),(0,m.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>{n.current()},Xj);return()=>{clearTimeout(t)}},[e])}function Qj(){return(0,h.jsxs)(`span`,{className:`inline-flex animate-tick-in items-center gap-1 text-label text-done motion-reduce:animate-none`,children:[(0,h.jsx)(GA,{"aria-hidden":`true`,className:`size-[14px]`}),`Saved`]})}function $j({onDelete:e,blocked:t,blockedId:n,pending:r,saved:i,cancel:a,errors:o,onSave:s}){let c=t!==void 0||r||i;return(0,h.jsxs)(`div`,{className:`flex flex-wrap items-center gap-[10px] border-t border-line pt-[14px]`,children:[e===void 0?null:(0,h.jsx)(B,{className:`bg-transparent`,onClick:e,children:`Delete`}),(0,h.jsx)(`span`,{className:`flex-1`}),i?(0,h.jsx)(Qj,{}):null,t===void 0?null:(0,h.jsx)(`span`,{id:n,className:`text-small text-ink2`,children:t}),a,(0,h.jsx)(B,{variant:`primary`,"aria-disabled":c,"aria-describedby":t===void 0?void 0:n,onClick:()=>{c||s()},children:`Save`}),o.map(e=>(0,h.jsx)(`p`,{className:`basis-full text-label text-red`,children:e},e))]})}var eM=`rounded-panel border border-line bg-panel p-[18px]`;function tM(){return(0,h.jsxs)(`div`,{className:`mx-auto grid max-w-[1440px] grid-cols-[minmax(0,1fr)] gap-6 lg:grid-cols-[minmax(0,1fr)_360px]`,children:[(0,h.jsxs)(`div`,{className:`${eM} flex flex-col gap-[14px]`,children:[(0,h.jsx)(`span`,{className:`h-8 w-64 rounded-control bg-panel2`}),(0,h.jsx)(`span`,{className:`h-[520px] rounded-control bg-panel2`})]}),(0,h.jsx)(`div`,{className:`${eM} flex flex-col gap-3`,children:(0,h.jsx)(`span`,{className:`h-3 w-28 rounded-control bg-panel2`})})]})}function nM({children:e,back:t}){return(0,h.jsxs)(`div`,{className:`mx-auto max-w-[1440px]`,children:[(0,h.jsx)(Mj,{children:(0,h.jsx)(`p`,{className:`px-4 py-[14px] text-body text-red`,children:e})}),t]})}var rM=`mt-[10px] inline-block text-small text-run-text underline`;function iM({className:e,...t}){return(0,h.jsx)(j_,{"data-slot":`label`,className:z(`engraved block select-none text-ink3`,e),...t})}function aM({label:e,value:t,options:n,describedBy:r,onPick:i}){let a=(0,m.useId)();return(0,h.jsxs)(`div`,{children:[(0,h.jsx)(iM,{id:a,className:`mb-[5px]`,children:e}),(0,h.jsx)(Bj,{type:`single`,value:t,"aria-labelledby":a,"aria-describedby":r,onValueChange:e=>{let t=n.find(t=>t.value===e);t!==void 0&&i(t.value)},children:n.map(e=>(0,h.jsx)(Vj,{value:e.value,children:e.label},e.value))})]})}function oM({className:e,...t}){return(0,h.jsx)(`input`,{"data-slot":`input`,className:z(`h-8 w-full min-w-0 rounded-control border border-line2 bg-panel2 px-[10px] text-small text-ink`,`placeholder:text-ink3 aria-invalid:border-red`,e),...t})}function sM({className:e,...t}){return(0,h.jsx)(`textarea`,{"data-slot":`textarea`,className:z(`w-full min-w-0 rounded-control border border-line2 bg-panel2 px-[10px] py-2 text-small text-ink`,`placeholder:text-ink3 aria-invalid:border-red`,e),...t})}var cM=/\{\{([^{}\n]*)\}\}/g,lM=`{{`,uM=`}}`;function dM(e){let t=[],n=[],r=e.indexOf(lM);for(;r!==-1;){let i=e.indexOf(`
99
99
  `,r+2),a=i===-1?e.length:i,o=e.indexOf(uM,r+2);if(o===-1||o>a){n.push({kind:`unclosed`,at:r}),r=e.indexOf(lM,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(lM,o+2)}return{names:t,errors:n}}function fM(e,t){let n=mM(e),r=mM(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 pM(e,t){return e.replace(cM,(e,n)=>{let r=n.trim(),i=Object.hasOwn(t,r)?t[r]:void 0;return i===void 0?e:i})}function mM(e){let t=[];for(let n of e)for(let e of dM(n).names)t.includes(e)||t.push(e);return t}function hM(e){return _M(e.name,e.body)}function gM(e){return _M(e.name,e.body)}function _M(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 dM(t).errors)n.push({field:`body`,message:vM(e,t)});return n}function vM(e,t){let n=yM(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 yM(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 bM(e,t){return[...`kind`in e?hM(e):gM(e),...t]}function xM(e){return e[0]?.message}function SM(e){return e.filter(e=>e.field===`body`)}function CM(e){return e.filter(e=>e.field===`name`)}function wM(e){return dM(e).names}function TM(e){let t=[],n=0;for(let r of dM(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 EM=`px-3 py-[10px] font-sans text-body leading-[1.5] break-words [scrollbar-gutter:stable]`;function DM({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(EM,`pointer-events-none absolute inset-0 overflow-hidden whitespace-pre-wrap`,`rounded-control border border-transparent bg-panel2 text-ink`),children:[TM(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)(sM,{id:e,rows:24,value:t,spellCheck:!1,"aria-invalid":n,"aria-describedby":r,className:z(EM,`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 OM({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,k=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})}}),A=it({mutationFn:e=>Fo(i,e),onSuccess:async()=>{C(!1),await a.invalidateQueries({queryKey:xy(i).queryKey}),r(O.category)}});Zj(b,()=>{r(O.category)});let j=(e,t)=>{g(e),y(e=>e.filter(e=>e.field!==t))},ee=bM(O,v),M=xM(ee),N=wM(O.body),P=O.body.trim()===``?[]:SM(ee),F=O.name.trim()===``?[]:CM(ee);return o.error===null?T!==void 0&&w===void 0?(0,h.jsx)(tM,{}):T!==void 0&&E===void 0?(0,h.jsx)(kM,{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)(qA,{"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:`${eM} 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)(iM,{htmlFor:s,className:`mb-[5px]`,children:`Name`}),(0,h.jsx)(oM,{id:s,value:O.name,"aria-invalid":F.length>0,"aria-describedby":F.length===0?void 0:c,onChange:e=>{j({...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)(aM,{label:`Category`,value:O.category,options:xj,onPick:e=>{j({...O,category:e},`name`)}}),(0,h.jsx)(aM,{label:`Mode`,value:O.mode,options:Sj,describedBy:l,onPick:e=>{j({...O,mode:e},`mode`)}})]}),(0,h.jsx)(`p`,{id:l,className:`-mt-[6px] text-right text-small text-ink2`,children:Tj(O.mode)}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(iM,{htmlFor:u,className:`mb-[5px]`,children:`Body`}),(0,h.jsx)(DM,{id:u,value:O.body,invalid:P.length>0,describedBy:P.length===0?void 0:d,onChange:e=>{j({...O,body:e},`body`)}})]}),(0,h.jsx)($j,{onDelete:e===void 0?void 0:()=>{C(!0)},blocked:M,blockedId:f,pending:k.isPending,saved:b,cancel:(0,h.jsx)(B,{asChild:!0,children:(0,h.jsx)(sa,{to:`/entries`,search:{category:O.category},children:`Cancel`})}),errors:[k.error,A.error].flatMap(e=>e===null?[]:[e.message]),onSave:()=>{k.mutate(O)}})]}),(0,h.jsx)(`div`,{className:`${eM} flex flex-col gap-3 lg:sticky lg:top-6`,children:(0,h.jsx)(Yj,{slots:N,body:O.body,lint:P,lintId:d,noSlots:Ej(O.mode)})})]}),(0,h.jsx)(jj,{open:S,title:`Delete "${O.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:A.isPending,onConfirm:()=>{e!==void 0&&A.mutate(e)},onCancel:()=>{C(!1)}})]}):(0,h.jsx)(kM,{category:O.category,children:o.error.message})}function kM({category:e,children:t}){return(0,h.jsx)(nM,{back:(0,h.jsx)(sa,{to:`/entries`,search:{category:e},className:rM,children:`Back to Intros & Outros`}),children:t})}function AM(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 jM(e){return e.mode===`off`||e.fontId!==``&&Number.isInteger(e.fontSize)&&e.fontSize>=16&&e.fontSize<=120}({...ok.form});var MM={off:`Off`,generate:`Generate`,provide:`Provide`,from_prompt:`From prompt`,prompt_by_llm:`Prompt by LLM`};function NM(e){return ZO[e].map(e=>({value:e,label:MM[e]}))}function PM(e,t){return e.sources.article===`generate`||e.sources.thumbnail===`prompt_by_llm`||e.sources.audio===`generate`&&(FM(t,`intro`,e.intro)===`llm`||FM(t,`outro`,e.outro)===`llm`)}function FM(e,t,n){if(n!==``)return e.find(e=>e.category===t&&e.name===n)?.mode}function IM(e){return[e.audio,e.thumbnail,...e.images].flatMap(e=>e?.file===void 0?[]:[e.file])}function LM(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,imagePrompts:t.imagePrompts,thumbnailPrompt:t.thumbnailPrompt,...RM(zM(e,`intro`),e=>({intro:e})),...RM(zM(e,`outro`),e=>({outro:e})),values:BM(t.values,e.slots),provided:{research:t.provided.research,article:t.provided.article,...RM(t.provided.audio?.file,e=>({audio:e.id})),...RM(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:AM(t.subtitles,t.sources),silenceGapSeconds:e.silenceGapSeconds}}function RM(e,t){return e===void 0?{}:t(e)}function zM(e,t){if(e.form.sources.audio!==`generate`)return;let n=t===`intro`?e.form.intro:e.form.outro,r=FM(e.entries,t,n);return n===``||r===void 0?void 0:{name:n,mode:r}}function BM(e,t){let n=Object.create(null);for(let r of t)n[r]=Object.hasOwn(e,r)?e[r]??``:``;return n}function VM(e){let{form:t}=e,n=[],r=[];if(t.sources.article===`generate`&&XM(n,JM(e.prompts,`article`,t.articlePrompt)),t.sources.audio===`generate`&&(XM(n,YM(e.entries,`intro`,t.intro)),XM(n,YM(e.entries,`outro`,t.outro))),t.sources.images===`generate`)for(let n of t.imagePrompts)XM(r,JM(e.prompts,`image`,n.name));return(t.sources.thumbnail===`from_prompt`||t.sources.thumbnail===`prompt_by_llm`)&&XM(r,JM(e.prompts,`thumbnail`,t.thumbnailPrompt)),fM(n,r)}function HM(e){let t=VM(e),n={form:e.form,entries:e.entries,slots:t.map(e=>e.name),silenceGapSeconds:e.silenceGapSeconds},r=LM(n),i=QO({draft:r,staged:IM(e.form.provided),requiredSlots:n.slots}),a=jM(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:WM(e.form,a)}}var UM=[`sources`,`provided.research`,`articlePrompt`,`provided.article`,`audio`,`provided.audio`,`imagePrompts`,`images`,`provided.images`,`thumbnailPrompt`,`provided.thumbnail`,`subtitles`,`title`,`intro`,`outro`,`llm`,`values`,`silenceGapSeconds`];function WM(e,t){let n=GM(e);if(n!==void 0)return n;if(t.ok)return;let r=[...t.fields].sort((e,t)=>KM(e.field)-KM(t.field))[0];return r===void 0?void 0:{field:r.field,hint:qM(e,r)}}function GM(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 KM(e){let t=UM.length;for(let[n,r]of UM.entries())(e===r||e.startsWith(`${r}.`))&&n<t&&(t=n);return t}function qM(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 JM(e,t,n){if(n!==``)return e.find(e=>e.kind===t&&e.name===n)?.body}function YM(e,t,n){if(n!==``)return e.find(e=>e.category===t&&e.name===n)?.body}function XM(e,t){t!==void 0&&e.push(t)}function ZM(e){let t=new Map,n=(e,n)=>{if(e)for(let r of dM(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(r.sources.article===`generate`&&n(JM(i,`article`,r.articlePrompt),`Article`),r.sources.images===`generate`)for(let e of r.imagePrompts)n(JM(i,`image`,e.name),`Image: ${e.name}`);if((r.sources.thumbnail===`from_prompt`||r.sources.thumbnail===`prompt_by_llm`)&&n(JM(i,`thumbnail`,r.thumbnailPrompt),`Thumbnail`),r.sources.audio===`generate`)for(let e of[`intro`,`outro`])n(YM(a,e,r[e]),e===`intro`?`Intro`:`Outro`);return t}var QM=[{stage:`audio`,label:`Audio`},{stage:`images`,label:`Images`},{stage:`video`,label:`Video / export`}];function $M(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:QM.some(e=>e.stage===r)?`checkpoints.${r}`:`checkpoints`}}function eN({problem:e}){let t=wk(),{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.`}),QM.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 tN({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)(nN,{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 nN({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)(iM,{htmlFor:a,className:`mb-[5px]`,children:e}),(0,h.jsx)(oM,{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 rN({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)(KA,{"aria-hidden":`true`,className:`pointer-events-none absolute right-[8px] size-[14px] text-ink2`})]})}var iN=e=>[`provider-models`,e];async function aN(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 oN(e,t){return rt({queryKey:iN(t),queryFn:({signal:n})=>aN(e,t,!1,n),enabled:t!==``,staleTime:3e4,refetchInterval:3e4,retry:!1})}function sN(e){return e!==``&&e!==`fal`&&e!==`replicate`}function cN({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)(iM,{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 lN({label:e,field:t,value:n,problem:r,inline:i,placeholder:a,options:o,disabled:s=!1,onPick:c}){return(0,h.jsx)(cN,{field:t,label:e,problem:r,inline:i,children:({id:e,describedBy:l})=>(0,h.jsxs)(rN,{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 uN(e,t){return e.filter(e=>e.family===t).map(e=>{let t=dN(e);return{value:e.id,label:t===void 0?e.displayName:`${e.displayName} · ${t}`,disabled:t!==void 0}})}function dN(e){let{readiness:t}=e;return t.kind===`cli`?t.issue===void 0?Ik(t)?void 0:`CLI missing`:`CLI update required`:t.hasKey?void 0:`Key missing`}function fN({label:e,field:t,family:n,providers:r,value:i,problem:a,inline:o,onPick:s}){return(0,h.jsx)(lN,{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}]:[],...uN(r,n)],onPick:s})}function pN(e){return(0,h.jsx)(mN,{...e},e.provider)}function mN({label:e,field:t,provider:n,value:r,problem:i,inline:a,onPick:o}){let{api:s}=I(),c=_(),l=nt(oN(s,n)),[u,d]=(0,m.useState)(!1),f=(0,m.useId)(),p=(0,m.useId)(),g=it({mutationFn:()=>aN(s,n,!0),onSuccess:e=>c.setQueryData(iN(n),e)}),v=l.data?.models??[],y=l.data?.allowsCustom??sN(n),b=u&&y,x=l.isFetching||g.isPending,S=g.error?.message??l.error?.message??l.data?.warning,C=r!==``&&!v.some(e=>e.id===r);return(0,h.jsxs)(`div`,{className:`min-w-0 max-w-full`,children:[(0,h.jsx)(cN,{field:t,label:e,problem:i,inline:a,children:({id:e,describedBy:s})=>{let c=[s,S?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:b?(0,h.jsx)(oM,{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)(rN,{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`}),C?(0,h.jsxs)(`option`,{value:r,children:[r,` (saved model)`]}):null,v.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]})})}}),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:x,onClick:()=>g.mutate(),children:[(0,h.jsx)(ij,{"aria-hidden":`true`,className:z(`size-3`,x&&`animate-spin motion-reduce:animate-none`)}),`Refresh`]}),y?(0,h.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2 text-label`,"aria-label":b?`Choose ${e} from list`:`Enter ${e} ID`,onClick:()=>d(!b),children:b?`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,S?(0,h.jsx)(`p`,{id:f,className:`mt-1 max-w-[360px] text-label text-ink3`,role:`status`,children:S}):null]})}function hN({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)(iM,{id:s,className:n?`sr-only`:`shrink-0`,children:e}),(0,h.jsx)(Bj,{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)(Vj,{value:e.value,"data-play-field":e.value===r?t:void 0,disabled:e.disabled===!0,children:e.label},e.value))})]})}function gN({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)(hN,{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)(cN,{label:o?`Characters`:`Words`,problem:void 0,inline:!0,children:({id:r})=>(0,h.jsx)(oM,{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 _N=1;function vN({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)(yN,{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:_N}]: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 yN({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)(iM,{htmlFor:s,className:`sr-only`,children:`Number for ${e}`}),(0,h.jsx)(oM,{id:s,"data-play-field":`imagePrompts.${e}.number`,type:a?`text`:`number`,min:_N,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 bN=`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 xN({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)(iM,{htmlFor:o,className:`mb-[5px]`,children:e}),(0,h.jsx)(sM,{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 SN({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)(iM,{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:bN,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)(CN,{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 CN({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 wN=`col-span-3 grid min-w-0 grid-cols-1 gap-4 min-[700px]:grid-cols-2`,TN=`col-span-3 min-w-0`;function EN({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 DN({kind:e,form:t,update:n}){return(0,h.jsx)(hN,{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:NM(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 ON(e,t){return e.filter(e=>e.kind===t).map(e=>({value:e.name,label:e.name}))}function kN({form:e,providers:t,voices:n,problem:r,update:i,onPickFiles:a,onRemoveFile:o,onReattachFile:s,rawCounts:c}){let l=n.filter(t=>t.provider===e.audio.provider);return(0,h.jsxs)(EN,{kind:`audio`,name:`Audio`,dim:e.sources.audio===`off`,children:[(0,h.jsx)(DN,{kind:`audio`,form:e,update:i}),(0,h.jsx)(`div`,{className:wN,children:e.sources.audio===`generate`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fN,{field:`audio.provider`,label:`TTS`,family:`tts`,providers:t,value:e.audio.provider,problem:r(`audio`),onPick:e=>{i({audio:{provider:e,model:``,voice:``}})}}),(0,h.jsx)(pN,{field:`audio.model`,label:`TTS model`,provider:e.audio.provider,value:e.audio.model,problem:r(`audio.model`),onPick:t=>i({audio:{...e.audio,model:t}})}),(0,h.jsx)(lN,{field:`audio.voice`,label:`Voice`,value:e.audio.voice,placeholder:l.length===0?`No voices. Add one in Settings.`:`Pick a voice`,options:l.map(e=>({value:e.voiceId,label:e.name})),problem:r(`audio.voice`),onPick:t=>{i({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)(gN,{...c?{rawCounts:c}:{},value:e.chunking,onPick:e=>{i({chunking:e})}})]})]}):null}),e.sources.audio===`provide`?(0,h.jsxs)(`div`,{className:TN,children:[(0,h.jsx)(SN,{field:`provided.audio`,label:`Narration file`,accept:`audio/*`,uploads:e.provided.audio===void 0?[]:[e.provided.audio],problem:r(`provided.audio`),onPick:e=>{a(`audio`,e)},onReattach:s?(e,t)=>s(`audio`,e,t):void 0,onRemove:e=>{o(`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 AN({form:e,providers:t,prompts:n,problem:r,update:i,onPickFiles:a,onRemoveFile:o,onReattachFile:s,rawNumbers:c}){return(0,h.jsxs)(EN,{kind:`images`,name:`Images`,dim:e.sources.images===`off`,children:[(0,h.jsx)(DN,{kind:`images`,form:e,update:i}),(0,h.jsx)(`div`,{className:wN,children:e.sources.images===`generate`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(jN,{form:e,providers:t,problem:r,update:i}),(0,h.jsx)(vN,{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:TN,children:(0,h.jsx)(SN,{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 jN({form:e,providers:t,problem:n,update:r}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fN,{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)(pN,{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 MN({form:e,problem:t,update:n}){return(0,h.jsxs)(EN,{kind:`research`,name:`Research`,dim:e.sources.research===`off`,children:[(0,h.jsx)(DN,{kind:`research`,form:e,update:n}),(0,h.jsx)(`div`,{className:wN,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:TN,children:(0,h.jsx)(xN,{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 NN({form:e,prompts:t,problem:n,update:r}){return(0,h.jsxs)(EN,{kind:`article`,name:`Article`,dim:!1,children:[(0,h.jsx)(DN,{kind:`article`,form:e,update:r}),(0,h.jsx)(`div`,{className:`${TN} grid gap-4`,children:e.sources.article===`generate`?(0,h.jsx)(lN,{field:`articlePrompt`,label:`Article prompt`,value:e.articlePrompt,placeholder:`Pick a prompt`,options:ON(t,`article`),problem:n(`articlePrompt`),onPick:e=>{r({articlePrompt:e})}}):null}),e.sources.article===`provide`?(0,h.jsx)(`div`,{className:TN,children:(0,h.jsx)(xN,{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 PN({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)(EN,{kind:`thumbnail`,name:`Thumbnail`,dim:e.sources.thumbnail===`off`,children:[(0,h.jsx)(DN,{kind:`thumbnail`,form:e,update:i}),(0,h.jsxs)(`div`,{className:wN,children:[c&&e.sources.images!==`generate`?(0,h.jsx)(jN,{form:e,providers:t,problem:r,update:i}):null,c?(0,h.jsx)(lN,{field:`thumbnailPrompt`,label:`Thumbnail prompt`,value:e.thumbnailPrompt,placeholder:`Pick a prompt`,options:ON(n,`thumbnail`),problem:r(`thumbnailPrompt`),onPick:e=>{i({thumbnailPrompt:e})}}):null]}),e.sources.thumbnail===`provide`?(0,h.jsx)(`div`,{className:TN,children:(0,h.jsx)(SN,{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 FN({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)(EN,{kind:`video`,name:`Export`,dim:e.sources.video===`off`,children:[(0,h.jsx)(DN,{kind:`video`,form:e,update:n}),(0,h.jsx)(`span`,{className:wN,children:(0,h.jsx)(`span`,{className:`engraved text-ink3`,children:r})}),e.sources.images===`off`?(0,h.jsx)(`p`,{className:`${TN} text-small text-ink2`,children:`Video is Off because Images is Off. Generate or provide images to enable video.`}):null]})}function IN({choice:e,onChange:t}){let{api:n}=I(),r=nt(oN(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)(lN,{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 LN(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)(iM,{htmlFor:s,className:`mb-2`,children:`Project title`}),(0,h.jsx)(oM,{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)(NN,{...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)(tN,{fields:i,origins:ZM({form:t,prompts:e.prompts,entries:a,silenceGapSeconds:e.silenceGapSeconds}),values:t.values,problem:n,onChange:(e,n)=>r({values:{...t.values,[e]:n}})}),PM(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)(fN,{field:`llm.provider`,label:`LLM`,family:`llm`,providers:e.providers,value:t.llm.provider,problem:n(`llm`)??n(`llm.provider`),onPick:e=>r({llm:{provider:e,model:``}})}),(0,h.jsx)(pN,{field:`llm.model`,label:`Text model`,provider:t.llm.provider,value:t.llm.model,problem:n(`llm.model`),onPick:e=>r({llm:{...t.llm,model:e}})}),(0,h.jsx)(IN,{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 and generated entries 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)(MN,{...e})]})}function RN(){let{api:e}=I(),t=wk(),[n,r]=(0,m.useState)(null),[i,a]=(0,m.useState)(null),[o,s]=(0,m.useState)(!1),c=nt({queryKey:[`play-drafts`],queryFn:async()=>{let t=await NO(e);if(!t.ok)throw Error(t.message);return t.value.drafts}}),l=async()=>{if(n&&!o){s(!0),a(null);try{await t.discard({id:n.id,version:n.version}),r(null)}catch(e){a(e instanceof Error?e.message:`Couldn't discard draft`)}finally{s(!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`}),c.isPending?(0,h.jsx)(`p`,{role:`status`,children:`Loading drafts…`}):null,c.error?(0,h.jsxs)(`p`,{role:`alert`,children:[c.error.message,(0,h.jsx)(`button`,{type:`button`,onClick:()=>void c.refetch(),children:`Retry`})]}):null,c.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:c.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:()=>{r(e),a(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)(jj,{open:n!==null,title:`Discard draft`,consequence:`Discard ${n?.title||`Untitled draft`}? This cannot be undone.`,verb:`Confirm discard`,pending:o,onConfirm:()=>void l(),onCancel:()=>{o||r(null)}}),i?(0,h.jsx)(`p`,{role:`alert`,children:i}):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 zN(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 BN(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`,`provided.audio`,`intro`,`outro`,`chunking`,`images`,`imagePrompts`,`provided.images`,`thumbnailPrompt`,`provided.thumbnail`,`provided`,`sources`])?`outputs`:`review`,field:r}}function VN(e){return e===`9:16`?{width:1080,height:1920}:{width:1920,height:1080}}function HN(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 UN({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=VN(t),f=HN(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 WN(){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 GN(){let{api:e}=I(),t=wk(),{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)(UN,{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 KN(e){let t=wk(),n=t.document,{form:r,entries:i,problem:a,update:o}=e;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(kN,{...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:[[`intro`,`outro`].map(e=>(0,h.jsx)(lN,{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)(AN,{...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)(PN,{...e}),(0,h.jsx)(FN,{...e}),(0,h.jsx)(eN,{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 qN({selected:e,reviewed:t}){let n=e=>QM.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 JN({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)(oM,{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)(oM,{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 YN({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: `,XN(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`:XN(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 XN(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 ZN(e){return e===void 0?{ok:!1,text:`Provider status unavailable`}:e.readiness.kind===`cli`?Ik(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 QN(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 $N({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 eP({form:e,entries:t,providers:n,voices:r,textModels:i,audioModels:a,imageModels:o,onReveal:s}){let c=QN(e,t);if(!c.length)return(0,h.jsx)($N,{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)($N,{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=ZN(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 tP({fields:e,onReveal:t,children:n}){let{document:r,review:i}=wk(),{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(iN(a.llm.provider)),p=s.getQueryData(iN(a.audio.provider)),m=s.getQueryData(iN(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)(eP,{form:a,entries:l?.entries??[],providers:c?.providers,voices:u?.voices,textModels:f,audioModels:p,imageModels:m,onReveal:t}),(0,h.jsxs)($N,{name:`Content`,children:[(0,h.jsxs)(`dl`,{className:`text-body`,children:[x(`Project`,`title`,a.title||`Untitled run`),x(`Article`,`sources.article`,MM[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`,MM[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)($N,{name:`Outputs`,children:(0,h.jsxs)(`dl`,{className:`text-body`,children:[x(`Narration`,`sources.audio`,MM[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(`Outro`,`outro`,a.outro||`Off`)]}):null,a.sources.audio===`provide`?x(`Narration file`,`provided.audio`,a.provided.audio?.name):null,x(`Images`,`sources.images`,MM[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`,MM[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`,MM[a.sources.video])]})}),(0,h.jsxs)($N,{name:`Checkpoints`,children:[(0,h.jsx)(qN,{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)($N,{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 nP({fields:e,errors:t,onReveal:n,problem:r}){let i=wk(),{document:a,review:o}=i,s=a.form,c=(0,m.useId)(),l=_k(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)(tP,{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)(JN,{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)(oM,{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)(YN,{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 rP=[{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 iP({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:rP.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 aP({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`],[`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 oP(e){return e.upload?(0,h.jsx)(cP,{value:e.value,onPick:e.onPick,upload:e.upload}):(0,h.jsx)(sP,{...e})}function sP({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)(cP,{value:e,onPick:t,upload:{pending:o,error:a.error?.message,pick:e=>a.mutate(e,{onSuccess:({font:e})=>s.current(e.id)})}})}function cP({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)(iM,{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)(iM,{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 lP({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)(iM,{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)(oP,{...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)(iM,{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)(oM,{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":!jM(e)||S!==void 0,onChange:t=>f?f.onChange(t.target.value):a({...e,fontSize:Number(t.target.value)})})]}),!jM(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)(iM,{htmlFor:d?void 0:v,id:`${v}-label`,className:`mb-1`,children:`Subtitle position`}),d?(0,h.jsx)(Bj,{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)(Vj,{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)(UN,{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 uP({value:e,onPick:t}){let n=(0,m.useId)();return(0,h.jsxs)(`div`,{className:`w-full`,children:[(0,h.jsx)(iM,{id:n,className:`mb-2`,children:`Frame format`}),(0,h.jsx)(Bj,{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)(Vj,{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 dP({problem:e}){let t=wk(),{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)(uP,{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)(lP,{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)(iM,{htmlFor:i,className:`mb-2`,children:`Preview text`}),(0,h.jsx)(oM,{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 fP(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 pP(){let e=Gi();return(0,h.jsx)(mP,{onCreated:t=>{e({to:`/projects/$projectId`,params:{projectId:t}})}})}function mP({onCreated:e}){let{api:t}=I(),n=WN(),r=MA(),i=nt(vy(t)),a=nt(by(t)),o=nt(xy(t)),s=nt(yy(t)),c=nt(Sy(t)),[l,u]=Ok(),d=wk(),f=fP(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(zN(b.current,e.field))return}x.current?.focus()}},[d.reveal,d.section]);let T=e=>{let t=$M(e,l)??BN(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:AM(n.subtitles,n.sources)}}),d.invalidateReview(!0)},{fields:O,result:k,blocker:A}=HM({form:l,prompts:f.prompts,entries:f.entries,silenceGapSeconds:c.data?.silenceGapSeconds??3}),j=g?{field:`subtitles.fontUpload`,hint:`Wait for the subtitle font upload to finish to play`}:A;(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 ee=k.ok?_:[...k.fields,..._],M=(...e)=>!ee.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;jA({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:j===void 0&&!d.review.starting});let F=e=>{let t=($M(e,l)??BN(e,l,p)).field;return ee.find(n=>($M(n.field,l)??BN(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)(RN,{})]}),ae?(0,h.jsx)(`p`,{className:`mb-4 text-body text-red`,children:ae}):null,(0,h.jsx)(iP,{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.`:rP.find(e=>e.id===d.section)?.label}),n?null:d.section===`style`?(0,h.jsx)(`div`,{className:`mt-5`,children:(0,h.jsx)(GN,{})}):(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)(GN,{})]}),d.section===`content`?(0,h.jsx)(LN,{...oe,fields:O,entries:f.entries,onLibrary:e=>{E(e)}}):null,d.section===`outputs`?(0,h.jsx)(KN,{...oe,entries:f.entries,missingKeyword:ee.find(e=>e.field.startsWith(`values.`))?.field,onKeyword:T,onSettings:()=>{E(`/settings`)}}):null,d.section===`style`?(0,h.jsx)(dP,{problem:F}):null,d.section===`review`?(0,h.jsx)(nP,{fields:O,errors:ee,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=rP[rP.findIndex(e=>e.id===d.section)+1];e&&d.navigate(e.id)},children:[`Continue to`,` `,rP[rP.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)(GN,{}):null,(0,h.jsx)(aP,{form:l,blocker:j,onReveal:T})]})]})]})}function hP(){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 gP(e,t){return e.filter(e=>e.stageKind===t.kind)}function _P(e,t){return e.find(e=>e.role===t)}var vP={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 yP(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:vP[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 bP=(0,m.createContext)(!1);function xP({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=yP(e);return(0,m.useContext)(bP)&&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)(jj,{open:s,title:l.title,consequence:l.consequence,verb:l.verb,dismiss:l.dismiss,pending:r,onConfirm:()=>{c(!1),t()},onCancel:()=>{c(!1)}})]})}function SP(e){let{api:t}=I();return nt({...hy(t,e),enabled:!1,select:e=>e.revisionId??null}).data??null}var CP=(e,t=null)=>[`live-writing`,e,t];function wP(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 TP({projectId:e,stage:t}){let n=(nt({queryKey:CP(e,SP(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)(rN,{"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 EP(e){let t=e.role.replaceAll(`_`,`-`);return e.role===`instructions`?`${e.stageKind}-${t}`:e.role===`image`&&e.meta.index!==void 0?`${t}-${String(e.meta.index)}`:t}function DP(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var OP=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,kP=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,AP={};function jP(e,t){return((t||AP).jsx?kP:OP).test(e)}var MP=/[ \t\n\f\r]/g;function NP(e){return typeof e==`object`?e.type===`text`&&PP(e.value):PP(e)}function PP(e){return e.replace(MP,``)===``}var FP=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};FP.prototype.normal={},FP.prototype.property={},FP.prototype.space=void 0;function IP(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new FP(n,r,t)}function LP(e){return e.toLowerCase()}var RP=class{constructor(e,t){this.attribute=t,this.property=e}};RP.prototype.attribute=``,RP.prototype.booleanish=!1,RP.prototype.boolean=!1,RP.prototype.commaOrSpaceSeparated=!1,RP.prototype.commaSeparated=!1,RP.prototype.defined=!1,RP.prototype.mustUseProperty=!1,RP.prototype.number=!1,RP.prototype.overloadedBoolean=!1,RP.prototype.property=``,RP.prototype.spaceSeparated=!1,RP.prototype.space=void 0;var zP=s({boolean:()=>VP,booleanish:()=>HP,commaOrSpaceSeparated:()=>KP,commaSeparated:()=>GP,number:()=>J,overloadedBoolean:()=>UP,spaceSeparated:()=>WP}),BP=0,VP=qP(),HP=qP(),UP=qP(),J=qP(),WP=qP(),GP=qP(),KP=qP();function qP(){return 2**++BP}var JP=Object.keys(zP),YP=class extends RP{constructor(e,t,n,r){let i=-1;if(super(e,t),XP(this,`space`,r),typeof n==`number`)for(;++i<JP.length;){let e=JP[i];XP(this,JP[i],(n&zP[e])===zP[e])}}};YP.prototype.defined=!0;function XP(e,t,n){n&&(e[t]=n)}function ZP(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new YP(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[LP(r)]=r,n[LP(a.attribute)]=r}return new FP(t,n,e.space)}var QP=ZP({properties:{ariaActiveDescendant:null,ariaAtomic:HP,ariaAutoComplete:null,ariaBusy:HP,ariaChecked:HP,ariaColCount:J,ariaColIndex:J,ariaColSpan:J,ariaControls:WP,ariaCurrent:null,ariaDescribedBy:WP,ariaDetails:null,ariaDisabled:HP,ariaDropEffect:WP,ariaErrorMessage:null,ariaExpanded:HP,ariaFlowTo:WP,ariaGrabbed:HP,ariaHasPopup:null,ariaHidden:HP,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:WP,ariaLevel:J,ariaLive:null,ariaModal:HP,ariaMultiLine:HP,ariaMultiSelectable:HP,ariaOrientation:null,ariaOwns:WP,ariaPlaceholder:null,ariaPosInSet:J,ariaPressed:HP,ariaReadOnly:HP,ariaRelevant:null,ariaRequired:HP,ariaRoleDescription:WP,ariaRowCount:J,ariaRowIndex:J,ariaRowSpan:J,ariaSelected:HP,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 $P(e,t){return t in e?e[t]:t}function eF(e,t){return $P(e,t.toLowerCase())}var tF=ZP({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:GP,acceptCharset:WP,accessKey:WP,action:null,allow:null,allowFullScreen:VP,allowPaymentRequest:VP,allowUserMedia:VP,alpha:VP,alt:null,as:null,async:VP,autoCapitalize:null,autoComplete:WP,autoFocus:VP,autoPlay:VP,blocking:WP,capture:null,charSet:null,checked:VP,cite:null,className:WP,closedBy:null,colorSpace:null,cols:J,colSpan:J,command:null,commandFor:null,content:null,contentEditable:HP,controls:VP,controlsList:WP,coords:J|GP,crossOrigin:null,data:null,dateTime:null,decoding:null,default:VP,defer:VP,dir:null,dirName:null,disabled:VP,download:UP,draggable:HP,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:VP,formTarget:null,headers:WP,height:J,hidden:UP,high:J,href:null,hrefLang:null,htmlFor:WP,httpEquiv:WP,id:null,imageSizes:null,imageSrcSet:null,inert:VP,inputMode:null,integrity:null,is:null,isMap:VP,itemId:null,itemProp:WP,itemRef:WP,itemScope:VP,itemType:WP,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:VP,low:J,manifest:null,max:null,maxLength:J,media:null,method:null,min:null,minLength:J,multiple:VP,muted:VP,name:null,nonce:null,noModule:VP,noValidate:VP,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:VP,optimum:J,pattern:null,ping:WP,placeholder:null,playsInline:VP,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:VP,referrerPolicy:null,rel:WP,required:VP,reversed:VP,rows:J,rowSpan:J,sandbox:WP,scope:null,scoped:VP,seamless:VP,selected:VP,shadowRootClonable:VP,shadowRootCustomElementRegistry:VP,shadowRootDelegatesFocus:VP,shadowRootMode:null,shadowRootSerializable:VP,shape:null,size:J,sizes:null,slot:null,span:J,spellCheck:HP,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:VP,useMap:null,value:HP,width:J,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:WP,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:VP,declare:VP,event:null,face:null,frame:null,frameBorder:null,hSpace:J,leftMargin:J,link:null,longDesc:null,lowSrc:null,marginHeight:J,marginWidth:J,noResize:VP,noHref:VP,noShade:VP,noWrap:VP,object:null,profile:null,prompt:null,rev:null,rightMargin:J,rules:null,scheme:null,scrolling:HP,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:VP,disablePictureInPicture:VP,disableRemotePlayback:VP,exportParts:GP,part:WP,prefix:null,property:null,results:J,security:null,unselectable:null},space:`html`,transform:eF}),nF=ZP({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:KP,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:WP,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:VP,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:GP,g2:GP,glyphName:GP,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:KP,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:WP,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:J,pointsAtY:J,pointsAtZ:J,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:KP,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:KP,rev:KP,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:KP,requiredFeatures:KP,requiredFonts:KP,requiredFormats:KP,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:KP,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:KP,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:KP,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:$P}),rF=ZP({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()}}),iF=ZP({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:eF}),aF=ZP({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),oF={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`},sF=/[A-Z]/g,cF=/-[a-z]/g,lF=/^data[-\w.:]+$/i;function uF(e,t){let n=LP(t),r=t,i=RP;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&lF.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(cF,fF);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!cF.test(e)){let n=e.replace(sF,dF);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=YP}return new i(r,t)}function dF(e){return`-`+e.toLowerCase()}function fF(e){return e.charAt(1).toUpperCase()}var pF=IP([QP,tF,rF,iF,aF],`html`),mF=IP([QP,nF,rF,iF,aF],`svg`);function hF(e){return e.join(` `).trim()}var gF=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(`
102
+ `]}),(0,h.jsx)(sM,{id:e,rows:24,value:t,spellCheck:!1,"aria-invalid":n,"aria-describedby":r,className:z(EM,`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 OM({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,k=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})}}),A=it({mutationFn:e=>Fo(i,e),onSuccess:async()=>{C(!1),await a.invalidateQueries({queryKey:xy(i).queryKey}),r(O.category)}});Zj(b,()=>{r(O.category)});let j=(e,t)=>{g(e),y(e=>e.filter(e=>e.field!==t))},ee=bM(O,v),M=xM(ee),N=wM(O.body),P=O.body.trim()===``?[]:SM(ee),F=O.name.trim()===``?[]:CM(ee);return o.error===null?T!==void 0&&w===void 0?(0,h.jsx)(tM,{}):T!==void 0&&E===void 0?(0,h.jsx)(kM,{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)(qA,{"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:`${eM} 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)(iM,{htmlFor:s,className:`mb-[5px]`,children:`Name`}),(0,h.jsx)(oM,{id:s,value:O.name,"aria-invalid":F.length>0,"aria-describedby":F.length===0?void 0:c,onChange:e=>{j({...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)(aM,{label:`Category`,value:O.category,options:xj,onPick:e=>{j({...O,category:e},`name`)}}),(0,h.jsx)(aM,{label:`Mode`,value:O.mode,options:Sj,describedBy:l,onPick:e=>{j({...O,mode:e},`mode`)}})]}),(0,h.jsx)(`p`,{id:l,className:`-mt-[6px] text-right text-small text-ink2`,children:Tj(O.mode)}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(iM,{htmlFor:u,className:`mb-[5px]`,children:`Body`}),(0,h.jsx)(DM,{id:u,value:O.body,invalid:P.length>0,describedBy:P.length===0?void 0:d,onChange:e=>{j({...O,body:e},`body`)}})]}),(0,h.jsx)($j,{onDelete:e===void 0?void 0:()=>{C(!0)},blocked:M,blockedId:f,pending:k.isPending,saved:b,cancel:(0,h.jsx)(B,{asChild:!0,children:(0,h.jsx)(sa,{to:`/entries`,search:{category:O.category},children:`Cancel`})}),errors:[k.error,A.error].flatMap(e=>e===null?[]:[e.message]),onSave:()=>{k.mutate(O)}})]}),(0,h.jsx)(`div`,{className:`${eM} flex flex-col gap-3 lg:sticky lg:top-6`,children:(0,h.jsx)(Yj,{slots:N,body:O.body,lint:P,lintId:d,noSlots:Ej(O.mode)})})]}),(0,h.jsx)(jj,{open:S,title:`Delete "${O.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:A.isPending,onConfirm:()=>{e!==void 0&&A.mutate(e)},onCancel:()=>{C(!1)}})]}):(0,h.jsx)(kM,{category:O.category,children:o.error.message})}function kM({category:e,children:t}){return(0,h.jsx)(nM,{back:(0,h.jsx)(sa,{to:`/entries`,search:{category:e},className:rM,children:`Back to Intros & Outros`}),children:t})}function AM(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 jM(e){return e.mode===`off`||e.fontId!==``&&Number.isInteger(e.fontSize)&&e.fontSize>=16&&e.fontSize<=120}({...ok.form});var MM={off:`Off`,generate:`Generate`,provide:`Provide`,from_prompt:`From prompt`,prompt_by_llm:`Prompt by LLM`};function NM(e){return ZO[e].map(e=>({value:e,label:MM[e]}))}function PM(e,t){return e.sources.article===`generate`||e.sources.thumbnail===`prompt_by_llm`||e.sources.audio===`generate`&&(FM(t,`intro`,e.intro)===`llm`||FM(t,`outro`,e.outro)===`llm`)}function FM(e,t,n){if(n!==``)return e.find(e=>e.category===t&&e.name===n)?.mode}function IM(e){return[e.audio,e.thumbnail,...e.images].flatMap(e=>e?.file===void 0?[]:[e.file])}function LM(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,imagePrompts:t.imagePrompts,thumbnailPrompt:t.thumbnailPrompt,...RM(zM(e,`intro`),e=>({intro:e})),...RM(zM(e,`outro`),e=>({outro:e})),values:BM(t.values,e.slots),provided:{research:t.provided.research,article:t.provided.article,...RM(t.provided.audio?.file,e=>({audio:e.id})),...RM(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:AM(t.subtitles,t.sources),silenceGapSeconds:e.silenceGapSeconds}}function RM(e,t){return e===void 0?{}:t(e)}function zM(e,t){if(e.form.sources.audio!==`generate`)return;let n=t===`intro`?e.form.intro:e.form.outro,r=FM(e.entries,t,n);return n===``||r===void 0?void 0:{name:n,mode:r}}function BM(e,t){let n=Object.create(null);for(let r of t)n[r]=Object.hasOwn(e,r)?e[r]??``:``;return n}function VM(e){let{form:t}=e,n=[],r=[];if(t.sources.article===`generate`&&XM(n,JM(e.prompts,`article`,t.articlePrompt)),t.sources.audio===`generate`&&(XM(n,YM(e.entries,`intro`,t.intro)),XM(n,YM(e.entries,`outro`,t.outro))),t.sources.images===`generate`)for(let n of t.imagePrompts)XM(r,JM(e.prompts,`image`,n.name));return(t.sources.thumbnail===`from_prompt`||t.sources.thumbnail===`prompt_by_llm`)&&XM(r,JM(e.prompts,`thumbnail`,t.thumbnailPrompt)),fM(n,r)}function HM(e){let t=VM(e),n={form:e.form,entries:e.entries,slots:t.map(e=>e.name),silenceGapSeconds:e.silenceGapSeconds},r=LM(n),i=QO({draft:r,staged:IM(e.form.provided),requiredSlots:n.slots}),a=jM(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:WM(e.form,a)}}var UM=[`sources`,`provided.research`,`articlePrompt`,`provided.article`,`audio`,`provided.audio`,`imagePrompts`,`images`,`provided.images`,`thumbnailPrompt`,`provided.thumbnail`,`subtitles`,`title`,`intro`,`outro`,`llm`,`values`,`silenceGapSeconds`];function WM(e,t){let n=GM(e);if(n!==void 0)return n;if(t.ok)return;let r=[...t.fields].sort((e,t)=>KM(e.field)-KM(t.field))[0];return r===void 0?void 0:{field:r.field,hint:qM(e,r)}}function GM(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 KM(e){let t=UM.length;for(let[n,r]of UM.entries())(e===r||e.startsWith(`${r}.`))&&n<t&&(t=n);return t}function qM(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 JM(e,t,n){if(n!==``)return e.find(e=>e.kind===t&&e.name===n)?.body}function YM(e,t,n){if(n!==``)return e.find(e=>e.category===t&&e.name===n)?.body}function XM(e,t){t!==void 0&&e.push(t)}function ZM(e){let t=new Map,n=(e,n)=>{if(e)for(let r of dM(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(r.sources.article===`generate`&&n(JM(i,`article`,r.articlePrompt),`Article`),r.sources.images===`generate`)for(let e of r.imagePrompts)n(JM(i,`image`,e.name),`Image: ${e.name}`);if((r.sources.thumbnail===`from_prompt`||r.sources.thumbnail===`prompt_by_llm`)&&n(JM(i,`thumbnail`,r.thumbnailPrompt),`Thumbnail`),r.sources.audio===`generate`)for(let e of[`intro`,`outro`])n(YM(a,e,r[e]),e===`intro`?`Intro`:`Outro`);return t}var QM=[{stage:`audio`,label:`Audio`},{stage:`images`,label:`Images`},{stage:`video`,label:`Video / export`}];function $M(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:QM.some(e=>e.stage===r)?`checkpoints.${r}`:`checkpoints`}}function eN({problem:e}){let t=wk(),{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.`}),QM.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 tN({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)(nN,{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 nN({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)(iM,{htmlFor:a,className:`mb-[5px]`,children:e}),(0,h.jsx)(oM,{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 rN({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)(KA,{"aria-hidden":`true`,className:`pointer-events-none absolute right-[8px] size-[14px] text-ink2`})]})}var iN=e=>[`provider-models`,e];async function aN(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 oN(e,t){return rt({queryKey:iN(t),queryFn:({signal:n})=>aN(e,t,!1,n),enabled:t!==``,staleTime:3e4,refetchInterval:3e4,retry:!1})}function sN(e){return e!==``&&e!==`fal`&&e!==`replicate`}function cN({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)(iM,{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 lN({label:e,field:t,value:n,problem:r,inline:i,placeholder:a,options:o,disabled:s=!1,onPick:c}){return(0,h.jsx)(cN,{field:t,label:e,problem:r,inline:i,children:({id:e,describedBy:l})=>(0,h.jsxs)(rN,{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 uN(e,t){return e.filter(e=>e.family===t).map(e=>{let t=dN(e);return{value:e.id,label:t===void 0?e.displayName:`${e.displayName} · ${t}`,disabled:t!==void 0}})}function dN(e){let{readiness:t}=e;return t.kind===`cli`?t.issue===void 0?Ik(t)?void 0:`CLI missing`:`CLI update required`:t.hasKey?void 0:`Key missing`}function fN({label:e,field:t,family:n,providers:r,value:i,problem:a,inline:o,onPick:s}){return(0,h.jsx)(lN,{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}]:[],...uN(r,n)],onPick:s})}function pN(e){return(0,h.jsx)(mN,{...e},e.provider)}function mN({label:e,field:t,provider:n,value:r,problem:i,inline:a,onPick:o}){let{api:s}=I(),c=_(),l=nt(oN(s,n)),[u,d]=(0,m.useState)(!1),f=(0,m.useId)(),p=(0,m.useId)(),g=it({mutationFn:()=>aN(s,n,!0),onSuccess:e=>c.setQueryData(iN(n),e)}),v=l.data?.models??[],y=l.data?.allowsCustom??sN(n),b=u&&y,x=l.isFetching||g.isPending,S=g.error?.message??l.error?.message??l.data?.warning,C=r!==``&&!v.some(e=>e.id===r);return(0,h.jsxs)(`div`,{className:`min-w-0 max-w-full`,children:[(0,h.jsx)(cN,{field:t,label:e,problem:i,inline:a,children:({id:e,describedBy:s})=>{let c=[s,S?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:b?(0,h.jsx)(oM,{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)(rN,{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`}),C?(0,h.jsxs)(`option`,{value:r,children:[r,` (saved model)`]}):null,v.map(e=>(0,h.jsx)(`option`,{value:e.id,children:e.name},e.id))]})})}}),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:x,onClick:()=>g.mutate(),children:[(0,h.jsx)(ij,{"aria-hidden":`true`,className:z(`size-3`,x&&`animate-spin motion-reduce:animate-none`)}),`Refresh`]}),y?(0,h.jsx)(B,{type:`button`,variant:`ghost`,className:`px-2 text-label`,"aria-label":b?`Choose ${e} from list`:`Enter ${e} ID`,onClick:()=>d(!b),children:b?`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,S?(0,h.jsx)(`p`,{id:f,className:`mt-1 max-w-[360px] text-label text-ink3`,role:`status`,children:S}):null]})}function hN({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)(iM,{id:s,className:n?`sr-only`:`shrink-0`,children:e}),(0,h.jsx)(Bj,{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)(Vj,{value:e.value,"data-play-field":e.value===r?t:void 0,disabled:e.disabled===!0,children:e.label},e.value))})]})}function gN({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)(hN,{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)(cN,{label:o?`Characters`:`Words`,problem:void 0,inline:!0,children:({id:r})=>(0,h.jsx)(oM,{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 _N=1;function vN({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)(yN,{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:_N}]: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 yN({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)(iM,{htmlFor:s,className:`sr-only`,children:`Number for ${e}`}),(0,h.jsx)(oM,{id:s,"data-play-field":`imagePrompts.${e}.number`,type:a?`text`:`number`,min:_N,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 bN=`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 xN({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)(iM,{htmlFor:o,className:`mb-[5px]`,children:e}),(0,h.jsx)(sM,{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 SN({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)(iM,{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:bN,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)(CN,{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 CN({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 wN=`col-span-3 grid min-w-0 grid-cols-1 gap-4 min-[700px]:grid-cols-2`,TN=`col-span-3 min-w-0`;function EN({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 DN({kind:e,form:t,update:n}){return(0,h.jsx)(hN,{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:NM(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 ON(e,t){return e.filter(e=>e.kind===t).map(e=>({value:e.name,label:e.name}))}function kN({form:e,providers:t,voices:n,problem:r,update:i,onPickFiles:a,onRemoveFile:o,onReattachFile:s,rawCounts:c}){let l=n.filter(t=>t.provider===e.audio.provider);return(0,h.jsxs)(EN,{kind:`audio`,name:`Audio`,dim:e.sources.audio===`off`,children:[(0,h.jsx)(DN,{kind:`audio`,form:e,update:i}),(0,h.jsx)(`div`,{className:wN,children:e.sources.audio===`generate`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fN,{field:`audio.provider`,label:`TTS`,family:`tts`,providers:t,value:e.audio.provider,problem:r(`audio`),onPick:e=>{i({audio:{provider:e,model:``,voice:``}})}}),(0,h.jsx)(pN,{field:`audio.model`,label:`TTS model`,provider:e.audio.provider,value:e.audio.model,problem:r(`audio.model`),onPick:t=>i({audio:{...e.audio,model:t}})}),(0,h.jsx)(lN,{field:`audio.voice`,label:`Voice`,value:e.audio.voice,placeholder:l.length===0?`No voices. Add one in Settings.`:`Pick a voice`,options:l.map(e=>({value:e.voiceId,label:e.name})),problem:r(`audio.voice`),onPick:t=>{i({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)(gN,{...c?{rawCounts:c}:{},value:e.chunking,onPick:e=>{i({chunking:e})}})]})]}):null}),e.sources.audio===`provide`?(0,h.jsxs)(`div`,{className:TN,children:[(0,h.jsx)(SN,{field:`provided.audio`,label:`Narration file`,accept:`audio/*`,uploads:e.provided.audio===void 0?[]:[e.provided.audio],problem:r(`provided.audio`),onPick:e=>{a(`audio`,e)},onReattach:s?(e,t)=>s(`audio`,e,t):void 0,onRemove:e=>{o(`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 AN({form:e,providers:t,prompts:n,problem:r,update:i,onPickFiles:a,onRemoveFile:o,onReattachFile:s,rawNumbers:c}){return(0,h.jsxs)(EN,{kind:`images`,name:`Images`,dim:e.sources.images===`off`,children:[(0,h.jsx)(DN,{kind:`images`,form:e,update:i}),(0,h.jsx)(`div`,{className:wN,children:e.sources.images===`generate`?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(jN,{form:e,providers:t,problem:r,update:i}),(0,h.jsx)(vN,{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:TN,children:(0,h.jsx)(SN,{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 jN({form:e,providers:t,problem:n,update:r}){return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fN,{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)(pN,{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 MN({form:e,problem:t,update:n}){return(0,h.jsxs)(EN,{kind:`research`,name:`Research`,dim:e.sources.research===`off`,children:[(0,h.jsx)(DN,{kind:`research`,form:e,update:n}),(0,h.jsx)(`div`,{className:wN,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:TN,children:(0,h.jsx)(xN,{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 NN({form:e,prompts:t,problem:n,update:r}){return(0,h.jsxs)(EN,{kind:`article`,name:`Article`,dim:!1,children:[(0,h.jsx)(DN,{kind:`article`,form:e,update:r}),(0,h.jsx)(`div`,{className:`${TN} grid gap-4`,children:e.sources.article===`generate`?(0,h.jsx)(lN,{field:`articlePrompt`,label:`Article prompt`,value:e.articlePrompt,placeholder:`Pick a prompt`,options:ON(t,`article`),problem:n(`articlePrompt`),onPick:e=>{r({articlePrompt:e})}}):null}),e.sources.article===`provide`?(0,h.jsx)(`div`,{className:TN,children:(0,h.jsx)(xN,{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 PN({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)(EN,{kind:`thumbnail`,name:`Thumbnail`,dim:e.sources.thumbnail===`off`,children:[(0,h.jsx)(DN,{kind:`thumbnail`,form:e,update:i}),(0,h.jsxs)(`div`,{className:wN,children:[c&&e.sources.images!==`generate`?(0,h.jsx)(jN,{form:e,providers:t,problem:r,update:i}):null,c?(0,h.jsx)(lN,{field:`thumbnailPrompt`,label:`Thumbnail prompt`,value:e.thumbnailPrompt,placeholder:`Pick a prompt`,options:ON(n,`thumbnail`),problem:r(`thumbnailPrompt`),onPick:e=>{i({thumbnailPrompt:e})}}):null]}),e.sources.thumbnail===`provide`?(0,h.jsx)(`div`,{className:TN,children:(0,h.jsx)(SN,{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 FN({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)(EN,{kind:`video`,name:`Export`,dim:e.sources.video===`off`,children:[(0,h.jsx)(DN,{kind:`video`,form:e,update:n}),(0,h.jsx)(`span`,{className:wN,children:(0,h.jsx)(`span`,{className:`engraved text-ink3`,children:r})}),e.sources.images===`off`?(0,h.jsx)(`p`,{className:`${TN} text-small text-ink2`,children:`Video is Off because Images is Off. Generate or provide images to enable video.`}):null]})}function IN({choice:e,onChange:t}){let{api:n}=I(),r=nt(oN(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)(lN,{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 LN(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)(iM,{htmlFor:s,className:`mb-2`,children:`Project title`}),(0,h.jsx)(oM,{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)(NN,{...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)(tN,{fields:i,origins:ZM({form:t,prompts:e.prompts,entries:a,silenceGapSeconds:e.silenceGapSeconds}),values:t.values,problem:n,onChange:(e,n)=>r({values:{...t.values,[e]:n}})}),PM(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)(fN,{field:`llm.provider`,label:`LLM`,family:`llm`,providers:e.providers,value:t.llm.provider,problem:n(`llm`)??n(`llm.provider`),onPick:e=>r({llm:{provider:e,model:``}})}),(0,h.jsx)(pN,{field:`llm.model`,label:`Text model`,provider:t.llm.provider,value:t.llm.model,problem:n(`llm.model`),onPick:e=>r({llm:{...t.llm,model:e}})}),(0,h.jsx)(IN,{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 and generated entries 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)(MN,{...e})]})}function RN(){let{api:e}=I(),t=wk(),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)(jj,{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 zN(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 BN(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`,`provided.audio`,`intro`,`outro`,`chunking`,`images`,`imagePrompts`,`provided.images`,`thumbnailPrompt`,`provided.thumbnail`,`provided`,`sources`])?`outputs`:`review`,field:r}}function VN(e){return e===`9:16`?{width:1080,height:1920}:{width:1920,height:1080}}function HN(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 UN({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=VN(t),f=HN(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 WN(){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 GN(){let{api:e}=I(),t=wk(),{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)(UN,{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 KN(e){let t=wk(),n=t.document,{form:r,entries:i,problem:a,update:o}=e;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(kN,{...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:[[`intro`,`outro`].map(e=>(0,h.jsx)(lN,{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)(AN,{...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)(PN,{...e}),(0,h.jsx)(FN,{...e}),(0,h.jsx)(eN,{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 qN({selected:e,reviewed:t}){let n=e=>QM.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 JN({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)(oM,{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)(oM,{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 YN({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: `,XN(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`:XN(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 XN(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 ZN(e){return e===void 0?{ok:!1,text:`Provider status unavailable`}:e.readiness.kind===`cli`?Ik(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 QN(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 $N({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 eP({form:e,entries:t,providers:n,voices:r,textModels:i,audioModels:a,imageModels:o,onReveal:s}){let c=QN(e,t);if(!c.length)return(0,h.jsx)($N,{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)($N,{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=ZN(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 tP({fields:e,onReveal:t,children:n}){let{document:r,review:i}=wk(),{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(iN(a.llm.provider)),p=s.getQueryData(iN(a.audio.provider)),m=s.getQueryData(iN(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)(eP,{form:a,entries:l?.entries??[],providers:c?.providers,voices:u?.voices,textModels:f,audioModels:p,imageModels:m,onReveal:t}),(0,h.jsxs)($N,{name:`Content`,children:[(0,h.jsxs)(`dl`,{className:`text-body`,children:[x(`Project`,`title`,a.title||`Untitled run`),x(`Article`,`sources.article`,MM[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`,MM[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)($N,{name:`Outputs`,children:(0,h.jsxs)(`dl`,{className:`text-body`,children:[x(`Narration`,`sources.audio`,MM[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(`Outro`,`outro`,a.outro||`Off`)]}):null,a.sources.audio===`provide`?x(`Narration file`,`provided.audio`,a.provided.audio?.name):null,x(`Images`,`sources.images`,MM[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`,MM[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`,MM[a.sources.video])]})}),(0,h.jsxs)($N,{name:`Checkpoints`,children:[(0,h.jsx)(qN,{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)($N,{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 nP({fields:e,errors:t,onReveal:n,problem:r}){let i=wk(),{document:a,review:o}=i,s=a.form,c=(0,m.useId)(),l=_k(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)(tP,{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)(JN,{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)(oM,{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)(YN,{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 rP=[{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 iP({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:rP.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 aP({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`],[`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 oP(e){return e.upload?(0,h.jsx)(cP,{value:e.value,onPick:e.onPick,upload:e.upload}):(0,h.jsx)(sP,{...e})}function sP({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)(cP,{value:e,onPick:t,upload:{pending:o,error:a.error?.message,pick:e=>a.mutate(e,{onSuccess:({font:e})=>s.current(e.id)})}})}function cP({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)(iM,{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)(iM,{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 lP({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)(iM,{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)(oP,{...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)(iM,{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)(oM,{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":!jM(e)||S!==void 0,onChange:t=>f?f.onChange(t.target.value):a({...e,fontSize:Number(t.target.value)})})]}),!jM(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)(iM,{htmlFor:d?void 0:v,id:`${v}-label`,className:`mb-1`,children:`Subtitle position`}),d?(0,h.jsx)(Bj,{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)(Vj,{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)(UN,{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 uP({value:e,onPick:t}){let n=(0,m.useId)();return(0,h.jsxs)(`div`,{className:`w-full`,children:[(0,h.jsx)(iM,{id:n,className:`mb-2`,children:`Frame format`}),(0,h.jsx)(Bj,{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)(Vj,{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 dP({problem:e}){let t=wk(),{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)(uP,{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)(lP,{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)(iM,{htmlFor:i,className:`mb-2`,children:`Preview text`}),(0,h.jsx)(oM,{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 fP(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 pP(){let e=Gi();return(0,h.jsx)(mP,{onCreated:t=>{e({to:`/projects/$projectId`,params:{projectId:t}})}})}function mP({onCreated:e}){let{api:t}=I(),n=WN(),r=MA(),i=nt(vy(t)),a=nt(by(t)),o=nt(xy(t)),s=nt(yy(t)),c=nt(Sy(t)),[l,u]=Ok(),d=wk(),f=fP(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(zN(b.current,e.field))return}x.current?.focus()}},[d.reveal,d.section]);let T=e=>{let t=$M(e,l)??BN(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:AM(n.subtitles,n.sources)}}),d.invalidateReview(!0)},{fields:O,result:k,blocker:A}=HM({form:l,prompts:f.prompts,entries:f.entries,silenceGapSeconds:c.data?.silenceGapSeconds??3}),j=g?{field:`subtitles.fontUpload`,hint:`Wait for the subtitle font upload to finish to play`}:A;(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 ee=k.ok?_:[...k.fields,..._],M=(...e)=>!ee.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;jA({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:j===void 0&&!d.review.starting});let F=e=>{let t=($M(e,l)??BN(e,l,p)).field;return ee.find(n=>($M(n.field,l)??BN(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)(RN,{})]}),ae?(0,h.jsx)(`p`,{className:`mb-4 text-body text-red`,children:ae}):null,(0,h.jsx)(iP,{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.`:rP.find(e=>e.id===d.section)?.label}),n?null:d.section===`style`?(0,h.jsx)(`div`,{className:`mt-5`,children:(0,h.jsx)(GN,{})}):(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)(GN,{})]}),d.section===`content`?(0,h.jsx)(LN,{...oe,fields:O,entries:f.entries,onLibrary:e=>{E(e)}}):null,d.section===`outputs`?(0,h.jsx)(KN,{...oe,entries:f.entries,missingKeyword:ee.find(e=>e.field.startsWith(`values.`))?.field,onKeyword:T,onSettings:()=>{E(`/settings`)}}):null,d.section===`style`?(0,h.jsx)(dP,{problem:F}):null,d.section===`review`?(0,h.jsx)(nP,{fields:O,errors:ee,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=rP[rP.findIndex(e=>e.id===d.section)+1];e&&d.navigate(e.id)},children:[`Continue to`,` `,rP[rP.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)(GN,{}):null,(0,h.jsx)(aP,{form:l,blocker:j,onReveal:T})]})]})]})}function hP(){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 gP(e,t){return e.filter(e=>e.stageKind===t.kind)}function _P(e,t){return e.find(e=>e.role===t)}var vP={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 yP(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:vP[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 bP=(0,m.createContext)(!1);function xP({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=yP(e);return(0,m.useContext)(bP)&&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)(jj,{open:s,title:l.title,consequence:l.consequence,verb:l.verb,dismiss:l.dismiss,pending:r,onConfirm:()=>{c(!1),t()},onCancel:()=>{c(!1)}})]})}function SP(e){let{api:t}=I();return nt({...hy(t,e),enabled:!1,select:e=>e.revisionId??null}).data??null}var CP=(e,t=null)=>[`live-writing`,e,t];function wP(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 TP({projectId:e,stage:t}){let n=(nt({queryKey:CP(e,SP(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)(rN,{"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 EP(e){let t=e.role.replaceAll(`_`,`-`);return e.role===`instructions`?`${e.stageKind}-${t}`:e.role===`image`&&e.meta.index!==void 0?`${t}-${String(e.meta.index)}`:t}function DP(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var OP=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,kP=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,AP={};function jP(e,t){return((t||AP).jsx?kP:OP).test(e)}var MP=/[ \t\n\f\r]/g;function NP(e){return typeof e==`object`?e.type===`text`&&PP(e.value):PP(e)}function PP(e){return e.replace(MP,``)===``}var FP=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};FP.prototype.normal={},FP.prototype.property={},FP.prototype.space=void 0;function IP(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new FP(n,r,t)}function LP(e){return e.toLowerCase()}var RP=class{constructor(e,t){this.attribute=t,this.property=e}};RP.prototype.attribute=``,RP.prototype.booleanish=!1,RP.prototype.boolean=!1,RP.prototype.commaOrSpaceSeparated=!1,RP.prototype.commaSeparated=!1,RP.prototype.defined=!1,RP.prototype.mustUseProperty=!1,RP.prototype.number=!1,RP.prototype.overloadedBoolean=!1,RP.prototype.property=``,RP.prototype.spaceSeparated=!1,RP.prototype.space=void 0;var zP=s({boolean:()=>VP,booleanish:()=>HP,commaOrSpaceSeparated:()=>KP,commaSeparated:()=>GP,number:()=>J,overloadedBoolean:()=>UP,spaceSeparated:()=>WP}),BP=0,VP=qP(),HP=qP(),UP=qP(),J=qP(),WP=qP(),GP=qP(),KP=qP();function qP(){return 2**++BP}var JP=Object.keys(zP),YP=class extends RP{constructor(e,t,n,r){let i=-1;if(super(e,t),XP(this,`space`,r),typeof n==`number`)for(;++i<JP.length;){let e=JP[i];XP(this,JP[i],(n&zP[e])===zP[e])}}};YP.prototype.defined=!0;function XP(e,t,n){n&&(e[t]=n)}function ZP(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new YP(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[LP(r)]=r,n[LP(a.attribute)]=r}return new FP(t,n,e.space)}var QP=ZP({properties:{ariaActiveDescendant:null,ariaAtomic:HP,ariaAutoComplete:null,ariaBusy:HP,ariaChecked:HP,ariaColCount:J,ariaColIndex:J,ariaColSpan:J,ariaControls:WP,ariaCurrent:null,ariaDescribedBy:WP,ariaDetails:null,ariaDisabled:HP,ariaDropEffect:WP,ariaErrorMessage:null,ariaExpanded:HP,ariaFlowTo:WP,ariaGrabbed:HP,ariaHasPopup:null,ariaHidden:HP,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:WP,ariaLevel:J,ariaLive:null,ariaModal:HP,ariaMultiLine:HP,ariaMultiSelectable:HP,ariaOrientation:null,ariaOwns:WP,ariaPlaceholder:null,ariaPosInSet:J,ariaPressed:HP,ariaReadOnly:HP,ariaRelevant:null,ariaRequired:HP,ariaRoleDescription:WP,ariaRowCount:J,ariaRowIndex:J,ariaRowSpan:J,ariaSelected:HP,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 $P(e,t){return t in e?e[t]:t}function eF(e,t){return $P(e,t.toLowerCase())}var tF=ZP({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:GP,acceptCharset:WP,accessKey:WP,action:null,allow:null,allowFullScreen:VP,allowPaymentRequest:VP,allowUserMedia:VP,alpha:VP,alt:null,as:null,async:VP,autoCapitalize:null,autoComplete:WP,autoFocus:VP,autoPlay:VP,blocking:WP,capture:null,charSet:null,checked:VP,cite:null,className:WP,closedBy:null,colorSpace:null,cols:J,colSpan:J,command:null,commandFor:null,content:null,contentEditable:HP,controls:VP,controlsList:WP,coords:J|GP,crossOrigin:null,data:null,dateTime:null,decoding:null,default:VP,defer:VP,dir:null,dirName:null,disabled:VP,download:UP,draggable:HP,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:VP,formTarget:null,headers:WP,height:J,hidden:UP,high:J,href:null,hrefLang:null,htmlFor:WP,httpEquiv:WP,id:null,imageSizes:null,imageSrcSet:null,inert:VP,inputMode:null,integrity:null,is:null,isMap:VP,itemId:null,itemProp:WP,itemRef:WP,itemScope:VP,itemType:WP,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:VP,low:J,manifest:null,max:null,maxLength:J,media:null,method:null,min:null,minLength:J,multiple:VP,muted:VP,name:null,nonce:null,noModule:VP,noValidate:VP,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:VP,optimum:J,pattern:null,ping:WP,placeholder:null,playsInline:VP,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:VP,referrerPolicy:null,rel:WP,required:VP,reversed:VP,rows:J,rowSpan:J,sandbox:WP,scope:null,scoped:VP,seamless:VP,selected:VP,shadowRootClonable:VP,shadowRootCustomElementRegistry:VP,shadowRootDelegatesFocus:VP,shadowRootMode:null,shadowRootSerializable:VP,shape:null,size:J,sizes:null,slot:null,span:J,spellCheck:HP,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:VP,useMap:null,value:HP,width:J,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:WP,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:VP,declare:VP,event:null,face:null,frame:null,frameBorder:null,hSpace:J,leftMargin:J,link:null,longDesc:null,lowSrc:null,marginHeight:J,marginWidth:J,noResize:VP,noHref:VP,noShade:VP,noWrap:VP,object:null,profile:null,prompt:null,rev:null,rightMargin:J,rules:null,scheme:null,scrolling:HP,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:VP,disablePictureInPicture:VP,disableRemotePlayback:VP,exportParts:GP,part:WP,prefix:null,property:null,results:J,security:null,unselectable:null},space:`html`,transform:eF}),nF=ZP({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:KP,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:WP,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:VP,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:GP,g2:GP,glyphName:GP,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:KP,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:WP,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:J,pointsAtY:J,pointsAtZ:J,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:KP,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:KP,rev:KP,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:KP,requiredFeatures:KP,requiredFonts:KP,requiredFormats:KP,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:KP,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:KP,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:KP,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:$P}),rF=ZP({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()}}),iF=ZP({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:eF}),aF=ZP({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),oF={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`},sF=/[A-Z]/g,cF=/-[a-z]/g,lF=/^data[-\w.:]+$/i;function uF(e,t){let n=LP(t),r=t,i=RP;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&lF.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(cF,fF);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!cF.test(e)){let n=e.replace(sF,dF);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=YP}return new i(r,t)}function dF(e){return`-`+e.toLowerCase()}function fF(e){return e.charAt(1).toUpperCase()}var pF=IP([QP,tF,rF,iF,aF],`html`),mF=IP([QP,nF,rF,iF,aF],`svg`);function hF(e){return e.join(` `).trim()}var gF=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
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})),_F=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(gF());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}})),vF=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))}})),yF=o(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(_F()),r=vF();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})),bF=SF(`end`),xF=SF(`start`);function SF(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 CF(e){let t=xF(e),n=bF(e);if(t&&n)return{start:t,end:n}}function wF(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?EF(e.position):`start`in e||`end`in e?EF(e):`line`in e||`column`in e?TF(e):``}function TF(e){return DF(e&&e.line)+`:`+DF(e&&e.column)}function EF(e){return TF(e&&e.start)+`-`+TF(e&&e.end)}function DF(e){return e&&typeof e==`number`?e:1}var OF=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=wF(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}};OF.prototype.file=``,OF.prototype.name=``,OF.prototype.reason=``,OF.prototype.message=``,OF.prototype.stack=``,OF.prototype.column=void 0,OF.prototype.line=void 0,OF.prototype.ancestors=void 0,OF.prototype.cause=void 0,OF.prototype.fatal=void 0,OF.prototype.place=void 0,OF.prototype.ruleId=void 0,OF.prototype.source=void 0;var kF=l(yF(),1),AF={}.hasOwnProperty,jF=new Map,MF=/[A-Z]/g,NF=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),PF=new Set([`td`,`th`]),FF=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function IF(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=qF(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=KF(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`?mF:pF,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=LF(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function LF(e,t,n){if(t.type===`element`)return RF(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return zF(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return VF(e,t,n);if(t.type===`mdxjsEsm`)return BF(e,t);if(t.type===`root`)return HF(e,t,n);if(t.type===`text`)return UF(e,t)}function RF(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=mF,e.schema=i),e.ancestors.push(t);let a=$F(e,t.tagName,!1),o=JF(e,t),s=XF(e,t);return NF.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!NP(e)})),WF(e,o,a,t),GF(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function zF(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)}eI(e,t.position)}function BF(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);eI(e,t.position)}function VF(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=mF,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:$F(e,t.name,!0),o=YF(e,t),s=XF(e,t);return WF(e,o,a,t),GF(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function HF(e,t,n){let r={};return GF(r,XF(e,t)),e.create(t,e.Fragment,r,n)}function UF(e,t){return t.value}function WF(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function GF(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function KF(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 qF(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=xF(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 JF(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&AF.call(t.properties,i)){let a=ZF(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&PF.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 YF(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 eI(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 eI(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function XF(e,t){let n=[],r=-1,i=e.passKeys?new Map:jF;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=LF(e,a,o);s!==void 0&&n.push(s)}return n}function ZF(e,t,n){let r=uF(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?DP(n):hF(n)),r.property===`style`){let t=typeof n==`object`?n:QF(e,String(n));return e.stylePropertyNameCase===`css`&&(t=tI(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?oF[r.property]||r.property:r.attribute,n]}}function QF(e,t){try{return(0,kF.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new OF("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=FF+`#cannot-parse-style-attribute`,r}}function $F(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=jP(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=jP(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return AF.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);eI(e)}function eI(e,t){let n=new OF("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=FF+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function tI(e){let t={},n;for(n in e)AF.call(e,n)&&(t[nI(n)]=e[n]);return t}function nI(e){let t=e.replace(MF,rI);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function rI(e){return`-`+e.toLowerCase()}var iI={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`]},aI={};function oI(e,t){let n=t||aI;return sI(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function sI(e,t,n){if(lI(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 cI(e.children,t,n)}return Array.isArray(e)?cI(e,t,n):``}function cI(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=sI(e[i],t,n);return r.join(``)}function lI(e){return!!(e&&typeof e==`object`)}var uI=document.createElement(`i`);function dI(e){let t=`&`+e+`;`;uI.innerHTML=t;let n=uI.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function fI(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 pI(e,t){return e.length>0?(fI(e,e.length,0,t),e):t}var mI={}.hasOwnProperty;function hI(e){let t={},n=-1;for(;++n<e.length;)gI(t,e[n]);return t}function gI(e,t){let n;for(n in t){let r=(mI.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){mI.call(r,a)||(r[a]=[]);let e=i[a];_I(r[a],Array.isArray(e)?e:e?[e]:[])}}}function _I(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);fI(e,0,0,r)}function vI(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 yI(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var bI=MI(/[A-Za-z]/),xI=MI(/[\dA-Za-z]/),SI=MI(/[#-'*+\--9=?A-Z^-~]/);function CI(e){return e!==null&&(e<32||e===127)}var wI=MI(/\d/),TI=MI(/[\dA-Fa-f]/),EI=MI(/[!-/:-@[-`{-~]/);function DI(e){return e!==null&&e<-2}function OI(e){return e!==null&&(e<0||e===32)}function kI(e){return e===-2||e===-1||e===32}var AI=MI(/\p{P}|\p{S}/u),jI=MI(/\s/);function MI(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function NI(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&xI(e.charCodeAt(n+1))&&xI(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 PI(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return kI(r)?(e.enter(n),s(r)):t(r)}function s(r){return kI(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var FI={tokenize:II};function II(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`),PI(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 DI(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var LI={tokenize:zI},RI={tokenize:BI};function zI(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 fI(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(RI,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(RI,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 DI(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++;fI(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 BI(e,t,n){return PI(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function VI(e){if(e===null||OI(e)||jI(e))return 1;if(AI(e))return 2}function HI(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 UI={name:`attention`,resolveAll:WI,tokenize:GI};function WI(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};KI(d,-c),KI(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=pI(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=pI(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=pI(l,HI(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=pI(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=pI(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,fI(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 GI(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=VI(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=VI(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 KI(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var qI={name:`autolink`,tokenize:JI};function JI(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 bI(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||xI(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||xI(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||CI(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):SI(t)?(e.consume(t),l):n(t)}function u(e){return xI(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||xI(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var YI={partial:!0,tokenize:XI};function XI(e,t,n){return r;function r(t){return kI(t)?PI(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||DI(e)?t(e):n(e)}}var ZI={continuation:{tokenize:$I},exit:eL,name:`blockQuote`,tokenize:QI};function QI(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 kI(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function $I(e,t,n){let r=this;return i;function i(t){return kI(t)?PI(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(ZI,t,n)(r)}}function eL(e){e.exit(`blockQuote`)}var tL={name:`characterEscape`,tokenize:nL};function nL(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 EI(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var rL={name:`characterReference`,tokenize:iL};function iL(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=xI,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=TI,u):(e.enter(`characterReferenceValue`),a=7,o=wI,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===xI&&!dI(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 aL={partial:!0,tokenize:cL},oL={concrete:!0,name:`codeFenced`,tokenize:sL};function sL(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`),kI(t)?PI(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||DI(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(aL,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||DI(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):kI(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),PI(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||DI(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||DI(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&&kI(t)?PI(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||DI(t)?e.check(aL,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||DI(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`),kI(t)?PI(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`),kI(t)?PI(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||DI(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function cL(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 lL={name:`codeIndented`,tokenize:dL},uL={partial:!0,tokenize:fL};function dL(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),PI(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):DI(t)?e.attempt(uL,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||DI(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function fL(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):DI(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):PI(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):DI(e)?i(e):n(e)}}var pL={name:`codeText`,previous:hL,resolve:mL,tokenize:gL};function mL(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 hL(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function gL(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)):DI(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||DI(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 _L=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&&vL(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),vL(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),vL(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);vL(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);vL(this.left,t.reverse())}}}};function vL(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 yL(e){let t={},n=-1,r,i,a,o,s,c,l,u=new _L(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,bL(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 fI(e,0,1/0,u.slice(0)),!l}function bL(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 xL={resolve:CL,tokenize:wL},SL={partial:!0,tokenize:TL};function CL(e){return yL(e),e}function wL(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):DI(t)?e.check(SL,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 TL(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),PI(e,a,`linePrefix`)}function a(i){if(i===null||DI(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 EL(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||CI(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||DI(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||OI(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||CI(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 DL(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):DI(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||DI(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!kI(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function OL(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):DI(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),PI(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||DI(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 kL(e,t){let n;return r;function r(i){return DI(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):kI(i)?PI(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var AL={name:`definition`,tokenize:ML},jL={partial:!0,tokenize:NL};function ML(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return DL.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=yI(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 OI(t)?kL(e,l)(t):l(t)}function l(t){return EL(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(jL,d,d)(t)}function d(t){return kI(t)?PI(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||DI(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function NL(e,t,n){return r;function r(t){return OI(t)?kL(e,i)(t):n(t)}function i(t){return OL(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return kI(t)?PI(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||DI(e)?t(e):n(e)}}var PL={name:`hardBreakEscape`,tokenize:FL};function FL(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return DI(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var IL={name:`headingAtx`,resolve:LL,tokenize:RL};function LL(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`},fI(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function RL(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||OI(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||DI(n)?(e.exit(`atxHeading`),t(n)):kI(n)?PI(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||OI(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var zL=`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(`.`),BL=[`pre`,`script`,`style`,`textarea`],VL={concrete:!0,name:`htmlFlow`,resolveTo:WL,tokenize:GL},HL={partial:!0,tokenize:qL},UL={partial:!0,tokenize:KL};function WL(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 GL(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):bI(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):bI(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 bI(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||OI(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&BL.includes(l)?(i=1,r.interrupt?t(s):O(s)):zL.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||xI(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 kI(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||bI(t)?(e.consume(t),b):kI(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||xI(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):kI(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):kI(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||DI(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||OI(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||kI(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||DI(t)?O(t):kI(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),ee):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):DI(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(HL,ne,k)(t)):t===null||DI(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(UL,A,ne)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||DI(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function ee(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 BL.includes(n)?(e.consume(t),te):O(t)}return bI(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||DI(t)?(e.exit(`htmlFlowData`),ne(t)):(e.consume(t),te)}function ne(n){return e.exit(`htmlFlow`),t(n)}}function KL(e,t,n){let r=this;return i;function i(t){return DI(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 qL(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(YI,t,n)}}var JL={name:`htmlText`,tokenize:YL};function YL(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):bI(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):bI(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):DI(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?ee(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):DI(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?ee(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?ee(t):DI(t)?(o=v,M(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):DI(t)?(o=y,M(t)):(e.consume(t),y)}function b(e){return e===62?ee(e):y(e)}function x(t){return bI(t)?(e.consume(t),S):n(t)}function S(t){return t===45||xI(t)?(e.consume(t),S):C(t)}function C(t){return DI(t)?(o=C,M(t)):kI(t)?(e.consume(t),C):ee(t)}function w(t){return t===45||xI(t)?(e.consume(t),w):t===47||t===62||OI(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),ee):t===58||t===95||bI(t)?(e.consume(t),E):DI(t)?(o=T,M(t)):kI(t)?(e.consume(t),T):ee(t)}function E(t){return t===45||t===46||t===58||t===95||xI(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):DI(t)?(o=D,M(t)):kI(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,k):DI(t)?(o=O,M(t)):kI(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):DI(t)?(o=k,M(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||OI(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||OI(e)?T(e):n(e)}function ee(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 kI(t)?PI(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 XL={name:`labelEnd`,resolveAll:eR,resolveTo:tR,tokenize:nR},ZL={tokenize:rR},QL={tokenize:iR},$L={tokenize:aR};function eR(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&&fI(e,0,e.length,n),e}function tR(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=pI(s,e.slice(a+1,a+r+3)),s=pI(s,[[`enter`,u,t]]),s=pI(s,HI(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=pI(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=pI(s,e.slice(o+1)),s=pI(s,[[`exit`,c,t]]),fI(e,a,e.length,s),e}function nR(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(yI(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(ZL,u,o?u:d)(t):t===91?e.attempt(QL,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt($L,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function rR(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 OI(t)?kL(e,a)(t):a(t)}function a(t){return t===41?u(t):EL(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return OI(t)?kL(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?OL(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return OI(t)?kL(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 iR(e,t,n){let r=this;return i;function i(t){return DL.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(yI(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function aR(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 oR={name:`labelStartImage`,resolveAll:XL.resolveAll,tokenize:sR};function sR(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 cR={name:`labelStartLink`,resolveAll:XL.resolveAll,tokenize:lR};function lR(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 uR={name:`lineEnding`,tokenize:dR};function dR(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),PI(e,t,`linePrefix`)}}var fR={name:`thematicBreak`,tokenize:pR};function pR(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||DI(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),kI(t)?PI(e,s,`whitespace`)(t):s(t))}}var mR={continuation:{tokenize:vR},exit:bR,name:`list`,tokenize:_R},hR={partial:!0,tokenize:xR},gR={partial:!0,tokenize:yR};function _R(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:wI(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(fR,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 wI(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(YI,r.interrupt?n:u,e.attempt(hR,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return kI(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 vR(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(YI,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,PI(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!kI(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(gR,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,PI(e,e.attempt(mR,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function yR(e,t,n){let r=this;return PI(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 bR(e){e.exit(this.containerState.type)}function xR(e,t,n){let r=this;return PI(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!kI(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var SR={name:`setextUnderline`,resolveTo:CR,tokenize:wR};function CR(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 wR(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`),kI(t)?PI(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||DI(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var TR={tokenize:ER};function ER(e){let t=this,n=e.attempt(YI,r,e.attempt(this.parser.constructs.flowInitial,i,PI(e,e.attempt(this.parser.constructs.flow,i,e.attempt(xL,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 DR={resolveAll:jR()},OR=AR(`string`),kR=AR(`text`);function AR(e){return{resolveAll:jR(e===`text`?MR: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 jR(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 MR(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 NR=s({attentionMarkers:()=>VR,contentInitial:()=>FR,disable:()=>HR,document:()=>PR,flow:()=>LR,flowInitial:()=>IR,insideSpan:()=>BR,string:()=>RR,text:()=>zR}),PR={42:mR,43:mR,45:mR,48:mR,49:mR,50:mR,51:mR,52:mR,53:mR,54:mR,55:mR,56:mR,57:mR,62:ZI},FR={91:AL},IR={[-2]:lL,[-1]:lL,32:lL},LR={35:IL,42:fR,45:[SR,fR],60:VL,61:SR,95:fR,96:oL,126:oL},RR={38:rL,92:tL},zR={[-5]:uR,[-4]:uR,[-3]:uR,33:oR,38:rL,42:UI,60:[qI,JL],91:cR,92:[PL,tL],93:XL,95:UI,96:pL},BR={null:[UI,DR]},VR={null:[42,95]},HR={null:[]};function UR(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=pI(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=HI(a,l.events,l),l.events):[]}function f(e,t){return GR(p(e),t)}function p(e){return WR(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){DI(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&&fI(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 WR(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 GR(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
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 KR(e){let t={constructs:hI([NR,...(e||{}).extensions||[]]),content:n(FI),defined:[],document:n(LI),flow:n(TR),lazy:{},string:n(OR),text:n(kR)};return t;function n(e){return n;function n(n){return UR(t,e,n)}}}function qR(e){for(;!yL(e););return e}var JR=/[\0\t\n\r]/g;function YR(){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(JR.lastIndex=u,c=JR.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 XR=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function ZR(e){return e.replace(XR,QR)}function QR(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return vI(n.slice(t?2:1),t?16:10)}return dI(n)||e}var $R={}.hasOwnProperty;function ez(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),tz(n)(qR(KR(n).document().write(YR()(e,t,!0))))}function tz(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(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(M),label:P,labelText:N,lineEnding:D,link:c(ee),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()}};rz(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]];$R.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]||az).call(a,void 0,e[0])}for(r.position={start:nz(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:nz(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:nz(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]||az).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+wF({start:e.start,end:e.end})+`): it’s not open`);n.position.end=nz(e.end)}function u(){return oI(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=yI(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:nz(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=nz(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=nz(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 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.resume(),t=this.stack[this.stack.length-1];t.value=e}function ee(){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=ZR(t),n.identifier=yI(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=yI(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=vI(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=dI(t);let i=this.stack[this.stack.length-1];i.value+=r}function se(e){let t=this.stack.pop();t.position.end=nz(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 nz(e){return{line:e.line,column:e.column,offset:e.offset}}function rz(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?rz(e,r):iz(e,r)}}function iz(e,t){let n;for(n in t)if($R.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 az(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+wF({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+wF({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+wF({start:t.start,end:t.end})+`) is still open`)}function oz(e){let t=this;t.parser=n;function n(n){return ez(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function sz(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 cz(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
@@ -134,4 +134,4 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
134
134
  `):void 0,o?.filter(e=>e.trim()).map((e,t)=>`${t+1}. ${e}`).join(`
135
135
  `),s].find(e=>e?.trim())??`No text was recorded for this part.`}catch{return`Recorded text cannot be decoded.`}}function XK({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 QW(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 $W(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:iG(r,e,c.revision.id),download:!0,children:`Download all images`}),(0,h.jsx)(aG,{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:[VK(t.output),` · `,t.state,t.selected?``:` · Earlier result`,`:`,` `,t.available?(0,h.jsx)(`a`,{href:nG(r,e,c.revision.id,t.recordId),children:`Download`}):`File missing`,t.available?(0,h.jsx)(aG,{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:nG(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:nG(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:VK(t.output),loading:`lazy`,src:nG(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:nG(r,e,c.revision.id,t.recordId)}),(0,h.jsx)(`a`,{href:nG(r,e,c.revision.id,t.recordId),children:`Download narration part`}),(0,h.jsx)(aG,{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:YK(e.piece.payload)})]})},e.recordId))}),(0,h.jsx)(B,{type:`button`,disabled:t,onClick:()=>n(c.revision.id),children:`Restore this revision`})]})]})}function ZK(e,t,n){let r=JSON.stringify(t);return e?.payload===r?e:{payload:r,idempotencyKey:n()}}function QK({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 $W(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,k=(0,m.useRef)(!1);async function A(e){if(!k.current){k.current=!0,v(!0),S(void 0);try{await e()}catch(e){S(e instanceof Error?e.message:String(e))}finally{k.current=!1,v(!1)}}}async function j(t){let n=await YW(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 ee(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=ZK(T.current,t,()=>crypto.randomUUID());T.current=n;let i=await XW(r,e,{...t,idempotencyKey:n.idempotencyKey});if(!i.ok){w(i);return}await ee(i.value.view),T.current=void 0}async function N(){let t=await j(!1);if(t===void 0)return;let n=await eG(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=ZK(D.current,n,()=>crypto.randomUUID());D.current=a;let o=await tG(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 j(!1);if(n===void 0)return;let i={baseRevisionId:n.revision.id,targetRevisionId:t},s=ZK(E.current,i,()=>crypto.randomUUID());E.current=s;let c=await ZW(r,e,{...i,idempotencyKey:s.idempotencyKey});if(!c.ok){w(c);return}await ee(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:[VK(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 A(async()=>{await j(!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 A(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 A(async()=>{E.current=void 0,D.current=void 0,p(void 0),await j(!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(),A(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 A(async()=>{T.current=void 0,b(!1),await j(!0),w(void 0)}),children:`Reload current revision and discard my draft`}):null]})]}),u?(0,h.jsx)(XK,{projectId:e,pending:g||y||c!==void 0||f!==void 0,onRestore:e=>void A(()=>F(e))}):null,f===void 0?null:(0,h.jsx)(UK,{preview:f,pending:g,onStart:e=>void A(()=>P(e)),onCancel:()=>{p(void 0),D.current=void 0}},f.id)]})}var $K=K({id:OE(),name:W(),version:KE().int().positive(),updatedAt:W()}),eq=$K.extend({document:gO}),tq=oD([eq,K({template:eq}).transform(e=>e.template)]),nq=K({title:W(),detail:W().optional(),reason:W().optional()}),rq=[`project-templates`],iq=e=>`${e.origin}/api/project-templates`;async function aq(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=nq.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 oq=(e,t)=>({method:e,headers:{"content-type":`application/json`},body:JSON.stringify(t)});async function sq(e){return aq(await e.fetch(iq(e)),K({templates:G($K)}).transform(e=>e.templates))}function cq(e){return{queryKey:rq,queryFn:async()=>{let t=await sq(e);if(!t.ok)throw Error(t.message);return t.value}}}async function lq(e,t){let n=K({id:OE(),name:W().trim().min(1),document:gO}).parse(t);return aq(await e.fetch(iq(e),oq(`POST`,n)),tq)}async function uq(e,t,n){let r=K({id:OE(),name:W().trim().min(1).max(200),revisionId:W().min(1).max(64)}).parse(n);return aq(await e.fetch(`${iq(e)}/from-project/${encodeURIComponent(t)}`,oq(`POST`,r)),tq)}async function dq(e,t){let n=await e.fetch(`${iq(e)}/${encodeURIComponent(t.id)}`,oq(`DELETE`,{baseVersion:t.version}));return n.ok?{ok:!0,value:null}:aq(n,QE())}async function fq(e,t,n){let r=K({id:OE(),version:KE().int().positive()}).parse({id:n,version:t.version});return aq(await e.fetch(`${iq(e)}/${encodeURIComponent(t.id)}/instantiate`,oq(`POST`,r)),oD([EO,K({draft:EO}).transform(e=>e.draft)]))}function pq({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 uq(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:rq})}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)(oM,{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 mq(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 hq(e,t,n){let r=mq(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}:Ik(i.readiness)?void 0:{label:i.readiness.issue?`CLI update required`:`CLI missing`,provider:r}}var gq={research:`Research notes`,article:`Article workspace`,audio:`Narration`,images:`Image library`,thumbnail:`Thumbnail preview`,video:`Preview & export`};function _q({stage:e,project:t,outputs:n,providers:r,actions:i,children:a,active:o=!0}){let s=(0,m.useContext)(bP),c=zk(e.kind,t.config),l=t.status===`paused`?{...i,pending:!0}:i,u=hq(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`:gq[e.kind]}),(0,h.jsx)(`p`,{className:`mt-1 text-small text-ink2`,children:Uk(e,n,t)})]}),(0,h.jsx)(sK,{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:Wk(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)(xG,{message:d,onDismiss:i.dismissRefusal})}):null,e.state===`running`&&e.kind!==`article`&&e.kind!==`images`&&e.kind!==`video`?(0,h.jsx)(TP,{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 vq=K({baseRevisionId:W().min(1).max(64),idempotencyKey:OE()}).strict(),yq=new Set([400,404,409]);async function bq(e,t,n){return jq(e,t,`cancel`,n)}async function xq(e,t,n){return jq(e,t,`pause`,n)}async function Sq(e,t){return Aq(await e.client.projects[`:id`].resume.$post({param:{id:t}}))}async function Cq(e,t,n){return Aq(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/providers`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}))}async function wq(e,t,n){return Aq(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/subtitles`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)}))}async function Tq(e,t,n){return Aq(await e.client.projects[`:id`].stages[`:kind`].retry.$post({param:{id:t,kind:n}}))}async function Eq(e,t,n){return Aq(await e.client.projects[`:id`].stages[`:kind`].rerun.$post({param:{id:t,kind:n}}))}async function Dq(e,t,n){return Aq(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/article`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({markdown:n})}))}async function Oq(e,t,n){return Aq(await e.client.projects[`:id`].images[`:outputId`].$delete({param:{id:t,outputId:n}}))}async function kq(e,t,n){return Aq(await e.client.projects[`:id`].images[`:outputId`].regenerate.$post({param:{id:t,outputId:n}}))}async function Aq(e){if(e.ok)return{ok:!0,value:await e.json()};let t=await ao(e);if(t!==void 0&&yq.has(e.status))return{ok:!1,message:io(e,t).message};throw io(e,t)}async function jq(e,t,n,r){let i=vq.parse(r);return Aq(await e.fetch(`${e.origin}/api/projects/${encodeURIComponent(t)}/${n}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(i)}))}function Mq(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 Pq(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 YW(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`?xq:bq)(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:Nq(t.action)}),await n.invalidateQueries({queryKey:V.project(t.projectId)})},onSettled:()=>{o.current=!1},onError:(e,t)=>{i({message:e.message,stage:Nq(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 Nq(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 Pq(e,t,n){switch(n.kind){case`resume`:return Sq(e,t);case`providers`:return Cq(e,t,n.choices);case`subtitles`:return wq(e,t,n.subtitles);case`retry`:return Tq(e,t,n.stage);case`rerun`:return Eq(e,t,n.stage);case`save-article`:return Dq(e,t,n.markdown);case`delete-image`:return Oq(e,t,n.outputId);case`regenerate-image`:return kq(e,t,n.outputId)}}var Fq=200;function Iq(e,t=null){let{api:n,openEvents:r}=I(),i=_();(0,m.useEffect)(()=>{i.setQueryData(V.article(e,t),``),i.setQueryData(CP(e,t),[]);let a=()=>i.getQueryData(V.project(e))?.revisionId??null,o=jk(()=>{i.invalidateQueries({queryKey:V.project(e)}),i.invalidateQueries({queryKey:V.projects}),i.invalidateQueries({queryKey:JG(e)})},Fq),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(CP(e,a()),e=>wP(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(CP(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=>kk(e,t))}});return()=>{s(),o.stop()}},[n,r,i,e,t])}function Lq({projectId:e}){return(0,h.jsx)(Rq,{projectId:e},e)}function Rq({projectId:e}){let{api:t}=I(),n=nt(hy(t,e)),r=nt(vy(t)),i=nt(by(t)),a=Mq(e),[o,s]=(0,m.useState)(),c=NA(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:Rk(n.data.project.config)===`article`?`article`:`video`}))},[c,e,n.data]),Iq(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)(zq,{});let{project:u,stages:d,outputs:f}=n.data,p=o?.projectId===e?o.stage:mK(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)(sG,{projectId:e,revisionId:n.data.revisionId,children:(0,h.jsx)(bP,{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)(uK,{project:u,prompts:i.data?.prompts,actions:a,inFlight:v,primaryOutput:_,children:(0,h.jsx)(pq,{projectId:e,revisionId:n.data.revisionId,title:u.title})}),a.refusal===void 0||a.refusal.stage!==void 0?null:(0,h.jsx)(Nj,{className:`py-[10px]`,children:(0,h.jsx)(xG,{message:a.refusal.message,onDismiss:a.dismissRefusal})}),(0,h.jsx)(QK,{projectId:e,currentRevisionId:n.data.revisionId,renderEditor:e=>(0,h.jsx)(zK,{...e,renderContent:e=>(0,h.jsx)(FK,{...e},e.view.revision.id)})})]}),(0,h.jsx)(hP,{}),(0,h.jsx)(hK,{stages:d,project:u}),(0,h.jsx)(rK,{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)(gK,{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)(_q,{active:e.kind===p,stage:e,project:u,outputs:f,providers:r.data?.providers??[],actions:a,children:(0,h.jsx)(UG,{stage:e,project:u,outputs:f,actions:a,busy:y})},e.id))})]})]})})})}function zq(){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)(Mj,{children:[0,1,2,3,4,5].map(e=>(0,h.jsxs)(Nj,{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 Bq=`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]`,Vq=`col-start-2 row-start-2 text-small text-ink2 tabular-nums md:col-start-3 md:row-start-1`,Hq=`col-start-3 row-start-1 justify-end md:col-start-4`,Uq=`relative z-10 col-start-4 row-start-1 size-8 p-0 md:col-start-5`;function Wq(){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)(hP,{}),n.data?.projects.length===0?(0,h.jsx)(sj,{}):null,n.error===null?null:(0,h.jsx)(Mj,{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)(Jq,{}):null:n.data.projects.length===0?(0,h.jsx)(Mj,{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)(Mj,{children:n.data.projects.map(e=>(0,h.jsx)(Gq,{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)(jj,{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 Gq({project:e,onDelete:t}){return(0,h.jsxs)(`div`,{className:Bq,children:[(0,h.jsx)(lK,{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:Kq(e)})]}),(0,h.jsx)(`span`,{className:Vq,children:jc(e.createdAt)}),(0,h.jsx)(sK,{state:e.status,announce:e.title,className:Hq}),(0,h.jsx)(qq,{project:e,onDelete:t}),e.status===`running`?(0,h.jsx)(Pj,{current:e.progress,total:1}):null]})}function Kq(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)(Ij,{children:[(0,h.jsx)(Lj,{asChild:!0,children:(0,h.jsx)(B,{variant:`ghost`,"aria-label":`More for ${e.title}`,className:Uq,children:(0,h.jsx)($A,{"aria-hidden":`true`,className:`size-4`})})}),(0,h.jsxs)(Rj,{children:[(0,h.jsx)(`span`,{title:n?`Cancel the run first`:void 0,children:(0,h.jsx)(zj,{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 Jq(){return(0,h.jsx)(Mj,{children:[0,1,2,3,4,5].map(e=>(0,h.jsxs)(`div`,{className:Bq,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))})}function Yq({promptId:e,kind:t,from:n,onLeave:r}){let{api:i}=I(),a=_(),o=MA(),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]=Dk(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=s.data?.prompts,E=e??n,D=E===void 0?void 0:T?.find(e=>e.id===E),O=D===void 0?{kind:t,name:``,body:``}:e===void 0?{kind:D.kind,name:`${D.name} copy`,body:D.body}:{kind:D.kind,name:D.name,body:D.body},k=p??b??O,A=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})}}),j=it({mutationFn:e=>Mo(i,e),onSuccess:async()=>{w(!1),g(void 0),await a.invalidateQueries({queryKey:by(i).queryKey}),r(k.kind)}});Zj(S,()=>{r(k.kind)});let ee=(e,t)=>{g(e),y(e=>e.filter(e=>e.field!==t))},M=bM(k,v),N=xM(M),P=wM(k.body),F=k.body.trim()===``?[]:SM(M),te=k.name.trim()===``?[]:CM(M);return jA({promptNamed:k.name.trim()!==``&&te.length===0,promptBodyReady:k.body.trim()!==``&&F.length===0,promptHasKeywords:P.length>0&&F.length===0,promptSaveReady:N===void 0&&!A.isPending&&!S,promptSaving:A.isPending||S,promptIsArticle:k.kind===`article`,promptIsImage:k.kind===`image`}),s.error===null?E!==void 0&&T===void 0?(0,h.jsx)(tM,{}):E!==void 0&&D===void 0?(0,h.jsx)(Xq,{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:k.kind},className:`mb-[10px] inline-flex items-center gap-1 text-small text-ink2 hover:text-ink`,children:[(0,h.jsx)(qA,{"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:`${eM} flex min-w-0 flex-col gap-[14px]`,children:[(0,h.jsxs)(`div`,{className:`flex items-end gap-[14px]`,children:[(0,h.jsxs)(`div`,{"data-tour":`prompt-name`,className:`flex-1`,children:[(0,h.jsx)(iM,{htmlFor:c,className:`mb-[5px]`,children:`Name`}),(0,h.jsx)(oM,{id:c,value:k.name,"aria-invalid":te.length>0,"aria-describedby":te.length===0?void 0:l,onChange:e=>{ee({...k,name:e.target.value},`name`)}}),te.length===0?null:(0,h.jsx)(`p`,{id:l,className:`mt-1 text-label text-red`,children:te.map(e=>e.message).join(` `)})]}),(0,h.jsx)(aM,{label:`Kind`,value:k.kind,options:Oj,onPick:e=>{ee({...k,kind:e},`name`)}})]}),(0,h.jsxs)(`div`,{"data-tour":`prompt-body`,children:[(0,h.jsx)(iM,{htmlFor:u,className:`mb-[5px]`,children:`Body`}),(0,h.jsx)(DM,{id:u,value:k.body,invalid:F.length>0,describedBy:F.length===0?void 0:d,onChange:e=>{ee({...k,body:e},`body`)}})]}),(0,h.jsx)(`div`,{"data-tour":`prompt-save`,children:(0,h.jsx)($j,{onDelete:e===void 0?void 0:()=>{w(!0)},blocked:N,blockedId:f,pending:A.isPending,saved:S,cancel:(0,h.jsx)(B,{asChild:!0,children:(0,h.jsx)(sa,{to:`/prompts`,search:{kind:k.kind},onClick:()=>{g(void 0)},children:`Cancel`})}),errors:[A.error,j.error].flatMap(e=>e===null?[]:[e.message]),onSave:()=>{A.mutate(k)}})})]}),(0,h.jsx)(`div`,{"data-tour":`prompt-slots`,className:`${eM} flex flex-col gap-3 lg:sticky lg:top-6`,children:(0,h.jsx)(Yj,{slots:P,body:k.body,lint:F,lintId:d})})]}),(0,h.jsx)(jj,{open:C,title:`Delete "${k.name}"?`,consequence:`Projects that used it keep their text.`,verb:`Delete`,pending:j.isPending,onConfirm:()=>{e!==void 0&&j.mutate(e)},onCancel:()=>{w(!1)}})]}):(0,h.jsx)(Xq,{kind:k.kind,children:s.error.message})}function Xq({kind:e,children:t}){return(0,h.jsx)(nM,{back:(0,h.jsx)(sa,{to:`/prompts`,search:{kind:e},className:rM,children:`Back to Prompts`}),children:t})}var Zq=`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]`,Qq=`col-span-3 col-start-1 row-start-2 flex flex-wrap gap-[6px] md:col-span-1`,$q=`md:col-start-2 md:row-start-1`;function eJ({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 items-center gap-4`,children:[(0,h.jsx)(Bj,{type:`single`,value:e,"aria-label":`Prompt kind`,onValueChange:e=>{let n=Oj.find(t=>t.value===e);n!==void 0&&t(n.value)},children:Oj.map(e=>(0,h.jsx)(Vj,{value:e.value,children:e.label},e.value))}),(0,h.jsx)(`span`,{className:`flex-1`}),(0,h.jsx)(tJ,{kind:e})]}),i.error===null?null:(0,h.jsx)(Mj,{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)(iJ,{}):null:c.length===0?(0,h.jsx)(nJ,{kind:e}):(0,h.jsx)(Mj,{children:c.map(e=>(0,h.jsxs)(`div`,{className:Zq,children:[(0,h.jsx)(`span`,{className:`col-start-1 row-start-1 font-semibold`,children:e.name}),(0,h.jsx)(`span`,{className:z(Qq,$q),children:e.slots.map(e=>(0,h.jsx)(Fj,{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)(rJ,{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)(jj,{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 tJ({kind:e}){return(0,h.jsx)(B,{asChild:!0,children:(0,h.jsxs)(sa,{to:`/prompts/new`,search:{kind:e},children:[(0,h.jsx)(rj,{"aria-hidden":`true`,className:`size-[14px]`}),`New prompt`]})})}function nJ({kind:e}){return(0,h.jsx)(Mj,{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)(tJ,{kind:e})]})})}function rJ({prompt:e,onDelete:t}){return(0,h.jsxs)(Ij,{children:[(0,h.jsx)(Lj,{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)($A,{"aria-hidden":`true`,className:`size-4`})})}),(0,h.jsxs)(Rj,{children:[(0,h.jsx)(zj,{asChild:!0,children:(0,h.jsx)(sa,{to:`/prompts/new`,search:{kind:e.kind,from:e.id},children:`Duplicate`})}),(0,h.jsx)(zj,{onSelect:t,children:`Delete`})]})]})}function iJ(){return(0,h.jsx)(Mj,{children:[0,1,2].map(e=>(0,h.jsxs)(`div`,{className:Zq,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(Qq,$q),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 aJ=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 oJ(e){try{return new Intl.DateTimeFormat(`en`,{timeZone:e}).format(),!0}catch{return!1}}var sJ=OE(),cJ=W().min(1).max(200).refine(e=>e===e.trim(),`Keyword names cannot start or end with spaces.`),lJ=K({title:W().trim().min(1).max(200),values:fD(cJ,W().max(1e4)).readonly()}).strict().readonly(),uJ=q([`skip`,`run-once`]);K({id:sJ,name:W().trim().min(1).max(200),templateId:sJ,templateVersion:KE().int().positive(),cadence:aJ,timezone:W().min(1).max(100).refine(oJ,`Choose a valid IANA timezone.`),missedPolicy:uJ.default(`skip`),overlapPolicy:hD(`skip`).default(`skip`),spendLimitCents:KE().int().nonnegative().nullable().default(null),items:G(lJ).max(49).default([]).readonly()}).strict().readonly().unwrap().extend({baseVersion:KE().int().positive(),mutationId:sJ}).strict().readonly(),K({id:sJ,baseVersion:KE().int().positive()}).strict().readonly(),K({id:sJ,baseVersion:KE().int().positive()}).strict().readonly();var dJ=K({id:sJ,name:W(),templateId:sJ,templateVersion:KE().int().positive(),cadence:aJ,timezone:W(),missedPolicy:uJ,overlapPolicy:hD(`skip`),spendLimitCents:KE().int().nonnegative().nullable(),items:G(lJ).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(),fJ=K({id:sJ,scheduleId:sJ,scheduledFor:W().datetime({offset:!0}),status:q([`running`,`succeeded`,`failed`,`skipped`]),requestId:sJ.nullable(),projectIds:G(W()).readonly(),estimate:eD().nullable(),startedAt:W().datetime({offset:!0}),endedAt:W().datetime({offset:!0}).nullable(),error:W().nullable()}).strict().readonly(),pJ=K({title:W(),detail:W().optional(),reason:W().optional()}),mJ=K({schedules:G(dJ)}),hJ=K({schedule:dJ,runs:G(fJ)}),gJ=e=>`${e.origin}/api/schedules`;async function _J(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=pJ.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 vJ=(e,t)=>({method:e,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),yJ=[`schedules`];function bJ(e){return{queryKey:yJ,queryFn:async()=>{let t=await _J(await e.fetch(gJ(e)),mJ);if(!t.ok)throw Error(t.message);return t.value.schedules},refetchInterval:3e4}}async function xJ(e,t){return _J(await e.fetch(`${gJ(e)}/${encodeURIComponent(t)}`),hJ)}async function SJ(e,t){return _J(await e.fetch(gJ(e),vJ(`POST`,t)),dJ)}async function CJ(e,t,n){return _J(await e.fetch(`${gJ(e)}/${encodeURIComponent(t)}`,vJ(`PUT`,n)),dJ)}async function wJ(e,t,n,r){return _J(await e.fetch(`${gJ(e)}/${encodeURIComponent(t)}/${n}`,vJ(`POST`,{baseVersion:r})),dJ)}async function TJ(e,t,n){return _J(await e.fetch(`${gJ(e)}/${encodeURIComponent(t)}`,vJ(`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),EJ=Y.default.BigInt(0),DJ=Y.default.BigInt(1),OJ=Y.default.BigInt(2),kJ=Y.default.BigInt(10),AJ=Y.default.BigInt(24),jJ=Y.default.BigInt(60),MJ=Y.default.BigInt(1e3),NJ=Y.default.BigInt(1e6),PJ=Y.default.BigInt(1e9),FJ=Y.default.multiply(Y.default.BigInt(3600),PJ),IJ=Y.default.multiply(jJ,PJ),LJ=Y.default.multiply(FJ,AJ);function RJ(e){return typeof e==`bigint`?Y.default.BigInt(e.toString(10)):e}function zJ(e){return Y.default.equal(Y.default.remainder(e,OJ),EJ)}function BJ(e){return Y.default.lessThan(e,EJ)?Y.default.unaryMinus(e):e}function VJ(e,t){return Y.default.lessThan(e,t)?-1:+!!Y.default.greaterThan(e,t)}function HJ(e,t){return{quotient:Y.default.divide(e,t),remainder:Y.default.remainder(e,t)}}var UJ,WJ,GJ=`slot-epochNanoSeconds`,KJ=`slot-iso-date`,qJ=`slot-iso-date-time`,JJ=`slot-time`,X=`slot-calendar`,YJ=`slot-date-brand`,XJ=`slot-year-month-brand`,ZJ=`slot-month-day-brand`,QJ=`slot-time-zone`,$J=`slot-years`,eY=`slot-months`,tY=`slot-weeks`,nY=`slot-days`,rY=`slot-hours`,iY=`slot-minutes`,aY=`slot-seconds`,oY=`slot-milliseconds`,sY=`slot-microseconds`,cY=`slot-nanoseconds`,lY=`date`,uY=`ym`,dY=`md`,fY=`time`,pY=`datetime`,mY=`instant`,hY=`original`,gY=`timezone-canonical`,_Y=`timezone-original`,vY=`calendar-id`,yY=`locale`,bY=`options`,xY=new WeakMap,SY=Symbol.for(`@@Temporal__GetSlots`);(UJ=globalThis)[SY]||(UJ[SY]=function(e){return xY.get(e)});var CY=globalThis[SY],wY=Symbol.for(`@@Temporal__CreateSlots`);(WJ=globalThis)[wY]||(WJ[wY]=function(e){xY.set(e,Object.create(null))});var TY=globalThis[wY];function EY(e,...t){if(!e||typeof e!=`object`)return!1;let n=CY(e);return!!n&&t.every((e=>e in n))}function Z(e,t){let n=CY(e)?.[t];if(n===void 0)throw TypeError(`Missing internal slot ${t}`);return n}function DY(e,t,n){let r=CY(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 OY={};function kY(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))}AY(t,e),AY(`${t}.prototype`,e.prototype)}function AY(e,t){let n=`%${e}%`;if(OY[n]!==void 0)throw Error(`intrinsic ${e} already exists`);OY[n]=t}function jY(e){return OY[e]}function MY(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 NY(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 PY(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 FY(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 IY=class e{constructor(e){this.totalNs=RJ(e),this.sec=Y.default.toNumber(Y.default.divide(this.totalNs,PJ)),this.subsec=Y.default.toNumber(Y.default.remainder(this.totalNs,PJ))}static validateNew(t,n){if(Y.default.greaterThan(BJ(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(RJ(t),RJ(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),MJ)),Y.default.multiply(Y.default.BigInt(i),NJ)),Y.default.multiply(Y.default.BigInt(r),PJ)),Y.default.multiply(Y.default.BigInt(n),IJ)),Y.default.multiply(Y.default.BigInt(t),FJ));return e.validateNew(s,`total`)}abs(){return new e(BJ(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),LJ)),`sum`)}addToEpochNs(e){return Y.default.add(RJ(e),this.totalNs)}cmp(e){return VJ(this.totalNs,e.totalNs)}divmod(t){let{quotient:n,remainder:r}=HJ(this.totalNs,Y.default.BigInt(t));return{quotient:Y.default.toNumber(n),remainder:new e(r)}}fdiv(e){let t=RJ(e),n=Y.default.BigInt(t),{quotient:r,remainder:i}=HJ(this.totalNs,n),a=[],o,s=(Y.default.lessThan(this.totalNs,EJ)?-1:1)*Math.sign(Y.default.toNumber(t));for(;!Y.default.equal(i,EJ)&&a.length<50;)i=Y.default.multiply(i,kJ),{quotient:o,remainder:i}=HJ(i,n),a.push(Math.abs(Y.default.toNumber(o)));return s*Number(BJ(r).toString()+`.`+a.join(``))}isZero(){return Y.default.equal(this.totalNs,EJ)}round(t,n){let r=RJ(t);if(Y.default.equal(r,DJ))return this;let{quotient:i,remainder:a}=HJ(this.totalNs,r),o=Y.default.lessThan(this.totalNs,EJ)?`negative`:`positive`,s=Y.default.multiply(BJ(i),r),c=Y.default.add(s,r),l=VJ(BJ(Y.default.multiply(a,OJ)),r),u=PY(n,o),d=Y.default.equal(BJ(this.totalNs),s)?s:FY(s,c,l,zJ(i),u),f=o===`positive`?d:Y.default.unaryMinus(d);return e.validateNew(f,`rounding`)}sign(){return this.cmp(new e(EJ))}subtract(t){return e.validateNew(Y.default.subtract(this.totalNs,t.totalNs),`difference`)}};IY.MAX=Y.default.BigInt(`9007199254740991999999999`),IY.ZERO=new IY(EJ);var LY=/[A-Za-z._][A-Za-z._0-9+-]*/,RY=RegExp(`(?:(?:[+-](?:[01][0-9]|2[0-3])(?::?[0-5][0-9])?)|(?:${LY.source})(?:\\/(?:${LY.source}))*)`),zY=/(?:[+-]\d{6}|\d{4})/,BY=/(?:0[1-9]|1[0-2])/,VY=/(?:0[1-9]|[12]\d|3[01])/,HY=RegExp(`(${zY.source})(?:-(${BY.source})-(${VY.source})|(${BY.source})(${VY.source}))`),UY=/(\d{2})(?::(\d{2})(?::(\d{2})(?:[.,](\d{1,9}))?)?|(\d{2})(?:(\d{2})(?:[.,](\d{1,9}))?)?)?/,WY=/((?:[+-])(?:[01][0-9]|2[0-3])(?::?(?:[0-5][0-9])(?::?(?:[0-5][0-9])(?:[.,](?:\d{1,9}))?)?)?)/,GY=RegExp(`([zZ])|${WY.source}?`),KY=/\[(!)?([a-z_][a-z0-9_-]*)=([A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)\]/g,qY=new RegExp([`^${HY.source}`,`(?:(?:[tT]|\\s+)${UY.source}(?:${GY.source})?)?`,`(?:\\[!?(${RY.source})\\])?`,`((?:${KY.source})*)$`].join(``)),JY=new RegExp([`^[tT]?${UY.source}`,`(?:${GY.source})?`,`(?:\\[!?${RY.source}\\])?`,`((?:${KY.source})*)$`].join(``)),YY=RegExp(`^(${zY.source})-?(${BY.source})(?:\\[!?${RY.source}\\])?((?:${KY.source})*)$`),XY=RegExp(`^(?:--)?(${BY.source})-?(${VY.source})(?:\\[!?${RY.source}\\])?((?:${KY.source})*)$`),ZY=/(\d+)(?:[.,](\d{1,9}))?/,QY=RegExp(`(?:${ZY.source}H)?(?:${ZY.source}M)?(?:${ZY.source}S)?`),$Y=RegExp(`^([+-])?P(?:(\\d+)Y)?(?:(\\d+)M)?(?:(\\d+)W)?(?:(\\d+)D)?(?:T(?!$)${QY.source})?$`,`i`),eX=864e5,tX=1e6*eX,nX=6e10,rX=1e8*eX,iX=n1(rX),aX=Y.default.unaryMinus(iX),oX=Y.default.add(Y.default.subtract(aX,LJ),DJ),sX=Y.default.subtract(Y.default.add(iX,LJ),DJ),cX=146097*eX,lX=-271821,uX=275760,dX=Date.UTC(1847,0,1),fX=[`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`],pX=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 mX(e){return typeof e==`object`&&!!e||typeof e==`function`}function hX(e){if(typeof e==`bigint`)throw TypeError(`Cannot convert BigInt to number`);return Number(e)}function gX(e){if(typeof e==`symbol`)throw TypeError(`Cannot convert a Symbol value to a String`);return String(e)}function _X(e){let t=hX(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 vX(e,t){let n=_X(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 yX(e){let t=hX(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 bX(e,t){return String(e).padStart(t,`0`)}function xX(e){if(typeof e!=`string`)throw TypeError(`expected a string, not ${String(e)}`);return e}function SX(e,t){if(mX(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 CX=[`era`,`eraYear`,`year`,`month`,`monthCode`,`day`,`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`,`offset`,`timeZone`],wX={era:gX,eraYear:_X,year:_X,month:vX,monthCode:function(e){let t=xX(SX(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:vX,hour:_X,minute:_X,second:_X,millisecond:_X,microsecond:_X,nanosecond:_X,offset:function(e){let t=xX(SX(e));return kQ(t),t},timeZone:sQ},TX={hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0},EX=[[`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`]],DX=Object.fromEntries(EX.map((e=>[e[0],e[1]]))),OX=Object.fromEntries(EX.map((([e,t])=>[t,e]))),kX=EX.map((([,e])=>e)),AX={day:tX,hour:36e11,minute:6e10,second:1e9,millisecond:1e6,microsecond:1e3,nanosecond:1},jX=[`days`,`hours`,`microseconds`,`milliseconds`,`minutes`,`months`,`nanoseconds`,`seconds`,`weeks`,`years`],MX=Intl.DateTimeFormat,NX=new Map;function PX(e){let t=u1(e),n=NX.get(t);return n===void 0&&(n=new MX(`en-us`,{timeZone:t,hour12:!1,era:`short`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`}),NX.set(t,n)),n}function FX(e){return EY(e,GJ)&&!EY(e,QJ,X)}function IX(e){return EY(e,$J,eY,nY,rY,iY,aY,oY,sY,cY)}function LX(e){return EY(e,YJ)}function RX(e){return EY(e,JJ)}function zX(e){return EY(e,qJ)}function BX(e){return EY(e,XJ)}function VX(e){return EY(e,ZJ)}function HX(e){return EY(e,GJ,QJ,X)}function Q(e,t){if(!t(e))throw TypeError(`invalid receiver: method called with the wrong type of this-object`)}function UX(e){if(EY(e,X)||EY(e,QJ))throw TypeError(`with() does not support a calendar or timeZone property`);if(RX(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 WX(e,t){return t===`never`||t===`auto`&&e===`iso8601`?``:`[${t===`critical`?`!`:``}u-ca=${e}]`}function GX(e){let t,n,r=!1;for(KY.lastIndex=0;n=KY.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 KX(e){let t=qY.exec(e);if(!t)throw RangeError(`invalid RFC 9557 string: ${e}`);let n=GX(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 o$(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 qX(e){let t=JY.exec(e),n,r,i,a,o,s,c;if(t){c=GX(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}=KX(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(a$(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}=YX(e);r$(1972,t,n)}catch{try{let{year:t,month:n}=JX(e);r$(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 JX(e){let t=YY.exec(e),n,r,i,a;if(t){i=GX(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}=KX(e),t)throw RangeError(`Z designator not supported for PlainYearMonth`)}return{year:n,month:r,calendar:i,referenceISODay:a}}function YX(e){let t=XY.exec(e),n,r,i,a;if(t){if(i=GX(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}=KX(e),t)throw RangeError(`Z designator not supported for PlainMonthDay`)}return{month:n,day:r,calendar:i,referenceISOYear:a}}var XX=RegExp(`^${RY.source}$`,`i`),ZX=RegExp(`^([+-])([01][0-9]|2[0-3])(?::?([0-5][0-9])?)?$`);function QX(e){let t=f1.test(e)?`Seconds not allowed in offset time zone`:`Invalid time zone`;throw RangeError(`${t}: ${e}`)}function $X(e){return XX.test(e)||QX(e),ZX.test(e)?{offsetMinutes:kQ(e)/6e10}:{tzName:e}}function eZ(e,t,n,r){let i=e,a=t,o=n;switch(r){case`reject`:r$(i,a,o);break;case`constrain`:({year:i,month:a,day:o}=t$(i,a,o))}return{year:i,month:a,day:o}}function tZ(e,t,n,r,i,a,o){let s=e,c=t,l=n,u=r,d=i,f=a;switch(o){case`reject`:a$(s,c,l,u,d,f);break;case`constrain`:s=e$(s,0,23),c=e$(c,0,59),l=e$(l,0,59),u=e$(u,0,999),d=e$(d,0,999),f=e$(f,0,999)}return{hour:s,minute:c,second:l,millisecond:u,microsecond:d,nanosecond:f}}function nZ(e){if(!mX(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<jX.length;r++){let i=jX[r],a=e[i];a!==void 0&&(n=!0,t[i]=yX(a))}if(!n)throw TypeError(`invalid duration-like`);return t}function rZ({years:e,months:t,weeks:n,days:r},i,a,o){return{years:e,months:o??t,weeks:a??n,days:i??r}}function iZ(e,t){return{isoDate:e,time:t}}function aZ(e){return c1(e,`overflow`,[`constrain`,`reject`],`constrain`)}function oZ(e){return c1(e,`disambiguation`,[`compatible`,`earlier`,`later`,`reject`],`compatible`)}function sZ(e,t){return c1(e,`roundingMode`,[`ceil`,`floor`,`expand`,`trunc`,`halfCeil`,`halfFloor`,`halfExpand`,`halfTrunc`,`halfEven`],t)}function cZ(e,t){return c1(e,`offset`,[`prefer`,`use`,`ignore`,`reject`],t)}function lZ(e){return c1(e,`calendarName`,[`auto`,`always`,`never`,`critical`],`auto`)}function uZ(e){let t=e.roundingIncrement;if(t===void 0)return 1;let n=_X(t);if(n<1||n>1e9)throw RangeError(`roundingIncrement must be at least 1 and at most 1e9, not ${t}`);return n}function dZ(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 fZ(e){let t=e.fractionalSecondDigits;if(t===void 0)return`auto`;if(typeof t!=`number`){if(gX(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 pZ(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 mZ=Symbol(`~required~`);function hZ(e,t,n,r,i=[]){let a=[];for(let e=0;e<EX.length;e++){let t=EX[e],r=t[1],i=t[2];n!==`datetime`&&n!==i||a.push(r)}a=a.concat(i);let o=r;o===mZ?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=OX[a[e]];t!==void 0&&s.push(t)}let c=c1(e,t,s,o);if(c===void 0&&r===mZ)throw RangeError(`${t} is required`);return c&&c in DX?DX[c]:c}function gZ(e){let t=e.relativeTo;if(t===void 0)return{};let n,r,i,a,o,s=`option`,c=!1;if(mX(t)){if(HX(t))return{zonedRelativeTo:t};if(LX(t))return{plainRelativeTo:t};if(zX(t))return{plainRelativeTo:RZ(Z(t,qJ).isoDate,Z(t,X))};i=nQ(t);let e=wZ(i,t,[`year`,`month`,`monthCode`,`day`],[`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`,`offset`,`timeZone`],[]);({isoDate:n,time:r}=DZ(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}=KX(xX(t)),e)a=sQ(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=l1(i),n={year:u,month:d,day:f}}return a===void 0?{plainRelativeTo:RZ(n,i)}:{zonedRelativeTo:XZ(FZ(n,r,s,s===`option`?kQ(o):0,a,`compatible`,`reject`,c),a,i)}}function _Z(e){return Z(e,$J)===0?Z(e,eY)===0?Z(e,tY)===0?Z(e,nY)===0?Z(e,rY)===0?Z(e,iY)===0?Z(e,aY)===0?Z(e,oY)===0?Z(e,sY)===0?`nanosecond`:`microsecond`:`millisecond`:`second`:`minute`:`hour`:`day`:`week`:`month`:`year`}function vZ(e,t){return kX.indexOf(e)>kX.indexOf(t)?t:e}function yZ(e){return e===`year`||e===`month`||e===`week`}function bZ(e){return yZ(e)||e===`day`?`date`:`time`}function xZ(e){return jY(`%calendarImpl%`)(e)}function SZ(e){return jY(`%calendarImpl%`)(Z(e,X))}function CZ(e,t,n=`date`){let r=Object.create(null),i=xZ(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 wZ(e,t,n,r,i){let a=xZ(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,wX[n])(r);else if(i!==`partial`){if(i.includes(n))throw TypeError(`required property '${n}' missing or undefined`);s[n]=TX[n]}}if(i===`partial`&&!c)throw TypeError(`no supported properties found`);return s}function TZ(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]=_X(s),r=!0)}if(!r)throw TypeError(`invalid time-like`);return i}function EZ(e,t){if(mX(e)){if(LX(e))return aZ($(t)),RZ(Z(e,KJ),Z(e,X));if(HX(e)){let n=dQ(Z(e,QJ),Z(e,GJ));return aZ($(t)),RZ(n.isoDate,Z(e,X))}if(zX(e))return aZ($(t)),RZ(Z(e,qJ).isoDate,Z(e,X));let n=nQ(e);return RZ(iQ(n,wZ(n,e,[`year`,`month`,`monthCode`,`day`],[],[]),aZ($(t))),n)}let{year:n,month:r,day:i,calendar:a,z:o}=KX(xX(e));if(o)throw RangeError(`Z designator not supported for PlainDate`);return a||=`iso8601`,a=l1(a),aZ($(t)),RZ({year:n,month:r,day:i},a)}function DZ(e,t,n){return iZ(iQ(e,t,n),tZ(t.hour,t.minute,t.second,t.millisecond,t.microsecond,t.nanosecond,n))}function OZ(e,t){let n,r,i;if(mX(e)){if(zX(e))return aZ($(t)),BZ(Z(e,qJ),Z(e,X));if(HX(e)){let n=dQ(Z(e,QJ),Z(e,GJ));return aZ($(t)),BZ(n,Z(e,X))}if(LX(e))return aZ($(t)),BZ(iZ(Z(e,KJ),{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),Z(e,X));i=nQ(e);let a=wZ(i,e,[`year`,`month`,`monthCode`,`day`],[`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`],[]),o=aZ($(t));({isoDate:n,time:r}=DZ(i,a,o))}else{let a,o,s,c;if({year:o,month:s,day:c,time:r,calendar:i,z:a}=KX(xX(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}),o$(o,s,c,r.hour,r.minute,r.second,r.millisecond,r.microsecond,r.nanosecond),i||=`iso8601`,i=l1(i),aZ($(t)),n={year:o,month:s,day:c}}return BZ(iZ(n,r),i)}function kZ(e){let t=jY(`%Temporal.Duration%`);if(IX(e))return new t(Z(e,$J),Z(e,eY),Z(e,tY),Z(e,nY),Z(e,rY),Z(e,iY),Z(e,aY),Z(e,oY),Z(e,sY),Z(e,cY));if(!mX(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=$Y.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:_X(t[2])*n,i=t[3]===void 0?0:_X(t[3])*n,a=t[4]===void 0?0:_X(t[4])*n,o=t[5]===void 0?0:_X(t[5])*n,s=t[6]===void 0?0:_X(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*_X((c+`000000000`).slice(0,9))*n}else if(p=l===void 0?0:_X(l)*n,u!==void 0){if(d??f)throw RangeError(`only the smallest unit can be fractional`);h=60*_X((u+`000000000`).slice(0,9))*n}else m=d===void 0?0:_X(d)*n,f!==void 0&&(h=_X((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),d$(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(jY(`%Temporal.Duration%`))(t,n,r,i,a,o,s,c,l,u)}(xX(e));let n={years:0,months:0,weeks:0,days:0,hours:0,minutes:0,seconds:0,milliseconds:0,microseconds:0,nanoseconds:0},r=nZ(e);for(let e=0;e<jX.length;e++){let t=jX[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 AZ(e){let t;if(mX(e)){if(FX(e)||HX(e))return JZ(Z(e,GJ));t=SX(e)}else t=e;let{year:n,month:r,day:i,time:a,offset:o,z:s}=function(e){let t=KX(e);if(!t.z&&!t.offset)throw RangeError(`Temporal.Instant requires a time zone offset`);return t}(xX(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=XQ(n,r,i,c,l,u,d,f,p-(s?0:kQ(o)));return v$(m.isoDate),JZ(RQ(m))}function jZ(e,t){if(mX(e)){if(VX(e))return aZ($(t)),HZ(Z(e,KJ),Z(e,X));let n;return EY(e,X)?n=Z(e,X):(n=e.calendar,n===void 0&&(n=`iso8601`),n=tQ(n)),HZ(oQ(n,wZ(n,e,[`year`,`month`,`monthCode`,`day`],[],[]),aZ($(t))),n)}let{month:n,day:r,referenceISOYear:i,calendar:a}=YX(xX(e));if(a===void 0&&(a=`iso8601`),a=l1(a),aZ($(t)),a===`iso8601`)return HZ({year:1972,month:n,day:r},a);let o={year:i,month:n,day:r};return i$(o),o=oQ(a,CZ(a,o,`month-day`),`constrain`),HZ(o,a)}function MZ(e,t){let n;if(mX(e)){if(RX(e))return aZ($(t)),WZ(Z(e,JJ));if(zX(e))return aZ($(t)),WZ(Z(e,qJ).time);if(HX(e)){let n=dQ(Z(e,QJ),Z(e,GJ));return aZ($(t)),WZ(n.time)}let{hour:r,minute:i,second:a,millisecond:o,microsecond:s,nanosecond:c}=TZ(e);n=tZ(r,i,a,o,s,c,aZ($(t)))}else n=qX(xX(e)),aZ($(t));return WZ(n)}function NZ(e){return e===void 0?{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}:Z(MZ(e),JJ)}function PZ(e,t){if(mX(e)){if(BX(e))return aZ($(t)),KZ(Z(e,KJ),Z(e,X));let n=nQ(e);return KZ(aQ(n,wZ(n,e,[`year`,`month`,`monthCode`],[],[]),aZ($(t))),n)}let{year:n,month:r,referenceISODay:i,calendar:a}=JX(xX(e));a===void 0&&(a=`iso8601`),a=l1(a),aZ($(t));let o={year:n,month:r,day:i};return u$(o),o=aQ(a,CZ(a,o,`year-month`),`constrain`),KZ(o,a)}function FZ(e,t,n,r,i,a,o,s){if(t===`start-of-day`)return hQ(i,e);let c=iZ(e,t);if(n===`wall`||o===`ignore`)return fQ(i,c,a);if(n===`exact`||o===`use`){let n=XQ(e.year,e.month,e.day,t.hour,t.minute,t.second,t.millisecond,t.microsecond,t.nanosecond-r);v$(n.isoDate);let i=RQ(n);return l$(i),i}v$(e);let l=RQ(c),u=mQ(i,c);for(let e=0;e<u.length;e++){let t=u[e],n=Y.default.toNumber(Y.default.subtract(l,t)),i=G$(n,6e10,`halfExpand`);if(n===r||s&&i===r)return t}if(o===`reject`){let e=uQ(r),t=wQ(c,`iso8601`,`auto`);throw RangeError(`Offset ${e} is invalid for ${t} in ${i}`)}return pQ(u,i,c,a)}function IZ(e,t){let n,r,i,a,o,s,c,l=!1,u=`option`;if(mX(e)){if(HX(e)){let n=$(t);return oZ(n),cZ(n,`reject`),aZ(n),XZ(Z(e,GJ),Z(e,QJ),Z(e,X))}o=nQ(e);let l=wZ(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=oZ(d),c=cZ(d,`reject`);let f=aZ(d);({isoDate:n,time:r}=DZ(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=KX(e);if(!t.tzAnnotation)throw RangeError(`Temporal.ZonedDateTime requires a time zone ID in brackets`);return t}(xX(e))),i=sQ(d),f?u=`exact`:a||(u=`wall`),o||=`iso8601`,o=l1(o),l=!0;let g=$(t);s=oZ(g),c=cZ(g,`reject`),aZ(g),n={year:p,month:m,day:h}}let d=0;return u===`option`&&(d=kQ(a)),XZ(FZ(n,r,u,d,i,s,c,l),i,o)}function LZ(e,t,n){i$(t),TY(e),DY(e,KJ,t),DY(e,X,n),DY(e,YJ,!0)}function RZ(e,t){let n=jY(`%Temporal.PlainDate%`),r=Object.create(n.prototype);return LZ(r,e,t),r}function zZ(e,t,n){s$(t),TY(e),DY(e,qJ,t),DY(e,X,n)}function BZ(e,t){let n=jY(`%Temporal.PlainDateTime%`),r=Object.create(n.prototype);return zZ(r,e,t),r}function VZ(e,t,n){i$(t),TY(e),DY(e,KJ,t),DY(e,X,n),DY(e,ZJ,!0)}function HZ(e,t){let n=jY(`%Temporal.PlainMonthDay%`),r=Object.create(n.prototype);return VZ(r,e,t),r}function UZ(e,t){TY(e),DY(e,JJ,t)}function WZ(e){let t=jY(`%Temporal.PlainTime%`),n=Object.create(t.prototype);return UZ(n,e),n}function GZ(e,t,n){u$(t),TY(e),DY(e,KJ,t),DY(e,X,n),DY(e,XJ,!0)}function KZ(e,t){let n=jY(`%Temporal.PlainYearMonth%`),r=Object.create(n.prototype);return GZ(r,e,t),r}function qZ(e,t){l$(t),TY(e),DY(e,GJ,t)}function JZ(e){let t=jY(`%Temporal.Instant%`),n=Object.create(t.prototype);return qZ(n,e),n}function YZ(e,t,n,r){l$(t),TY(e),DY(e,GJ,t),DY(e,QJ,n),DY(e,X,r)}function XZ(e,t,n=`iso8601`){let r=jY(`%Temporal.ZonedDateTime%`),i=Object.create(r.prototype);return YZ(i,e,t,n),i}function ZZ(e){return CX.filter((t=>e[t]!==void 0))}function QZ(e,t,n){let r=ZZ(n),i=xZ(e).fieldKeysToIgnore(r),a=Object.create(null),o=ZZ(t);for(let e=0;e<CX.length;e++){let s,c=CX[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 $Z(e,t,n,r){let i=xZ(e).dateAdd(t,n,r);return i$(i),i}function eQ(e,t,n,r){return xZ(e).dateUntil(t,n,r)}function tQ(e){if(mX(e)&&EY(e,X))return Z(e,X);let t=xX(e);try{return l1(t)}catch{}let n;try{({calendar:n}=KX(t))}catch{try{({calendar:n}=qX(t))}catch{try{({calendar:n}=JX(t))}catch{({calendar:n}=YX(t))}}}return n||=`iso8601`,l1(n)}function nQ(e){if(EY(e,X))return Z(e,X);let{calendar:t}=e;return t===void 0?`iso8601`:tQ(t)}function rQ(e,t){return l1(e)===l1(t)}function iQ(e,t,n){let r=xZ(e);r.resolveFields(t,`date`);let i=r.dateToISO(t,n);return i$(i),i}function aQ(e,t,n){let r=xZ(e);r.resolveFields(t,`year-month`),t.day=1;let i=r.dateToISO(t,n);return u$(i),i}function oQ(e,t,n){let r=xZ(e);r.resolveFields(t,`month-day`);let i=r.monthDayToISOReferenceDate(t,n);return i$(i),i}function sQ(e){if(mX(e)&&HX(e))return Z(e,QJ);let t=xX(e);if(t===`UTC`)return`UTC`;let{tzName:n,offsetMinutes:r}=function(e){let{tzAnnotation:t,offset:n,z:r}=function(e){if(XX.test(e))return{tzAnnotation:e,offset:void 0,z:!1};try{let{tzAnnotation:t,offset:n,z:r}=KX(e);if(r||t||n)return{tzAnnotation:t,offset:n,z:r}}catch{}QX(e)}(e);return t?$X(t):r?$X(`UTC`):n?$X(n):void 0}(t);if(r!==void 0)return FQ(r);let i=MQ(n);if(!i)throw RangeError(`Unrecognized time zone ${n}`);return i.identifier}function cQ(e,t){if(e===t)return!0;let n=$X(e).offsetMinutes,r=$X(t).offsetMinutes;if(n===void 0&&r===void 0){let n=MQ(t);if(!n)return!1;let r=MQ(e);return!!r&&r.primaryIdentifier===n.primaryIdentifier}return n===r}function lQ(e,t){let n=$X(e).offsetMinutes;return n===void 0?PQ(e,t):6e10*n}function uQ(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}${yQ(r,i,a,o,a===0&&o===0?`minute`:`auto`)}`}function dQ(e,t){let n=lQ(e,t),{isoDate:{year:r,month:i,day:a},time:{hour:o,minute:s,second:c,millisecond:l,microsecond:u,nanosecond:d}}=zQ(t);return XQ(r,i,a,o,s,c,l,u,d+n)}function fQ(e,t,n){return pQ(mQ(e,t),e,t,n)}function pQ(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=RQ(n),o=Y.default.subtract(a,LJ);l$(o);let s=lQ(t,o),c=Y.default.add(a,LJ);l$(c);let l=lQ(t,c)-s;switch(r){case`earlier`:{let e=IY.fromComponents(0,0,0,0,0,-l),r=F$(n.time,e);return mQ(t,iZ(YQ(n.isoDate.year,n.isoDate.month,n.isoDate.day+r.deltaDays),r))[0]}case`compatible`:case`later`:{let e=IY.fromComponents(0,0,0,0,0,l),r=F$(n.time,e),i=mQ(t,iZ(YQ(n.isoDate.year,n.isoDate.month,n.isoDate.day+r.deltaDays),r));return i[i.length-1]}}}function mQ(e,t){if(e===`UTC`)return v$(t.isoDate),[RQ(t)];let n=$X(e).offsetMinutes;if(n!==void 0){let e=XQ(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);v$(e.isoDate);let r=RQ(e);return l$(r),[r]}return v$(t.isoDate),function(e,t){let n=RQ(t),r=Y.default.subtract(n,LJ);Y.default.lessThan(r,aX)&&(r=n);let i=Y.default.add(n,LJ);Y.default.greaterThan(i,iX)&&(i=n);let a=PQ(e,r),o=PQ(e,i);return(a===o?[a]:[a,o]).map((r=>{let i=Y.default.subtract(n,Y.default.BigInt(r));if($$(t,function(e,t){let{epochMilliseconds:n,time:{millisecond:r,microsecond:i,nanosecond:a}}=zQ(t),{year:o,month:s,day:c,hour:l,minute:u,second:d}=HQ(e,n);return XQ(o,s,c,l,u,d,r,i,a)}(e,i))===0)return l$(i),i})).filter((e=>e!==void 0))}(e,t)}function hQ(e,t){let n=iZ(t,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),r=mQ(e,n);if(r.length)return r[0];let i=RQ(n),a=Y.default.subtract(i,LJ);return l$(a),BQ(e,a)}function gQ(e){let t;return t=e<0||e>9999?(e<0?`-`:`+`)+bX(Math.abs(e),6):bX(e,4),t}function _Q(e){return bX(e,2)}function vQ(e,t){let n;if(t===`auto`){if(e===0)return``;n=bX(e,9).replace(/0+$/,``)}else{if(t===0)return``;n=bX(e,9).slice(0,t)}return`.${n}`}function yQ(e,t,n,r,i){let a=`${_Q(e)}:${_Q(t)}`;return i===`minute`||(a+=`:${_Q(n)}`,a+=vQ(r,i)),a}function bQ(e,t,n){let r=t;r===void 0&&(r=`UTC`);let i=Z(e,GJ),a=wQ(dQ(r,i),`iso8601`,n,`never`),o=`Z`;return t!==void 0&&(o=IQ(lQ(r,i))),`${a}${o}`}function xQ(e,t){let n=Z(e,$J),r=Z(e,eY),i=Z(e,tY),a=Z(e,nY),o=Z(e,rY),s=Z(e,iY),c=GQ(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=IY.fromComponents(0,0,Z(e,aY),Z(e,oY),Z(e,sY),Z(e,cY));d.isZero()&&![`second`,`millisecond`,`microsecond`,`nanosecond`].includes(_Z(e))&&t===`auto`||(u+=`${Math.abs(d.sec)}${vQ(Math.abs(d.subsec),t)}S`);let f=`${c<0?`-`:``}P${l}`;return u&&(f=`${f}T${u}`),f}function SQ(e,t=`auto`){let{year:n,month:r,day:i}=Z(e,KJ);return`${gQ(n)}-${_Q(r)}-${_Q(i)}${WX(Z(e,X),t)}`}function CQ({hour:e,minute:t,second:n,millisecond:r,microsecond:i,nanosecond:a},o){return yQ(e,t,n,1e6*r+1e3*i+a,o)}function wQ(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`${gQ(i)}-${_Q(a)}-${_Q(o)}T${yQ(s,c,l,1e6*u+1e3*d+f,n)}${WX(t,r)}`}function TQ(e,t=`auto`){let{year:n,month:r,day:i}=Z(e,KJ),a=`${_Q(r)}-${_Q(i)}`,o=Z(e,X);t!==`always`&&t!==`critical`&&o===`iso8601`||(a=`${gQ(n)}-${a}`);let s=WX(o,t);return s&&(a+=s),a}function EQ(e,t=`auto`){let{year:n,month:r,day:i}=Z(e,KJ),a=`${gQ(n)}-${_Q(r)}`,o=Z(e,X);t!==`always`&&t!==`critical`&&o===`iso8601`||(a+=`-${_Q(i)}`);let s=WX(o,t);return s&&(a+=s),a}function DQ(e,t,n=`auto`,r=`auto`,i=`auto`,a=void 0){let o=Z(e,GJ);if(a){let{unit:e,increment:t,roundingMode:n}=a;o=K$(o,t,e,n)}let s=Z(e,QJ),c=lQ(s,o),l=wQ(dQ(s,o),`iso8601`,t,`never`);return i!==`never`&&(l+=IQ(c)),r!==`never`&&(l+=`[${r===`critical`?`!`:``}${s}]`),l+=WX(Z(e,X),n),l}function OQ(e){return ZX.test(e)}function kQ(e){let t=p1.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 AQ,jQ=Object.assign(Object.create(null),{"/":!0,"-":!0,_:!0});function MQ(e){if(AQ===void 0){let e=Intl.supportedValuesOf?.(`timeZone`);if(e){AQ=new Map;for(let t=0;t<e.length;t++){let n=e[t];AQ.set(u1(n),n)}}else AQ=null}let t=u1(e),n=AQ?.get(t);if(n)return{identifier:n,primaryIdentifier:n};try{n=PX(e).resolvedOptions().timeZone}catch{return}if(t===`antarctica/south_pole`&&(n=`Antarctica/McMurdo`),pX.has(e))throw RangeError(`${e} is a legacy time zone identifier from ICU. Use ${n} instead`);let r=[...t].map(((e,n)=>n===0||jQ[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 NQ(e,t){let{year:n,month:r,day:i,hour:a,minute:o,second:s}=HQ(e,t),c=t%1e3;return c<0&&(c+=1e3),1e6*(LQ({isoDate:{year:n,month:r,day:i},time:{hour:a,minute:o,second:s,millisecond:c}})-t)}function PQ(e,t){return NQ(e,t1(t,`floor`))}function FQ(e){let t=e<0?`-`:`+`,n=Math.abs(e);return`${t}${yQ(Math.floor(n/60),n%60,0,0,`minute`)}`}function IQ(e){return FQ(G$(e,nX,`halfExpand`)/6e10)}function LQ({isoDate:{year:e,month:t,day:n},time:{hour:r,minute:i,second:a,millisecond:o}}){let s=e%400,c=(e-s)/400,l=new Date;return l.setUTCHours(r,i,a,o),l.setUTCFullYear(s,t-1,n),l.getTime()+cX*c}function RQ(e){let t=LQ(e),n=1e3*e.time.microsecond+e.time.nanosecond;return Y.default.add(n1(t),Y.default.BigInt(n))}function zQ(e){let t=t1(e,`trunc`),n=Y.default.toNumber(Y.default.remainder(e,NJ));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 BQ(e,t){if(e===`UTC`)return null;let n=t1(t,`floor`);if(n<dX)return BQ(e,n1(dX));let r=Math.max(n,Date.now())+366*eX*3,i=n,a=NQ(e,i),o=i,s=a;for(;a===s&&i<r;){if(o=i+2*eX*7,o>rX)return null;s=NQ(e,o),a===s&&(i=o)}return a===s?null:n1(m1((t=>NQ(e,t)),i,o,a,s))}function VQ(e,t){if(e===`UTC`)return null;let n=t1(t,`ceil`),r=Date.now(),i=r+366*eX*3;if(n>i){let t=VQ(e,n1(i));if(t===null||Y.default.lessThan(t,n1(r)))return t}if(e===`Africa/Casablanca`||e===`Africa/El_Aaiun`){let t=Date.UTC(2088,0,1);if(t<n)return VQ(e,n1(t))}let a=n-1;if(a<dX)return null;let o=NQ(e,a),s=a,c=o;for(;o===c&&a>dX;){if(s=a-2*eX*7,s<dX)return null;c=NQ(e,s),o===c&&(a=s)}return o===c?null:n1(m1((t=>NQ(e,t)),s,a,c,o))}function HQ(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}}(PX(e).format(t))}function UQ(e){return e!==void 0&&!(e%4!=0||e%100==0&&e%400!=0)}function WQ(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]}[UQ(e)?`leapyear`:`standard`][t-1]}function GQ(e){let t=[Z(e,$J),Z(e,eY),Z(e,tY),Z(e,nY),Z(e,rY),Z(e,iY),Z(e,aY),Z(e,oY),Z(e,sY),Z(e,cY)];for(let e=0;e<t.length;e++){let n=t[e];if(n!==0)return n<0?-1:1}return 0}function KQ(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 qQ(e){let t=KQ(e.date);return t===0?e.time.sign():t}function JQ(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 YQ(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}=JQ(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=UQ(c)?366:365,a<-s;)--r,--c,a+=s;for(c+=1;s=UQ(c)?366:365,a>s;)r+=1,c+=1,a-=s;for(;a<1;)({year:r,month:i}=JQ(r,i-1)),a+=WQ(r,i);for(;a>WQ(r,i);)a-=WQ(r,i),{year:r,month:i}=JQ(r,i+1);return{year:r,month:i,day:a}}function XQ(e,t,n,r,i,a,o,s,c){let l=ZQ(r,i,a,o,s,c);return iZ(YQ(e,t,n+l.deltaDays),l)}function ZQ(e,t,n,r,i,a){let o,s=e,c=t,l=n,u=r,d=i,f=a;({div:o,mod:f}=MY(f,3)),d+=o,f<0&&(--d,f+=1e3),{div:o,mod:d}=MY(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 QQ(e,t){let n=rZ(e,0);if(KQ(n)===0)return e.days;let r=Z(t,KJ),i=$Z(Z(t,X),r,n,`constrain`),a=_$(r.year,r.month-1,r.day),o=_$(i.year,i.month-1,i.day)-a;return e.days+o}function $Q(e){return new(jY(`%Temporal.Duration%`))(-Z(e,$J),-Z(e,eY),-Z(e,tY),-Z(e,nY),-Z(e,rY),-Z(e,iY),-Z(e,aY),-Z(e,oY),-Z(e,sY),-Z(e,cY))}function e$(e,t,n){return Math.min(n,Math.max(t,e))}function t$(e,t,n){let r=e$(t,1,12);return{year:e,month:r,day:e$(n,1,WQ(e,r))}}function n$(e,t,n){if(e<t||e>n)throw RangeError(`value out of range: ${t} <= ${e} <= ${n}`)}function r$(e,t,n){n$(t,1,12),n$(n,1,WQ(e,t))}function i$(e){s$(iZ(e,{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}))}function a$(e,t,n,r,i,a){n$(e,0,23),n$(t,0,59),n$(n,0,59),n$(r,0,999),n$(i,0,999),n$(a,0,999)}function o$(e,t,n,r,i,a,o,s,c){r$(e,t,n),a$(r,i,a,o,s,c)}function s$(e){let t=RQ(e);(Y.default.lessThan(t,oX)||Y.default.greaterThan(t,sX))&&l$(t)}function c$(e){RQ(e)}function l$(e){if(Y.default.lessThan(e,aX)||Y.default.greaterThan(e,iX))throw RangeError(`date/time value is outside of supported range`)}function u$({year:e,month:t}){n$(e,lX,uX),e===lX?n$(t,4,12):e===uX&&n$(t,1,9)}function d$(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=MY(s,3),p=MY(c,6),m=MY(l,9),h=MY(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 f$(e){return{date:{years:Z(e,$J),months:Z(e,eY),weeks:Z(e,tY),days:Z(e,nY)},time:IY.fromComponents(Z(e,rY),Z(e,iY),Z(e,aY),Z(e,oY),Z(e,sY),Z(e,cY))}}function p$(e){let t=IY.fromComponents(Z(e,rY),Z(e,iY),Z(e,aY),Z(e,oY),Z(e,sY),Z(e,cY)).add24HourDays(Z(e,nY));return{date:{years:Z(e,$J),months:Z(e,eY),weeks:Z(e,tY),days:0},time:t}}function m$(e){let t=p$(e),n=Math.trunc(t.time.sec/86400);return d$(t.date.years,t.date.months,t.date.weeks,n,0,0,0,0,0,0),{...t.date,days:n}}function h$(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=NY(o,3,Math.trunc(i/1e3)),i%=1e3,o=0;break;case`microsecond`:i=NY(o,6,Math.trunc(r/1e3)),r%=1e3,o=0;break;case`nanosecond`:r=NY(o,9,r),o=0}return new(jY(`%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 g$(e,t){return KQ(e),t.sign(),{date:e,time:t}}function _$(e,t,n){return LQ({isoDate:{year:e,month:t+1,day:n},time:{hour:0,minute:0,second:0,millisecond:0}})/eX}function v$({year:e,month:t,day:n}){if(Math.abs(_$(e,t-1,n))>1e8)throw RangeError(`date/time value is outside the supported range`)}function y$(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 IY.fromComponents(n,r,i,a,o,s)}function b$(e,t,n,r,i){let a=IY.fromEpochNsDiff(t,e);return a=Y$(a,n,r,i),g$({years:0,months:0,weeks:0,days:0},a)}function x$(e,t,n,r){c$(e),c$(t);let i=y$(e.time,t.time),a=i.sign(),o=Z$(e.isoDate,t.isoDate),s=t.isoDate;o===a&&(s=YQ(s.year,s.month,s.day+a),i=i.add24HourDays(-a));let c=vZ(`day`,r),l=eQ(n,e.isoDate,s,c);return r!==c&&(i=i.add24HourDays(l.days),l.days=0),g$(l,i)}function S$(e,t,n,r,i){let a=Y.default.subtract(t,e);if(Y.default.equal(a,EJ))return{date:{years:0,months:0,weeks:0,days:0},time:IY.ZERO};let o=Y.default.lessThan(a,EJ)?-1:1,s=dQ(n,e),c=dQ(n,t),l,u=0,d=o===1?2:1,f=y$(s.time,c.time);for(f.sign()===-o&&u++;u<=d;u++){l=iZ(YQ(c.isoDate.year,c.isoDate.month,c.isoDate.day-u*o),s.time);let e=fQ(n,l,`compatible`);if(f=IY.fromEpochNsDiff(t,e),f.sign()!==-o)break}let p=vZ(`day`,i);return g$(eQ(r,s.isoDate,l.isoDate,p),f)}function C$(e,t,n,r,i,a,o,s,c){let l,u,d,f,p=t;switch(s){case`year`:{let t=G$(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=G$(p.date.months,o,`trunc`);l=t,u=t+o*e,d=rZ(p.date,0,0,l),f=rZ(p.date,0,0,u);break}case`week`:{let t=rZ(p.date,0,0),n=$Z(a,r.isoDate,t,`constrain`),i=eQ(a,n,YQ(n.year,n.month,n.day+p.date.days),`week`),s=G$(p.date.weeks+i.weeks,o,`trunc`);l=s,u=s+o*e,d=rZ(p.date,0,l),f=rZ(p.date,0,u);break}case`day`:{let t=G$(p.date.days,o,`trunc`);l=t,u=t+o*e,d=rZ(p.date,l),f=rZ(p.date,u);break}}let m=$Z(a,r.isoDate,d,`constrain`),h=$Z(a,r.isoDate,f,`constrain`),g,_,v=iZ(m,r.time),y=iZ(h,r.time);i?(g=fQ(i,v,`compatible`),_=fQ(i,y,`compatible`)):(g=RQ(v),_=RQ(y));let b=IY.fromEpochNsDiff(n,g),x=IY.fromEpochNsDiff(_,g),S=PY(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)?FY(Math.abs(l),Math.abs(u),C,w,S):Math.abs(u),E=new IY(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:IY.ZERO},{nudgeResult:{duration:p,nudgedEpochNs:D?_:g,didExpandCalendarUnit:D},total:E}}function w$(e,t,n,r,i,a,o,s,c){let l=e,u=yZ(s)||r&&s===`day`,d=qQ(l)<0?-1:1,f;return u?{nudgeResult:f}=C$(d,l,t,n,r,i,o,s,c):f=r?function(e,t,n,r,i,a,o,s){let c=t,l=$Z(i,n.isoDate,c.date,`constrain`),u=iZ(l,n.time),d=iZ(YQ(l.year,l.month,l.day+e),n.time),f=fQ(r,u,`compatible`),p=fQ(r,d,`compatible`),m=IY.fromEpochNsDiff(p,f);if(m.sign()!==e)throw RangeError(`time zone returned inconsistent Instants`);let h=Y.default.BigInt(AX[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:g$(rZ(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*AX[i]),a),l=c.subtract(s),{quotient:u}=s.divmod(tX),{quotient:d}=c.divmod(tX),f=Math.sign(d-u)===s.sign(),p=l.addToEpochNs(t),m=0,h=c;return bZ(n)===`date`&&(m=d,h=c.add(IY.fromComponents(24*-d,0,0,0,0,0))),{duration:{date:rZ(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=kX.indexOf(o);for(let t=kX.indexOf(s)-1;t>=l;t--){let s=kX[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=rZ(c.date,0,0,t);break}case`week`:{let t=c.date.weeks+e;l=rZ(c.date,0,t);break}}let u=iZ($Z(a,r.isoDate,l,`constrain`),r.time),d;if(d=i?fQ(i,u,`compatible`):RQ(u),VJ(n,d)===-e)break;c={date:l,time:IY.ZERO}}return c}(d,l,f.nudgedEpochNs,n,r,i,a,vZ(s,`day`))),l}function T$(e,t,n,r,i,a){return yZ(a)||r&&a===`day`?C$(qQ(e)<0?-1:1,e,t,n,r,i,1,a,`trunc`).total:X$(e.time.add24HourDays(e.date.days),a)}function E$(e,t,n,r,i,a,o){if($$(e,t)==0)return{date:{years:0,months:0,weeks:0,days:0},time:IY.ZERO};s$(e),s$(t);let s=x$(e,t,n,r);return a===`nanosecond`&&i===1?s:w$(s,RQ(t),e,null,n,r,i,a,o)}function D$(e,t,n,r,i,a,o,s){if(bZ(i)===`time`)return b$(e,t,a,o,s);let c=S$(e,t,n,r,i);return o===`nanosecond`&&a===1?c:w$(c,t,dQ(n,e),n,r,i,a,o,s)}function O$(e,t,n,r,i,a){let o=EX.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=hZ(t,`largestUnit`,n,`auto`);if(r.includes(s))throw RangeError(`largestUnit must be one of ${o.join(`, `)}, not ${s}`);let c=uZ(t),l=sZ(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=hZ(t,`smallestUnit`,n,i);if(r.includes(u))throw RangeError(`smallestUnit must be one of ${o.join(`, `)}, not ${u}`);let d=vZ(a,u);if(s===`auto`&&(s=d),vZ(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&&dZ(c,f,!1),{largestUnit:s,roundingIncrement:c,roundingMode:l,smallestUnit:u}}function k$(e,t,n,r){let i=AZ(n),a=O$(e,$(r),`time`,[],`nanosecond`,`second`),o=h$(b$(Z(t,GJ),Z(i,GJ),a.roundingIncrement,a.smallestUnit,a.roundingMode),a.largestUnit);return e===`since`&&(o=$Q(o)),o}function A$(e,t,n,r){let i=EZ(n),a=Z(t,X),o=Z(i,X);if(!rQ(a,o))throw RangeError(`cannot compute difference between dates of ${a} and ${o} calendars`);let s=O$(e,$(r),`date`,[],`day`,`day`),c=jY(`%Temporal.Duration%`),l=Z(t,KJ),u=Z(i,KJ);if(Z$(l,u)===0)return new c;let d={date:eQ(a,l,u,s.largestUnit),time:IY.ZERO};if(s.smallestUnit!==`day`||s.roundingIncrement!==1){let e=iZ(l,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});d=w$(d,RQ(iZ(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=h$(d,`day`);return e===`since`&&(f=$Q(f)),f}function j$(e,t,n,r){let i=OZ(n),a=Z(t,X),o=Z(i,X);if(!rQ(a,o))throw RangeError(`cannot compute difference between dates of ${a} and ${o} calendars`);let s=O$(e,$(r),`datetime`,[],`nanosecond`,`day`),c=jY(`%Temporal.Duration%`),l=Z(t,qJ),u=Z(i,qJ);if($$(l,u)===0)return new c;let d=h$(E$(l,u,a,s.largestUnit,s.roundingIncrement,s.smallestUnit,s.roundingMode),s.largestUnit);return e===`since`&&(d=$Q(d)),d}function M$(e,t,n,r){let i=MZ(n),a=O$(e,$(r),`time`,[],`nanosecond`,`hour`),o=y$(Z(t,JJ),Z(i,JJ));o=Y$(o,a.roundingIncrement,a.smallestUnit,a.roundingMode);let s=h$(g$({years:0,months:0,weeks:0,days:0},o),a.largestUnit);return e===`since`&&(s=$Q(s)),s}function N$(e,t,n,r){let i=PZ(n),a=Z(t,X),o=Z(i,X);if(!rQ(a,o))throw RangeError(`cannot compute difference between months of ${a} and ${o} calendars`);let s=O$(e,$(r),`date`,[`week`,`day`],`month`,`year`),c=jY(`%Temporal.Duration%`);if(Z$(Z(t,KJ),Z(i,KJ))==0)return new c;let l=CZ(a,Z(t,KJ),`year-month`);l.day=1;let u=iQ(a,l,`constrain`),d=CZ(a,Z(i,KJ),`year-month`);d.day=1;let f=iQ(a,d,`constrain`),p={date:rZ(eQ(a,u,f,s.largestUnit),0,0),time:IY.ZERO};if(s.smallestUnit!==`month`||s.roundingIncrement!==1){let e=iZ(u,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});p=w$(p,RQ(iZ(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=h$(p,`day`);return e===`since`&&(m=$Q(m)),m}function P$(e,t,n,r){let i=IZ(n),a=Z(t,X),o=Z(i,X);if(!rQ(a,o))throw RangeError(`cannot compute difference between dates of ${a} and ${o} calendars`);let s=O$(e,$(r),`datetime`,[],`nanosecond`,`hour`),c=Z(t,GJ),l=Z(i,GJ),u=jY(`%Temporal.Duration%`),d;if(bZ(s.largestUnit)!==`date`)d=h$(b$(c,l,s.roundingIncrement,s.smallestUnit,s.roundingMode),s.largestUnit);else{let e=Z(t,QJ);if(!cQ(e,Z(i,QJ)))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=h$(D$(c,l,e,a,s.largestUnit,s.roundingIncrement,s.smallestUnit,s.roundingMode),`hour`)}return e===`since`&&(d=$Q(d)),d}function F$({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,ZQ(e,t,s,r,i,c)}function I$(e,t){let n=t.addToEpochNs(e);return l$(n),n}function L$(e,t,n,r,i=`constrain`){if(KQ(r.date)===0)return I$(e,r.time);let a=dQ(t,e);return I$(fQ(t,iZ($Z(n,a.isoDate,r.date,i),a.time),`compatible`),r.time)}function R$(e,t,n){let r=kZ(n);e===`subtract`&&(r=$Q(r));let i=vZ(_Z(t),_Z(r));if(yZ(i))throw RangeError(`For years, months, or weeks arithmetic, use date arithmetic relative to a starting point`);let a=p$(t),o=p$(r);return h$(g$({years:0,months:0,weeks:0,days:0},a.time.add(o.time)),i)}function z$(e,t,n){let r=kZ(n);e===`subtract`&&(r=$Q(r));let i=_Z(r);if(bZ(i)===`date`)throw RangeError(`Duration field ${i} not supported by Temporal.Instant. Try Temporal.ZonedDateTime instead.`);let a=p$(r);return JZ(I$(Z(t,GJ),a.time))}function B$(e,t,n,r){let i=Z(t,X),a=kZ(n);e===`subtract`&&(a=$Q(a));let o=m$(a),s=aZ($(r));return RZ($Z(i,Z(t,KJ),o,s),i)}function V$(e,t,n,r){let i=kZ(n);e===`subtract`&&(i=$Q(i));let a=aZ($(r)),o=Z(t,X),s=p$(i),c=Z(t,qJ),l=F$(c.time,s.time),u=rZ(s.date,l.deltaDays);return d$(u.years,u.months,u.weeks,u.days,0,0,0,0,0,0),BZ(iZ($Z(o,c.isoDate,u,a),l),o)}function H$(e,t,n){let r=kZ(n);e===`subtract`&&(r=$Q(r));let i=p$(r),{hour:a,minute:o,second:s,millisecond:c,microsecond:l,nanosecond:u}=F$(Z(t,JJ),i.time);return WZ(tZ(a,o,s,c,l,u,`reject`))}function U$(e,t,n,r){let i=kZ(n);e===`subtract`&&(i=$Q(i));let a=aZ($(r)),o=GQ(i),s=Z(t,X),c=CZ(s,Z(t,KJ),`year-month`);c.day=1;let l=iQ(s,c,`constrain`);if(o<0){let e=$Z(s,l,{months:1},`constrain`);l=YQ(e.year,e.month,e.day-1)}let u=m$(i);return i$(l),KZ(aQ(s,CZ(s,$Z(s,l,u,a),`year-month`),a),s)}function W$(e,t,n,r){let i=kZ(n);e===`subtract`&&(i=$Q(i));let a=aZ($(r)),o=Z(t,QJ),s=Z(t,X),c=f$(i);return XZ(L$(Z(t,GJ),o,s,c,a),o,s)}function G$(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=o1(Math.abs(2*i)-t),l=o%2==0,u=PY(n,a),d=i===0?o:FY(o,s,c,l,u);return t*(a===`positive`?d:-d)}function K$(e,t,n,r){let i=AX[n]*t;return function(e,t,n){let r=RJ(e),i=RJ(t),a=Y.default.divide(r,i),o=Y.default.remainder(r,i),s=PY(n,`positive`),c,l;Y.default.lessThan(r,EJ)?(c=Y.default.subtract(a,DJ),l=a):(c=a,l=Y.default.add(a,DJ));let u=VJ(BJ(Y.default.multiply(o,OJ)),i)*(Y.default.lessThan(r,EJ)?-1:1)+0,d=Y.default.equal(o,EJ)?a:FY(c,l,u,zJ(c),s);return Y.default.multiply(d,i)}(e,Y.default.BigInt(i),r)}function q$(e,t,n,r){c$(e);let{year:i,month:a,day:o}=e.isoDate,s=J$(e.time,t,n,r);return iZ(YQ(i,a,o+s.deltaDays),s)}function J$({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=AX[s],d=G$(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 ZQ(d,0,0,0,0,0);case`minute`:return ZQ(e,d,0,0,0,0);case`second`:return ZQ(e,t,d,0,0,0);case`millisecond`:return ZQ(e,t,n,d,0,0);case`microsecond`:return ZQ(e,t,n,r,d,0);case`nanosecond`:return ZQ(e,t,n,r,i,d);default:throw Error(`Invalid unit ${s}`)}}function Y$(e,t,n,r){let i=AX[n];return e.round(Y.default.BigInt(i*t),r)}function X$(e,t){let n=AX[t];return e.fdiv(Y.default.BigInt(n))}function Z$(e,t){return e.year===t.year?e.month===t.month?e.day===t.day?0:o1(e.day-t.day):o1(e.month-t.month):o1(e.year-t.year)}function Q$(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:o1(e.nanosecond-t.nanosecond):o1(e.microsecond-t.microsecond):o1(e.millisecond-t.millisecond):o1(e.second-t.second):o1(e.minute-t.minute):o1(e.hour-t.hour)}function $$(e,t){let n=Z$(e.isoDate,t.isoDate);return n===0?Q$(e.time,t.time):n}function e1(e){let t=r1(e);return globalThis.BigInt===void 0?t:globalThis.BigInt(t.toString(10))}function t1(e,t){let{quotient:n,remainder:r}=HJ(RJ(e),NJ),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 n1(e){if(!Number.isInteger(e))throw RangeError(`epoch milliseconds must be an integer`);return Y.default.multiply(Y.default.BigInt(e),NJ)}function r1(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 i1=(()=>{let e=Y.default.BigInt(Date.now()%1e6);return()=>{let t=Date.now(),n=Y.default.BigInt(t),r=Y.default.add(n1(t),e);return e=Y.default.remainder(n,NJ),Y.default.greaterThan(r,iX)?iX:Y.default.lessThan(r,aX)?aX:r}})();function a1(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}function o1(e){return e<0?-1:e>0?1:e}function $(e){if(e===void 0)return Object.create(null);if(mX(e)&&e!==null)return e;throw TypeError(`Options parameter must be an object, not `+(e===null?`null`:typeof e))}function s1(e,t){let n=Object.create(null);return n[e]=t,n}function c1(e,t,n,r){let i=e[t];if(i!==void 0){if(i=gX(i),!n.includes(i))throw RangeError(`${t} must be one of ${n.join(`, `)}, not ${i}`);return i}if(r===mZ)throw RangeError(`${t} option is required`);return r}function l1(e){let t=u1(e);if(!fX.includes(u1(t)))throw RangeError(`invalid calendar identifier ${t}`);switch(t){case`ethiopic-amete-alem`:return`ethioaa`;case`islamicc`:return`islamic-civil`}return t}function u1(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 d1(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 f1=RegExp(`^${WY.source}$`),p1=RegExp(`^([+-])([01][0-9]|2[0-3])(?::?([0-5][0-9])(?::?([0-5][0-9])(?:[.,](\\d{1,9}))?)?)?$`);function m1(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 h1(e){return[...e]}function g1(e,t){if(e!==`gregory`&&e!==`iso8601`)return;let n=v1[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 _1(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 v1={};function y1(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 b1(e,t=!1){return`M${`${e}`.padStart(2,`0`)}${t?`L`:``}`}function x1(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`&&n$(r,1,n),t===`constrain`&&(r=e$(r,1,n)),i=b1(r)}else{let e=y1(i);if(i!==b1(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}}v1.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,x1(e))},dateToISO:(e,t)=>eZ(e.year,e.month,e.day,t),monthDayToISOReferenceDate(e,t){let{month:n,day:r}=eZ(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 h1(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}=JQ(o,s),{year:o,month:s,day:c}=eZ(o,s,c,a),c+=i+7*r,YQ(o,s,c)},dateUntil(e,t,n){let r=-Z$(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);!_1(r,e.year+s,e.month,e.day,t);)a=s,s+=r;let c=r;for(i=JQ(e.year+a,e.month+c);!_1(r,i.year,i.month,e.day,t);)o=c,c+=r,i=JQ(i.year,i.month+r);n===`month`&&(o+=12*a,a=0)}i=JQ(e.year+a,e.month+o);let s=t$(i.year,i.month,e.day),c=0,l=_$(t.year,t.month-1,t.day)-_$(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=b1(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+=WQ(e,n);i.dayOfYear=r}return r.weekOfYear&&(i.weekOfYear=g1(`iso8601`,{year:e,month:t,day:n})),r.daysInMonth&&(i.daysInMonth=WQ(e,t)),(r.daysInYear||r.inLeapYear)&&(i.inLeapYear=UQ(e),i.daysInYear=i.inLeapYear?366:365),i},getFirstDayOfWeek:()=>1,getMinimalDaysInFirstWeek:()=>4};var S1=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 C1({isoYear:e,isoMonth:t,isoDay:n}){return`${gQ(e)}-${_Q(t)}-${_Q(n)}T00:00Z`}function w1(e,t){return{years:e.year-t.year,months:e.month-t.month,days:e.day-t.day}}S1.objectMap=new WeakMap,S1.MAX_CACHE_ENTRIES=1e3;var T1=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=C1({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}=x1(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`?(n$(i,1,r),n$(a,1,this.maximumMonthLength(e))):(i=e$(i,1,r),a=e$(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=w1(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=w1(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=w1(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:o1(e.day-t.day):o1(e.month-t.month):o1(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 YQ(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 _$(i.year,i.month-1,i.day)-_$(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(){}},E1=class extends T1{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?b1(5,!0):b1(t<6?t:t-1):b1(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=y1(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`?(n$(a,1,this.monthsInYear({year:i})),n$(s,1,this.maximumMonthLength({year:i,month:a}))):(a=e$(a,1,this.monthsInYear({year:i})),s=e$(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}}},D1=class extends T1{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}}},O1=class extends D1{constructor(){super(...arguments),this.id=`islamic`}},k1=class extends D1{constructor(){super(...arguments),this.id=`islamic-umalqura`}},A1=class extends D1{constructor(){super(...arguments),this.id=`islamic-tbla`}},j1=class extends D1{constructor(){super(...arguments),this.id=`islamic-civil`}},M1=class extends D1{constructor(){super(...arguments),this.id=`islamic-rgsa`}},N1=class extends D1{constructor(){super(...arguments),this.id=`islamicc`}},P1=class extends T1{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 y1(e)<=6?31:30}estimateIsoDate(e){let{year:t}=this.adjustCalendarDate(e);return{year:t+621,month:1,day:1}}},F1=class extends T1{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 I1(e.year+78)}monthsInYear(){return 12}minimumMonthLength(e){return this.getMonthInfo(e).length}maximumMonthLength(e){return this.getMonthInfo(e).length}maxLengthOfMonthCodeInAnyYear(e){let t=y1(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 YQ(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 I1(e){return e%4==0&&(e%100!=0||e%400==0)}var L1=class extends T1{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 I1(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][y1(e)-1]}estimateIsoDate(e){let t=this.adjustCalendarDate(e);return eZ(t.year+this.isoEpoch.year,t.month+this.isoEpoch.month,t.day+this.isoEpoch.day,`constrain`)}},R1=class extends T1{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 I1(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][y1(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:y1(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 eZ(t+i.isoEpoch.year-+!i.hasYearZero,n,r,`constrain`)}},z1=class extends R1{constructor(e,t){super(e,t)}isoToCalendarDate(e){let{year:t,month:n,day:r}=e,i=b1(n),a=t-this.anchorEra.isoEpoch.year+1;return this.completeEraYear({year:a,month:n,monthCode:i,day:r})}},B1={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},V1=class extends L1{constructor(e,t){super(e,t),this.inLeapYear=B1.inLeapYear,this.monthsInYear=B1.monthsInYear,this.minimumMonthLength=B1.minimumMonthLength,this.maximumMonthLength=B1.maximumMonthLength,this.maxLengthOfMonthCodeInAnyYear=B1.maxLengthOfMonthCodeInAnyYear}},H1=class extends R1{constructor(e,t){super(e,t),this.inLeapYear=B1.inLeapYear,this.monthsInYear=B1.monthsInYear,this.minimumMonthLength=B1.minimumMonthLength,this.maximumMonthLength=B1.maximumMonthLength,this.maxLengthOfMonthCodeInAnyYear=B1.maxLengthOfMonthCodeInAnyYear}},U1=class extends V1{constructor(){super(`ethioaa`,{year:-5492,month:7,day:17})}},W1=class extends H1{constructor(){super(`coptic`,[{code:`coptic`,isoEpoch:{year:284,month:8,day:29}},{code:`coptic-inverse`,reverseOf:`coptic`}])}},G1=class extends H1{constructor(){super(`ethiopic`,[{code:`ethioaa`,names:[`ethiopic-amete-alem`,`mundi`],isoEpoch:{year:-5492,month:7,day:17}},{code:`ethiopic`,names:[`incar`],isoEpoch:{year:8,month:8,day:27},anchorEpoch:{year:5501}}])}},K1=class extends z1{constructor(){super(`roc`,[{code:`roc`,names:[`minguo`],isoEpoch:{year:1912,month:1,day:1}},{code:`roc-inverse`,names:[`before-roc`],reverseOf:`roc`}])}},q1=class extends L1{constructor(){super(`buddhist`,{year:-543,month:1,day:1})}},J1=class extends z1{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}},Y1=class extends z1{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}}},X1=class extends T1{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=C1({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=b1(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=b1(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`?(n$(a,1,o),n$(s,1,this.maximumMonthLength())):(a=e$(a,1,o),s=e$(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=b1(+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}}},Z1=class extends X1{constructor(){super(...arguments),this.id=`chinese`}},Q1=class extends X1{constructor(){super(...arguments),this.id=`dangi`}},$1=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 S1;x1(e,void 0,this.helper.monthsInYear({year:e.year??1972},t))}}dateToISO(e,t){let n=new S1,r=this.helper.calendarToIsoDate(e,t,n);return n.setObject(r),r}monthDayToISOReferenceDate(e,t){let n=new S1,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 h1(t)}dateAdd(e,{years:t,months:n,weeks:r,days:i},a){let o=S1.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 S1.getCacheForObject(l)||new S1(o).setObject(l),l}dateUntil(e,t,n){let r=S1.getCacheForObject(e),i=S1.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=S1.getCacheForObject(e),r=this.helper.isoToCalendarDate(e,n);if(t.dayOfWeek&&(r.dayOfWeek=v1.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=g1(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[E1,P1,G1,U1,W1,Z1,Q1,K1,F1,q1,J1,Y1,O1,k1,A1,j1,M1,N1]){let t=new e;v1[t.id]=new $1(t)}AY(`calendarImpl`,(function(e){return v1[e]}));var e0=Intl.DateTimeFormat;function t0(e,t){let n=Z(e,t);return typeof n==`function`&&(n=new e0(Z(e,yY),n(Z(e,bY))),function(e,t,n){let r=CY(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 n0(e){return EY(e,hY)}var r0=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 e0(t,i),o=a.resolvedOptions();if(TY(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,DY(e,bY,t)}else DY(e,bY,i);DY(e,yY,o.locale),DY(e,hY,a),DY(e,gY,o.timeZone),DY(e,vY,o.calendar),DY(e,lY,m0),DY(e,uY,f0),DY(e,dY,p0),DY(e,fY,d0),DY(e,pY,h0),DY(e,mY,g0);let s=r?i.timeZone:void 0;if(s===void 0)DY(e,_Y,o.timeZone);else{let t=gX(s);if(t.startsWith(`−`))throw RangeError(`Unicode minus (U+2212) is not supported in time zone offsets`);DY(e,_Y,sQ(t))}})(this,e,t)}get format(){Q(this,n0);let e=o0.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,n0),c0.call(this,e,t)}formatToParts(e,...t){return Q(this,n0),s0.call(this,e,...t)}formatRangeToParts(e,t){return Q(this,n0),l0.call(this,e,t)}resolvedOptions(){return Q(this,n0),a0.call(this)}};`formatToParts`in e0.prototype||delete r0.prototype.formatToParts,`formatRangeToParts`in e0.prototype||delete r0.prototype.formatRangeToParts;var i0=function(e=void 0,t=void 0){return new r0(e,t)};function a0(){let e=Z(this,hY).resolvedOptions();return e.timeZone=Z(this,_Y),e}function o0(e,...t){let n,r,i=C0(e,this);return i.formatter?(n=i.formatter,r=[t1(i.epochNs,`floor`)]):(n=Z(this,hY),r=[e,...t]),n.format(...r)}function s0(e,...t){let n,r,i=C0(e,this);return i.formatter?(n=i.formatter,r=[t1(i.epochNs,`floor`)]):(n=Z(this,hY),r=[e,...t]),n.formatToParts(...r)}function c0(e,t){if(e===void 0||t===void 0)throw TypeError(`Intl.DateTimeFormat.formatRange requires two values`);let n=x0(e),r=x0(t),i,a=[n,r];if(b0(n)!==b0(r))throw TypeError(`Intl.DateTimeFormat.formatRange accepts two values of the same type`);if(b0(n)){if(!S0(n,r))throw TypeError(`Intl.DateTimeFormat.formatRange accepts two values of the same type`);let{epochNs:e,formatter:t}=C0(n,this),{epochNs:o,formatter:s}=C0(r,this);t&&(i=t,a=[t1(e,`floor`),t1(o,`floor`)])}return i||=Z(this,hY),i.formatRange(...a)}function l0(e,t){if(e===void 0||t===void 0)throw TypeError(`Intl.DateTimeFormat.formatRange requires two values`);let n=x0(e),r=x0(t),i,a=[n,r];if(b0(n)!==b0(r))throw TypeError(`Intl.DateTimeFormat.formatRangeToParts accepts two values of the same type`);if(b0(n)){if(!S0(n,r))throw TypeError(`Intl.DateTimeFormat.formatRangeToParts accepts two values of the same type`);let{epochNs:e,formatter:t}=C0(n,this),{epochNs:o,formatter:s}=C0(r,this);t&&(i=t,a=[t1(e,`floor`),t1(o,`floor`)])}return i||=Z(this,hY),i.formatRangeToParts(...a)}function u0(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 d0(e){let t=u0(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`})),!v0(t)){if(y0(e))throw TypeError(`cannot format Temporal.PlainTime with options [${Object.keys(e)}]`);Object.assign(t,{hour:`numeric`,minute:`numeric`,second:`numeric`})}return t}function f0(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=u0(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(y0(e))throw TypeError(`cannot format PlainYearMonth with options [${Object.keys(e)}]`);Object.assign(n,{year:`numeric`,month:`numeric`})}return n}function p0(e){let t={short:{month:`numeric`,day:`numeric`},medium:{month:`short`,day:`numeric`},long:{month:`long`,day:`numeric`},full:{month:`long`,day:`numeric`}},n=u0(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(y0(e))throw TypeError(`cannot format PlainMonthDay with options [${Object.keys(e)}]`);Object.assign(n,{month:`numeric`,day:`numeric`})}return n}function m0(e){let t=u0(e,{hour:!1,minute:!1,second:!1,dayPeriod:!1,timeZoneName:!1,timeStyle:!1});if(!_0(t)){if(y0(e))throw TypeError(`cannot format PlainDate with options [${Object.keys(e)}]`);Object.assign(t,{year:`numeric`,month:`numeric`,day:`numeric`})}return t}function h0(e){let t=u0(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),!v0(t)&&!_0(t)){if(y0(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 g0(e){let t=e;return v0(t)||_0(t)||(t=Object.assign({},t,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`})),t}function _0(e){return`year`in e||`month`in e||`day`in e||`weekday`in e||`dateStyle`in e||`era`in e}function v0(e){return`hour`in e||`minute`in e||`second`in e||`timeStyle`in e||`dayPeriod`in e||`fractionalSecondDigits`in e}function y0(e){return _0(e)||v0(e)||`dateStyle`in e||`timeStyle`in e||`timeZoneName`in e}function b0(e){return LX(e)||RX(e)||zX(e)||HX(e)||BX(e)||VX(e)||FX(e)}function x0(e){return b0(e)?e:hX(e)}function S0(e,t){return!(!b0(e)||!b0(t)||RX(e)&&!RX(t)||LX(e)&&!LX(t)||zX(e)&&!zX(t)||HX(e)&&!HX(t)||BX(e)&&!BX(t)||VX(e)&&!VX(t)||FX(e)&&!FX(t))}function C0(e,t){if(RX(e)){let n={isoDate:{year:1970,month:1,day:1},time:Z(e,JJ)};return{epochNs:fQ(Z(t,gY),n,`compatible`),formatter:t0(t,fY)}}if(BX(e)){let n=Z(e,X),r=Z(t,vY);if(n!==r)throw RangeError(`cannot format PlainYearMonth with calendar ${n} in locale with calendar ${r}`);let i=iZ(Z(e,KJ),{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{epochNs:fQ(Z(t,gY),i,`compatible`),formatter:t0(t,uY)}}if(VX(e)){let n=Z(e,X),r=Z(t,vY);if(n!==r)throw RangeError(`cannot format PlainMonthDay with calendar ${n} in locale with calendar ${r}`);let i=iZ(Z(e,KJ),{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{epochNs:fQ(Z(t,gY),i,`compatible`),formatter:t0(t,dY)}}if(LX(e)){let n=Z(e,X),r=Z(t,vY);if(n!==`iso8601`&&n!==r)throw RangeError(`cannot format PlainDate with calendar ${n} in locale with calendar ${r}`);let i=iZ(Z(e,KJ),{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{epochNs:fQ(Z(t,gY),i,`compatible`),formatter:t0(t,lY)}}if(zX(e)){let n=Z(e,X),r=Z(t,vY);if(n!==`iso8601`&&n!==r)throw RangeError(`cannot format PlainDateTime with calendar ${n} in locale with calendar ${r}`);let i=Z(e,qJ);return{epochNs:fQ(Z(t,gY),i,`compatible`),formatter:t0(t,pY)}}if(HX(e))throw TypeError(`Temporal.ZonedDateTime not supported in DateTimeFormat methods. Use toLocaleString() instead.`);return FX(e)?{epochNs:Z(e,GJ),formatter:t0(t,mY)}:{}}function w0(e){let t=Object.create(null);return t.years=Z(e,$J),t.months=Z(e,eY),t.weeks=Z(e,tY),t.days=Z(e,nY),t.hours=Z(e,rY),t.minutes=Z(e,iY),t.seconds=Z(e,aY),t.milliseconds=Z(e,oY),t.microseconds=Z(e,sY),t.nanoseconds=Z(e,cY),t}r0.prototype.constructor=i0,Object.defineProperty(i0,"prototype",{value:r0.prototype,writable:!1,enumerable:!1,configurable:!1}),i0.supportedLocalesOf=e0.supportedLocalesOf,kY(i0,`Intl.DateTimeFormat`);var{format:T0,formatToParts:E0}=Intl.DurationFormat?.prototype??Object.create(null);function D0(e){Intl.DurationFormat.prototype.resolvedOptions.call(this);let t=w0(kZ(e));return T0.call(this,t)}Intl.DurationFormat?.prototype&&(Intl.DurationFormat.prototype.format=D0,Intl.DurationFormat.prototype.formatToParts=function(e){Intl.DurationFormat.prototype.resolvedOptions.call(this);let t=w0(kZ(e));return E0.call(this,t)}),Object.freeze({__proto__:null,DateTimeFormat:i0,ModifiedIntlDurationFormatPrototypeFormat:D0});var O0=class{constructor(e){if(arguments.length<1)throw TypeError(`missing argument: epochNanoseconds is required`);qZ(this,r1(e))}get epochMilliseconds(){return Q(this,FX),t1(Z(this,GJ),`floor`)}get epochNanoseconds(){return Q(this,FX),e1(Y.default.BigInt(Z(this,GJ)))}add(e){return Q(this,FX),z$(`add`,this,e)}subtract(e){return Q(this,FX),z$(`subtract`,this,e)}until(e,t=void 0){return Q(this,FX),k$(`until`,this,e,t)}since(e,t=void 0){return Q(this,FX),k$(`since`,this,e,t)}round(e){if(Q(this,FX),e===void 0)throw TypeError(`options parameter is required`);let t=typeof e==`string`?s1(`smallestUnit`,e):$(e),n=uZ(t),r=sZ(t,`halfExpand`),i=hZ(t,`smallestUnit`,`time`,mZ);return dZ(n,{hour:24,minute:1440,second:86400,millisecond:864e5,microsecond:864e8,nanosecond:864e11}[i],!0),JZ(K$(Z(this,GJ),n,i,r))}equals(e){Q(this,FX);let t=AZ(e),n=Z(this,GJ),r=Z(t,GJ);return Y.default.equal(Y.default.BigInt(n),Y.default.BigInt(r))}toString(e=void 0){Q(this,FX);let t=$(e),n=fZ(t),r=sZ(t,`trunc`),i=hZ(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=sQ(a));let{precision:o,unit:s,increment:c}=pZ(i,n);return bQ(JZ(K$(Z(this,GJ),c,s,r)),a,o)}toJSON(){return Q(this,FX),bQ(this,void 0,`auto`)}toLocaleString(e=void 0,t=void 0){return Q(this,FX),new i0(e,t).format(this)}valueOf(){d1(`Instant`)}toZonedDateTimeISO(e){Q(this,FX);let t=sQ(e);return XZ(Z(this,GJ),t,`iso8601`)}static fromEpochMilliseconds(e){return JZ(n1(hX(e)))}static fromEpochNanoseconds(e){return JZ(r1(e))}static from(e){return AZ(e)}static compare(e,t){let n=AZ(e),r=AZ(t),i=Z(n,GJ),a=Z(r,GJ);return Y.default.lessThan(i,a)?-1:+!!Y.default.greaterThan(i,a)}};kY(O0,`Temporal.Instant`);var k0=class{constructor(e,t,n,r=`iso8601`){let i=_X(e),a=_X(t),o=_X(n),s=l1(r===void 0?`iso8601`:xX(r));r$(i,a,o),LZ(this,{year:i,month:a,day:o},s)}get calendarId(){return Q(this,LX),Z(this,X)}get era(){return A0(this,`era`)}get eraYear(){return A0(this,`eraYear`)}get year(){return A0(this,`year`)}get month(){return A0(this,`month`)}get monthCode(){return A0(this,`monthCode`)}get day(){return A0(this,`day`)}get dayOfWeek(){return A0(this,`dayOfWeek`)}get dayOfYear(){return A0(this,`dayOfYear`)}get weekOfYear(){return A0(this,`weekOfYear`)?.week}get yearOfWeek(){return A0(this,`weekOfYear`)?.year}get daysInWeek(){return A0(this,`daysInWeek`)}get daysInMonth(){return A0(this,`daysInMonth`)}get daysInYear(){return A0(this,`daysInYear`)}get monthsInYear(){return A0(this,`monthsInYear`)}get inLeapYear(){return A0(this,`inLeapYear`)}with(e,t=void 0){if(Q(this,LX),!mX(e))throw TypeError(`invalid argument`);UX(e);let n=Z(this,X),r=CZ(n,Z(this,KJ));return r=QZ(n,r,wZ(n,e,[`year`,`month`,`monthCode`,`day`],[],`partial`)),RZ(iQ(n,r,aZ($(t))),n)}withCalendar(e){Q(this,LX);let t=tQ(e);return RZ(Z(this,KJ),t)}add(e,t=void 0){return Q(this,LX),B$(`add`,this,e,t)}subtract(e,t=void 0){return Q(this,LX),B$(`subtract`,this,e,t)}until(e,t=void 0){return Q(this,LX),A$(`until`,this,e,t)}since(e,t=void 0){return Q(this,LX),A$(`since`,this,e,t)}equals(e){Q(this,LX);let t=EZ(e);return Z$(Z(this,KJ),Z(t,KJ))===0&&rQ(Z(this,X),Z(t,X))}toString(e=void 0){return Q(this,LX),SQ(this,lZ($(e)))}toJSON(){return Q(this,LX),SQ(this)}toLocaleString(e=void 0,t=void 0){return Q(this,LX),new i0(e,t).format(this)}valueOf(){d1(`PlainDate`)}toPlainDateTime(e=void 0){Q(this,LX);let t=NZ(e);return BZ(iZ(Z(this,KJ),t),Z(this,X))}toZonedDateTime(e){let t,n;if(Q(this,LX),mX(e)){let r=e.timeZone;r===void 0?t=sQ(e):(t=sQ(r),n=e.plainTime)}else t=sQ(e);let r=Z(this,KJ),i;return n===void 0?i=hQ(t,r):(n=MZ(n),i=fQ(t,iZ(r,Z(n,JJ)),`compatible`)),XZ(i,t,Z(this,X))}toPlainYearMonth(){Q(this,LX);let e=Z(this,X);return KZ(aQ(e,CZ(e,Z(this,KJ)),`constrain`),e)}toPlainMonthDay(){Q(this,LX);let e=Z(this,X);return HZ(oQ(e,CZ(e,Z(this,KJ)),`constrain`),e)}static from(e,t=void 0){return EZ(e,t)}static compare(e,t){let n=EZ(e),r=EZ(t);return Z$(Z(n,KJ),Z(r,KJ))}};function A0(e,t){Q(e,LX);let n=Z(e,KJ);return SZ(e).isoToDate(n,{[t]:!0})[t]}kY(k0,`Temporal.PlainDate`);var j0=class{constructor(e,t,n,r=0,i=0,a=0,o=0,s=0,c=0,l=`iso8601`){let u=_X(e),d=_X(t),f=_X(n),p=r===void 0?0:_X(r),m=i===void 0?0:_X(i),h=a===void 0?0:_X(a),g=o===void 0?0:_X(o),_=s===void 0?0:_X(s),v=c===void 0?0:_X(c),y=l1(l===void 0?`iso8601`:xX(l));o$(u,d,f,p,m,h,g,_,v),zZ(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,zX),Z(this,X)}get year(){return M0(this,`year`)}get month(){return M0(this,`month`)}get monthCode(){return M0(this,`monthCode`)}get day(){return M0(this,`day`)}get hour(){return N0(this,`hour`)}get minute(){return N0(this,`minute`)}get second(){return N0(this,`second`)}get millisecond(){return N0(this,`millisecond`)}get microsecond(){return N0(this,`microsecond`)}get nanosecond(){return N0(this,`nanosecond`)}get era(){return M0(this,`era`)}get eraYear(){return M0(this,`eraYear`)}get dayOfWeek(){return M0(this,`dayOfWeek`)}get dayOfYear(){return M0(this,`dayOfYear`)}get weekOfYear(){return M0(this,`weekOfYear`)?.week}get yearOfWeek(){return M0(this,`weekOfYear`)?.year}get daysInWeek(){return M0(this,`daysInWeek`)}get daysInYear(){return M0(this,`daysInYear`)}get daysInMonth(){return M0(this,`daysInMonth`)}get monthsInYear(){return M0(this,`monthsInYear`)}get inLeapYear(){return M0(this,`inLeapYear`)}with(e,t=void 0){if(Q(this,zX),!mX(e))throw TypeError(`invalid argument`);UX(e);let n=Z(this,X),r=Z(this,qJ),i={...CZ(n,r.isoDate),...r.time};return i=QZ(n,i,wZ(n,e,[`year`,`month`,`monthCode`,`day`],[`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`],`partial`)),BZ(DZ(n,i,aZ($(t))),n)}withPlainTime(e=void 0){Q(this,zX);let t=NZ(e);return BZ(iZ(Z(this,qJ).isoDate,t),Z(this,X))}withCalendar(e){Q(this,zX);let t=tQ(e);return BZ(Z(this,qJ),t)}add(e,t=void 0){return Q(this,zX),V$(`add`,this,e,t)}subtract(e,t=void 0){return Q(this,zX),V$(`subtract`,this,e,t)}until(e,t=void 0){return Q(this,zX),j$(`until`,this,e,t)}since(e,t=void 0){return Q(this,zX),j$(`since`,this,e,t)}round(e){if(Q(this,zX),e===void 0)throw TypeError(`options parameter is required`);let t=typeof e==`string`?s1(`smallestUnit`,e):$(e),n=uZ(t),r=sZ(t,`halfExpand`),i=hZ(t,`smallestUnit`,`time`,mZ,[`day`]),a={day:1,hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[i];dZ(n,a,a===1);let o=Z(this,qJ);return BZ(n===1&&i===`nanosecond`?o:q$(o,n,i,r),Z(this,X))}equals(e){Q(this,zX);let t=OZ(e);return $$(Z(this,qJ),Z(t,qJ))===0&&rQ(Z(this,X),Z(t,X))}toString(e=void 0){Q(this,zX);let t=$(e),n=lZ(t),r=fZ(t),i=sZ(t,`trunc`),a=hZ(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}=pZ(a,r),l=q$(Z(this,qJ),c,s,i);return s$(l),wQ(l,Z(this,X),o,n)}toJSON(){return Q(this,zX),wQ(Z(this,qJ),Z(this,X),`auto`)}toLocaleString(e=void 0,t=void 0){return Q(this,zX),new i0(e,t).format(this)}valueOf(){d1(`PlainDateTime`)}toZonedDateTime(e,t=void 0){Q(this,zX);let n=sQ(e),r=oZ($(t));return XZ(fQ(n,Z(this,qJ),r),n,Z(this,X))}toPlainDate(){return Q(this,zX),RZ(Z(this,qJ).isoDate,Z(this,X))}toPlainTime(){return Q(this,zX),WZ(Z(this,qJ).time)}static from(e,t=void 0){return OZ(e,t)}static compare(e,t){let n=OZ(e),r=OZ(t);return $$(Z(n,qJ),Z(r,qJ))}};function M0(e,t){Q(e,zX);let n=Z(e,qJ).isoDate;return SZ(e).isoToDate(n,{[t]:!0})[t]}function N0(e,t){return Q(e,zX),Z(e,qJ).time[t]}kY(j0,`Temporal.PlainDateTime`);var P0=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:yX(e),d=t===void 0?0:yX(t),f=n===void 0?0:yX(n),p=r===void 0?0:yX(r),m=i===void 0?0:yX(i),h=a===void 0?0:yX(a),g=o===void 0?0:yX(o),_=s===void 0?0:yX(s),v=c===void 0?0:yX(c),y=l===void 0?0:yX(l);d$(u,d,f,p,m,h,g,_,v,y),TY(this),DY(this,$J,u),DY(this,eY,d),DY(this,tY,f),DY(this,nY,p),DY(this,rY,m),DY(this,iY,h),DY(this,aY,g),DY(this,oY,_),DY(this,sY,v),DY(this,cY,y)}get years(){return Q(this,IX),Z(this,$J)}get months(){return Q(this,IX),Z(this,eY)}get weeks(){return Q(this,IX),Z(this,tY)}get days(){return Q(this,IX),Z(this,nY)}get hours(){return Q(this,IX),Z(this,rY)}get minutes(){return Q(this,IX),Z(this,iY)}get seconds(){return Q(this,IX),Z(this,aY)}get milliseconds(){return Q(this,IX),Z(this,oY)}get microseconds(){return Q(this,IX),Z(this,sY)}get nanoseconds(){return Q(this,IX),Z(this,cY)}get sign(){return Q(this,IX),GQ(this)}get blank(){return Q(this,IX),GQ(this)===0}with(t){Q(this,IX);let{years:n=Z(this,$J),months:r=Z(this,eY),weeks:i=Z(this,tY),days:a=Z(this,nY),hours:o=Z(this,rY),minutes:s=Z(this,iY),seconds:c=Z(this,aY),milliseconds:l=Z(this,oY),microseconds:u=Z(this,sY),nanoseconds:d=Z(this,cY)}=nZ(t);return new e(n,r,i,a,o,s,c,l,u,d)}negated(){return Q(this,IX),$Q(this)}abs(){return Q(this,IX),new e(Math.abs(Z(this,$J)),Math.abs(Z(this,eY)),Math.abs(Z(this,tY)),Math.abs(Z(this,nY)),Math.abs(Z(this,rY)),Math.abs(Z(this,iY)),Math.abs(Z(this,aY)),Math.abs(Z(this,oY)),Math.abs(Z(this,sY)),Math.abs(Z(this,cY)))}add(e){return Q(this,IX),R$(`add`,this,e)}subtract(e){return Q(this,IX),R$(`subtract`,this,e)}round(e){if(Q(this,IX),e===void 0)throw TypeError(`options parameter is required`);let t=_Z(this),n=typeof e==`string`?s1(`smallestUnit`,e):$(e),r=hZ(n,`largestUnit`,`datetime`,void 0,[`auto`]),{plainRelativeTo:i,zonedRelativeTo:a}=gZ(n),o=uZ(n),s=sZ(n,`halfExpand`),c=hZ(n,`smallestUnit`,`datetime`,void 0),l=!0;c||=(l=!1,`nanosecond`);let u=vZ(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(vZ(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&&dZ(o,f,!1),o>1&&bZ(c)===`date`&&r!==c)throw RangeError(`For calendar units with roundingIncrement > 1, use largestUnit = smallestUnit`);if(a){let e=f$(this),t=Z(a,QJ),n=Z(a,X),i=Z(a,GJ);return e=D$(i,L$(i,t,n,e),t,n,r,o,c,s),bZ(r)===`date`&&(r=`hour`),h$(e,r)}if(i){let e=p$(this),t=F$({deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0},e.time),n=Z(i,KJ),a=Z(i,X),l=$Z(a,n,rZ(e.date,t.deltaDays),`constrain`);return e=E$(iZ(n,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),iZ(l,t),a,r,o,c,s),h$(e,r)}if(yZ(t))throw RangeError(`a starting point is required for ${t}s balancing`);if(yZ(r))throw RangeError(`a starting point is required for ${r}s balancing`);let p=p$(this);if(c===`day`){let{quotient:e,remainder:t}=p.time.divmod(tX),n=p.date.days+e+X$(t,`day`);n=G$(n,o,s),p=g$({years:0,months:0,weeks:0,days:n},IY.ZERO)}else p=g$({years:0,months:0,weeks:0,days:0},Y$(p.time,o,c,s));return h$(p,r)}total(e){if(Q(this,IX),e===void 0)throw TypeError(`options argument is required`);let t=typeof e==`string`?s1(`unit`,e):$(e),{plainRelativeTo:n,zonedRelativeTo:r}=gZ(t),i=hZ(t,`unit`,`datetime`,mZ);if(r){let e=f$(this),t=Z(r,QJ),n=Z(r,X),a=Z(r,GJ);return function(e,t,n,r,i){return bZ(i)===`time`?X$(IY.fromEpochNsDiff(t,e),i):T$(S$(e,t,n,r,i),t,dQ(n,e),n,r,i)}(a,L$(a,t,n,e),t,n,i)}if(n){let e=p$(this),t=F$({deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0},e.time),r=Z(n,KJ),a=Z(n,X),o=$Z(a,r,rZ(e.date,t.deltaDays),`constrain`);return function(e,t,n,r){if($$(e,t)==0)return 0;s$(e),s$(t);let i=x$(e,t,n,r);return r===`nanosecond`?Y.default.toNumber(i.time.totalNs):T$(i,RQ(t),e,null,n,r)}(iZ(r,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),iZ(o,t),a,i)}let a=_Z(this);if(yZ(a))throw RangeError(`a starting point is required for ${a}s total`);if(yZ(i))throw RangeError(`a starting point is required for ${i}s total`);return X$(p$(this).time,i)}toString(e=void 0){Q(this,IX);let t=$(e),n=fZ(t),r=sZ(t,`trunc`),i=hZ(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}=pZ(i,n);if(o===`nanosecond`&&s===1)return xQ(this,a);let c=_Z(this),l=f$(this),u=Y$(l.time,s,o,r);return l=g$(l.date,u),xQ(h$(l,vZ(c,`second`)),a)}toJSON(){return Q(this,IX),xQ(this,`auto`)}toLocaleString(e=void 0,t=void 0){if(Q(this,IX),typeof Intl.DurationFormat==`function`){let n=new Intl.DurationFormat(e,t);return D0.call(n,this)}return console.warn(`Temporal.Duration.prototype.toLocaleString() requires Intl.DurationFormat.`),xQ(this,`auto`)}valueOf(){d1(`Duration`)}static from(e){return kZ(e)}static compare(e,t,n=void 0){let r=kZ(e),i=kZ(t),{plainRelativeTo:a,zonedRelativeTo:o}=gZ($(n));if(Z(r,$J)===Z(i,$J)&&Z(r,eY)===Z(i,eY)&&Z(r,tY)===Z(i,tY)&&Z(r,nY)===Z(i,nY)&&Z(r,rY)===Z(i,rY)&&Z(r,iY)===Z(i,iY)&&Z(r,aY)===Z(i,aY)&&Z(r,oY)===Z(i,oY)&&Z(r,sY)===Z(i,sY)&&Z(r,cY)===Z(i,cY))return 0;let s=_Z(r),c=_Z(i),l=f$(r),u=f$(i);if(o&&(bZ(s)===`date`||bZ(c)===`date`)){let e=Z(o,QJ),t=Z(o,X),n=Z(o,GJ),r=L$(n,e,t,l),i=L$(n,e,t,u);return o1(Y.default.toNumber(Y.default.subtract(r,i)))}let d=l.date.days,f=u.date.days;if(yZ(s)||yZ(c)){if(!a)throw RangeError(`A starting point is required for years, months, or weeks comparison`);d=QQ(l.date,a),f=QQ(u.date,a)}let p=l.time.add24HourDays(d),m=u.time.add24HourDays(f);return p.cmp(m)}};kY(P0,`Temporal.Duration`);var F0=class{constructor(e,t,n=`iso8601`,r=1972){let i=_X(e),a=_X(t),o=l1(n===void 0?`iso8601`:xX(n)),s=_X(r);r$(s,i,a),VZ(this,{year:s,month:i,day:a},o)}get monthCode(){return I0(this,`monthCode`)}get day(){return I0(this,`day`)}get calendarId(){return Q(this,VX),Z(this,X)}with(e,t=void 0){if(Q(this,VX),!mX(e))throw TypeError(`invalid argument`);UX(e);let n=Z(this,X),r=CZ(n,Z(this,KJ),`month-day`);return r=QZ(n,r,wZ(n,e,[`year`,`month`,`monthCode`,`day`],[],`partial`)),HZ(oQ(n,r,aZ($(t))),n)}equals(e){Q(this,VX);let t=jZ(e);return Z$(Z(this,KJ),Z(t,KJ))===0&&rQ(Z(this,X),Z(t,X))}toString(e=void 0){return Q(this,VX),TQ(this,lZ($(e)))}toJSON(){return Q(this,VX),TQ(this)}toLocaleString(e=void 0,t=void 0){return Q(this,VX),new i0(e,t).format(this)}valueOf(){d1(`PlainMonthDay`)}toPlainDate(e){if(Q(this,VX),!mX(e))throw TypeError(`argument should be an object`);let t=Z(this,X);return RZ(iQ(t,QZ(t,CZ(t,Z(this,KJ),`month-day`),wZ(t,e,[`year`],[],[])),`constrain`),t)}static from(e,t=void 0){return jZ(e,t)}};function I0(e,t){Q(e,VX);let n=Z(e,KJ);return SZ(e).isoToDate(n,{[t]:!0})[t]}function L0(e){return dQ(e,i1())}kY(F0,`Temporal.PlainMonthDay`);var R0={instant:()=>JZ(i1()),plainDateTimeISO:(e=a1())=>BZ(L0(sQ(e)),`iso8601`),plainDateISO:(e=a1())=>RZ(L0(sQ(e)).isoDate,`iso8601`),plainTimeISO:(e=a1())=>WZ(L0(sQ(e)).time),timeZoneId:()=>a1(),zonedDateTimeISO:(e=a1())=>{let t=sQ(e);return XZ(i1(),t,`iso8601`)},[Symbol.toStringTag]:`Temporal.Now`};Object.defineProperty(R0,Symbol.toStringTag,{value:`Temporal.Now`,writable:!1,enumerable:!1,configurable:!0});var z0=class e{constructor(e=0,t=0,n=0,r=0,i=0,a=0){let o=e===void 0?0:_X(e),s=t===void 0?0:_X(t),c=n===void 0?0:_X(n),l=r===void 0?0:_X(r),u=i===void 0?0:_X(i),d=a===void 0?0:_X(a);a$(o,s,c,l,u,d),UZ(this,{hour:o,minute:s,second:c,millisecond:l,microsecond:u,nanosecond:d})}get hour(){return Q(this,RX),Z(this,JJ).hour}get minute(){return Q(this,RX),Z(this,JJ).minute}get second(){return Q(this,RX),Z(this,JJ).second}get millisecond(){return Q(this,RX),Z(this,JJ).millisecond}get microsecond(){return Q(this,RX),Z(this,JJ).microsecond}get nanosecond(){return Q(this,RX),Z(this,JJ).nanosecond}with(t,n=void 0){if(Q(this,RX),!mX(t))throw TypeError(`invalid argument`);UX(t);let r=TZ(t,`partial`),i=TZ(this),{hour:a,minute:o,second:s,millisecond:c,microsecond:l,nanosecond:u}=Object.assign(i,r),d=aZ($(n));return{hour:a,minute:o,second:s,millisecond:c,microsecond:l,nanosecond:u}=tZ(a,o,s,c,l,u,d),new e(a,o,s,c,l,u)}add(e){return Q(this,RX),H$(`add`,this,e)}subtract(e){return Q(this,RX),H$(`subtract`,this,e)}until(e,t=void 0){return Q(this,RX),M$(`until`,this,e,t)}since(e,t=void 0){return Q(this,RX),M$(`since`,this,e,t)}round(e){if(Q(this,RX),e===void 0)throw TypeError(`options parameter is required`);let t=typeof e==`string`?s1(`smallestUnit`,e):$(e),n=uZ(t),r=sZ(t,`halfExpand`),i=hZ(t,`smallestUnit`,`time`,mZ);return dZ(n,{hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[i],!1),WZ(J$(Z(this,JJ),n,i,r))}equals(e){Q(this,RX);let t=MZ(e);return Q$(Z(this,JJ),Z(t,JJ))===0}toString(e=void 0){Q(this,RX);let t=$(e),n=fZ(t),r=sZ(t,`trunc`),i=hZ(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}=pZ(i,n);return CQ(J$(Z(this,JJ),s,o,r),a)}toJSON(){return Q(this,RX),CQ(Z(this,JJ),`auto`)}toLocaleString(e=void 0,t=void 0){return Q(this,RX),new i0(e,t).format(this)}valueOf(){d1(`PlainTime`)}static from(e,t=void 0){return MZ(e,t)}static compare(e,t){let n=MZ(e),r=MZ(t);return Q$(Z(n,JJ),Z(r,JJ))}};kY(z0,`Temporal.PlainTime`);var B0=class{constructor(e,t,n=`iso8601`,r=1){let i=_X(e),a=_X(t),o=l1(n===void 0?`iso8601`:xX(n)),s=_X(r);r$(i,a,s),GZ(this,{year:i,month:a,day:s},o)}get year(){return V0(this,`year`)}get month(){return V0(this,`month`)}get monthCode(){return V0(this,`monthCode`)}get calendarId(){return Q(this,BX),Z(this,X)}get era(){return V0(this,`era`)}get eraYear(){return V0(this,`eraYear`)}get daysInMonth(){return V0(this,`daysInMonth`)}get daysInYear(){return V0(this,`daysInYear`)}get monthsInYear(){return V0(this,`monthsInYear`)}get inLeapYear(){return V0(this,`inLeapYear`)}with(e,t=void 0){if(Q(this,BX),!mX(e))throw TypeError(`invalid argument`);UX(e);let n=Z(this,X),r=CZ(n,Z(this,KJ),`year-month`);return r=QZ(n,r,wZ(n,e,[`year`,`month`,`monthCode`],[],`partial`)),KZ(aQ(n,r,aZ($(t))),n)}add(e,t=void 0){return Q(this,BX),U$(`add`,this,e,t)}subtract(e,t=void 0){return Q(this,BX),U$(`subtract`,this,e,t)}until(e,t=void 0){return Q(this,BX),N$(`until`,this,e,t)}since(e,t=void 0){return Q(this,BX),N$(`since`,this,e,t)}equals(e){Q(this,BX);let t=PZ(e);return Z$(Z(this,KJ),Z(t,KJ))===0&&rQ(Z(this,X),Z(t,X))}toString(e=void 0){return Q(this,BX),EQ(this,lZ($(e)))}toJSON(){return Q(this,BX),EQ(this)}toLocaleString(e=void 0,t=void 0){return Q(this,BX),new i0(e,t).format(this)}valueOf(){d1(`PlainYearMonth`)}toPlainDate(e){if(Q(this,BX),!mX(e))throw TypeError(`argument should be an object`);let t=Z(this,X);return RZ(iQ(t,QZ(t,CZ(t,Z(this,KJ),`year-month`),wZ(t,e,[`day`],[],[])),`constrain`),t)}static from(e,t=void 0){return PZ(e,t)}static compare(e,t){let n=PZ(e),r=PZ(t);return Z$(Z(n,KJ),Z(r,KJ))}};function V0(e,t){Q(e,BX);let n=Z(e,KJ);return SZ(e).isoToDate(n,{[t]:!0})[t]}kY(B0,`Temporal.PlainYearMonth`);var H0=i0.prototype.resolvedOptions,U0=class{constructor(e,t,n=`iso8601`){if(arguments.length<1)throw TypeError(`missing argument: epochNanoseconds is required`);let r=r1(e),i=xX(t),{tzName:a,offsetMinutes:o}=$X(i);if(o===void 0){let e=MQ(a);if(!e)throw RangeError(`unknown time zone ${a}`);i=e.identifier}else i=FQ(o);YZ(this,r,i,l1(n===void 0?`iso8601`:xX(n)))}get calendarId(){return Q(this,HX),Z(this,X)}get timeZoneId(){return Q(this,HX),Z(this,QJ)}get year(){return G0(this,`year`)}get month(){return G0(this,`month`)}get monthCode(){return G0(this,`monthCode`)}get day(){return G0(this,`day`)}get hour(){return K0(this,`hour`)}get minute(){return K0(this,`minute`)}get second(){return K0(this,`second`)}get millisecond(){return K0(this,`millisecond`)}get microsecond(){return K0(this,`microsecond`)}get nanosecond(){return K0(this,`nanosecond`)}get era(){return G0(this,`era`)}get eraYear(){return G0(this,`eraYear`)}get epochMilliseconds(){return Q(this,HX),t1(Z(this,GJ),`floor`)}get epochNanoseconds(){return Q(this,HX),e1(Z(this,GJ))}get dayOfWeek(){return G0(this,`dayOfWeek`)}get dayOfYear(){return G0(this,`dayOfYear`)}get weekOfYear(){return G0(this,`weekOfYear`)?.week}get yearOfWeek(){return G0(this,`weekOfYear`)?.year}get hoursInDay(){Q(this,HX);let e=Z(this,QJ),t=W0(this).isoDate,n=YQ(t.year,t.month,t.day+1),r=hQ(e,t),i=hQ(e,n);return X$(IY.fromEpochNsDiff(i,r),`hour`)}get daysInWeek(){return G0(this,`daysInWeek`)}get daysInMonth(){return G0(this,`daysInMonth`)}get daysInYear(){return G0(this,`daysInYear`)}get monthsInYear(){return G0(this,`monthsInYear`)}get inLeapYear(){return G0(this,`inLeapYear`)}get offset(){return Q(this,HX),uQ(lQ(Z(this,QJ),Z(this,GJ)))}get offsetNanoseconds(){return Q(this,HX),lQ(Z(this,QJ),Z(this,GJ))}with(e,t=void 0){if(Q(this,HX),!mX(e))throw TypeError(`invalid zoned-date-time-like`);UX(e);let n=Z(this,X),r=Z(this,QJ),i=lQ(r,Z(this,GJ)),a=W0(this),o={...CZ(n,a.isoDate),...a.time,offset:uQ(i)};o=QZ(n,o,wZ(n,e,[`year`,`month`,`monthCode`,`day`],[`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`,`offset`],`partial`));let s=$(t),c=oZ(s),l=cZ(s,`prefer`),u=DZ(n,o,aZ(s)),d=kQ(o.offset);return XZ(FZ(u.isoDate,u.time,`option`,d,r,c,l,!1),r,n)}withPlainTime(e=void 0){Q(this,HX);let t=Z(this,QJ),n=Z(this,X),r=W0(this).isoDate,i;return i=e===void 0?hQ(t,r):fQ(t,iZ(r,Z(MZ(e),JJ)),`compatible`),XZ(i,t,n)}withTimeZone(e){Q(this,HX);let t=sQ(e);return XZ(Z(this,GJ),t,Z(this,X))}withCalendar(e){Q(this,HX);let t=tQ(e);return XZ(Z(this,GJ),Z(this,QJ),t)}add(e,t=void 0){return Q(this,HX),W$(`add`,this,e,t)}subtract(e,t=void 0){return Q(this,HX),W$(`subtract`,this,e,t)}until(e,t=void 0){return Q(this,HX),P$(`until`,this,e,t)}since(e,t=void 0){return Q(this,HX),P$(`since`,this,e,t)}round(e){if(Q(this,HX),e===void 0)throw TypeError(`options parameter is required`);let t=typeof e==`string`?s1(`smallestUnit`,e):$(e),n=uZ(t),r=sZ(t,`halfExpand`),i=hZ(t,`smallestUnit`,`time`,mZ,[`day`]),a={day:1,hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[i];if(dZ(n,a,a===1),i===`nanosecond`&&n===1)return XZ(Z(this,GJ),Z(this,QJ),Z(this,X));let o=Z(this,QJ),s=Z(this,GJ),c=W0(this),l;if(i===`day`){let e=c.isoDate,t=YQ(e.year,e.month,e.day+1),n=hQ(o,e),i=hQ(o,t),a=Y.default.subtract(i,n);l=IY.fromEpochNsDiff(s,n).round(a,r).addToEpochNs(n)}else{let e=q$(c,n,i,r),t=lQ(o,s);l=FZ(e.isoDate,e.time,`option`,t,o,`compatible`,`prefer`,!1)}return XZ(l,o,Z(this,X))}equals(e){Q(this,HX);let t=IZ(e),n=Z(this,GJ),r=Z(t,GJ);return!!Y.default.equal(Y.default.BigInt(n),Y.default.BigInt(r))&&!!cQ(Z(this,QJ),Z(t,QJ))&&rQ(Z(this,X),Z(t,X))}toString(e=void 0){Q(this,HX);let t=$(e),n=lZ(t),r=fZ(t),i=function(e){return c1(e,`offset`,[`auto`,`never`],`auto`)}(t),a=sZ(t,`trunc`),o=hZ(t,`smallestUnit`,`time`,void 0);if(o===`hour`)throw RangeError(`smallestUnit must be a time unit other than "hour"`);let s=function(e){return c1(e,`timeZoneName`,[`auto`,`never`,`critical`],`auto`)}(t),{precision:c,unit:l,increment:u}=pZ(o,r);return DQ(this,c,n,s,i,{unit:l,increment:u,roundingMode:a})}toLocaleString(e=void 0,t=void 0){Q(this,HX);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,QJ),OQ(r.timeZone))throw RangeError(`toLocaleString does not currently support offset time zones`);let i=new i0(e,r),a=H0.call(i).calendar,o=Z(this,X);if(o!==`iso8601`&&a!==`iso8601`&&!rQ(a,o))throw RangeError(`cannot format ZonedDateTime with calendar ${o} in locale with calendar ${a}`);return i.format(JZ(Z(this,GJ)))}toJSON(){return Q(this,HX),DQ(this,`auto`)}valueOf(){d1(`ZonedDateTime`)}startOfDay(){Q(this,HX);let e=Z(this,QJ);return XZ(hQ(e,W0(this).isoDate),e,Z(this,X))}getTimeZoneTransition(e){Q(this,HX);let t=Z(this,QJ);if(e===void 0)throw TypeError(`options parameter is required`);let n=c1(typeof e==`string`?s1(`direction`,e):$(e),`direction`,[`next`,`previous`],mZ);if(n===void 0)throw TypeError(`direction option is required`);if(OQ(t)||t===`UTC`)return null;let r=Z(this,GJ),i=n===`next`?BQ(t,r):VQ(t,r);return i===null?null:XZ(i,t,Z(this,X))}toInstant(){return Q(this,HX),JZ(Z(this,GJ))}toPlainDate(){return Q(this,HX),RZ(W0(this).isoDate,Z(this,X))}toPlainTime(){return Q(this,HX),WZ(W0(this).time)}toPlainDateTime(){return Q(this,HX),BZ(W0(this),Z(this,X))}static from(e,t=void 0){return IZ(e,t)}static compare(e,t){let n=IZ(e),r=IZ(t),i=Z(n,GJ),a=Z(r,GJ);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 W0(e){return dQ(Z(e,QJ),Z(e,GJ))}function G0(e,t){Q(e,HX);let n=W0(e).isoDate;return SZ(e).isoToDate(n,{[t]:!0})[t]}function K0(e,t){return Q(e,HX),W0(e).time[t]}kY(U0,`Temporal.ZonedDateTime`);var q0=Object.freeze({__proto__:null,Duration:P0,Instant:O0,Now:R0,PlainDate:k0,PlainDateTime:j0,PlainMonthDay:F0,PlainTime:z0,PlainYearMonth:B0,ZonedDateTime:U0});(class{toTemporalInstant(){return JZ(n1(Date.prototype.valueOf.call(this)))}}).prototype.toTemporalInstant;var J0=[O0,k0,j0,P0,F0,z0,B0,U0];for(let e of J0){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 Y0(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 X0(e,t){return Y0(new Date(e),t)}function Z0(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=q0.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 Q0(e,t){return new Intl.DateTimeFormat(void 0,{timeZone:t,dateStyle:`medium`,timeStyle:`short`}).format(new Date(e))}var $0=[[1,`Mon`],[2,`Tue`],[3,`Wed`],[4,`Thu`],[5,`Fri`],[6,`Sat`],[0,`Sun`]];function e2({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`?X0(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,k]=(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}))}))),[A,j]=(0,m.useState)(!1),[ee,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,j(!0),o(!0);try{if(!P.current){if(!te)throw Error(`Choose a template before saving the schedule.`);let e=S.trim();if(!oJ(e))throw Error(`Choose a valid IANA timezone, such as Europe/Tirane.`);let t=f===`once`?{kind:f,at:Z0(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:t2(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 CJ(s,t,a):await SJ(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(``),k([]),n()}catch(e){M(P.current!==null),r(e instanceof Error?e.message:`Could not save the schedule. Try again.`)}finally{N.current=!1,j(!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:A||ee||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)(oM,{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)(oM,{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)(oM,{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:$0.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)(oM,{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)(oM,{id:`schedule-spend`,inputMode:`numeric`,value:E,onChange:e=>D(e.target.value),placeholder:`1000`})]}),(0,h.jsx)(n2,{variants:O,onChange:k})]}),(0,h.jsxs)(`div`,{className:`mt-4 flex gap-2`,children:[(0,h.jsx)(B,{type:`submit`,disabled:t||A||F.length===0&&!ee,children:A?`Saving…`:ee?`Retry save`:i?`Save changes`:`Save schedule`}),i?(0,h.jsx)(B,{type:`button`,disabled:A||ee,onClick:a,children:`Cancel editing`}):null]})]})]})}function t2(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 n2({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 r2(){let{api:e}=I(),t=_(),n=nt(bJ(e)),r=nt(cq(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:yJ})},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)(WA,{"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)(e2,{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:yJ})},onError:e=>{a(e),t.invalidateQueries({queryKey:yJ})}},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)(Mj,{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)(i2,{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)(i2,{schedule:e,pending:!1,onAction:y,error:null,onEdit:()=>void 0},e.id))})]}):null]})}function i2({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 xJ(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: ${Q0(e.nextRunAt,e.timezone)}`:`Deleted: ${Q0(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(()=>wJ(a,e.id,`pause`,e.version)),children:[(0,h.jsx)(tj,{"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(()=>wJ(a,e.id,`resume`,e.version)),children:[(0,h.jsx)(nj,{"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)(aj,{"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)(YA,{"aria-hidden":`true`,className:`size-4`}):(0,h.jsx)(KA,{"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)(jj,{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 TJ(a,e.id,e.version):await wJ(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,` · `,Q0(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 a2(){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 o2({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,v=e.cliPath?.command??g,y=l??p??``,b=Ik(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),Xj);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)(lK,{state:b?`done`:`pending`}),(0,h.jsx)(`span`,{children:s2(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)(iM,{htmlFor:a,id:o,className:`mb-[5px]`,children:`Executable path`}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(oM,{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)(Qj,{}):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.`]})]})]})}function s2(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 c2=[`llm`,`tts`,`image`],l2={llm:`API keys · LLM`,tts:`API keys · Text to speech`,image:`API keys · Image generation`},u2=`••••••••••••`,d2=`grid grid-cols-[140px_1fr_auto] items-end gap-[14px] border-t border-line px-4 py-[14px] first:border-t-0`,f2=`engraved border-t border-line px-4 py-3 text-ink3 first:border-t-0`;function p2(){let{api:e}=I(),t=nt(vy(e));if(t.error!==null)return(0,h.jsx)(Mj,{children:(0,h.jsx)(Nj,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:t.error.message})})});if(t.data===void 0)return(0,h.jsx)(h2,{});let n=t.data.providers,r=n.every(e=>e.readiness.kind!==`keyed`||!e.readiness.hasKey);return(0,h.jsx)(Mj,{children:c2.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:f2,children:l2[e]}),n.filter(t=>t.family===e).map(e=>e.readiness.kind===`cli`?(0,h.jsx)(o2,{provider:e,readiness:e.readiness},e.id):(0,h.jsx)(m2,{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 m2({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)},Xj);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:d2,children:[(0,h.jsx)(`span`,{id:o,className:`pb-[7px] font-semibold`,children:e.displayName}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(iM,{htmlFor:i,id:a,className:`mb-[5px]`,children:`API key`}),(0,h.jsx)(oM,{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?u2: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)(Qj,{}):null,t?(0,h.jsx)(B,{className:`bg-transparent`,"aria-label":`Remove ${e.displayName} key`,onClick:()=>{x(!0)},children:`Remove`}):null]}),(0,h.jsx)(jj,{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 h2(){return(0,h.jsx)(Mj,{children:[0,1,2,3].map(e=>(0,h.jsxs)(Nj,{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 g2=ev,_2=iv;function v2({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)(KA,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-ink2`})})]})}function y2({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 b2({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)(GA,{"aria-hidden":`true`,className:`size-[14px] text-done`})})]})}var x2=`px-4 align-top`;function S2(){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)(Mj,{children:(0,h.jsx)(Nj,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message})})});let c=n.data?.voices;return(0,h.jsxs)(Mj,{"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(x2,`engraved w-[26%] py-3 text-left text-ink3`),children:`Voices · Name`}),(0,h.jsx)(`th`,{className:z(x2,`engraved w-[26%] py-3 text-left text-ink3`),children:`Provider`}),(0,h.jsx)(`th`,{className:z(x2,`engraved py-3 text-left text-ink3`),children:`Voice ID`}),(0,h.jsx)(`th`,{className:z(x2,`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(x2,`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(x2,`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(x2,`py-3 font-semibold`),children:e.name}),(0,h.jsx)(`td`,{className:z(x2,`py-3 text-ink2`),children:T2(s,e.provider)}),(0,h.jsx)(`td`,{className:z(x2,`py-3 text-ink2 tabular-nums`),children:e.voiceId}),(0,h.jsx)(`td`,{className:z(x2,`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)(C2,{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)(jj,{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 C2({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(x2,`py-[14px]`),children:[(0,h.jsx)(iM,{htmlFor:r,className:`mb-[5px]`,children:`Voice name`}),(0,h.jsx)(oM,{id:r,value:c,"aria-invalid":S(`name`)!==void 0,onChange:e=>{let t=e.target.value;x(`name`,()=>{l(t)})}}),(0,h.jsx)(w2,{id:`${s}-name`,message:S(`name`)})]}),(0,h.jsxs)(`td`,{className:z(x2,`py-[14px]`),children:[(0,h.jsx)(iM,{id:a,className:`mb-[5px]`,children:`Provider`}),(0,h.jsxs)(g2,{value:y??``,onValueChange:t=>{let n=e.find(e=>e.id===t);n!==void 0&&x(`provider`,()=>{p(n.id)})},children:[(0,h.jsx)(v2,{id:i,"aria-labelledby":`${a} ${i}`,children:(0,h.jsx)(_2,{placeholder:`Pick a provider`})}),(0,h.jsx)(y2,{children:e.map(e=>(0,h.jsx)(b2,{value:e.id,children:e.displayName},e.id))})]}),(0,h.jsx)(w2,{id:`${s}-provider`,message:S(`provider`)})]}),(0,h.jsxs)(`td`,{className:z(x2,`py-[14px]`),children:[(0,h.jsx)(iM,{htmlFor:o,className:`mb-[5px]`,children:`Voice ID`}),(0,h.jsx)(oM,{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)(w2,{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(x2,`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 w2({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 T2(e,t){return e.find(e=>e.id===t)?.displayName??t}var E2=[`storage-usage`],D2=[E2,V.settings,V.providers,V.voices,V.prompts,V.entries,V.staging,rq,UO,[`provider-models`]];async function O2(e){await Promise.all(D2.map(t=>e.invalidateQueries({queryKey:t})))}var k2=30,A2=[{value:`system`,label:`System`},{value:`dark`,label:`Dark`},{value:`light`,label:`Light`}];function j2(e){let t=e.trim();return/^\d+$/.test(t)&&Number(t)>=0&&Number(t)<=k2?void 0:`The silence gap is a whole number of seconds between 0 and ${String(k2)}.`}function M2(){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)(p2,{}),(0,h.jsx)(S2,{}),(0,h.jsx)(a2,{}),(0,h.jsx)(F2,{}),(0,h.jsx)(N2,{})]})}function N2(){let{api:e}=I(),t=_(),n=nt({queryKey:E2,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 O2(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:E2})}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:[P2(n.data.data),` stored · `,P2(n.data.projects),` project files · `,P2(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:P2(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 P2(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 F2(){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)},Xj);return()=>{clearTimeout(e)}},[c]),n.error!==null)return(0,h.jsx)(Mj,{children:(0,h.jsx)(Nj,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message})})});if(n.data===void 0)return(0,h.jsxs)(Mj,{children:[(0,h.jsx)(`h2`,{className:`engraved border-b border-line px-4 py-3 text-ink3`,children:`Playback`}),(0,h.jsxs)(Nj,{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=j2(f);return(0,h.jsxs)(Mj,{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)(oM,{id:r,type:`number`,inputMode:`numeric`,min:0,max:k2,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)(Qj,{}):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)(Bj,{type:`single`,value:d.appearance,"aria-labelledby":a,className:`justify-self-start`,onValueChange:e=>{let t=A2.find(t=>t.value===e);t!==void 0&&u.mutate({silenceGapSeconds:d.silenceGapSeconds,appearance:t.value})},children:A2.map(e=>(0,h.jsx)(Vj,{value:e.value,children:e.label},e.value))})]})]})}function I2({onApplied:e,beforeApply:t,getGeneration:n,blocked:r=!1}){let{api:i}=I(),a=_(),o=nt(cq(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 lq(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:rq})}async function k(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 fq(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 A(){if(!x)return;let e=await dq(i,x);if(!e.ok)throw Error(e.message);S(null),b(`Template deleted.`),await a.invalidateQueries({queryKey:rq})}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)(oM,{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(()=>k(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)(jj,{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(A),onCancel:()=>{f||S(null)}})]})}function L2({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 R2({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 z2(){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)(Mj,{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)(R2,{cells:5}),(0,h.jsx)(J2,{})]}):null:(0,h.jsx)(B2,{usage:t.data})]})}function B2({usage:e}){let t=Object.values(e.counters).every(e=>e===0);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(L2,{counters:q2(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)(V2,{className:`w-[24%]`,children:`Tokens by stage`}),(0,h.jsx)(V2,{className:`w-[38%]`,children:`Provider · model`}),(0,h.jsx)(V2,{className:`w-[19%] text-right`,children:`Tokens in`}),(0,h.jsx)(V2,{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)(H2,{className:`truncate font-semibold`,children:Lk[e.stage]}),(0,h.jsx)(H2,{className:`truncate text-ink2`,children:U2(e)}),(0,h.jsx)(H2,{className:`text-right tabular-nums`,children:W2.format(e.tokensIn)}),(0,h.jsx)(H2,{className:`text-right tabular-nums`,children:W2.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 V2({children:e,className:t}){return(0,h.jsx)(`th`,{className:`engraved px-4 py-3 text-left text-ink3 ${t}`,children:e})}function H2({children:e,className:t}){return(0,h.jsx)(`td`,{className:`px-4 py-3 align-top text-small ${t}`,children:e})}function U2(e){return e.model===null?e.provider:`${e.provider} · ${e.model}`}var W2=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),G2=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),K2=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1});function q2(e){let t=e.counters;return[{label:`Videos made`,value:W2.format(t.videosMade)},{label:`Hours of audio`,value:G2.format(t.audioSeconds/3600)},{label:`Images made`,value:W2.format(t.imagesMade)},{label:`Tokens used`,value:t.tokensUsed<1e6?W2.format(t.tokensUsed):K2.format(t.tokensUsed)},{label:`Projects`,value:W2.format(t.projects)}]}function J2(){return(0,h.jsx)(Mj,{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 Y2=da({component:yj}),X2=la({getParentRoute:()=>Y2,path:`/`,component:Wq}),Z2=la({getParentRoute:()=>Y2,path:`play`,component:pP}),Q2=la({getParentRoute:()=>Y2,path:`templates`,component:e4}),$2=la({getParentRoute:()=>Y2,path:`schedules`,component:r2});function e4(){let e=wk(),t=Gi();return(0,h.jsx)(I2,{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 t4=la({getParentRoute:()=>Y2,path:`projects/$projectId`,component:u4}),n4=la({getParentRoute:()=>Y2,path:`prompts`,validateSearch:e=>({kind:Aj(e.kind)}),component:d4}),r4=la({getParentRoute:()=>Y2,path:`prompts/new`,validateSearch:e=>{let t=Aj(e.kind);return typeof e.from==`string`?{kind:t,from:e.from}:{kind:t}},component:f4}),i4=la({getParentRoute:()=>Y2,path:`prompts/$promptId`,component:p4}),a4=la({getParentRoute:()=>Y2,path:`entries`,validateSearch:e=>({category:Dj(e.category)}),component:h4}),o4=la({getParentRoute:()=>Y2,path:`entries/new`,validateSearch:e=>{let t=Dj(e.category);return typeof e.from==`string`?{category:t,from:e.from}:{category:t}},component:g4}),s4=la({getParentRoute:()=>Y2,path:`entries/$entryId`,component:_4}),c4=la({getParentRoute:()=>Y2,path:`settings`,component:M2}),l4=la({getParentRoute:()=>Y2,path:`usage`,component:z2});function u4(){let{projectId:e}=t4.useParams();return(0,h.jsx)(Lq,{projectId:e},e)}function d4(){let{kind:e}=n4.useSearch(),t=Gi();return(0,h.jsx)(eJ,{kind:e,onKind:e=>{t({to:`/prompts`,search:{kind:e},replace:!0})}})}function f4(){let{kind:e,from:t}=r4.useSearch(),n=m4();return(0,h.jsx)(Yq,{promptId:void 0,kind:e,from:t,onLeave:n},`${e}:${t??`new`}`)}function p4(){let{promptId:e}=i4.useParams(),t=m4();return(0,h.jsx)(Yq,{promptId:e,kind:`article`,from:void 0,onLeave:t},e)}function m4(){let e=Gi();return t=>{e({to:`/prompts`,search:{kind:t}})}}function h4(){let{category:e}=a4.useSearch(),t=Gi();return(0,h.jsx)(Wj,{category:e,onCategory:e=>{t({to:`/entries`,search:{category:e},replace:!0})}})}function g4(){let{category:e,from:t}=o4.useSearch(),n=v4();return(0,h.jsx)(OM,{entryId:void 0,category:e,from:t,onLeave:n})}function _4(){let{entryId:e}=s4.useParams(),t=v4();return(0,h.jsx)(OM,{entryId:e,category:`intro`,from:void 0,onLeave:t})}function v4(){let e=Gi();return t=>{e({to:`/entries`,search:{category:t}})}}var y4=Y2.addChildren({projectsRoute:X2,playRoute:Z2,templatesRoute:Q2,schedulesRoute:$2,projectRoute:t4,promptsRoute:n4,newPromptRoute:r4,promptRoute:i4,entriesRoute:a4,newEntryRoute:o4,entryRoute:s4,settingsRoute:c4,usageRoute:l4});function b4(){return Oa({routeTree:y4})}function x4(){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 S4(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 C4(e){let t=x4(),n={api:oo(window.location.origin,S4(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:b4()})})})}))}var w4=document.getElementById(`root`);if(w4===null)throw Error(`index.html carries no #root element for the app to mount on`);C4(w4);
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),EJ=Y.default.BigInt(0),DJ=Y.default.BigInt(1),OJ=Y.default.BigInt(2),kJ=Y.default.BigInt(10),AJ=Y.default.BigInt(24),jJ=Y.default.BigInt(60),MJ=Y.default.BigInt(1e3),NJ=Y.default.BigInt(1e6),PJ=Y.default.BigInt(1e9),FJ=Y.default.multiply(Y.default.BigInt(3600),PJ),IJ=Y.default.multiply(jJ,PJ),LJ=Y.default.multiply(FJ,AJ);function RJ(e){return typeof e==`bigint`?Y.default.BigInt(e.toString(10)):e}function zJ(e){return Y.default.equal(Y.default.remainder(e,OJ),EJ)}function BJ(e){return Y.default.lessThan(e,EJ)?Y.default.unaryMinus(e):e}function VJ(e,t){return Y.default.lessThan(e,t)?-1:+!!Y.default.greaterThan(e,t)}function HJ(e,t){return{quotient:Y.default.divide(e,t),remainder:Y.default.remainder(e,t)}}var UJ,WJ,GJ=`slot-epochNanoSeconds`,KJ=`slot-iso-date`,qJ=`slot-iso-date-time`,JJ=`slot-time`,X=`slot-calendar`,YJ=`slot-date-brand`,XJ=`slot-year-month-brand`,ZJ=`slot-month-day-brand`,QJ=`slot-time-zone`,$J=`slot-years`,eY=`slot-months`,tY=`slot-weeks`,nY=`slot-days`,rY=`slot-hours`,iY=`slot-minutes`,aY=`slot-seconds`,oY=`slot-milliseconds`,sY=`slot-microseconds`,cY=`slot-nanoseconds`,lY=`date`,uY=`ym`,dY=`md`,fY=`time`,pY=`datetime`,mY=`instant`,hY=`original`,gY=`timezone-canonical`,_Y=`timezone-original`,vY=`calendar-id`,yY=`locale`,bY=`options`,xY=new WeakMap,SY=Symbol.for(`@@Temporal__GetSlots`);(UJ=globalThis)[SY]||(UJ[SY]=function(e){return xY.get(e)});var CY=globalThis[SY],wY=Symbol.for(`@@Temporal__CreateSlots`);(WJ=globalThis)[wY]||(WJ[wY]=function(e){xY.set(e,Object.create(null))});var TY=globalThis[wY];function EY(e,...t){if(!e||typeof e!=`object`)return!1;let n=CY(e);return!!n&&t.every((e=>e in n))}function Z(e,t){let n=CY(e)?.[t];if(n===void 0)throw TypeError(`Missing internal slot ${t}`);return n}function DY(e,t,n){let r=CY(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 OY={};function kY(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))}AY(t,e),AY(`${t}.prototype`,e.prototype)}function AY(e,t){let n=`%${e}%`;if(OY[n]!==void 0)throw Error(`intrinsic ${e} already exists`);OY[n]=t}function jY(e){return OY[e]}function MY(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 NY(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 PY(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 FY(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 IY=class e{constructor(e){this.totalNs=RJ(e),this.sec=Y.default.toNumber(Y.default.divide(this.totalNs,PJ)),this.subsec=Y.default.toNumber(Y.default.remainder(this.totalNs,PJ))}static validateNew(t,n){if(Y.default.greaterThan(BJ(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(RJ(t),RJ(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),MJ)),Y.default.multiply(Y.default.BigInt(i),NJ)),Y.default.multiply(Y.default.BigInt(r),PJ)),Y.default.multiply(Y.default.BigInt(n),IJ)),Y.default.multiply(Y.default.BigInt(t),FJ));return e.validateNew(s,`total`)}abs(){return new e(BJ(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),LJ)),`sum`)}addToEpochNs(e){return Y.default.add(RJ(e),this.totalNs)}cmp(e){return VJ(this.totalNs,e.totalNs)}divmod(t){let{quotient:n,remainder:r}=HJ(this.totalNs,Y.default.BigInt(t));return{quotient:Y.default.toNumber(n),remainder:new e(r)}}fdiv(e){let t=RJ(e),n=Y.default.BigInt(t),{quotient:r,remainder:i}=HJ(this.totalNs,n),a=[],o,s=(Y.default.lessThan(this.totalNs,EJ)?-1:1)*Math.sign(Y.default.toNumber(t));for(;!Y.default.equal(i,EJ)&&a.length<50;)i=Y.default.multiply(i,kJ),{quotient:o,remainder:i}=HJ(i,n),a.push(Math.abs(Y.default.toNumber(o)));return s*Number(BJ(r).toString()+`.`+a.join(``))}isZero(){return Y.default.equal(this.totalNs,EJ)}round(t,n){let r=RJ(t);if(Y.default.equal(r,DJ))return this;let{quotient:i,remainder:a}=HJ(this.totalNs,r),o=Y.default.lessThan(this.totalNs,EJ)?`negative`:`positive`,s=Y.default.multiply(BJ(i),r),c=Y.default.add(s,r),l=VJ(BJ(Y.default.multiply(a,OJ)),r),u=PY(n,o),d=Y.default.equal(BJ(this.totalNs),s)?s:FY(s,c,l,zJ(i),u),f=o===`positive`?d:Y.default.unaryMinus(d);return e.validateNew(f,`rounding`)}sign(){return this.cmp(new e(EJ))}subtract(t){return e.validateNew(Y.default.subtract(this.totalNs,t.totalNs),`difference`)}};IY.MAX=Y.default.BigInt(`9007199254740991999999999`),IY.ZERO=new IY(EJ);var LY=/[A-Za-z._][A-Za-z._0-9+-]*/,RY=RegExp(`(?:(?:[+-](?:[01][0-9]|2[0-3])(?::?[0-5][0-9])?)|(?:${LY.source})(?:\\/(?:${LY.source}))*)`),zY=/(?:[+-]\d{6}|\d{4})/,BY=/(?:0[1-9]|1[0-2])/,VY=/(?:0[1-9]|[12]\d|3[01])/,HY=RegExp(`(${zY.source})(?:-(${BY.source})-(${VY.source})|(${BY.source})(${VY.source}))`),UY=/(\d{2})(?::(\d{2})(?::(\d{2})(?:[.,](\d{1,9}))?)?|(\d{2})(?:(\d{2})(?:[.,](\d{1,9}))?)?)?/,WY=/((?:[+-])(?:[01][0-9]|2[0-3])(?::?(?:[0-5][0-9])(?::?(?:[0-5][0-9])(?:[.,](?:\d{1,9}))?)?)?)/,GY=RegExp(`([zZ])|${WY.source}?`),KY=/\[(!)?([a-z_][a-z0-9_-]*)=([A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)\]/g,qY=new RegExp([`^${HY.source}`,`(?:(?:[tT]|\\s+)${UY.source}(?:${GY.source})?)?`,`(?:\\[!?(${RY.source})\\])?`,`((?:${KY.source})*)$`].join(``)),JY=new RegExp([`^[tT]?${UY.source}`,`(?:${GY.source})?`,`(?:\\[!?${RY.source}\\])?`,`((?:${KY.source})*)$`].join(``)),YY=RegExp(`^(${zY.source})-?(${BY.source})(?:\\[!?${RY.source}\\])?((?:${KY.source})*)$`),XY=RegExp(`^(?:--)?(${BY.source})-?(${VY.source})(?:\\[!?${RY.source}\\])?((?:${KY.source})*)$`),ZY=/(\d+)(?:[.,](\d{1,9}))?/,QY=RegExp(`(?:${ZY.source}H)?(?:${ZY.source}M)?(?:${ZY.source}S)?`),$Y=RegExp(`^([+-])?P(?:(\\d+)Y)?(?:(\\d+)M)?(?:(\\d+)W)?(?:(\\d+)D)?(?:T(?!$)${QY.source})?$`,`i`),eX=864e5,tX=1e6*eX,nX=6e10,rX=1e8*eX,iX=n1(rX),aX=Y.default.unaryMinus(iX),oX=Y.default.add(Y.default.subtract(aX,LJ),DJ),sX=Y.default.subtract(Y.default.add(iX,LJ),DJ),cX=146097*eX,lX=-271821,uX=275760,dX=Date.UTC(1847,0,1),fX=[`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`],pX=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 mX(e){return typeof e==`object`&&!!e||typeof e==`function`}function hX(e){if(typeof e==`bigint`)throw TypeError(`Cannot convert BigInt to number`);return Number(e)}function gX(e){if(typeof e==`symbol`)throw TypeError(`Cannot convert a Symbol value to a String`);return String(e)}function _X(e){let t=hX(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 vX(e,t){let n=_X(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 yX(e){let t=hX(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 bX(e,t){return String(e).padStart(t,`0`)}function xX(e){if(typeof e!=`string`)throw TypeError(`expected a string, not ${String(e)}`);return e}function SX(e,t){if(mX(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 CX=[`era`,`eraYear`,`year`,`month`,`monthCode`,`day`,`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`,`offset`,`timeZone`],wX={era:gX,eraYear:_X,year:_X,month:vX,monthCode:function(e){let t=xX(SX(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:vX,hour:_X,minute:_X,second:_X,millisecond:_X,microsecond:_X,nanosecond:_X,offset:function(e){let t=xX(SX(e));return kQ(t),t},timeZone:sQ},TX={hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0},EX=[[`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`]],DX=Object.fromEntries(EX.map((e=>[e[0],e[1]]))),OX=Object.fromEntries(EX.map((([e,t])=>[t,e]))),kX=EX.map((([,e])=>e)),AX={day:tX,hour:36e11,minute:6e10,second:1e9,millisecond:1e6,microsecond:1e3,nanosecond:1},jX=[`days`,`hours`,`microseconds`,`milliseconds`,`minutes`,`months`,`nanoseconds`,`seconds`,`weeks`,`years`],MX=Intl.DateTimeFormat,NX=new Map;function PX(e){let t=u1(e),n=NX.get(t);return n===void 0&&(n=new MX(`en-us`,{timeZone:t,hour12:!1,era:`short`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`}),NX.set(t,n)),n}function FX(e){return EY(e,GJ)&&!EY(e,QJ,X)}function IX(e){return EY(e,$J,eY,nY,rY,iY,aY,oY,sY,cY)}function LX(e){return EY(e,YJ)}function RX(e){return EY(e,JJ)}function zX(e){return EY(e,qJ)}function BX(e){return EY(e,XJ)}function VX(e){return EY(e,ZJ)}function HX(e){return EY(e,GJ,QJ,X)}function Q(e,t){if(!t(e))throw TypeError(`invalid receiver: method called with the wrong type of this-object`)}function UX(e){if(EY(e,X)||EY(e,QJ))throw TypeError(`with() does not support a calendar or timeZone property`);if(RX(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 WX(e,t){return t===`never`||t===`auto`&&e===`iso8601`?``:`[${t===`critical`?`!`:``}u-ca=${e}]`}function GX(e){let t,n,r=!1;for(KY.lastIndex=0;n=KY.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 KX(e){let t=qY.exec(e);if(!t)throw RangeError(`invalid RFC 9557 string: ${e}`);let n=GX(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 o$(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 qX(e){let t=JY.exec(e),n,r,i,a,o,s,c;if(t){c=GX(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}=KX(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(a$(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}=YX(e);r$(1972,t,n)}catch{try{let{year:t,month:n}=JX(e);r$(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 JX(e){let t=YY.exec(e),n,r,i,a;if(t){i=GX(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}=KX(e),t)throw RangeError(`Z designator not supported for PlainYearMonth`)}return{year:n,month:r,calendar:i,referenceISODay:a}}function YX(e){let t=XY.exec(e),n,r,i,a;if(t){if(i=GX(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}=KX(e),t)throw RangeError(`Z designator not supported for PlainMonthDay`)}return{month:n,day:r,calendar:i,referenceISOYear:a}}var XX=RegExp(`^${RY.source}$`,`i`),ZX=RegExp(`^([+-])([01][0-9]|2[0-3])(?::?([0-5][0-9])?)?$`);function QX(e){let t=f1.test(e)?`Seconds not allowed in offset time zone`:`Invalid time zone`;throw RangeError(`${t}: ${e}`)}function $X(e){return XX.test(e)||QX(e),ZX.test(e)?{offsetMinutes:kQ(e)/6e10}:{tzName:e}}function eZ(e,t,n,r){let i=e,a=t,o=n;switch(r){case`reject`:r$(i,a,o);break;case`constrain`:({year:i,month:a,day:o}=t$(i,a,o))}return{year:i,month:a,day:o}}function tZ(e,t,n,r,i,a,o){let s=e,c=t,l=n,u=r,d=i,f=a;switch(o){case`reject`:a$(s,c,l,u,d,f);break;case`constrain`:s=e$(s,0,23),c=e$(c,0,59),l=e$(l,0,59),u=e$(u,0,999),d=e$(d,0,999),f=e$(f,0,999)}return{hour:s,minute:c,second:l,millisecond:u,microsecond:d,nanosecond:f}}function nZ(e){if(!mX(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<jX.length;r++){let i=jX[r],a=e[i];a!==void 0&&(n=!0,t[i]=yX(a))}if(!n)throw TypeError(`invalid duration-like`);return t}function rZ({years:e,months:t,weeks:n,days:r},i,a,o){return{years:e,months:o??t,weeks:a??n,days:i??r}}function iZ(e,t){return{isoDate:e,time:t}}function aZ(e){return c1(e,`overflow`,[`constrain`,`reject`],`constrain`)}function oZ(e){return c1(e,`disambiguation`,[`compatible`,`earlier`,`later`,`reject`],`compatible`)}function sZ(e,t){return c1(e,`roundingMode`,[`ceil`,`floor`,`expand`,`trunc`,`halfCeil`,`halfFloor`,`halfExpand`,`halfTrunc`,`halfEven`],t)}function cZ(e,t){return c1(e,`offset`,[`prefer`,`use`,`ignore`,`reject`],t)}function lZ(e){return c1(e,`calendarName`,[`auto`,`always`,`never`,`critical`],`auto`)}function uZ(e){let t=e.roundingIncrement;if(t===void 0)return 1;let n=_X(t);if(n<1||n>1e9)throw RangeError(`roundingIncrement must be at least 1 and at most 1e9, not ${t}`);return n}function dZ(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 fZ(e){let t=e.fractionalSecondDigits;if(t===void 0)return`auto`;if(typeof t!=`number`){if(gX(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 pZ(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 mZ=Symbol(`~required~`);function hZ(e,t,n,r,i=[]){let a=[];for(let e=0;e<EX.length;e++){let t=EX[e],r=t[1],i=t[2];n!==`datetime`&&n!==i||a.push(r)}a=a.concat(i);let o=r;o===mZ?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=OX[a[e]];t!==void 0&&s.push(t)}let c=c1(e,t,s,o);if(c===void 0&&r===mZ)throw RangeError(`${t} is required`);return c&&c in DX?DX[c]:c}function gZ(e){let t=e.relativeTo;if(t===void 0)return{};let n,r,i,a,o,s=`option`,c=!1;if(mX(t)){if(HX(t))return{zonedRelativeTo:t};if(LX(t))return{plainRelativeTo:t};if(zX(t))return{plainRelativeTo:RZ(Z(t,qJ).isoDate,Z(t,X))};i=nQ(t);let e=wZ(i,t,[`year`,`month`,`monthCode`,`day`],[`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`,`offset`,`timeZone`],[]);({isoDate:n,time:r}=DZ(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}=KX(xX(t)),e)a=sQ(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=l1(i),n={year:u,month:d,day:f}}return a===void 0?{plainRelativeTo:RZ(n,i)}:{zonedRelativeTo:XZ(FZ(n,r,s,s===`option`?kQ(o):0,a,`compatible`,`reject`,c),a,i)}}function _Z(e){return Z(e,$J)===0?Z(e,eY)===0?Z(e,tY)===0?Z(e,nY)===0?Z(e,rY)===0?Z(e,iY)===0?Z(e,aY)===0?Z(e,oY)===0?Z(e,sY)===0?`nanosecond`:`microsecond`:`millisecond`:`second`:`minute`:`hour`:`day`:`week`:`month`:`year`}function vZ(e,t){return kX.indexOf(e)>kX.indexOf(t)?t:e}function yZ(e){return e===`year`||e===`month`||e===`week`}function bZ(e){return yZ(e)||e===`day`?`date`:`time`}function xZ(e){return jY(`%calendarImpl%`)(e)}function SZ(e){return jY(`%calendarImpl%`)(Z(e,X))}function CZ(e,t,n=`date`){let r=Object.create(null),i=xZ(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 wZ(e,t,n,r,i){let a=xZ(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,wX[n])(r);else if(i!==`partial`){if(i.includes(n))throw TypeError(`required property '${n}' missing or undefined`);s[n]=TX[n]}}if(i===`partial`&&!c)throw TypeError(`no supported properties found`);return s}function TZ(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]=_X(s),r=!0)}if(!r)throw TypeError(`invalid time-like`);return i}function EZ(e,t){if(mX(e)){if(LX(e))return aZ($(t)),RZ(Z(e,KJ),Z(e,X));if(HX(e)){let n=dQ(Z(e,QJ),Z(e,GJ));return aZ($(t)),RZ(n.isoDate,Z(e,X))}if(zX(e))return aZ($(t)),RZ(Z(e,qJ).isoDate,Z(e,X));let n=nQ(e);return RZ(iQ(n,wZ(n,e,[`year`,`month`,`monthCode`,`day`],[],[]),aZ($(t))),n)}let{year:n,month:r,day:i,calendar:a,z:o}=KX(xX(e));if(o)throw RangeError(`Z designator not supported for PlainDate`);return a||=`iso8601`,a=l1(a),aZ($(t)),RZ({year:n,month:r,day:i},a)}function DZ(e,t,n){return iZ(iQ(e,t,n),tZ(t.hour,t.minute,t.second,t.millisecond,t.microsecond,t.nanosecond,n))}function OZ(e,t){let n,r,i;if(mX(e)){if(zX(e))return aZ($(t)),BZ(Z(e,qJ),Z(e,X));if(HX(e)){let n=dQ(Z(e,QJ),Z(e,GJ));return aZ($(t)),BZ(n,Z(e,X))}if(LX(e))return aZ($(t)),BZ(iZ(Z(e,KJ),{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),Z(e,X));i=nQ(e);let a=wZ(i,e,[`year`,`month`,`monthCode`,`day`],[`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`],[]),o=aZ($(t));({isoDate:n,time:r}=DZ(i,a,o))}else{let a,o,s,c;if({year:o,month:s,day:c,time:r,calendar:i,z:a}=KX(xX(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}),o$(o,s,c,r.hour,r.minute,r.second,r.millisecond,r.microsecond,r.nanosecond),i||=`iso8601`,i=l1(i),aZ($(t)),n={year:o,month:s,day:c}}return BZ(iZ(n,r),i)}function kZ(e){let t=jY(`%Temporal.Duration%`);if(IX(e))return new t(Z(e,$J),Z(e,eY),Z(e,tY),Z(e,nY),Z(e,rY),Z(e,iY),Z(e,aY),Z(e,oY),Z(e,sY),Z(e,cY));if(!mX(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=$Y.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:_X(t[2])*n,i=t[3]===void 0?0:_X(t[3])*n,a=t[4]===void 0?0:_X(t[4])*n,o=t[5]===void 0?0:_X(t[5])*n,s=t[6]===void 0?0:_X(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*_X((c+`000000000`).slice(0,9))*n}else if(p=l===void 0?0:_X(l)*n,u!==void 0){if(d??f)throw RangeError(`only the smallest unit can be fractional`);h=60*_X((u+`000000000`).slice(0,9))*n}else m=d===void 0?0:_X(d)*n,f!==void 0&&(h=_X((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),d$(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(jY(`%Temporal.Duration%`))(t,n,r,i,a,o,s,c,l,u)}(xX(e));let n={years:0,months:0,weeks:0,days:0,hours:0,minutes:0,seconds:0,milliseconds:0,microseconds:0,nanoseconds:0},r=nZ(e);for(let e=0;e<jX.length;e++){let t=jX[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 AZ(e){let t;if(mX(e)){if(FX(e)||HX(e))return JZ(Z(e,GJ));t=SX(e)}else t=e;let{year:n,month:r,day:i,time:a,offset:o,z:s}=function(e){let t=KX(e);if(!t.z&&!t.offset)throw RangeError(`Temporal.Instant requires a time zone offset`);return t}(xX(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=XQ(n,r,i,c,l,u,d,f,p-(s?0:kQ(o)));return v$(m.isoDate),JZ(RQ(m))}function jZ(e,t){if(mX(e)){if(VX(e))return aZ($(t)),HZ(Z(e,KJ),Z(e,X));let n;return EY(e,X)?n=Z(e,X):(n=e.calendar,n===void 0&&(n=`iso8601`),n=tQ(n)),HZ(oQ(n,wZ(n,e,[`year`,`month`,`monthCode`,`day`],[],[]),aZ($(t))),n)}let{month:n,day:r,referenceISOYear:i,calendar:a}=YX(xX(e));if(a===void 0&&(a=`iso8601`),a=l1(a),aZ($(t)),a===`iso8601`)return HZ({year:1972,month:n,day:r},a);let o={year:i,month:n,day:r};return i$(o),o=oQ(a,CZ(a,o,`month-day`),`constrain`),HZ(o,a)}function MZ(e,t){let n;if(mX(e)){if(RX(e))return aZ($(t)),WZ(Z(e,JJ));if(zX(e))return aZ($(t)),WZ(Z(e,qJ).time);if(HX(e)){let n=dQ(Z(e,QJ),Z(e,GJ));return aZ($(t)),WZ(n.time)}let{hour:r,minute:i,second:a,millisecond:o,microsecond:s,nanosecond:c}=TZ(e);n=tZ(r,i,a,o,s,c,aZ($(t)))}else n=qX(xX(e)),aZ($(t));return WZ(n)}function NZ(e){return e===void 0?{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}:Z(MZ(e),JJ)}function PZ(e,t){if(mX(e)){if(BX(e))return aZ($(t)),KZ(Z(e,KJ),Z(e,X));let n=nQ(e);return KZ(aQ(n,wZ(n,e,[`year`,`month`,`monthCode`],[],[]),aZ($(t))),n)}let{year:n,month:r,referenceISODay:i,calendar:a}=JX(xX(e));a===void 0&&(a=`iso8601`),a=l1(a),aZ($(t));let o={year:n,month:r,day:i};return u$(o),o=aQ(a,CZ(a,o,`year-month`),`constrain`),KZ(o,a)}function FZ(e,t,n,r,i,a,o,s){if(t===`start-of-day`)return hQ(i,e);let c=iZ(e,t);if(n===`wall`||o===`ignore`)return fQ(i,c,a);if(n===`exact`||o===`use`){let n=XQ(e.year,e.month,e.day,t.hour,t.minute,t.second,t.millisecond,t.microsecond,t.nanosecond-r);v$(n.isoDate);let i=RQ(n);return l$(i),i}v$(e);let l=RQ(c),u=mQ(i,c);for(let e=0;e<u.length;e++){let t=u[e],n=Y.default.toNumber(Y.default.subtract(l,t)),i=G$(n,6e10,`halfExpand`);if(n===r||s&&i===r)return t}if(o===`reject`){let e=uQ(r),t=wQ(c,`iso8601`,`auto`);throw RangeError(`Offset ${e} is invalid for ${t} in ${i}`)}return pQ(u,i,c,a)}function IZ(e,t){let n,r,i,a,o,s,c,l=!1,u=`option`;if(mX(e)){if(HX(e)){let n=$(t);return oZ(n),cZ(n,`reject`),aZ(n),XZ(Z(e,GJ),Z(e,QJ),Z(e,X))}o=nQ(e);let l=wZ(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=oZ(d),c=cZ(d,`reject`);let f=aZ(d);({isoDate:n,time:r}=DZ(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=KX(e);if(!t.tzAnnotation)throw RangeError(`Temporal.ZonedDateTime requires a time zone ID in brackets`);return t}(xX(e))),i=sQ(d),f?u=`exact`:a||(u=`wall`),o||=`iso8601`,o=l1(o),l=!0;let g=$(t);s=oZ(g),c=cZ(g,`reject`),aZ(g),n={year:p,month:m,day:h}}let d=0;return u===`option`&&(d=kQ(a)),XZ(FZ(n,r,u,d,i,s,c,l),i,o)}function LZ(e,t,n){i$(t),TY(e),DY(e,KJ,t),DY(e,X,n),DY(e,YJ,!0)}function RZ(e,t){let n=jY(`%Temporal.PlainDate%`),r=Object.create(n.prototype);return LZ(r,e,t),r}function zZ(e,t,n){s$(t),TY(e),DY(e,qJ,t),DY(e,X,n)}function BZ(e,t){let n=jY(`%Temporal.PlainDateTime%`),r=Object.create(n.prototype);return zZ(r,e,t),r}function VZ(e,t,n){i$(t),TY(e),DY(e,KJ,t),DY(e,X,n),DY(e,ZJ,!0)}function HZ(e,t){let n=jY(`%Temporal.PlainMonthDay%`),r=Object.create(n.prototype);return VZ(r,e,t),r}function UZ(e,t){TY(e),DY(e,JJ,t)}function WZ(e){let t=jY(`%Temporal.PlainTime%`),n=Object.create(t.prototype);return UZ(n,e),n}function GZ(e,t,n){u$(t),TY(e),DY(e,KJ,t),DY(e,X,n),DY(e,XJ,!0)}function KZ(e,t){let n=jY(`%Temporal.PlainYearMonth%`),r=Object.create(n.prototype);return GZ(r,e,t),r}function qZ(e,t){l$(t),TY(e),DY(e,GJ,t)}function JZ(e){let t=jY(`%Temporal.Instant%`),n=Object.create(t.prototype);return qZ(n,e),n}function YZ(e,t,n,r){l$(t),TY(e),DY(e,GJ,t),DY(e,QJ,n),DY(e,X,r)}function XZ(e,t,n=`iso8601`){let r=jY(`%Temporal.ZonedDateTime%`),i=Object.create(r.prototype);return YZ(i,e,t,n),i}function ZZ(e){return CX.filter((t=>e[t]!==void 0))}function QZ(e,t,n){let r=ZZ(n),i=xZ(e).fieldKeysToIgnore(r),a=Object.create(null),o=ZZ(t);for(let e=0;e<CX.length;e++){let s,c=CX[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 $Z(e,t,n,r){let i=xZ(e).dateAdd(t,n,r);return i$(i),i}function eQ(e,t,n,r){return xZ(e).dateUntil(t,n,r)}function tQ(e){if(mX(e)&&EY(e,X))return Z(e,X);let t=xX(e);try{return l1(t)}catch{}let n;try{({calendar:n}=KX(t))}catch{try{({calendar:n}=qX(t))}catch{try{({calendar:n}=JX(t))}catch{({calendar:n}=YX(t))}}}return n||=`iso8601`,l1(n)}function nQ(e){if(EY(e,X))return Z(e,X);let{calendar:t}=e;return t===void 0?`iso8601`:tQ(t)}function rQ(e,t){return l1(e)===l1(t)}function iQ(e,t,n){let r=xZ(e);r.resolveFields(t,`date`);let i=r.dateToISO(t,n);return i$(i),i}function aQ(e,t,n){let r=xZ(e);r.resolveFields(t,`year-month`),t.day=1;let i=r.dateToISO(t,n);return u$(i),i}function oQ(e,t,n){let r=xZ(e);r.resolveFields(t,`month-day`);let i=r.monthDayToISOReferenceDate(t,n);return i$(i),i}function sQ(e){if(mX(e)&&HX(e))return Z(e,QJ);let t=xX(e);if(t===`UTC`)return`UTC`;let{tzName:n,offsetMinutes:r}=function(e){let{tzAnnotation:t,offset:n,z:r}=function(e){if(XX.test(e))return{tzAnnotation:e,offset:void 0,z:!1};try{let{tzAnnotation:t,offset:n,z:r}=KX(e);if(r||t||n)return{tzAnnotation:t,offset:n,z:r}}catch{}QX(e)}(e);return t?$X(t):r?$X(`UTC`):n?$X(n):void 0}(t);if(r!==void 0)return FQ(r);let i=MQ(n);if(!i)throw RangeError(`Unrecognized time zone ${n}`);return i.identifier}function cQ(e,t){if(e===t)return!0;let n=$X(e).offsetMinutes,r=$X(t).offsetMinutes;if(n===void 0&&r===void 0){let n=MQ(t);if(!n)return!1;let r=MQ(e);return!!r&&r.primaryIdentifier===n.primaryIdentifier}return n===r}function lQ(e,t){let n=$X(e).offsetMinutes;return n===void 0?PQ(e,t):6e10*n}function uQ(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}${yQ(r,i,a,o,a===0&&o===0?`minute`:`auto`)}`}function dQ(e,t){let n=lQ(e,t),{isoDate:{year:r,month:i,day:a},time:{hour:o,minute:s,second:c,millisecond:l,microsecond:u,nanosecond:d}}=zQ(t);return XQ(r,i,a,o,s,c,l,u,d+n)}function fQ(e,t,n){return pQ(mQ(e,t),e,t,n)}function pQ(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=RQ(n),o=Y.default.subtract(a,LJ);l$(o);let s=lQ(t,o),c=Y.default.add(a,LJ);l$(c);let l=lQ(t,c)-s;switch(r){case`earlier`:{let e=IY.fromComponents(0,0,0,0,0,-l),r=F$(n.time,e);return mQ(t,iZ(YQ(n.isoDate.year,n.isoDate.month,n.isoDate.day+r.deltaDays),r))[0]}case`compatible`:case`later`:{let e=IY.fromComponents(0,0,0,0,0,l),r=F$(n.time,e),i=mQ(t,iZ(YQ(n.isoDate.year,n.isoDate.month,n.isoDate.day+r.deltaDays),r));return i[i.length-1]}}}function mQ(e,t){if(e===`UTC`)return v$(t.isoDate),[RQ(t)];let n=$X(e).offsetMinutes;if(n!==void 0){let e=XQ(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);v$(e.isoDate);let r=RQ(e);return l$(r),[r]}return v$(t.isoDate),function(e,t){let n=RQ(t),r=Y.default.subtract(n,LJ);Y.default.lessThan(r,aX)&&(r=n);let i=Y.default.add(n,LJ);Y.default.greaterThan(i,iX)&&(i=n);let a=PQ(e,r),o=PQ(e,i);return(a===o?[a]:[a,o]).map((r=>{let i=Y.default.subtract(n,Y.default.BigInt(r));if($$(t,function(e,t){let{epochMilliseconds:n,time:{millisecond:r,microsecond:i,nanosecond:a}}=zQ(t),{year:o,month:s,day:c,hour:l,minute:u,second:d}=HQ(e,n);return XQ(o,s,c,l,u,d,r,i,a)}(e,i))===0)return l$(i),i})).filter((e=>e!==void 0))}(e,t)}function hQ(e,t){let n=iZ(t,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),r=mQ(e,n);if(r.length)return r[0];let i=RQ(n),a=Y.default.subtract(i,LJ);return l$(a),BQ(e,a)}function gQ(e){let t;return t=e<0||e>9999?(e<0?`-`:`+`)+bX(Math.abs(e),6):bX(e,4),t}function _Q(e){return bX(e,2)}function vQ(e,t){let n;if(t===`auto`){if(e===0)return``;n=bX(e,9).replace(/0+$/,``)}else{if(t===0)return``;n=bX(e,9).slice(0,t)}return`.${n}`}function yQ(e,t,n,r,i){let a=`${_Q(e)}:${_Q(t)}`;return i===`minute`||(a+=`:${_Q(n)}`,a+=vQ(r,i)),a}function bQ(e,t,n){let r=t;r===void 0&&(r=`UTC`);let i=Z(e,GJ),a=wQ(dQ(r,i),`iso8601`,n,`never`),o=`Z`;return t!==void 0&&(o=IQ(lQ(r,i))),`${a}${o}`}function xQ(e,t){let n=Z(e,$J),r=Z(e,eY),i=Z(e,tY),a=Z(e,nY),o=Z(e,rY),s=Z(e,iY),c=GQ(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=IY.fromComponents(0,0,Z(e,aY),Z(e,oY),Z(e,sY),Z(e,cY));d.isZero()&&![`second`,`millisecond`,`microsecond`,`nanosecond`].includes(_Z(e))&&t===`auto`||(u+=`${Math.abs(d.sec)}${vQ(Math.abs(d.subsec),t)}S`);let f=`${c<0?`-`:``}P${l}`;return u&&(f=`${f}T${u}`),f}function SQ(e,t=`auto`){let{year:n,month:r,day:i}=Z(e,KJ);return`${gQ(n)}-${_Q(r)}-${_Q(i)}${WX(Z(e,X),t)}`}function CQ({hour:e,minute:t,second:n,millisecond:r,microsecond:i,nanosecond:a},o){return yQ(e,t,n,1e6*r+1e3*i+a,o)}function wQ(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`${gQ(i)}-${_Q(a)}-${_Q(o)}T${yQ(s,c,l,1e6*u+1e3*d+f,n)}${WX(t,r)}`}function TQ(e,t=`auto`){let{year:n,month:r,day:i}=Z(e,KJ),a=`${_Q(r)}-${_Q(i)}`,o=Z(e,X);t!==`always`&&t!==`critical`&&o===`iso8601`||(a=`${gQ(n)}-${a}`);let s=WX(o,t);return s&&(a+=s),a}function EQ(e,t=`auto`){let{year:n,month:r,day:i}=Z(e,KJ),a=`${gQ(n)}-${_Q(r)}`,o=Z(e,X);t!==`always`&&t!==`critical`&&o===`iso8601`||(a+=`-${_Q(i)}`);let s=WX(o,t);return s&&(a+=s),a}function DQ(e,t,n=`auto`,r=`auto`,i=`auto`,a=void 0){let o=Z(e,GJ);if(a){let{unit:e,increment:t,roundingMode:n}=a;o=K$(o,t,e,n)}let s=Z(e,QJ),c=lQ(s,o),l=wQ(dQ(s,o),`iso8601`,t,`never`);return i!==`never`&&(l+=IQ(c)),r!==`never`&&(l+=`[${r===`critical`?`!`:``}${s}]`),l+=WX(Z(e,X),n),l}function OQ(e){return ZX.test(e)}function kQ(e){let t=p1.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 AQ,jQ=Object.assign(Object.create(null),{"/":!0,"-":!0,_:!0});function MQ(e){if(AQ===void 0){let e=Intl.supportedValuesOf?.(`timeZone`);if(e){AQ=new Map;for(let t=0;t<e.length;t++){let n=e[t];AQ.set(u1(n),n)}}else AQ=null}let t=u1(e),n=AQ?.get(t);if(n)return{identifier:n,primaryIdentifier:n};try{n=PX(e).resolvedOptions().timeZone}catch{return}if(t===`antarctica/south_pole`&&(n=`Antarctica/McMurdo`),pX.has(e))throw RangeError(`${e} is a legacy time zone identifier from ICU. Use ${n} instead`);let r=[...t].map(((e,n)=>n===0||jQ[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 NQ(e,t){let{year:n,month:r,day:i,hour:a,minute:o,second:s}=HQ(e,t),c=t%1e3;return c<0&&(c+=1e3),1e6*(LQ({isoDate:{year:n,month:r,day:i},time:{hour:a,minute:o,second:s,millisecond:c}})-t)}function PQ(e,t){return NQ(e,t1(t,`floor`))}function FQ(e){let t=e<0?`-`:`+`,n=Math.abs(e);return`${t}${yQ(Math.floor(n/60),n%60,0,0,`minute`)}`}function IQ(e){return FQ(G$(e,nX,`halfExpand`)/6e10)}function LQ({isoDate:{year:e,month:t,day:n},time:{hour:r,minute:i,second:a,millisecond:o}}){let s=e%400,c=(e-s)/400,l=new Date;return l.setUTCHours(r,i,a,o),l.setUTCFullYear(s,t-1,n),l.getTime()+cX*c}function RQ(e){let t=LQ(e),n=1e3*e.time.microsecond+e.time.nanosecond;return Y.default.add(n1(t),Y.default.BigInt(n))}function zQ(e){let t=t1(e,`trunc`),n=Y.default.toNumber(Y.default.remainder(e,NJ));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 BQ(e,t){if(e===`UTC`)return null;let n=t1(t,`floor`);if(n<dX)return BQ(e,n1(dX));let r=Math.max(n,Date.now())+366*eX*3,i=n,a=NQ(e,i),o=i,s=a;for(;a===s&&i<r;){if(o=i+2*eX*7,o>rX)return null;s=NQ(e,o),a===s&&(i=o)}return a===s?null:n1(m1((t=>NQ(e,t)),i,o,a,s))}function VQ(e,t){if(e===`UTC`)return null;let n=t1(t,`ceil`),r=Date.now(),i=r+366*eX*3;if(n>i){let t=VQ(e,n1(i));if(t===null||Y.default.lessThan(t,n1(r)))return t}if(e===`Africa/Casablanca`||e===`Africa/El_Aaiun`){let t=Date.UTC(2088,0,1);if(t<n)return VQ(e,n1(t))}let a=n-1;if(a<dX)return null;let o=NQ(e,a),s=a,c=o;for(;o===c&&a>dX;){if(s=a-2*eX*7,s<dX)return null;c=NQ(e,s),o===c&&(a=s)}return o===c?null:n1(m1((t=>NQ(e,t)),s,a,c,o))}function HQ(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}}(PX(e).format(t))}function UQ(e){return e!==void 0&&!(e%4!=0||e%100==0&&e%400!=0)}function WQ(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]}[UQ(e)?`leapyear`:`standard`][t-1]}function GQ(e){let t=[Z(e,$J),Z(e,eY),Z(e,tY),Z(e,nY),Z(e,rY),Z(e,iY),Z(e,aY),Z(e,oY),Z(e,sY),Z(e,cY)];for(let e=0;e<t.length;e++){let n=t[e];if(n!==0)return n<0?-1:1}return 0}function KQ(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 qQ(e){let t=KQ(e.date);return t===0?e.time.sign():t}function JQ(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 YQ(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}=JQ(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=UQ(c)?366:365,a<-s;)--r,--c,a+=s;for(c+=1;s=UQ(c)?366:365,a>s;)r+=1,c+=1,a-=s;for(;a<1;)({year:r,month:i}=JQ(r,i-1)),a+=WQ(r,i);for(;a>WQ(r,i);)a-=WQ(r,i),{year:r,month:i}=JQ(r,i+1);return{year:r,month:i,day:a}}function XQ(e,t,n,r,i,a,o,s,c){let l=ZQ(r,i,a,o,s,c);return iZ(YQ(e,t,n+l.deltaDays),l)}function ZQ(e,t,n,r,i,a){let o,s=e,c=t,l=n,u=r,d=i,f=a;({div:o,mod:f}=MY(f,3)),d+=o,f<0&&(--d,f+=1e3),{div:o,mod:d}=MY(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 QQ(e,t){let n=rZ(e,0);if(KQ(n)===0)return e.days;let r=Z(t,KJ),i=$Z(Z(t,X),r,n,`constrain`),a=_$(r.year,r.month-1,r.day),o=_$(i.year,i.month-1,i.day)-a;return e.days+o}function $Q(e){return new(jY(`%Temporal.Duration%`))(-Z(e,$J),-Z(e,eY),-Z(e,tY),-Z(e,nY),-Z(e,rY),-Z(e,iY),-Z(e,aY),-Z(e,oY),-Z(e,sY),-Z(e,cY))}function e$(e,t,n){return Math.min(n,Math.max(t,e))}function t$(e,t,n){let r=e$(t,1,12);return{year:e,month:r,day:e$(n,1,WQ(e,r))}}function n$(e,t,n){if(e<t||e>n)throw RangeError(`value out of range: ${t} <= ${e} <= ${n}`)}function r$(e,t,n){n$(t,1,12),n$(n,1,WQ(e,t))}function i$(e){s$(iZ(e,{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}))}function a$(e,t,n,r,i,a){n$(e,0,23),n$(t,0,59),n$(n,0,59),n$(r,0,999),n$(i,0,999),n$(a,0,999)}function o$(e,t,n,r,i,a,o,s,c){r$(e,t,n),a$(r,i,a,o,s,c)}function s$(e){let t=RQ(e);(Y.default.lessThan(t,oX)||Y.default.greaterThan(t,sX))&&l$(t)}function c$(e){RQ(e)}function l$(e){if(Y.default.lessThan(e,aX)||Y.default.greaterThan(e,iX))throw RangeError(`date/time value is outside of supported range`)}function u$({year:e,month:t}){n$(e,lX,uX),e===lX?n$(t,4,12):e===uX&&n$(t,1,9)}function d$(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=MY(s,3),p=MY(c,6),m=MY(l,9),h=MY(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 f$(e){return{date:{years:Z(e,$J),months:Z(e,eY),weeks:Z(e,tY),days:Z(e,nY)},time:IY.fromComponents(Z(e,rY),Z(e,iY),Z(e,aY),Z(e,oY),Z(e,sY),Z(e,cY))}}function p$(e){let t=IY.fromComponents(Z(e,rY),Z(e,iY),Z(e,aY),Z(e,oY),Z(e,sY),Z(e,cY)).add24HourDays(Z(e,nY));return{date:{years:Z(e,$J),months:Z(e,eY),weeks:Z(e,tY),days:0},time:t}}function m$(e){let t=p$(e),n=Math.trunc(t.time.sec/86400);return d$(t.date.years,t.date.months,t.date.weeks,n,0,0,0,0,0,0),{...t.date,days:n}}function h$(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=NY(o,3,Math.trunc(i/1e3)),i%=1e3,o=0;break;case`microsecond`:i=NY(o,6,Math.trunc(r/1e3)),r%=1e3,o=0;break;case`nanosecond`:r=NY(o,9,r),o=0}return new(jY(`%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 g$(e,t){return KQ(e),t.sign(),{date:e,time:t}}function _$(e,t,n){return LQ({isoDate:{year:e,month:t+1,day:n},time:{hour:0,minute:0,second:0,millisecond:0}})/eX}function v$({year:e,month:t,day:n}){if(Math.abs(_$(e,t-1,n))>1e8)throw RangeError(`date/time value is outside the supported range`)}function y$(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 IY.fromComponents(n,r,i,a,o,s)}function b$(e,t,n,r,i){let a=IY.fromEpochNsDiff(t,e);return a=Y$(a,n,r,i),g$({years:0,months:0,weeks:0,days:0},a)}function x$(e,t,n,r){c$(e),c$(t);let i=y$(e.time,t.time),a=i.sign(),o=Z$(e.isoDate,t.isoDate),s=t.isoDate;o===a&&(s=YQ(s.year,s.month,s.day+a),i=i.add24HourDays(-a));let c=vZ(`day`,r),l=eQ(n,e.isoDate,s,c);return r!==c&&(i=i.add24HourDays(l.days),l.days=0),g$(l,i)}function S$(e,t,n,r,i){let a=Y.default.subtract(t,e);if(Y.default.equal(a,EJ))return{date:{years:0,months:0,weeks:0,days:0},time:IY.ZERO};let o=Y.default.lessThan(a,EJ)?-1:1,s=dQ(n,e),c=dQ(n,t),l,u=0,d=o===1?2:1,f=y$(s.time,c.time);for(f.sign()===-o&&u++;u<=d;u++){l=iZ(YQ(c.isoDate.year,c.isoDate.month,c.isoDate.day-u*o),s.time);let e=fQ(n,l,`compatible`);if(f=IY.fromEpochNsDiff(t,e),f.sign()!==-o)break}let p=vZ(`day`,i);return g$(eQ(r,s.isoDate,l.isoDate,p),f)}function C$(e,t,n,r,i,a,o,s,c){let l,u,d,f,p=t;switch(s){case`year`:{let t=G$(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=G$(p.date.months,o,`trunc`);l=t,u=t+o*e,d=rZ(p.date,0,0,l),f=rZ(p.date,0,0,u);break}case`week`:{let t=rZ(p.date,0,0),n=$Z(a,r.isoDate,t,`constrain`),i=eQ(a,n,YQ(n.year,n.month,n.day+p.date.days),`week`),s=G$(p.date.weeks+i.weeks,o,`trunc`);l=s,u=s+o*e,d=rZ(p.date,0,l),f=rZ(p.date,0,u);break}case`day`:{let t=G$(p.date.days,o,`trunc`);l=t,u=t+o*e,d=rZ(p.date,l),f=rZ(p.date,u);break}}let m=$Z(a,r.isoDate,d,`constrain`),h=$Z(a,r.isoDate,f,`constrain`),g,_,v=iZ(m,r.time),y=iZ(h,r.time);i?(g=fQ(i,v,`compatible`),_=fQ(i,y,`compatible`)):(g=RQ(v),_=RQ(y));let b=IY.fromEpochNsDiff(n,g),x=IY.fromEpochNsDiff(_,g),S=PY(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)?FY(Math.abs(l),Math.abs(u),C,w,S):Math.abs(u),E=new IY(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:IY.ZERO},{nudgeResult:{duration:p,nudgedEpochNs:D?_:g,didExpandCalendarUnit:D},total:E}}function w$(e,t,n,r,i,a,o,s,c){let l=e,u=yZ(s)||r&&s===`day`,d=qQ(l)<0?-1:1,f;return u?{nudgeResult:f}=C$(d,l,t,n,r,i,o,s,c):f=r?function(e,t,n,r,i,a,o,s){let c=t,l=$Z(i,n.isoDate,c.date,`constrain`),u=iZ(l,n.time),d=iZ(YQ(l.year,l.month,l.day+e),n.time),f=fQ(r,u,`compatible`),p=fQ(r,d,`compatible`),m=IY.fromEpochNsDiff(p,f);if(m.sign()!==e)throw RangeError(`time zone returned inconsistent Instants`);let h=Y.default.BigInt(AX[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:g$(rZ(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*AX[i]),a),l=c.subtract(s),{quotient:u}=s.divmod(tX),{quotient:d}=c.divmod(tX),f=Math.sign(d-u)===s.sign(),p=l.addToEpochNs(t),m=0,h=c;return bZ(n)===`date`&&(m=d,h=c.add(IY.fromComponents(24*-d,0,0,0,0,0))),{duration:{date:rZ(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=kX.indexOf(o);for(let t=kX.indexOf(s)-1;t>=l;t--){let s=kX[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=rZ(c.date,0,0,t);break}case`week`:{let t=c.date.weeks+e;l=rZ(c.date,0,t);break}}let u=iZ($Z(a,r.isoDate,l,`constrain`),r.time),d;if(d=i?fQ(i,u,`compatible`):RQ(u),VJ(n,d)===-e)break;c={date:l,time:IY.ZERO}}return c}(d,l,f.nudgedEpochNs,n,r,i,a,vZ(s,`day`))),l}function T$(e,t,n,r,i,a){return yZ(a)||r&&a===`day`?C$(qQ(e)<0?-1:1,e,t,n,r,i,1,a,`trunc`).total:X$(e.time.add24HourDays(e.date.days),a)}function E$(e,t,n,r,i,a,o){if($$(e,t)==0)return{date:{years:0,months:0,weeks:0,days:0},time:IY.ZERO};s$(e),s$(t);let s=x$(e,t,n,r);return a===`nanosecond`&&i===1?s:w$(s,RQ(t),e,null,n,r,i,a,o)}function D$(e,t,n,r,i,a,o,s){if(bZ(i)===`time`)return b$(e,t,a,o,s);let c=S$(e,t,n,r,i);return o===`nanosecond`&&a===1?c:w$(c,t,dQ(n,e),n,r,i,a,o,s)}function O$(e,t,n,r,i,a){let o=EX.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=hZ(t,`largestUnit`,n,`auto`);if(r.includes(s))throw RangeError(`largestUnit must be one of ${o.join(`, `)}, not ${s}`);let c=uZ(t),l=sZ(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=hZ(t,`smallestUnit`,n,i);if(r.includes(u))throw RangeError(`smallestUnit must be one of ${o.join(`, `)}, not ${u}`);let d=vZ(a,u);if(s===`auto`&&(s=d),vZ(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&&dZ(c,f,!1),{largestUnit:s,roundingIncrement:c,roundingMode:l,smallestUnit:u}}function k$(e,t,n,r){let i=AZ(n),a=O$(e,$(r),`time`,[],`nanosecond`,`second`),o=h$(b$(Z(t,GJ),Z(i,GJ),a.roundingIncrement,a.smallestUnit,a.roundingMode),a.largestUnit);return e===`since`&&(o=$Q(o)),o}function A$(e,t,n,r){let i=EZ(n),a=Z(t,X),o=Z(i,X);if(!rQ(a,o))throw RangeError(`cannot compute difference between dates of ${a} and ${o} calendars`);let s=O$(e,$(r),`date`,[],`day`,`day`),c=jY(`%Temporal.Duration%`),l=Z(t,KJ),u=Z(i,KJ);if(Z$(l,u)===0)return new c;let d={date:eQ(a,l,u,s.largestUnit),time:IY.ZERO};if(s.smallestUnit!==`day`||s.roundingIncrement!==1){let e=iZ(l,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});d=w$(d,RQ(iZ(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=h$(d,`day`);return e===`since`&&(f=$Q(f)),f}function j$(e,t,n,r){let i=OZ(n),a=Z(t,X),o=Z(i,X);if(!rQ(a,o))throw RangeError(`cannot compute difference between dates of ${a} and ${o} calendars`);let s=O$(e,$(r),`datetime`,[],`nanosecond`,`day`),c=jY(`%Temporal.Duration%`),l=Z(t,qJ),u=Z(i,qJ);if($$(l,u)===0)return new c;let d=h$(E$(l,u,a,s.largestUnit,s.roundingIncrement,s.smallestUnit,s.roundingMode),s.largestUnit);return e===`since`&&(d=$Q(d)),d}function M$(e,t,n,r){let i=MZ(n),a=O$(e,$(r),`time`,[],`nanosecond`,`hour`),o=y$(Z(t,JJ),Z(i,JJ));o=Y$(o,a.roundingIncrement,a.smallestUnit,a.roundingMode);let s=h$(g$({years:0,months:0,weeks:0,days:0},o),a.largestUnit);return e===`since`&&(s=$Q(s)),s}function N$(e,t,n,r){let i=PZ(n),a=Z(t,X),o=Z(i,X);if(!rQ(a,o))throw RangeError(`cannot compute difference between months of ${a} and ${o} calendars`);let s=O$(e,$(r),`date`,[`week`,`day`],`month`,`year`),c=jY(`%Temporal.Duration%`);if(Z$(Z(t,KJ),Z(i,KJ))==0)return new c;let l=CZ(a,Z(t,KJ),`year-month`);l.day=1;let u=iQ(a,l,`constrain`),d=CZ(a,Z(i,KJ),`year-month`);d.day=1;let f=iQ(a,d,`constrain`),p={date:rZ(eQ(a,u,f,s.largestUnit),0,0),time:IY.ZERO};if(s.smallestUnit!==`month`||s.roundingIncrement!==1){let e=iZ(u,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});p=w$(p,RQ(iZ(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=h$(p,`day`);return e===`since`&&(m=$Q(m)),m}function P$(e,t,n,r){let i=IZ(n),a=Z(t,X),o=Z(i,X);if(!rQ(a,o))throw RangeError(`cannot compute difference between dates of ${a} and ${o} calendars`);let s=O$(e,$(r),`datetime`,[],`nanosecond`,`hour`),c=Z(t,GJ),l=Z(i,GJ),u=jY(`%Temporal.Duration%`),d;if(bZ(s.largestUnit)!==`date`)d=h$(b$(c,l,s.roundingIncrement,s.smallestUnit,s.roundingMode),s.largestUnit);else{let e=Z(t,QJ);if(!cQ(e,Z(i,QJ)))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=h$(D$(c,l,e,a,s.largestUnit,s.roundingIncrement,s.smallestUnit,s.roundingMode),`hour`)}return e===`since`&&(d=$Q(d)),d}function F$({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,ZQ(e,t,s,r,i,c)}function I$(e,t){let n=t.addToEpochNs(e);return l$(n),n}function L$(e,t,n,r,i=`constrain`){if(KQ(r.date)===0)return I$(e,r.time);let a=dQ(t,e);return I$(fQ(t,iZ($Z(n,a.isoDate,r.date,i),a.time),`compatible`),r.time)}function R$(e,t,n){let r=kZ(n);e===`subtract`&&(r=$Q(r));let i=vZ(_Z(t),_Z(r));if(yZ(i))throw RangeError(`For years, months, or weeks arithmetic, use date arithmetic relative to a starting point`);let a=p$(t),o=p$(r);return h$(g$({years:0,months:0,weeks:0,days:0},a.time.add(o.time)),i)}function z$(e,t,n){let r=kZ(n);e===`subtract`&&(r=$Q(r));let i=_Z(r);if(bZ(i)===`date`)throw RangeError(`Duration field ${i} not supported by Temporal.Instant. Try Temporal.ZonedDateTime instead.`);let a=p$(r);return JZ(I$(Z(t,GJ),a.time))}function B$(e,t,n,r){let i=Z(t,X),a=kZ(n);e===`subtract`&&(a=$Q(a));let o=m$(a),s=aZ($(r));return RZ($Z(i,Z(t,KJ),o,s),i)}function V$(e,t,n,r){let i=kZ(n);e===`subtract`&&(i=$Q(i));let a=aZ($(r)),o=Z(t,X),s=p$(i),c=Z(t,qJ),l=F$(c.time,s.time),u=rZ(s.date,l.deltaDays);return d$(u.years,u.months,u.weeks,u.days,0,0,0,0,0,0),BZ(iZ($Z(o,c.isoDate,u,a),l),o)}function H$(e,t,n){let r=kZ(n);e===`subtract`&&(r=$Q(r));let i=p$(r),{hour:a,minute:o,second:s,millisecond:c,microsecond:l,nanosecond:u}=F$(Z(t,JJ),i.time);return WZ(tZ(a,o,s,c,l,u,`reject`))}function U$(e,t,n,r){let i=kZ(n);e===`subtract`&&(i=$Q(i));let a=aZ($(r)),o=GQ(i),s=Z(t,X),c=CZ(s,Z(t,KJ),`year-month`);c.day=1;let l=iQ(s,c,`constrain`);if(o<0){let e=$Z(s,l,{months:1},`constrain`);l=YQ(e.year,e.month,e.day-1)}let u=m$(i);return i$(l),KZ(aQ(s,CZ(s,$Z(s,l,u,a),`year-month`),a),s)}function W$(e,t,n,r){let i=kZ(n);e===`subtract`&&(i=$Q(i));let a=aZ($(r)),o=Z(t,QJ),s=Z(t,X),c=f$(i);return XZ(L$(Z(t,GJ),o,s,c,a),o,s)}function G$(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=o1(Math.abs(2*i)-t),l=o%2==0,u=PY(n,a),d=i===0?o:FY(o,s,c,l,u);return t*(a===`positive`?d:-d)}function K$(e,t,n,r){let i=AX[n]*t;return function(e,t,n){let r=RJ(e),i=RJ(t),a=Y.default.divide(r,i),o=Y.default.remainder(r,i),s=PY(n,`positive`),c,l;Y.default.lessThan(r,EJ)?(c=Y.default.subtract(a,DJ),l=a):(c=a,l=Y.default.add(a,DJ));let u=VJ(BJ(Y.default.multiply(o,OJ)),i)*(Y.default.lessThan(r,EJ)?-1:1)+0,d=Y.default.equal(o,EJ)?a:FY(c,l,u,zJ(c),s);return Y.default.multiply(d,i)}(e,Y.default.BigInt(i),r)}function q$(e,t,n,r){c$(e);let{year:i,month:a,day:o}=e.isoDate,s=J$(e.time,t,n,r);return iZ(YQ(i,a,o+s.deltaDays),s)}function J$({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=AX[s],d=G$(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 ZQ(d,0,0,0,0,0);case`minute`:return ZQ(e,d,0,0,0,0);case`second`:return ZQ(e,t,d,0,0,0);case`millisecond`:return ZQ(e,t,n,d,0,0);case`microsecond`:return ZQ(e,t,n,r,d,0);case`nanosecond`:return ZQ(e,t,n,r,i,d);default:throw Error(`Invalid unit ${s}`)}}function Y$(e,t,n,r){let i=AX[n];return e.round(Y.default.BigInt(i*t),r)}function X$(e,t){let n=AX[t];return e.fdiv(Y.default.BigInt(n))}function Z$(e,t){return e.year===t.year?e.month===t.month?e.day===t.day?0:o1(e.day-t.day):o1(e.month-t.month):o1(e.year-t.year)}function Q$(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:o1(e.nanosecond-t.nanosecond):o1(e.microsecond-t.microsecond):o1(e.millisecond-t.millisecond):o1(e.second-t.second):o1(e.minute-t.minute):o1(e.hour-t.hour)}function $$(e,t){let n=Z$(e.isoDate,t.isoDate);return n===0?Q$(e.time,t.time):n}function e1(e){let t=r1(e);return globalThis.BigInt===void 0?t:globalThis.BigInt(t.toString(10))}function t1(e,t){let{quotient:n,remainder:r}=HJ(RJ(e),NJ),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 n1(e){if(!Number.isInteger(e))throw RangeError(`epoch milliseconds must be an integer`);return Y.default.multiply(Y.default.BigInt(e),NJ)}function r1(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 i1=(()=>{let e=Y.default.BigInt(Date.now()%1e6);return()=>{let t=Date.now(),n=Y.default.BigInt(t),r=Y.default.add(n1(t),e);return e=Y.default.remainder(n,NJ),Y.default.greaterThan(r,iX)?iX:Y.default.lessThan(r,aX)?aX:r}})();function a1(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}function o1(e){return e<0?-1:e>0?1:e}function $(e){if(e===void 0)return Object.create(null);if(mX(e)&&e!==null)return e;throw TypeError(`Options parameter must be an object, not `+(e===null?`null`:typeof e))}function s1(e,t){let n=Object.create(null);return n[e]=t,n}function c1(e,t,n,r){let i=e[t];if(i!==void 0){if(i=gX(i),!n.includes(i))throw RangeError(`${t} must be one of ${n.join(`, `)}, not ${i}`);return i}if(r===mZ)throw RangeError(`${t} option is required`);return r}function l1(e){let t=u1(e);if(!fX.includes(u1(t)))throw RangeError(`invalid calendar identifier ${t}`);switch(t){case`ethiopic-amete-alem`:return`ethioaa`;case`islamicc`:return`islamic-civil`}return t}function u1(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 d1(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 f1=RegExp(`^${WY.source}$`),p1=RegExp(`^([+-])([01][0-9]|2[0-3])(?::?([0-5][0-9])(?::?([0-5][0-9])(?:[.,](\\d{1,9}))?)?)?$`);function m1(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 h1(e){return[...e]}function g1(e,t){if(e!==`gregory`&&e!==`iso8601`)return;let n=v1[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 _1(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 v1={};function y1(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 b1(e,t=!1){return`M${`${e}`.padStart(2,`0`)}${t?`L`:``}`}function x1(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`&&n$(r,1,n),t===`constrain`&&(r=e$(r,1,n)),i=b1(r)}else{let e=y1(i);if(i!==b1(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}}v1.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,x1(e))},dateToISO:(e,t)=>eZ(e.year,e.month,e.day,t),monthDayToISOReferenceDate(e,t){let{month:n,day:r}=eZ(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 h1(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}=JQ(o,s),{year:o,month:s,day:c}=eZ(o,s,c,a),c+=i+7*r,YQ(o,s,c)},dateUntil(e,t,n){let r=-Z$(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);!_1(r,e.year+s,e.month,e.day,t);)a=s,s+=r;let c=r;for(i=JQ(e.year+a,e.month+c);!_1(r,i.year,i.month,e.day,t);)o=c,c+=r,i=JQ(i.year,i.month+r);n===`month`&&(o+=12*a,a=0)}i=JQ(e.year+a,e.month+o);let s=t$(i.year,i.month,e.day),c=0,l=_$(t.year,t.month-1,t.day)-_$(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=b1(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+=WQ(e,n);i.dayOfYear=r}return r.weekOfYear&&(i.weekOfYear=g1(`iso8601`,{year:e,month:t,day:n})),r.daysInMonth&&(i.daysInMonth=WQ(e,t)),(r.daysInYear||r.inLeapYear)&&(i.inLeapYear=UQ(e),i.daysInYear=i.inLeapYear?366:365),i},getFirstDayOfWeek:()=>1,getMinimalDaysInFirstWeek:()=>4};var S1=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 C1({isoYear:e,isoMonth:t,isoDay:n}){return`${gQ(e)}-${_Q(t)}-${_Q(n)}T00:00Z`}function w1(e,t){return{years:e.year-t.year,months:e.month-t.month,days:e.day-t.day}}S1.objectMap=new WeakMap,S1.MAX_CACHE_ENTRIES=1e3;var T1=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=C1({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}=x1(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`?(n$(i,1,r),n$(a,1,this.maximumMonthLength(e))):(i=e$(i,1,r),a=e$(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=w1(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=w1(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=w1(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:o1(e.day-t.day):o1(e.month-t.month):o1(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 YQ(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 _$(i.year,i.month-1,i.day)-_$(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(){}},E1=class extends T1{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?b1(5,!0):b1(t<6?t:t-1):b1(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=y1(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`?(n$(a,1,this.monthsInYear({year:i})),n$(s,1,this.maximumMonthLength({year:i,month:a}))):(a=e$(a,1,this.monthsInYear({year:i})),s=e$(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}}},D1=class extends T1{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}}},O1=class extends D1{constructor(){super(...arguments),this.id=`islamic`}},k1=class extends D1{constructor(){super(...arguments),this.id=`islamic-umalqura`}},A1=class extends D1{constructor(){super(...arguments),this.id=`islamic-tbla`}},j1=class extends D1{constructor(){super(...arguments),this.id=`islamic-civil`}},M1=class extends D1{constructor(){super(...arguments),this.id=`islamic-rgsa`}},N1=class extends D1{constructor(){super(...arguments),this.id=`islamicc`}},P1=class extends T1{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 y1(e)<=6?31:30}estimateIsoDate(e){let{year:t}=this.adjustCalendarDate(e);return{year:t+621,month:1,day:1}}},F1=class extends T1{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 I1(e.year+78)}monthsInYear(){return 12}minimumMonthLength(e){return this.getMonthInfo(e).length}maximumMonthLength(e){return this.getMonthInfo(e).length}maxLengthOfMonthCodeInAnyYear(e){let t=y1(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 YQ(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 I1(e){return e%4==0&&(e%100!=0||e%400==0)}var L1=class extends T1{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 I1(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][y1(e)-1]}estimateIsoDate(e){let t=this.adjustCalendarDate(e);return eZ(t.year+this.isoEpoch.year,t.month+this.isoEpoch.month,t.day+this.isoEpoch.day,`constrain`)}},R1=class extends T1{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 I1(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][y1(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:y1(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 eZ(t+i.isoEpoch.year-+!i.hasYearZero,n,r,`constrain`)}},z1=class extends R1{constructor(e,t){super(e,t)}isoToCalendarDate(e){let{year:t,month:n,day:r}=e,i=b1(n),a=t-this.anchorEra.isoEpoch.year+1;return this.completeEraYear({year:a,month:n,monthCode:i,day:r})}},B1={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},V1=class extends L1{constructor(e,t){super(e,t),this.inLeapYear=B1.inLeapYear,this.monthsInYear=B1.monthsInYear,this.minimumMonthLength=B1.minimumMonthLength,this.maximumMonthLength=B1.maximumMonthLength,this.maxLengthOfMonthCodeInAnyYear=B1.maxLengthOfMonthCodeInAnyYear}},H1=class extends R1{constructor(e,t){super(e,t),this.inLeapYear=B1.inLeapYear,this.monthsInYear=B1.monthsInYear,this.minimumMonthLength=B1.minimumMonthLength,this.maximumMonthLength=B1.maximumMonthLength,this.maxLengthOfMonthCodeInAnyYear=B1.maxLengthOfMonthCodeInAnyYear}},U1=class extends V1{constructor(){super(`ethioaa`,{year:-5492,month:7,day:17})}},W1=class extends H1{constructor(){super(`coptic`,[{code:`coptic`,isoEpoch:{year:284,month:8,day:29}},{code:`coptic-inverse`,reverseOf:`coptic`}])}},G1=class extends H1{constructor(){super(`ethiopic`,[{code:`ethioaa`,names:[`ethiopic-amete-alem`,`mundi`],isoEpoch:{year:-5492,month:7,day:17}},{code:`ethiopic`,names:[`incar`],isoEpoch:{year:8,month:8,day:27},anchorEpoch:{year:5501}}])}},K1=class extends z1{constructor(){super(`roc`,[{code:`roc`,names:[`minguo`],isoEpoch:{year:1912,month:1,day:1}},{code:`roc-inverse`,names:[`before-roc`],reverseOf:`roc`}])}},q1=class extends L1{constructor(){super(`buddhist`,{year:-543,month:1,day:1})}},J1=class extends z1{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}},Y1=class extends z1{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}}},X1=class extends T1{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=C1({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=b1(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=b1(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`?(n$(a,1,o),n$(s,1,this.maximumMonthLength())):(a=e$(a,1,o),s=e$(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=b1(+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}}},Z1=class extends X1{constructor(){super(...arguments),this.id=`chinese`}},Q1=class extends X1{constructor(){super(...arguments),this.id=`dangi`}},$1=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 S1;x1(e,void 0,this.helper.monthsInYear({year:e.year??1972},t))}}dateToISO(e,t){let n=new S1,r=this.helper.calendarToIsoDate(e,t,n);return n.setObject(r),r}monthDayToISOReferenceDate(e,t){let n=new S1,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 h1(t)}dateAdd(e,{years:t,months:n,weeks:r,days:i},a){let o=S1.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 S1.getCacheForObject(l)||new S1(o).setObject(l),l}dateUntil(e,t,n){let r=S1.getCacheForObject(e),i=S1.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=S1.getCacheForObject(e),r=this.helper.isoToCalendarDate(e,n);if(t.dayOfWeek&&(r.dayOfWeek=v1.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=g1(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[E1,P1,G1,U1,W1,Z1,Q1,K1,F1,q1,J1,Y1,O1,k1,A1,j1,M1,N1]){let t=new e;v1[t.id]=new $1(t)}AY(`calendarImpl`,(function(e){return v1[e]}));var e0=Intl.DateTimeFormat;function t0(e,t){let n=Z(e,t);return typeof n==`function`&&(n=new e0(Z(e,yY),n(Z(e,bY))),function(e,t,n){let r=CY(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 n0(e){return EY(e,hY)}var r0=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 e0(t,i),o=a.resolvedOptions();if(TY(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,DY(e,bY,t)}else DY(e,bY,i);DY(e,yY,o.locale),DY(e,hY,a),DY(e,gY,o.timeZone),DY(e,vY,o.calendar),DY(e,lY,m0),DY(e,uY,f0),DY(e,dY,p0),DY(e,fY,d0),DY(e,pY,h0),DY(e,mY,g0);let s=r?i.timeZone:void 0;if(s===void 0)DY(e,_Y,o.timeZone);else{let t=gX(s);if(t.startsWith(`−`))throw RangeError(`Unicode minus (U+2212) is not supported in time zone offsets`);DY(e,_Y,sQ(t))}})(this,e,t)}get format(){Q(this,n0);let e=o0.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,n0),c0.call(this,e,t)}formatToParts(e,...t){return Q(this,n0),s0.call(this,e,...t)}formatRangeToParts(e,t){return Q(this,n0),l0.call(this,e,t)}resolvedOptions(){return Q(this,n0),a0.call(this)}};`formatToParts`in e0.prototype||delete r0.prototype.formatToParts,`formatRangeToParts`in e0.prototype||delete r0.prototype.formatRangeToParts;var i0=function(e=void 0,t=void 0){return new r0(e,t)};function a0(){let e=Z(this,hY).resolvedOptions();return e.timeZone=Z(this,_Y),e}function o0(e,...t){let n,r,i=C0(e,this);return i.formatter?(n=i.formatter,r=[t1(i.epochNs,`floor`)]):(n=Z(this,hY),r=[e,...t]),n.format(...r)}function s0(e,...t){let n,r,i=C0(e,this);return i.formatter?(n=i.formatter,r=[t1(i.epochNs,`floor`)]):(n=Z(this,hY),r=[e,...t]),n.formatToParts(...r)}function c0(e,t){if(e===void 0||t===void 0)throw TypeError(`Intl.DateTimeFormat.formatRange requires two values`);let n=x0(e),r=x0(t),i,a=[n,r];if(b0(n)!==b0(r))throw TypeError(`Intl.DateTimeFormat.formatRange accepts two values of the same type`);if(b0(n)){if(!S0(n,r))throw TypeError(`Intl.DateTimeFormat.formatRange accepts two values of the same type`);let{epochNs:e,formatter:t}=C0(n,this),{epochNs:o,formatter:s}=C0(r,this);t&&(i=t,a=[t1(e,`floor`),t1(o,`floor`)])}return i||=Z(this,hY),i.formatRange(...a)}function l0(e,t){if(e===void 0||t===void 0)throw TypeError(`Intl.DateTimeFormat.formatRange requires two values`);let n=x0(e),r=x0(t),i,a=[n,r];if(b0(n)!==b0(r))throw TypeError(`Intl.DateTimeFormat.formatRangeToParts accepts two values of the same type`);if(b0(n)){if(!S0(n,r))throw TypeError(`Intl.DateTimeFormat.formatRangeToParts accepts two values of the same type`);let{epochNs:e,formatter:t}=C0(n,this),{epochNs:o,formatter:s}=C0(r,this);t&&(i=t,a=[t1(e,`floor`),t1(o,`floor`)])}return i||=Z(this,hY),i.formatRangeToParts(...a)}function u0(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 d0(e){let t=u0(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`})),!v0(t)){if(y0(e))throw TypeError(`cannot format Temporal.PlainTime with options [${Object.keys(e)}]`);Object.assign(t,{hour:`numeric`,minute:`numeric`,second:`numeric`})}return t}function f0(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=u0(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(y0(e))throw TypeError(`cannot format PlainYearMonth with options [${Object.keys(e)}]`);Object.assign(n,{year:`numeric`,month:`numeric`})}return n}function p0(e){let t={short:{month:`numeric`,day:`numeric`},medium:{month:`short`,day:`numeric`},long:{month:`long`,day:`numeric`},full:{month:`long`,day:`numeric`}},n=u0(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(y0(e))throw TypeError(`cannot format PlainMonthDay with options [${Object.keys(e)}]`);Object.assign(n,{month:`numeric`,day:`numeric`})}return n}function m0(e){let t=u0(e,{hour:!1,minute:!1,second:!1,dayPeriod:!1,timeZoneName:!1,timeStyle:!1});if(!_0(t)){if(y0(e))throw TypeError(`cannot format PlainDate with options [${Object.keys(e)}]`);Object.assign(t,{year:`numeric`,month:`numeric`,day:`numeric`})}return t}function h0(e){let t=u0(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),!v0(t)&&!_0(t)){if(y0(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 g0(e){let t=e;return v0(t)||_0(t)||(t=Object.assign({},t,{year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`})),t}function _0(e){return`year`in e||`month`in e||`day`in e||`weekday`in e||`dateStyle`in e||`era`in e}function v0(e){return`hour`in e||`minute`in e||`second`in e||`timeStyle`in e||`dayPeriod`in e||`fractionalSecondDigits`in e}function y0(e){return _0(e)||v0(e)||`dateStyle`in e||`timeStyle`in e||`timeZoneName`in e}function b0(e){return LX(e)||RX(e)||zX(e)||HX(e)||BX(e)||VX(e)||FX(e)}function x0(e){return b0(e)?e:hX(e)}function S0(e,t){return!(!b0(e)||!b0(t)||RX(e)&&!RX(t)||LX(e)&&!LX(t)||zX(e)&&!zX(t)||HX(e)&&!HX(t)||BX(e)&&!BX(t)||VX(e)&&!VX(t)||FX(e)&&!FX(t))}function C0(e,t){if(RX(e)){let n={isoDate:{year:1970,month:1,day:1},time:Z(e,JJ)};return{epochNs:fQ(Z(t,gY),n,`compatible`),formatter:t0(t,fY)}}if(BX(e)){let n=Z(e,X),r=Z(t,vY);if(n!==r)throw RangeError(`cannot format PlainYearMonth with calendar ${n} in locale with calendar ${r}`);let i=iZ(Z(e,KJ),{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{epochNs:fQ(Z(t,gY),i,`compatible`),formatter:t0(t,uY)}}if(VX(e)){let n=Z(e,X),r=Z(t,vY);if(n!==r)throw RangeError(`cannot format PlainMonthDay with calendar ${n} in locale with calendar ${r}`);let i=iZ(Z(e,KJ),{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{epochNs:fQ(Z(t,gY),i,`compatible`),formatter:t0(t,dY)}}if(LX(e)){let n=Z(e,X),r=Z(t,vY);if(n!==`iso8601`&&n!==r)throw RangeError(`cannot format PlainDate with calendar ${n} in locale with calendar ${r}`);let i=iZ(Z(e,KJ),{deltaDays:0,hour:12,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0});return{epochNs:fQ(Z(t,gY),i,`compatible`),formatter:t0(t,lY)}}if(zX(e)){let n=Z(e,X),r=Z(t,vY);if(n!==`iso8601`&&n!==r)throw RangeError(`cannot format PlainDateTime with calendar ${n} in locale with calendar ${r}`);let i=Z(e,qJ);return{epochNs:fQ(Z(t,gY),i,`compatible`),formatter:t0(t,pY)}}if(HX(e))throw TypeError(`Temporal.ZonedDateTime not supported in DateTimeFormat methods. Use toLocaleString() instead.`);return FX(e)?{epochNs:Z(e,GJ),formatter:t0(t,mY)}:{}}function w0(e){let t=Object.create(null);return t.years=Z(e,$J),t.months=Z(e,eY),t.weeks=Z(e,tY),t.days=Z(e,nY),t.hours=Z(e,rY),t.minutes=Z(e,iY),t.seconds=Z(e,aY),t.milliseconds=Z(e,oY),t.microseconds=Z(e,sY),t.nanoseconds=Z(e,cY),t}r0.prototype.constructor=i0,Object.defineProperty(i0,"prototype",{value:r0.prototype,writable:!1,enumerable:!1,configurable:!1}),i0.supportedLocalesOf=e0.supportedLocalesOf,kY(i0,`Intl.DateTimeFormat`);var{format:T0,formatToParts:E0}=Intl.DurationFormat?.prototype??Object.create(null);function D0(e){Intl.DurationFormat.prototype.resolvedOptions.call(this);let t=w0(kZ(e));return T0.call(this,t)}Intl.DurationFormat?.prototype&&(Intl.DurationFormat.prototype.format=D0,Intl.DurationFormat.prototype.formatToParts=function(e){Intl.DurationFormat.prototype.resolvedOptions.call(this);let t=w0(kZ(e));return E0.call(this,t)}),Object.freeze({__proto__:null,DateTimeFormat:i0,ModifiedIntlDurationFormatPrototypeFormat:D0});var O0=class{constructor(e){if(arguments.length<1)throw TypeError(`missing argument: epochNanoseconds is required`);qZ(this,r1(e))}get epochMilliseconds(){return Q(this,FX),t1(Z(this,GJ),`floor`)}get epochNanoseconds(){return Q(this,FX),e1(Y.default.BigInt(Z(this,GJ)))}add(e){return Q(this,FX),z$(`add`,this,e)}subtract(e){return Q(this,FX),z$(`subtract`,this,e)}until(e,t=void 0){return Q(this,FX),k$(`until`,this,e,t)}since(e,t=void 0){return Q(this,FX),k$(`since`,this,e,t)}round(e){if(Q(this,FX),e===void 0)throw TypeError(`options parameter is required`);let t=typeof e==`string`?s1(`smallestUnit`,e):$(e),n=uZ(t),r=sZ(t,`halfExpand`),i=hZ(t,`smallestUnit`,`time`,mZ);return dZ(n,{hour:24,minute:1440,second:86400,millisecond:864e5,microsecond:864e8,nanosecond:864e11}[i],!0),JZ(K$(Z(this,GJ),n,i,r))}equals(e){Q(this,FX);let t=AZ(e),n=Z(this,GJ),r=Z(t,GJ);return Y.default.equal(Y.default.BigInt(n),Y.default.BigInt(r))}toString(e=void 0){Q(this,FX);let t=$(e),n=fZ(t),r=sZ(t,`trunc`),i=hZ(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=sQ(a));let{precision:o,unit:s,increment:c}=pZ(i,n);return bQ(JZ(K$(Z(this,GJ),c,s,r)),a,o)}toJSON(){return Q(this,FX),bQ(this,void 0,`auto`)}toLocaleString(e=void 0,t=void 0){return Q(this,FX),new i0(e,t).format(this)}valueOf(){d1(`Instant`)}toZonedDateTimeISO(e){Q(this,FX);let t=sQ(e);return XZ(Z(this,GJ),t,`iso8601`)}static fromEpochMilliseconds(e){return JZ(n1(hX(e)))}static fromEpochNanoseconds(e){return JZ(r1(e))}static from(e){return AZ(e)}static compare(e,t){let n=AZ(e),r=AZ(t),i=Z(n,GJ),a=Z(r,GJ);return Y.default.lessThan(i,a)?-1:+!!Y.default.greaterThan(i,a)}};kY(O0,`Temporal.Instant`);var k0=class{constructor(e,t,n,r=`iso8601`){let i=_X(e),a=_X(t),o=_X(n),s=l1(r===void 0?`iso8601`:xX(r));r$(i,a,o),LZ(this,{year:i,month:a,day:o},s)}get calendarId(){return Q(this,LX),Z(this,X)}get era(){return A0(this,`era`)}get eraYear(){return A0(this,`eraYear`)}get year(){return A0(this,`year`)}get month(){return A0(this,`month`)}get monthCode(){return A0(this,`monthCode`)}get day(){return A0(this,`day`)}get dayOfWeek(){return A0(this,`dayOfWeek`)}get dayOfYear(){return A0(this,`dayOfYear`)}get weekOfYear(){return A0(this,`weekOfYear`)?.week}get yearOfWeek(){return A0(this,`weekOfYear`)?.year}get daysInWeek(){return A0(this,`daysInWeek`)}get daysInMonth(){return A0(this,`daysInMonth`)}get daysInYear(){return A0(this,`daysInYear`)}get monthsInYear(){return A0(this,`monthsInYear`)}get inLeapYear(){return A0(this,`inLeapYear`)}with(e,t=void 0){if(Q(this,LX),!mX(e))throw TypeError(`invalid argument`);UX(e);let n=Z(this,X),r=CZ(n,Z(this,KJ));return r=QZ(n,r,wZ(n,e,[`year`,`month`,`monthCode`,`day`],[],`partial`)),RZ(iQ(n,r,aZ($(t))),n)}withCalendar(e){Q(this,LX);let t=tQ(e);return RZ(Z(this,KJ),t)}add(e,t=void 0){return Q(this,LX),B$(`add`,this,e,t)}subtract(e,t=void 0){return Q(this,LX),B$(`subtract`,this,e,t)}until(e,t=void 0){return Q(this,LX),A$(`until`,this,e,t)}since(e,t=void 0){return Q(this,LX),A$(`since`,this,e,t)}equals(e){Q(this,LX);let t=EZ(e);return Z$(Z(this,KJ),Z(t,KJ))===0&&rQ(Z(this,X),Z(t,X))}toString(e=void 0){return Q(this,LX),SQ(this,lZ($(e)))}toJSON(){return Q(this,LX),SQ(this)}toLocaleString(e=void 0,t=void 0){return Q(this,LX),new i0(e,t).format(this)}valueOf(){d1(`PlainDate`)}toPlainDateTime(e=void 0){Q(this,LX);let t=NZ(e);return BZ(iZ(Z(this,KJ),t),Z(this,X))}toZonedDateTime(e){let t,n;if(Q(this,LX),mX(e)){let r=e.timeZone;r===void 0?t=sQ(e):(t=sQ(r),n=e.plainTime)}else t=sQ(e);let r=Z(this,KJ),i;return n===void 0?i=hQ(t,r):(n=MZ(n),i=fQ(t,iZ(r,Z(n,JJ)),`compatible`)),XZ(i,t,Z(this,X))}toPlainYearMonth(){Q(this,LX);let e=Z(this,X);return KZ(aQ(e,CZ(e,Z(this,KJ)),`constrain`),e)}toPlainMonthDay(){Q(this,LX);let e=Z(this,X);return HZ(oQ(e,CZ(e,Z(this,KJ)),`constrain`),e)}static from(e,t=void 0){return EZ(e,t)}static compare(e,t){let n=EZ(e),r=EZ(t);return Z$(Z(n,KJ),Z(r,KJ))}};function A0(e,t){Q(e,LX);let n=Z(e,KJ);return SZ(e).isoToDate(n,{[t]:!0})[t]}kY(k0,`Temporal.PlainDate`);var j0=class{constructor(e,t,n,r=0,i=0,a=0,o=0,s=0,c=0,l=`iso8601`){let u=_X(e),d=_X(t),f=_X(n),p=r===void 0?0:_X(r),m=i===void 0?0:_X(i),h=a===void 0?0:_X(a),g=o===void 0?0:_X(o),_=s===void 0?0:_X(s),v=c===void 0?0:_X(c),y=l1(l===void 0?`iso8601`:xX(l));o$(u,d,f,p,m,h,g,_,v),zZ(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,zX),Z(this,X)}get year(){return M0(this,`year`)}get month(){return M0(this,`month`)}get monthCode(){return M0(this,`monthCode`)}get day(){return M0(this,`day`)}get hour(){return N0(this,`hour`)}get minute(){return N0(this,`minute`)}get second(){return N0(this,`second`)}get millisecond(){return N0(this,`millisecond`)}get microsecond(){return N0(this,`microsecond`)}get nanosecond(){return N0(this,`nanosecond`)}get era(){return M0(this,`era`)}get eraYear(){return M0(this,`eraYear`)}get dayOfWeek(){return M0(this,`dayOfWeek`)}get dayOfYear(){return M0(this,`dayOfYear`)}get weekOfYear(){return M0(this,`weekOfYear`)?.week}get yearOfWeek(){return M0(this,`weekOfYear`)?.year}get daysInWeek(){return M0(this,`daysInWeek`)}get daysInYear(){return M0(this,`daysInYear`)}get daysInMonth(){return M0(this,`daysInMonth`)}get monthsInYear(){return M0(this,`monthsInYear`)}get inLeapYear(){return M0(this,`inLeapYear`)}with(e,t=void 0){if(Q(this,zX),!mX(e))throw TypeError(`invalid argument`);UX(e);let n=Z(this,X),r=Z(this,qJ),i={...CZ(n,r.isoDate),...r.time};return i=QZ(n,i,wZ(n,e,[`year`,`month`,`monthCode`,`day`],[`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`],`partial`)),BZ(DZ(n,i,aZ($(t))),n)}withPlainTime(e=void 0){Q(this,zX);let t=NZ(e);return BZ(iZ(Z(this,qJ).isoDate,t),Z(this,X))}withCalendar(e){Q(this,zX);let t=tQ(e);return BZ(Z(this,qJ),t)}add(e,t=void 0){return Q(this,zX),V$(`add`,this,e,t)}subtract(e,t=void 0){return Q(this,zX),V$(`subtract`,this,e,t)}until(e,t=void 0){return Q(this,zX),j$(`until`,this,e,t)}since(e,t=void 0){return Q(this,zX),j$(`since`,this,e,t)}round(e){if(Q(this,zX),e===void 0)throw TypeError(`options parameter is required`);let t=typeof e==`string`?s1(`smallestUnit`,e):$(e),n=uZ(t),r=sZ(t,`halfExpand`),i=hZ(t,`smallestUnit`,`time`,mZ,[`day`]),a={day:1,hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[i];dZ(n,a,a===1);let o=Z(this,qJ);return BZ(n===1&&i===`nanosecond`?o:q$(o,n,i,r),Z(this,X))}equals(e){Q(this,zX);let t=OZ(e);return $$(Z(this,qJ),Z(t,qJ))===0&&rQ(Z(this,X),Z(t,X))}toString(e=void 0){Q(this,zX);let t=$(e),n=lZ(t),r=fZ(t),i=sZ(t,`trunc`),a=hZ(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}=pZ(a,r),l=q$(Z(this,qJ),c,s,i);return s$(l),wQ(l,Z(this,X),o,n)}toJSON(){return Q(this,zX),wQ(Z(this,qJ),Z(this,X),`auto`)}toLocaleString(e=void 0,t=void 0){return Q(this,zX),new i0(e,t).format(this)}valueOf(){d1(`PlainDateTime`)}toZonedDateTime(e,t=void 0){Q(this,zX);let n=sQ(e),r=oZ($(t));return XZ(fQ(n,Z(this,qJ),r),n,Z(this,X))}toPlainDate(){return Q(this,zX),RZ(Z(this,qJ).isoDate,Z(this,X))}toPlainTime(){return Q(this,zX),WZ(Z(this,qJ).time)}static from(e,t=void 0){return OZ(e,t)}static compare(e,t){let n=OZ(e),r=OZ(t);return $$(Z(n,qJ),Z(r,qJ))}};function M0(e,t){Q(e,zX);let n=Z(e,qJ).isoDate;return SZ(e).isoToDate(n,{[t]:!0})[t]}function N0(e,t){return Q(e,zX),Z(e,qJ).time[t]}kY(j0,`Temporal.PlainDateTime`);var P0=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:yX(e),d=t===void 0?0:yX(t),f=n===void 0?0:yX(n),p=r===void 0?0:yX(r),m=i===void 0?0:yX(i),h=a===void 0?0:yX(a),g=o===void 0?0:yX(o),_=s===void 0?0:yX(s),v=c===void 0?0:yX(c),y=l===void 0?0:yX(l);d$(u,d,f,p,m,h,g,_,v,y),TY(this),DY(this,$J,u),DY(this,eY,d),DY(this,tY,f),DY(this,nY,p),DY(this,rY,m),DY(this,iY,h),DY(this,aY,g),DY(this,oY,_),DY(this,sY,v),DY(this,cY,y)}get years(){return Q(this,IX),Z(this,$J)}get months(){return Q(this,IX),Z(this,eY)}get weeks(){return Q(this,IX),Z(this,tY)}get days(){return Q(this,IX),Z(this,nY)}get hours(){return Q(this,IX),Z(this,rY)}get minutes(){return Q(this,IX),Z(this,iY)}get seconds(){return Q(this,IX),Z(this,aY)}get milliseconds(){return Q(this,IX),Z(this,oY)}get microseconds(){return Q(this,IX),Z(this,sY)}get nanoseconds(){return Q(this,IX),Z(this,cY)}get sign(){return Q(this,IX),GQ(this)}get blank(){return Q(this,IX),GQ(this)===0}with(t){Q(this,IX);let{years:n=Z(this,$J),months:r=Z(this,eY),weeks:i=Z(this,tY),days:a=Z(this,nY),hours:o=Z(this,rY),minutes:s=Z(this,iY),seconds:c=Z(this,aY),milliseconds:l=Z(this,oY),microseconds:u=Z(this,sY),nanoseconds:d=Z(this,cY)}=nZ(t);return new e(n,r,i,a,o,s,c,l,u,d)}negated(){return Q(this,IX),$Q(this)}abs(){return Q(this,IX),new e(Math.abs(Z(this,$J)),Math.abs(Z(this,eY)),Math.abs(Z(this,tY)),Math.abs(Z(this,nY)),Math.abs(Z(this,rY)),Math.abs(Z(this,iY)),Math.abs(Z(this,aY)),Math.abs(Z(this,oY)),Math.abs(Z(this,sY)),Math.abs(Z(this,cY)))}add(e){return Q(this,IX),R$(`add`,this,e)}subtract(e){return Q(this,IX),R$(`subtract`,this,e)}round(e){if(Q(this,IX),e===void 0)throw TypeError(`options parameter is required`);let t=_Z(this),n=typeof e==`string`?s1(`smallestUnit`,e):$(e),r=hZ(n,`largestUnit`,`datetime`,void 0,[`auto`]),{plainRelativeTo:i,zonedRelativeTo:a}=gZ(n),o=uZ(n),s=sZ(n,`halfExpand`),c=hZ(n,`smallestUnit`,`datetime`,void 0),l=!0;c||=(l=!1,`nanosecond`);let u=vZ(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(vZ(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&&dZ(o,f,!1),o>1&&bZ(c)===`date`&&r!==c)throw RangeError(`For calendar units with roundingIncrement > 1, use largestUnit = smallestUnit`);if(a){let e=f$(this),t=Z(a,QJ),n=Z(a,X),i=Z(a,GJ);return e=D$(i,L$(i,t,n,e),t,n,r,o,c,s),bZ(r)===`date`&&(r=`hour`),h$(e,r)}if(i){let e=p$(this),t=F$({deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0},e.time),n=Z(i,KJ),a=Z(i,X),l=$Z(a,n,rZ(e.date,t.deltaDays),`constrain`);return e=E$(iZ(n,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),iZ(l,t),a,r,o,c,s),h$(e,r)}if(yZ(t))throw RangeError(`a starting point is required for ${t}s balancing`);if(yZ(r))throw RangeError(`a starting point is required for ${r}s balancing`);let p=p$(this);if(c===`day`){let{quotient:e,remainder:t}=p.time.divmod(tX),n=p.date.days+e+X$(t,`day`);n=G$(n,o,s),p=g$({years:0,months:0,weeks:0,days:n},IY.ZERO)}else p=g$({years:0,months:0,weeks:0,days:0},Y$(p.time,o,c,s));return h$(p,r)}total(e){if(Q(this,IX),e===void 0)throw TypeError(`options argument is required`);let t=typeof e==`string`?s1(`unit`,e):$(e),{plainRelativeTo:n,zonedRelativeTo:r}=gZ(t),i=hZ(t,`unit`,`datetime`,mZ);if(r){let e=f$(this),t=Z(r,QJ),n=Z(r,X),a=Z(r,GJ);return function(e,t,n,r,i){return bZ(i)===`time`?X$(IY.fromEpochNsDiff(t,e),i):T$(S$(e,t,n,r,i),t,dQ(n,e),n,r,i)}(a,L$(a,t,n,e),t,n,i)}if(n){let e=p$(this),t=F$({deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0},e.time),r=Z(n,KJ),a=Z(n,X),o=$Z(a,r,rZ(e.date,t.deltaDays),`constrain`);return function(e,t,n,r){if($$(e,t)==0)return 0;s$(e),s$(t);let i=x$(e,t,n,r);return r===`nanosecond`?Y.default.toNumber(i.time.totalNs):T$(i,RQ(t),e,null,n,r)}(iZ(r,{deltaDays:0,hour:0,minute:0,second:0,millisecond:0,microsecond:0,nanosecond:0}),iZ(o,t),a,i)}let a=_Z(this);if(yZ(a))throw RangeError(`a starting point is required for ${a}s total`);if(yZ(i))throw RangeError(`a starting point is required for ${i}s total`);return X$(p$(this).time,i)}toString(e=void 0){Q(this,IX);let t=$(e),n=fZ(t),r=sZ(t,`trunc`),i=hZ(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}=pZ(i,n);if(o===`nanosecond`&&s===1)return xQ(this,a);let c=_Z(this),l=f$(this),u=Y$(l.time,s,o,r);return l=g$(l.date,u),xQ(h$(l,vZ(c,`second`)),a)}toJSON(){return Q(this,IX),xQ(this,`auto`)}toLocaleString(e=void 0,t=void 0){if(Q(this,IX),typeof Intl.DurationFormat==`function`){let n=new Intl.DurationFormat(e,t);return D0.call(n,this)}return console.warn(`Temporal.Duration.prototype.toLocaleString() requires Intl.DurationFormat.`),xQ(this,`auto`)}valueOf(){d1(`Duration`)}static from(e){return kZ(e)}static compare(e,t,n=void 0){let r=kZ(e),i=kZ(t),{plainRelativeTo:a,zonedRelativeTo:o}=gZ($(n));if(Z(r,$J)===Z(i,$J)&&Z(r,eY)===Z(i,eY)&&Z(r,tY)===Z(i,tY)&&Z(r,nY)===Z(i,nY)&&Z(r,rY)===Z(i,rY)&&Z(r,iY)===Z(i,iY)&&Z(r,aY)===Z(i,aY)&&Z(r,oY)===Z(i,oY)&&Z(r,sY)===Z(i,sY)&&Z(r,cY)===Z(i,cY))return 0;let s=_Z(r),c=_Z(i),l=f$(r),u=f$(i);if(o&&(bZ(s)===`date`||bZ(c)===`date`)){let e=Z(o,QJ),t=Z(o,X),n=Z(o,GJ),r=L$(n,e,t,l),i=L$(n,e,t,u);return o1(Y.default.toNumber(Y.default.subtract(r,i)))}let d=l.date.days,f=u.date.days;if(yZ(s)||yZ(c)){if(!a)throw RangeError(`A starting point is required for years, months, or weeks comparison`);d=QQ(l.date,a),f=QQ(u.date,a)}let p=l.time.add24HourDays(d),m=u.time.add24HourDays(f);return p.cmp(m)}};kY(P0,`Temporal.Duration`);var F0=class{constructor(e,t,n=`iso8601`,r=1972){let i=_X(e),a=_X(t),o=l1(n===void 0?`iso8601`:xX(n)),s=_X(r);r$(s,i,a),VZ(this,{year:s,month:i,day:a},o)}get monthCode(){return I0(this,`monthCode`)}get day(){return I0(this,`day`)}get calendarId(){return Q(this,VX),Z(this,X)}with(e,t=void 0){if(Q(this,VX),!mX(e))throw TypeError(`invalid argument`);UX(e);let n=Z(this,X),r=CZ(n,Z(this,KJ),`month-day`);return r=QZ(n,r,wZ(n,e,[`year`,`month`,`monthCode`,`day`],[],`partial`)),HZ(oQ(n,r,aZ($(t))),n)}equals(e){Q(this,VX);let t=jZ(e);return Z$(Z(this,KJ),Z(t,KJ))===0&&rQ(Z(this,X),Z(t,X))}toString(e=void 0){return Q(this,VX),TQ(this,lZ($(e)))}toJSON(){return Q(this,VX),TQ(this)}toLocaleString(e=void 0,t=void 0){return Q(this,VX),new i0(e,t).format(this)}valueOf(){d1(`PlainMonthDay`)}toPlainDate(e){if(Q(this,VX),!mX(e))throw TypeError(`argument should be an object`);let t=Z(this,X);return RZ(iQ(t,QZ(t,CZ(t,Z(this,KJ),`month-day`),wZ(t,e,[`year`],[],[])),`constrain`),t)}static from(e,t=void 0){return jZ(e,t)}};function I0(e,t){Q(e,VX);let n=Z(e,KJ);return SZ(e).isoToDate(n,{[t]:!0})[t]}function L0(e){return dQ(e,i1())}kY(F0,`Temporal.PlainMonthDay`);var R0={instant:()=>JZ(i1()),plainDateTimeISO:(e=a1())=>BZ(L0(sQ(e)),`iso8601`),plainDateISO:(e=a1())=>RZ(L0(sQ(e)).isoDate,`iso8601`),plainTimeISO:(e=a1())=>WZ(L0(sQ(e)).time),timeZoneId:()=>a1(),zonedDateTimeISO:(e=a1())=>{let t=sQ(e);return XZ(i1(),t,`iso8601`)},[Symbol.toStringTag]:`Temporal.Now`};Object.defineProperty(R0,Symbol.toStringTag,{value:`Temporal.Now`,writable:!1,enumerable:!1,configurable:!0});var z0=class e{constructor(e=0,t=0,n=0,r=0,i=0,a=0){let o=e===void 0?0:_X(e),s=t===void 0?0:_X(t),c=n===void 0?0:_X(n),l=r===void 0?0:_X(r),u=i===void 0?0:_X(i),d=a===void 0?0:_X(a);a$(o,s,c,l,u,d),UZ(this,{hour:o,minute:s,second:c,millisecond:l,microsecond:u,nanosecond:d})}get hour(){return Q(this,RX),Z(this,JJ).hour}get minute(){return Q(this,RX),Z(this,JJ).minute}get second(){return Q(this,RX),Z(this,JJ).second}get millisecond(){return Q(this,RX),Z(this,JJ).millisecond}get microsecond(){return Q(this,RX),Z(this,JJ).microsecond}get nanosecond(){return Q(this,RX),Z(this,JJ).nanosecond}with(t,n=void 0){if(Q(this,RX),!mX(t))throw TypeError(`invalid argument`);UX(t);let r=TZ(t,`partial`),i=TZ(this),{hour:a,minute:o,second:s,millisecond:c,microsecond:l,nanosecond:u}=Object.assign(i,r),d=aZ($(n));return{hour:a,minute:o,second:s,millisecond:c,microsecond:l,nanosecond:u}=tZ(a,o,s,c,l,u,d),new e(a,o,s,c,l,u)}add(e){return Q(this,RX),H$(`add`,this,e)}subtract(e){return Q(this,RX),H$(`subtract`,this,e)}until(e,t=void 0){return Q(this,RX),M$(`until`,this,e,t)}since(e,t=void 0){return Q(this,RX),M$(`since`,this,e,t)}round(e){if(Q(this,RX),e===void 0)throw TypeError(`options parameter is required`);let t=typeof e==`string`?s1(`smallestUnit`,e):$(e),n=uZ(t),r=sZ(t,`halfExpand`),i=hZ(t,`smallestUnit`,`time`,mZ);return dZ(n,{hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[i],!1),WZ(J$(Z(this,JJ),n,i,r))}equals(e){Q(this,RX);let t=MZ(e);return Q$(Z(this,JJ),Z(t,JJ))===0}toString(e=void 0){Q(this,RX);let t=$(e),n=fZ(t),r=sZ(t,`trunc`),i=hZ(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}=pZ(i,n);return CQ(J$(Z(this,JJ),s,o,r),a)}toJSON(){return Q(this,RX),CQ(Z(this,JJ),`auto`)}toLocaleString(e=void 0,t=void 0){return Q(this,RX),new i0(e,t).format(this)}valueOf(){d1(`PlainTime`)}static from(e,t=void 0){return MZ(e,t)}static compare(e,t){let n=MZ(e),r=MZ(t);return Q$(Z(n,JJ),Z(r,JJ))}};kY(z0,`Temporal.PlainTime`);var B0=class{constructor(e,t,n=`iso8601`,r=1){let i=_X(e),a=_X(t),o=l1(n===void 0?`iso8601`:xX(n)),s=_X(r);r$(i,a,s),GZ(this,{year:i,month:a,day:s},o)}get year(){return V0(this,`year`)}get month(){return V0(this,`month`)}get monthCode(){return V0(this,`monthCode`)}get calendarId(){return Q(this,BX),Z(this,X)}get era(){return V0(this,`era`)}get eraYear(){return V0(this,`eraYear`)}get daysInMonth(){return V0(this,`daysInMonth`)}get daysInYear(){return V0(this,`daysInYear`)}get monthsInYear(){return V0(this,`monthsInYear`)}get inLeapYear(){return V0(this,`inLeapYear`)}with(e,t=void 0){if(Q(this,BX),!mX(e))throw TypeError(`invalid argument`);UX(e);let n=Z(this,X),r=CZ(n,Z(this,KJ),`year-month`);return r=QZ(n,r,wZ(n,e,[`year`,`month`,`monthCode`],[],`partial`)),KZ(aQ(n,r,aZ($(t))),n)}add(e,t=void 0){return Q(this,BX),U$(`add`,this,e,t)}subtract(e,t=void 0){return Q(this,BX),U$(`subtract`,this,e,t)}until(e,t=void 0){return Q(this,BX),N$(`until`,this,e,t)}since(e,t=void 0){return Q(this,BX),N$(`since`,this,e,t)}equals(e){Q(this,BX);let t=PZ(e);return Z$(Z(this,KJ),Z(t,KJ))===0&&rQ(Z(this,X),Z(t,X))}toString(e=void 0){return Q(this,BX),EQ(this,lZ($(e)))}toJSON(){return Q(this,BX),EQ(this)}toLocaleString(e=void 0,t=void 0){return Q(this,BX),new i0(e,t).format(this)}valueOf(){d1(`PlainYearMonth`)}toPlainDate(e){if(Q(this,BX),!mX(e))throw TypeError(`argument should be an object`);let t=Z(this,X);return RZ(iQ(t,QZ(t,CZ(t,Z(this,KJ),`year-month`),wZ(t,e,[`day`],[],[])),`constrain`),t)}static from(e,t=void 0){return PZ(e,t)}static compare(e,t){let n=PZ(e),r=PZ(t);return Z$(Z(n,KJ),Z(r,KJ))}};function V0(e,t){Q(e,BX);let n=Z(e,KJ);return SZ(e).isoToDate(n,{[t]:!0})[t]}kY(B0,`Temporal.PlainYearMonth`);var H0=i0.prototype.resolvedOptions,U0=class{constructor(e,t,n=`iso8601`){if(arguments.length<1)throw TypeError(`missing argument: epochNanoseconds is required`);let r=r1(e),i=xX(t),{tzName:a,offsetMinutes:o}=$X(i);if(o===void 0){let e=MQ(a);if(!e)throw RangeError(`unknown time zone ${a}`);i=e.identifier}else i=FQ(o);YZ(this,r,i,l1(n===void 0?`iso8601`:xX(n)))}get calendarId(){return Q(this,HX),Z(this,X)}get timeZoneId(){return Q(this,HX),Z(this,QJ)}get year(){return G0(this,`year`)}get month(){return G0(this,`month`)}get monthCode(){return G0(this,`monthCode`)}get day(){return G0(this,`day`)}get hour(){return K0(this,`hour`)}get minute(){return K0(this,`minute`)}get second(){return K0(this,`second`)}get millisecond(){return K0(this,`millisecond`)}get microsecond(){return K0(this,`microsecond`)}get nanosecond(){return K0(this,`nanosecond`)}get era(){return G0(this,`era`)}get eraYear(){return G0(this,`eraYear`)}get epochMilliseconds(){return Q(this,HX),t1(Z(this,GJ),`floor`)}get epochNanoseconds(){return Q(this,HX),e1(Z(this,GJ))}get dayOfWeek(){return G0(this,`dayOfWeek`)}get dayOfYear(){return G0(this,`dayOfYear`)}get weekOfYear(){return G0(this,`weekOfYear`)?.week}get yearOfWeek(){return G0(this,`weekOfYear`)?.year}get hoursInDay(){Q(this,HX);let e=Z(this,QJ),t=W0(this).isoDate,n=YQ(t.year,t.month,t.day+1),r=hQ(e,t),i=hQ(e,n);return X$(IY.fromEpochNsDiff(i,r),`hour`)}get daysInWeek(){return G0(this,`daysInWeek`)}get daysInMonth(){return G0(this,`daysInMonth`)}get daysInYear(){return G0(this,`daysInYear`)}get monthsInYear(){return G0(this,`monthsInYear`)}get inLeapYear(){return G0(this,`inLeapYear`)}get offset(){return Q(this,HX),uQ(lQ(Z(this,QJ),Z(this,GJ)))}get offsetNanoseconds(){return Q(this,HX),lQ(Z(this,QJ),Z(this,GJ))}with(e,t=void 0){if(Q(this,HX),!mX(e))throw TypeError(`invalid zoned-date-time-like`);UX(e);let n=Z(this,X),r=Z(this,QJ),i=lQ(r,Z(this,GJ)),a=W0(this),o={...CZ(n,a.isoDate),...a.time,offset:uQ(i)};o=QZ(n,o,wZ(n,e,[`year`,`month`,`monthCode`,`day`],[`hour`,`minute`,`second`,`millisecond`,`microsecond`,`nanosecond`,`offset`],`partial`));let s=$(t),c=oZ(s),l=cZ(s,`prefer`),u=DZ(n,o,aZ(s)),d=kQ(o.offset);return XZ(FZ(u.isoDate,u.time,`option`,d,r,c,l,!1),r,n)}withPlainTime(e=void 0){Q(this,HX);let t=Z(this,QJ),n=Z(this,X),r=W0(this).isoDate,i;return i=e===void 0?hQ(t,r):fQ(t,iZ(r,Z(MZ(e),JJ)),`compatible`),XZ(i,t,n)}withTimeZone(e){Q(this,HX);let t=sQ(e);return XZ(Z(this,GJ),t,Z(this,X))}withCalendar(e){Q(this,HX);let t=tQ(e);return XZ(Z(this,GJ),Z(this,QJ),t)}add(e,t=void 0){return Q(this,HX),W$(`add`,this,e,t)}subtract(e,t=void 0){return Q(this,HX),W$(`subtract`,this,e,t)}until(e,t=void 0){return Q(this,HX),P$(`until`,this,e,t)}since(e,t=void 0){return Q(this,HX),P$(`since`,this,e,t)}round(e){if(Q(this,HX),e===void 0)throw TypeError(`options parameter is required`);let t=typeof e==`string`?s1(`smallestUnit`,e):$(e),n=uZ(t),r=sZ(t,`halfExpand`),i=hZ(t,`smallestUnit`,`time`,mZ,[`day`]),a={day:1,hour:24,minute:60,second:60,millisecond:1e3,microsecond:1e3,nanosecond:1e3}[i];if(dZ(n,a,a===1),i===`nanosecond`&&n===1)return XZ(Z(this,GJ),Z(this,QJ),Z(this,X));let o=Z(this,QJ),s=Z(this,GJ),c=W0(this),l;if(i===`day`){let e=c.isoDate,t=YQ(e.year,e.month,e.day+1),n=hQ(o,e),i=hQ(o,t),a=Y.default.subtract(i,n);l=IY.fromEpochNsDiff(s,n).round(a,r).addToEpochNs(n)}else{let e=q$(c,n,i,r),t=lQ(o,s);l=FZ(e.isoDate,e.time,`option`,t,o,`compatible`,`prefer`,!1)}return XZ(l,o,Z(this,X))}equals(e){Q(this,HX);let t=IZ(e),n=Z(this,GJ),r=Z(t,GJ);return!!Y.default.equal(Y.default.BigInt(n),Y.default.BigInt(r))&&!!cQ(Z(this,QJ),Z(t,QJ))&&rQ(Z(this,X),Z(t,X))}toString(e=void 0){Q(this,HX);let t=$(e),n=lZ(t),r=fZ(t),i=function(e){return c1(e,`offset`,[`auto`,`never`],`auto`)}(t),a=sZ(t,`trunc`),o=hZ(t,`smallestUnit`,`time`,void 0);if(o===`hour`)throw RangeError(`smallestUnit must be a time unit other than "hour"`);let s=function(e){return c1(e,`timeZoneName`,[`auto`,`never`,`critical`],`auto`)}(t),{precision:c,unit:l,increment:u}=pZ(o,r);return DQ(this,c,n,s,i,{unit:l,increment:u,roundingMode:a})}toLocaleString(e=void 0,t=void 0){Q(this,HX);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,QJ),OQ(r.timeZone))throw RangeError(`toLocaleString does not currently support offset time zones`);let i=new i0(e,r),a=H0.call(i).calendar,o=Z(this,X);if(o!==`iso8601`&&a!==`iso8601`&&!rQ(a,o))throw RangeError(`cannot format ZonedDateTime with calendar ${o} in locale with calendar ${a}`);return i.format(JZ(Z(this,GJ)))}toJSON(){return Q(this,HX),DQ(this,`auto`)}valueOf(){d1(`ZonedDateTime`)}startOfDay(){Q(this,HX);let e=Z(this,QJ);return XZ(hQ(e,W0(this).isoDate),e,Z(this,X))}getTimeZoneTransition(e){Q(this,HX);let t=Z(this,QJ);if(e===void 0)throw TypeError(`options parameter is required`);let n=c1(typeof e==`string`?s1(`direction`,e):$(e),`direction`,[`next`,`previous`],mZ);if(n===void 0)throw TypeError(`direction option is required`);if(OQ(t)||t===`UTC`)return null;let r=Z(this,GJ),i=n===`next`?BQ(t,r):VQ(t,r);return i===null?null:XZ(i,t,Z(this,X))}toInstant(){return Q(this,HX),JZ(Z(this,GJ))}toPlainDate(){return Q(this,HX),RZ(W0(this).isoDate,Z(this,X))}toPlainTime(){return Q(this,HX),WZ(W0(this).time)}toPlainDateTime(){return Q(this,HX),BZ(W0(this),Z(this,X))}static from(e,t=void 0){return IZ(e,t)}static compare(e,t){let n=IZ(e),r=IZ(t),i=Z(n,GJ),a=Z(r,GJ);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 W0(e){return dQ(Z(e,QJ),Z(e,GJ))}function G0(e,t){Q(e,HX);let n=W0(e).isoDate;return SZ(e).isoToDate(n,{[t]:!0})[t]}function K0(e,t){return Q(e,HX),W0(e).time[t]}kY(U0,`Temporal.ZonedDateTime`);var q0=Object.freeze({__proto__:null,Duration:P0,Instant:O0,Now:R0,PlainDate:k0,PlainDateTime:j0,PlainMonthDay:F0,PlainTime:z0,PlainYearMonth:B0,ZonedDateTime:U0});(class{toTemporalInstant(){return JZ(n1(Date.prototype.valueOf.call(this)))}}).prototype.toTemporalInstant;var J0=[O0,k0,j0,P0,F0,z0,B0,U0];for(let e of J0){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 Y0(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 X0(e,t){return Y0(new Date(e),t)}function Z0(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=q0.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 Q0(e,t){return new Intl.DateTimeFormat(void 0,{timeZone:t,dateStyle:`medium`,timeStyle:`short`}).format(new Date(e))}var $0=[[1,`Mon`],[2,`Tue`],[3,`Wed`],[4,`Thu`],[5,`Fri`],[6,`Sat`],[0,`Sun`]];function e2({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`?X0(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,k]=(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}))}))),[A,j]=(0,m.useState)(!1),[ee,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,j(!0),o(!0);try{if(!P.current){if(!te)throw Error(`Choose a template before saving the schedule.`);let e=S.trim();if(!oJ(e))throw Error(`Choose a valid IANA timezone, such as Europe/Tirane.`);let t=f===`once`?{kind:f,at:Z0(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:t2(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 CJ(s,t,a):await SJ(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(``),k([]),n()}catch(e){M(P.current!==null),r(e instanceof Error?e.message:`Could not save the schedule. Try again.`)}finally{N.current=!1,j(!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:A||ee||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)(oM,{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)(oM,{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)(oM,{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:$0.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)(oM,{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)(oM,{id:`schedule-spend`,inputMode:`numeric`,value:E,onChange:e=>D(e.target.value),placeholder:`1000`})]}),(0,h.jsx)(n2,{variants:O,onChange:k})]}),(0,h.jsxs)(`div`,{className:`mt-4 flex gap-2`,children:[(0,h.jsx)(B,{type:`submit`,disabled:t||A||F.length===0&&!ee,children:A?`Saving…`:ee?`Retry save`:i?`Save changes`:`Save schedule`}),i?(0,h.jsx)(B,{type:`button`,disabled:A||ee,onClick:a,children:`Cancel editing`}):null]})]})]})}function t2(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 n2({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 r2(){let{api:e}=I(),t=_(),n=nt(bJ(e)),r=nt(cq(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:yJ})},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)(WA,{"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)(e2,{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:yJ})},onError:e=>{a(e),t.invalidateQueries({queryKey:yJ})}},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)(Mj,{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)(i2,{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)(i2,{schedule:e,pending:!1,onAction:y,error:null,onEdit:()=>void 0},e.id))})]}):null]})}function i2({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 xJ(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: ${Q0(e.nextRunAt,e.timezone)}`:`Deleted: ${Q0(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(()=>wJ(a,e.id,`pause`,e.version)),children:[(0,h.jsx)(tj,{"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(()=>wJ(a,e.id,`resume`,e.version)),children:[(0,h.jsx)(nj,{"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)(aj,{"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)(YA,{"aria-hidden":`true`,className:`size-4`}):(0,h.jsx)(KA,{"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)(jj,{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 TJ(a,e.id,e.version):await wJ(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,` · `,Q0(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 a2(){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 o2({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,v=e.cliPath?.command??g,y=l??p??``,b=Ik(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),Xj);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)(lK,{state:b?`done`:`pending`}),(0,h.jsx)(`span`,{children:s2(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)(iM,{htmlFor:a,id:o,className:`mb-[5px]`,children:`Executable path`}),(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,h.jsx)(oM,{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)(Qj,{}):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.`]})]})]})}function s2(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 c2=[`llm`,`tts`,`image`],l2={llm:`API keys · LLM`,tts:`API keys · Text to speech`,image:`API keys · Image generation`},u2=`••••••••••••`,d2=`grid grid-cols-[140px_1fr_auto] items-end gap-[14px] border-t border-line px-4 py-[14px] first:border-t-0`,f2=`engraved border-t border-line px-4 py-3 text-ink3 first:border-t-0`;function p2(){let{api:e}=I(),t=nt(vy(e));if(t.error!==null)return(0,h.jsx)(Mj,{children:(0,h.jsx)(Nj,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:t.error.message})})});if(t.data===void 0)return(0,h.jsx)(h2,{});let n=t.data.providers,r=n.every(e=>e.readiness.kind!==`keyed`||!e.readiness.hasKey);return(0,h.jsx)(Mj,{children:c2.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:f2,children:l2[e]}),n.filter(t=>t.family===e).map(e=>e.readiness.kind===`cli`?(0,h.jsx)(o2,{provider:e,readiness:e.readiness},e.id):(0,h.jsx)(m2,{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 m2({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)},Xj);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:d2,children:[(0,h.jsx)(`span`,{id:o,className:`pb-[7px] font-semibold`,children:e.displayName}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(iM,{htmlFor:i,id:a,className:`mb-[5px]`,children:`API key`}),(0,h.jsx)(oM,{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?u2: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)(Qj,{}):null,t?(0,h.jsx)(B,{className:`bg-transparent`,"aria-label":`Remove ${e.displayName} key`,onClick:()=>{x(!0)},children:`Remove`}):null]}),(0,h.jsx)(jj,{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 h2(){return(0,h.jsx)(Mj,{children:[0,1,2,3].map(e=>(0,h.jsxs)(Nj,{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 g2=ev,_2=iv;function v2({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)(KA,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-ink2`})})]})}function y2({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 b2({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)(GA,{"aria-hidden":`true`,className:`size-[14px] text-done`})})]})}var x2=`px-4 align-top`;function S2(){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)(Mj,{children:(0,h.jsx)(Nj,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message})})});let c=n.data?.voices;return(0,h.jsxs)(Mj,{"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(x2,`engraved w-[26%] py-3 text-left text-ink3`),children:`Voices · Name`}),(0,h.jsx)(`th`,{className:z(x2,`engraved w-[26%] py-3 text-left text-ink3`),children:`Provider`}),(0,h.jsx)(`th`,{className:z(x2,`engraved py-3 text-left text-ink3`),children:`Voice ID`}),(0,h.jsx)(`th`,{className:z(x2,`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(x2,`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(x2,`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(x2,`py-3 font-semibold`),children:e.name}),(0,h.jsx)(`td`,{className:z(x2,`py-3 text-ink2`),children:T2(s,e.provider)}),(0,h.jsx)(`td`,{className:z(x2,`py-3 text-ink2 tabular-nums`),children:e.voiceId}),(0,h.jsx)(`td`,{className:z(x2,`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)(C2,{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)(jj,{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 C2({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(x2,`py-[14px]`),children:[(0,h.jsx)(iM,{htmlFor:r,className:`mb-[5px]`,children:`Voice name`}),(0,h.jsx)(oM,{id:r,value:c,"aria-invalid":S(`name`)!==void 0,onChange:e=>{let t=e.target.value;x(`name`,()=>{l(t)})}}),(0,h.jsx)(w2,{id:`${s}-name`,message:S(`name`)})]}),(0,h.jsxs)(`td`,{className:z(x2,`py-[14px]`),children:[(0,h.jsx)(iM,{id:a,className:`mb-[5px]`,children:`Provider`}),(0,h.jsxs)(g2,{value:y??``,onValueChange:t=>{let n=e.find(e=>e.id===t);n!==void 0&&x(`provider`,()=>{p(n.id)})},children:[(0,h.jsx)(v2,{id:i,"aria-labelledby":`${a} ${i}`,children:(0,h.jsx)(_2,{placeholder:`Pick a provider`})}),(0,h.jsx)(y2,{children:e.map(e=>(0,h.jsx)(b2,{value:e.id,children:e.displayName},e.id))})]}),(0,h.jsx)(w2,{id:`${s}-provider`,message:S(`provider`)})]}),(0,h.jsxs)(`td`,{className:z(x2,`py-[14px]`),children:[(0,h.jsx)(iM,{htmlFor:o,className:`mb-[5px]`,children:`Voice ID`}),(0,h.jsx)(oM,{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)(w2,{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(x2,`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 w2({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 T2(e,t){return e.find(e=>e.id===t)?.displayName??t}var E2=[`storage-usage`],D2=[E2,V.settings,V.providers,V.voices,V.prompts,V.entries,V.staging,rq,UO,[`provider-models`]];async function O2(e){await Promise.all(D2.map(t=>e.invalidateQueries({queryKey:t})))}var k2=30,A2=[{value:`system`,label:`System`},{value:`dark`,label:`Dark`},{value:`light`,label:`Light`}];function j2(e){let t=e.trim();return/^\d+$/.test(t)&&Number(t)>=0&&Number(t)<=k2?void 0:`The silence gap is a whole number of seconds between 0 and ${String(k2)}.`}function M2(){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)(p2,{}),(0,h.jsx)(S2,{}),(0,h.jsx)(a2,{}),(0,h.jsx)(F2,{}),(0,h.jsx)(N2,{})]})}function N2(){let{api:e}=I(),t=_(),n=nt({queryKey:E2,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 O2(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:E2})}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:[P2(n.data.data),` stored · `,P2(n.data.projects),` project files · `,P2(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:P2(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 P2(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 F2(){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)},Xj);return()=>{clearTimeout(e)}},[c]),n.error!==null)return(0,h.jsx)(Mj,{children:(0,h.jsx)(Nj,{children:(0,h.jsx)(`p`,{className:`text-body text-red`,children:n.error.message})})});if(n.data===void 0)return(0,h.jsxs)(Mj,{children:[(0,h.jsx)(`h2`,{className:`engraved border-b border-line px-4 py-3 text-ink3`,children:`Playback`}),(0,h.jsxs)(Nj,{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=j2(f);return(0,h.jsxs)(Mj,{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)(oM,{id:r,type:`number`,inputMode:`numeric`,min:0,max:k2,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)(Qj,{}):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)(Bj,{type:`single`,value:d.appearance,"aria-labelledby":a,className:`justify-self-start`,onValueChange:e=>{let t=A2.find(t=>t.value===e);t!==void 0&&u.mutate({silenceGapSeconds:d.silenceGapSeconds,appearance:t.value})},children:A2.map(e=>(0,h.jsx)(Vj,{value:e.value,children:e.label},e.value))})]})]})}function I2({onApplied:e,beforeApply:t,getGeneration:n,blocked:r=!1}){let{api:i}=I(),a=_(),o=nt(cq(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 lq(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:rq})}async function k(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 fq(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 A(){if(!x)return;let e=x.id,t=await dq(i,x);if(!t.ok)throw Error(t.message);S(null),await a.cancelQueries({queryKey:rq}),a.setQueryData(rq,t=>t?.filter(t=>t.id!==e)),b(`Template deleted.`),await a.invalidateQueries({queryKey:rq})}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)(oM,{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(()=>k(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)(jj,{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(A),onCancel:()=>{f||S(null)}})]})}function L2({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 R2({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 z2(){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)(Mj,{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)(R2,{cells:5}),(0,h.jsx)(J2,{})]}):null:(0,h.jsx)(B2,{usage:t.data})]})}function B2({usage:e}){let t=Object.values(e.counters).every(e=>e===0);return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(L2,{counters:q2(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)(V2,{className:`w-[24%]`,children:`Tokens by stage`}),(0,h.jsx)(V2,{className:`w-[38%]`,children:`Provider · model`}),(0,h.jsx)(V2,{className:`w-[19%] text-right`,children:`Tokens in`}),(0,h.jsx)(V2,{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)(H2,{className:`truncate font-semibold`,children:Lk[e.stage]}),(0,h.jsx)(H2,{className:`truncate text-ink2`,children:U2(e)}),(0,h.jsx)(H2,{className:`text-right tabular-nums`,children:W2.format(e.tokensIn)}),(0,h.jsx)(H2,{className:`text-right tabular-nums`,children:W2.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 V2({children:e,className:t}){return(0,h.jsx)(`th`,{className:`engraved px-4 py-3 text-left text-ink3 ${t}`,children:e})}function H2({children:e,className:t}){return(0,h.jsx)(`td`,{className:`px-4 py-3 align-top text-small ${t}`,children:e})}function U2(e){return e.model===null?e.provider:`${e.provider} · ${e.model}`}var W2=new Intl.NumberFormat(void 0,{maximumFractionDigits:0}),G2=new Intl.NumberFormat(void 0,{maximumFractionDigits:1}),K2=new Intl.NumberFormat(void 0,{notation:`compact`,maximumFractionDigits:1});function q2(e){let t=e.counters;return[{label:`Videos made`,value:W2.format(t.videosMade)},{label:`Hours of audio`,value:G2.format(t.audioSeconds/3600)},{label:`Images made`,value:W2.format(t.imagesMade)},{label:`Tokens used`,value:t.tokensUsed<1e6?W2.format(t.tokensUsed):K2.format(t.tokensUsed)},{label:`Projects`,value:W2.format(t.projects)}]}function J2(){return(0,h.jsx)(Mj,{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 Y2=da({component:yj}),X2=la({getParentRoute:()=>Y2,path:`/`,component:Wq}),Z2=la({getParentRoute:()=>Y2,path:`play`,component:pP}),Q2=la({getParentRoute:()=>Y2,path:`templates`,component:e4}),$2=la({getParentRoute:()=>Y2,path:`schedules`,component:r2});function e4(){let e=wk(),t=Gi();return(0,h.jsx)(I2,{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 t4=la({getParentRoute:()=>Y2,path:`projects/$projectId`,component:u4}),n4=la({getParentRoute:()=>Y2,path:`prompts`,validateSearch:e=>({kind:Aj(e.kind)}),component:d4}),r4=la({getParentRoute:()=>Y2,path:`prompts/new`,validateSearch:e=>{let t=Aj(e.kind);return typeof e.from==`string`?{kind:t,from:e.from}:{kind:t}},component:f4}),i4=la({getParentRoute:()=>Y2,path:`prompts/$promptId`,component:p4}),a4=la({getParentRoute:()=>Y2,path:`entries`,validateSearch:e=>({category:Dj(e.category)}),component:h4}),o4=la({getParentRoute:()=>Y2,path:`entries/new`,validateSearch:e=>{let t=Dj(e.category);return typeof e.from==`string`?{category:t,from:e.from}:{category:t}},component:g4}),s4=la({getParentRoute:()=>Y2,path:`entries/$entryId`,component:_4}),c4=la({getParentRoute:()=>Y2,path:`settings`,component:M2}),l4=la({getParentRoute:()=>Y2,path:`usage`,component:z2});function u4(){let{projectId:e}=t4.useParams();return(0,h.jsx)(Lq,{projectId:e},e)}function d4(){let{kind:e}=n4.useSearch(),t=Gi();return(0,h.jsx)(eJ,{kind:e,onKind:e=>{t({to:`/prompts`,search:{kind:e},replace:!0})}})}function f4(){let{kind:e,from:t}=r4.useSearch(),n=m4();return(0,h.jsx)(Yq,{promptId:void 0,kind:e,from:t,onLeave:n},`${e}:${t??`new`}`)}function p4(){let{promptId:e}=i4.useParams(),t=m4();return(0,h.jsx)(Yq,{promptId:e,kind:`article`,from:void 0,onLeave:t},e)}function m4(){let e=Gi();return t=>{e({to:`/prompts`,search:{kind:t}})}}function h4(){let{category:e}=a4.useSearch(),t=Gi();return(0,h.jsx)(Wj,{category:e,onCategory:e=>{t({to:`/entries`,search:{category:e},replace:!0})}})}function g4(){let{category:e,from:t}=o4.useSearch(),n=v4();return(0,h.jsx)(OM,{entryId:void 0,category:e,from:t,onLeave:n})}function _4(){let{entryId:e}=s4.useParams(),t=v4();return(0,h.jsx)(OM,{entryId:e,category:`intro`,from:void 0,onLeave:t})}function v4(){let e=Gi();return t=>{e({to:`/entries`,search:{category:t}})}}var y4=Y2.addChildren({projectsRoute:X2,playRoute:Z2,templatesRoute:Q2,schedulesRoute:$2,projectRoute:t4,promptsRoute:n4,newPromptRoute:r4,promptRoute:i4,entriesRoute:a4,newEntryRoute:o4,entryRoute:s4,settingsRoute:c4,usageRoute:l4});function b4(){return Oa({routeTree:y4})}function x4(){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 S4(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 C4(e){let t=x4(),n={api:oo(window.location.origin,S4(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:b4()})})})}))}var w4=document.getElementById(`root`);if(w4===null)throw Error(`index.html carries no #root element for the app to mount on`);C4(w4);