@lincyaw/dsh 0.2.0-rc.31 → 0.2.0-rc.32
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.
- package/build/dist/client.js +1 -1
- package/package.json +7 -7
package/build/dist/client.js
CHANGED
|
@@ -1356,7 +1356,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
1356
1356
|
`);let t=e;return t.type==="text"?t.text??t.value??"":t.type==="image"?t.alt??"":t.type==="math"||t.type==="code"?t.value??"":t.type==="extension"?typeof t.fallback=="string"?t.fallback:rh(t.fallback):(t.children??[]).map(rh).join(t.type==="root"?`
|
|
1357
1357
|
`:"")}function Ru(){return{rich:new Map,baseline:new Map,tables:new Map,opaqueInline:new Map,newInlineId:()=>Xe()}}function n6(e,t){for(let n of e)t.baseline.set(n.id,JSON.stringify(n)),n6(n.children,t)}var e6=()=>Xe(),q4e=e=>({id:e.id,type:"presmiumAtom",props:{entityId:e.id,kind:`rich:${e.type}`,label:e.type==="extension"?rh(e.fallback):rh(e)}});function Wl(e,t){return e.flatMap(n=>{if(t.rich.set(n.id,{original:structuredClone(n)}),n.type==="paragraph"||n.type==="heading")return[{id:n.id,type:n.type,props:{...Q3(n.style),...n.type==="heading"?{level:n.level}:{}},content:z1(n.children,t)}];if(n.type==="code")return[{id:n.id,type:"codeBlock",props:{language:n.language},content:n.value}];if(n.type==="math")return[{id:n.id,type:"presmiumMath",content:n.value}];if(n.type==="extension")return[q4e(n)];if(n.type==="blockquote"){let[r,...o]=n.children;return!r||r.type!=="paragraph"?[{...q4e(n),children:Wl(n.children,t)}]:(t.rich.set(n.id,{original:structuredClone(n),paragraphId:r.id}),[{id:n.id,type:"quote",props:Q3(r.style),content:z1(r.children,t),children:Wl(o,t)}])}return n.type==="list"?n.children.map((r,o)=>{let[i,...a]=r.children,s=i?.type==="paragraph"?i:void 0;return t.rich.set(r.id,{listId:n.id,itemId:r.id,paragraphId:s?.id}),{id:r.id,type:r.checked!==void 0?"checkListItem":n.ordered?"numberedListItem":"bulletListItem",props:{...Q3(s?.style),...r.checked!==void 0?{checked:r.checked}:{},...n.ordered&&o===0&&n.start!==void 0?{start:n.start}:{}},content:z1(s?.children??[],t),children:Wl(s?a:r.children,t)}}):[{id:n.id,type:"table",content:{type:"tableContent",columnWidths:n.columnWidths??[],headerRows:n.headerRows??U4e(n.children.length),headerCols:n.headerColumns,rows:n.children.map(r=>({cells:r.children.map(o=>({type:"tableCell",props:{...Q3(o.style),colspan:o.colspan,rowspan:o.rowspan},content:z1(o.children,t)}))}))}}]})}var U4e=e=>Math.min(1,e);function Ect(e,t,n){return n&&n.headerRows===void 0&&e===U4e(t)?{}:{headerRows:e}}function W4e(e,t){return Array.isArray(e.content)?xY(e.content,t):[]}function SY(e,t,n=e.id){let r=nD("textAlignment"in e.props?e.props:{});return{id:n,type:"paragraph",children:W4e(e,t),...r?{style:r}:{}}}function Act(e){return e.type==="bulletListItem"||e.type==="numberedListItem"||e.type==="checkListItem"}function t6(e,t){if(e.type==="list"){t??=new Set,t.add(e.id);for(let n of e.children)for(let r of n.children)t=t6(r,t)}else if(e.type==="blockquote")for(let n of e.children)t=t6(n,t);else if(e.type==="extension")for(let n of e.fallback)t=t6(n,t);return t}function ka(e,t,n){let r=[],o;for(let i of e){let a=t.rich.get(i.id);if(a?.original&&t.baseline.get(i.id)===JSON.stringify(i)){n=t6(a.original,n),r.push(structuredClone(a.original)),o=void 0;continue}if(Act(i)){n??=new Set;let s=i.type==="numberedListItem",l=i.type==="numberedListItem"?i.props.start:void 0,c=r.at(-1);if(c?.type!=="list"||c.ordered!==s||a?.listId&&a.listId!==o){let u=a?.listId&&!n.has(a.listId)?a.listId:e6();o=a?.listId??u,c={id:u,type:"list",ordered:s,...l!==void 0?{start:l}:{},children:[]},n.add(u),r.push(c)}let d={id:a?.itemId??i.id,type:"listItem",children:[SY(i,t,a?.paragraphId??e6()),...ka(i.children,t,n)],...i.type==="checkListItem"?{checked:i.props.checked}:{}};c.children.push(d),t.rich.set(i.id,{...a,original:void 0,listId:c.id,itemId:d.id,paragraphId:d.children[0].id});continue}if(o=void 0,i.type==="paragraph")r.push(SY(i,t));else if(i.type==="heading"){let s=nD(i.props);r.push({id:i.id,type:"heading",level:Math.max(1,Math.min(6,i.props.level)),children:W4e(i,t),...s?{style:s}:{}})}else if(i.type==="quote")r.push({id:i.id,type:"blockquote",children:[SY(i,t,a?.paragraphId??e6()),...ka(i.children,t,n??=new Set)]});else if(i.type==="presmiumMath")r.push({id:i.id,type:"math",value:i.content.map(s=>s.text).join("")});else if(i.type==="codeBlock")r.push({id:i.id,type:"code",language:i.props.language,value:i.content.map(s=>s.text).join("")});else if(i.type==="table"){let s=a?.original?.type==="table"?a.original:void 0,l={id:i.id,type:"table",...Ect(i.content.headerRows??0,i.content.rows.length,s),...i.content.headerCols?{headerColumns:i.content.headerCols}:{},...i.content.columnWidths.length&&i.content.columnWidths.every(c=>typeof c=="number"&&Number.isFinite(c)&&c>0)?{columnWidths:i.content.columnWidths}:{},children:i.content.rows.map((c,d)=>({id:t.tables.get(i.id)?.[d]?.id??s?.children[d]?.id??e6(),type:"tableRow",children:c.cells.map((u,f)=>{let p=Array.isArray(u)?{}:u.props,m=nD(p);return{id:t.tables.get(i.id)?.[d]?.cells[f]??s?.children[d]?.children[f]?.id??e6(),type:"tableCell",children:xY(Array.isArray(u)?u:u.content,t),...m?{style:m}:{},...p.colspan&&p.colspan!==1?{colspan:p.colspan}:{},...p.rowspan&&p.rowspan!==1?{rowspan:p.rowspan}:{}}})}))};t.rich.set(i.id,{original:structuredClone(l)}),r.push(l)}else if(i.type==="presmiumAtom"&&i.props.kind.startsWith("rich:")){if(!a?.original)throw new Error("document-rich-reference");let s=structuredClone(a.original);s.type==="blockquote"?s.children=ka(i.children,t,n??=new Set):n=t6(s,n),r.push(s)}else throw new Error(`document-rich-block:${i.type}`);i.children.length&&i.type!=="quote"&&i.type!=="presmiumAtom"&&r.push(...ka(i.children,t,n??=new Set))}return r}var A0=e=>new Date(e),T0=e=>e&&typeof e=="object"&&!Array.isArray(e)?structuredClone(e):void 0,G4e=(e,t)=>JSON.stringify(e)===JSON.stringify(t),rD=e=>JSON.stringify({userId:e.userId,content:e.content}),_Y=class extends tG{#t;#n;constructor(t){super(),this.#t=t,this.#n=new Nke(t?.id??"","editor")}#o=()=>!!(this.#t?.id&&Xu(this.#t,"editor"));canCreateThread=()=>this.#o();canAddComment=()=>this.#o();canUpdateComment=t=>this.#o()&&(Xu(this.#t,"owner")||this.#n.canUpdateComment(t));canDeleteComment=t=>this.#o()&&this.#n.canDeleteComment(t);canDeleteThread=()=>this.#o();canResolveThread=()=>this.#o();canUnresolveThread=()=>this.#o();canAddReaction=(t,n)=>this.#o()&&this.#n.canAddReaction(t,n);canDeleteReaction=(t,n)=>this.#o()&&this.#n.canDeleteReaction(t,n)},oD=class extends eG{addThreadToDocument=void 0;beforeAction;member;drafts;#t;#n=new Map;#o={};#s;#r;#i=!1;#l=new Map;#a;#c=new Set;#f=Ru();#u=new Map;#h=new Map;constructor(t,n,r,o,i){super(new _Y(n)),this.member=n,this.#s=r,this.#r=t,this.#w(t.comments??{}),this.#t=!i,(i||o&&n?.id)&&(this.drafts=i??new GC(o,n.id))}get version(){return this.#s}get document(){return this.#r}threadSnapshot(t){return this.#o[t]}anchorOf(t){let n=this.#u.get(t);return n?structuredClone(n):void 0}placeAnchorOf(t){let n=this.#u.get(t);return n&&xi(n)?structuredClone(n):void 0}refreshEditorCallbacks(){this.#P()}draftTargetState(t){if(no(t)){if(t.documentId!==this.#r.id||!t.anchor||!t.signature)return"unavailable";let o=KC(this.#r,t.anchor);return o===void 0?"unavailable":o===t.signature?"current":"changed"}let n=this.#o[t.threadId],r=n?.comments.find(o=>o.id===t.commentId);return!n||n.deletedAt||n.createdAt!==t.threadCreatedAt||t.commentId&&(!r||r.deletedAt||r.createdAt!==t.commentCreatedAt)?"unavailable":r&&t.baseline!==Ape(r)?"changed":"current"}newDraftTarget(t,n=Xe()){this.beforeAction?.();let r={kind:"create",intentId:n,documentId:this.#r.id},o=t.prosemirrorState.selection;if(o.empty)return r;let i=kc(t,o.from),a=kc(t,o.to);if(!i||!a)return r;let s={from:{blockId:i.blockId,offset:i.offset},to:{blockId:a.blockId,offset:a.offset}},l=KC(this.#r,s);return l?{...r,anchor:s,signature:l}:r}newDraftPositions(t,n){if(n.prosemirrorView.isDestroyed||this.draftTargetState(t)!=="current"||!t.anchor||!ob(t.anchor)||!t.signature)return;let r=s=>{let l=Bm(n,s);if(l===void 0)return;let c=kc(n,l);return c?.blockId===s.blockId&&c.offset===s.offset?l:void 0},o=r(t.anchor.from),i=r(t.anchor.to);if(o===void 0||i===void 0||o>=i)return;let a=JSON.parse(t.signature);for(let s of a){let l=r({blockId:s.id,offset:0}),c=r({blockId:s.id,offset:s.text.length});if(l===void 0||c===void 0||xye(n.prosemirrorState.doc,l,c)!==s.text)return}return{from:o,to:i}}close(){this.#t&&this.drafts?.close()}get synchronizing(){return this.#i}getThread=t=>{let n=this.#n.get(t);if(!n)throw new Error("document-thread-missing");return n};getThreads=()=>this.#n;subscribe=t=>(this.#c.add(t),()=>this.#c.delete(t));#g(){for(let t of this.#c)t(this.#n)}#w(t,n,r=!1){let o=this.#o;this.#o=structuredClone(t),this.#u.clear(),this.#n=new Map(Object.values(t).map(a=>{this.#u.set(a.id,a.anchor);let s=this.#n.get(a.id);return[a.id,{...a,createdAt:A0(a.createdAt),updatedAt:A0(a.updatedAt),resolvedUpdatedAt:a.resolvedUpdatedAt?A0(a.resolvedUpdatedAt):void 0,deletedAt:a.deletedAt?A0(a.deletedAt):void 0,comments:a.comments.map(l=>{let c=s?.comments.find(p=>p.id===l.id),d=o[a.id]?.comments.find(p=>p.id===l.id),u=r?this.#l.get(l.id):void 0;u&&u.baseline!==rD(l)&&this.#v(u,"changed");let f=l.deletedAt?void 0:u?u.body:n?.id===l.id?n.body:c&&G4e(d?.content,l.content)?c.body:Wl(l.content??[],this.#f);return this.#h.set(l.id,{body:f,content:structuredClone(l.content??[])}),{...l,createdAt:A0(l.createdAt),updatedAt:A0(l.updatedAt),deletedAt:l.deletedAt?A0(l.deletedAt):void 0,body:f,reactions:l.reactions.map(p=>({...p,createdAt:A0(p.createdAt)}))}})}]}));for(let a of this.#l.values())r&&(!a.threadId||!t[a.threadId]?.comments.some(s=>s.id===a.commentId&&!s.deletedAt))&&this.#v(a,"unavailable");let i=new Set(Object.values(t).flatMap(a=>a.comments.map(s=>s.id)));for(let a of this.#h.keys())i.has(a)||this.#h.delete(a)}#m(t){return ka(t.body,this.#f)}#y(t,n){this.beforeAction?.();let r=yz(this.#o,t,{member:this.member,now:new Date().toISOString(),allocate:()=>Xe()});return r.effect.changed&&(this.#w(r.threads,r.effect.commentId&&n!==void 0?{id:r.effect.commentId,body:n}:void 0),this.#g()),r.effect}createThread=async({initialComment:t,metadata:n})=>{let r=this.#y({type:"comment.create",content:this.#m(t),metadata:T0(n),commentMetadata:T0(t.metadata)},t.body);return this.getThread(r.threadId)};createPlaceThread=async({blockId:t,stepId:n,body:r})=>{this.beforeAction?.();let o={blockId:t,...n===void 0?{}:{stepId:n}};ag(this.#r,o);let i=this.#y({type:"comment.create",content:this.#m({body:r}),anchor:o},r);return this.getThread(i.threadId)};addComment=async({threadId:t,comment:n})=>{let r=this.#y({type:"comment.reply",threadId:t,content:this.#m(n),metadata:T0(n.metadata)},n.body);return this.getThread(t).comments.find(o=>o.id===r.commentId)};updateComment=async({threadId:t,commentId:n,comment:r})=>{this.beforeAction?.();let o=this.#a;if(!o||o.threadId!==t||o.commentId!==n||!this.#_(o))throw new Error("comment-editor-version-changed");this.#y({type:"comment.update",threadId:t,commentId:n,content:this.#m(r),metadata:T0(r.metadata)},r.body)};deleteComment=async({threadId:t,commentId:n})=>{this.#y({type:"comment.delete",threadId:t,commentId:n})};deleteThread=async({threadId:t})=>{this.#y({type:"comment.delete",threadId:t})};resolveThread=async({threadId:t})=>{this.#y({type:"comment.resolve",threadId:t})};unresolveThread=async({threadId:t})=>{this.#y({type:"comment.reopen",threadId:t})};addReaction=async({threadId:t,commentId:n,emoji:r})=>{this.#y({type:"comment.react",threadId:t,commentId:n,emoji:r,active:!0})};deleteReaction=async({threadId:t,commentId:n,emoji:r})=>{this.#y({type:"comment.react",threadId:t,commentId:n,emoji:r,active:!1})};#v(t,n){if(t.failure!==n){t.failure=n;for(let r of t.listeners)r()}}#_(t){if(t.closed||!t.editable||!t.threadId||!t.commentId||t.failure)return!1;let n=this.#o[t.threadId],r=n?.comments.find(o=>o.id===t.commentId);return!n||n.deletedAt||!r||r.deletedAt?(this.#v(t,"unavailable"),!1):t.baseline!==rD(r)?(this.#v(t,"changed"),!1):!0}#P(){let t=this.#i;this.#i=!0;try{this.#n=new Map(this.#n),this.#g()}finally{this.#i=t}}bindEditor(t,n,r){let o=new Set(t.document.map(h=>h.id)),i=Object.values(this.#o).filter(h=>h.id===r).flatMap(h=>h.comments.flatMap(g=>{let v=this.#h.get(g.id)?.body;return Array.isArray(v)&&v.some(b=>o.has(b.id))?[{thread:h,comment:g,body:v}]:[]})),a=!n,s=i.length===1?i[0]:void 0,l={threadId:s?.thread.id,commentId:s?.comment.id,baseline:s?rD(s.comment):void 0,body:s?.body,editable:!1,closed:!1,listeners:new Set},c=a?t.getExtension(go):void 0,d,u=()=>{};if(c){t.replaceExtension(c,go({onSubmit:async()=>{try{this.beforeAction?.()}catch{this.#v(l,"unavailable");return}if(!this.#_(l)){l.failure||this.#v(l,"unavailable");return}let g=this.#a,v;try{this.#a=l,v=c.submit()}finally{this.#a=g}await v}})),d=t.getExtension(go);let h=d;u=r6(t,()=>h?.submit()),this.#P()}let f=h=>{if(!(!a||l.closed||h===l.editable))if(l.editable=h,h)l.commentId&&this.#l.set(l.commentId,l),s||this.#v(l,"unavailable");else{l.commentId&&this.#l.get(l.commentId)===l&&this.#l.delete(l.commentId);let g=l.threadId?this.#o[l.threadId]?.comments.find(v=>v.id===l.commentId):void 0;g&&l.failure&&(this.#w(this.#o,{id:g.id,body:Wl(g.content??[],this.#f)},!0),this.#P())}};f(n);let p=r?this.#o[r]:void 0;return{target:p&&(!a||s)?{threadId:p.id,threadCreatedAt:p.createdAt,...a&&s?{commentId:s.comment.id,commentCreatedAt:s.comment.createdAt,baseline:rD(s.comment)}:{}}:void 0,restoreBaseline:h=>{a&&l.editable&&!l.closed&&(l.baseline=h,!this.#_(l)&&!l.failure&&this.#v(l,"unavailable"))},setEditable:f,failure:()=>l.failure,subscribe:h=>(l.listeners.add(h),()=>l.listeners.delete(h)),close:()=>{l.closed||(f(!1),l.closed=!0,l.listeners.clear(),u(),c&&d&&!t.prosemirrorView.isDestroyed&&t.getExtension(go)===d&&t.replaceExtension(d,c))}}}synchronize(t,n,r,o,i=!1){if(this.#i||(this.#r=t,this.drafts?.synchronize(t,n,i),n===void 0||n===this.#s))return;this.#s=n;let a=t.comments;if(!G4e(a??{},this.#o)){this.#i=!0;try{this.#w(a??{},void 0,!0),this.restoreAnchors(r,o),this.#g();let s=r.getExtension(ro),l=s.store.state.selectedThreadId;l&&(!this.#n.has(l)||this.#n.get(l).resolved||this.#n.get(l).deletedAt)&&s.selectThread(void 0,!1)}finally{this.#i=!1}}}restoreAnchors(t,n){let r=t.getExtension(ro),o=r.tiptapExtensions[0].name,i=[...this.#u].flatMap(([a,s])=>{if(!s||!ob(s))return[];try{ag(this.#r,s)}catch{return[]}let l=(u,f)=>{if(!n)return Bm(t,u);let p=eW(n.before,u);return p===void 0?void 0:n.mapping.map(p,f)},c=l(s.from,1),d=l(s.to,-1);return c!==void 0&&d!==void 0&&c<d?[{threadId:a,from:c,to:d,orphan:!!(this.#n.get(a)?.resolved||this.#n.get(a)?.deletedAt)}]:[]});t.transact(a=>{let s=a.doc.type.schema.marks[o];a.removeMark(0,a.doc.content.size,s);for(let{threadId:l,from:c,to:d,orphan:u}of i)a.addMark(c,d,s.create({threadId:l,orphan:u}));a.setMeta("addToHistory",!1)})}snapshot(t,n=this.#r){let r=t.getExtension(ro).store.state.threadPositions,o=Object.fromEntries([...this.#n.values()].map(i=>{let a=this.#u.get(i.id),s;if(a&&xi(a)){let c=bz(n,a);s=c&&xi(c)?c:void 0}else{let c=r.get(i.id),d=c?kc(t,c.from):void 0,u=c?kc(t,c.to):void 0;s=d&&u?{from:{blockId:d.blockId,offset:d.offset},to:{blockId:u.blockId,offset:u.offset}}:void 0}s?this.#u.set(i.id,structuredClone(s)):this.#u.delete(i.id);let l={id:i.id,type:"thread",createdAt:i.createdAt.toISOString(),updatedAt:i.updatedAt.toISOString(),resolved:i.resolved,...i.resolvedUpdatedAt?{resolvedUpdatedAt:i.resolvedUpdatedAt.toISOString()}:{},...i.resolvedBy?{resolvedBy:i.resolvedBy}:{},...i.deletedAt?{deletedAt:i.deletedAt.toISOString()}:{},...T0(i.metadata)?{metadata:T0(i.metadata)}:{},...s?{anchor:s}:{},comments:i.comments.map(c=>({id:c.id,type:"comment",userId:c.userId,createdAt:c.createdAt.toISOString(),updatedAt:c.updatedAt.toISOString(),...c.deletedAt?{deletedAt:c.deletedAt.toISOString()}:{content:this.#h.get(c.id)?.body===c.body?structuredClone(this.#h.get(c.id).content):ka(c.body,this.#f)},...T0(c.metadata)?{metadata:T0(c.metadata)}:{},reactions:c.reactions.map(d=>({...d,createdAt:d.createdAt.toISOString()}))}))};return[l.id,l]}));return this.#o=o,o}};function Tct(e){let t=e?.name.trim();return t&&!(e.id===N_.id&&e.name===N_.name)?t:void 0}function r6(e,t){let n=e.prosemirrorView.dom,r=o=>{let i=e.prosemirrorView;o.key!=="Enter"||o.shiftKey||o.altKey||o.ctrlKey||o.metaKey||!i.editable||i.composing||o.isComposing||o.keyCode===229||(o.preventDefault(),o.stopPropagation(),o.repeat||t())};return n.addEventListener("keydown",r,!0),()=>n.removeEventListener("keydown",r,!0)}function K4e(e,t){let n=i=>i.map(a=>({id:a,avatarUrl:"",username:a===e.member?.id?Tct(e.member)??t:a==="local-author"||a===N_.id?t:a})),r=L4(async i=>n(i)),o=new Set(e.member?[e.member.id]:[]);for(let i of e.getThreads().values()){i.resolvedBy&&o.add(i.resolvedBy);for(let a of i.comments){o.add(a.userId);for(let s of a.reactions)for(let l of s.userIds)o.add(l)}}return r.setUser(n([...o])),ro({threadStore:e,schema:h2,resolveUsers:r})}var J4e=Ot(({editor:e})=>{let t,n=()=>(t=void 0,!1);return{key:"presmium-native-comment-selection",runsBefore:["comments"],mount:()=>(n(),()=>{n()}),prosemirrorPlugins:[new nt({props:{handleDOMEvents:{mousedown(r,o){n();let i=e.getExtension(ro);if(o.button!==0||o.defaultPrevented||!r.editable||r.composing||!i||i.store.state.pendingComment)return!1;let a=o.target instanceof Element?o.target.closest("[data-bn-thread-id]"):null;if(!a||!r.dom.contains(a)||a.hasAttribute("data-orphan"))return!1;let s=a.getAttribute("data-bn-thread-id"),l=s?i.threadStore.getThreads().get(s):void 0;return s&&l&&!l.resolved&&!l.deletedAt&&i.store.state.threadPositions.has(s)&&i.store.state.selectedThreadId!==s&&(t=s,i.selectThread(s,!1)),!1},pointercancel:n,dragstart:n,blur:n,keydown:n},handleClick(r,o,i){let a=t,s=e.getExtension(ro);return n(),!!(a&&s?.store.state.selectedThreadId===a&&i.button===0&&!i.defaultPrevented&&r.editable&&!r.composing&&r.state.doc.nodeAt(o)?.marks.some(l=>l.type.name===s.tiptapExtensions[0].name&&l.attrs.threadId===a&&l.attrs.orphan!==!0))}}})]}});function Y4e(e){let t=e.getExtension(ro).tiptapExtensions[0].name;return e.onBeforeChange(({tr:n})=>{n.steps.length&&n.steps.every(r=>(r instanceof Nb||r instanceof ip)&&r.mark.type.name===t)&&n.setMeta("addToHistory",!1)})}var Zt=require("react");function j1(e){let t=typeof e.parameterSchema=="object"&&typeof e.parameterSchema.title=="string"?e.parameterSchema.title.trim():"";if(t)return Array.from(t).slice(0,80).join("");let n=e.implementation,r=n.type==="file"?n.path.split("/").at(-1)?.replace(/\.(tsx?|jsx?|mjs|cjs)$/,""):n.type==="plugin"?n.name:n.specifier.split("/").at(-1);return Array.from(r||e.kind).slice(0,80).join("")}var Br=require("react/jsx-runtime"),Cc=(0,Zt.createContext)(void 0),X4e=(0,Zt.createContext)(void 0),PY=()=>()=>{},Q4e={candidates:[],pending:!1,failed:!1,reading:!1},CY=e=>JSON.stringify([e.id,e.revision,e.token]),e3e=ba.Comments.Editor,Z4e=new WeakMap;function t3e(e){return(0,Br.jsx)(X4e.Provider,{value:e.thread.id,children:(0,Br.jsx)(pR,{...e})})}function n3e(){let e=rt(),{selectedThreadId:t,threadPositions:n}=pn(ro),r=Gn({editor:e,on:"selection",selector:({editor:p})=>p.prosemirrorState.selection.empty}),[o,i]=(0,Zt.useState)(!1),a=o||!r,s=!!(t&&n.has(t)),l=(0,Zt.useRef)(!1),c=(0,Zt.useRef)(t);l.current=s&&!a,c.current=t;let d=(0,Zt.useRef)(),u=(0,Zt.useRef)();(0,Zt.useEffect)(()=>{let p=()=>e.prosemirrorView,m=!1,h=w=>{let _=p();w.target instanceof Element&&_?.dom.contains(w.target)&&w.target.closest("[data-bn-thread-id]")&&(d.current={x:w.clientX,y:w.clientY},u.current=void 0),!(w.button!==0||w.isPrimary===!1||!_?.editable||_.composing||!(w.target instanceof Element)||!_.dom.contains(w.target)||w.target.closest('[contenteditable="false"]'))&&(m=!0,l.current||i(!0))},g=w=>{m&&w.buttons&1&&document.getSelection()?.isCollapsed===!1&&i(!0)},v=()=>{m&&(m=!1,i(document.getSelection()?.isCollapsed===!1))},b=w=>{!(w.target instanceof Node)||!p()?.dom.contains(w.target)||(m=!1,i(!1),d.current=void 0,u.current=void 0)},y=()=>{m&&(m=!1,i(!0))};return document.addEventListener("pointerdown",h,!0),document.addEventListener("pointermove",g,!0),document.addEventListener("keydown",b,!0),document.addEventListener("click",v),document.addEventListener("pointercancel",y,!0),window.addEventListener("blur",y),()=>{m=!1,document.removeEventListener("pointerdown",h,!0),document.removeEventListener("pointermove",g,!0),document.removeEventListener("keydown",b,!0),document.removeEventListener("click",v),document.removeEventListener("pointercancel",y,!0),window.removeEventListener("blur",y)}},[e]);let f=(0,Zt.useMemo)(()=>ZM(()=>{let p=c.current,m=e.prosemirrorView?.dom;if(!p||!m)return;let h=[...m.querySelectorAll(`[data-bn-thread-id="${CSS.escape(p)}"]:not([data-orphan="true"])`)].flatMap(g=>[...g.getClientRects()]).filter(g=>g.width>0&&g.height>0);if(h.length){if(u.current?.thread!==p){let g=d.current,v=b=>g?Math.hypot(Math.max(b.left-g.x,0,g.x-b.right),Math.max(b.top-g.y,0,g.y-b.bottom)):0;u.current={thread:p,index:h.reduce((b,y,w)=>v(y)<v(h[b])?w:b,0)}}return h[Math.min(u.current.index,h.length-1)]}}),[e]);return(0,Br.jsx)(jG,{floatingThread:t3e,floatingUIOptions:{useFloatingOptions:{...f,open:s&&!a},elementProps:{className:a?"pm-ui-comment-hidden":void 0}}})}function Ict(e,t,n){if(!e)return"";let r=e.blocks[t.blockId],o;if(r?.type==="component"){let s=e.definitions[r.definitionId],l=typeof r.parameters.title=="string"?r.parameters.title.trim():"",c=s?.data&&typeof s.data.title=="string"?s.data.title.trim():"",d=s&&typeof s.parameterSchema=="object"&&typeof s.parameterSchema.title=="string"?s.parameterSchema.title.trim():"",u=l||c||d||(s?j1(s):r.definitionId);o=s?.kind==="scene"?n.animation(u):n.component(u)}else r?.type==="code"?o=n.codeReference(r.title??r.origin?.anchor??r.language):r?.type==="image"?o=r.alt||n.block:r?.type==="text"?o=(r.content[0]?Array.from(rh(r.content[0]).replace(/\s+/g," ").trim()).slice(0,40).join(""):"")||n.block:r?.type==="container"?o=r.properties.title||n.block:o=n.block;if(t.stepId===void 0)return n.placeCommentReference(o);let i=e.steps[t.stepId],a=i?e.sections[i.sectionId]:void 0;return n.placeCommentReference(o,i&&a?a.stepOrder.indexOf(i.id)+1:0)}function r3e({children:e}){let t=rt(),n=an(ro),r=v3(),{selectedThreadId:o,threadPositions:i}=pn(ro),a=(0,Zt.useContext)(Cc),s=ao[a?.locale??"en"],l=me(g=>g.authoring?.content)??a?.store.document,c=(0,Zt.useMemo)(()=>l?vz(l):new Map,[l]),d=g=>{let v=a?.store.anchorOf(g);if(!v)return Number.MAX_VALUE;if(xi(v)){let y=c.get(v.blockId),w=v.stepId===void 0?void 0:l?.steps[v.stepId],_=w&&l?l.sections[w.sectionId]:void 0;return y===void 0?Number.MAX_VALUE:y*1e6+(w&&_?_.stepOrder.indexOf(w.id):0)}let b=c.get(v.from.blockId);return b===void 0?Number.MAX_VALUE:b*1e6+Math.min(999999,v.from.offset)},u=g=>{let v=a?.store.anchorOf(g);return v&&xi(v)?Ict(l,v,s):yxe(t,i.get(g))},f=g=>{let v=a?.store.anchorOf(g);return!(v&&xi(v))&&!i.has(g)},p=[...r.values()].sort((g,v)=>d(g.id)-d(v.id)||g.createdAt.getTime()-v.createdAt.getTime()),m=(g,v)=>{v.target.closest(".bn-action-toolbar")||n.selectThread(g)},h=g=>{let v=g.relatedTarget;if(!v||v.closest(".bn-action-toolbar"))return;let b=v.closest(".bn-thread");(!b||!(g.target instanceof Node)||!b.contains(g.target))&&n.selectThread(void 0)};return(0,Br.jsxs)("div",{className:"bn-threads-sidebar",children:[e,(0,Br.jsx)(Mct,{}),!p.length&&(0,Br.jsx)(Kc,{icon:"comment",children:s.commentsEmpty}),p.map(g=>(0,Br.jsx)(t3e,{thread:g,selected:o===g.id,orphaned:f(g.id),referenceText:u(g.id),onFocus:v=>m(g.id,v),onBlur:h,tabIndex:0},g.id))]})}function Rct({candidate:e}){let t=(0,Zt.useRef)(Ru()),n=Fl({schema:h2,trailingBlock:!1,initialContent:Wl(e.content,t.current)},[e.id,e.revision,e.token]);return(0,Br.jsx)(e3e,{editor:n,editable:!1,autoFocus:!1})}function g2({candidates:e,disabled:t,onRecover:n,onDiscard:r,preview:o=!1,canRecover:i,unavailableMessage:a}){let s=(0,Zt.useContext)(Cc),l=ao[s?.locale??"en"],[c,d]=(0,Zt.useState)(""),[u,f]=(0,Zt.useState)(!1),p=e.find(h=>CY(h)===c),m=async h=>{if(!(!p||u||t)){f(!0);try{await h(p)}finally{f(!1)}}};return e.length?(0,Br.jsxs)(ke,{tone:"accent",children:[(0,Br.jsxs)(sr,{label:l.commentDrafts,value:p?c:"",disabled:t||u,onChange:h=>d(h.target.value),children:[(0,Br.jsx)("option",{value:"",children:l.commentChooseDraft}),e.map(h=>(0,Br.jsxs)("option",{value:CY(h),children:[new Date(h.updatedAt).toLocaleString(s?.locale)," \xB7 ",no(h.target)?l.commentNewDraft:h.target.commentId?l.commentEditDraft:l.commentReplyDraft,h.storage==="session"?` \xB7 ${l.commentSessionOnly}`:""]},CY(h)))]}),p&&o&&(0,Br.jsx)(Rct,{candidate:p}),p&&a&&i&&!i(p)&&(0,Br.jsx)(ke,{tone:"warn",children:a}),(0,Br.jsxs)("span",{className:"pmw-notice__actions",children:[n&&(0,Br.jsx)(he,{small:!0,variant:"primary",disabled:!p||t||u||p.storage==="session"||i&&!i(p),loading:u,onClick:()=>void m(n),children:l.commentRecover}),(0,Br.jsx)(he,{small:!0,disabled:!p||t||u,onClick:()=>void m(r),children:l.commentDiscard})]})]}):null}function Mct(){let e=(0,Zt.useContext)(Cc),t=e?.store.drafts,n=(0,Zt.useSyncExternalStore)(t?.subscribe??PY,t?.snapshot??(()=>Q4e)),r=n.candidates.filter(o=>!no(o.target)&&(o.storage==="session"||e?.store.draftTargetState(o.target)==="unavailable"));return t?(0,Br.jsxs)(Br.Fragment,{children:[n.failed&&(0,Br.jsx)(ke,{tone:"warn",children:ao[e?.locale??"en"].commentBackupFailed}),(0,Br.jsx)(g2,{candidates:r,preview:!0,onDiscard:async o=>{await t.discard(o)}})]}):null}function o3e(e){let t=(0,Zt.useContext)(Cc),n=(0,Zt.useContext)(X4e),[r,o]=(0,Zt.useState)(),[,i]=(0,Zt.useState)(0),[a,s]=(0,Zt.useState)(!1),l=(0,Zt.useRef)(r),c=(0,Zt.useRef)(0);l.current=r;let d=(0,Zt.useRef)(e),u=(0,Zt.useRef)(!0),f=(0,Zt.useRef)(0),p=(0,Zt.useRef)(!1),m=(0,Zt.useRef)(!1),h=(0,Zt.useRef)(!1);d.current=e;let g=t?.store.drafts,v=(0,Zt.useMemo)(()=>{let I=Z4e.get(e.editor);return(!I||I.owner!==g)&&(I={owner:g,rich:Ru()},Z4e.set(e.editor,I)),I},[e.editor,g]),b=(0,Zt.useMemo)(()=>({current:v.rich}),[v]),y=(0,Zt.useRef)(Xe()),w=(0,Zt.useSyncExternalStore)(g?.subscribe??PY,g?.snapshot??(()=>Q4e));(0,Zt.useLayoutEffect)(()=>{if(!t||!n)return;u.current=!0,++f.current,v.current&&g&&!g.owns(v.current)&&(v.current=void 0);let I=t.store.bindEditor(e.editor,e.editable,n);o(I);let C=e.editor.getExtension(go),A,R=()=>{};if(C&&I.target&&g){e.editor.replaceExtension(C,go({onSubmit:async()=>{if(p.current||!u.current)return;let D=I.target,$=t.store.threadSnapshot(D.threadId),j=new Set($?.comments.map(te=>te.id)),J=v.current;m.current=!0;try{let te=C.submit(),V=t.store.threadSnapshot(D.threadId),ee=D.commentId?V?.comments.find(Y=>Y.id===D.commentId):V?.comments.find(Y=>!j.has(Y.id));ee&&V!==$&&(g.submitted(J,ee),v.current=void 0,i(Y=>Y+1)),await te}finally{m.current=!1}}})),A=e.editor.getExtension(go);let L=A;R=r6(e.editor,()=>L?.submit()),t.store.refreshEditorCallbacks()}let O=e.editor.onChange(()=>{if(!u.current||!d.current.editable||h.current||m.current)return;++f.current,s(!1);let L=t.store.version;if(!I.target||!g||!L)return;if(e.editor.isEmpty&&!I.target.commentId){v.current&&(g.clearOwn(v.current),v.current=void 0);return}let D=ka(e.editor.document,b.current);v.current=g.write(v.current?.target??I.target,v.current?.version??L,D,p.current,v.current)??v.current,i($=>$+1)});return()=>{u.current=!1,++f.current,O(),R(),C&&A&&!e.editor.prosemirrorView.isDestroyed&&e.editor.getExtension(go)===A&&e.editor.replaceExtension(A,C),I.close()}},[t?.store,e.editor,n]);let _=(0,Zt.useRef)(e.editable);(0,Zt.useLayoutEffect)(()=>{if(r?.setEditable(e.editable),_.current&&!e.editable&&v.current&&g){let I=v.current;v.current=void 0,g.clearOwn(I)}_.current=e.editable},[r,e.editable,g]),(0,Zt.useLayoutEffect)(()=>{c.current++,s(!1)},[r,e.editable]);let x=(0,Zt.useSyncExternalStore)(r?.subscribe??PY,r?.failure??(()=>{})),k=r?.target,S=ao[t?.locale??"en"],E=k?w.candidates.filter(I=>zb(I.target,k)&&I.id!==v.current?.id):[],P=async(I,C)=>{if(!g||!k||!t?.store.version||!e.editable||p.current||m.current||e.editor.prosemirrorView.composing)return;t.store.beforeAction?.();let A=f.current,R=t.store.version,O=e.editor.prosemirrorState,L=t.getPositionToken?.(),D=v.current,$=()=>{if(C?.signal?.throwIfAborted(),C?.guard?.(),t.store.beforeAction?.(),!u.current||f.current!==A||t.store.version!==R||p.current||m.current||!d.current.editable||e.editor.prosemirrorView.isDestroyed||e.editor.prosemirrorView.composing||e.editor.prosemirrorState.doc!==O.doc||e.editor.prosemirrorState.selection!==O.selection||t.getPositionToken?.()!==L||v.current!==D||t.store.draftTargetState(k)==="unavailable")throw new Error("client-comment-composer-changed")};if(D&&!await g.confirm(D))return;$();let j=await g.recover(I,k,R,{signal:C?.signal,guard:$});if(j){$(),h.current=!0;try{e.editor.replaceBlocks(e.editor.document,Wl(j.content,b.current));let J=ka(e.editor.document,b.current);if(JSON.stringify(J)!==JSON.stringify(j.content))throw new Error("client-comment-native-unverified");v.current=j,r?.restoreBaseline(no(I.target)?void 0:I.target.baseline),++f.current,i(te=>te+1)}finally{h.current=!1}return C||await g.discard(I),j}};(0,Zt.useLayoutEffect)(()=>{if(!(!g||!k||!e.editable))return g.registerComposer({id:y.current,target:k,snapshot:()=>{let I=u.current&&d.current.editable&&!m.current&&!e.editor.prosemirrorView.isDestroyed;return{record:v.current,composing:p.current||I&&e.editor.prosemirrorView.composing,available:I}},targetState:()=>t?.store.draftTargetState(k)??"unavailable",restore:P})},[g,r,e.editor,e.editable]);let T=I=>{p.current=I,v.current&&k&&g&&t?.store.version&&(v.current=g.write(v.current.target,v.current.version,ka(e.editor.document,b.current),I,v.current)??v.current,i(C=>C+1))};return(0,Br.jsxs)("div",{"data-comment-draft-editor":k?JSON.stringify([k.threadId,k.commentId??null]):void 0,"aria-busy":w.pending||void 0,onCompositionStart:()=>T(!0),onCompositionEnd:()=>T(!1),children:[(0,Br.jsx)(e3e,{...e}),a&&(0,Br.jsx)(ke,{tone:"warn",children:S.commentRecoveryChanged}),x&&(0,Br.jsx)(ke,{tone:"danger",children:x==="changed"?S.commentChanged:S.commentUnavailable}),g&&e.editable&&(0,Br.jsx)(g2,{candidates:E,disabled:p.current||m.current,onRecover:async I=>{let C=r,A=c.current;s(!1);try{await P(I)}catch{u.current&&d.current.editable&&l.current===C&&c.current===A&&s(!0)}},onDiscard:async I=>{await g.discard(I)}}),g&&e.editable&&w.failed&&!t?.sidebar&&(0,Br.jsx)(ke,{tone:"warn",children:S.commentBackupFailed})]})}var bn=require("react");var ws=require("react/jsx-runtime"),o6=(0,bn.createContext)(void 0),i3e=()=>()=>{},a3e={candidates:[],pending:!1,failed:!1,reading:!1};function s3e({children:e}){let t=(0,bn.useContext)(Cc),n=rt(),r=an(ro),o=(0,bn.useRef)(),i=(0,bn.useRef)(),a=(0,bn.useRef)(!0),s=(0,bn.useRef)(0),[l,c]=(0,bn.useState)(!1);(0,bn.useEffect)(()=>(a.current=!0,()=>{a.current=!1,++s.current,i.current=void 0,o.current=void 0}),[n]);let d=async(u,f=()=>!0)=>{let p=t?.store,m=p?.drafts,h=u.target;if(!p||!m||!no(h)||u.storage!=="durable"||n.prosemirrorView.isDestroyed||n.prosemirrorView.composing)return;let g=o.current;g?.record&&!m.owns(g.record)&&(g.record=void 0);let v=++s.current,b=g?.input,y=g?.record;try{if(p.beforeAction?.(),!p.auth.canCreateThread()||p.draftTargetState(h)!=="current"||!p.newDraftPositions(h,n)){c(!0);return}let w=p.version,_=n.prosemirrorState,x=r.store.state,k=t.getPositionToken?.();if(!w||g?.composing||g?.editor.prosemirrorView.composing)return;let S=()=>a.current&&f()&&v===s.current&&!n.prosemirrorView.isDestroyed&&!n.prosemirrorView.composing&&p.version===w&&t.getPositionToken?.()===k&&n.prosemirrorState.doc===_.doc&&n.prosemirrorState.selection===_.selection&&r.store.state===x&&(!g||o.current===g&&g.input===b&&g.record===y&&!g.composing);if(y&&!await m.confirm(y)||!S())return;let E={...h,intentId:Xe()},P=await m.recover(u,E,w);if(p.beforeAction?.(),!P||!S())return;let T=p.newDraftPositions(E,n);if(!T){c(!0);return}r.stopPendingComment(),n.focus(),n.transact(I=>I.setSelection($e.create(I.doc,T.from,T.to)).scrollIntoView()),i.current={record:P,origin:u,doc:n.prosemirrorState.doc,selection:n.prosemirrorState.selection,version:w},r.startPendingComment(),i.current.selection=n.prosemirrorState.selection,c(!1),t.onDraftRestore?.()}catch{a.current&&v===s.current&&c(!0)}};return(0,ws.jsx)(o6.Provider,{value:{editor:n,latest:o,prepared:i,restore:d,failure:l},children:e})}function l3e(){let e=(0,bn.useContext)(o6),t=(0,bn.useContext)(Cc),n=an(ro),r=rt(),o=Ct(),i=pn(ro,{editor:r,selector:c=>c.pendingComment}),a=Fl({trailingBlock:!1,dictionary:{...o,placeholders:{...o.placeholders,emptyDocument:o.placeholders.new_comment}},schema:n.commentEditorSchema,extensions:[go({submitOnEnter:n.submitOnEnter,onSubmit:async c=>{await n.createThread({initialComment:{body:c.document}}),n.stopPendingComment(),r.transact(d=>{d.setSelection($e.create(d.doc,d.selection.to))}),r.focus()}})]},[i]),s=Gn({editor:r,selector:({editor:c})=>i?{from:c.prosemirrorState.selection.from,to:c.prosemirrorState.selection.to}:void 0}),l=(0,bn.useMemo)(()=>ZM(),[]);return(0,ws.jsx)(_x,{position:s,focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:Dct}},useFloatingOptions:{placement:"bottom",...l,open:i,onOpenChange(c){if(!(c||!e||e.latest.current?.composing||e.latest.current?.editor.prosemirrorView.composing)){try{t?.store.beforeAction?.()}catch{return}n.stopPendingComment(),e.editor.prosemirrorView.isDestroyed||e.editor.focus()}}},children:(0,ws.jsx)(Oct,{newCommentEditor:a})})}var Dct=60;function Oct({newCommentEditor:e}){let t=(0,bn.useContext)(o6),n=(0,bn.useContext)(Cc),r=st(),[o,i]=(0,bn.useState)(),[,a]=(0,bn.useState)(0);(0,bn.useLayoutEffect)(()=>{if(!(!t||!n))try{n.store.beforeAction?.();let l=t.prepared.current,c=l&&l.version===n.store.version&&l.doc===t.editor.prosemirrorState.doc&&l.selection===t.editor.prosemirrorState.selection&&e.isEmpty&&no(l.record.target)&&n.store.newDraftPositions(l.record.target,t.editor)?l:void 0,u={target:c&&no(c.record.target)?c.record.target:n.store.newDraftTarget(t.editor),editor:e,record:c?.record,origin:c?.origin,input:0,composing:!1,active:!0};return c&&(t.prepared.current=void 0),t.latest.current=u,i(u),()=>{u.active=!1}}catch{}},[e,n?.store,t?.editor]);let s=(0,bn.useMemo)(()=>({...r,Comments:{...r.Comments,Editor:Nct}}),[r]);return(0,ws.jsx)(c3e.Provider,{value:{binding:o,ready:()=>a(l=>l+1)},children:(0,ws.jsx)(e0.Provider,{value:s,children:(0,ws.jsx)(zG,{newCommentEditor:e})})})}var c3e=(0,bn.createContext)(void 0);function Nct(e){let t=(0,bn.useContext)(Cc),n=(0,bn.useContext)(o6),r=(0,bn.useContext)(c3e),o=r?.binding,i=(0,bn.useMemo)(()=>Ru(),[e.editor]),a=(0,bn.useRef)(!1),s=(0,bn.useRef)(!1),[l,c]=(0,bn.useState)(!1),d=t?.store.drafts,u=(0,bn.useSyncExternalStore)(d?.subscribe??i3e,d?.snapshot??(()=>a3e));(0,bn.useLayoutEffect)(()=>{if(!o||!d||!t||!n)return;o.record&&e.editor.isEmpty&&(e.editor.replaceBlocks(e.editor.document,Wl(o.record.content,i)),o.origin&&(d.discard(o.origin),o.origin=void 0));let h=e.editor.getExtension(go),g,v=()=>{};if(h){e.editor.replaceExtension(h,go({onSubmit:async()=>{if(!(!o.active||o.composing||e.editor.prosemirrorView.composing))try{t.store.beforeAction?.();let w=t.store.newDraftPositions(o.target,n.editor),_=n.editor.prosemirrorState.selection;if(!t.store.auth.canCreateThread()||!w||_.from!==w.from||_.to!==w.to){c(!0);return}let x=new Set(t.store.getThreads().keys()),k=o.record;s.current=!0;try{let S=h.submit(),E=[...t.store.getThreads().values()].find(T=>!x.has(T.id)),P=E&&t.store.threadSnapshot(E.id);P&&(d.submitted(k,P.comments[0],P),o.record=void 0),await S}finally{s.current=!1}}catch{c(!0)}}})),g=e.editor.getExtension(go),r.ready();let y=g;v=r6(e.editor,()=>y?.submit())}let b=e.editor.onChange(()=>{if(!(!o.active||a.current||s.current||!t.store.version)){if(++o.input,e.editor.isEmpty){o.record&&(d.clearOwn(o.record),o.record=void 0);return}o.record=d.write(o.record?.target??o.target,o.record?.version??t.store.version,ka(e.editor.document,i),o.composing,o.record)??o.record}});return()=>{b(),v(),h&&g&&!e.editor.prosemirrorView.isDestroyed&&e.editor.getExtension(go)===g&&e.editor.replaceExtension(g,h)}},[o,d,e.editor]);let f=(0,bn.useRef)(Xe());(0,bn.useLayoutEffect)(()=>{if(!(!o||!d||!t))return d.registerComposer({id:f.current,target:o.target,snapshot:()=>{let h=o.active&&!s.current&&!e.editor.prosemirrorView.isDestroyed;return{record:o.record,composing:o.composing||h&&e.editor.prosemirrorView.composing,available:h}},targetState:()=>t.store.draftTargetState(o.target)})},[o,d,e.editor]);let p=ao[t?.locale??"en"],m=h=>{o&&(o.composing=h,o.record&&d&&(o.record=d.write(o.record.target,o.record.version,ka(e.editor.document,i),h,o.record)??o.record))};return(0,ws.jsxs)("div",{onCompositionStart:()=>m(!0),onCompositionEnd:()=>m(!1),children:[(0,ws.jsx)(ba.Comments.Editor,{...e}),l&&(0,ws.jsx)(ke,{tone:"warn",children:p.commentTargetUnavailable}),u.failed&&(0,ws.jsx)(ke,{tone:"warn",children:p.commentBackupFailed})]})}function d3e(){let e=(0,bn.useContext)(Cc),t=(0,bn.useContext)(o6),n=e?.store.drafts,r=(0,bn.useRef)(!0);(0,bn.useLayoutEffect)(()=>(r.current=!0,()=>{r.current=!1}),[t?.editor]);let o=(0,bn.useSyncExternalStore)(n?.subscribe??i3e,n?.snapshot??(()=>a3e)),i=ao[e?.locale??"en"],a=o.candidates.filter(s=>no(s.target)&&!(s.target.anchor&&xi(s.target.anchor)));return!n||!t?null:(0,ws.jsxs)(ws.Fragment,{children:[t.failure&&(0,ws.jsx)(ke,{tone:"warn",children:i.commentTargetUnavailable}),(0,ws.jsx)(g2,{candidates:a,preview:!0,canRecover:s=>no(s.target)&&!!e?.store.newDraftPositions(s.target,t.editor),unavailableMessage:i.commentTargetUnavailable,onRecover:s=>t.restore(s,()=>r.current),onDiscard:async s=>{let l=t.latest.current,c=l?.record,d=l?.input,{token:u,storage:f,...p}=s;await n.discard(s)&&l&&t.latest.current===l&&l.input===d&&l.record===c&&c&&JSON.stringify(c)===JSON.stringify(p)&&(l.record=void 0)}})]})}var _t=require("react/jsx-runtime"),EY={colors:{editor:{background:"var(--pm-color-surface)",text:"var(--pm-color-ink)"},menu:{background:"var(--pm-color-surface)",text:"var(--pm-color-ink)"},tooltip:{background:"var(--pm-color-surface)",text:"var(--pm-color-ink)"},hovered:{background:"var(--pm-color-sunk)",text:"var(--pm-color-ink)"},selected:{background:"var(--pm-color-accent-soft)",text:"var(--pm-color-accent)"},disabled:{background:"var(--pm-color-sunk)",text:"var(--pm-color-muted)"},border:"var(--pm-color-line)",shadow:"var(--pm-color-backdrop)",sideMenu:"var(--pm-color-muted)"},fontFamily:"var(--pm-font-sans)"},Fct=ba.Comments.Comment,Lct=(0,Pc.forwardRef)(function(t,n){let r=y3("(pointer: coarse)",!1,{getInitialValueInEffect:!1}),o=[t.className,t.actions?"pm-ui-comment-actions-row":void 0].filter(Boolean).join(" ");return(0,_t.jsx)(Fct,{...t,ref:n,className:o,showActions:r&&t.showActions==="hover"?!0:t.showActions})}),u3e=ba.Generic.Badge.Root,Bct=(0,Pc.forwardRef)(function(t,n){if(!t.className?.split(/\s+/).includes("bn-comment-reaction"))return(0,_t.jsx)(u3e,{...t,ref:n});let r=[t.mainTooltip,t.secondaryTooltip?.replace(/\s+/g," ")].filter(Boolean).join(" \xB7 ");return(0,_t.jsx)(Ry,{label:r,children:(0,_t.jsx)("span",{children:(0,_t.jsx)(u3e,{...t,mainTooltip:void 0,secondaryTooltip:void 0,ref:n,onClick:o=>{o.target instanceof HTMLInputElement&&t.onClick?.(o)}})})})}),f3e=ba.Generic.Toolbar.Button,$ct=(0,Pc.forwardRef)(function(t,n){let r=t.label??t.mainTooltip;return r===void 0?(0,_t.jsx)(f3e,{...t,ref:n}):(0,_t.jsx)(f3e,{...t,ref:n,label:r})}),zct={...ba,Generic:{...ba.Generic,Menu:{...ba.Generic.Menu,Root:h4e},Badge:{...ba.Generic.Badge,Root:Bct},Toolbar:{...ba.Generic.Toolbar,Button:$ct}},Comments:{...ba.Comments,Comment:Lct,Editor:o3e}};function jct(e){let t=rt(vY);return Gn({editor:t,selector:({editor:r})=>r.getSelection()?.blocks.some(o=>o.type==="presmiumPage")??!1})?(0,_t.jsx)(n0,{...e,children:(0,_t.jsx)(u3,{})}):(0,_t.jsxs)(n0,{...e,children:[(0,_t.jsx)(gG,{items:e.blockTypeSelectItems}),(0,_t.jsx)(vp,{basicTextStyle:"bold"}),(0,_t.jsx)(vp,{basicTextStyle:"italic"}),(0,_t.jsx)(vp,{basicTextStyle:"underline"}),(0,_t.jsx)(vp,{basicTextStyle:"strike"}),(0,_t.jsx)(vp,{basicTextStyle:"code"}),(0,_t.jsx)(v1,{textAlignment:"left"}),(0,_t.jsx)(v1,{textAlignment:"center"}),(0,_t.jsx)(v1,{textAlignment:"right"}),(0,_t.jsx)(R4e,{}),(0,_t.jsx)(mG,{}),(0,_t.jsx)(hG,{}),(0,_t.jsx)(pG,{}),(0,_t.jsx)($4e,{}),(0,_t.jsx)(vG,{}),(0,_t.jsx)(u3,{})]})}function Vct({editor:e}){return Gn({editor:e,selector:({editor:n})=>{if(n.prosemirrorState.selection.empty)return!1;let r=!1;return n.prosemirrorState.selection.content().content.descendants(o=>(o.type.spec.content==="text*"&&(r=!0),!r)),r}})&&e.getExtension("comments")?(0,_t.jsx)("div",{className:"pm-document-editor__comment-tools",children:(0,_t.jsx)(n0,{children:(0,_t.jsx)(u3,{})})}):null}function p3e(e,t){let n=e.findLastIndex(r=>r.group===t[0]?.group);return n<0?[...e,...t]:[...e.slice(0,n+1),...t,...e.slice(n+1)]}function m3e(e){let t=(0,Pc.useRef)(e),n=(0,Pc.useMemo)(()=>({controllers:new Set,pending:Promise.resolve()}),[e.identity,e.reset??0]),[r,o]=(0,Pc.useState)();t.current=e;let i=t3(e.locale),a=ao[e.locale],s=(0,Pc.useMemo)(g4e,[]),l=(0,Pc.useMemo)(()=>({openSection:u=>t.current.onSectionLink?.(u)??!1}),[]),c=f4e[e.locale],d=Fl({schema:vY,initialContent:e.initialContent,resolveFileUrl:u=>t.current.resolveAssetURL?.(u)??Promise.resolve(u),uploadFile:e.uploadImage?u=>{let f=new AbortController,p=t.current.uploadImage;n.controllers.add(f);let m=n.pending.then(async()=>{if(f.signal.throwIfAborted(),t.current.identity!==e.identity)throw new DOMException("Document changed","AbortError");return p(u,f.signal)});return n.pending=m.then(()=>{},()=>{}),m.finally(()=>{n.controllers.delete(f)})}:void 0,disableExtensions:["dropFile"],pasteHandler:({event:u,editor:f,defaultPasteHandler:p})=>{let m=[...u.clipboardData?.files??[]];return m.length&&!u.clipboardData?.getData("text/html")?(f.getExtension(bY)?.insert(m),!0):p({prioritizeMarkdownOverHTML:!1})},dictionary:i,tables:{splitCells:!0,cellBackgroundColor:!0,cellTextColor:!0,headers:!0},links:{onClick:()=>!0},extensions:[C4e,F_e,A4e(),bY({onStart:()=>{t.current.identity===e.identity&&o(void 0)},onFailure:u=>{t.current.identity===e.identity&&o(f=>({identity:e.identity,failures:[...f?.identity===e.identity?f.failures:[],u]}))}}),...e.comments?[J4e(),K4e(e.comments,a.author)]:[]],domAttributes:{block:{"data-document-editor-block":""},editor:{lang:e.contentLang??e.locale}}},[e.identity,e.reset??0]);return(0,Pc.useEffect)(()=>{let u=t.current.comments?Y4e(d):void 0;return t.current.onReady?.(d),()=>{for(let f of n.controllers)f.abort();n.controllers.clear(),u?.(),t.current.onReady?.(void 0)}},[d]),(0,_t.jsx)(X3.Provider,{value:e.locale,children:(0,_t.jsx)(wY.Provider,{value:l,children:(0,_t.jsx)(QM.Provider,{value:e.nodeViews??{},children:(0,_t.jsx)(Cc.Provider,{value:e.comments?{store:e.comments,locale:e.locale,sidebar:!!e.commentsPortal,readOnly:!!e.readOnly,getPositionToken:()=>t.current.getPositionToken?.(),onDraftRestore:()=>t.current.onCommentDraftRestore?.(),openComments:()=>t.current.onOpenComments?.()}:void 0,children:(0,_t.jsxs)("div",{className:"pm-document-editor pm-ui-block-editor pm-ui","data-document-editor":e.identity,onDragEnter:u=>{u.dataTransfer.types.includes("Files")&&u.stopPropagation()},onDragOver:u=>{u.dataTransfer.types.includes("Files")&&u.stopPropagation()},onClick:u=>{let p=(u.target instanceof Element?u.target.closest('a[data-inline-content-type="link"]'):null)?.getAttribute("href");!p||u.button!==0||(u.preventDefault(),kY(p,l))},onCompositionStart:()=>t.current.onComposition?.(!0),onCompositionEnd:()=>queueMicrotask(()=>t.current.onComposition?.(!1)),children:[r?.identity===e.identity&&(0,_t.jsx)(ke,{tone:"danger",children:(0,_t.jsxs)("div",{className:"pm-document-editor__file-errors",children:[(0,_t.jsx)("ul",{children:r.failures.map((u,f)=>(0,_t.jsxs)("li",{children:[u.name," \xB7 ",c[u.kind]]},f))}),(0,_t.jsx)(Et,{small:!0,icon:"close",label:c.dismiss,onClick:()=>o(void 0)})]})}),(0,_t.jsx)($3,{editor:d,editable:!e.readOnly,theme:EY,formattingToolbar:!1,slashMenu:!1,linkToolbar:!1,sideMenu:!1,tableHandles:!1,renderEditor:!1,comments:!1,onChange:()=>t.current.onChange(d.document,d),onSelectionChange:()=>t.current.onSelection?.(_ye(d)),children:(0,_t.jsxs)(e0.Provider,{value:zct,children:[(0,_t.jsx)(Vct,{editor:d}),(0,_t.jsx)(OG,{children:(0,_t.jsxs)(s3e,{children:[(0,_t.jsx)(l3e,{}),!e.commentsPortal&&(0,_t.jsx)(n3e,{}),e.commentsPortal&&(0,_t.jsx)(_t.Fragment,{children:(0,_t.jsx)(N9,{target:e.commentsPortal,children:(0,_t.jsx)(r3e,{children:(0,_t.jsx)(d3e,{})})})}),(0,_t.jsx)(f3,{formattingToolbar:jct}),(0,_t.jsx)(xG,{linkToolbar:z4e,floatingUIOptions:s}),(0,_t.jsx)(g3,{sideMenu:M4e}),(0,_t.jsx)(MG,{tableHandle:F4e,tableCellHandle:O4e}),(0,_t.jsx)(PG,{triggerCharacter:"/",getItems:async u=>d.getTextCursorPosition().block.type==="presmiumPage"?[]:sx([...p3e(p3e(CG(d),B4e(d,e.locale,i.slash_menu.table.group)),t.current.animationRequest?.available()?[{title:a.animateWithAI,subtext:a.animateWithAIHint,group:i.slash_menu.image.group,icon:(0,_t.jsx)(dn,{name:"sparkle"}),aliases:m2("animateWithAIAliases"),onItemClick:()=>t.current.animationRequest?.request(d)}]:[]),{title:a.page,aliases:m2("pageAliases"),group:a.document,onItemClick:()=>{let f=d.getTextCursorPosition().block;d.insertBlocks([{type:"presmiumPage",props:{sectionId:Xe()},content:a.untitledPage}],f,"after")}}],u)}),e.children]})})]})}),(0,_t.jsx)("div",{className:"pm-document-editor__end","aria-hidden":"true","data-editable":e.readOnly?void 0:"",onMouseDown:u=>{u.button!==0||!d.isEditable||d.prosemirrorView.composing||(u.preventDefault(),T4e(d))}})]})})})})})}var I0=require("react");var Gl=require("react/jsx-runtime"),AY={"zh-CN":{field:"\u8BB2\u7A3F",captions:"\u5B57\u5E55",pronunciation:"\u53D1\u97F3",display:"\u663E\u793A\u6587\u5B57",spoken:"\u5B9E\u9645\u8BFB\u97F3",done:"\u786E\u5B9A",cancel:"\u53D6\u6D88",cue:"\u63D0\u793A",empty:"\u8F93\u5165\u672C\u6B65\u8BB2\u7A3F\u2026",emptyCaptions:"\u8F93\u5165\u5B57\u5E55\u2026",cueTitle:e=>`\u63D0\u793A\uFF1A${e}`,actions:{next:"\u4E0B\u4E00\u6B65",spot:"\u805A\u5149",hint:"\u9AD8\u4EAE",point:"\u6307\u793A",click:"\u70B9\u51FB",run:"\u8FD0\u884C",ink:"\u6807\u6CE8",pause:"\u505C\u987F",mark:"\u6807\u8BB0",call:"\u8C03\u7528",hover:"\u60AC\u505C",move:"\u79FB\u52A8"}},en:{field:"Script",captions:"Captions",pronunciation:"Pronunciation",display:"Written text",spoken:"Spoken text",done:"Apply",cancel:"Cancel",cue:"Cue",empty:"Write this step\u2019s script\u2026",emptyCaptions:"Write captions\u2026",cueTitle:e=>`Cue: ${e}`,actions:{next:"Next Step",spot:"Spotlight",hint:"Highlight",point:"Pointer",click:"Click",run:"Run",ink:"Ink",pause:"Pause",mark:"Mark",call:"Call",hover:"Hover",move:"Move"}}},TY=(0,I0.createContext)({locale:"zh-CN"}),Hct=Px({type:"narrationAtom",propSchema:{kind:{default:"cue"},cueId:{default:""},payload:{default:""},display:{default:""},spoken:{default:""}},content:"none"},{render:({inlineContent:e,updateInlineContent:t})=>{let{locale:n,readOnly:r,advanced:o}=(0,I0.useContext)(TY),i=AY[n],[a,s]=(0,I0.useState)(!1),[l,c]=(0,I0.useState)(""),[d,u]=(0,I0.useState)(""),f=e.props;if(f.kind==="cue"){if(o===!1)return(0,Gl.jsx)("span",{contentEditable:!1,className:"pm-ui-narration-editor__cue",children:i.cue});let p="";try{p=String(JSON.parse(f.payload).action??"")}catch{}let m=i.actions[p];return(0,Gl.jsxs)("span",{contentEditable:!1,className:"pm-ui-narration-editor__cue",title:m?i.cueTitle(m):i.cue,children:[i.cue,m?` \xB7 ${m}`:""]})}return o===!1?(0,Gl.jsx)("span",{contentEditable:!1,children:f.display}):(0,Gl.jsxs)("span",{contentEditable:!1,children:[(0,Gl.jsx)(he,{small:!0,variant:"ghost",disabled:r,title:f.spoken,onClick:()=>{c(f.display),u(f.spoken),s(!0)},children:f.display||i.pronunciation}),(0,Gl.jsxs)(kn,{open:a,label:i.pronunciation,closeLabel:i.cancel,onClose:()=>s(!1),actions:(0,Gl.jsxs)(Gl.Fragment,{children:[(0,Gl.jsx)(he,{small:!0,onClick:()=>s(!1),children:i.cancel}),(0,Gl.jsx)(he,{small:!0,variant:"primary",onClick:()=>{t({type:"narrationAtom",props:{...f,display:l,spoken:d}}),s(!1)},children:i.done})]}),children:[(0,Gl.jsx)(Kn,{label:i.display,value:l,onChange:p=>c(p.target.value)}),(0,Gl.jsx)(Kn,{label:i.spoken,value:d,onChange:p=>u(p.target.value)})]})]})}});function h3e(e,t){let n=r=>{let o=Xe();return t(r,o),o};return[Ot({key:"presmium-narration-cue-identities",tiptapExtensions:[Zn.create({name:"presmiumNarrationCueIdentities",addProseMirrorPlugins:()=>[new nt({props:{transformPasted:r=>{let o=i=>{let a=[];return i.forEach(s=>a.push(s.type.name==="narrationAtom"&&s.attrs.kind==="cue"?s.type.create({...s.attrs,cueId:n(s.attrs.cueId)},s.content,s.marks):s.isLeaf?s:s.copy(o(s.content)))),Ce.fromArray(a)};return new Le(o(r.content),r.openStart,r.openEnd)}},appendTransaction:(r,o,i)=>{let a=new Set,s=i.tr,l=e();return i.doc.descendants((c,d)=>{if(c.type.name!=="narrationAtom"||c.attrs.kind!=="cue")return;let u=c.attrs.cueId,f=i.doc.resolve(d),p;for(let m=f.depth;m>0;m--)if(f.node(m).type.name==="blockContainer"){p=f.node(m).attrs.id;break}!u||a.has(u)||l.has(u)&&l.get(u)!==p?s.setNodeMarkup(d,void 0,{...c.attrs,cueId:n(u)}):a.add(u)}),s.docChanged?s:null}})]})]})]}var g3e=fp.create({blockSpecs:{paragraph:Eo.paragraph},inlineContentSpecs:{...Ug,narrationAtom:Hct},styleSpecs:{}});var $r=require("react/jsx-runtime");function iD(e){let t=(0,xa.useRef)(null),n=(0,xa.useRef)(),r=(0,xa.useRef)(e);return r.current=e,(0,xa.useEffect)(()=>{let o=t.current,i=o.shadowRoot??o.attachShadow({mode:"open"}),a=[...document.head.querySelectorAll('link[rel="stylesheet"], style')].map(u=>u.cloneNode(!0)),s=document.createElement("div");i.append(...a,s);let l=(0,b3e.createRoot)(s);n.current=l;let c=u=>u.stopPropagation(),d=["keydown","keyup","keypress","beforeinput","input","compositionstart","compositionupdate","compositionend","mousedown","mouseup","pointerdown","pointerup","click","dblclick","contextmenu","focusin","focusout","copy","cut","paste","dragstart","dragover","drop"];for(let u of d)s.addEventListener(u,c);return l.render((0,$r.jsx)(v3e,{...r.current})),()=>{n.current=void 0;for(let u of d)s.removeEventListener(u,c);queueMicrotask(()=>{l.unmount(),s.remove(),a.forEach(u=>u.parentNode?.removeChild(u))})}},[]),(0,xa.useEffect)(()=>{n.current?.render((0,$r.jsx)(v3e,{...e}))}),(0,$r.jsx)("div",{ref:t,contentEditable:!1,"data-narration-editor":e.fieldId})}function qct(){let e=st(),t=Ct(),n=Ao(),r=an(ma);return(0,$r.jsxs)(e.Generic.Menu.Root,{position:"left",portalElement:n,onOpenChange:o=>{o?r.freezeMenu():r.unfreezeMenu()},children:[(0,$r.jsx)(e.Generic.Menu.Trigger,{children:(0,$r.jsx)(e.SideMenu.Button,{label:t.side_menu.drag_handle_label,icon:(0,$r.jsx)(dn,{name:"more"})})}),(0,$r.jsx)(m3,{children:(0,$r.jsx)(p3,{children:t.drag_handle.delete_menuitem})})]})}function Uct(){let e=rt(),t=st(),n=Ct(),r=pn(ma,{selector:o=>o?.block});return r?(0,$r.jsx)(t.SideMenu.Button,{label:n.side_menu.add_block_label,icon:(0,$r.jsx)(dn,{name:"plus"}),onClick:()=>{let[o]=e.insertBlocks([{type:"paragraph"}],r,"after");e.setTextCursorPosition(o,"start"),e.focus()}}):null}function Wct(e){return(0,$r.jsxs)(h3,{...e,children:[(0,$r.jsx)(Uct,{}),(0,$r.jsx)(qct,{})]})}function v3e(e){let t=(0,xa.useRef)(e),n=(0,xa.useRef)([]);t.current=e;let r=e.getContent?.()??e.content,o=JSON.stringify(r),i=JSON.stringify([e.identity,e.fieldId,e.reset]),a=(0,xa.useRef)({key:i,incoming:o,epoch:0});if(a.current.key!==i)a.current.epoch++,a.current.key=i,n.current=[];else if(a.current.incoming!==o){let y=n.current.lastIndexOf(o);y>=0?n.current.splice(0,y+1):(a.current.epoch++,n.current=[])}a.current.incoming=o;let s=(0,xa.useMemo)(()=>({content:structuredClone(r),emitted:o}),[i,a.current.epoch]),l=(0,xa.useRef)(s);l.current=s;let c=AY[e.locale],d=Fl({schema:g3e,initialContent:e.toNative(s.content),trailingBlock:!1,dictionary:{...t3(e.locale),placeholders:{...t3(e.locale).placeholders,default:e.advanced===!1?c.emptyCaptions:c.empty}},extensions:h3e(()=>t.current.cueOwners?.()??new Map,(y,w)=>t.current.onCueCopy?.(y,w)),domAttributes:{editor:{"aria-label":e.advanced===!1?c.captions:c.field}}},[s,e.advanced]),u=(0,xa.useMemo)(()=>JSON.stringify(d.document),[d]),[f,p]=(0,xa.useState)(!1),[m,h]=(0,xa.useState)(""),[g,v]=(0,xa.useState)("");(0,xa.useEffect)(()=>(t.current.onReady?.(d),()=>{e.onComposition?.(!1),e.onReady?.(void 0)}),[d]);let b=()=>{if(l.current===s&&!(t.current.getContent&&t.current.getContent()===void 0))try{let y=JSON.stringify(d.document)===u?structuredClone(s.content):t.current.fromNative(d.document),w=JSON.stringify(y);if(w===s.emitted)return;s.emitted=w,n.current.push(w),t.current.onChange(y)}catch(y){t.current.onError?.(y instanceof Error?y:new Error(String(y)))}};return(0,$r.jsx)(TY.Provider,{value:{locale:e.locale,readOnly:e.readOnly,advanced:e.advanced},children:(0,$r.jsxs)("div",{className:"pm-ui-narration-editor pm-ui-block-editor pm-ui","data-block-menu":e.blockMenu||void 0,onFocus:()=>t.current.onFocus?.(),onCompositionStart:()=>t.current.onComposition?.(!0),onCompositionEnd:()=>queueMicrotask(()=>{l.current===s&&t.current.onComposition?.(!1)}),children:[(0,$r.jsx)($3,{editor:d,editable:!e.readOnly,theme:EY,formattingToolbar:!1,sideMenu:!1,slashMenu:!1,linkToolbar:!1,comments:!1,onChange:b,children:e.blockMenu&&(0,$r.jsx)(g3,{sideMenu:Wct})}),e.advanced!==!1&&(0,$r.jsx)("div",{className:"pm-ui-narration-editor__actions",children:(0,$r.jsx)(he,{small:!0,variant:"ghost",disabled:e.readOnly,onClick:()=>{h(d.getSelectedText()),v(""),p(!0)},children:c.pronunciation})}),(0,$r.jsxs)(kn,{open:f,label:c.pronunciation,closeLabel:c.cancel,onClose:()=>p(!1),actions:(0,$r.jsxs)($r.Fragment,{children:[(0,$r.jsx)(he,{small:!0,onClick:()=>p(!1),children:c.cancel}),(0,$r.jsx)(he,{small:!0,variant:"primary",disabled:!m,onClick:()=>{d.insertInlineContent([{type:"narrationAtom",props:{kind:"pronunciation",display:m,spoken:g,cueId:"",payload:""}}],{updateSelection:!0}),p(!1),d.focus()},children:c.done})]}),children:[(0,$r.jsx)(Kn,{label:c.display,value:m,onChange:y=>h(y.target.value)}),(0,$r.jsx)(Kn,{label:c.spoken,value:g,onChange:y=>v(y.target.value)})]})]})})}function y3e(e,t){return{capture:()=>{if(!e.prosemirrorView.hasFocus())return;let n=e.prosemirrorState;return{content:t(),document:n.doc.toJSON(),selection:n.selection.getBookmark()}},restore:n=>{if(n.content!==t())return!1;let r=e.prosemirrorState.schema.nodeFromJSON(n.document);return e.transact(o=>{o.replaceWith(0,o.doc.content.size,r.content),o.setSelection(n.selection.resolve(o.doc)),o.setMeta("addToHistory",!1)}),e.focus(),!0}}}var w3e=e=>y3e(e,()=>JSON.stringify(IY(e.document)));function i6(e,t){return[{id:e,type:"paragraph",content:t.map(n=>n.type==="text"?{type:"text",text:n.text,styles:{}}:{type:"narrationAtom",content:void 0,props:n.type==="pronunciation"?{kind:"pronunciation",display:n.display,spoken:n.spoken,cueId:"",payload:""}:{kind:"cue",cueId:n.id,payload:JSON.stringify(n),display:"",spoken:""}})}]}function k3e(e,t){return e.length?e.flatMap(n=>i6(n.id,n.content)):i6(t,[])}function IY(e){let t=[],n=r=>{for(let o of r)t.push({id:o.id,content:RY([{...o,children:[]}])}),n(o.children)};return n(e),t.length===1&&!t[0].content.length?[]:t}function RY(e){let t=[],n=r=>{let o=t.at(-1);o?.type==="text"?o.text+=r:r&&t.push({type:"text",text:r})};return e.forEach((r,o)=>{o&&n(`
|
|
1358
1358
|
`);for(let i of r.content)if(i.type==="text")n(i.text);else if(i.type==="link")n(i.content.map(a=>a.text).join(""));else if(i.props.kind==="pronunciation")t.push({type:"pronunciation",display:i.props.display,spoken:i.props.spoken});else{let a=JSON.parse(i.props.payload);if(a.type!=="cue"||!i.props.cueId)throw new Error("narration-cue-reference");t.push({...a,id:i.props.cueId})}}),t}var Ec=require("react/jsx-runtime");function aD(e,t){let n=r=>{if(r===t)return!0;let o=e.blocks[r];return(o?.type==="container"||o?.type==="component")&&(o.children??[]).some(n)};return e.sectionOrder.find(r=>e.sections[r]?.children.some(n))}function Gct(e){return e.map(t=>t.type==="text"?t.text:t.type==="pronunciation"?t.display:"").join("")}function Kct({identity:e,reset:t,blockId:n,stepId:r,content:o,readOnly:i,advanced:a,onPause:s}){let l=tt(),c=me(h=>h.locale),[d]=(0,a6.useState)(()=>Xe()),u=()=>{let h=l.getDocument(e),g=h?.steps[r];return g?g.narrationIds.map(v=>({id:v,content:h.narrations[v].content})):void 0},f=(0,a6.useRef)(),p=(0,a6.useRef)(),m=`narration:${e}:${t}:${JSON.stringify(n??null)}:${r}`;return(0,Ec.jsx)(iD,{identity:e,reset:t,fieldId:r,content:o,locale:c,readOnly:i,advanced:a,blockMenu:!0,getContent:u,toNative:h=>k3e(h,d),fromNative:IY,cueOwners:()=>{let h=l.getDocument(e),g=new Set(Object.values(h?.steps??{}).filter(v=>v.id!==r).flatMap(v=>v.narrationIds));return new Map([...g].flatMap(v=>h.narrations[v].content.flatMap(b=>b.type==="cue"?[[b.id,v]]:[])))},onCueCopy:(h,g)=>l.copyNarrationCueTiming(h,g,e),onReady:h=>{f.current?.(),p.current=h,f.current=h?l.registerDocumentField({identity:e,reset:t,blockId:n,stepId:r,focus:w3e(h),editor:h}):void 0},onFocus:()=>{l.documentInteraction(),p.current&&l.activateDocumentHistory(p.current),s()},onChange:h=>l.setDocumentNarrations(r,h,e),onComposition:h=>l.documentComposition(h,m,e),onError:h=>l.documentError(h)})}function v2({blockId:e,sectionId:t,stepId:n,expanded:r,advanced:o=!1,showLabel:i=!0,panelId:a,onPause:s}){let l=tt(),c=me(k=>k.authoring),d=me(k=>k.locale),u=ao[d],f=me(k=>l.client.capabilities?.readOnly===!0||!!k.authoring?.loading||Wt(k)),p=me(k=>k.documentTimingDraftStorageFailure);if(l.client.capabilities?.narration===!1)return null;let m=c?.content,h=m?.sections[t],g=m?.steps[n];if(!c?.identity||!m||!h||!g)return null;let v=h.stepOrder.indexOf(n),b=g.narrationIds,y=u.narrationStep(v+1,h.stepOrder.length,g.title??""),w=o?u.stepNarration:u.stepCaptions,_=b.map(k=>Gct(m.narrations[k]?.content??[])).filter(Boolean).join(`
|
|
1359
|
-
`),x=k=>{let S=h.stepOrder[v+k];S&&(s(),l.selectDocumentStep(t,S))};return(0,Ec.jsxs)("section",{className:"pm-ui-block-preview__narration","aria-label":w,"data-step-narration":n,children:[(0,Ec.jsxs)("header",{className:"pm-ui-block-preview__narration-header",children:[(0,Ec.jsx)("span",{className:"pm-ui-block-preview__step-label",children:y}),(0,Ec.jsxs)("span",{className:"pm-ui-block-preview__actions",children:[(0,Ec.jsx)(Et,{small:!0,icon:"chevron-left",label:u.previousStep,disabled:v<=0,onClick:()=>x(-1)}),(0,Ec.jsx)(Et,{small:!0,icon:"chevron-right",label:u.nextStep,disabled:v>=h.stepOrder.length-1,onClick:()=>x(1)})]})]}),!r&&_&&(0,Ec.jsx)("p",{className:"pm-ui-block-preview__caption","data-step-caption":n,children:_}),r&&(0,Ec.jsxs)("div",{id:a,className:"pm-ui-block-preview__narration-fields",children:[i&&(0,Ec.jsx)("span",{className:"pm-ui-block-preview__step-label",children:w}),(0,Ec.jsx)(Kct,{identity:c.identity,reset:c.reset,blockId:e,stepId:n,content:b.map(k=>({id:k,content:m.narrations[k].content})),readOnly:f,advanced:o,onPause:s},`${c.identity}:${c.reset}:${n}`),(0,Ec.jsx)(Nj,{document:m,stepId:n,locale:d,readOnly:f,advanced:o,onPause:s,onInteraction:()=>l.documentInteraction(),onChange:k=>l.setDocumentStepProduction(n,k,c.identity),drafts:{minimumHoldMs:l.documentTimingDraft(n,"minimumHoldMs",c.identity,c.reset),trailingPauseMs:l.documentTimingDraft(n,"trailingPauseMs",c.identity,c.reset)},draftStorageFailure:p,onDraft:(k,S)=>l.setDocumentTimingDraft(n,k,S,c.identity,c.reset),onComposition:(k,S)=>l.documentComposition(S,`production:${c.identity}:${c.reset}:${e}:${n}:${k}`,c.identity)},`${c.identity}:${c.reset}:${n}`)]})]})}var Jct={serviceSettings:"\u8BED\u97F3\u670D\u52A1\u8BBE\u7F6E",playOnDemand:"\u64AD\u653E\u65F6\u6309\u9700\u751F\u6210\u914D\u97F3\u5E76\u7F13\u5B58\uFF1B\u7F3A\u5931\u8BB2\u7A3F\u4F1A\u53D1\u9001\u5230\u6240\u9009\u8BED\u97F3\u670D\u52A1\u3002",generatingPlayback:"\u6B63\u5728\u751F\u6210\u5F53\u524D\u914D\u97F3\uFF0C\u5B8C\u6210\u540E\u81EA\u52A8\u64AD\u653E\u3002\u53EF\u6682\u505C\u53D6\u6D88\u3002",generatingProgress:(e,t)=>`\u6B63\u5728\u751F\u6210\u914D\u97F3 ${e} / ${t}\uFF0C\u5B8C\u6210\u540E\u81EA\u52A8\u64AD\u653E\u3002`,library:"\u9875\u9762\u4E0E\u7D20\u6750",pages:"\u9875\u9762",media:"\u97F3\u9891\u7D20\u6750",properties:"\u6B65\u9AA4\u5C5E\u6027",narration:"\u8BB2\u7A3F",voiceTab:"\u914D\u97F3",captionsTab:"\u5B57\u5E55",searchPages:"\u641C\u7D22\u9875\u9762",pageResults:e=>`${e} \u9875`,pageSteps:e=>`${e} \u4E2A\u6B65\u9AA4`,noPages:"\u6CA1\u6709\u5339\u914D\u7684\u9875\u9762",resizeLibrary:"\u8C03\u6574\u9875\u9762\u5217\u8868\u4E0E\u753B\u9762\u5BBD\u5EA6",issueCount:e=>`${e} \u9879\u95EE\u9898`,resizeProperties:"\u8C03\u6574\u753B\u9762\u4E0E\u8BB2\u7A3F\u5BBD\u5EA6",resizeTimeline:"\u8C03\u6574\u753B\u9762\u4E0E\u65F6\u95F4\u7EBF\u9AD8\u5EA6",title:"\u89C6\u9891\u5236\u4F5C",back:"\u8FD4\u56DE\u6587\u7A3F",preview:"\u753B\u9762",script:"\u8BB2\u7A3F\u4E0E\u914D\u97F3",outputs:"\u5BFC\u51FA",step:"\u5F53\u524D\u6B65\u9AA4",page:"\u9875\u9762",prepare:"\u51C6\u5907\u753B\u9762",preparing:"\u6B63\u5728\u51C6\u5907\u753B\u9762\u2026",current:"\u5F53\u524D\u4FDD\u5B58\u7248\u672C",outdated:"\u9700\u8981\u66F4\u65B0",unavailable:"\u753B\u9762\u5C1A\u672A\u51C6\u5907",previewHint:"\u7528\u5F53\u524D\u4FDD\u5B58\u7248\u672C\u51C6\u5907\u753B\u9762\u540E\u5373\u53EF\u67E5\u770B\u3002\u8BB2\u7A3F\u548C\u97F3\u8272\u53EF\u5355\u72EC\u7F16\u8F91\u3002",voice:"\u97F3\u8272\u4E0E\u914D\u97F3",choose:"\u9009\u62E9\u97F3\u8272",generate:"\u751F\u6210\u914D\u97F3",none:"\u9759\u97F3",unset:"\u672A\u8BBE\u7F6E\u97F3\u8272",recording:"\u5F55\u97F3\u6765\u6E90",inherited:{step:"\u672C\u6B65\u8BBE\u7F6E",page:"\u7EE7\u627F\u672C\u9875",document:"\u7EE7\u627F\u6587\u7A3F\u9ED8\u8BA4",unset:"\u672A\u8BBE\u7F6E"},scopeShort:{step:"\u672C\u6B65",steps:"\u591A\u6B65",page:"\u672C\u9875",document:"\u6587\u7A3F"},counts:(e,t,n)=>`\u66F4\u65B0 ${e} \u4E2A\u6B65\u9AA4\uFF0C${t} \u4E2A\u6B65\u9AA4\u4FDD\u7559\u8986\u76D6\uFF0C${n} \u4E2A\u6B65\u9AA4\u4E0D\u53D8\u3002`,overridden:(e,t)=>`\u8303\u56F4\u5185\u6709 ${e} \u9879\u9759\u97F3\u3001${t} \u9879\u5F55\u97F3\u72EC\u7ACB\u8BBE\u7F6E\u3002`,replaceCount:e=>`\u786E\u8BA4\u66FF\u6362 ${e} \u5904\u8986\u76D6`,keepAssets:"\u5F55\u97F3\u548C\u5176\u4ED6\u7D20\u6750\u4ECD\u4FDD\u7559\uFF0C\u4E0D\u4F1A\u6539\u5199\u8BB2\u7A3F\u6216\u751F\u6210\u914D\u97F3\u3002",mute:"\u8BBE\u7F6E\u4E3A\u9759\u97F3",restore:"\u4F7F\u7528\u7EE7\u627F\u8BBE\u7F6E",selectSteps:"\u8BF7\u81F3\u5C11\u9009\u62E9\u4E00\u4E2A\u6B65\u9AA4\u3002",draftChanged:"\u6587\u7A3F\u5DF2\u66F4\u65B0\u3002\u8BBE\u7F6E\u8349\u7A3F\u5DF2\u4FDD\u7559\uFF0C\u8BF7\u91CD\u65B0\u68C0\u67E5\u8303\u56F4\u540E\u5E94\u7528\u3002",applyTitle:"\u786E\u8BA4\u97F3\u8272\u5E94\u7528\u8303\u56F4",restoreTitle:"\u786E\u8BA4\u4F7F\u7528\u7EE7\u627F\u8BBE\u7F6E",applyHint:"\u53EA\u4FEE\u6539\u6240\u9009\u8303\u56F4\u7684\u97F3\u8272\u6765\u6E90\uFF0C\u6B63\u6587\u3001\u8BB2\u7A3F\u548C\u64AD\u653E\u65F6\u673A\u4FDD\u7559\u3002",restoreHint:"\u6240\u9009\u5C42\u7EA7\u6539\u7528\u4E0A\u4E00\u7EA7\u7684\u8BBE\u7F6E\uFF0C\u4FDD\u7559\u7684\u4E0B\u7EA7\u8986\u76D6\u4E0D\u53D8\u3002\u6E05\u9664\u6587\u7A3F\u9ED8\u8BA4\u540E\u5C06\u6CA1\u6709\u9ED8\u8BA4\u97F3\u8272\u3002",catalogFailed:"\u65E0\u6CD5\u52A0\u8F7D\u97F3\u8272\u5217\u8868\uFF0C\u8BF7\u91CD\u8BD5\u3002",cached:"\u5F53\u524D\u8BB2\u7A3F\u53EF\u4F7F\u7528\u5DF2\u6709\u914D\u97F3\u7F13\u5B58\u3002",sourceReady:"\u53EA\u6709\u786E\u8BA4\u4FDD\u5B58\u7248\u672C\u4E0E\u6B65\u9AA4\u540E\u624D\u80FD\u8BD5\u542C\u6216\u751F\u6210\u3002",currentScript:"\u8BD5\u542C\u672C\u6B65\u8BB2\u7A3F",selectedVoice:"\u6240\u9009\u97F3\u8272",unknownSource:"\u672A\u8FDE\u63A5\u7684\u670D\u52A1",playbackHint:"\u5F53\u524D\u6309\u6B65\u9AA4\u7F16\u8F91\uFF1B\u64AD\u653E\u65F6\u957F\u4E0E\u5B57\u5E55\u65F6\u95F4\u7531\u5B9E\u9645\u8BB2\u6388\u7684\u65F6\u95F4\u7EBF\u5F97\u51FA\u3002",timeline:"\u65F6\u95F4\u7EBF",play:"\u64AD\u653E",pause:"\u6682\u505C",rate:"\u64AD\u653E\u901F\u5EA6",planLoading:"\u6B63\u5728\u52A0\u8F7D\u65F6\u95F4\u7EBF\u2026",enable:"\u542F\u7528\u89C6\u9891\u5236\u4F5C",enableHint:"\u6B64\u6587\u7A3F\u5C1A\u672A\u542F\u7528\u89C6\u9891\u5236\u4F5C\u3002\u542F\u7528\u540E\u53EF\u4F7F\u7528\u65F6\u95F4\u7EBF\u5E76\u5BFC\u51FA\u8BB2\u6388\uFF0C\u6B63\u6587\u548C\u8BB2\u7A3F\u4FDD\u7559\uFF1B\u9009\u62E9\u97F3\u8272\u540E\uFF0C\u64AD\u653E\u65F6\u4F1A\u6309\u9700\u751F\u6210\u914D\u97F3\u3002",planOutdated:"\u6587\u7A3F\u5DF2\u66F4\u65B0\uFF0C\u6B63\u5728\u51C6\u5907\u5BF9\u5E94\u7684\u65F6\u95F4\u7EBF\u3002",planRetry:"\u91CD\u65B0\u52A0\u8F7D\u65F6\u95F4\u7EBF",playbackWaiting:"\u51C6\u5907\u5F53\u524D\u753B\u9762\u540E\u53EF\u64AD\u653E\u6216\u5B9A\u4F4D\u5230\u65F6\u95F4\u3002",playbackLoading:"\u6B63\u5728\u51C6\u5907\u64AD\u653E\u2026",playbackFailed:"\u65E0\u6CD5\u5B8C\u6210\u64AD\u653E\u6216\u5B9A\u4F4D\uFF0C\u8BF7\u91CD\u8BD5\u3002",planFailed:"\u5F53\u524D\u7F16\u6392\u65E0\u6CD5\u51C6\u5907\uFF0C\u8BF7\u68C0\u67E5\u6B65\u9AA4\u3001\u914D\u97F3\u548C\u52A8\u753B\u65F6\u957F\u3002",estimatedPlan:"\u672A\u751F\u6210\u90E8\u5206\u663E\u793A\u4F30\u8BA1\u65F6\u957F\u3002\u64AD\u653E\u65F6\u81EA\u52A8\u751F\u6210\u5E76\u7F13\u5B58\uFF0C\u751F\u6210\u540E\u66F4\u65B0\u7CBE\u786E\u65F6\u95F4\u3002",unknownPlan:"\u5F53\u524D\u7F16\u6392\u4ECD\u6709\u672A\u786E\u8BA4\u7684\u65F6\u5E8F\u3002\u8BF7\u67E5\u770B\u539F\u56E0\uFF0C\u4FEE\u6B63\u540E\u518D\u6309\u65F6\u95F4\u64AD\u653E\u6216\u5BFC\u51FA\u3002",issues:e=>`\u67E5\u770B ${e} \u9879\u7F16\u6392\u95EE\u9898`,diagnosticFallback:"\u5F53\u524D\u7F16\u6392\u5305\u542B\u672A\u652F\u6301\u6216\u65E0\u6548\u7684\u7ED1\u5B9A\uFF0C\u8BF7\u68C0\u67E5\u5173\u8054\u5185\u5BB9\u3002",diagnostics:{"production.animation-duration-unknown":"\u52A8\u753B\u672A\u58F0\u660E\u6709\u6548\u65F6\u957F\uFF0C\u6682\u4E0D\u80FD\u6309\u65F6\u95F4\u64AD\u653E\u6216\u5BFC\u51FA\u3002","production.recording-cue-unsupported":"\u539F\u97F3\u9891\u6CA1\u6709\u63D0\u793A\u7684\u786E\u8BA4\u65F6\u7801\uFF0C\u8BF7\u79FB\u9664\u8DE8\u6B65\u6216\u5185\u90E8\u6682\u505C\uFF0C\u5E76\u5C06\u63D0\u793A\u653E\u5230\u672C\u6B65\u8D77\u70B9\u3002","production.recording-start-conflict":"\u540C\u4E00\u6B65\u8BB2\u7A3F\u7684\u64AD\u653E\u8D77\u70B9\u4E0D\u4E00\u81F4\uFF0C\u8BF7\u5148\u7EDF\u4E00\u540E\u91C7\u7528\u539F\u97F3\u9891\u3002","production.recording-captions-unverified":"\u5F55\u97F3\u5DF2\u88C1\u526A\uFF0C\u5B57\u5E55\u4ECD\u4E3A\u672C\u6B65\u5B8C\u6574\u8BB2\u7A3F\uFF0C\u5C1A\u672A\u6309\u539F\u97F3\u5BF9\u9F50\uFF0C\u8BF7\u6838\u5BF9\u3002","production.recording-fingerprint-required":"\u8BF7\u91CD\u65B0\u91C7\u7528\u539F\u97F3\u9891\u4EE5\u786E\u8BA4\u5B9E\u9645\u6587\u4EF6\u3002","production.recording-unsupported":"\u5F55\u97F3\u6765\u6E90\u5DF2\u4FDD\u7559\uFF0C\u4F46\u6682\u65F6\u4E0D\u80FD\u7528\u4E8E\u8FD9\u4EFD\u8BB2\u7A3F\u7684\u64AD\u653E\u3002","production.media-unsupported":"\u5A92\u4F53\u7247\u6BB5\u5DF2\u4FDD\u7559\uFF0C\u6682\u4E0D\u652F\u6301\u88C1\u526A\u548C\u6DF7\u97F3\u3002","production.silent-cue-unknown":"\u9759\u97F3\u8BB2\u7A3F\u4E2D\u7684\u6587\u5B57\u63D0\u793A\u6CA1\u6709\u786E\u8BA4\u65F6\u7801\uFF1B\u8BF7\u653E\u5230\u6B65\u9AA4\u8D77\u70B9\u6216\u63D0\u4F9B\u97F3\u9891\u3002","production.next-pause-unsupported":"\u8DE8\u6B65\u9AA4\u7684\u540C\u4E00\u6BB5\u914D\u97F3\u5C1A\u4E0D\u80FD\u63D2\u5165\u6B65\u9AA4\u505C\u987F\uFF0C\u8BF7\u5148\u62C6\u6210\u6309\u6B65\u9AA4\u7ED1\u5B9A\u7684\u8BB2\u7A3F\u3002","production.cache-missing":"\u5F53\u524D\u914D\u97F3\u5C1A\u672A\u7F13\u5B58\uFF0C\u70B9\u51FB\u64AD\u653E\u540E\u81EA\u52A8\u751F\u6210\u3002","production.voice-unset":"\u6B64\u8BB2\u7A3F\u5C1A\u672A\u9009\u62E9\u53D1\u58F0\u65B9\u5F0F\uFF0C\u8BF7\u9009\u62E9\u9759\u97F3\u6216\u5B9E\u9645\u97F3\u8272\u3002","production.cue-invalid":"\u8BB2\u7A3F\u63D0\u793A\u7684\u76EE\u6807\u6216\u52A8\u4F5C\u65E0\u6548\uFF0C\u8BF7\u68C0\u67E5\u5BF9\u5E94\u7684\u8BB2\u7A3F\u548C\u5185\u5BB9\u3002"},timingDraft:"\u8BF7\u5148\u786E\u8BA4\u6216\u4FEE\u6B63\u5C1A\u672A\u4FDD\u5B58\u7684\u64AD\u653E\u65F6\u673A\u3002",captionDraft:"\u672A\u5E94\u7528\u5B57\u5E55\u65F6\u95F4",captionStorageFailed:"\u65E0\u6CD5\u5907\u4EFD\u5B57\u5E55\u65F6\u95F4\uFF0C\u8BF7\u4FDD\u6301\u6B64\u9875\u9762\u6253\u5F00\u3002",tracks:{visual:"\u753B\u9762",voice:"\u914D\u97F3",caption:"\u5B57\u5E55"},captionSegment:"\u5B57\u5E55\u7247\u6BB5",chooseCaptionSegment:"\u9009\u62E9\u5B57\u5E55\u7247\u6BB5",alignmentStatus:{manual:"\u624B\u52A8\u65F6\u95F4",words:"\u8BCD\u65F6\u7801",proportional:"\u6BD4\u4F8B\u4F30\u65F6",none:"\u672A\u5BF9\u9F50"},segmentStatus:{recorded:"\u539F\u97F3\u9891",cached:"\u5DF2\u6709\u914D\u97F3",silent:"\u9759\u97F3",missing:"\u914D\u97F3\u5F85\u751F\u6210",blocked:"\u6682\u4E0D\u53EF\u7528"},waveformLoading:"\u6B63\u5728\u52A0\u8F7D\u6CE2\u5F62\u2026",waveformUnavailable:"\u6CE2\u5F62\u4E0D\u53EF\u7528",stepNumber:e=>`\u6B65\u9AA4 ${e+1}`,notInLecture:"\u4E0D\u5728\u8BB2\u6388\u4E2D",notInLectureHint:"\u8FD9\u4E00\u9875\u7684\u5185\u5BB9\u90FD\u9650\u5B9A\u5728\u5176\u4ED6\u5F62\u6001\uFF0C\u53C8\u6CA1\u6709\u8BB2\u7A3F\u4E0E\u97F3\u9891\uFF0C\u8BB2\u6388\u89C6\u9891\u4E2D\u6CA1\u6709\u8FD9\u4E00\u9875\u3002",notInLectureStep:"\u8FD9\u4E00\u6B65\u4E0D\u5728\u8BB2\u6388\u4E2D\uFF1A\u5B83\u7684\u5185\u5BB9\u90FD\u9650\u5B9A\u5728\u5176\u4ED6\u5F62\u6001\uFF0C\u53C8\u6CA1\u6709\u8BB2\u7A3F\u4E0E\u97F3\u9891\u3002",captionSize:"\u5B57\u5E55\u5927\u5C0F",captionSizeHint:"\u6574\u4E2A\u6587\u7A3F\u7684\u5B57\u5E55\uFF1A\u653E\u6620\u4E2D\u663E\u793A\u7684\u4E0E\u5BFC\u51FA\u89C6\u9891\u4E2D\u70E7\u5F55\u7684\u90FD\u6309\u8FD9\u4E2A\u5927\u5C0F\u3002",timelineLabels:{position:"\u4F4D\u7F6E",seconds:"\u79D2",seek:"\u64AD\u653E\u5934\u4F4D\u7F6E",zoomIn:"\u653E\u5927\u65F6\u95F4\u7EBF",zoomOut:"\u7F29\u5C0F\u65F6\u95F4\u7EBF",fit:"\u9002\u914D\u672C\u9875",estimated:"\u4F30\u8BA1\u65F6\u957F",unknown:"\u65F6\u957F\u672A\u77E5",loading:"\u6B63\u5728\u52A0\u8F7D\u65F6\u95F4\u7EBF\u2026",empty:"\u5F53\u524D\u9875\u6682\u65E0\u65F6\u95F4\u7EBF\u7247\u6BB5",seekHint:"\u9009\u62E9\u6B65\u9AA4\uFF0C\u6216\u7528\u65F6\u95F4\u5C3A\u3001\u65B9\u5411\u952E\u548C\u7CBE\u786E\u65F6\u95F4\u5B9A\u4F4D\uFF1B\u5B9A\u4F4D\u4F1A\u5148\u6682\u505C\u64AD\u653E\u3002",invalidPosition:"\u8BF7\u8F93\u5165\u672C\u9875\u65F6\u957F\u8303\u56F4\u5185\u7684\u79D2\u6570\u3002"},failures:{"production-source-changed":"\u6587\u7A3F\u5DF2\u66F4\u65B0\uFF0C\u65E7\u64AD\u653E\u8BF7\u6C42\u5DF2\u505C\u6B62\u3002\u8BF7\u91CD\u65B0\u51C6\u5907\u5F53\u524D\u7248\u672C\u3002","production-binding-stale":"\u65F6\u95F4\u7EBF\u5DF2\u66F4\u65B0\uFF0C\u8BF7\u91CD\u65B0\u52A0\u8F7D\u540E\u518D\u64AD\u653E\u3002","production-plan-changed":"\u97F3\u9891\u6216\u65F6\u95F4\u7EBF\u5DF2\u66F4\u65B0\uFF0C\u8BF7\u91CD\u65B0\u52A0\u8F7D\u540E\u518D\u64AD\u653E\u3002","production-plan-unavailable":"\u5F53\u524D\u65F6\u95F4\u7EBF\u5C1A\u4E0D\u80FD\u64AD\u653E\uFF0C\u8BF7\u68C0\u67E5\u7F3A\u5931\u7684\u914D\u97F3\u3001\u52A8\u753B\u65F6\u957F\u6216\u4E0D\u652F\u6301\u7684\u5A92\u4F53\u8BBE\u7F6E\u3002","production-playback-unavailable":"\u753B\u9762\u5C1A\u672A\u8FDE\u63A5\u64AD\u653E\u63A7\u5236\uFF0C\u8BF7\u66F4\u65B0\u753B\u9762\u540E\u91CD\u8BD5\u3002","production-playback-timeout":"\u65E0\u6CD5\u786E\u8BA4\u64AD\u653E\u6216\u5B9A\u4F4D\uFF0C\u8BF7\u91CD\u8BD5\u3002","production-playback-time":"\u6240\u9009\u65F6\u95F4\u8D85\u51FA\u5F53\u524D\u65F6\u95F4\u7EBF\uFF0C\u8BF7\u91CD\u65B0\u5B9A\u4F4D\u3002","production-playback-rate":"\u5F53\u524D\u64AD\u653E\u901F\u5EA6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u3002","production-playback-failed":"\u65E0\u6CD5\u64AD\u653E\u5F53\u524D\u5A92\u4F53\uFF0C\u8BF7\u68C0\u67E5\u97F3\u9891\u80FD\u5426\u8BFB\u53D6\u3002","production-playback-cancelled":"\u64AD\u653E\u8BF7\u6C42\u5DF2\u53D6\u6D88\u3002"}},Gi={"zh-CN":Jct,en:{serviceSettings:"Voice Service Settings",playOnDemand:"Play generates and caches missing voiceover using the selected speech service.",generatingPlayback:"Generating the current voiceover. Playback continues when ready; pause to cancel.",generatingProgress:(e,t)=>`Generating voiceover ${e} / ${t}. Playback continues when ready.`,library:"Pages and Assets",pages:"Pages",media:"Audio Assets",properties:"Step Properties",narration:"Script",voiceTab:"Voiceover",captionsTab:"Captions",searchPages:"Search Pages",pageResults:e=>`${e} ${e===1?"page":"pages"}`,pageSteps:e=>`${e} ${e===1?"step":"steps"}`,noPages:"No matching pages",resizeLibrary:"Resize page list and visuals",issueCount:e=>`${e} ${e===1?"Issue":"Issues"}`,resizeProperties:"Resize visuals and script",resizeTimeline:"Resize visuals and timeline",title:"Video Production",back:"Back to Document",preview:"Visuals",script:"Script and Voiceover",outputs:"Export",step:"Current step",page:"Page",prepare:"Prepare Visuals",preparing:"Preparing visuals\u2026",current:"Current saved version",outdated:"Update needed",unavailable:"Visuals are not prepared",previewHint:"Prepare the saved version to see the visuals. Scripts and voices can be edited separately.",voice:"Voice and Voiceover",choose:"Choose Voice",generate:"Generate Voiceover",none:"Silent",unset:"No voice set",recording:"Recording source",inherited:{step:"This step",page:"Inherited from page",document:"Inherited from document",unset:"Not set"},scopeShort:{step:"Step",steps:"Selected",page:"Page",document:"Document"},counts:(e,t,n)=>`${e} steps update, ${t} keep overrides, ${n} stay unchanged.`,overridden:(e,t)=>`This scope contains ${e} silent and ${t} recording overrides.`,replaceCount:e=>`Replace ${e} ${e===1?"Override":"Overrides"}`,keepAssets:"Recordings and other assets are kept. Scripts stay unchanged; no voiceover is generated.",mute:"Set to Silent",restore:"Use Inherited Setting",selectSteps:"Select at least one step.",draftChanged:"The document changed. Your settings draft is kept; check the scope again before applying.",applyTitle:"Confirm Voice Scope",restoreTitle:"Use Inherited Setting",applyHint:"Only the voice source changes. Content, scripts, and timing are kept.",restoreHint:"The selected level uses its parent\u2019s setting; overrides kept below it stay. Clearing the document default leaves no default voice.",catalogFailed:"Couldn\u2019t load the list of voices. Try again.",cached:"The current script can use existing cached voiceover.",sourceReady:"Confirm the saved version and step before listening or generating voiceover.",currentScript:"Play This Step\u2019s Script",selectedVoice:"Selected voice",unknownSource:"Disconnected service",playbackHint:"Editing is organized by steps. Durations and caption times come from the lecture\u2019s actual timeline.",timeline:"Timeline",play:"Play",pause:"Pause",rate:"Playback speed",planLoading:"Loading the timeline\u2026",enable:"Turn On Video Production",enableHint:"Video production is not turned on for this document. Turn it on to use the timeline and export the lecture; content and scripts are kept. Choose a voice, then Play generates missing voiceover.",planOutdated:"The document changed. Preparing its timeline.",planRetry:"Reload Timeline",playbackWaiting:"Prepare the current visuals to play or go to a time.",playbackLoading:"Preparing playback\u2026",playbackFailed:"Couldn\u2019t finish playing or seeking. Try again.",planFailed:"Couldn\u2019t prepare the sequence. Check the steps, voiceover, and animation durations.",estimatedPlan:"Missing clips show estimated durations. Play generates and caches voiceover, then updates exact times.",unknownPlan:"Some timing is unconfirmed. Review the issues before timed playback or export.",issues:e=>`Review ${e} Sequence ${e===1?"Issue":"Issues"}`,diagnosticFallback:"The sequence contains an unsupported or invalid link to content. Check the related content.",diagnostics:{"production.animation-duration-unknown":"The animation has no valid declared duration. Timed playback and export are unavailable.","production.recording-cue-unsupported":"The recording has no confirmed cue timing. Remove next-step cues and internal pauses, and place cues at the step start.","production.recording-start-conflict":"Scripts in this step have different starts. Use one common start before using the recording.","production.recording-captions-unverified":"The recording is trimmed. Captions still show the complete step script and are not aligned to the audio; review them.","production.recording-fingerprint-required":"Use the recording again to confirm the actual file.","production.recording-unsupported":"The recording source is kept but can\u2019t be used to play this script yet.","production.media-unsupported":"Media clips are kept. Trimming and mixing are not available yet.","production.silent-cue-unknown":"Text-anchored cues in silent scripts have no confirmed timing. Move them to the step start or provide audio.","production.next-pause-unsupported":"One voiceover clip that spans steps can\u2019t take step pauses yet. Split it into one script per step.","production.cache-missing":"This voiceover is not cached. Play generates it automatically.","production.voice-unset":"This script has no voice source. Choose silence or an actual voice.","production.cue-invalid":"A script cue has an invalid target or action. Check the script and its content."},timingDraft:"Confirm or correct the playback timing that is not saved first.",captionDraft:"Caption times not applied",captionStorageFailed:"Couldn\u2019t back up caption times. Keep this page open.",tracks:{visual:"Visuals",voice:"Voiceover",caption:"Captions"},captionSegment:"Caption segment",chooseCaptionSegment:"Choose Caption Segment",alignmentStatus:{manual:"Manual timing",words:"Word timing",proportional:"Proportional timing",none:"Unaligned"},segmentStatus:{recorded:"Original audio",cached:"Voiceover cached",silent:"Silent",missing:"Voiceover needed",blocked:"Unavailable"},waveformLoading:"Loading waveform\u2026",waveformUnavailable:"Waveform unavailable",stepNumber:e=>`Step ${e+1}`,notInLecture:"Not in the lecture",notInLectureHint:"Everything on this page is limited to other forms and it has no script or audio, so the lecture video leaves it out.",notInLectureStep:"This step is not in the lecture: everything on it is limited to other forms and it has no script or audio.",captionSize:"Caption size",captionSizeHint:"For the whole document: captions shown in the presentation and burned into an exported video use this size.",timelineLabels:{position:"Position",seconds:"seconds",seek:"Playhead position",zoomIn:"Zoom In Timeline",zoomOut:"Zoom Out Timeline",fit:"Fit Page",estimated:"Estimated duration",unknown:"Unknown duration",loading:"Loading the timeline\u2026",empty:"This page has no timeline segments",seekHint:"Select a step, or use the ruler, arrow keys, or an exact time to seek. Seeking pauses playback first.",invalidPosition:"Enter a time in seconds within this page\u2019s duration."},failures:{"production-source-changed":"The document changed and the old playback request stopped. Prepare the current version.","production-binding-stale":"The timeline changed. Reload it before playing.","production-plan-changed":"The audio or timeline changed. Reload it before playing.","production-plan-unavailable":"This timeline can\u2019t be played yet. Check for missing voiceover, animation durations, or unsupported media settings.","production-playback-unavailable":"The visuals are not connected to playback controls. Update the visuals and try again.","production-playback-timeout":"Couldn\u2019t confirm playing or seeking. Try again.","production-playback-time":"The selected time is outside the current timeline. Choose another position.","production-playback-rate":"This playback speed is unavailable. Choose another speed.","production-playback-failed":"Couldn\u2019t play the current media. Check that its audio can be read.","production-playback-cancelled":"The playback request was canceled."}}};function sD(e,t){let n=e instanceof Error?e.message:String(e),r=Gi[t];return r.failures[n]??r.playbackFailed}var fD=require("react");var Ho=require("react");var x3e=new WeakMap,lD=(e,t)=>JSON.stringify([e,t]),s6=e=>`presmium.voice-draft.v2:${e}`;function MY(e){if(!xt(e)||typeof e.version!="string"||typeof e.replaceOverrides!="boolean"||!xt(e.scope)||e.rateInput!==void 0&&typeof e.rateInput!="string")return!1;let t=e.scope;if(!(t.kind==="document"||t.kind==="page"&&typeof t.sectionId=="string"||t.kind==="step"&&typeof t.stepId=="string"||t.kind==="steps"&&Array.isArray(t.stepIds)&&t.stepIds.every(o=>typeof o=="string")))return!1;let n=e.source;if(n===null)return!0;if(!xt(n))return!1;if(n.type==="none")return!0;if(n.type==="recording")return typeof n.assetId=="string";if(n.type!=="tts"||!xt(n.voice))return!1;let r=n.voice;return typeof r.voice=="string"&&(r.engine===void 0||typeof r.engine=="string")&&(r.rate===void 0||typeof r.rate=="number"&&Number.isFinite(r.rate))&&(r.style===void 0||typeof r.style=="string")}function Yct(e){let t=x3e.get(e);return t||x3e.set(e,t=new Map),t}function cD(e,t){let n=Yct(e),r=n.get(t);if(r)return r;let o={status:"available"};n.set(t,o);try{let i=sessionStorage.getItem(s6(t));if(i!==null){o.unreadable=i;let a=JSON.parse(i);if(!MY(a))return o.status="corrupt",o;o.draft=a,delete o.unreadable}}catch{o.status=o.unreadable===void 0?"unavailable":"corrupt"}return o}function S3e(e,t,n){let r=cD(e,lD(t,n)).draft;return r&&structuredClone(r)}function _3e(e,t,n){return cD(e,lD(t,n)).status}function DY(e,t,n,r){if(!MY(r))throw new Error("voice-draft-invalid");let o=lD(t,n),i=cD(e,o);i.draft=structuredClone(r);try{return i.unreadable!==void 0&&sessionStorage.setItem(`${s6(o)}:unreadable`,i.unreadable),sessionStorage.setItem(s6(o),JSON.stringify(i.draft)),i.status="available",delete i.unreadable,!0}catch{return i.status="unavailable",!1}}function C3e(e,t,n,r){let o=lD(t,n),i=cD(e,o);if(r&&JSON.stringify(i.draft)!==JSON.stringify(r))return!1;try{let a=sessionStorage.getItem(s6(o));if(r&&a!==null){let s;try{s=JSON.parse(a)}catch{return i.status="corrupt",i.unreadable=a,!1}if(!MY(s))return i.status="corrupt",i.unreadable=a,!1;if(JSON.stringify(s)!==JSON.stringify(r))return!1}return sessionStorage.removeItem(s6(o)),delete i.draft,delete i.unreadable,i.status="available",!0}catch{return i.status="unavailable",!1}}var dD=(e,t=!0)=>`${/^[A-Za-z0-9]/.test(e)?" ":""}${e}${t&&/[A-Za-z0-9]$/.test(e)?" ":""}`,P3e=e=>`${String(Math.floor(e/6e4)).padStart(2,"0")}:${String(Math.floor(e/1e3)%60).padStart(2,"0")}`,Zct={open:"\u590D\u523B\u97F3\u8272\u2026",title:"\u590D\u523B\u97F3\u8272",cloned:"\u590D\u523B\u97F3\u8272",close:"\u5173\u95ED",cancel:"\u53D6\u6D88",description:"\u7528\u4E00\u4E2A\u4EBA\u7684\u5F55\u97F3\u8BAD\u7EC3\u51FA\u4E00\u4E2A\u5408\u6210\u97F3\u8272\u3002\u9700\u8981\u672C\u4EBA\u6388\u6743\uFF0C\u5E76\u4EB2\u53E3\u8BFB\u4E00\u904D\u6388\u6743\u58F0\u660E\u3002",voice:"\u97F3\u8272\u540D\u79F0",voiceHint:e=>e?"\u5728\u706B\u5C71\u5F15\u64CE\u63A7\u5236\u53F0\u8D2D\u4E70\u7684\u97F3\u8272\u69FD\u4F4D\uFF08\u4EE5 S_ \u5F00\u5934\uFF09\uFF0C\u6216\u8005\u7ED9\u6309\u91CF\u4ED8\u8D39\u7684\u97F3\u8272\u8D77\u4E00\u4E2A\u540D\u5B57\uFF08\u5B57\u6BCD\u5F00\u5934\uFF0C\u81F3\u5C11 8 \u4E2A\u5B57\u6BCD\u6216\u6570\u5B57\uFF09\u3002":"\u7ED9\u8FD9\u4E2A\u97F3\u8272\u8D77\u4E00\u4E2A\u540D\u5B57\uFF0C\u53EA\u7528\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u201C.\u201D\u3001\u201C-\u201D\u548C\u201C_\u201D\u3002",voiceInvalid:"\u540D\u79F0\u53EA\u80FD\u5305\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u201C.\u201D\u3001\u201C-\u201D\u548C\u201C_\u201D\uFF0C\u5E76\u4EE5\u5B57\u6BCD\u6216\u6570\u5B57\u5F00\u5934\u3002",speaker:"\u8BF4\u8BDD\u4EBA",speakerHint:"\u5F55\u97F3\u91CC\u662F\u8C01\u7684\u58F0\u97F3\u3002",scope:"\u7528\u9014",scopeHint:"\u8FD9\u4E2A\u97F3\u8272\u53EF\u4EE5\u7528\u5728\u54EA\u91CC\uFF0C\u4F1A\u5199\u8FDB\u6388\u6743\u8BB0\u5F55\u3002",defaultScope:"\u672C\u5DE5\u4F5C\u533A\u8BB2\u4E49\u7684\u914D\u97F3",statement:"\u6388\u6743\u58F0\u660E\u5F55\u97F3",statementHint:"\u8BF7\u8BF4\u8BDD\u4EBA\u672C\u4EBA\u8BFB\u51FA\u4E0A\u9762\u7684\u6388\u6743\u58F0\u660E\u3002",statementText:(e,t)=>`\u6211\u662F${dD(e,!1)}\u3002\u6211\u6388\u6743\u7528\u6211\u7684\u58F0\u97F3\u8BAD\u7EC3\u4E00\u4E2A\u5408\u6210\u97F3\u8272\uFF0C\u53EA\u7528\u4E8E${dD(t,!1)}\u3002`,someone:"\uFF08\u8BF4\u8BDD\u4EBA\u7684\u540D\u5B57\uFF09",statementLabel:"\u6388\u6743\u58F0\u660E",passageLabel:"\u53EF\u4EE5\u6717\u8BFB\u7684\u6BB5\u843D",passage:"\u4ECA\u5929\u6211\u4EEC\u4ECE\u4E00\u4E2A\u7B80\u5355\u7684\u95EE\u9898\u5F00\u59CB\uFF1A\u4E00\u5F20\u56FE\u7247\u662F\u600E\u6837\u4E00\u6B65\u4E00\u6B65\u751F\u6210\u51FA\u6765\u7684\uFF1F\u5148\u770B\u6700\u57FA\u672C\u7684\u60F3\u6CD5\uFF0C\u518D\u770B\u5B83\u4E3A\u4EC0\u4E48\u6709\u6548\uFF0C\u6700\u540E\u7528\u51E0\u4E2A\u4F8B\u5B50\u628A\u5B83\u4EEC\u8FDE\u8D77\u6765\u3002\u8BF7\u7528\u5E73\u65F6\u8BB2\u8BFE\u7684\u8BED\u6C14\uFF0C\u81EA\u7136\u5730\u8BFB\u4E0B\u53BB\u3002",sample:"\u58F0\u97F3\u6837\u672C",sampleHint:"10 \u5230 30 \u79D2\uFF0C\u53EA\u6709\u8BF4\u8BDD\u4EBA\u4E00\u4E2A\u4EBA\uFF0C\u73AF\u5883\u5B89\u9759\u3002\u53EF\u4EE5\u8BFB\u4E0A\u9762\u8FD9\u6BB5\u3002",sampleLength:e=>`\u6837\u672C\u957F ${e.toFixed(0)} \u79D2\u300210 \u5230 30 \u79D2\u7684\u5F55\u97F3\u6548\u679C\u6700\u597D\u3002`,record:"\u5F55\u97F3",stop:"\u505C\u6B62\u5F55\u97F3",choose:"\u9009\u62E9\u97F3\u9891\u6587\u4EF6",listen:"\u8BD5\u542C",stopListening:"\u505C\u6B62\u8BD5\u542C",clear:"\u6E05\u9664",empty:"\u5C1A\u672A\u5F55\u5236\u6216\u9009\u62E9",preparing:"\u6B63\u5728\u5904\u7406\u5F55\u97F3\u2026",seconds:e=>`${e.toFixed(1)} \u79D2`,decodeFailed:"\u65E0\u6CD5\u8BFB\u53D6\u8FD9\u6BB5\u97F3\u9891\u3002\u8BF7\u6362\u4E00\u4E2A\u6587\u4EF6\uFF0C\u6216\u91CD\u65B0\u5F55\u5236\u3002",train:"\u5F00\u59CB\u8BAD\u7EC3",use:"\u4F7F\u7528\u8FD9\u4E2A\u97F3\u8272",confirmTitle:"\u786E\u8BA4\u8BAD\u7EC3\u8FD9\u4E2A\u97F3\u8272\uFF1F",confirmHint:"\u6388\u6743\u8BB0\u5F55\u4F1A\u5148\u4FDD\u5B58\u5728\u672C\u673A\u7684\u8FD0\u8425\u8005\u76EE\u5F55\u4E2D\uFF0C\u7136\u540E\u628A\u6837\u672C\u53D1\u9001\u7ED9\u8BED\u97F3\u670D\u52A1\u8BAD\u7EC3\u3002",costs:(e,t)=>t?`\u8BAD\u7EC3\u548C\u4E4B\u540E\u7684\u5408\u6210\u90FD\u6309${dD(e)}\u7684\u4EF7\u683C\u8BA1\u8D39\u3002\u6309\u91CF\u4ED8\u8D39\u7684\u97F3\u8272\u5728\u7B2C\u4E00\u6B21\u5408\u6210\uFF08\u5305\u62EC\u8BD5\u542C\uFF09\u65F6\u6263\u8D39\uFF0C\u4E4B\u540E\u5C31\u4E0D\u80FD\u518D\u8BAD\u7EC3\u3002`:`\u8BAD\u7EC3\u548C\u4E4B\u540E\u7684\u5408\u6210\u6309${dD(e)}\u7684\u4EF7\u683C\u8BA1\u8D39\u3002`,confirm:"\u786E\u8BA4\u8BAD\u7EC3",state:(e,t)=>e.state==="ready"?`\u8BAD\u7EC3\u5B8C\u6210${e.trainingsLeft===void 0?"":`\uFF0C\u8FD9\u4E2A\u97F3\u8272\u8FD8\u53EF\u4EE5\u518D\u8BAD\u7EC3 ${e.trainingsLeft} \u6B21`}\u3002\u9009\u62E9\u201C\u4F7F\u7528\u8FD9\u4E2A\u97F3\u8272\u201D\u56DE\u5230\u97F3\u8272\u8BBE\u7F6E\u3002`:e.state==="failed"?"\u8BAD\u7EC3\u5931\u8D25\u3002\u8BF7\u6362\u4E00\u6BB5\u66F4\u6E05\u695A\u7684\u6837\u672C\u540E\u91CD\u8BD5\u3002":e.state==="training"?`\u6B63\u5728\u8BAD\u7EC3\u2026 \u5DF2\u7B49\u5F85 ${P3e(t)}`:"\u8BED\u97F3\u670D\u52A1\u6682\u65F6\u627E\u4E0D\u5230\u8FD9\u6B21\u8BAD\u7EC3\uFF0C\u8BF7\u7A0D\u540E\u67E5\u770B\u3002",failures:{notAllowed:"\u8FD0\u8425\u8005\u5C1A\u672A\u5141\u8BB8\u4F7F\u7528\u590D\u523B\u97F3\u8272\uFF0C\u8BF7\u8BA9\u8FD0\u8425\u8005\u5728\u5DE5\u4F5C\u533A\u8BBE\u7F6E\u4E2D\u5F00\u542F\u3002",busy:"\u8BED\u97F3\u670D\u52A1\u6B63\u5FD9\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",tooLarge:"\u5F55\u97F3\u592A\u5927\uFF0C\u8BF7\u7F29\u77ED\u5230 30 \u79D2\u5DE6\u53F3\u3002",format:"\u8BED\u97F3\u670D\u52A1\u4E0D\u63A5\u53D7\u8FD9\u79CD\u97F3\u9891\u683C\u5F0F\uFF0C\u8BF7\u91CD\u65B0\u5F55\u5236\u3002",unsupported:"\u5F53\u524D\u8BED\u97F3\u670D\u52A1\u4E0D\u652F\u6301\u590D\u523B\u97F3\u8272\u3002\u8BF7\u5728\u201C\u8BBE\u7F6E \u2192 \u8BED\u97F3\u670D\u52A1\u201D\u4E2D\u9009\u62E9\u652F\u6301\u5B83\u7684\u670D\u52A1\u3002",failed:"\u65E0\u6CD5\u5F00\u59CB\u8BAD\u7EC3\u3002\u5F55\u97F3\u5DF2\u4FDD\u7559\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002"}},Xct={open:"Voice Cloning\u2026",title:"Voice Cloning",cloned:"cloned voice",close:"Close",cancel:"Cancel",description:"Train a synthetic voice from recordings of one person. They must agree, and read the consent statement aloud themselves.",voice:"Voice name",voiceHint:e=>e?"A voice slot bought in the Volcengine console (it starts with S_), or a name for a pay-as-you-go voice (a letter first, at least 8 letters or digits).":"A name for the voice: letters, digits, \u201C.\u201D, \u201C-\u201D, and \u201C_\u201D only.",voiceInvalid:"Use letters, digits, \u201C.\u201D, \u201C-\u201D, and \u201C_\u201D, starting with a letter or digit.",speaker:"Speaker",speakerHint:"Whose voice this is.",scope:"Use",scopeHint:"Where this voice may be used; it goes into the consent record.",defaultScope:"the voiceover of this workspace\u2019s documents",statement:"Consent statement recording",statementHint:"The speaker reads the consent statement above aloud.",statementText:(e,t)=>`I am ${e}. I agree that my voice is used to train a synthetic voice, only for ${t}.`,someone:"(the speaker\u2019s name)",statementLabel:"Consent statement",passageLabel:"A passage to read",passage:"Today we start from a simple question: how is a picture made, one step after another? First the basic idea, then why it works, and finally a few examples that tie it together. Read it the way you would speak in class, at an easy pace.",sample:"Voice sample",sampleHint:"10 to 30 seconds of the speaker alone, somewhere quiet. Reading the passage above works well.",sampleLength:e=>`The sample is ${e.toFixed(0)} seconds long. Recordings of 10 to 30 seconds work best.`,record:"Record",stop:"Stop Recording",choose:"Choose Audio File",listen:"Play Sample",stopListening:"Stop Sample",clear:"Clear",empty:"Nothing recorded or chosen yet",preparing:"Preparing the recording\u2026",seconds:e=>`${e.toFixed(1)} s`,decodeFailed:"Couldn\u2019t read this audio. Choose another file, or record again.",train:"Start Training",use:"Use This Voice",confirmTitle:"Train this voice?",confirmHint:"The consent record is saved first, in the operator directory on this machine; then the sample is sent to the voice service for training.",costs:(e,t)=>t?`Training and every later voiceover are charged at ${e}\u2019s prices. A pay-as-you-go voice is charged when it first generates voiceover, listening included, and can\u2019t be trained again after that.`:`Training and later voiceover are charged at ${e}\u2019s prices.`,confirm:"Train",state:(e,t)=>e.state==="ready"?`Trained${e.trainingsLeft===void 0?"":`; it can be trained ${e.trainingsLeft} more times`}. Choose Use This Voice to return to the voice settings.`:e.state==="failed"?"Training failed. Try again with a clearer sample.":e.state==="training"?`Training\u2026 ${P3e(t)} so far`:"The voice service can\u2019t find this training yet. Check again later.",failures:{notAllowed:"The operator has not allowed cloned voices yet. Ask them to turn cloned voices on in the workspace settings.",busy:"The voice service is busy. Try again shortly.",tooLarge:"The recording is too large. Keep it to about 30 seconds.",format:"The voice service doesn\u2019t accept this audio format. Record again.",unsupported:"The current voice service doesn\u2019t support Voice Cloning. Choose one that does in Settings \u2192 Voice Service.",failed:"Couldn\u2019t start training. The recordings are kept; try again shortly."}},b2={"zh-CN":Zct,en:Xct};function E3e(e,t){let n=b2[t].failures,r=e instanceof Pn?e.status:0,o=e instanceof Error?e.message:String(e);return r===403&&/cloned voices are off|not allowed/.test(o)?n.notAllowed:r===429?n.busy:r===413?n.tooLarge:r===415?n.format:r===400&&/cannot (?:clone|train cloned) voices/.test(o)?n.unsupported:(console.warn(`presmium: voice cloning failed: ${o}`),n.failed)}var Qct={voice:"\u97F3\u8272",settings:"\u9009\u62E9\u97F3\u8272",generate:"\u751F\u6210\u914D\u97F3",generation:"\u914D\u97F3\u751F\u6210\u4E0E\u66F4\u65B0",currentVoice:"\u5F53\u524D\u97F3\u8272",unset:"\u5C1A\u672A\u9009\u62E9\u97F3\u8272",inherited:{step:"\u72EC\u7ACB\u8BBE\u7F6E",page:"\u7EE7\u627F\u9875\u9762",document:"\u7EE7\u627F\u6587\u7A3F\u9ED8\u8BA4",unset:"\u672A\u8BBE\u7F6E"},loading:"\u6B63\u5728\u52A0\u8F7D\u97F3\u8272\u8BBE\u7F6E\u2026",loadingVoices:"\u6B63\u5728\u52A0\u8F7D\u53EF\u7528\u97F3\u8272\u2026",loadFailed:"\u65E0\u6CD5\u52A0\u8F7D\u97F3\u8272\u8BBE\u7F6E\uFF0C\u8BF7\u91CD\u8BD5\u3002",unsupported:"\u5F53\u524D\u5DE5\u4F5C\u533A\u670D\u52A1\u5C1A\u4E0D\u652F\u6301\u97F3\u8272\u8BBE\u7F6E\u3002\u8BF7\u66F4\u65B0\u5E76\u91CD\u65B0\u542F\u52A8 Presmium\u3002",noService:"\u672A\u8FDE\u63A5\u8BED\u97F3\u670D\u52A1\u3002",speechFailures:{"speech-authentication":"\u8BED\u97F3 API Key \u9A8C\u8BC1\u5931\u8D25\uFF0C\u8BF7\u5728\u8BED\u97F3\u670D\u52A1\u8BBE\u7F6E\u4E2D\u66F4\u65B0\u5BC6\u94A5\u3002","speech-permission":"\u8BED\u97F3\u670D\u52A1\u62D2\u7EDD\u8BBF\u95EE\uFF0C\u8BF7\u68C0\u67E5\u662F\u5426\u5DF2\u5F00\u901A\u8BED\u97F3\u5408\u6210 2.0\uFF0C\u4EE5\u53CA\u5BC6\u94A5\u7684\u670D\u52A1\u548C\u97F3\u8272\u6743\u9650\u3002","speech-quota":"\u8BED\u97F3\u670D\u52A1\u989D\u5EA6\u4E0D\u8DB3\uFF0C\u8BF7\u68C0\u67E5\u8D26\u6237\u4F59\u989D\u6216\u53EF\u7528\u914D\u989D\u540E\u91CD\u8BD5\u3002","speech-busy":"\u8BED\u97F3\u670D\u52A1\u5E76\u53D1\u5DF2\u6EE1\uFF0C\u8BF7\u7A0D\u540E\u91CD\u65B0\u64AD\u653E\u3002","speech-network":"\u65E0\u6CD5\u8FDE\u63A5\u8BED\u97F3\u670D\u52A1\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u65B0\u64AD\u653E\u3002","speech-empty-audio":"\u8BED\u97F3\u670D\u52A1\u6CA1\u6709\u8FD4\u56DE\u97F3\u9891\uFF0C\u8BF7\u91CD\u65B0\u64AD\u653E\u6216\u66F4\u6362\u97F3\u8272\u3002","speech-invalid-request":"\u8BED\u97F3\u670D\u52A1\u4E0D\u63A5\u53D7\u5F53\u524D\u8BB2\u7A3F\u6216\u97F3\u8272\u53C2\u6570\uFF0C\u8BF7\u68C0\u67E5\u97F3\u8272\u548C\u8BB2\u7A3F\u3002","speech-provider":"\u8BED\u97F3\u670D\u52A1\u6682\u65F6\u65E0\u6CD5\u5408\u6210\uFF0C\u8BF7\u7A0D\u540E\u91CD\u65B0\u64AD\u653E\u3002","speech-cache-failed":"\u914D\u97F3\u7F13\u5B58\u65E0\u6CD5\u5199\u5165\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u78C1\u76D8\u7A7A\u95F4\u548C\u76EE\u5F55\u6743\u9650\u3002"},noServiceOption:"\u5C1A\u672A\u8FDE\u63A5",savedEngineUnavailable:"\u5DF2\u4FDD\u5B58\u7684\u670D\u52A1\uFF08\u672A\u8FDE\u63A5\uFF09",generationUnavailable:"\u5F53\u524D\u6587\u7A3F\u5C1A\u672A\u542F\u7528\u914D\u97F3\u751F\u6210\uFF0C\u8BB2\u7A3F\u4E0E\u97F3\u8272\u8BBE\u7F6E\u4ECD\u7136\u4FDD\u7559\u3002",catalogUnsupported:"\u6B64\u670D\u52A1\u5C1A\u672A\u63D0\u4F9B\u97F3\u8272\u76EE\u5F55\u3002\u5DF2\u4FDD\u5B58\u7684\u97F3\u8272\u8BBE\u7F6E\u4ECD\u7136\u4FDD\u7559\u3002",voiceUnavailable:"\u6240\u9009\u97F3\u8272\u4E0D\u652F\u6301\u6B64\u6587\u7A3F\u8BED\u8A00\u6216\u5F53\u524D\u670D\u52A1\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u3002",parametersUnsupported:"\u5F53\u524D\u670D\u52A1\u4E0D\u652F\u6301\u6240\u9009\u53C2\u6570\uFF0C\u8BF7\u5237\u65B0\u97F3\u8272\u76EE\u5F55\u540E\u91CD\u65B0\u68C0\u67E5\u3002",previewTooLong:"\u5F53\u524D\u6B65\u9AA4\u8BB2\u7A3F\u8D85\u8FC7\u8BD5\u542C\u957F\u5EA6\uFF0C\u8BF7\u751F\u6210\u914D\u97F3\u540E\u64AD\u653E\u3002",sourceUnsupported:"\u6B64\u6587\u7A3F\u7684\u6765\u6E90\u683C\u5F0F\u6682\u4E0D\u652F\u6301\u5B89\u5168\u4FEE\u6539\u97F3\u8272\u3002\u539F\u8BBE\u7F6E\u548C\u8349\u7A3F\u5DF2\u4FDD\u7559\u3002",bundledCatalog:"\u97F3\u8272\u6765\u81EA\u670D\u52A1\u7684\u5185\u7F6E\u76EE\u5F55\uFF0C\u5408\u6210\u65F6\u68C0\u67E5\u8FDE\u63A5\u3002",search:"\u67E5\u627E\u97F3\u8272",searchPlaceholder:"\u540D\u79F0\u3001\u8BED\u8A00\u6216\u58F0\u97F3\u6765\u6E90",available:"\u53EF\u7528\u97F3\u8272",empty:"\u6CA1\u6709\u7B26\u5408\u6761\u4EF6\u7684\u97F3\u8272",results:e=>`${e} \u4E2A\u97F3\u8272`,language:"\u8BED\u8A00",allLanguages:"\u5168\u90E8\u8BED\u8A00",provider:"\u8BED\u97F3\u670D\u52A1",details:"\u97F3\u8272\u8BE6\u60C5",languageMismatch:"\u4E0D\u652F\u6301\u6587\u7A3F\u7684\u8BED\u8A00",standard:"\u8BD5\u542C\u6807\u51C6\u793A\u4F8B",currentScript:"\u8BD5\u542C\u5F53\u524D\u8BB2\u7A3F",stop:"\u505C\u6B62\u8BD5\u542C",auditioning:"\u6B63\u5728\u8BD5\u542C",auditionLoading:"\u6B63\u5728\u51C6\u5907\u8BD5\u542C\u2026",auditionFailed:"\u65E0\u6CD5\u8BD5\u542C\uFF0C\u8BF7\u91CD\u8BD5\u3002\u97F3\u8272\u8BBE\u7F6E\u672A\u66F4\u6539\u3002",pauseUnavailable:"\u9884\u89C8\u5C1A\u4E0D\u652F\u6301\u6682\u505C\u64AD\u653E\uFF0C\u6682\u65F6\u65E0\u6CD5\u8BD5\u542C\u3002\u8BF7\u91CD\u65B0\u52A0\u8F7D\u6587\u7A3F\u3002",pauseTimeout:"\u65E0\u6CD5\u786E\u8BA4\u64AD\u653E\u5DF2\u6682\u505C\uFF0C\u8BF7\u91CD\u8BD5\u3002",changed:"\u6587\u7A3F\u6216\u97F3\u8272\u8BBE\u7F6E\u5DF2\u66F4\u65B0\u3002\u8349\u7A3F\u5DF2\u4FDD\u7559\uFF0C\u8BF7\u6309\u5F53\u524D\u6B65\u9AA4\u91CD\u65B0\u68C0\u67E5\u5E94\u7528\u8303\u56F4\u3002",draftRecovered:"\u5DF2\u6062\u590D\u5C1A\u672A\u5E94\u7528\u7684\u97F3\u8272\u8BBE\u7F6E\u8349\u7A3F\uFF0C\u8BF7\u68C0\u67E5\u8303\u56F4\u540E\u5E94\u7528\u3002",recoveryFailed:"\u65E0\u6CD5\u5728\u6B64\u6D4F\u89C8\u5668\u4FDD\u7559\u97F3\u8272\u8349\u7A3F\uFF0C\u8BF7\u5728\u5173\u95ED\u524D\u5E94\u7528\u6216\u590D\u5236\u8BBE\u7F6E\u3002",recheck:"\u6309\u5F53\u524D\u6B65\u9AA4\u91CD\u65B0\u68C0\u67E5",scope:"\u5E94\u7528\u8303\u56F4",scopes:{step:"\u5F53\u524D\u6B65\u9AA4",steps:"\u6240\u9009\u6B65\u9AA4",page:"\u5F53\u524D\u9875",document:"\u6574\u4EFD\u6587\u7A3F"},selectedSteps:"\u9009\u62E9\u6B65\u9AA4",step:(e,t)=>`\u7B2C ${e} \u9875\uFF0C\u6B65\u9AA4 ${t}`,selected:e=>`\u5DF2\u9009\u62E9 ${e} \u4E2A\u6B65\u9AA4`,inherit:"\u4F7F\u7528\u7EE7\u627F\u7684\u97F3\u8272",inheritHint:"\u6539\u7528\u6700\u8FD1\u7684\u9875\u9762\u6216\u6587\u7A3F\u9ED8\u8BA4\u97F3\u8272\u3002",pageScript:e=>`\u7B2C ${e} \u9875\uFF0C\u5173\u8054\u8BB2\u7A3F\uFF08\u6309\u9875\u751F\u6210\uFF09`,replace:"\u5DF2\u6709\u8986\u76D6",preserve:"\u4FDD\u7559\u72EC\u7ACB\u8BBE\u7F6E",replaceAll:"\u66FF\u6362\u72EC\u7ACB\u8BBE\u7F6E",counts:(e,t)=>`\u5C06\u66F4\u65B0 ${e} \u4E2A\u6B65\u9AA4\uFF0C\u4FDD\u7559 ${t} \u4E2A\u72EC\u7ACB\u8BBE\u7F6E\u3002`,check:"\u68C0\u67E5\u5E94\u7528\u8303\u56F4",checking:"\u6B63\u5728\u68C0\u67E5\u5E94\u7528\u8303\u56F4\u2026",apply:"\u5E94\u7528\u8BBE\u7F6E",saved:"\u97F3\u8272\u8BBE\u7F6E\u5DF2\u4FDD\u5B58\u3002",cachedPreview:"\u672C\u6B21\u4F7F\u7528\u5DF2\u6709\u914D\u97F3\u7F13\u5B58\u3002",clearDefault:"\u6E05\u9664\u6587\u7A3F\u9ED8\u8BA4\u97F3\u8272",rate:"\u8BED\u901F",rateInvalid:(e,t)=>`\u8BF7\u8F93\u5165 ${e}\u2013${t} \u4E4B\u95F4\u7684\u6570\u503C\u3002`,style:"\u6717\u8BFB\u98CE\u683C",styleDefault:"\u670D\u52A1\u9ED8\u8BA4",cueStep:"\u6B64\u8BB2\u7A3F\u5305\u542B\u8DE8\u6B65\u9AA4\u63D0\u793A\uFF0C\u6682\u4E0D\u652F\u6301\u5355\u72EC\u8986\u76D6\u97F3\u8272\u3002\u53EF\u8BBE\u7F6E\u9875\u9762\u6216\u6587\u7A3F\u9ED8\u8BA4\u97F3\u8272\u3002",disclosure:(e,t)=>t?`\u672C\u6B21\u5728\u672C\u673A\u901A\u8FC7 ${e} \u5408\u6210\u3002`:`\u672C\u6B21\u5C06\u6240\u793A\u8BB2\u7A3F\u53D1\u9001\u81F3 ${e} \u5408\u6210\u914D\u97F3\u3002`,confirmPreview:"\u786E\u8BA4\u5E76\u8BD5\u542C",sampleText:"\u6807\u51C6\u793A\u4F8B\u6587\u672C",source:"\u58F0\u97F3\u6765\u6E90",previewHint:"\u786E\u8BA4\u540E\u64AD\u653E\u5DF2\u6709\u7F13\u5B58\u6216\u8BF7\u6C42\u5408\u6210\uFF1B\u9009\u62E9\u97F3\u8272\u672C\u8EAB\u4E0D\u4F1A\u751F\u6210\u914D\u97F3\u3002",refreshing:"\u6B63\u5728\u52A0\u8F7D\u914D\u97F3\u72B6\u6001\u2026",refresh:"\u5237\u65B0\u72B6\u6001",missingOnly:"\u53EA\u751F\u6210\u7F3A\u5931\u4E0E\u9700\u8981\u66F4\u65B0\u7684\u7247\u6BB5",confirmGenerate:"\u786E\u8BA4\u5E76\u751F\u6210",cancelJob:"\u53D6\u6D88\u751F\u6210",oldVersion:"\u8F83\u65E9\u6587\u7A3F\u7248\u672C",noScript:"\u5F53\u524D\u8303\u56F4\u6CA1\u6709\u53EF\u751F\u6210\u7684\u8BB2\u7A3F\u3002",statuses:{ready:"\u53EF\u64AD\u653E",missing:"\u9700\u8981\u751F\u6210",blocked:"\u6682\u4E0D\u53EF\u751F\u6210",empty:"\u6CA1\u6709\u8BB2\u7A3F"},jobs:{queued:"\u7B49\u5F85\u751F\u6210",running:"\u6B63\u5728\u751F\u6210",cancelling:"\u6B63\u5728\u53D6\u6D88",cancelled:"\u5DF2\u53D6\u6D88",done:"\u5DF2\u5B8C\u6210",failed:"\u751F\u6210\u5931\u8D25",stale:"\u6587\u7A3F\u5DF2\u66F4\u65B0"},progress:(e,t,n)=>`\u5DF2\u5B8C\u6210 ${e} / ${t}${n?`\uFF0C\u5931\u8D25 ${n}`:""}`,generationSummary:(e,t)=>[e?`\u5F85\u751F\u6210 ${e} \u6BB5`:"",t?`${t} \u6BB5\u4E0D\u53EF\u7528`:""].filter(Boolean).join(" \xB7 "),generationScript:"\u672C\u6B21\u8303\u56F4\u7684\u8BB2\u7A3F",generationBusy:"\u6B64\u6587\u7A3F\u5DF2\u6709\u751F\u6210\u64CD\u4F5C\uFF0C\u8BF7\u7B49\u5F85\u5B8C\u6210\u6216\u53D6\u6D88\u540E\u91CD\u8BD5\u3002",cacheReady:"\u914D\u97F3\u5DF2\u5C31\u7EEA\u3002",unboundScript:"\u6B64\u9875\u6709\u5173\u8054\u5230\u8DE8\u6B65\u9AA4\u63D0\u793A\u7684\u8BB2\u7A3F\uFF0C\u8BF7\u9009\u62E9\u9875\u9762\u6216\u6587\u7A3F\u8303\u56F4\u751F\u6210\u3002",recordingUnavailable:"\u672C\u6B65\u4F7F\u7528\u539F\u97F3\u9891\uFF0C\u65E0\u9700\u751F\u6210\u8BED\u97F3\u3002",silentScope:e=>`${e} \u4E2A\u6B65\u9AA4\u5DF2\u660E\u786E\u8BBE\u7F6E\u4E3A\u9759\u97F3\uFF0C\u8BBE\u7F6E\u4FDD\u6301\u4E0D\u53D8\u3002`,requestFailed:"\u65E0\u6CD5\u5B8C\u6210\u64CD\u4F5C\u3002\u8BBE\u7F6E\u548C\u8349\u7A3F\u5DF2\u4FDD\u7559\uFF0C\u8BF7\u91CD\u8BD5\u3002",cancel:"\u53D6\u6D88",close:"\u5173\u95ED",cancelAndClose:"\u53D6\u6D88\u5E76\u5173\u95ED",retry:"\u91CD\u8BD5"},edt={voice:"Voice",settings:"Choose Voice",generate:"Generate Voiceover",generation:"Voiceover Generation and Updates",currentVoice:"Current voice",unset:"No voice selected",inherited:{step:"Independent setting",page:"Inherited from page",document:"Inherited from document",unset:"Not set"},loading:"Loading voice settings\u2026",loadingVoices:"Loading available voices\u2026",loadFailed:"Couldn\u2019t load voice settings. Try again.",unsupported:"This workspace service does not support voice settings yet. Update and restart Presmium.",noService:"No voice service is connected.",speechFailures:{"speech-authentication":"The speech API key was rejected. Update it in Voice Service settings.","speech-permission":"The speech service denied access. Check activation of speech synthesis 2.0 and the key\u2019s service and voice permissions.","speech-quota":"The speech service has insufficient credit or quota. Check the account and try again.","speech-busy":"The speech service is at its concurrency limit. Try playing again shortly.","speech-network":"Couldn\u2019t connect to the speech service. Check the network and play again.","speech-empty-audio":"The speech service returned no audio. Play again or choose another voice.","speech-invalid-request":"The speech service rejected this script or voice parameters. Check the voice and script.","speech-provider":"The speech service can\u2019t generate voiceover right now. Try playing again shortly.","speech-cache-failed":"Couldn\u2019t write the voiceover cache. Check disk space and directory permissions."},noServiceOption:"Not connected",savedEngineUnavailable:"Saved service (not connected)",generationUnavailable:"Voiceover generation is not enabled for this document. Script and voice settings are kept.",catalogUnsupported:"This service does not provide a list of voices. Your saved voice settings are kept.",voiceUnavailable:"The selected voice does not support the document language or service. Choose another voice.",parametersUnsupported:"This service does not support the selected parameters. Refresh the list of voices and check again.",previewTooLong:"This step\u2019s script exceeds the preview limit. Generate voiceover to play it.",sourceUnsupported:"The document\u2019s source format cannot safely update voice settings yet. Settings and drafts are kept.",bundledCatalog:"Voices come from the service\u2019s built-in list. The connection is checked when voiceover is generated.",search:"Find a voice",searchPlaceholder:"Name, language, or voice source",available:"Available voices",empty:"No matching voices",results:e=>`${e} voices`,language:"Language",allLanguages:"All languages",provider:"Voice service",details:"Voice details",languageMismatch:"Does not support the document language",standard:"Play Standard Sample",currentScript:"Play Current Script",stop:"Stop Sample",auditioning:"Playing",auditionLoading:"Preparing to play\u2026",auditionFailed:"Couldn\u2019t play the sample. Try again; your voice settings haven\u2019t changed.",pauseUnavailable:"The preview can\u2019t pause playback yet, so listening is unavailable. Reload the document.",pauseTimeout:"Couldn\u2019t confirm that playback paused. Try again.",changed:"The document or voice settings changed. Your draft is kept; check the scope again for the current step.",draftRecovered:"Your draft voice settings were recovered. Check the scope before applying them.",recoveryFailed:"Voice drafts can\u2019t be kept in this browser. Apply or copy your settings before closing.",recheck:"Check Again for Current Step",scope:"Apply to",scopes:{step:"Current step",steps:"Selected steps",page:"Current page",document:"Entire document"},selectedSteps:"Select Steps",step:(e,t)=>`Page ${e}, step ${t}`,selected:e=>`${e} steps selected`,pageScript:e=>`Page ${e}, linked script (generate by page)`,inherit:"Use Inherited Voice",inheritHint:"Use the nearest page or document default voice.",replace:"Existing overrides",preserve:"Keep independent settings",replaceAll:"Replace independent settings",counts:(e,t)=>`${e} steps will update; ${t} independent settings will be kept.`,check:"Check Scope",checking:"Checking scope\u2026",apply:"Apply Settings",saved:"Voice settings saved.",cachedPreview:"This preview uses an existing voiceover cache.",clearDefault:"Clear Document Default Voice",rate:"Speaking rate",rateInvalid:(e,t)=>`Enter a number between ${e} and ${t}.`,style:"Reading style",styleDefault:"Service default",cueStep:"This script has cues across steps. A step voice override is not supported yet; set a page or document default instead.",disclosure:(e,t)=>t?`The voiceover is generated on this device with ${e}.`:`The script shown is sent to ${e} to generate the voiceover.`,confirmPreview:"Confirm and Play Sample",sampleText:"Standard sample text",source:"Voice source",previewHint:"After you confirm, a saved voiceover plays or a new one is generated. Choosing a voice doesn\u2019t generate voiceover.",refreshing:"Loading voiceover status\u2026",refresh:"Refresh Status",missingOnly:"Generate only missing clips and clips that need updating",confirmGenerate:"Confirm and Generate",cancelJob:"Cancel Generating",oldVersion:"Earlier document version",noScript:"There is no script to generate in this scope.",statuses:{ready:"Playable",missing:"Needs generation",blocked:"Unavailable",empty:"No script"},jobs:{queued:"Queued",running:"Generating",cancelling:"Canceling",cancelled:"Canceled",done:"Completed",failed:"Generation failed",stale:"Document changed"},progress:(e,t,n)=>`${e} / ${t} completed${n?`; ${n} failed`:""}`,generationSummary:(e,t)=>[e?`${e} ${e===1?"clip":"clips"} to generate`:"",t?`${t} ${t===1?"clip":"clips"} unavailable`:""].filter(Boolean).join(" \xB7 "),generationScript:"Script in this scope",generationBusy:"Voiceover is already being generated for this document. Wait for it or cancel it, then try again.",cacheReady:"Voiceover is ready.",unboundScript:"This page has script with cues across steps. Choose a page or document scope to generate it.",recordingUnavailable:"This step uses original audio, so no voiceover needs to be generated.",silentScope:e=>`${e} steps are explicitly silent. Their settings are kept.`,requestFailed:"Couldn\u2019t finish the operation. Settings and drafts are kept; try again.",cancel:"Cancel",close:"Close",cancelAndClose:"Cancel and Close",retry:"Retry"},oh={"zh-CN":Qct,en:edt};function Ki(e,t){let n=oh[t],r=e instanceof Error?e.message:"",o=KA(e);if(o)return n.speechFailures[o]??n.requestFailed;if(r==="not-configured"||r==="voice-not-configured")return n.noService;if(r==="voice-unavailable"||r==="voice-engine-unsupported"||r==="voice-engine-unknown")return n.voiceUnavailable;if(r==="voice-catalog-unavailable"||r==="catalog-unavailable")return n.catalogUnsupported;if(r==="voice-cue-step")return n.cueStep;if(r==="voice-script-empty")return n.noScript;if(r==="voice-preview-too-long"||r==="voice-preview-too-large")return n.previewTooLong;if(r==="voice-rate-unsupported"||r==="voice-style-unsupported")return n.parametersUnsupported;if(r==="voice-source-format"||r==="voice-source-ignored")return n.sourceUnsupported;if(r==="voiceover-unavailable")return n.generationUnavailable;if(r==="voice-job-busy")return n.generationBusy;if(r==="voice-unset")return n.unset;if(r==="recording-unavailable"||r==="voice-recording-unavailable")return n.recordingUnavailable;if(r==="speech-unavailable"||r.startsWith("no speech service:"))return n.noService;if(["voice-source-changed","voice-source-unavailable","voice-source-pending","voice-revision-changed","voice-preview-changed","voice-step-binding-stale","voice-target-changed"].includes(r))return n.changed;if(e instanceof Pn){if(e.status===404)return n.unsupported;if(e.status===409)return n.changed}return r==="voice-context-changed"?n.changed:r==="preview-playback-timeout"?n.pauseTimeout:r.startsWith("preview-playback-")?n.pauseUnavailable:r.startsWith("audition-")?n.auditionFailed:n.requestFailed}function Sa(e,t){let n=e.getState(),r=n.authoring;return n.document===t.directory&&r?.identity===t.identity&&r.version===t.source.version&&r.fingerprint===t.source.fingerprint&&r.content?.id===t.source.documentId&&!r.loading&&!r.dirty&&!r.saving&&!r.composing&&!r.restored&&!r.error}function OY(e,t){let n=e.sections.find(o=>o.stepIds?.includes(t)),r=n?.stepIds?.indexOf(t)??-1;if(!n||r<0)throw new Error("voice-step-binding-stale");return Pj(n,r)}async function y2(e,t,n){let r=e.getState(),o=r.authoring?.identity,i=r.document;if(!o||i===void 0)throw new Error("voice-context-changed");await e.pausePlayback(),n.throwIfAborted(),await e.flushPendingEdits(n);let a=e.getState(),s=a.authoring;if(a.document!==i||s?.identity!==o||!s.version||!s.fingerprint||!s.content?.steps[t])throw new Error("voice-context-changed");let l=await v9(e.client,{directory:i,version:s.version,fingerprint:s.fingerprint},n);if(n.throwIfAborted(),!l.doc.source)throw new Error("voice-source-pending");let c={directory:i,identity:o,revision:l.revision,source:l.doc.source,target:OY(l.doc,t),ir:l.doc};if(!Sa(e,c))throw new Error("voice-context-changed");return c}function NY(e,t){if(t.kind==="document")return{kind:"document"};if(t.kind==="page"){if(!e.ir.sections.some(n=>n.id===t.sectionId))throw new Error("voice-target-changed");return{kind:"page",section:t.sectionId}}if(t.kind==="step")return{kind:"step",target:OY(e.ir,t.stepId)};if(!t.stepIds.length)throw new Error("voice-script-empty");return{kind:"steps",targets:[...new Set(t.stepIds)].map(n=>OY(e.ir,n))}}var fo=require("react");var tdt={trim:"\u5F55\u97F3\u533A\u95F4",captionReview:"\u5B57\u5E55\u5C1A\u672A\u6309\u88C1\u526A\u540E\u7684\u5F55\u97F3\u5BF9\u9F50\uFF0C\u8BF7\u6838\u5BF9\u3002",title:"\u539F\u97F3\u9891",source:"\u672C\u6B65\u539F\u97F3",choose:"\u9009\u62E9\u5DF2\u4FDD\u5B58\u97F3\u9891",removedAudio:"\u539F\u97F3\u9891\u5DF2\u79FB\u9664",adopt:"\u91C7\u7528\u4E3A\u672C\u6B65\u914D\u97F3",adopted:"\u5DF2\u91C7\u7528",retryAdoption:"\u91CD\u8BD5\u91C7\u7528",cancelAdoption:"\u53D6\u6D88\u91C7\u7528",adoptionSourceChanged:"\u6587\u7A3F\u5DF2\u66F4\u65B0\uFF0C\u8BF7\u91CD\u8BD5\u3002",adoptionFailed:"\u65E0\u6CD5\u91C7\u7528\u8FD9\u6BB5\u97F3\u9891\uFF0C\u8BF7\u91CD\u8BD5\u3002",start:"\u5F00\u59CB\u5F55\u97F3",stop:"\u505C\u6B62\u5F55\u97F3",cancel:"\u53D6\u6D88",cancelTake:"\u653E\u5F03\u672C\u6B21\u5F55\u97F3",rerecord:"\u91CD\u65B0\u5F55\u97F3",audition:"\u8BD5\u542C",stopAudition:"\u505C\u6B62\u8BD5\u542C",save:"\u4FDD\u5B58\u4E3A\u97F3\u9891\u7D20\u6750",saving:"\u6B63\u5728\u4FDD\u5B58\u539F\u97F3\u2026",retry:"\u91CD\u8BD5",discard:"\u653E\u5F03\u5019\u9009",ready:"\u539F\u97F3\u5019\u9009 \xB7 \u5C1A\u672A\u4FDD\u5B58",imported:"\u5DF2\u4FDD\u5B58\u4E3A\u97F3\u9891\u7D20\u6750",requesting:"\u6B63\u5728\u7B49\u5F85\u9EA6\u514B\u98CE\u8BB8\u53EF",recording:"\u6B63\u5728\u5F55\u97F3",stopping:"\u6B63\u5728\u5B8C\u6210\u5F55\u97F3\u2026",cancelSave:"\u53D6\u6D88\u4FDD\u5B58",currentSource:"\u6587\u7A3F\u5C1A\u672A\u4FDD\u5B58\uFF0C\u8BF7\u5148\u5B8C\u6210\u5F53\u524D\u8F93\u5165\u3002",saveFailed:"\u65E0\u6CD5\u4FDD\u5B58\u539F\u97F3\u3002\u5F55\u97F3\u5DF2\u4FDD\u7559\uFF0C\u8BF7\u91CD\u8BD5\u3002",discardTitle:"\u653E\u5F03\u8FD9\u4EFD\u539F\u97F3\uFF1F",discardHint:"\u672A\u4FDD\u5B58\u7684\u5F55\u97F3\u5C06\u88AB\u5220\u9664\uFF0C\u5DF2\u4FDD\u5B58\u7684\u97F3\u9891\u7D20\u6750\u4E0D\u53D7\u5F71\u54CD\u3002",keep:"\u4FDD\u7559\u539F\u97F3",failures:{"recording-context":"\u5F53\u524D\u73AF\u5883\u65E0\u6CD5\u8BBF\u95EE\u9EA6\u514B\u98CE\u3002\u8BF7\u4F7F\u7528\u5B89\u5168\u8FDE\u63A5\uFF0C\u6216\u7EE7\u7EED\u5BFC\u5165\u97F3\u9891\u3002","recording-unsupported":"\u6B64\u6D4F\u89C8\u5668\u65E0\u6CD5\u5F55\u5236\u53D7\u652F\u6301\u7684\u97F3\u9891\u683C\u5F0F\u3002\u4ECD\u53EF\u5BFC\u5165\u97F3\u9891\u3002","recording-permission":"\u9EA6\u514B\u98CE\u672A\u83B7\u8BB8\u53EF\u3002\u8BF7\u68C0\u67E5\u6D4F\u89C8\u5668\u6743\u9650\u540E\u91CD\u8BD5\u3002","recording-device":"\u6CA1\u6709\u53EF\u7528\u7684\u9EA6\u514B\u98CE\u3002","recording-device-busy":"\u9EA6\u514B\u98CE\u5F53\u524D\u65E0\u6CD5\u4F7F\u7528\uFF0C\u8BF7\u68C0\u67E5\u8BBE\u5907\u540E\u91CD\u8BD5\u3002","recording-device-unsupported":"\u5F53\u524D\u6D4F\u89C8\u5668\u6216\u8BBE\u5907\u4E0D\u652F\u6301\u6B64\u5F55\u97F3\u8BF7\u6C42\u3002\u4ECD\u53EF\u5BFC\u5165\u97F3\u9891\u3002","recording-device-ended":"\u9EA6\u514B\u98CE\u8FDE\u63A5\u5DF2\u7ED3\u675F\uFF0C\u5DF2\u4FDD\u7559\u5F55\u5230\u7684\u539F\u97F3\u3002","recording-failed":"\u65E0\u6CD5\u5B8C\u6210\u672C\u6B21\u5F55\u97F3\u3002\u5DF2\u6709\u539F\u97F3\u4ECD\u4FDD\u7559\u3002","recording-empty":"\u672C\u6B21\u6CA1\u6709\u5F55\u5230\u97F3\u9891\uFF0C\u8BF7\u91CD\u8BD5\u3002","recording-size":"\u5F55\u97F3\u8D85\u8FC7 16 MiB\u3002\u8BF7\u7F29\u77ED\u5F55\u97F3\u540E\u91CD\u8BD5\uFF0C\u5DF2\u6709\u5019\u9009\u4ECD\u4FDD\u7559\u3002","recording-duration":"\u5DF2\u8FBE\u5230\u5341\u5206\u949F\u5F55\u5236\u4E0A\u9650\uFF0C\u5F55\u97F3\u5DF2\u505C\u6B62\u3002","audition-audio":"\u539F\u97F3\u65E0\u6CD5\u64AD\u653E\u3002\u8BF7\u68C0\u67E5\u97F3\u9891\u6216\u91CD\u65B0\u5F55\u5236\u3002","audition-request":"\u65E0\u6CD5\u5F00\u59CB\u8BD5\u542C\uFF0C\u8BF7\u91CD\u8BD5\u3002"}},ndt={trim:"Recording range",captionReview:"Captions are not aligned to the trimmed recording. Review them.",title:"Original audio",source:"Original audio for this step",choose:"Choose Saved Audio",removedAudio:"Original audio was removed",adopt:"Use as Step Voiceover",adopted:"Applied",retryAdoption:"Retry",cancelAdoption:"Cancel",adoptionSourceChanged:"The document changed. Retry.",adoptionFailed:"Couldn\u2019t use this audio. Try again.",start:"Start Recording",stop:"Stop Recording",cancel:"Cancel",cancelTake:"Discard This Recording",rerecord:"Record Again",audition:"Play Sample",stopAudition:"Stop Sample",save:"Save as Audio Asset",saving:"Saving original audio\u2026",retry:"Retry",discard:"Discard Candidate",ready:"Original audio candidate \xB7 Not saved",imported:"Saved as an audio asset",requesting:"Waiting for microphone permission",recording:"Recording",stopping:"Finishing recording\u2026",cancelSave:"Cancel",currentSource:"Finish and save the current document input first.",saveFailed:"Couldn\u2019t save the original audio. The recording is kept; try again.",discardTitle:"Discard this original audio?",discardHint:"The recording that is not saved will be deleted. Saved audio assets are kept.",keep:"Keep Original Audio",failures:{"recording-context":"Microphone access is unavailable here. Use a secure connection or import an audio file.","recording-unsupported":"This browser cannot record a supported audio format. Audio file import is still available.","recording-permission":"Microphone permission was not granted. Check browser permissions and retry.","recording-device":"No microphone is available.","recording-device-busy":"The microphone is unavailable. Check the device and retry.","recording-device-unsupported":"This browser or device does not support the recording request. Audio file import is still available.","recording-device-ended":"The microphone disconnected. Recorded audio is retained.","recording-failed":"Couldn\u2019t finish this recording. Any previous original audio is kept.","recording-empty":"No audio was recorded. Retry.","recording-size":"The recording exceeds 16 MiB. Record a shorter take; any previous candidate is retained.","recording-duration":"The ten-minute recording limit was reached. Recording stopped.","audition-audio":"This audio could not be played. Check it or record again.","audition-request":"Couldn\u2019t start listening. Try again."}},V1={"zh-CN":tdt,en:ndt};async function A3e(e,t=24e3){let n=await new OfflineAudioContext(1,1,t).decodeAudioData(await e.arrayBuffer()),r=new OfflineAudioContext(1,Math.max(1,Math.ceil(n.duration*t)),t),o=r.createBufferSource();o.buffer=n,o.connect(r.destination),o.start();let i=(await r.startRendering()).getChannelData(0),a=new DataView(new ArrayBuffer(44+i.length*2)),s=(l,c)=>{for(let d=0;d<c.length;d++)a.setUint8(l+d,c.charCodeAt(d))};s(0,"RIFF"),a.setUint32(4,36+i.length*2,!0),s(8,"WAVE"),s(12,"fmt "),a.setUint32(16,16,!0),a.setUint16(20,1,!0),a.setUint16(22,1,!0),a.setUint32(24,t,!0),a.setUint32(28,t*2,!0),a.setUint16(32,2,!0),a.setUint16(34,16,!0),s(36,"data"),a.setUint32(40,i.length*2,!0);for(let l=0;l<i.length;l++)a.setInt16(44+l*2,Math.round(Math.max(-1,Math.min(1,i[l]))*32767),!0);return{blob:new Blob([a.buffer],{type:"audio/wav"}),seconds:n.duration}}var R0=class{#t;#n=new Set;#o;#s={status:"idle"};#r=0;#i;#l;#a;#c=!1;constructor(t){this.#t=t,this.#o=t.registerAudition(()=>this.stop())}snapshot=()=>this.#s;subscribe=t=>(this.#n.add(t),()=>{this.#n.delete(t)});#f(t){this.#s=t;for(let n of this.#n)n()}#u(){this.#i?.abort(),this.#i=void 0;let t=this.#l;this.#l=void 0,t&&(t.onended=null,t.onerror=null,t.pause(),t.removeAttribute("src"),t.load()),this.#a&&URL.revokeObjectURL(this.#a),this.#a=void 0}stop(){this.#r++,this.#u(),this.#c||this.#f({status:"idle"})}async play(t){if(this.#t.stopAuditions(),this.#c)return;let n=this.#r,r=new AbortController;this.#i=r;let o=()=>!this.#c&&this.#r===n&&!r.signal.aborted;this.#f({status:"loading"});try{if(await this.#t.pausePlayback(!0),!o())return;let i=await t(r.signal);if(!o())return;let a=new Audio;if(this.#l=a,a.preload="auto",a.src=typeof i.audio=="string"?i.audio:this.#a=URL.createObjectURL(i.audio),a.onended=()=>{o()&&this.stop()},a.onerror=()=>{o()&&(this.#u(),this.#f({status:"failed",error:"audition-audio"}))},await a.play(),!o()){a.pause();return}this.#f({status:"playing"})}catch(i){if(!o())return;this.#u(),this.#f({status:"failed",error:KA(i)??(i instanceof Error&&i.message.startsWith("preview-playback-")?i.message:"audition-request")})}}dispose(){this.#c||(this.stop(),this.#c=!0,this.#o(),this.#n.clear())}};var Gt=require("react/jsx-runtime");function T3e({label:e,hint:t,value:n,disabled:r,onChange:o}){let i=tt(),a=me(T=>T.locale),s=b2[a],l=V1[a],[c]=(0,fo.useState)(()=>new e4),d=(0,fo.useSyncExternalStore)(c.subscribe,c.snapshot),[u]=(0,fo.useState)(n4),[f,p]=(0,fo.useState)(!1),[m,h]=(0,fo.useState)(),[g,v]=(0,fo.useState)({status:"idle"}),b=(0,fo.useRef)(),y=(0,fo.useRef)(null),w=(0,fo.useRef)(!0);(0,fo.useEffect)(()=>()=>{w.current=!1,c.dispose(),b.current?.dispose()},[c]);let _=async(T,I)=>{p(!0),h(void 0),b.current?.stop();try{let C=await A3e(T);w.current&&o({...C,name:I})}catch{w.current&&h(s.decodeFailed)}finally{w.current&&p(!1)}},x=d.candidate?.file;(0,fo.useEffect)(()=>{x&&_(x,l.title).finally(()=>c.discard())},[x]);let k=["requesting","recording","stopping"].includes(d.phase),S=()=>{h(void 0),c.start(async()=>(i.stopAuditions(),await i.pausePlayback(),i.registerAudioCapture(()=>c.stop())))},E=()=>{if(n){if(!b.current){let T=b.current=new R0(i);T.subscribe(()=>{w.current&&v(T.snapshot())})}g.status==="playing"||g.status==="loading"?b.current.stop():b.current.play(async()=>({audio:n.blob}))}},P=d.phase==="requesting"?l.requesting:d.phase==="recording"?l.recording:f?s.preparing:n?`${n.name} \xB7 ${s.seconds(n.seconds)}`:s.empty;return(0,Gt.jsxs)(Ut,{label:e,hint:t,group:!0,children:[(0,Gt.jsx)("span",{className:"pm-ui-hint",role:"status",children:P}),(d.error||u)&&!k&&(0,Gt.jsx)(ke,{tone:"warn",children:l.failures[d.error??u]??l.failures["recording-failed"]}),m&&(0,Gt.jsx)(ke,{tone:"danger",children:m}),(0,Gt.jsxs)("div",{className:"pmw-voice__actions",children:[d.phase==="recording"?(0,Gt.jsx)(he,{small:!0,variant:"primary",onClick:()=>c.stop(),children:s.stop}):(0,Gt.jsx)(he,{small:!0,disabled:r||k||f||!!u,onClick:S,children:s.record}),(0,Gt.jsx)(he,{small:!0,disabled:r||k||f,onClick:()=>y.current?.click(),children:s.choose}),n&&(0,Gt.jsx)(he,{small:!0,icon:"audio",disabled:k||f,loading:g.status==="loading",onClick:E,children:g.status==="playing"?s.stopListening:s.listen}),n&&(0,Gt.jsx)(he,{small:!0,disabled:r||k||f,onClick:()=>{b.current?.stop(),o(void 0)},children:s.clear})]}),(0,Gt.jsx)("input",{ref:y,hidden:!0,type:"file",accept:"audio/*,.wav,.mp3,.m4a,.ogg,.webm",onChange:T=>{let I=T.currentTarget.files?.[0];T.currentTarget.value="",I&&_(I,I.name)}})]})}function I3e({directory:e,engine:t,lang:n,onUse:r,onClose:o}){let i=tt(),a=me(J=>J.locale),s=b2[a],l=t.id==="volcengine",[c,d]=(0,fo.useState)(""),[u,f]=(0,fo.useState)(""),[p,m]=(0,fo.useState)(s.defaultScope),[h,g]=(0,fo.useState)(),[v,b]=(0,fo.useState)(),[y,w]=(0,fo.useState)(!1),[_,x]=(0,fo.useState)(!1),[k,S]=(0,fo.useState)(),[E,P]=(0,fo.useState)(),[T,I]=(0,fo.useState)(0),C=(0,fo.useRef)();(0,fo.useEffect)(()=>()=>C.current?.abort(),[]);let A=c.trim(),R=!!A&&!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(A),O=E?.state==="ready",L=_||O,D=!!(A&&!R&&u.trim()&&p.trim()&&h&&v)&&!L,$=async()=>{let J=new AbortController;C.current?.abort(),C.current=J,w(!1),x(!0),S(void 0),P(void 0),I(0);let te=V=>new Promise((ee,Y)=>{let G=setTimeout(ee,V);J.signal.addEventListener("abort",()=>{clearTimeout(G),Y(J.signal.reason)},{once:!0})});try{let V=await i.client.cloneVoice(e,{engine:t.id,voice:A,lang:n,speaker:u.trim(),scope:p.trim(),sample:v.blob,statement:h.blob},J.signal);P(V);let ee=Date.now();for(;V.state==="training"&&Date.now()-ee<10*6e4;)await te(3e3),V=await i.client.readCloneStatus(e,A,t.id,J.signal),P(V),I(Date.now()-ee)}catch(V){J.signal.aborted||S(E3e(V,a))}finally{C.current===J&&(C.current=void 0,x(!1))}},j=()=>{C.current?.abort(),o()};return(0,Gt.jsxs)(Gt.Fragment,{children:[(0,Gt.jsx)(kn,{open:!0,label:s.title,closeLabel:s.close,description:s.description,onClose:j,footer:(0,Gt.jsxs)(Gt.Fragment,{children:[(0,Gt.jsx)(he,{onClick:j,children:s.close}),O?(0,Gt.jsx)(he,{variant:"primary",onClick:()=>r(A),children:s.use}):(0,Gt.jsx)(he,{variant:"primary",loading:_,disabled:!D,onClick:()=>w(!0),children:s.train})]}),children:(0,Gt.jsxs)("div",{className:"pmw-voice__form",children:[k&&(0,Gt.jsx)(ke,{tone:"danger",children:k}),E&&(0,Gt.jsx)(ke,{tone:E.state==="ready"?"ok":E.state==="failed"?"danger":"accent",children:(0,Gt.jsx)("span",{role:"status",children:s.state(E,T)})}),(0,Gt.jsx)(Kn,{label:s.voice,hint:s.voiceHint(l),error:R?s.voiceInvalid:void 0,value:c,maxLength:128,spellCheck:!1,autoComplete:"off",disabled:L,onChange:J=>d(J.target.value)}),(0,Gt.jsx)(Kn,{label:s.speaker,hint:s.speakerHint,value:u,maxLength:80,disabled:L,onChange:J=>f(J.target.value)}),(0,Gt.jsx)(Kn,{label:s.scope,hint:s.scopeHint,value:p,maxLength:200,disabled:L,onChange:J=>m(J.target.value)}),(0,Gt.jsx)(Ut,{label:s.statementLabel,children:(0,Gt.jsx)("p",{className:"pmw-voice__sample",children:s.statementText(u.trim()||s.someone,p.trim()||s.defaultScope)})}),(0,Gt.jsx)(T3e,{label:s.statement,hint:s.statementHint,value:h,disabled:L,onChange:g}),(0,Gt.jsx)(Ut,{label:s.passageLabel,children:(0,Gt.jsx)("p",{className:"pmw-voice__sample",children:s.passage})}),(0,Gt.jsx)(T3e,{label:s.sample,hint:s.sampleHint,value:v,disabled:L,onChange:b}),v&&(v.seconds<10||v.seconds>30)&&(0,Gt.jsx)(ke,{tone:"warn",children:s.sampleLength(v.seconds)})]})}),(0,Gt.jsx)(kn,{open:y,label:s.confirmTitle,closeLabel:s.cancel,description:s.confirmHint,onClose:()=>w(!1),footer:(0,Gt.jsxs)(Gt.Fragment,{children:[(0,Gt.jsx)(he,{onClick:()=>w(!1),children:s.cancel}),(0,Gt.jsx)(he,{variant:"primary",onClick:()=>void $(),children:s.confirm})]}),children:(0,Gt.jsxs)("div",{className:"pmw-voice__form",children:[(0,Gt.jsx)(Ut,{label:s.voice,children:(0,Gt.jsx)("span",{children:A})}),(0,Gt.jsx)(Ut,{label:s.speaker,children:(0,Gt.jsx)("span",{children:u.trim()})}),(0,Gt.jsx)(Ut,{label:s.scope,children:(0,Gt.jsx)("span",{children:p.trim()})}),(0,Gt.jsx)(ke,{tone:"warn",children:s.costs(t.provider,l)})]})})]})}var kf=require("react");var Vo=require("react/jsx-runtime");function R3e({quote:e,snapshot:t,onClose:n,onRecheck:r}){let o=tt(),i=me(k=>k.locale),a=oh[i],s=me(()=>Sa(o,t)),l=(0,kf.useRef)(),c=(0,kf.useRef)(0),d=(0,kf.useRef)(!1),[u,f]=(0,kf.useState)({status:"idle"}),[p,m]=(0,kf.useState)(),[h,g]=(0,kf.useState)(!1),v=e.revision===t.revision&&e.source.documentId===t.source.documentId&&e.source.version===t.source.version&&e.source.fingerprint===t.source.fingerprint;(0,kf.useEffect)(()=>{let k=++c.current,S=new R0(o);d.current=!1,l.current=S,f(S.snapshot()),m(void 0),g(!1);let E=S.subscribe(()=>{c.current===k&&!d.current&&f(S.snapshot())});return()=>{c.current++,E(),S.dispose(),l.current===S&&(l.current=void 0)}},[o,e,t]),(0,kf.useEffect)(()=>{s&&v||(g(!0),l.current?.stop())},[s,v]);let b=()=>{d.current||(d.current=!0,c.current++,l.current?.dispose(),n())},y=()=>{l.current?.stop(),r?.()},w=()=>{let k=l.current,S=c.current;!k||d.current||h||!v||!Sa(o,t)||(m(void 0),k.play(async E=>{try{if(!Sa(o,t))throw new Error("voice-context-changed");let P=await o.client.previewVoice(t.directory,{revision:e.revision,source:e.source,voice:e.voice,mode:e.mode,...e.target?{target:e.target}:{},quote:e.quote,confirmed:!0},E);if(E.throwIfAborted(),c.current!==S||d.current||!Sa(o,t)||P.revision!==e.revision||P.source.documentId!==e.source.documentId||P.source.version!==e.source.version||P.source.fingerprint!==e.source.fingerprint)throw new Error("voice-context-changed");return{audio:P.audio}}catch(P){throw c.current===S&&!d.current&&!E.aborted&&(m(Ki(P,i)),P instanceof Error&&["voice-context-changed","voice-source-changed","voice-source-unavailable","voice-revision-changed","voice-preview-changed"].includes(P.message)&&g(!0)),P}}))},_=h||!s||!v,x=u.status==="loading"||u.status==="playing";return(0,Vo.jsx)(kn,{open:!0,label:e.mode==="step"?a.currentScript:a.standard,description:a.previewHint,closeLabel:a.close,onClose:b,footer:(0,Vo.jsxs)(Vo.Fragment,{children:[(0,Vo.jsx)(he,{small:!0,onClick:b,children:a.close}),_&&r&&(0,Vo.jsx)(he,{small:!0,onClick:y,children:a.recheck}),x?(0,Vo.jsx)(he,{small:!0,onClick:()=>l.current?.stop(),children:a.stop}):(0,Vo.jsx)(he,{small:!0,variant:"accent",disabled:_||!l.current,onClick:w,children:a.confirmPreview})]}),children:(0,Vo.jsxs)("div",{className:"pmw-operation",children:[(0,Vo.jsx)(Ut,{label:a.provider,children:(0,Vo.jsx)("span",{children:e.provider})}),(0,Vo.jsx)(Ut,{label:a.currentVoice,children:(0,Vo.jsx)("span",{children:e.voice.voice})}),e.target&&(0,Vo.jsx)(Ut,{label:a.scope,children:(0,Vo.jsxs)("span",{children:[t.ir.sections.find(k=>k.id===e.target?.section)?.title," \xB7 ",a.step(t.ir.sections.findIndex(k=>k.id===e.target?.section)+1,e.target.step+1)]})}),(0,Vo.jsx)(Ut,{label:e.mode==="step"?a.currentScript:a.sampleText,children:(0,Vo.jsx)("p",{className:"pmw-voice__sample",children:e.text})}),(0,Vo.jsx)(ke,{children:e.cached?a.cachedPreview:a.disclosure(e.provider,e.local)}),_&&(0,Vo.jsx)(ke,{tone:"warn",children:a.changed}),u.status==="loading"&&(0,Vo.jsx)(ke,{children:a.auditionLoading}),u.status==="playing"&&(0,Vo.jsx)(ke,{tone:"accent",children:a.auditioning}),(p||u.status==="failed")&&(0,Vo.jsx)(ke,{tone:"danger",children:p??Ki(new Error(u.error),i)})]})})}var Mp=require("react/jsx-runtime");function uD({document:e,stepId:t,value:n,disabled:r,onChange:o}){let i=me(c=>c.locale),a=oh[i],s=Gi[i],l=e.steps[t]?.sectionId;return(0,Mp.jsxs)(Mp.Fragment,{children:[(0,Mp.jsx)(Ut,{label:a.scope,group:!0,children:(0,Mp.jsx)(Wc,{label:a.scope,value:n.kind,options:["step","steps","page","document"].map(c=>({value:c,label:s.scopeShort[c]})),disabled:r,onChange:c=>{c==="document"?o({kind:c}):c==="page"&&l?o({kind:c,sectionId:l}):c==="step"?o({kind:c,stepId:t}):c==="steps"&&o({kind:c,stepIds:[t]})}})}),n.kind==="steps"&&(0,Mp.jsx)(Ut,{label:a.selectedSteps,group:!0,hint:a.selected(n.stepIds.length),error:n.stepIds.length?void 0:s.selectSteps,children:(0,Mp.jsx)("div",{className:"pmw-voice__steps",children:e.sectionOrder.flatMap((c,d)=>e.sections[c].stepOrder.map((u,f)=>{let p=n.stepIds.includes(u);return(0,Mp.jsxs)(he,{small:!0,"aria-label":`${e.sections[c].title} \xB7 ${a.step(d+1,f+1)}`,"aria-pressed":p,disabled:r,onClick:()=>o({kind:"steps",stepIds:p?n.stepIds.filter(m=>m!==u):[...n.stepIds,u]}),children:[d+1," \xB7 ",f+1]},u)}))})})]})}var ot=require("react/jsx-runtime"),M3e=(e,t)=>!e.length||e.some(n=>n.toLowerCase().split("-")[0]===t.toLowerCase().split("-")[0]);function D3e({stepId:e,onClose:t}){let n=tt(),r=me(oe=>oe.authoring),o=me(oe=>oe.locale),i=me(oe=>!!(oe.authoring?.loading||oe.authoring?.composing)||Wt(oe)),a=oh[o],s=Gi[o],l=b2[o],c=me(oe=>oe.voiceServiceVersion),d=(0,Ho.useRef)(r.identity).current,u=(0,Ho.useRef)(r.directory).current,[f]=(0,Ho.useState)(()=>S3e(n.client,d,e)),[p,m]=(0,Ho.useState)(()=>f??{version:r.version,scope:{kind:"step",stepId:e},source:od(r.content,e).value??null,replaceOverrides:!1}),[h,g]=(0,Ho.useState)(()=>_3e(n.client,d,e)!=="available"),[v,b]=(0,Ho.useState)(p.source?.type==="tts"?p.source.voice.engine:void 0),[y,w]=(0,Ho.useState)(""),[_,x]=(0,Ho.useState)(""),[k,S]=(0,Ho.useState)(),[E,P]=(0,Ho.useState)(!0),[T,I]=(0,Ho.useState)(),[C,A]=(0,Ho.useState)(0),[R,O]=(0,Ho.useState)(!1),[L,D]=(0,Ho.useState)(),[$,j]=(0,Ho.useState)(),[J,te]=(0,Ho.useState)(),[V,ee]=(0,Ho.useState)(!1),Y=(0,Ho.useRef)({active:!0,generation:0}),G=(0,Ho.useRef)();(0,Ho.useEffect)(()=>()=>{Y.current.active=!1,Y.current.generation++,G.current?.abort()},[]),(0,Ho.useEffect)(()=>{let oe=new AbortController;return P(!0),I(void 0),n.client.readVoiceCatalog(u,v,void 0,oe.signal).then(be=>{oe.signal.aborted||S(be)},be=>{oe.signal.aborted||I(Ki(be,o))}).finally(()=>{oe.signal.aborted||P(!1)}),()=>oe.abort()},[n,u,v,C,r?.reset,o,c]);let F=r?.content,B=r?.identity===d&&!!F?.steps[e],z=v??k?.engine,q=k?.engines.filter(oe=>oe.tts)??[],Z=q.find(oe=>oe.id===(p.source?.type==="tts"?p.source.voice.engine??z:z)),X=k?.catalog.status==="available"?k.catalog.voices:[],K=F?.metadata.lang??"zh-CN",ue=[...new Set(X.flatMap(oe=>oe.lang))].sort(),ie=Z?.parameters?.rate,W=Z?.parameters?.styles,le=p.rateInput?.normalize("NFKC").trim(),ae=le?Number(le):void 0,ne=p.rateInput!==void 0&&le!==void 0&&le.length>0&&(!ie||!/^\d+(?:\.\d+)?$/.test(le)||!Number.isFinite(ae)||ae<ie.min||ae>ie.max),re=p.source===null?"inherit":p.source.type,ye=()=>Y.current.active&&n.getState().authoring?.identity===d,fe=oe=>{G.current?.abort(),Y.current.generation++,O(!1),D(void 0),j(void 0),te(void 0),n.stopAuditions(),m(oe),g(!DY(n.client,d,e,oe))},we=oe=>({...oe,version:n.getState().authoring.version}),Pe=async(oe=p)=>{if(!ye()||!B||i||oe.source?.type==="tts"&&(ne||!oe.source.voice.voice.trim()))return;let be=++Y.current.generation,Ye=new AbortController;G.current?.abort(),G.current=Ye,O(!0),D(void 0);try{if(await n.flushPendingEdits(Ye.signal),!ye()||be!==Y.current.generation)return;let Ae=n.getState().authoring,Ze=n.getDocument(d);if(!Ae?.version||!Ae.fingerprint||!Ze||Ae.dirty||Ae.saving||Ae.error||Ae.restored||Ae.composing)throw new Error("voice-context-changed");let We=we(oe),Ht=rT(Ze,We.scope,We.source,{replaceOverrides:We.replaceOverrides});m(We),g(!DY(n.client,d,e,We));let rr=dg(Ze,We.scope).map(Rr=>{let _r=Ze.steps[Rr],or=Ze.sections[_r.sectionId];return`${or.title} \xB7 ${a.step(Ze.sectionOrder.indexOf(or.id)+1,or.stepOrder.indexOf(Rr)+1)}`});j({draft:We,impact:Ht,scopeLabel:a.scopes[We.scope.kind],targets:rr,expected:{identity:d,version:Ae.version,fingerprint:Ae.fingerprint}})}catch(Ae){ye()&&be===Y.current.generation&&D(Ki(Ae,o))}finally{ye()&&be===Y.current.generation&&O(!1)}},xe=async()=>{if(!$||!ye())return;let oe=$,be=++Y.current.generation;O(!0),D(void 0);try{let Ye=await n.applyDocumentVoice(oe.draft.scope,oe.draft.source,{replaceOverrides:oe.draft.replaceOverrides},oe.expected);if(!ye()||be!==Y.current.generation)return;if(!Ye)throw new Error("voice-context-changed");if(!C3e(n.client,d,e,oe.draft)){g(!0),j(void 0);return}t()}catch(Ye){ye()&&be===Y.current.generation&&(j(void 0),D(Ki(Ye,o)))}finally{ye()&&be===Y.current.generation&&O(!1)}},ve=async oe=>{if(p.source?.type!=="tts"||ne||!B||i)return;let be=++Y.current.generation,Ye=new AbortController,Ae=p.source.voice;G.current?.abort(),G.current=Ye,O(!0),D(void 0);try{let Ze=await y2(n,e,Ye.signal),We=await n.client.readVoicePreview(u,{revision:Ze.revision,voice:Ae,mode:oe,...oe==="step"?{target:Ze.target}:{}},Ye.signal);if(!ye()||be!==Y.current.generation)return;if(!Sa(n,Ze)||We.source.version!==Ze.source.version||We.source.fingerprint!==Ze.source.fingerprint||We.source.documentId!==Ze.source.documentId)throw new Error("voice-context-changed");te({quote:We,snapshot:Ze})}catch(Ze){ye()&&be===Y.current.generation&&D(Ki(Ze,o))}finally{ye()&&be===Y.current.generation&&O(!1)}},de=!!($&&r?.version===$.expected.version&&r.fingerprint===$.expected.fingerprint&&!r.dirty&&!r.saving&&!r.error&&!i);return!F||!B?(0,ot.jsx)(kn,{open:!0,label:a.settings,closeLabel:a.close,onClose:t,children:(0,ot.jsx)(ke,{tone:"warn",children:s.draftChanged})}):(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsx)(kn,{open:!0,label:a.settings,closeLabel:a.close,onClose:t,footer:(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsx)(he,{onClick:t,children:a.close}),(0,ot.jsx)(he,{loading:R,disabled:i||ne||p.source?.type==="tts"&&!p.source.voice.voice.trim()||p.scope.kind==="steps"&&!p.scope.stepIds.length,variant:"primary",onClick:()=>void Pe(),children:a.check})]}),children:(0,ot.jsxs)("div",{className:"pmw-voice__form",children:[f&&(0,ot.jsx)(ke,{tone:"accent",children:a.draftRecovered}),h&&(0,ot.jsx)(ke,{tone:"warn",children:a.recoveryFailed}),L&&(0,ot.jsx)(ke,{tone:"danger",children:L}),(0,ot.jsx)(uD,{document:F,stepId:e,value:p.scope,disabled:R||i,onChange:oe=>fe({...p,scope:oe,replaceOverrides:oe.kind==="steps"&&p.source===null?!0:oe.kind==="step"?!1:p.replaceOverrides})}),(0,ot.jsx)(Ut,{label:a.source,group:!0,children:(0,ot.jsx)(Wc,{label:a.source,value:re,disabled:R||i,options:[{value:"tts",label:a.voice},{value:"none",label:s.none},{value:"inherit",label:a.inherit},...re==="recording"?[{value:"recording",label:s.recording}]:[]],onChange:oe=>{oe==="none"?fe({...p,source:{type:"none"},rateInput:void 0}):oe==="inherit"?fe({...p,source:null,rateInput:void 0,replaceOverrides:p.scope.kind==="steps"?!0:p.replaceOverrides}):oe==="tts"&&fe({...p,source:{type:"tts",voice:{...z?{engine:z}:{},voice:""}},rateInput:void 0})}})}),p.source?.type==="recording"&&(0,ot.jsx)("span",{children:F.assets[p.source.assetId]?.title||s.recording}),p.source?.type==="tts"&&(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsxs)(sr,{label:a.provider,value:z??"",disabled:!q.length||R||i,onChange:oe=>{b(oe.target.value),w(""),x("")},children:[!q.length&&(0,ot.jsx)("option",{value:z??"",children:z?`${z} \xB7 ${a.savedEngineUnavailable}`:a.noServiceOption}),q.map(oe=>(0,ot.jsxs)("option",{value:oe.id,children:[oe.id," \xB7 ",oe.provider]},oe.id)),z&&q.length>0&&!q.some(oe=>oe.id===z)&&(0,ot.jsxs)("option",{value:z,children:[z," \xB7 ",a.savedEngineUnavailable]})]}),T&&(0,ot.jsx)(he,{small:!0,onClick:()=>A(oe=>oe+1),children:a.retry}),k?.catalog.status==="unavailable"&&(0,ot.jsx)(ke,{tone:"warn",children:k.catalog.reason==="not-configured"?a.noService:a.catalogUnsupported}),X.length>0&&(0,ot.jsxs)(sr,{label:a.language,value:y,disabled:R||i,onChange:oe=>w(oe.target.value),children:[(0,ot.jsx)("option",{value:"",children:a.allLanguages}),ue.map(oe=>(0,ot.jsx)("option",{value:oe,children:oe},oe))]}),(E||T||k?.catalog.status==="available")&&(0,ot.jsx)(mw,{label:a.available,searchLabel:a.search,searchPlaceholder:a.searchPlaceholder,emptyLabel:a.empty,loadingLabel:a.loadingVoices,loading:E,error:T,disabled:R||i||k?.catalog.status!=="available",query:_,onQueryChange:x,value:p.source.voice.engine===z||!p.source.voice.engine?p.source.voice.voice:void 0,items:X.filter(oe=>!y||oe.lang.includes(y)).map(oe=>({value:oe.id,label:oe.label,description:[oe.lang.join(", "),oe.cloned?l.cloned:"",M3e(oe.lang,K)?"":a.languageMismatch].filter(Boolean).join(" \xB7 "),keywords:[oe.id,...oe.lang,z??""],disabled:!M3e(oe.lang,K)})),resultsLabel:a.results,onValueChange:oe=>fe({...p,source:{type:"tts",voice:{...z?{engine:z}:{},voice:oe}},rateInput:void 0})}),Z?.clone&&(0,ot.jsx)("div",{className:"pmw-voice__actions",children:(0,ot.jsx)(he,{small:!0,disabled:R||i,onClick:()=>ee(!0),children:l.open})}),(0,ot.jsx)(Ut,{label:s.selectedVoice,children:(0,ot.jsx)("span",{children:p.source.voice.voice||a.unset})}),ie&&(0,ot.jsx)(Kn,{label:a.rate,width:"number",inputMode:"decimal",maxLength:32,value:p.rateInput??(p.source.voice.rate===void 0?"":String(p.source.voice.rate)),error:ne?a.rateInvalid(ie.min,ie.max):void 0,disabled:R||i,onChange:oe=>{if(p.source?.type!=="tts")return;let be=oe.target.value,Ye=be.normalize("NFKC").trim(),Ae=Number(Ye),Ze=/^\d+(?:\.\d+)?$/.test(Ye)&&Number.isFinite(Ae)&&Ae>=ie.min&&Ae<=ie.max,We={...p.source.voice};Ye?Ze&&(We.rate=Ae):delete We.rate,fe({...p,rateInput:be,source:{type:"tts",voice:We}})}}),W?.length?(0,ot.jsxs)(sr,{label:a.style,value:p.source.voice.style??"",disabled:R||i,onChange:oe=>{if(p.source?.type!=="tts")return;let be={...p.source.voice};oe.target.value?be.style=oe.target.value:delete be.style,fe({...p,source:{type:"tts",voice:be}})},children:[(0,ot.jsx)("option",{value:"",children:a.styleDefault}),W.map(oe=>(0,ot.jsx)("option",{value:oe,children:oe},oe))]}):null,p.rateInput!==void 0&&!ie&&(0,ot.jsxs)(ke,{tone:"warn",children:[s.draftChanged," ",(0,ot.jsx)(he,{small:!0,onClick:()=>fe({...p,rateInput:void 0}),children:a.recheck})]}),(0,ot.jsxs)("div",{className:"pmw-voice__actions",children:[(0,ot.jsx)(he,{small:!0,icon:"audio",disabled:R||i||!p.source.voice.voice||ne,onClick:()=>void ve("sample"),children:a.standard}),(0,ot.jsx)(he,{small:!0,icon:"audio",disabled:R||i||!p.source.voice.voice||ne,onClick:()=>void ve("step"),children:s.currentScript})]}),(0,ot.jsx)("p",{className:"pmw-pane__footer",children:a.previewHint})]}),p.scope.kind!=="step"&&!(p.scope.kind==="steps"&&p.source===null)&&(0,ot.jsx)(Ut,{label:a.replace,group:!0,children:(0,ot.jsx)(Wc,{label:a.replace,value:p.replaceOverrides?"replace":"preserve",disabled:R||i,options:[{value:"preserve",label:a.preserve},{value:"replace",label:a.replaceAll}],onChange:oe=>fe({...p,replaceOverrides:oe==="replace"})})})]})}),(0,ot.jsx)(kn,{open:!!$,label:$?.draft.source===null?s.restoreTitle:s.applyTitle,closeLabel:a.close,onClose:()=>j(void 0),busy:R,description:$?.draft.source===null?s.restoreHint:s.applyHint,footer:(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsx)(he,{disabled:R,onClick:()=>j(void 0),children:a.cancel}),(0,ot.jsx)(he,{loading:R,disabled:!de,variant:$?.draft.replaceOverrides&&$.impact.overrides.pages+$.impact.overrides.steps>0?"danger":"primary",onClick:()=>void xe(),children:$?.draft.replaceOverrides&&$.impact.overrides.pages+$.impact.overrides.steps>0?s.replaceCount($.impact.overrides.pages+$.impact.overrides.steps):a.apply})]}),children:$&&(0,ot.jsxs)("div",{className:"pmw-voice__form",children:[(0,ot.jsx)(Ut,{label:a.source,children:(0,ot.jsx)("span",{children:$.draft.source===null?a.inherit:$.draft.source.type==="none"?s.none:$.draft.source.type==="recording"?F.assets[$.draft.source.assetId]?.title||s.recording:`${$.draft.source.voice.voice}${$.draft.source.voice.engine?` \xB7 ${$.draft.source.voice.engine}`:""}`})}),$.draft.source?.type==="tts"&&(0,ot.jsxs)(ot.Fragment,{children:[$.draft.source.voice.rate!==void 0&&(0,ot.jsx)(Ut,{label:a.rate,children:(0,ot.jsx)("span",{children:$.draft.source.voice.rate})}),$.draft.source.voice.style&&(0,ot.jsx)(Ut,{label:a.style,children:(0,ot.jsx)("span",{children:$.draft.source.voice.style})})]}),(0,ot.jsx)(Ut,{label:a.scope,children:(0,ot.jsx)("span",{children:$.scopeLabel})}),(0,ot.jsxs)("details",{children:[(0,ot.jsx)("summary",{children:a.selected($.targets.length)}),(0,ot.jsx)("ul",{children:$.targets.map(oe=>(0,ot.jsx)("li",{children:oe},oe))})]}),(0,ot.jsx)("p",{children:s.counts($.impact.updated,$.impact.preserved,$.impact.unchanged)}),(0,ot.jsx)("p",{children:s.overridden($.impact.overrides.none,$.impact.overrides.recording)}),$.draft.replaceOverrides&&(0,ot.jsxs)(ke,{tone:"warn",children:[a.replaceAll," ",s.keepAssets]}),!de&&(0,ot.jsx)(ke,{tone:"warn",children:s.draftChanged})]})}),V&&Z&&(0,ot.jsx)(I3e,{directory:u,engine:Z,lang:K,onClose:()=>ee(!1),onUse:oe=>{ee(!1),A(be=>be+1),fe({...p,source:{type:"tts",voice:{engine:Z.id,voice:oe}},rateInput:void 0})}}),J&&(0,ot.jsx)(R3e,{quote:J.quote,snapshot:J.snapshot,onClose:()=>te(void 0),onRecheck:()=>{let oe=J.quote.mode;te(void 0),ve(oe)}})]})}var Mu=require("react/jsx-runtime");function O3e({stepId:e,disabled:t=!1,onGenerate:n}){let r=tt(),o=me(h=>h.authoring),i=me(h=>h.locale),a=me(h=>!!(h.authoring?.loading||h.authoring?.composing)||Wt(h)),[s,l]=(0,fD.useState)(!1);(0,fD.useEffect)(()=>{l(!1)},[o?.identity,e]);let c=o?.content,d=c?.steps[e],u=Gi[i];if(!c||!d||!o?.identity)return null;let f=od(c,e),p=f.value?.type==="recording"?c.assets[f.value.assetId]:void 0,m=f.value?.type==="tts"?f.value.voice.voice:f.value?.type==="none"?u.none:f.value?.type==="recording"?p?.title||u.recording:u.unset;return(0,Mu.jsxs)(Mu.Fragment,{children:[(0,Mu.jsxs)(Ut,{group:!0,label:u.voice,hint:u.inherited[f.inheritedFrom],children:[(0,Mu.jsx)("span",{children:m}),(0,Mu.jsxs)("div",{className:"pmw-voice__actions",children:[(0,Mu.jsx)(he,{small:!0,icon:"audio",disabled:t||a,onClick:()=>{r.pauseDocumentStep(d.sectionId,e),r.stopAuditions(),l(!0)},children:u.choose}),n&&(0,Mu.jsx)(he,{small:!0,icon:"refresh",disabled:t||a,onClick:n,children:u.generate}),r.client.openSpeechSettings&&(0,Mu.jsx)(he,{small:!0,variant:"ghost",icon:"sliders",onClick:()=>{r.stopAuditions(),r.pausePlayback(!0).catch(()=>{}),r.client.openSpeechSettings?.()},children:u.serviceSettings})]})]}),s&&(0,Mu.jsx)(D3e,{stepId:e,onClose:()=>l(!1)},`${o.identity}:${e}`)]})}var zr=require("react");var Ir=require("react/jsx-runtime"),rdt=[],w2=e=>["queued","running","cancelling"].includes(e.state),pD=(e,t)=>e.documentId===t.documentId&&e.version===t.version&&e.fingerprint===t.fingerprint,N3e=e=>e.map(t=>`${t.id}:${t.sequence}`).join(",");function odt(e,t){if(e.kind==="document")return!0;if(t.kind==="document")return!1;if(t.kind==="page")return e.kind==="page"&&e.section===t.section;let n=t.kind==="step"?[t.target]:t.targets;if(e.kind==="page")return n.every(o=>o.section===e.section);let r=e.kind==="step"?[e.target]:e.targets;return n.every(o=>r.some(i=>i.section===o.section&&i.step===o.step&&i.binding===o.binding))}function F3e({stepId:e,onClose:t}){let n=tt(),r=me(W=>W.locale),o=oh[r],i=me(W=>W.authoring),a=me(W=>W.voiceServiceVersion),s=me(W=>W.voiceoverJobs)??rdt,l=me(W=>W.voiceoverJobsFailure),c=me(W=>!!(W.authoring?.loading||W.authoring?.composing)||Wt(W)),[d,u]=(0,zr.useState)({kind:"step",stepId:e}),[f,p]=(0,zr.useState)(),[m,h]=(0,zr.useState)(),[g,v]=(0,zr.useState)(!0),[b,y]=(0,zr.useState)(!1),[w,_]=(0,zr.useState)(),[x,k]=(0,zr.useState)(!1),[S,E]=(0,zr.useState)(),[P,T]=(0,zr.useState)(0),I=(0,zr.useRef)(),C=(0,zr.useRef)(),A=(0,zr.useRef)(),R=(0,zr.useRef)(0),O=(0,zr.useRef)(!1),L=(0,zr.useRef)(),D=(0,zr.useRef)(""),$=(0,zr.useRef)(new Map),j=(0,zr.useRef)(!1),J=(0,zr.useRef)(n.getState().document),te=()=>{for(let[W,{directory:le}]of $.current){let ae=n.getState().voiceoverJobs?.find(ne=>ne.id===W);(!ae||w2(ae))&&n.client.cancelVoiceover(le,W,AbortSignal.timeout(5e3)).catch(()=>{})}$.current.clear()};(0,zr.useEffect)(()=>(I.current=new AbortController,j.current=!1,J.current=n.getState().document,u({kind:"step",stepId:e}),()=>{j.current=!0,R.current++,I.current?.abort(),C.current?.abort(),A.current?.abort(),te()}),[n,e,i?.identity]),(0,zr.useEffect)(()=>n.observeVoiceoverJobs(),[n,i?.identity]),(0,zr.useEffect)(()=>{let W=new AbortController,le=++R.current;C.current?.abort(),C.current=W;let ae=AbortSignal.any([W.signal,I.current.signal]);return L.current=void 0,p(void 0),h(void 0),v(!0),E(void 0),(async()=>{try{n.stopAuditions();let ne=await y2(n,e,ae),re=n.getDocument(ne.identity);if(!re)throw new Error("voice-context-changed");let ye=await n.client.readVoiceover(ne.directory,ae);if(ae.throwIfAborted(),R.current!==le||j.current)return;if(!Sa(n,ne)||ye.revision!==ne.revision||!pD(ye.source,ne.source))throw new Error("voice-context-changed");let fe={snapshot:ne,document:re};L.current=fe,D.current=N3e(ye.jobs),p(fe),h(ye),k(!1)}catch(ne){R.current===le&&!ae.aborted&&!j.current&&E(Ki(ne,r))}finally{R.current===le&&!ae.aborted&&!j.current&&v(!1)}})(),()=>W.abort()},[n,e,P,i?.identity,a]),(0,zr.useEffect)(()=>n.subscribe(()=>{let W=L.current;!W||Sa(n,W.snapshot)||(A.current?.abort(),O.current=!1,y(!1),k(!0))}),[n]);let V=s.some(w2);(0,zr.useEffect)(()=>{let W=L.current,le=N3e(s);if(!W||!Sa(n,W.snapshot)||le===D.current)return;let ae=new AbortController,ne=AbortSignal.any([ae.signal,I.current.signal]);return(async()=>{try{let re=await n.client.readVoiceover(W.snapshot.directory,ne);if(ne.throwIfAborted(),j.current||L.current!==W)return;Sa(n,W.snapshot)&&re.revision===W.snapshot.revision&&pD(re.source,W.snapshot.source)?(D.current=le,h(re)):k(!0)}catch(re){!ne.aborted&&!j.current&&E(Ki(re,r))}})(),()=>ae.abort()},[n,s,f]);let ee=(0,zr.useMemo)(()=>{if(!(!f||!m))try{let W=dg(f.document,d),le=new Set(W),ae=m.steps.filter(Ae=>{let Ze=f.snapshot.ir.sections.find(We=>We.id===Ae.target.section);return Ze?.stepIds?.[Ae.target.step]!==void 0&&le.has(Ze.stepIds[Ae.target.step])}),ne=new Set(W.map(Ae=>f.document.steps[Ae].sectionId)),re=d.kind==="page"||d.kind==="document"?(m.unboundByPage??[]).filter(Ae=>ne.has(Ae.section)):[],ye=[...ae,...re],fe=ye.reduce((Ae,Ze)=>Ae+Ze.cached,0),we=ye.filter(Ae=>Ae.state==="missing").reduce((Ae,Ze)=>Ae+Ze.utterances-Ze.cached,0),Pe=ye.filter(Ae=>Ae.state==="blocked").reduce((Ae,Ze)=>Ae+Ze.utterances-Ze.cached,0),xe=m.capability.providers.filter(Ae=>W.some(Ze=>{let We=od(f.document,Ze).value;return We?.type==="tts"&&Ae.id===Cj(We.voice.engine??m.capability.defaultEngine??"")})),ve=W.flatMap(Ae=>f.document.steps[Ae].narrationIds.map(Ze=>f.document.narrations[Ze].content.map(We=>We.type==="text"?We.text:We.type==="pronunciation"?We.spoken:"").join(""))).join(`
|
|
1359
|
+
`),x=k=>{let S=h.stepOrder[v+k];S&&(s(),l.selectDocumentStep(t,S))};return(0,Ec.jsxs)("section",{className:"pm-ui-block-preview__narration","aria-label":w,"data-step-narration":n,children:[(0,Ec.jsxs)("header",{className:"pm-ui-block-preview__narration-header",children:[(0,Ec.jsx)("span",{className:"pm-ui-block-preview__step-label",children:y}),(0,Ec.jsxs)("span",{className:"pm-ui-block-preview__actions",children:[(0,Ec.jsx)(Et,{small:!0,icon:"chevron-left",label:u.previousStep,disabled:v<=0,onClick:()=>x(-1)}),(0,Ec.jsx)(Et,{small:!0,icon:"chevron-right",label:u.nextStep,disabled:v>=h.stepOrder.length-1,onClick:()=>x(1)})]})]}),!r&&_&&(0,Ec.jsx)("p",{className:"pm-ui-block-preview__caption","data-step-caption":n,children:_}),r&&(0,Ec.jsxs)("div",{id:a,className:"pm-ui-block-preview__narration-fields",children:[i&&(0,Ec.jsx)("span",{className:"pm-ui-block-preview__step-label",children:w}),(0,Ec.jsx)(Kct,{identity:c.identity,reset:c.reset,blockId:e,stepId:n,content:b.map(k=>({id:k,content:m.narrations[k].content})),readOnly:f,advanced:o,onPause:s},`narration:${c.identity}:${c.reset}:${n}`),(0,Ec.jsx)(Nj,{document:m,stepId:n,locale:d,readOnly:f,advanced:o,onPause:s,onInteraction:()=>l.documentInteraction(),onChange:k=>l.setDocumentStepProduction(n,k,c.identity),drafts:{minimumHoldMs:l.documentTimingDraft(n,"minimumHoldMs",c.identity,c.reset),trailingPauseMs:l.documentTimingDraft(n,"trailingPauseMs",c.identity,c.reset)},draftStorageFailure:p,onDraft:(k,S)=>l.setDocumentTimingDraft(n,k,S,c.identity,c.reset),onComposition:(k,S)=>l.documentComposition(S,`production:${c.identity}:${c.reset}:${e}:${n}:${k}`,c.identity)},`timing:${c.identity}:${c.reset}:${n}`)]})]})}var Jct={serviceSettings:"\u8BED\u97F3\u670D\u52A1\u8BBE\u7F6E",playOnDemand:"\u64AD\u653E\u65F6\u6309\u9700\u751F\u6210\u914D\u97F3\u5E76\u7F13\u5B58\uFF1B\u7F3A\u5931\u8BB2\u7A3F\u4F1A\u53D1\u9001\u5230\u6240\u9009\u8BED\u97F3\u670D\u52A1\u3002",generatingPlayback:"\u6B63\u5728\u751F\u6210\u5F53\u524D\u914D\u97F3\uFF0C\u5B8C\u6210\u540E\u81EA\u52A8\u64AD\u653E\u3002\u53EF\u6682\u505C\u53D6\u6D88\u3002",generatingProgress:(e,t)=>`\u6B63\u5728\u751F\u6210\u914D\u97F3 ${e} / ${t}\uFF0C\u5B8C\u6210\u540E\u81EA\u52A8\u64AD\u653E\u3002`,library:"\u9875\u9762\u4E0E\u7D20\u6750",pages:"\u9875\u9762",media:"\u97F3\u9891\u7D20\u6750",properties:"\u6B65\u9AA4\u5C5E\u6027",narration:"\u8BB2\u7A3F",voiceTab:"\u914D\u97F3",captionsTab:"\u5B57\u5E55",searchPages:"\u641C\u7D22\u9875\u9762",pageResults:e=>`${e} \u9875`,pageSteps:e=>`${e} \u4E2A\u6B65\u9AA4`,noPages:"\u6CA1\u6709\u5339\u914D\u7684\u9875\u9762",resizeLibrary:"\u8C03\u6574\u9875\u9762\u5217\u8868\u4E0E\u753B\u9762\u5BBD\u5EA6",issueCount:e=>`${e} \u9879\u95EE\u9898`,resizeProperties:"\u8C03\u6574\u753B\u9762\u4E0E\u8BB2\u7A3F\u5BBD\u5EA6",resizeTimeline:"\u8C03\u6574\u753B\u9762\u4E0E\u65F6\u95F4\u7EBF\u9AD8\u5EA6",title:"\u89C6\u9891\u5236\u4F5C",back:"\u8FD4\u56DE\u6587\u7A3F",preview:"\u753B\u9762",script:"\u8BB2\u7A3F\u4E0E\u914D\u97F3",outputs:"\u5BFC\u51FA",step:"\u5F53\u524D\u6B65\u9AA4",page:"\u9875\u9762",prepare:"\u51C6\u5907\u753B\u9762",preparing:"\u6B63\u5728\u51C6\u5907\u753B\u9762\u2026",current:"\u5F53\u524D\u4FDD\u5B58\u7248\u672C",outdated:"\u9700\u8981\u66F4\u65B0",unavailable:"\u753B\u9762\u5C1A\u672A\u51C6\u5907",previewHint:"\u7528\u5F53\u524D\u4FDD\u5B58\u7248\u672C\u51C6\u5907\u753B\u9762\u540E\u5373\u53EF\u67E5\u770B\u3002\u8BB2\u7A3F\u548C\u97F3\u8272\u53EF\u5355\u72EC\u7F16\u8F91\u3002",voice:"\u97F3\u8272\u4E0E\u914D\u97F3",choose:"\u9009\u62E9\u97F3\u8272",generate:"\u751F\u6210\u914D\u97F3",none:"\u9759\u97F3",unset:"\u672A\u8BBE\u7F6E\u97F3\u8272",recording:"\u5F55\u97F3\u6765\u6E90",inherited:{step:"\u672C\u6B65\u8BBE\u7F6E",page:"\u7EE7\u627F\u672C\u9875",document:"\u7EE7\u627F\u6587\u7A3F\u9ED8\u8BA4",unset:"\u672A\u8BBE\u7F6E"},scopeShort:{step:"\u672C\u6B65",steps:"\u591A\u6B65",page:"\u672C\u9875",document:"\u6587\u7A3F"},counts:(e,t,n)=>`\u66F4\u65B0 ${e} \u4E2A\u6B65\u9AA4\uFF0C${t} \u4E2A\u6B65\u9AA4\u4FDD\u7559\u8986\u76D6\uFF0C${n} \u4E2A\u6B65\u9AA4\u4E0D\u53D8\u3002`,overridden:(e,t)=>`\u8303\u56F4\u5185\u6709 ${e} \u9879\u9759\u97F3\u3001${t} \u9879\u5F55\u97F3\u72EC\u7ACB\u8BBE\u7F6E\u3002`,replaceCount:e=>`\u786E\u8BA4\u66FF\u6362 ${e} \u5904\u8986\u76D6`,keepAssets:"\u5F55\u97F3\u548C\u5176\u4ED6\u7D20\u6750\u4ECD\u4FDD\u7559\uFF0C\u4E0D\u4F1A\u6539\u5199\u8BB2\u7A3F\u6216\u751F\u6210\u914D\u97F3\u3002",mute:"\u8BBE\u7F6E\u4E3A\u9759\u97F3",restore:"\u4F7F\u7528\u7EE7\u627F\u8BBE\u7F6E",selectSteps:"\u8BF7\u81F3\u5C11\u9009\u62E9\u4E00\u4E2A\u6B65\u9AA4\u3002",draftChanged:"\u6587\u7A3F\u5DF2\u66F4\u65B0\u3002\u8BBE\u7F6E\u8349\u7A3F\u5DF2\u4FDD\u7559\uFF0C\u8BF7\u91CD\u65B0\u68C0\u67E5\u8303\u56F4\u540E\u5E94\u7528\u3002",applyTitle:"\u786E\u8BA4\u97F3\u8272\u5E94\u7528\u8303\u56F4",restoreTitle:"\u786E\u8BA4\u4F7F\u7528\u7EE7\u627F\u8BBE\u7F6E",applyHint:"\u53EA\u4FEE\u6539\u6240\u9009\u8303\u56F4\u7684\u97F3\u8272\u6765\u6E90\uFF0C\u6B63\u6587\u3001\u8BB2\u7A3F\u548C\u64AD\u653E\u65F6\u673A\u4FDD\u7559\u3002",restoreHint:"\u6240\u9009\u5C42\u7EA7\u6539\u7528\u4E0A\u4E00\u7EA7\u7684\u8BBE\u7F6E\uFF0C\u4FDD\u7559\u7684\u4E0B\u7EA7\u8986\u76D6\u4E0D\u53D8\u3002\u6E05\u9664\u6587\u7A3F\u9ED8\u8BA4\u540E\u5C06\u6CA1\u6709\u9ED8\u8BA4\u97F3\u8272\u3002",catalogFailed:"\u65E0\u6CD5\u52A0\u8F7D\u97F3\u8272\u5217\u8868\uFF0C\u8BF7\u91CD\u8BD5\u3002",cached:"\u5F53\u524D\u8BB2\u7A3F\u53EF\u4F7F\u7528\u5DF2\u6709\u914D\u97F3\u7F13\u5B58\u3002",sourceReady:"\u53EA\u6709\u786E\u8BA4\u4FDD\u5B58\u7248\u672C\u4E0E\u6B65\u9AA4\u540E\u624D\u80FD\u8BD5\u542C\u6216\u751F\u6210\u3002",currentScript:"\u8BD5\u542C\u672C\u6B65\u8BB2\u7A3F",selectedVoice:"\u6240\u9009\u97F3\u8272",unknownSource:"\u672A\u8FDE\u63A5\u7684\u670D\u52A1",playbackHint:"\u5F53\u524D\u6309\u6B65\u9AA4\u7F16\u8F91\uFF1B\u64AD\u653E\u65F6\u957F\u4E0E\u5B57\u5E55\u65F6\u95F4\u7531\u5B9E\u9645\u8BB2\u6388\u7684\u65F6\u95F4\u7EBF\u5F97\u51FA\u3002",timeline:"\u65F6\u95F4\u7EBF",play:"\u64AD\u653E",pause:"\u6682\u505C",rate:"\u64AD\u653E\u901F\u5EA6",planLoading:"\u6B63\u5728\u52A0\u8F7D\u65F6\u95F4\u7EBF\u2026",enable:"\u542F\u7528\u89C6\u9891\u5236\u4F5C",enableHint:"\u6B64\u6587\u7A3F\u5C1A\u672A\u542F\u7528\u89C6\u9891\u5236\u4F5C\u3002\u542F\u7528\u540E\u53EF\u4F7F\u7528\u65F6\u95F4\u7EBF\u5E76\u5BFC\u51FA\u8BB2\u6388\uFF0C\u6B63\u6587\u548C\u8BB2\u7A3F\u4FDD\u7559\uFF1B\u9009\u62E9\u97F3\u8272\u540E\uFF0C\u64AD\u653E\u65F6\u4F1A\u6309\u9700\u751F\u6210\u914D\u97F3\u3002",planOutdated:"\u6587\u7A3F\u5DF2\u66F4\u65B0\uFF0C\u6B63\u5728\u51C6\u5907\u5BF9\u5E94\u7684\u65F6\u95F4\u7EBF\u3002",planRetry:"\u91CD\u65B0\u52A0\u8F7D\u65F6\u95F4\u7EBF",playbackWaiting:"\u51C6\u5907\u5F53\u524D\u753B\u9762\u540E\u53EF\u64AD\u653E\u6216\u5B9A\u4F4D\u5230\u65F6\u95F4\u3002",playbackLoading:"\u6B63\u5728\u51C6\u5907\u64AD\u653E\u2026",playbackFailed:"\u65E0\u6CD5\u5B8C\u6210\u64AD\u653E\u6216\u5B9A\u4F4D\uFF0C\u8BF7\u91CD\u8BD5\u3002",planFailed:"\u5F53\u524D\u7F16\u6392\u65E0\u6CD5\u51C6\u5907\uFF0C\u8BF7\u68C0\u67E5\u6B65\u9AA4\u3001\u914D\u97F3\u548C\u52A8\u753B\u65F6\u957F\u3002",estimatedPlan:"\u672A\u751F\u6210\u90E8\u5206\u663E\u793A\u4F30\u8BA1\u65F6\u957F\u3002\u64AD\u653E\u65F6\u81EA\u52A8\u751F\u6210\u5E76\u7F13\u5B58\uFF0C\u751F\u6210\u540E\u66F4\u65B0\u7CBE\u786E\u65F6\u95F4\u3002",unknownPlan:"\u5F53\u524D\u7F16\u6392\u4ECD\u6709\u672A\u786E\u8BA4\u7684\u65F6\u5E8F\u3002\u8BF7\u67E5\u770B\u539F\u56E0\uFF0C\u4FEE\u6B63\u540E\u518D\u6309\u65F6\u95F4\u64AD\u653E\u6216\u5BFC\u51FA\u3002",issues:e=>`\u67E5\u770B ${e} \u9879\u7F16\u6392\u95EE\u9898`,diagnosticFallback:"\u5F53\u524D\u7F16\u6392\u5305\u542B\u672A\u652F\u6301\u6216\u65E0\u6548\u7684\u7ED1\u5B9A\uFF0C\u8BF7\u68C0\u67E5\u5173\u8054\u5185\u5BB9\u3002",diagnostics:{"production.animation-duration-unknown":"\u52A8\u753B\u672A\u58F0\u660E\u6709\u6548\u65F6\u957F\uFF0C\u6682\u4E0D\u80FD\u6309\u65F6\u95F4\u64AD\u653E\u6216\u5BFC\u51FA\u3002","production.recording-cue-unsupported":"\u539F\u97F3\u9891\u6CA1\u6709\u63D0\u793A\u7684\u786E\u8BA4\u65F6\u7801\uFF0C\u8BF7\u79FB\u9664\u8DE8\u6B65\u6216\u5185\u90E8\u6682\u505C\uFF0C\u5E76\u5C06\u63D0\u793A\u653E\u5230\u672C\u6B65\u8D77\u70B9\u3002","production.recording-start-conflict":"\u540C\u4E00\u6B65\u8BB2\u7A3F\u7684\u64AD\u653E\u8D77\u70B9\u4E0D\u4E00\u81F4\uFF0C\u8BF7\u5148\u7EDF\u4E00\u540E\u91C7\u7528\u539F\u97F3\u9891\u3002","production.recording-captions-unverified":"\u5F55\u97F3\u5DF2\u88C1\u526A\uFF0C\u5B57\u5E55\u4ECD\u4E3A\u672C\u6B65\u5B8C\u6574\u8BB2\u7A3F\uFF0C\u5C1A\u672A\u6309\u539F\u97F3\u5BF9\u9F50\uFF0C\u8BF7\u6838\u5BF9\u3002","production.recording-fingerprint-required":"\u8BF7\u91CD\u65B0\u91C7\u7528\u539F\u97F3\u9891\u4EE5\u786E\u8BA4\u5B9E\u9645\u6587\u4EF6\u3002","production.recording-unsupported":"\u5F55\u97F3\u6765\u6E90\u5DF2\u4FDD\u7559\uFF0C\u4F46\u6682\u65F6\u4E0D\u80FD\u7528\u4E8E\u8FD9\u4EFD\u8BB2\u7A3F\u7684\u64AD\u653E\u3002","production.media-unsupported":"\u5A92\u4F53\u7247\u6BB5\u5DF2\u4FDD\u7559\uFF0C\u6682\u4E0D\u652F\u6301\u88C1\u526A\u548C\u6DF7\u97F3\u3002","production.silent-cue-unknown":"\u9759\u97F3\u8BB2\u7A3F\u4E2D\u7684\u6587\u5B57\u63D0\u793A\u6CA1\u6709\u786E\u8BA4\u65F6\u7801\uFF1B\u8BF7\u653E\u5230\u6B65\u9AA4\u8D77\u70B9\u6216\u63D0\u4F9B\u97F3\u9891\u3002","production.next-pause-unsupported":"\u8DE8\u6B65\u9AA4\u7684\u540C\u4E00\u6BB5\u914D\u97F3\u5C1A\u4E0D\u80FD\u63D2\u5165\u6B65\u9AA4\u505C\u987F\uFF0C\u8BF7\u5148\u62C6\u6210\u6309\u6B65\u9AA4\u7ED1\u5B9A\u7684\u8BB2\u7A3F\u3002","production.cache-missing":"\u5F53\u524D\u914D\u97F3\u5C1A\u672A\u7F13\u5B58\uFF0C\u70B9\u51FB\u64AD\u653E\u540E\u81EA\u52A8\u751F\u6210\u3002","production.voice-unset":"\u6B64\u8BB2\u7A3F\u5C1A\u672A\u9009\u62E9\u53D1\u58F0\u65B9\u5F0F\uFF0C\u8BF7\u9009\u62E9\u9759\u97F3\u6216\u5B9E\u9645\u97F3\u8272\u3002","production.cue-invalid":"\u8BB2\u7A3F\u63D0\u793A\u7684\u76EE\u6807\u6216\u52A8\u4F5C\u65E0\u6548\uFF0C\u8BF7\u68C0\u67E5\u5BF9\u5E94\u7684\u8BB2\u7A3F\u548C\u5185\u5BB9\u3002"},timingDraft:"\u8BF7\u5148\u786E\u8BA4\u6216\u4FEE\u6B63\u5C1A\u672A\u4FDD\u5B58\u7684\u64AD\u653E\u65F6\u673A\u3002",captionDraft:"\u672A\u5E94\u7528\u5B57\u5E55\u65F6\u95F4",captionStorageFailed:"\u65E0\u6CD5\u5907\u4EFD\u5B57\u5E55\u65F6\u95F4\uFF0C\u8BF7\u4FDD\u6301\u6B64\u9875\u9762\u6253\u5F00\u3002",tracks:{visual:"\u753B\u9762",voice:"\u914D\u97F3",caption:"\u5B57\u5E55"},captionSegment:"\u5B57\u5E55\u7247\u6BB5",chooseCaptionSegment:"\u9009\u62E9\u5B57\u5E55\u7247\u6BB5",alignmentStatus:{manual:"\u624B\u52A8\u65F6\u95F4",words:"\u8BCD\u65F6\u7801",proportional:"\u6BD4\u4F8B\u4F30\u65F6",none:"\u672A\u5BF9\u9F50"},segmentStatus:{recorded:"\u539F\u97F3\u9891",cached:"\u5DF2\u6709\u914D\u97F3",silent:"\u9759\u97F3",missing:"\u914D\u97F3\u5F85\u751F\u6210",blocked:"\u6682\u4E0D\u53EF\u7528"},waveformLoading:"\u6B63\u5728\u52A0\u8F7D\u6CE2\u5F62\u2026",waveformUnavailable:"\u6CE2\u5F62\u4E0D\u53EF\u7528",stepNumber:e=>`\u6B65\u9AA4 ${e+1}`,notInLecture:"\u4E0D\u5728\u8BB2\u6388\u4E2D",notInLectureHint:"\u8FD9\u4E00\u9875\u7684\u5185\u5BB9\u90FD\u9650\u5B9A\u5728\u5176\u4ED6\u5F62\u6001\uFF0C\u53C8\u6CA1\u6709\u8BB2\u7A3F\u4E0E\u97F3\u9891\uFF0C\u8BB2\u6388\u89C6\u9891\u4E2D\u6CA1\u6709\u8FD9\u4E00\u9875\u3002",notInLectureStep:"\u8FD9\u4E00\u6B65\u4E0D\u5728\u8BB2\u6388\u4E2D\uFF1A\u5B83\u7684\u5185\u5BB9\u90FD\u9650\u5B9A\u5728\u5176\u4ED6\u5F62\u6001\uFF0C\u53C8\u6CA1\u6709\u8BB2\u7A3F\u4E0E\u97F3\u9891\u3002",captionSize:"\u5B57\u5E55\u5927\u5C0F",captionSizeHint:"\u6574\u4E2A\u6587\u7A3F\u7684\u5B57\u5E55\uFF1A\u653E\u6620\u4E2D\u663E\u793A\u7684\u4E0E\u5BFC\u51FA\u89C6\u9891\u4E2D\u70E7\u5F55\u7684\u90FD\u6309\u8FD9\u4E2A\u5927\u5C0F\u3002",timelineLabels:{position:"\u4F4D\u7F6E",seconds:"\u79D2",seek:"\u64AD\u653E\u5934\u4F4D\u7F6E",zoomIn:"\u653E\u5927\u65F6\u95F4\u7EBF",zoomOut:"\u7F29\u5C0F\u65F6\u95F4\u7EBF",fit:"\u9002\u914D\u672C\u9875",estimated:"\u4F30\u8BA1\u65F6\u957F",unknown:"\u65F6\u957F\u672A\u77E5",loading:"\u6B63\u5728\u52A0\u8F7D\u65F6\u95F4\u7EBF\u2026",empty:"\u5F53\u524D\u9875\u6682\u65E0\u65F6\u95F4\u7EBF\u7247\u6BB5",seekHint:"\u9009\u62E9\u6B65\u9AA4\uFF0C\u6216\u7528\u65F6\u95F4\u5C3A\u3001\u65B9\u5411\u952E\u548C\u7CBE\u786E\u65F6\u95F4\u5B9A\u4F4D\uFF1B\u5B9A\u4F4D\u4F1A\u5148\u6682\u505C\u64AD\u653E\u3002",invalidPosition:"\u8BF7\u8F93\u5165\u672C\u9875\u65F6\u957F\u8303\u56F4\u5185\u7684\u79D2\u6570\u3002"},failures:{"production-source-changed":"\u6587\u7A3F\u5DF2\u66F4\u65B0\uFF0C\u65E7\u64AD\u653E\u8BF7\u6C42\u5DF2\u505C\u6B62\u3002\u8BF7\u91CD\u65B0\u51C6\u5907\u5F53\u524D\u7248\u672C\u3002","production-binding-stale":"\u65F6\u95F4\u7EBF\u5DF2\u66F4\u65B0\uFF0C\u8BF7\u91CD\u65B0\u52A0\u8F7D\u540E\u518D\u64AD\u653E\u3002","production-plan-changed":"\u97F3\u9891\u6216\u65F6\u95F4\u7EBF\u5DF2\u66F4\u65B0\uFF0C\u8BF7\u91CD\u65B0\u52A0\u8F7D\u540E\u518D\u64AD\u653E\u3002","production-plan-unavailable":"\u5F53\u524D\u65F6\u95F4\u7EBF\u5C1A\u4E0D\u80FD\u64AD\u653E\uFF0C\u8BF7\u68C0\u67E5\u7F3A\u5931\u7684\u914D\u97F3\u3001\u52A8\u753B\u65F6\u957F\u6216\u4E0D\u652F\u6301\u7684\u5A92\u4F53\u8BBE\u7F6E\u3002","production-playback-unavailable":"\u753B\u9762\u5C1A\u672A\u8FDE\u63A5\u64AD\u653E\u63A7\u5236\uFF0C\u8BF7\u66F4\u65B0\u753B\u9762\u540E\u91CD\u8BD5\u3002","production-playback-timeout":"\u65E0\u6CD5\u786E\u8BA4\u64AD\u653E\u6216\u5B9A\u4F4D\uFF0C\u8BF7\u91CD\u8BD5\u3002","production-playback-time":"\u6240\u9009\u65F6\u95F4\u8D85\u51FA\u5F53\u524D\u65F6\u95F4\u7EBF\uFF0C\u8BF7\u91CD\u65B0\u5B9A\u4F4D\u3002","production-playback-rate":"\u5F53\u524D\u64AD\u653E\u901F\u5EA6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u3002","production-playback-failed":"\u65E0\u6CD5\u64AD\u653E\u5F53\u524D\u5A92\u4F53\uFF0C\u8BF7\u68C0\u67E5\u97F3\u9891\u80FD\u5426\u8BFB\u53D6\u3002","production-playback-cancelled":"\u64AD\u653E\u8BF7\u6C42\u5DF2\u53D6\u6D88\u3002"}},Gi={"zh-CN":Jct,en:{serviceSettings:"Voice Service Settings",playOnDemand:"Play generates and caches missing voiceover using the selected speech service.",generatingPlayback:"Generating the current voiceover. Playback continues when ready; pause to cancel.",generatingProgress:(e,t)=>`Generating voiceover ${e} / ${t}. Playback continues when ready.`,library:"Pages and Assets",pages:"Pages",media:"Audio Assets",properties:"Step Properties",narration:"Script",voiceTab:"Voiceover",captionsTab:"Captions",searchPages:"Search Pages",pageResults:e=>`${e} ${e===1?"page":"pages"}`,pageSteps:e=>`${e} ${e===1?"step":"steps"}`,noPages:"No matching pages",resizeLibrary:"Resize page list and visuals",issueCount:e=>`${e} ${e===1?"Issue":"Issues"}`,resizeProperties:"Resize visuals and script",resizeTimeline:"Resize visuals and timeline",title:"Video Production",back:"Back to Document",preview:"Visuals",script:"Script and Voiceover",outputs:"Export",step:"Current step",page:"Page",prepare:"Prepare Visuals",preparing:"Preparing visuals\u2026",current:"Current saved version",outdated:"Update needed",unavailable:"Visuals are not prepared",previewHint:"Prepare the saved version to see the visuals. Scripts and voices can be edited separately.",voice:"Voice and Voiceover",choose:"Choose Voice",generate:"Generate Voiceover",none:"Silent",unset:"No voice set",recording:"Recording source",inherited:{step:"This step",page:"Inherited from page",document:"Inherited from document",unset:"Not set"},scopeShort:{step:"Step",steps:"Selected",page:"Page",document:"Document"},counts:(e,t,n)=>`${e} steps update, ${t} keep overrides, ${n} stay unchanged.`,overridden:(e,t)=>`This scope contains ${e} silent and ${t} recording overrides.`,replaceCount:e=>`Replace ${e} ${e===1?"Override":"Overrides"}`,keepAssets:"Recordings and other assets are kept. Scripts stay unchanged; no voiceover is generated.",mute:"Set to Silent",restore:"Use Inherited Setting",selectSteps:"Select at least one step.",draftChanged:"The document changed. Your settings draft is kept; check the scope again before applying.",applyTitle:"Confirm Voice Scope",restoreTitle:"Use Inherited Setting",applyHint:"Only the voice source changes. Content, scripts, and timing are kept.",restoreHint:"The selected level uses its parent\u2019s setting; overrides kept below it stay. Clearing the document default leaves no default voice.",catalogFailed:"Couldn\u2019t load the list of voices. Try again.",cached:"The current script can use existing cached voiceover.",sourceReady:"Confirm the saved version and step before listening or generating voiceover.",currentScript:"Play This Step\u2019s Script",selectedVoice:"Selected voice",unknownSource:"Disconnected service",playbackHint:"Editing is organized by steps. Durations and caption times come from the lecture\u2019s actual timeline.",timeline:"Timeline",play:"Play",pause:"Pause",rate:"Playback speed",planLoading:"Loading the timeline\u2026",enable:"Turn On Video Production",enableHint:"Video production is not turned on for this document. Turn it on to use the timeline and export the lecture; content and scripts are kept. Choose a voice, then Play generates missing voiceover.",planOutdated:"The document changed. Preparing its timeline.",planRetry:"Reload Timeline",playbackWaiting:"Prepare the current visuals to play or go to a time.",playbackLoading:"Preparing playback\u2026",playbackFailed:"Couldn\u2019t finish playing or seeking. Try again.",planFailed:"Couldn\u2019t prepare the sequence. Check the steps, voiceover, and animation durations.",estimatedPlan:"Missing clips show estimated durations. Play generates and caches voiceover, then updates exact times.",unknownPlan:"Some timing is unconfirmed. Review the issues before timed playback or export.",issues:e=>`Review ${e} Sequence ${e===1?"Issue":"Issues"}`,diagnosticFallback:"The sequence contains an unsupported or invalid link to content. Check the related content.",diagnostics:{"production.animation-duration-unknown":"The animation has no valid declared duration. Timed playback and export are unavailable.","production.recording-cue-unsupported":"The recording has no confirmed cue timing. Remove next-step cues and internal pauses, and place cues at the step start.","production.recording-start-conflict":"Scripts in this step have different starts. Use one common start before using the recording.","production.recording-captions-unverified":"The recording is trimmed. Captions still show the complete step script and are not aligned to the audio; review them.","production.recording-fingerprint-required":"Use the recording again to confirm the actual file.","production.recording-unsupported":"The recording source is kept but can\u2019t be used to play this script yet.","production.media-unsupported":"Media clips are kept. Trimming and mixing are not available yet.","production.silent-cue-unknown":"Text-anchored cues in silent scripts have no confirmed timing. Move them to the step start or provide audio.","production.next-pause-unsupported":"One voiceover clip that spans steps can\u2019t take step pauses yet. Split it into one script per step.","production.cache-missing":"This voiceover is not cached. Play generates it automatically.","production.voice-unset":"This script has no voice source. Choose silence or an actual voice.","production.cue-invalid":"A script cue has an invalid target or action. Check the script and its content."},timingDraft:"Confirm or correct the playback timing that is not saved first.",captionDraft:"Caption times not applied",captionStorageFailed:"Couldn\u2019t back up caption times. Keep this page open.",tracks:{visual:"Visuals",voice:"Voiceover",caption:"Captions"},captionSegment:"Caption segment",chooseCaptionSegment:"Choose Caption Segment",alignmentStatus:{manual:"Manual timing",words:"Word timing",proportional:"Proportional timing",none:"Unaligned"},segmentStatus:{recorded:"Original audio",cached:"Voiceover cached",silent:"Silent",missing:"Voiceover needed",blocked:"Unavailable"},waveformLoading:"Loading waveform\u2026",waveformUnavailable:"Waveform unavailable",stepNumber:e=>`Step ${e+1}`,notInLecture:"Not in the lecture",notInLectureHint:"Everything on this page is limited to other forms and it has no script or audio, so the lecture video leaves it out.",notInLectureStep:"This step is not in the lecture: everything on it is limited to other forms and it has no script or audio.",captionSize:"Caption size",captionSizeHint:"For the whole document: captions shown in the presentation and burned into an exported video use this size.",timelineLabels:{position:"Position",seconds:"seconds",seek:"Playhead position",zoomIn:"Zoom In Timeline",zoomOut:"Zoom Out Timeline",fit:"Fit Page",estimated:"Estimated duration",unknown:"Unknown duration",loading:"Loading the timeline\u2026",empty:"This page has no timeline segments",seekHint:"Select a step, or use the ruler, arrow keys, or an exact time to seek. Seeking pauses playback first.",invalidPosition:"Enter a time in seconds within this page\u2019s duration."},failures:{"production-source-changed":"The document changed and the old playback request stopped. Prepare the current version.","production-binding-stale":"The timeline changed. Reload it before playing.","production-plan-changed":"The audio or timeline changed. Reload it before playing.","production-plan-unavailable":"This timeline can\u2019t be played yet. Check for missing voiceover, animation durations, or unsupported media settings.","production-playback-unavailable":"The visuals are not connected to playback controls. Update the visuals and try again.","production-playback-timeout":"Couldn\u2019t confirm playing or seeking. Try again.","production-playback-time":"The selected time is outside the current timeline. Choose another position.","production-playback-rate":"This playback speed is unavailable. Choose another speed.","production-playback-failed":"Couldn\u2019t play the current media. Check that its audio can be read.","production-playback-cancelled":"The playback request was canceled."}}};function sD(e,t){let n=e instanceof Error?e.message:String(e),r=Gi[t];return r.failures[n]??r.playbackFailed}var fD=require("react");var Ho=require("react");var x3e=new WeakMap,lD=(e,t)=>JSON.stringify([e,t]),s6=e=>`presmium.voice-draft.v2:${e}`;function MY(e){if(!xt(e)||typeof e.version!="string"||typeof e.replaceOverrides!="boolean"||!xt(e.scope)||e.rateInput!==void 0&&typeof e.rateInput!="string")return!1;let t=e.scope;if(!(t.kind==="document"||t.kind==="page"&&typeof t.sectionId=="string"||t.kind==="step"&&typeof t.stepId=="string"||t.kind==="steps"&&Array.isArray(t.stepIds)&&t.stepIds.every(o=>typeof o=="string")))return!1;let n=e.source;if(n===null)return!0;if(!xt(n))return!1;if(n.type==="none")return!0;if(n.type==="recording")return typeof n.assetId=="string";if(n.type!=="tts"||!xt(n.voice))return!1;let r=n.voice;return typeof r.voice=="string"&&(r.engine===void 0||typeof r.engine=="string")&&(r.rate===void 0||typeof r.rate=="number"&&Number.isFinite(r.rate))&&(r.style===void 0||typeof r.style=="string")}function Yct(e){let t=x3e.get(e);return t||x3e.set(e,t=new Map),t}function cD(e,t){let n=Yct(e),r=n.get(t);if(r)return r;let o={status:"available"};n.set(t,o);try{let i=sessionStorage.getItem(s6(t));if(i!==null){o.unreadable=i;let a=JSON.parse(i);if(!MY(a))return o.status="corrupt",o;o.draft=a,delete o.unreadable}}catch{o.status=o.unreadable===void 0?"unavailable":"corrupt"}return o}function S3e(e,t,n){let r=cD(e,lD(t,n)).draft;return r&&structuredClone(r)}function _3e(e,t,n){return cD(e,lD(t,n)).status}function DY(e,t,n,r){if(!MY(r))throw new Error("voice-draft-invalid");let o=lD(t,n),i=cD(e,o);i.draft=structuredClone(r);try{return i.unreadable!==void 0&&sessionStorage.setItem(`${s6(o)}:unreadable`,i.unreadable),sessionStorage.setItem(s6(o),JSON.stringify(i.draft)),i.status="available",delete i.unreadable,!0}catch{return i.status="unavailable",!1}}function C3e(e,t,n,r){let o=lD(t,n),i=cD(e,o);if(r&&JSON.stringify(i.draft)!==JSON.stringify(r))return!1;try{let a=sessionStorage.getItem(s6(o));if(r&&a!==null){let s;try{s=JSON.parse(a)}catch{return i.status="corrupt",i.unreadable=a,!1}if(!MY(s))return i.status="corrupt",i.unreadable=a,!1;if(JSON.stringify(s)!==JSON.stringify(r))return!1}return sessionStorage.removeItem(s6(o)),delete i.draft,delete i.unreadable,i.status="available",!0}catch{return i.status="unavailable",!1}}var dD=(e,t=!0)=>`${/^[A-Za-z0-9]/.test(e)?" ":""}${e}${t&&/[A-Za-z0-9]$/.test(e)?" ":""}`,P3e=e=>`${String(Math.floor(e/6e4)).padStart(2,"0")}:${String(Math.floor(e/1e3)%60).padStart(2,"0")}`,Zct={open:"\u590D\u523B\u97F3\u8272\u2026",title:"\u590D\u523B\u97F3\u8272",cloned:"\u590D\u523B\u97F3\u8272",close:"\u5173\u95ED",cancel:"\u53D6\u6D88",description:"\u7528\u4E00\u4E2A\u4EBA\u7684\u5F55\u97F3\u8BAD\u7EC3\u51FA\u4E00\u4E2A\u5408\u6210\u97F3\u8272\u3002\u9700\u8981\u672C\u4EBA\u6388\u6743\uFF0C\u5E76\u4EB2\u53E3\u8BFB\u4E00\u904D\u6388\u6743\u58F0\u660E\u3002",voice:"\u97F3\u8272\u540D\u79F0",voiceHint:e=>e?"\u5728\u706B\u5C71\u5F15\u64CE\u63A7\u5236\u53F0\u8D2D\u4E70\u7684\u97F3\u8272\u69FD\u4F4D\uFF08\u4EE5 S_ \u5F00\u5934\uFF09\uFF0C\u6216\u8005\u7ED9\u6309\u91CF\u4ED8\u8D39\u7684\u97F3\u8272\u8D77\u4E00\u4E2A\u540D\u5B57\uFF08\u5B57\u6BCD\u5F00\u5934\uFF0C\u81F3\u5C11 8 \u4E2A\u5B57\u6BCD\u6216\u6570\u5B57\uFF09\u3002":"\u7ED9\u8FD9\u4E2A\u97F3\u8272\u8D77\u4E00\u4E2A\u540D\u5B57\uFF0C\u53EA\u7528\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u201C.\u201D\u3001\u201C-\u201D\u548C\u201C_\u201D\u3002",voiceInvalid:"\u540D\u79F0\u53EA\u80FD\u5305\u542B\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u201C.\u201D\u3001\u201C-\u201D\u548C\u201C_\u201D\uFF0C\u5E76\u4EE5\u5B57\u6BCD\u6216\u6570\u5B57\u5F00\u5934\u3002",speaker:"\u8BF4\u8BDD\u4EBA",speakerHint:"\u5F55\u97F3\u91CC\u662F\u8C01\u7684\u58F0\u97F3\u3002",scope:"\u7528\u9014",scopeHint:"\u8FD9\u4E2A\u97F3\u8272\u53EF\u4EE5\u7528\u5728\u54EA\u91CC\uFF0C\u4F1A\u5199\u8FDB\u6388\u6743\u8BB0\u5F55\u3002",defaultScope:"\u672C\u5DE5\u4F5C\u533A\u8BB2\u4E49\u7684\u914D\u97F3",statement:"\u6388\u6743\u58F0\u660E\u5F55\u97F3",statementHint:"\u8BF7\u8BF4\u8BDD\u4EBA\u672C\u4EBA\u8BFB\u51FA\u4E0A\u9762\u7684\u6388\u6743\u58F0\u660E\u3002",statementText:(e,t)=>`\u6211\u662F${dD(e,!1)}\u3002\u6211\u6388\u6743\u7528\u6211\u7684\u58F0\u97F3\u8BAD\u7EC3\u4E00\u4E2A\u5408\u6210\u97F3\u8272\uFF0C\u53EA\u7528\u4E8E${dD(t,!1)}\u3002`,someone:"\uFF08\u8BF4\u8BDD\u4EBA\u7684\u540D\u5B57\uFF09",statementLabel:"\u6388\u6743\u58F0\u660E",passageLabel:"\u53EF\u4EE5\u6717\u8BFB\u7684\u6BB5\u843D",passage:"\u4ECA\u5929\u6211\u4EEC\u4ECE\u4E00\u4E2A\u7B80\u5355\u7684\u95EE\u9898\u5F00\u59CB\uFF1A\u4E00\u5F20\u56FE\u7247\u662F\u600E\u6837\u4E00\u6B65\u4E00\u6B65\u751F\u6210\u51FA\u6765\u7684\uFF1F\u5148\u770B\u6700\u57FA\u672C\u7684\u60F3\u6CD5\uFF0C\u518D\u770B\u5B83\u4E3A\u4EC0\u4E48\u6709\u6548\uFF0C\u6700\u540E\u7528\u51E0\u4E2A\u4F8B\u5B50\u628A\u5B83\u4EEC\u8FDE\u8D77\u6765\u3002\u8BF7\u7528\u5E73\u65F6\u8BB2\u8BFE\u7684\u8BED\u6C14\uFF0C\u81EA\u7136\u5730\u8BFB\u4E0B\u53BB\u3002",sample:"\u58F0\u97F3\u6837\u672C",sampleHint:"10 \u5230 30 \u79D2\uFF0C\u53EA\u6709\u8BF4\u8BDD\u4EBA\u4E00\u4E2A\u4EBA\uFF0C\u73AF\u5883\u5B89\u9759\u3002\u53EF\u4EE5\u8BFB\u4E0A\u9762\u8FD9\u6BB5\u3002",sampleLength:e=>`\u6837\u672C\u957F ${e.toFixed(0)} \u79D2\u300210 \u5230 30 \u79D2\u7684\u5F55\u97F3\u6548\u679C\u6700\u597D\u3002`,record:"\u5F55\u97F3",stop:"\u505C\u6B62\u5F55\u97F3",choose:"\u9009\u62E9\u97F3\u9891\u6587\u4EF6",listen:"\u8BD5\u542C",stopListening:"\u505C\u6B62\u8BD5\u542C",clear:"\u6E05\u9664",empty:"\u5C1A\u672A\u5F55\u5236\u6216\u9009\u62E9",preparing:"\u6B63\u5728\u5904\u7406\u5F55\u97F3\u2026",seconds:e=>`${e.toFixed(1)} \u79D2`,decodeFailed:"\u65E0\u6CD5\u8BFB\u53D6\u8FD9\u6BB5\u97F3\u9891\u3002\u8BF7\u6362\u4E00\u4E2A\u6587\u4EF6\uFF0C\u6216\u91CD\u65B0\u5F55\u5236\u3002",train:"\u5F00\u59CB\u8BAD\u7EC3",use:"\u4F7F\u7528\u8FD9\u4E2A\u97F3\u8272",confirmTitle:"\u786E\u8BA4\u8BAD\u7EC3\u8FD9\u4E2A\u97F3\u8272\uFF1F",confirmHint:"\u6388\u6743\u8BB0\u5F55\u4F1A\u5148\u4FDD\u5B58\u5728\u672C\u673A\u7684\u8FD0\u8425\u8005\u76EE\u5F55\u4E2D\uFF0C\u7136\u540E\u628A\u6837\u672C\u53D1\u9001\u7ED9\u8BED\u97F3\u670D\u52A1\u8BAD\u7EC3\u3002",costs:(e,t)=>t?`\u8BAD\u7EC3\u548C\u4E4B\u540E\u7684\u5408\u6210\u90FD\u6309${dD(e)}\u7684\u4EF7\u683C\u8BA1\u8D39\u3002\u6309\u91CF\u4ED8\u8D39\u7684\u97F3\u8272\u5728\u7B2C\u4E00\u6B21\u5408\u6210\uFF08\u5305\u62EC\u8BD5\u542C\uFF09\u65F6\u6263\u8D39\uFF0C\u4E4B\u540E\u5C31\u4E0D\u80FD\u518D\u8BAD\u7EC3\u3002`:`\u8BAD\u7EC3\u548C\u4E4B\u540E\u7684\u5408\u6210\u6309${dD(e)}\u7684\u4EF7\u683C\u8BA1\u8D39\u3002`,confirm:"\u786E\u8BA4\u8BAD\u7EC3",state:(e,t)=>e.state==="ready"?`\u8BAD\u7EC3\u5B8C\u6210${e.trainingsLeft===void 0?"":`\uFF0C\u8FD9\u4E2A\u97F3\u8272\u8FD8\u53EF\u4EE5\u518D\u8BAD\u7EC3 ${e.trainingsLeft} \u6B21`}\u3002\u9009\u62E9\u201C\u4F7F\u7528\u8FD9\u4E2A\u97F3\u8272\u201D\u56DE\u5230\u97F3\u8272\u8BBE\u7F6E\u3002`:e.state==="failed"?"\u8BAD\u7EC3\u5931\u8D25\u3002\u8BF7\u6362\u4E00\u6BB5\u66F4\u6E05\u695A\u7684\u6837\u672C\u540E\u91CD\u8BD5\u3002":e.state==="training"?`\u6B63\u5728\u8BAD\u7EC3\u2026 \u5DF2\u7B49\u5F85 ${P3e(t)}`:"\u8BED\u97F3\u670D\u52A1\u6682\u65F6\u627E\u4E0D\u5230\u8FD9\u6B21\u8BAD\u7EC3\uFF0C\u8BF7\u7A0D\u540E\u67E5\u770B\u3002",failures:{notAllowed:"\u8FD0\u8425\u8005\u5C1A\u672A\u5141\u8BB8\u4F7F\u7528\u590D\u523B\u97F3\u8272\uFF0C\u8BF7\u8BA9\u8FD0\u8425\u8005\u5728\u5DE5\u4F5C\u533A\u8BBE\u7F6E\u4E2D\u5F00\u542F\u3002",busy:"\u8BED\u97F3\u670D\u52A1\u6B63\u5FD9\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002",tooLarge:"\u5F55\u97F3\u592A\u5927\uFF0C\u8BF7\u7F29\u77ED\u5230 30 \u79D2\u5DE6\u53F3\u3002",format:"\u8BED\u97F3\u670D\u52A1\u4E0D\u63A5\u53D7\u8FD9\u79CD\u97F3\u9891\u683C\u5F0F\uFF0C\u8BF7\u91CD\u65B0\u5F55\u5236\u3002",unsupported:"\u5F53\u524D\u8BED\u97F3\u670D\u52A1\u4E0D\u652F\u6301\u590D\u523B\u97F3\u8272\u3002\u8BF7\u5728\u201C\u8BBE\u7F6E \u2192 \u8BED\u97F3\u670D\u52A1\u201D\u4E2D\u9009\u62E9\u652F\u6301\u5B83\u7684\u670D\u52A1\u3002",failed:"\u65E0\u6CD5\u5F00\u59CB\u8BAD\u7EC3\u3002\u5F55\u97F3\u5DF2\u4FDD\u7559\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002"}},Xct={open:"Voice Cloning\u2026",title:"Voice Cloning",cloned:"cloned voice",close:"Close",cancel:"Cancel",description:"Train a synthetic voice from recordings of one person. They must agree, and read the consent statement aloud themselves.",voice:"Voice name",voiceHint:e=>e?"A voice slot bought in the Volcengine console (it starts with S_), or a name for a pay-as-you-go voice (a letter first, at least 8 letters or digits).":"A name for the voice: letters, digits, \u201C.\u201D, \u201C-\u201D, and \u201C_\u201D only.",voiceInvalid:"Use letters, digits, \u201C.\u201D, \u201C-\u201D, and \u201C_\u201D, starting with a letter or digit.",speaker:"Speaker",speakerHint:"Whose voice this is.",scope:"Use",scopeHint:"Where this voice may be used; it goes into the consent record.",defaultScope:"the voiceover of this workspace\u2019s documents",statement:"Consent statement recording",statementHint:"The speaker reads the consent statement above aloud.",statementText:(e,t)=>`I am ${e}. I agree that my voice is used to train a synthetic voice, only for ${t}.`,someone:"(the speaker\u2019s name)",statementLabel:"Consent statement",passageLabel:"A passage to read",passage:"Today we start from a simple question: how is a picture made, one step after another? First the basic idea, then why it works, and finally a few examples that tie it together. Read it the way you would speak in class, at an easy pace.",sample:"Voice sample",sampleHint:"10 to 30 seconds of the speaker alone, somewhere quiet. Reading the passage above works well.",sampleLength:e=>`The sample is ${e.toFixed(0)} seconds long. Recordings of 10 to 30 seconds work best.`,record:"Record",stop:"Stop Recording",choose:"Choose Audio File",listen:"Play Sample",stopListening:"Stop Sample",clear:"Clear",empty:"Nothing recorded or chosen yet",preparing:"Preparing the recording\u2026",seconds:e=>`${e.toFixed(1)} s`,decodeFailed:"Couldn\u2019t read this audio. Choose another file, or record again.",train:"Start Training",use:"Use This Voice",confirmTitle:"Train this voice?",confirmHint:"The consent record is saved first, in the operator directory on this machine; then the sample is sent to the voice service for training.",costs:(e,t)=>t?`Training and every later voiceover are charged at ${e}\u2019s prices. A pay-as-you-go voice is charged when it first generates voiceover, listening included, and can\u2019t be trained again after that.`:`Training and later voiceover are charged at ${e}\u2019s prices.`,confirm:"Train",state:(e,t)=>e.state==="ready"?`Trained${e.trainingsLeft===void 0?"":`; it can be trained ${e.trainingsLeft} more times`}. Choose Use This Voice to return to the voice settings.`:e.state==="failed"?"Training failed. Try again with a clearer sample.":e.state==="training"?`Training\u2026 ${P3e(t)} so far`:"The voice service can\u2019t find this training yet. Check again later.",failures:{notAllowed:"The operator has not allowed cloned voices yet. Ask them to turn cloned voices on in the workspace settings.",busy:"The voice service is busy. Try again shortly.",tooLarge:"The recording is too large. Keep it to about 30 seconds.",format:"The voice service doesn\u2019t accept this audio format. Record again.",unsupported:"The current voice service doesn\u2019t support Voice Cloning. Choose one that does in Settings \u2192 Voice Service.",failed:"Couldn\u2019t start training. The recordings are kept; try again shortly."}},b2={"zh-CN":Zct,en:Xct};function E3e(e,t){let n=b2[t].failures,r=e instanceof Pn?e.status:0,o=e instanceof Error?e.message:String(e);return r===403&&/cloned voices are off|not allowed/.test(o)?n.notAllowed:r===429?n.busy:r===413?n.tooLarge:r===415?n.format:r===400&&/cannot (?:clone|train cloned) voices/.test(o)?n.unsupported:(console.warn(`presmium: voice cloning failed: ${o}`),n.failed)}var Qct={voice:"\u97F3\u8272",settings:"\u9009\u62E9\u97F3\u8272",generate:"\u751F\u6210\u914D\u97F3",generation:"\u914D\u97F3\u751F\u6210\u4E0E\u66F4\u65B0",currentVoice:"\u5F53\u524D\u97F3\u8272",unset:"\u5C1A\u672A\u9009\u62E9\u97F3\u8272",inherited:{step:"\u72EC\u7ACB\u8BBE\u7F6E",page:"\u7EE7\u627F\u9875\u9762",document:"\u7EE7\u627F\u6587\u7A3F\u9ED8\u8BA4",unset:"\u672A\u8BBE\u7F6E"},loading:"\u6B63\u5728\u52A0\u8F7D\u97F3\u8272\u8BBE\u7F6E\u2026",loadingVoices:"\u6B63\u5728\u52A0\u8F7D\u53EF\u7528\u97F3\u8272\u2026",loadFailed:"\u65E0\u6CD5\u52A0\u8F7D\u97F3\u8272\u8BBE\u7F6E\uFF0C\u8BF7\u91CD\u8BD5\u3002",unsupported:"\u5F53\u524D\u5DE5\u4F5C\u533A\u670D\u52A1\u5C1A\u4E0D\u652F\u6301\u97F3\u8272\u8BBE\u7F6E\u3002\u8BF7\u66F4\u65B0\u5E76\u91CD\u65B0\u542F\u52A8 Presmium\u3002",noService:"\u672A\u8FDE\u63A5\u8BED\u97F3\u670D\u52A1\u3002",speechFailures:{"speech-authentication":"\u8BED\u97F3 API Key \u9A8C\u8BC1\u5931\u8D25\uFF0C\u8BF7\u5728\u8BED\u97F3\u670D\u52A1\u8BBE\u7F6E\u4E2D\u66F4\u65B0\u5BC6\u94A5\u3002","speech-permission":"\u8BED\u97F3\u670D\u52A1\u62D2\u7EDD\u8BBF\u95EE\uFF0C\u8BF7\u68C0\u67E5\u662F\u5426\u5DF2\u5F00\u901A\u8BED\u97F3\u5408\u6210 2.0\uFF0C\u4EE5\u53CA\u5BC6\u94A5\u7684\u670D\u52A1\u548C\u97F3\u8272\u6743\u9650\u3002","speech-quota":"\u8BED\u97F3\u670D\u52A1\u989D\u5EA6\u4E0D\u8DB3\uFF0C\u8BF7\u68C0\u67E5\u8D26\u6237\u4F59\u989D\u6216\u53EF\u7528\u914D\u989D\u540E\u91CD\u8BD5\u3002","speech-busy":"\u8BED\u97F3\u670D\u52A1\u5E76\u53D1\u5DF2\u6EE1\uFF0C\u8BF7\u7A0D\u540E\u91CD\u65B0\u64AD\u653E\u3002","speech-network":"\u65E0\u6CD5\u8FDE\u63A5\u8BED\u97F3\u670D\u52A1\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u65B0\u64AD\u653E\u3002","speech-empty-audio":"\u8BED\u97F3\u670D\u52A1\u6CA1\u6709\u8FD4\u56DE\u97F3\u9891\uFF0C\u8BF7\u91CD\u65B0\u64AD\u653E\u6216\u66F4\u6362\u97F3\u8272\u3002","speech-invalid-request":"\u8BED\u97F3\u670D\u52A1\u4E0D\u63A5\u53D7\u5F53\u524D\u8BB2\u7A3F\u6216\u97F3\u8272\u53C2\u6570\uFF0C\u8BF7\u68C0\u67E5\u97F3\u8272\u548C\u8BB2\u7A3F\u3002","speech-provider":"\u8BED\u97F3\u670D\u52A1\u6682\u65F6\u65E0\u6CD5\u5408\u6210\uFF0C\u8BF7\u7A0D\u540E\u91CD\u65B0\u64AD\u653E\u3002","speech-cache-failed":"\u914D\u97F3\u7F13\u5B58\u65E0\u6CD5\u5199\u5165\uFF0C\u8BF7\u68C0\u67E5\u672C\u673A\u78C1\u76D8\u7A7A\u95F4\u548C\u76EE\u5F55\u6743\u9650\u3002"},noServiceOption:"\u5C1A\u672A\u8FDE\u63A5",savedEngineUnavailable:"\u5DF2\u4FDD\u5B58\u7684\u670D\u52A1\uFF08\u672A\u8FDE\u63A5\uFF09",generationUnavailable:"\u5F53\u524D\u6587\u7A3F\u5C1A\u672A\u542F\u7528\u914D\u97F3\u751F\u6210\uFF0C\u8BB2\u7A3F\u4E0E\u97F3\u8272\u8BBE\u7F6E\u4ECD\u7136\u4FDD\u7559\u3002",catalogUnsupported:"\u6B64\u670D\u52A1\u5C1A\u672A\u63D0\u4F9B\u97F3\u8272\u76EE\u5F55\u3002\u5DF2\u4FDD\u5B58\u7684\u97F3\u8272\u8BBE\u7F6E\u4ECD\u7136\u4FDD\u7559\u3002",voiceUnavailable:"\u6240\u9009\u97F3\u8272\u4E0D\u652F\u6301\u6B64\u6587\u7A3F\u8BED\u8A00\u6216\u5F53\u524D\u670D\u52A1\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u3002",parametersUnsupported:"\u5F53\u524D\u670D\u52A1\u4E0D\u652F\u6301\u6240\u9009\u53C2\u6570\uFF0C\u8BF7\u5237\u65B0\u97F3\u8272\u76EE\u5F55\u540E\u91CD\u65B0\u68C0\u67E5\u3002",previewTooLong:"\u5F53\u524D\u6B65\u9AA4\u8BB2\u7A3F\u8D85\u8FC7\u8BD5\u542C\u957F\u5EA6\uFF0C\u8BF7\u751F\u6210\u914D\u97F3\u540E\u64AD\u653E\u3002",sourceUnsupported:"\u6B64\u6587\u7A3F\u7684\u6765\u6E90\u683C\u5F0F\u6682\u4E0D\u652F\u6301\u5B89\u5168\u4FEE\u6539\u97F3\u8272\u3002\u539F\u8BBE\u7F6E\u548C\u8349\u7A3F\u5DF2\u4FDD\u7559\u3002",bundledCatalog:"\u97F3\u8272\u6765\u81EA\u670D\u52A1\u7684\u5185\u7F6E\u76EE\u5F55\uFF0C\u5408\u6210\u65F6\u68C0\u67E5\u8FDE\u63A5\u3002",search:"\u67E5\u627E\u97F3\u8272",searchPlaceholder:"\u540D\u79F0\u3001\u8BED\u8A00\u6216\u58F0\u97F3\u6765\u6E90",available:"\u53EF\u7528\u97F3\u8272",empty:"\u6CA1\u6709\u7B26\u5408\u6761\u4EF6\u7684\u97F3\u8272",results:e=>`${e} \u4E2A\u97F3\u8272`,language:"\u8BED\u8A00",allLanguages:"\u5168\u90E8\u8BED\u8A00",provider:"\u8BED\u97F3\u670D\u52A1",details:"\u97F3\u8272\u8BE6\u60C5",languageMismatch:"\u4E0D\u652F\u6301\u6587\u7A3F\u7684\u8BED\u8A00",standard:"\u8BD5\u542C\u6807\u51C6\u793A\u4F8B",currentScript:"\u8BD5\u542C\u5F53\u524D\u8BB2\u7A3F",stop:"\u505C\u6B62\u8BD5\u542C",auditioning:"\u6B63\u5728\u8BD5\u542C",auditionLoading:"\u6B63\u5728\u51C6\u5907\u8BD5\u542C\u2026",auditionFailed:"\u65E0\u6CD5\u8BD5\u542C\uFF0C\u8BF7\u91CD\u8BD5\u3002\u97F3\u8272\u8BBE\u7F6E\u672A\u66F4\u6539\u3002",pauseUnavailable:"\u9884\u89C8\u5C1A\u4E0D\u652F\u6301\u6682\u505C\u64AD\u653E\uFF0C\u6682\u65F6\u65E0\u6CD5\u8BD5\u542C\u3002\u8BF7\u91CD\u65B0\u52A0\u8F7D\u6587\u7A3F\u3002",pauseTimeout:"\u65E0\u6CD5\u786E\u8BA4\u64AD\u653E\u5DF2\u6682\u505C\uFF0C\u8BF7\u91CD\u8BD5\u3002",changed:"\u6587\u7A3F\u6216\u97F3\u8272\u8BBE\u7F6E\u5DF2\u66F4\u65B0\u3002\u8349\u7A3F\u5DF2\u4FDD\u7559\uFF0C\u8BF7\u6309\u5F53\u524D\u6B65\u9AA4\u91CD\u65B0\u68C0\u67E5\u5E94\u7528\u8303\u56F4\u3002",draftRecovered:"\u5DF2\u6062\u590D\u5C1A\u672A\u5E94\u7528\u7684\u97F3\u8272\u8BBE\u7F6E\u8349\u7A3F\uFF0C\u8BF7\u68C0\u67E5\u8303\u56F4\u540E\u5E94\u7528\u3002",recoveryFailed:"\u65E0\u6CD5\u5728\u6B64\u6D4F\u89C8\u5668\u4FDD\u7559\u97F3\u8272\u8349\u7A3F\uFF0C\u8BF7\u5728\u5173\u95ED\u524D\u5E94\u7528\u6216\u590D\u5236\u8BBE\u7F6E\u3002",recheck:"\u6309\u5F53\u524D\u6B65\u9AA4\u91CD\u65B0\u68C0\u67E5",scope:"\u5E94\u7528\u8303\u56F4",scopes:{step:"\u5F53\u524D\u6B65\u9AA4",steps:"\u6240\u9009\u6B65\u9AA4",page:"\u5F53\u524D\u9875",document:"\u6574\u4EFD\u6587\u7A3F"},selectedSteps:"\u9009\u62E9\u6B65\u9AA4",step:(e,t)=>`\u7B2C ${e} \u9875\uFF0C\u6B65\u9AA4 ${t}`,selected:e=>`\u5DF2\u9009\u62E9 ${e} \u4E2A\u6B65\u9AA4`,inherit:"\u4F7F\u7528\u7EE7\u627F\u7684\u97F3\u8272",inheritHint:"\u6539\u7528\u6700\u8FD1\u7684\u9875\u9762\u6216\u6587\u7A3F\u9ED8\u8BA4\u97F3\u8272\u3002",pageScript:e=>`\u7B2C ${e} \u9875\uFF0C\u5173\u8054\u8BB2\u7A3F\uFF08\u6309\u9875\u751F\u6210\uFF09`,replace:"\u5DF2\u6709\u8986\u76D6",preserve:"\u4FDD\u7559\u72EC\u7ACB\u8BBE\u7F6E",replaceAll:"\u66FF\u6362\u72EC\u7ACB\u8BBE\u7F6E",counts:(e,t)=>`\u5C06\u66F4\u65B0 ${e} \u4E2A\u6B65\u9AA4\uFF0C\u4FDD\u7559 ${t} \u4E2A\u72EC\u7ACB\u8BBE\u7F6E\u3002`,check:"\u68C0\u67E5\u5E94\u7528\u8303\u56F4",checking:"\u6B63\u5728\u68C0\u67E5\u5E94\u7528\u8303\u56F4\u2026",apply:"\u5E94\u7528\u8BBE\u7F6E",saved:"\u97F3\u8272\u8BBE\u7F6E\u5DF2\u4FDD\u5B58\u3002",cachedPreview:"\u672C\u6B21\u4F7F\u7528\u5DF2\u6709\u914D\u97F3\u7F13\u5B58\u3002",clearDefault:"\u6E05\u9664\u6587\u7A3F\u9ED8\u8BA4\u97F3\u8272",rate:"\u8BED\u901F",rateInvalid:(e,t)=>`\u8BF7\u8F93\u5165 ${e}\u2013${t} \u4E4B\u95F4\u7684\u6570\u503C\u3002`,style:"\u6717\u8BFB\u98CE\u683C",styleDefault:"\u670D\u52A1\u9ED8\u8BA4",cueStep:"\u6B64\u8BB2\u7A3F\u5305\u542B\u8DE8\u6B65\u9AA4\u63D0\u793A\uFF0C\u6682\u4E0D\u652F\u6301\u5355\u72EC\u8986\u76D6\u97F3\u8272\u3002\u53EF\u8BBE\u7F6E\u9875\u9762\u6216\u6587\u7A3F\u9ED8\u8BA4\u97F3\u8272\u3002",disclosure:(e,t)=>t?`\u672C\u6B21\u5728\u672C\u673A\u901A\u8FC7 ${e} \u5408\u6210\u3002`:`\u672C\u6B21\u5C06\u6240\u793A\u8BB2\u7A3F\u53D1\u9001\u81F3 ${e} \u5408\u6210\u914D\u97F3\u3002`,confirmPreview:"\u786E\u8BA4\u5E76\u8BD5\u542C",sampleText:"\u6807\u51C6\u793A\u4F8B\u6587\u672C",source:"\u58F0\u97F3\u6765\u6E90",previewHint:"\u786E\u8BA4\u540E\u64AD\u653E\u5DF2\u6709\u7F13\u5B58\u6216\u8BF7\u6C42\u5408\u6210\uFF1B\u9009\u62E9\u97F3\u8272\u672C\u8EAB\u4E0D\u4F1A\u751F\u6210\u914D\u97F3\u3002",refreshing:"\u6B63\u5728\u52A0\u8F7D\u914D\u97F3\u72B6\u6001\u2026",refresh:"\u5237\u65B0\u72B6\u6001",missingOnly:"\u53EA\u751F\u6210\u7F3A\u5931\u4E0E\u9700\u8981\u66F4\u65B0\u7684\u7247\u6BB5",confirmGenerate:"\u786E\u8BA4\u5E76\u751F\u6210",cancelJob:"\u53D6\u6D88\u751F\u6210",oldVersion:"\u8F83\u65E9\u6587\u7A3F\u7248\u672C",noScript:"\u5F53\u524D\u8303\u56F4\u6CA1\u6709\u53EF\u751F\u6210\u7684\u8BB2\u7A3F\u3002",statuses:{ready:"\u53EF\u64AD\u653E",missing:"\u9700\u8981\u751F\u6210",blocked:"\u6682\u4E0D\u53EF\u751F\u6210",empty:"\u6CA1\u6709\u8BB2\u7A3F"},jobs:{queued:"\u7B49\u5F85\u751F\u6210",running:"\u6B63\u5728\u751F\u6210",cancelling:"\u6B63\u5728\u53D6\u6D88",cancelled:"\u5DF2\u53D6\u6D88",done:"\u5DF2\u5B8C\u6210",failed:"\u751F\u6210\u5931\u8D25",stale:"\u6587\u7A3F\u5DF2\u66F4\u65B0"},progress:(e,t,n)=>`\u5DF2\u5B8C\u6210 ${e} / ${t}${n?`\uFF0C\u5931\u8D25 ${n}`:""}`,generationSummary:(e,t)=>[e?`\u5F85\u751F\u6210 ${e} \u6BB5`:"",t?`${t} \u6BB5\u4E0D\u53EF\u7528`:""].filter(Boolean).join(" \xB7 "),generationScript:"\u672C\u6B21\u8303\u56F4\u7684\u8BB2\u7A3F",generationBusy:"\u6B64\u6587\u7A3F\u5DF2\u6709\u751F\u6210\u64CD\u4F5C\uFF0C\u8BF7\u7B49\u5F85\u5B8C\u6210\u6216\u53D6\u6D88\u540E\u91CD\u8BD5\u3002",cacheReady:"\u914D\u97F3\u5DF2\u5C31\u7EEA\u3002",unboundScript:"\u6B64\u9875\u6709\u5173\u8054\u5230\u8DE8\u6B65\u9AA4\u63D0\u793A\u7684\u8BB2\u7A3F\uFF0C\u8BF7\u9009\u62E9\u9875\u9762\u6216\u6587\u7A3F\u8303\u56F4\u751F\u6210\u3002",recordingUnavailable:"\u672C\u6B65\u4F7F\u7528\u539F\u97F3\u9891\uFF0C\u65E0\u9700\u751F\u6210\u8BED\u97F3\u3002",silentScope:e=>`${e} \u4E2A\u6B65\u9AA4\u5DF2\u660E\u786E\u8BBE\u7F6E\u4E3A\u9759\u97F3\uFF0C\u8BBE\u7F6E\u4FDD\u6301\u4E0D\u53D8\u3002`,requestFailed:"\u65E0\u6CD5\u5B8C\u6210\u64CD\u4F5C\u3002\u8BBE\u7F6E\u548C\u8349\u7A3F\u5DF2\u4FDD\u7559\uFF0C\u8BF7\u91CD\u8BD5\u3002",cancel:"\u53D6\u6D88",close:"\u5173\u95ED",cancelAndClose:"\u53D6\u6D88\u5E76\u5173\u95ED",retry:"\u91CD\u8BD5"},edt={voice:"Voice",settings:"Choose Voice",generate:"Generate Voiceover",generation:"Voiceover Generation and Updates",currentVoice:"Current voice",unset:"No voice selected",inherited:{step:"Independent setting",page:"Inherited from page",document:"Inherited from document",unset:"Not set"},loading:"Loading voice settings\u2026",loadingVoices:"Loading available voices\u2026",loadFailed:"Couldn\u2019t load voice settings. Try again.",unsupported:"This workspace service does not support voice settings yet. Update and restart Presmium.",noService:"No voice service is connected.",speechFailures:{"speech-authentication":"The speech API key was rejected. Update it in Voice Service settings.","speech-permission":"The speech service denied access. Check activation of speech synthesis 2.0 and the key\u2019s service and voice permissions.","speech-quota":"The speech service has insufficient credit or quota. Check the account and try again.","speech-busy":"The speech service is at its concurrency limit. Try playing again shortly.","speech-network":"Couldn\u2019t connect to the speech service. Check the network and play again.","speech-empty-audio":"The speech service returned no audio. Play again or choose another voice.","speech-invalid-request":"The speech service rejected this script or voice parameters. Check the voice and script.","speech-provider":"The speech service can\u2019t generate voiceover right now. Try playing again shortly.","speech-cache-failed":"Couldn\u2019t write the voiceover cache. Check disk space and directory permissions."},noServiceOption:"Not connected",savedEngineUnavailable:"Saved service (not connected)",generationUnavailable:"Voiceover generation is not enabled for this document. Script and voice settings are kept.",catalogUnsupported:"This service does not provide a list of voices. Your saved voice settings are kept.",voiceUnavailable:"The selected voice does not support the document language or service. Choose another voice.",parametersUnsupported:"This service does not support the selected parameters. Refresh the list of voices and check again.",previewTooLong:"This step\u2019s script exceeds the preview limit. Generate voiceover to play it.",sourceUnsupported:"The document\u2019s source format cannot safely update voice settings yet. Settings and drafts are kept.",bundledCatalog:"Voices come from the service\u2019s built-in list. The connection is checked when voiceover is generated.",search:"Find a voice",searchPlaceholder:"Name, language, or voice source",available:"Available voices",empty:"No matching voices",results:e=>`${e} voices`,language:"Language",allLanguages:"All languages",provider:"Voice service",details:"Voice details",languageMismatch:"Does not support the document language",standard:"Play Standard Sample",currentScript:"Play Current Script",stop:"Stop Sample",auditioning:"Playing",auditionLoading:"Preparing to play\u2026",auditionFailed:"Couldn\u2019t play the sample. Try again; your voice settings haven\u2019t changed.",pauseUnavailable:"The preview can\u2019t pause playback yet, so listening is unavailable. Reload the document.",pauseTimeout:"Couldn\u2019t confirm that playback paused. Try again.",changed:"The document or voice settings changed. Your draft is kept; check the scope again for the current step.",draftRecovered:"Your draft voice settings were recovered. Check the scope before applying them.",recoveryFailed:"Voice drafts can\u2019t be kept in this browser. Apply or copy your settings before closing.",recheck:"Check Again for Current Step",scope:"Apply to",scopes:{step:"Current step",steps:"Selected steps",page:"Current page",document:"Entire document"},selectedSteps:"Select Steps",step:(e,t)=>`Page ${e}, step ${t}`,selected:e=>`${e} steps selected`,pageScript:e=>`Page ${e}, linked script (generate by page)`,inherit:"Use Inherited Voice",inheritHint:"Use the nearest page or document default voice.",replace:"Existing overrides",preserve:"Keep independent settings",replaceAll:"Replace independent settings",counts:(e,t)=>`${e} steps will update; ${t} independent settings will be kept.`,check:"Check Scope",checking:"Checking scope\u2026",apply:"Apply Settings",saved:"Voice settings saved.",cachedPreview:"This preview uses an existing voiceover cache.",clearDefault:"Clear Document Default Voice",rate:"Speaking rate",rateInvalid:(e,t)=>`Enter a number between ${e} and ${t}.`,style:"Reading style",styleDefault:"Service default",cueStep:"This script has cues across steps. A step voice override is not supported yet; set a page or document default instead.",disclosure:(e,t)=>t?`The voiceover is generated on this device with ${e}.`:`The script shown is sent to ${e} to generate the voiceover.`,confirmPreview:"Confirm and Play Sample",sampleText:"Standard sample text",source:"Voice source",previewHint:"After you confirm, a saved voiceover plays or a new one is generated. Choosing a voice doesn\u2019t generate voiceover.",refreshing:"Loading voiceover status\u2026",refresh:"Refresh Status",missingOnly:"Generate only missing clips and clips that need updating",confirmGenerate:"Confirm and Generate",cancelJob:"Cancel Generating",oldVersion:"Earlier document version",noScript:"There is no script to generate in this scope.",statuses:{ready:"Playable",missing:"Needs generation",blocked:"Unavailable",empty:"No script"},jobs:{queued:"Queued",running:"Generating",cancelling:"Canceling",cancelled:"Canceled",done:"Completed",failed:"Generation failed",stale:"Document changed"},progress:(e,t,n)=>`${e} / ${t} completed${n?`; ${n} failed`:""}`,generationSummary:(e,t)=>[e?`${e} ${e===1?"clip":"clips"} to generate`:"",t?`${t} ${t===1?"clip":"clips"} unavailable`:""].filter(Boolean).join(" \xB7 "),generationScript:"Script in this scope",generationBusy:"Voiceover is already being generated for this document. Wait for it or cancel it, then try again.",cacheReady:"Voiceover is ready.",unboundScript:"This page has script with cues across steps. Choose a page or document scope to generate it.",recordingUnavailable:"This step uses original audio, so no voiceover needs to be generated.",silentScope:e=>`${e} steps are explicitly silent. Their settings are kept.`,requestFailed:"Couldn\u2019t finish the operation. Settings and drafts are kept; try again.",cancel:"Cancel",close:"Close",cancelAndClose:"Cancel and Close",retry:"Retry"},oh={"zh-CN":Qct,en:edt};function Ki(e,t){let n=oh[t],r=e instanceof Error?e.message:"",o=KA(e);if(o)return n.speechFailures[o]??n.requestFailed;if(r==="not-configured"||r==="voice-not-configured")return n.noService;if(r==="voice-unavailable"||r==="voice-engine-unsupported"||r==="voice-engine-unknown")return n.voiceUnavailable;if(r==="voice-catalog-unavailable"||r==="catalog-unavailable")return n.catalogUnsupported;if(r==="voice-cue-step")return n.cueStep;if(r==="voice-script-empty")return n.noScript;if(r==="voice-preview-too-long"||r==="voice-preview-too-large")return n.previewTooLong;if(r==="voice-rate-unsupported"||r==="voice-style-unsupported")return n.parametersUnsupported;if(r==="voice-source-format"||r==="voice-source-ignored")return n.sourceUnsupported;if(r==="voiceover-unavailable")return n.generationUnavailable;if(r==="voice-job-busy")return n.generationBusy;if(r==="voice-unset")return n.unset;if(r==="recording-unavailable"||r==="voice-recording-unavailable")return n.recordingUnavailable;if(r==="speech-unavailable"||r.startsWith("no speech service:"))return n.noService;if(["voice-source-changed","voice-source-unavailable","voice-source-pending","voice-revision-changed","voice-preview-changed","voice-step-binding-stale","voice-target-changed"].includes(r))return n.changed;if(e instanceof Pn){if(e.status===404)return n.unsupported;if(e.status===409)return n.changed}return r==="voice-context-changed"?n.changed:r==="preview-playback-timeout"?n.pauseTimeout:r.startsWith("preview-playback-")?n.pauseUnavailable:r.startsWith("audition-")?n.auditionFailed:n.requestFailed}function Sa(e,t){let n=e.getState(),r=n.authoring;return n.document===t.directory&&r?.identity===t.identity&&r.version===t.source.version&&r.fingerprint===t.source.fingerprint&&r.content?.id===t.source.documentId&&!r.loading&&!r.dirty&&!r.saving&&!r.composing&&!r.restored&&!r.error}function OY(e,t){let n=e.sections.find(o=>o.stepIds?.includes(t)),r=n?.stepIds?.indexOf(t)??-1;if(!n||r<0)throw new Error("voice-step-binding-stale");return Pj(n,r)}async function y2(e,t,n){let r=e.getState(),o=r.authoring?.identity,i=r.document;if(!o||i===void 0)throw new Error("voice-context-changed");await e.pausePlayback(),n.throwIfAborted(),await e.flushPendingEdits(n);let a=e.getState(),s=a.authoring;if(a.document!==i||s?.identity!==o||!s.version||!s.fingerprint||!s.content?.steps[t])throw new Error("voice-context-changed");let l=await v9(e.client,{directory:i,version:s.version,fingerprint:s.fingerprint},n);if(n.throwIfAborted(),!l.doc.source)throw new Error("voice-source-pending");let c={directory:i,identity:o,revision:l.revision,source:l.doc.source,target:OY(l.doc,t),ir:l.doc};if(!Sa(e,c))throw new Error("voice-context-changed");return c}function NY(e,t){if(t.kind==="document")return{kind:"document"};if(t.kind==="page"){if(!e.ir.sections.some(n=>n.id===t.sectionId))throw new Error("voice-target-changed");return{kind:"page",section:t.sectionId}}if(t.kind==="step")return{kind:"step",target:OY(e.ir,t.stepId)};if(!t.stepIds.length)throw new Error("voice-script-empty");return{kind:"steps",targets:[...new Set(t.stepIds)].map(n=>OY(e.ir,n))}}var fo=require("react");var tdt={trim:"\u5F55\u97F3\u533A\u95F4",captionReview:"\u5B57\u5E55\u5C1A\u672A\u6309\u88C1\u526A\u540E\u7684\u5F55\u97F3\u5BF9\u9F50\uFF0C\u8BF7\u6838\u5BF9\u3002",title:"\u539F\u97F3\u9891",source:"\u672C\u6B65\u539F\u97F3",choose:"\u9009\u62E9\u5DF2\u4FDD\u5B58\u97F3\u9891",removedAudio:"\u539F\u97F3\u9891\u5DF2\u79FB\u9664",adopt:"\u91C7\u7528\u4E3A\u672C\u6B65\u914D\u97F3",adopted:"\u5DF2\u91C7\u7528",retryAdoption:"\u91CD\u8BD5\u91C7\u7528",cancelAdoption:"\u53D6\u6D88\u91C7\u7528",adoptionSourceChanged:"\u6587\u7A3F\u5DF2\u66F4\u65B0\uFF0C\u8BF7\u91CD\u8BD5\u3002",adoptionFailed:"\u65E0\u6CD5\u91C7\u7528\u8FD9\u6BB5\u97F3\u9891\uFF0C\u8BF7\u91CD\u8BD5\u3002",start:"\u5F00\u59CB\u5F55\u97F3",stop:"\u505C\u6B62\u5F55\u97F3",cancel:"\u53D6\u6D88",cancelTake:"\u653E\u5F03\u672C\u6B21\u5F55\u97F3",rerecord:"\u91CD\u65B0\u5F55\u97F3",audition:"\u8BD5\u542C",stopAudition:"\u505C\u6B62\u8BD5\u542C",save:"\u4FDD\u5B58\u4E3A\u97F3\u9891\u7D20\u6750",saving:"\u6B63\u5728\u4FDD\u5B58\u539F\u97F3\u2026",retry:"\u91CD\u8BD5",discard:"\u653E\u5F03\u5019\u9009",ready:"\u539F\u97F3\u5019\u9009 \xB7 \u5C1A\u672A\u4FDD\u5B58",imported:"\u5DF2\u4FDD\u5B58\u4E3A\u97F3\u9891\u7D20\u6750",requesting:"\u6B63\u5728\u7B49\u5F85\u9EA6\u514B\u98CE\u8BB8\u53EF",recording:"\u6B63\u5728\u5F55\u97F3",stopping:"\u6B63\u5728\u5B8C\u6210\u5F55\u97F3\u2026",cancelSave:"\u53D6\u6D88\u4FDD\u5B58",currentSource:"\u6587\u7A3F\u5C1A\u672A\u4FDD\u5B58\uFF0C\u8BF7\u5148\u5B8C\u6210\u5F53\u524D\u8F93\u5165\u3002",saveFailed:"\u65E0\u6CD5\u4FDD\u5B58\u539F\u97F3\u3002\u5F55\u97F3\u5DF2\u4FDD\u7559\uFF0C\u8BF7\u91CD\u8BD5\u3002",discardTitle:"\u653E\u5F03\u8FD9\u4EFD\u539F\u97F3\uFF1F",discardHint:"\u672A\u4FDD\u5B58\u7684\u5F55\u97F3\u5C06\u88AB\u5220\u9664\uFF0C\u5DF2\u4FDD\u5B58\u7684\u97F3\u9891\u7D20\u6750\u4E0D\u53D7\u5F71\u54CD\u3002",keep:"\u4FDD\u7559\u539F\u97F3",failures:{"recording-context":"\u5F53\u524D\u73AF\u5883\u65E0\u6CD5\u8BBF\u95EE\u9EA6\u514B\u98CE\u3002\u8BF7\u4F7F\u7528\u5B89\u5168\u8FDE\u63A5\uFF0C\u6216\u7EE7\u7EED\u5BFC\u5165\u97F3\u9891\u3002","recording-unsupported":"\u6B64\u6D4F\u89C8\u5668\u65E0\u6CD5\u5F55\u5236\u53D7\u652F\u6301\u7684\u97F3\u9891\u683C\u5F0F\u3002\u4ECD\u53EF\u5BFC\u5165\u97F3\u9891\u3002","recording-permission":"\u9EA6\u514B\u98CE\u672A\u83B7\u8BB8\u53EF\u3002\u8BF7\u68C0\u67E5\u6D4F\u89C8\u5668\u6743\u9650\u540E\u91CD\u8BD5\u3002","recording-device":"\u6CA1\u6709\u53EF\u7528\u7684\u9EA6\u514B\u98CE\u3002","recording-device-busy":"\u9EA6\u514B\u98CE\u5F53\u524D\u65E0\u6CD5\u4F7F\u7528\uFF0C\u8BF7\u68C0\u67E5\u8BBE\u5907\u540E\u91CD\u8BD5\u3002","recording-device-unsupported":"\u5F53\u524D\u6D4F\u89C8\u5668\u6216\u8BBE\u5907\u4E0D\u652F\u6301\u6B64\u5F55\u97F3\u8BF7\u6C42\u3002\u4ECD\u53EF\u5BFC\u5165\u97F3\u9891\u3002","recording-device-ended":"\u9EA6\u514B\u98CE\u8FDE\u63A5\u5DF2\u7ED3\u675F\uFF0C\u5DF2\u4FDD\u7559\u5F55\u5230\u7684\u539F\u97F3\u3002","recording-failed":"\u65E0\u6CD5\u5B8C\u6210\u672C\u6B21\u5F55\u97F3\u3002\u5DF2\u6709\u539F\u97F3\u4ECD\u4FDD\u7559\u3002","recording-empty":"\u672C\u6B21\u6CA1\u6709\u5F55\u5230\u97F3\u9891\uFF0C\u8BF7\u91CD\u8BD5\u3002","recording-size":"\u5F55\u97F3\u8D85\u8FC7 16 MiB\u3002\u8BF7\u7F29\u77ED\u5F55\u97F3\u540E\u91CD\u8BD5\uFF0C\u5DF2\u6709\u5019\u9009\u4ECD\u4FDD\u7559\u3002","recording-duration":"\u5DF2\u8FBE\u5230\u5341\u5206\u949F\u5F55\u5236\u4E0A\u9650\uFF0C\u5F55\u97F3\u5DF2\u505C\u6B62\u3002","audition-audio":"\u539F\u97F3\u65E0\u6CD5\u64AD\u653E\u3002\u8BF7\u68C0\u67E5\u97F3\u9891\u6216\u91CD\u65B0\u5F55\u5236\u3002","audition-request":"\u65E0\u6CD5\u5F00\u59CB\u8BD5\u542C\uFF0C\u8BF7\u91CD\u8BD5\u3002"}},ndt={trim:"Recording range",captionReview:"Captions are not aligned to the trimmed recording. Review them.",title:"Original audio",source:"Original audio for this step",choose:"Choose Saved Audio",removedAudio:"Original audio was removed",adopt:"Use as Step Voiceover",adopted:"Applied",retryAdoption:"Retry",cancelAdoption:"Cancel",adoptionSourceChanged:"The document changed. Retry.",adoptionFailed:"Couldn\u2019t use this audio. Try again.",start:"Start Recording",stop:"Stop Recording",cancel:"Cancel",cancelTake:"Discard This Recording",rerecord:"Record Again",audition:"Play Sample",stopAudition:"Stop Sample",save:"Save as Audio Asset",saving:"Saving original audio\u2026",retry:"Retry",discard:"Discard Candidate",ready:"Original audio candidate \xB7 Not saved",imported:"Saved as an audio asset",requesting:"Waiting for microphone permission",recording:"Recording",stopping:"Finishing recording\u2026",cancelSave:"Cancel",currentSource:"Finish and save the current document input first.",saveFailed:"Couldn\u2019t save the original audio. The recording is kept; try again.",discardTitle:"Discard this original audio?",discardHint:"The recording that is not saved will be deleted. Saved audio assets are kept.",keep:"Keep Original Audio",failures:{"recording-context":"Microphone access is unavailable here. Use a secure connection or import an audio file.","recording-unsupported":"This browser cannot record a supported audio format. Audio file import is still available.","recording-permission":"Microphone permission was not granted. Check browser permissions and retry.","recording-device":"No microphone is available.","recording-device-busy":"The microphone is unavailable. Check the device and retry.","recording-device-unsupported":"This browser or device does not support the recording request. Audio file import is still available.","recording-device-ended":"The microphone disconnected. Recorded audio is retained.","recording-failed":"Couldn\u2019t finish this recording. Any previous original audio is kept.","recording-empty":"No audio was recorded. Retry.","recording-size":"The recording exceeds 16 MiB. Record a shorter take; any previous candidate is retained.","recording-duration":"The ten-minute recording limit was reached. Recording stopped.","audition-audio":"This audio could not be played. Check it or record again.","audition-request":"Couldn\u2019t start listening. Try again."}},V1={"zh-CN":tdt,en:ndt};async function A3e(e,t=24e3){let n=await new OfflineAudioContext(1,1,t).decodeAudioData(await e.arrayBuffer()),r=new OfflineAudioContext(1,Math.max(1,Math.ceil(n.duration*t)),t),o=r.createBufferSource();o.buffer=n,o.connect(r.destination),o.start();let i=(await r.startRendering()).getChannelData(0),a=new DataView(new ArrayBuffer(44+i.length*2)),s=(l,c)=>{for(let d=0;d<c.length;d++)a.setUint8(l+d,c.charCodeAt(d))};s(0,"RIFF"),a.setUint32(4,36+i.length*2,!0),s(8,"WAVE"),s(12,"fmt "),a.setUint32(16,16,!0),a.setUint16(20,1,!0),a.setUint16(22,1,!0),a.setUint32(24,t,!0),a.setUint32(28,t*2,!0),a.setUint16(32,2,!0),a.setUint16(34,16,!0),s(36,"data"),a.setUint32(40,i.length*2,!0);for(let l=0;l<i.length;l++)a.setInt16(44+l*2,Math.round(Math.max(-1,Math.min(1,i[l]))*32767),!0);return{blob:new Blob([a.buffer],{type:"audio/wav"}),seconds:n.duration}}var R0=class{#t;#n=new Set;#o;#s={status:"idle"};#r=0;#i;#l;#a;#c=!1;constructor(t){this.#t=t,this.#o=t.registerAudition(()=>this.stop())}snapshot=()=>this.#s;subscribe=t=>(this.#n.add(t),()=>{this.#n.delete(t)});#f(t){this.#s=t;for(let n of this.#n)n()}#u(){this.#i?.abort(),this.#i=void 0;let t=this.#l;this.#l=void 0,t&&(t.onended=null,t.onerror=null,t.pause(),t.removeAttribute("src"),t.load()),this.#a&&URL.revokeObjectURL(this.#a),this.#a=void 0}stop(){this.#r++,this.#u(),this.#c||this.#f({status:"idle"})}async play(t){if(this.#t.stopAuditions(),this.#c)return;let n=this.#r,r=new AbortController;this.#i=r;let o=()=>!this.#c&&this.#r===n&&!r.signal.aborted;this.#f({status:"loading"});try{if(await this.#t.pausePlayback(!0),!o())return;let i=await t(r.signal);if(!o())return;let a=new Audio;if(this.#l=a,a.preload="auto",a.src=typeof i.audio=="string"?i.audio:this.#a=URL.createObjectURL(i.audio),a.onended=()=>{o()&&this.stop()},a.onerror=()=>{o()&&(this.#u(),this.#f({status:"failed",error:"audition-audio"}))},await a.play(),!o()){a.pause();return}this.#f({status:"playing"})}catch(i){if(!o())return;this.#u(),this.#f({status:"failed",error:KA(i)??(i instanceof Error&&i.message.startsWith("preview-playback-")?i.message:"audition-request")})}}dispose(){this.#c||(this.stop(),this.#c=!0,this.#o(),this.#n.clear())}};var Gt=require("react/jsx-runtime");function T3e({label:e,hint:t,value:n,disabled:r,onChange:o}){let i=tt(),a=me(T=>T.locale),s=b2[a],l=V1[a],[c]=(0,fo.useState)(()=>new e4),d=(0,fo.useSyncExternalStore)(c.subscribe,c.snapshot),[u]=(0,fo.useState)(n4),[f,p]=(0,fo.useState)(!1),[m,h]=(0,fo.useState)(),[g,v]=(0,fo.useState)({status:"idle"}),b=(0,fo.useRef)(),y=(0,fo.useRef)(null),w=(0,fo.useRef)(!0);(0,fo.useEffect)(()=>()=>{w.current=!1,c.dispose(),b.current?.dispose()},[c]);let _=async(T,I)=>{p(!0),h(void 0),b.current?.stop();try{let C=await A3e(T);w.current&&o({...C,name:I})}catch{w.current&&h(s.decodeFailed)}finally{w.current&&p(!1)}},x=d.candidate?.file;(0,fo.useEffect)(()=>{x&&_(x,l.title).finally(()=>c.discard())},[x]);let k=["requesting","recording","stopping"].includes(d.phase),S=()=>{h(void 0),c.start(async()=>(i.stopAuditions(),await i.pausePlayback(),i.registerAudioCapture(()=>c.stop())))},E=()=>{if(n){if(!b.current){let T=b.current=new R0(i);T.subscribe(()=>{w.current&&v(T.snapshot())})}g.status==="playing"||g.status==="loading"?b.current.stop():b.current.play(async()=>({audio:n.blob}))}},P=d.phase==="requesting"?l.requesting:d.phase==="recording"?l.recording:f?s.preparing:n?`${n.name} \xB7 ${s.seconds(n.seconds)}`:s.empty;return(0,Gt.jsxs)(Ut,{label:e,hint:t,group:!0,children:[(0,Gt.jsx)("span",{className:"pm-ui-hint",role:"status",children:P}),(d.error||u)&&!k&&(0,Gt.jsx)(ke,{tone:"warn",children:l.failures[d.error??u]??l.failures["recording-failed"]}),m&&(0,Gt.jsx)(ke,{tone:"danger",children:m}),(0,Gt.jsxs)("div",{className:"pmw-voice__actions",children:[d.phase==="recording"?(0,Gt.jsx)(he,{small:!0,variant:"primary",onClick:()=>c.stop(),children:s.stop}):(0,Gt.jsx)(he,{small:!0,disabled:r||k||f||!!u,onClick:S,children:s.record}),(0,Gt.jsx)(he,{small:!0,disabled:r||k||f,onClick:()=>y.current?.click(),children:s.choose}),n&&(0,Gt.jsx)(he,{small:!0,icon:"audio",disabled:k||f,loading:g.status==="loading",onClick:E,children:g.status==="playing"?s.stopListening:s.listen}),n&&(0,Gt.jsx)(he,{small:!0,disabled:r||k||f,onClick:()=>{b.current?.stop(),o(void 0)},children:s.clear})]}),(0,Gt.jsx)("input",{ref:y,hidden:!0,type:"file",accept:"audio/*,.wav,.mp3,.m4a,.ogg,.webm",onChange:T=>{let I=T.currentTarget.files?.[0];T.currentTarget.value="",I&&_(I,I.name)}})]})}function I3e({directory:e,engine:t,lang:n,onUse:r,onClose:o}){let i=tt(),a=me(J=>J.locale),s=b2[a],l=t.id==="volcengine",[c,d]=(0,fo.useState)(""),[u,f]=(0,fo.useState)(""),[p,m]=(0,fo.useState)(s.defaultScope),[h,g]=(0,fo.useState)(),[v,b]=(0,fo.useState)(),[y,w]=(0,fo.useState)(!1),[_,x]=(0,fo.useState)(!1),[k,S]=(0,fo.useState)(),[E,P]=(0,fo.useState)(),[T,I]=(0,fo.useState)(0),C=(0,fo.useRef)();(0,fo.useEffect)(()=>()=>C.current?.abort(),[]);let A=c.trim(),R=!!A&&!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(A),O=E?.state==="ready",L=_||O,D=!!(A&&!R&&u.trim()&&p.trim()&&h&&v)&&!L,$=async()=>{let J=new AbortController;C.current?.abort(),C.current=J,w(!1),x(!0),S(void 0),P(void 0),I(0);let te=V=>new Promise((ee,Y)=>{let G=setTimeout(ee,V);J.signal.addEventListener("abort",()=>{clearTimeout(G),Y(J.signal.reason)},{once:!0})});try{let V=await i.client.cloneVoice(e,{engine:t.id,voice:A,lang:n,speaker:u.trim(),scope:p.trim(),sample:v.blob,statement:h.blob},J.signal);P(V);let ee=Date.now();for(;V.state==="training"&&Date.now()-ee<10*6e4;)await te(3e3),V=await i.client.readCloneStatus(e,A,t.id,J.signal),P(V),I(Date.now()-ee)}catch(V){J.signal.aborted||S(E3e(V,a))}finally{C.current===J&&(C.current=void 0,x(!1))}},j=()=>{C.current?.abort(),o()};return(0,Gt.jsxs)(Gt.Fragment,{children:[(0,Gt.jsx)(kn,{open:!0,label:s.title,closeLabel:s.close,description:s.description,onClose:j,footer:(0,Gt.jsxs)(Gt.Fragment,{children:[(0,Gt.jsx)(he,{onClick:j,children:s.close}),O?(0,Gt.jsx)(he,{variant:"primary",onClick:()=>r(A),children:s.use}):(0,Gt.jsx)(he,{variant:"primary",loading:_,disabled:!D,onClick:()=>w(!0),children:s.train})]}),children:(0,Gt.jsxs)("div",{className:"pmw-voice__form",children:[k&&(0,Gt.jsx)(ke,{tone:"danger",children:k}),E&&(0,Gt.jsx)(ke,{tone:E.state==="ready"?"ok":E.state==="failed"?"danger":"accent",children:(0,Gt.jsx)("span",{role:"status",children:s.state(E,T)})}),(0,Gt.jsx)(Kn,{label:s.voice,hint:s.voiceHint(l),error:R?s.voiceInvalid:void 0,value:c,maxLength:128,spellCheck:!1,autoComplete:"off",disabled:L,onChange:J=>d(J.target.value)}),(0,Gt.jsx)(Kn,{label:s.speaker,hint:s.speakerHint,value:u,maxLength:80,disabled:L,onChange:J=>f(J.target.value)}),(0,Gt.jsx)(Kn,{label:s.scope,hint:s.scopeHint,value:p,maxLength:200,disabled:L,onChange:J=>m(J.target.value)}),(0,Gt.jsx)(Ut,{label:s.statementLabel,children:(0,Gt.jsx)("p",{className:"pmw-voice__sample",children:s.statementText(u.trim()||s.someone,p.trim()||s.defaultScope)})}),(0,Gt.jsx)(T3e,{label:s.statement,hint:s.statementHint,value:h,disabled:L,onChange:g}),(0,Gt.jsx)(Ut,{label:s.passageLabel,children:(0,Gt.jsx)("p",{className:"pmw-voice__sample",children:s.passage})}),(0,Gt.jsx)(T3e,{label:s.sample,hint:s.sampleHint,value:v,disabled:L,onChange:b}),v&&(v.seconds<10||v.seconds>30)&&(0,Gt.jsx)(ke,{tone:"warn",children:s.sampleLength(v.seconds)})]})}),(0,Gt.jsx)(kn,{open:y,label:s.confirmTitle,closeLabel:s.cancel,description:s.confirmHint,onClose:()=>w(!1),footer:(0,Gt.jsxs)(Gt.Fragment,{children:[(0,Gt.jsx)(he,{onClick:()=>w(!1),children:s.cancel}),(0,Gt.jsx)(he,{variant:"primary",onClick:()=>void $(),children:s.confirm})]}),children:(0,Gt.jsxs)("div",{className:"pmw-voice__form",children:[(0,Gt.jsx)(Ut,{label:s.voice,children:(0,Gt.jsx)("span",{children:A})}),(0,Gt.jsx)(Ut,{label:s.speaker,children:(0,Gt.jsx)("span",{children:u.trim()})}),(0,Gt.jsx)(Ut,{label:s.scope,children:(0,Gt.jsx)("span",{children:p.trim()})}),(0,Gt.jsx)(ke,{tone:"warn",children:s.costs(t.provider,l)})]})})]})}var kf=require("react");var Vo=require("react/jsx-runtime");function R3e({quote:e,snapshot:t,onClose:n,onRecheck:r}){let o=tt(),i=me(k=>k.locale),a=oh[i],s=me(()=>Sa(o,t)),l=(0,kf.useRef)(),c=(0,kf.useRef)(0),d=(0,kf.useRef)(!1),[u,f]=(0,kf.useState)({status:"idle"}),[p,m]=(0,kf.useState)(),[h,g]=(0,kf.useState)(!1),v=e.revision===t.revision&&e.source.documentId===t.source.documentId&&e.source.version===t.source.version&&e.source.fingerprint===t.source.fingerprint;(0,kf.useEffect)(()=>{let k=++c.current,S=new R0(o);d.current=!1,l.current=S,f(S.snapshot()),m(void 0),g(!1);let E=S.subscribe(()=>{c.current===k&&!d.current&&f(S.snapshot())});return()=>{c.current++,E(),S.dispose(),l.current===S&&(l.current=void 0)}},[o,e,t]),(0,kf.useEffect)(()=>{s&&v||(g(!0),l.current?.stop())},[s,v]);let b=()=>{d.current||(d.current=!0,c.current++,l.current?.dispose(),n())},y=()=>{l.current?.stop(),r?.()},w=()=>{let k=l.current,S=c.current;!k||d.current||h||!v||!Sa(o,t)||(m(void 0),k.play(async E=>{try{if(!Sa(o,t))throw new Error("voice-context-changed");let P=await o.client.previewVoice(t.directory,{revision:e.revision,source:e.source,voice:e.voice,mode:e.mode,...e.target?{target:e.target}:{},quote:e.quote,confirmed:!0},E);if(E.throwIfAborted(),c.current!==S||d.current||!Sa(o,t)||P.revision!==e.revision||P.source.documentId!==e.source.documentId||P.source.version!==e.source.version||P.source.fingerprint!==e.source.fingerprint)throw new Error("voice-context-changed");return{audio:P.audio}}catch(P){throw c.current===S&&!d.current&&!E.aborted&&(m(Ki(P,i)),P instanceof Error&&["voice-context-changed","voice-source-changed","voice-source-unavailable","voice-revision-changed","voice-preview-changed"].includes(P.message)&&g(!0)),P}}))},_=h||!s||!v,x=u.status==="loading"||u.status==="playing";return(0,Vo.jsx)(kn,{open:!0,label:e.mode==="step"?a.currentScript:a.standard,description:a.previewHint,closeLabel:a.close,onClose:b,footer:(0,Vo.jsxs)(Vo.Fragment,{children:[(0,Vo.jsx)(he,{small:!0,onClick:b,children:a.close}),_&&r&&(0,Vo.jsx)(he,{small:!0,onClick:y,children:a.recheck}),x?(0,Vo.jsx)(he,{small:!0,onClick:()=>l.current?.stop(),children:a.stop}):(0,Vo.jsx)(he,{small:!0,variant:"accent",disabled:_||!l.current,onClick:w,children:a.confirmPreview})]}),children:(0,Vo.jsxs)("div",{className:"pmw-operation",children:[(0,Vo.jsx)(Ut,{label:a.provider,children:(0,Vo.jsx)("span",{children:e.provider})}),(0,Vo.jsx)(Ut,{label:a.currentVoice,children:(0,Vo.jsx)("span",{children:e.voice.voice})}),e.target&&(0,Vo.jsx)(Ut,{label:a.scope,children:(0,Vo.jsxs)("span",{children:[t.ir.sections.find(k=>k.id===e.target?.section)?.title," \xB7 ",a.step(t.ir.sections.findIndex(k=>k.id===e.target?.section)+1,e.target.step+1)]})}),(0,Vo.jsx)(Ut,{label:e.mode==="step"?a.currentScript:a.sampleText,children:(0,Vo.jsx)("p",{className:"pmw-voice__sample",children:e.text})}),(0,Vo.jsx)(ke,{children:e.cached?a.cachedPreview:a.disclosure(e.provider,e.local)}),_&&(0,Vo.jsx)(ke,{tone:"warn",children:a.changed}),u.status==="loading"&&(0,Vo.jsx)(ke,{children:a.auditionLoading}),u.status==="playing"&&(0,Vo.jsx)(ke,{tone:"accent",children:a.auditioning}),(p||u.status==="failed")&&(0,Vo.jsx)(ke,{tone:"danger",children:p??Ki(new Error(u.error),i)})]})})}var Mp=require("react/jsx-runtime");function uD({document:e,stepId:t,value:n,disabled:r,onChange:o}){let i=me(c=>c.locale),a=oh[i],s=Gi[i],l=e.steps[t]?.sectionId;return(0,Mp.jsxs)(Mp.Fragment,{children:[(0,Mp.jsx)(Ut,{label:a.scope,group:!0,children:(0,Mp.jsx)(Wc,{label:a.scope,value:n.kind,options:["step","steps","page","document"].map(c=>({value:c,label:s.scopeShort[c]})),disabled:r,onChange:c=>{c==="document"?o({kind:c}):c==="page"&&l?o({kind:c,sectionId:l}):c==="step"?o({kind:c,stepId:t}):c==="steps"&&o({kind:c,stepIds:[t]})}})}),n.kind==="steps"&&(0,Mp.jsx)(Ut,{label:a.selectedSteps,group:!0,hint:a.selected(n.stepIds.length),error:n.stepIds.length?void 0:s.selectSteps,children:(0,Mp.jsx)("div",{className:"pmw-voice__steps",children:e.sectionOrder.flatMap((c,d)=>e.sections[c].stepOrder.map((u,f)=>{let p=n.stepIds.includes(u);return(0,Mp.jsxs)(he,{small:!0,"aria-label":`${e.sections[c].title} \xB7 ${a.step(d+1,f+1)}`,"aria-pressed":p,disabled:r,onClick:()=>o({kind:"steps",stepIds:p?n.stepIds.filter(m=>m!==u):[...n.stepIds,u]}),children:[d+1," \xB7 ",f+1]},u)}))})})]})}var ot=require("react/jsx-runtime"),M3e=(e,t)=>!e.length||e.some(n=>n.toLowerCase().split("-")[0]===t.toLowerCase().split("-")[0]);function D3e({stepId:e,onClose:t}){let n=tt(),r=me(oe=>oe.authoring),o=me(oe=>oe.locale),i=me(oe=>!!(oe.authoring?.loading||oe.authoring?.composing)||Wt(oe)),a=oh[o],s=Gi[o],l=b2[o],c=me(oe=>oe.voiceServiceVersion),d=(0,Ho.useRef)(r.identity).current,u=(0,Ho.useRef)(r.directory).current,[f]=(0,Ho.useState)(()=>S3e(n.client,d,e)),[p,m]=(0,Ho.useState)(()=>f??{version:r.version,scope:{kind:"step",stepId:e},source:od(r.content,e).value??null,replaceOverrides:!1}),[h,g]=(0,Ho.useState)(()=>_3e(n.client,d,e)!=="available"),[v,b]=(0,Ho.useState)(p.source?.type==="tts"?p.source.voice.engine:void 0),[y,w]=(0,Ho.useState)(""),[_,x]=(0,Ho.useState)(""),[k,S]=(0,Ho.useState)(),[E,P]=(0,Ho.useState)(!0),[T,I]=(0,Ho.useState)(),[C,A]=(0,Ho.useState)(0),[R,O]=(0,Ho.useState)(!1),[L,D]=(0,Ho.useState)(),[$,j]=(0,Ho.useState)(),[J,te]=(0,Ho.useState)(),[V,ee]=(0,Ho.useState)(!1),Y=(0,Ho.useRef)({active:!0,generation:0}),G=(0,Ho.useRef)();(0,Ho.useEffect)(()=>()=>{Y.current.active=!1,Y.current.generation++,G.current?.abort()},[]),(0,Ho.useEffect)(()=>{let oe=new AbortController;return P(!0),I(void 0),n.client.readVoiceCatalog(u,v,void 0,oe.signal).then(be=>{oe.signal.aborted||S(be)},be=>{oe.signal.aborted||I(Ki(be,o))}).finally(()=>{oe.signal.aborted||P(!1)}),()=>oe.abort()},[n,u,v,C,r?.reset,o,c]);let F=r?.content,B=r?.identity===d&&!!F?.steps[e],z=v??k?.engine,q=k?.engines.filter(oe=>oe.tts)??[],Z=q.find(oe=>oe.id===(p.source?.type==="tts"?p.source.voice.engine??z:z)),X=k?.catalog.status==="available"?k.catalog.voices:[],K=F?.metadata.lang??"zh-CN",ue=[...new Set(X.flatMap(oe=>oe.lang))].sort(),ie=Z?.parameters?.rate,W=Z?.parameters?.styles,le=p.rateInput?.normalize("NFKC").trim(),ae=le?Number(le):void 0,ne=p.rateInput!==void 0&&le!==void 0&&le.length>0&&(!ie||!/^\d+(?:\.\d+)?$/.test(le)||!Number.isFinite(ae)||ae<ie.min||ae>ie.max),re=p.source===null?"inherit":p.source.type,ye=()=>Y.current.active&&n.getState().authoring?.identity===d,fe=oe=>{G.current?.abort(),Y.current.generation++,O(!1),D(void 0),j(void 0),te(void 0),n.stopAuditions(),m(oe),g(!DY(n.client,d,e,oe))},we=oe=>({...oe,version:n.getState().authoring.version}),Pe=async(oe=p)=>{if(!ye()||!B||i||oe.source?.type==="tts"&&(ne||!oe.source.voice.voice.trim()))return;let be=++Y.current.generation,Ye=new AbortController;G.current?.abort(),G.current=Ye,O(!0),D(void 0);try{if(await n.flushPendingEdits(Ye.signal),!ye()||be!==Y.current.generation)return;let Ae=n.getState().authoring,Ze=n.getDocument(d);if(!Ae?.version||!Ae.fingerprint||!Ze||Ae.dirty||Ae.saving||Ae.error||Ae.restored||Ae.composing)throw new Error("voice-context-changed");let We=we(oe),Ht=rT(Ze,We.scope,We.source,{replaceOverrides:We.replaceOverrides});m(We),g(!DY(n.client,d,e,We));let rr=dg(Ze,We.scope).map(Rr=>{let _r=Ze.steps[Rr],or=Ze.sections[_r.sectionId];return`${or.title} \xB7 ${a.step(Ze.sectionOrder.indexOf(or.id)+1,or.stepOrder.indexOf(Rr)+1)}`});j({draft:We,impact:Ht,scopeLabel:a.scopes[We.scope.kind],targets:rr,expected:{identity:d,version:Ae.version,fingerprint:Ae.fingerprint}})}catch(Ae){ye()&&be===Y.current.generation&&D(Ki(Ae,o))}finally{ye()&&be===Y.current.generation&&O(!1)}},xe=async()=>{if(!$||!ye())return;let oe=$,be=++Y.current.generation;O(!0),D(void 0);try{let Ye=await n.applyDocumentVoice(oe.draft.scope,oe.draft.source,{replaceOverrides:oe.draft.replaceOverrides},oe.expected);if(!ye()||be!==Y.current.generation)return;if(!Ye)throw new Error("voice-context-changed");if(!C3e(n.client,d,e,oe.draft)){g(!0),j(void 0);return}t()}catch(Ye){ye()&&be===Y.current.generation&&(j(void 0),D(Ki(Ye,o)))}finally{ye()&&be===Y.current.generation&&O(!1)}},ve=async oe=>{if(p.source?.type!=="tts"||ne||!B||i)return;let be=++Y.current.generation,Ye=new AbortController,Ae=p.source.voice;G.current?.abort(),G.current=Ye,O(!0),D(void 0);try{let Ze=await y2(n,e,Ye.signal),We=await n.client.readVoicePreview(u,{revision:Ze.revision,voice:Ae,mode:oe,...oe==="step"?{target:Ze.target}:{}},Ye.signal);if(!ye()||be!==Y.current.generation)return;if(!Sa(n,Ze)||We.source.version!==Ze.source.version||We.source.fingerprint!==Ze.source.fingerprint||We.source.documentId!==Ze.source.documentId)throw new Error("voice-context-changed");te({quote:We,snapshot:Ze})}catch(Ze){ye()&&be===Y.current.generation&&D(Ki(Ze,o))}finally{ye()&&be===Y.current.generation&&O(!1)}},de=!!($&&r?.version===$.expected.version&&r.fingerprint===$.expected.fingerprint&&!r.dirty&&!r.saving&&!r.error&&!i);return!F||!B?(0,ot.jsx)(kn,{open:!0,label:a.settings,closeLabel:a.close,onClose:t,children:(0,ot.jsx)(ke,{tone:"warn",children:s.draftChanged})}):(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsx)(kn,{open:!0,label:a.settings,closeLabel:a.close,onClose:t,footer:(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsx)(he,{onClick:t,children:a.close}),(0,ot.jsx)(he,{loading:R,disabled:i||ne||p.source?.type==="tts"&&!p.source.voice.voice.trim()||p.scope.kind==="steps"&&!p.scope.stepIds.length,variant:"primary",onClick:()=>void Pe(),children:a.check})]}),children:(0,ot.jsxs)("div",{className:"pmw-voice__form",children:[f&&(0,ot.jsx)(ke,{tone:"accent",children:a.draftRecovered}),h&&(0,ot.jsx)(ke,{tone:"warn",children:a.recoveryFailed}),L&&(0,ot.jsx)(ke,{tone:"danger",children:L}),(0,ot.jsx)(uD,{document:F,stepId:e,value:p.scope,disabled:R||i,onChange:oe=>fe({...p,scope:oe,replaceOverrides:oe.kind==="steps"&&p.source===null?!0:oe.kind==="step"?!1:p.replaceOverrides})}),(0,ot.jsx)(Ut,{label:a.source,group:!0,children:(0,ot.jsx)(Wc,{label:a.source,value:re,disabled:R||i,options:[{value:"tts",label:a.voice},{value:"none",label:s.none},{value:"inherit",label:a.inherit},...re==="recording"?[{value:"recording",label:s.recording}]:[]],onChange:oe=>{oe==="none"?fe({...p,source:{type:"none"},rateInput:void 0}):oe==="inherit"?fe({...p,source:null,rateInput:void 0,replaceOverrides:p.scope.kind==="steps"?!0:p.replaceOverrides}):oe==="tts"&&fe({...p,source:{type:"tts",voice:{...z?{engine:z}:{},voice:""}},rateInput:void 0})}})}),p.source?.type==="recording"&&(0,ot.jsx)("span",{children:F.assets[p.source.assetId]?.title||s.recording}),p.source?.type==="tts"&&(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsxs)(sr,{label:a.provider,value:z??"",disabled:!q.length||R||i,onChange:oe=>{b(oe.target.value),w(""),x("")},children:[!q.length&&(0,ot.jsx)("option",{value:z??"",children:z?`${z} \xB7 ${a.savedEngineUnavailable}`:a.noServiceOption}),q.map(oe=>(0,ot.jsxs)("option",{value:oe.id,children:[oe.id," \xB7 ",oe.provider]},oe.id)),z&&q.length>0&&!q.some(oe=>oe.id===z)&&(0,ot.jsxs)("option",{value:z,children:[z," \xB7 ",a.savedEngineUnavailable]})]}),T&&(0,ot.jsx)(he,{small:!0,onClick:()=>A(oe=>oe+1),children:a.retry}),k?.catalog.status==="unavailable"&&(0,ot.jsx)(ke,{tone:"warn",children:k.catalog.reason==="not-configured"?a.noService:a.catalogUnsupported}),X.length>0&&(0,ot.jsxs)(sr,{label:a.language,value:y,disabled:R||i,onChange:oe=>w(oe.target.value),children:[(0,ot.jsx)("option",{value:"",children:a.allLanguages}),ue.map(oe=>(0,ot.jsx)("option",{value:oe,children:oe},oe))]}),(E||T||k?.catalog.status==="available")&&(0,ot.jsx)(mw,{label:a.available,searchLabel:a.search,searchPlaceholder:a.searchPlaceholder,emptyLabel:a.empty,loadingLabel:a.loadingVoices,loading:E,error:T,disabled:R||i||k?.catalog.status!=="available",query:_,onQueryChange:x,value:p.source.voice.engine===z||!p.source.voice.engine?p.source.voice.voice:void 0,items:X.filter(oe=>!y||oe.lang.includes(y)).map(oe=>({value:oe.id,label:oe.label,description:[oe.lang.join(", "),oe.cloned?l.cloned:"",M3e(oe.lang,K)?"":a.languageMismatch].filter(Boolean).join(" \xB7 "),keywords:[oe.id,...oe.lang,z??""],disabled:!M3e(oe.lang,K)})),resultsLabel:a.results,onValueChange:oe=>fe({...p,source:{type:"tts",voice:{...z?{engine:z}:{},voice:oe}},rateInput:void 0})}),Z?.clone&&(0,ot.jsx)("div",{className:"pmw-voice__actions",children:(0,ot.jsx)(he,{small:!0,disabled:R||i,onClick:()=>ee(!0),children:l.open})}),(0,ot.jsx)(Ut,{label:s.selectedVoice,children:(0,ot.jsx)("span",{children:p.source.voice.voice||a.unset})}),ie&&(0,ot.jsx)(Kn,{label:a.rate,width:"number",inputMode:"decimal",maxLength:32,value:p.rateInput??(p.source.voice.rate===void 0?"":String(p.source.voice.rate)),error:ne?a.rateInvalid(ie.min,ie.max):void 0,disabled:R||i,onChange:oe=>{if(p.source?.type!=="tts")return;let be=oe.target.value,Ye=be.normalize("NFKC").trim(),Ae=Number(Ye),Ze=/^\d+(?:\.\d+)?$/.test(Ye)&&Number.isFinite(Ae)&&Ae>=ie.min&&Ae<=ie.max,We={...p.source.voice};Ye?Ze&&(We.rate=Ae):delete We.rate,fe({...p,rateInput:be,source:{type:"tts",voice:We}})}}),W?.length?(0,ot.jsxs)(sr,{label:a.style,value:p.source.voice.style??"",disabled:R||i,onChange:oe=>{if(p.source?.type!=="tts")return;let be={...p.source.voice};oe.target.value?be.style=oe.target.value:delete be.style,fe({...p,source:{type:"tts",voice:be}})},children:[(0,ot.jsx)("option",{value:"",children:a.styleDefault}),W.map(oe=>(0,ot.jsx)("option",{value:oe,children:oe},oe))]}):null,p.rateInput!==void 0&&!ie&&(0,ot.jsxs)(ke,{tone:"warn",children:[s.draftChanged," ",(0,ot.jsx)(he,{small:!0,onClick:()=>fe({...p,rateInput:void 0}),children:a.recheck})]}),(0,ot.jsxs)("div",{className:"pmw-voice__actions",children:[(0,ot.jsx)(he,{small:!0,icon:"audio",disabled:R||i||!p.source.voice.voice||ne,onClick:()=>void ve("sample"),children:a.standard}),(0,ot.jsx)(he,{small:!0,icon:"audio",disabled:R||i||!p.source.voice.voice||ne,onClick:()=>void ve("step"),children:s.currentScript})]}),(0,ot.jsx)("p",{className:"pmw-pane__footer",children:a.previewHint})]}),p.scope.kind!=="step"&&!(p.scope.kind==="steps"&&p.source===null)&&(0,ot.jsx)(Ut,{label:a.replace,group:!0,children:(0,ot.jsx)(Wc,{label:a.replace,value:p.replaceOverrides?"replace":"preserve",disabled:R||i,options:[{value:"preserve",label:a.preserve},{value:"replace",label:a.replaceAll}],onChange:oe=>fe({...p,replaceOverrides:oe==="replace"})})})]})}),(0,ot.jsx)(kn,{open:!!$,label:$?.draft.source===null?s.restoreTitle:s.applyTitle,closeLabel:a.close,onClose:()=>j(void 0),busy:R,description:$?.draft.source===null?s.restoreHint:s.applyHint,footer:(0,ot.jsxs)(ot.Fragment,{children:[(0,ot.jsx)(he,{disabled:R,onClick:()=>j(void 0),children:a.cancel}),(0,ot.jsx)(he,{loading:R,disabled:!de,variant:$?.draft.replaceOverrides&&$.impact.overrides.pages+$.impact.overrides.steps>0?"danger":"primary",onClick:()=>void xe(),children:$?.draft.replaceOverrides&&$.impact.overrides.pages+$.impact.overrides.steps>0?s.replaceCount($.impact.overrides.pages+$.impact.overrides.steps):a.apply})]}),children:$&&(0,ot.jsxs)("div",{className:"pmw-voice__form",children:[(0,ot.jsx)(Ut,{label:a.source,children:(0,ot.jsx)("span",{children:$.draft.source===null?a.inherit:$.draft.source.type==="none"?s.none:$.draft.source.type==="recording"?F.assets[$.draft.source.assetId]?.title||s.recording:`${$.draft.source.voice.voice}${$.draft.source.voice.engine?` \xB7 ${$.draft.source.voice.engine}`:""}`})}),$.draft.source?.type==="tts"&&(0,ot.jsxs)(ot.Fragment,{children:[$.draft.source.voice.rate!==void 0&&(0,ot.jsx)(Ut,{label:a.rate,children:(0,ot.jsx)("span",{children:$.draft.source.voice.rate})}),$.draft.source.voice.style&&(0,ot.jsx)(Ut,{label:a.style,children:(0,ot.jsx)("span",{children:$.draft.source.voice.style})})]}),(0,ot.jsx)(Ut,{label:a.scope,children:(0,ot.jsx)("span",{children:$.scopeLabel})}),(0,ot.jsxs)("details",{children:[(0,ot.jsx)("summary",{children:a.selected($.targets.length)}),(0,ot.jsx)("ul",{children:$.targets.map(oe=>(0,ot.jsx)("li",{children:oe},oe))})]}),(0,ot.jsx)("p",{children:s.counts($.impact.updated,$.impact.preserved,$.impact.unchanged)}),(0,ot.jsx)("p",{children:s.overridden($.impact.overrides.none,$.impact.overrides.recording)}),$.draft.replaceOverrides&&(0,ot.jsxs)(ke,{tone:"warn",children:[a.replaceAll," ",s.keepAssets]}),!de&&(0,ot.jsx)(ke,{tone:"warn",children:s.draftChanged})]})}),V&&Z&&(0,ot.jsx)(I3e,{directory:u,engine:Z,lang:K,onClose:()=>ee(!1),onUse:oe=>{ee(!1),A(be=>be+1),fe({...p,source:{type:"tts",voice:{engine:Z.id,voice:oe}},rateInput:void 0})}}),J&&(0,ot.jsx)(R3e,{quote:J.quote,snapshot:J.snapshot,onClose:()=>te(void 0),onRecheck:()=>{let oe=J.quote.mode;te(void 0),ve(oe)}})]})}var Mu=require("react/jsx-runtime");function O3e({stepId:e,disabled:t=!1,onGenerate:n}){let r=tt(),o=me(h=>h.authoring),i=me(h=>h.locale),a=me(h=>!!(h.authoring?.loading||h.authoring?.composing)||Wt(h)),[s,l]=(0,fD.useState)(!1);(0,fD.useEffect)(()=>{l(!1)},[o?.identity,e]);let c=o?.content,d=c?.steps[e],u=Gi[i];if(!c||!d||!o?.identity)return null;let f=od(c,e),p=f.value?.type==="recording"?c.assets[f.value.assetId]:void 0,m=f.value?.type==="tts"?f.value.voice.voice:f.value?.type==="none"?u.none:f.value?.type==="recording"?p?.title||u.recording:u.unset;return(0,Mu.jsxs)(Mu.Fragment,{children:[(0,Mu.jsxs)(Ut,{group:!0,label:u.voice,hint:u.inherited[f.inheritedFrom],children:[(0,Mu.jsx)("span",{children:m}),(0,Mu.jsxs)("div",{className:"pmw-voice__actions",children:[(0,Mu.jsx)(he,{small:!0,icon:"audio",disabled:t||a,onClick:()=>{r.pauseDocumentStep(d.sectionId,e),r.stopAuditions(),l(!0)},children:u.choose}),n&&(0,Mu.jsx)(he,{small:!0,icon:"refresh",disabled:t||a,onClick:n,children:u.generate}),r.client.openSpeechSettings&&(0,Mu.jsx)(he,{small:!0,variant:"ghost",icon:"sliders",onClick:()=>{r.stopAuditions(),r.pausePlayback(!0).catch(()=>{}),r.client.openSpeechSettings?.()},children:u.serviceSettings})]})]}),s&&(0,Mu.jsx)(D3e,{stepId:e,onClose:()=>l(!1)},`${o.identity}:${e}`)]})}var zr=require("react");var Ir=require("react/jsx-runtime"),rdt=[],w2=e=>["queued","running","cancelling"].includes(e.state),pD=(e,t)=>e.documentId===t.documentId&&e.version===t.version&&e.fingerprint===t.fingerprint,N3e=e=>e.map(t=>`${t.id}:${t.sequence}`).join(",");function odt(e,t){if(e.kind==="document")return!0;if(t.kind==="document")return!1;if(t.kind==="page")return e.kind==="page"&&e.section===t.section;let n=t.kind==="step"?[t.target]:t.targets;if(e.kind==="page")return n.every(o=>o.section===e.section);let r=e.kind==="step"?[e.target]:e.targets;return n.every(o=>r.some(i=>i.section===o.section&&i.step===o.step&&i.binding===o.binding))}function F3e({stepId:e,onClose:t}){let n=tt(),r=me(W=>W.locale),o=oh[r],i=me(W=>W.authoring),a=me(W=>W.voiceServiceVersion),s=me(W=>W.voiceoverJobs)??rdt,l=me(W=>W.voiceoverJobsFailure),c=me(W=>!!(W.authoring?.loading||W.authoring?.composing)||Wt(W)),[d,u]=(0,zr.useState)({kind:"step",stepId:e}),[f,p]=(0,zr.useState)(),[m,h]=(0,zr.useState)(),[g,v]=(0,zr.useState)(!0),[b,y]=(0,zr.useState)(!1),[w,_]=(0,zr.useState)(),[x,k]=(0,zr.useState)(!1),[S,E]=(0,zr.useState)(),[P,T]=(0,zr.useState)(0),I=(0,zr.useRef)(),C=(0,zr.useRef)(),A=(0,zr.useRef)(),R=(0,zr.useRef)(0),O=(0,zr.useRef)(!1),L=(0,zr.useRef)(),D=(0,zr.useRef)(""),$=(0,zr.useRef)(new Map),j=(0,zr.useRef)(!1),J=(0,zr.useRef)(n.getState().document),te=()=>{for(let[W,{directory:le}]of $.current){let ae=n.getState().voiceoverJobs?.find(ne=>ne.id===W);(!ae||w2(ae))&&n.client.cancelVoiceover(le,W,AbortSignal.timeout(5e3)).catch(()=>{})}$.current.clear()};(0,zr.useEffect)(()=>(I.current=new AbortController,j.current=!1,J.current=n.getState().document,u({kind:"step",stepId:e}),()=>{j.current=!0,R.current++,I.current?.abort(),C.current?.abort(),A.current?.abort(),te()}),[n,e,i?.identity]),(0,zr.useEffect)(()=>n.observeVoiceoverJobs(),[n,i?.identity]),(0,zr.useEffect)(()=>{let W=new AbortController,le=++R.current;C.current?.abort(),C.current=W;let ae=AbortSignal.any([W.signal,I.current.signal]);return L.current=void 0,p(void 0),h(void 0),v(!0),E(void 0),(async()=>{try{n.stopAuditions();let ne=await y2(n,e,ae),re=n.getDocument(ne.identity);if(!re)throw new Error("voice-context-changed");let ye=await n.client.readVoiceover(ne.directory,ae);if(ae.throwIfAborted(),R.current!==le||j.current)return;if(!Sa(n,ne)||ye.revision!==ne.revision||!pD(ye.source,ne.source))throw new Error("voice-context-changed");let fe={snapshot:ne,document:re};L.current=fe,D.current=N3e(ye.jobs),p(fe),h(ye),k(!1)}catch(ne){R.current===le&&!ae.aborted&&!j.current&&E(Ki(ne,r))}finally{R.current===le&&!ae.aborted&&!j.current&&v(!1)}})(),()=>W.abort()},[n,e,P,i?.identity,a]),(0,zr.useEffect)(()=>n.subscribe(()=>{let W=L.current;!W||Sa(n,W.snapshot)||(A.current?.abort(),O.current=!1,y(!1),k(!0))}),[n]);let V=s.some(w2);(0,zr.useEffect)(()=>{let W=L.current,le=N3e(s);if(!W||!Sa(n,W.snapshot)||le===D.current)return;let ae=new AbortController,ne=AbortSignal.any([ae.signal,I.current.signal]);return(async()=>{try{let re=await n.client.readVoiceover(W.snapshot.directory,ne);if(ne.throwIfAborted(),j.current||L.current!==W)return;Sa(n,W.snapshot)&&re.revision===W.snapshot.revision&&pD(re.source,W.snapshot.source)?(D.current=le,h(re)):k(!0)}catch(re){!ne.aborted&&!j.current&&E(Ki(re,r))}})(),()=>ae.abort()},[n,s,f]);let ee=(0,zr.useMemo)(()=>{if(!(!f||!m))try{let W=dg(f.document,d),le=new Set(W),ae=m.steps.filter(Ae=>{let Ze=f.snapshot.ir.sections.find(We=>We.id===Ae.target.section);return Ze?.stepIds?.[Ae.target.step]!==void 0&&le.has(Ze.stepIds[Ae.target.step])}),ne=new Set(W.map(Ae=>f.document.steps[Ae].sectionId)),re=d.kind==="page"||d.kind==="document"?(m.unboundByPage??[]).filter(Ae=>ne.has(Ae.section)):[],ye=[...ae,...re],fe=ye.reduce((Ae,Ze)=>Ae+Ze.cached,0),we=ye.filter(Ae=>Ae.state==="missing").reduce((Ae,Ze)=>Ae+Ze.utterances-Ze.cached,0),Pe=ye.filter(Ae=>Ae.state==="blocked").reduce((Ae,Ze)=>Ae+Ze.utterances-Ze.cached,0),xe=m.capability.providers.filter(Ae=>W.some(Ze=>{let We=od(f.document,Ze).value;return We?.type==="tts"&&Ae.id===Cj(We.voice.engine??m.capability.defaultEngine??"")})),ve=W.flatMap(Ae=>f.document.steps[Ae].narrationIds.map(Ze=>f.document.narrations[Ze].content.map(We=>We.type==="text"?We.text:We.type==="pronunciation"?We.spoken:"").join(""))).join(`
|
|
1360
1360
|
|
|
1361
1361
|
`),de=[...new Map(W.flatMap(Ae=>{let Ze=od(f.document,Ae).value;return Ze?.type==="tts"?[[JSON.stringify(Ze.voice),Ze.voice]]:[]})).values()],oe=W.filter(Ae=>od(f.document,Ae).value?.type==="none").length,be=W.some(Ae=>od(f.document,Ae).value===void 0),Ye=[...new Set(ye.filter(Ae=>Ae.state==="blocked").flatMap(Ae=>Ae.reason&&!(Ae.reason==="voice-unset"&&oe&&!be)?[Ae.reason]:[]))];return{cached:fe,missing:we,blocked:Pe,providers:xe,voices:de,silent:oe,reasons:Ye,text:ve,hasUnbound:!re.length&&(m.unboundByPage??[]).some(Ae=>ne.has(Ae.section)&&Ae.utterances>0)}}catch{return}},[f,m,d]),Y=(0,zr.useMemo)(()=>{if(!f)return!1;try{let W=NY(f.snapshot,d);return s.some(le=>(w2(le)||le.state==="done"&&le.completed>0)&&pD(le.source,f.snapshot.source)&&le.revision===f.snapshot.revision&&odt(le.scope,W))}catch{return!1}},[f,s,d]),G=W=>{A.current?.abort(),O.current=!1,y(!1),u(W),E(void 0)},F=()=>{j.current||(j.current=!0,R.current++,I.current?.abort(),C.current?.abort(),A.current?.abort(),te(),t())},B=async()=>{let W=L.current;if(!W||!ee?.missing||!ee.providers.length||O.current||x||c||j.current||!Sa(n,W.snapshot))return;let le=new AbortController,ae=R.current;A.current?.abort(),A.current=le;let ne=AbortSignal.any([le.signal,I.current.signal]);O.current=!0,y(!0),E(void 0);try{if(n.stopAuditions(),await n.pausePlayback(),ne.throwIfAborted(),!Sa(n,W.snapshot))throw new Error("voice-context-changed");let re=NY(W.snapshot,d),ye=await n.client.startVoiceover(W.snapshot.directory,{revision:W.snapshot.revision,source:W.snapshot.source,scope:re,confirmed:!0},ne);if(j.current||ne.aborted||R.current!==ae){w2(ye)&&n.client.cancelVoiceover(W.snapshot.directory,ye.id,AbortSignal.timeout(5e3)).catch(()=>{});return}if(!pD(ye.source,W.snapshot.source)||ye.revision!==W.snapshot.revision||!Sa(n,W.snapshot))throw new Error("voice-context-changed");$.current.set(ye.id,{directory:W.snapshot.directory}),n.rememberVoiceoverJob(W.snapshot.directory,ye)}catch(re){!ne.aborted&&!j.current&&R.current===ae&&E(Ki(re,r))}finally{A.current===le&&(O.current=!1,j.current||y(!1))}},z=async W=>{let le=$.current.get(W.id)?.directory??L.current?.snapshot.directory??J.current;if(le===void 0||w||j.current)return;let ae=I.current.signal;_(W.id),E(void 0);try{let ne=await n.client.cancelVoiceover(le,W.id,ae);if(ae.throwIfAborted(),j.current)return;n.rememberVoiceoverJob(le,ne)}catch(ne){!ae.aborted&&!j.current&&E(Ki(ne,r))}finally{!ae.aborted&&!j.current&&_(void 0)}},q=!m?.capability.available&&(!ee?.cached||!!(ee.missing||ee.blocked)),Z=S??(l?Ki(new Error(l),r):void 0),X=q&&ee?.voices.length&&m?Ki(new Error(m.capability.reason),r):void 0,K=[...new Set([...X?[X]:[],...(ee?.reasons??[]).map(W=>Ki(new Error(W),r))])].filter(W=>W!==Z),ie=b||[...$.current.keys()].some(W=>{let le=s.find(ae=>ae.id===W);return!le||w2(le)})?o.cancelAndClose:o.close;return(0,Ir.jsx)(kn,{open:!0,label:o.generation,closeLabel:ie,onClose:F,footer:(0,Ir.jsxs)(Ir.Fragment,{children:[(0,Ir.jsx)(he,{small:!0,onClick:F,children:ie}),(0,Ir.jsx)(he,{small:!0,loading:g,disabled:b,onClick:()=>T(W=>W+1),children:x?o.recheck:o.refresh}),(0,Ir.jsx)(he,{small:!0,variant:"accent",loading:b,disabled:g||x||c||V||!ee?.missing||!ee.providers.length||!m?.capability.available,onClick:()=>void B(),children:o.confirmGenerate})]}),children:(0,Ir.jsxs)("div",{className:"pmw-operation",children:[(i?.content||f?.document)&&(0,Ir.jsx)(uD,{document:f?.document??i.content,stepId:e,value:d,disabled:g||b||c,onChange:G}),g&&(0,Ir.jsx)(ke,{children:o.refreshing}),x&&(0,Ir.jsx)(ke,{tone:"warn",children:o.changed}),Z&&(0,Ir.jsx)(ke,{tone:"danger",children:Z}),m&&ee&&(0,Ir.jsxs)(Ir.Fragment,{children:[(ee.missing>0||ee.blocked>0)&&(0,Ir.jsx)(ke,{children:o.generationSummary(ee.missing,ee.blocked)}),!x&&!Y&&!ee.missing&&!ee.blocked&&ee.cached>0&&(0,Ir.jsx)(ke,{tone:"ok",children:o.cacheReady}),!ee.missing&&!ee.cached&&!ee.blocked&&(0,Ir.jsx)(ke,{children:o.noScript}),ee.hasUnbound&&(0,Ir.jsx)(ke,{tone:"warn",children:o.unboundScript}),ee.silent>0&&(0,Ir.jsx)(ke,{children:o.silentScope(ee.silent)}),K.map(W=>(0,Ir.jsx)(ke,{tone:"warn",children:W},W)),ee.voices.map(W=>(0,Ir.jsx)(Ut,{label:o.currentVoice,children:(0,Ir.jsxs)("span",{children:[W.voice,W.engine?` \xB7 ${W.engine}`:"",W.rate!==void 0?` \xB7 ${o.rate}: ${W.rate}`:"",W.style?` \xB7 ${o.style}: ${W.style}`:""]})},JSON.stringify(W))),ee.missing>0&&ee.providers.map(W=>(0,Ir.jsx)(ke,{children:o.disclosure(W.provider,W.local)},W.id)),ee.text&&(0,Ir.jsx)(Ut,{label:o.generationScript,children:(0,Ir.jsx)("p",{className:"pmw-voice__sample",children:ee.text})})]}),s.map(W=>(0,Ir.jsxs)("div",{className:"pmw-voice__status",children:[(0,Ir.jsxs)("span",{children:[o.scopes[W.scope.kind]," \xB7 ",o.jobs[W.state]," \xB7 ",o.progress(W.completed,W.total,W.failed),i?.version!==W.source.version||i?.fingerprint!==W.source.fingerprint?` \xB7 ${o.oldVersion}`:""]}),w2(W)&&(0,Ir.jsx)(he,{small:!0,loading:w===W.id,disabled:W.state==="cancelling",onClick:()=>void z(W),children:o.cancelJob}),W.error&&(0,Ir.jsx)("span",{children:Ki(new Error(W.error),r)})]},W.id))]})})}var L3e=require("react");var k2=require("react/jsx-runtime");function B3e({identity:e,document:t,disabled:n,onChanged:r}){let o=tt(),i=me(d=>d.locale),a=Gi[i],[s,l]=(0,L3e.useState)(),c=Math.round(NT(t.production)*100);return(0,k2.jsx)(Ut,{label:a.captionSize,group:!0,hint:a.captionSizeHint,children:(0,k2.jsxs)("div",{className:"pm-ui-range-row",children:[(0,k2.jsx)(r_,{label:a.captionSize,value:c,min:Math.round(.7*100),max:Math.round(1.6*100),step:10,disabled:n,valueText:d=>`${Math.round(d)}%`,onPreviewChange:l,onValueCommit:d=>{o.setDocumentCaptionScale(d/100,e),r()}}),(0,k2.jsxs)("output",{children:[Math.round(s??c),"%"]})]})})}var Ya=require("react");var $3e={"zh-CN":{title:"\u624B\u52A8\u5B57\u5E55\u65F6\u95F4",open:"\u8BBE\u7F6E\u5B57\u5E55\u65F6\u95F4",cancel:"\u53D6\u6D88",done:"\u5B8C\u6210",apply:"\u5E94\u7528",automatic:"\u4F7F\u7528\u81EA\u52A8\u65F6\u95F4",split:"\u6309\u6362\u884C\u5206\u6BB5",start:"\u5F00\u59CB\uFF08\u79D2\uFF09",end:"\u7ED3\u675F\uFF08\u79D2\uFF09",step:"\u672C\u6B65\u9AA4 \xB7 \u65F6\u95F4\u4ECE\u6B65\u9AA4\u8D77\u70B9\u8BA1\u7B97",invalid:"\u65F6\u95F4\u987B\u9012\u589E\u4E14\u4E0D\u8D85\u51FA\u672C\u6B65\u9AA4\u3002",loading:"\u6B63\u5728\u52A0\u8F7D\u5B57\u5E55\u65F6\u95F4\u2026",prepare:"\u8BF7\u5148\u51C6\u5907\u5F53\u524D\u6B65\u9AA4\u3002",unavailable:"\u5F53\u524D\u6B65\u9AA4\u7684\u5B57\u5E55\u65F6\u95F4\u4E0D\u53EF\u7528\u3002",changed:"\u8BB2\u7A3F\u6216\u97F3\u9891\u5DF2\u53D8\u5316\u3002",recheck:"\u518D\u6B21\u68C0\u67E5",saved:"\u5B57\u5E55\u65F6\u95F4\u5DF2\u4FDD\u5B58\u5230\u5F53\u524D\u6B65\u9AA4\u3002",failed:"\u65E0\u6CD5\u786E\u8BA4\u5B57\u5E55\u65F6\u95F4\u5DF2\u4FDD\u5B58\u3002\u8F93\u5165\u5DF2\u4FDD\u7559\uFF0C\u8BF7\u91CD\u8BD5\u3002",storageFailed:"\u65E0\u6CD5\u5907\u4EFD\u5B57\u5E55\u65F6\u95F4\uFF0C\u8BF7\u4FDD\u6301\u6B64\u9875\u9762\u6253\u5F00\u3002",discard:"\u653E\u5F03\u4FEE\u6539",limit:"\u672C\u6B21\u6700\u591A\u8BBE\u7F6E 32 \u6BB5\u3002",segment:e=>`\u5B57\u5E55 ${e}`},en:{title:"Manual Caption Timing",open:"Set Caption Times",cancel:"Cancel",done:"Done",apply:"Apply",automatic:"Use Automatic Times",split:"Split at Line Breaks",start:"Start (seconds)",end:"End (seconds)",step:"Current step \xB7 Times start at the step boundary",invalid:"Times must increase and fit inside this step.",loading:"Loading caption times\u2026",prepare:"Prepare the current step first.",unavailable:"Caption timing is unavailable for this step.",changed:"The script or audio has changed.",recheck:"Check Again",saved:"Caption times saved to this step.",failed:"Couldn\u2019t confirm that caption times were saved. Your input is kept; try again.",storageFailed:"Couldn\u2019t back up caption times. Keep this page open.",discard:"Discard Changes",limit:"Set no more than 32 segments at once.",segment:e=>`Caption ${e}`}};var Yr=require("react/jsx-runtime"),z3e=(e,t)=>JSON.stringify(e)===JSON.stringify(t),FY=e=>{if(!/^\d+(?:\.\d{1,3})?$/.test(e.trim()))return;let t=Math.round(Number(e.trim())*1e3);return Number.isSafeInteger(t)?t:void 0};function j3e(e){let t=[0,...Array.from(e.matchAll(/\n+(?=[^\n]*\S)/g),r=>r.index+r[0].length),e.length],n=[];for(let r=0;r+1<t.length;r++){let o=t[r],i=t[r+1];o!==i&&(!e.slice(o,i).trim()&&n.length||n.length&&!e.slice(n.at(-1).from,n.at(-1).to).trim()?n[n.length-1].to=i:n.push({from:o,to:i}))}return n.map(r=>({...r,id:Xe(),start:"",end:""}))}function idt(e){if(!e.basis.available||!e.basis.playbackFingerprint||e.basis.durationMs===void 0)return;let t=e.rows.map(r=>({id:r.id,from:r.from,to:r.to,startMs:FY(r.start),endMs:FY(r.end)}));if(t.some(r=>r.startMs===void 0||r.endMs===void 0))return;let n={narrationIds:e.basis.narrationIds,sourceFingerprint:e.basis.sourceFingerprint,playbackFingerprint:e.basis.playbackFingerprint,durationMs:e.basis.durationMs,segments:t};return ik(n,e.text)?void 0:n}function V3e({identity:e,stepId:t,plan:n,current:r,loading:o,disabled:i,onChanged:a}){let s=tt(),l=me(Y=>Y.authoring),c=me(Y=>Y.locale),d=$3e[c],u=l?.identity===e?l.content:void 0,f=r?n?.pages.flatMap(Y=>Y.steps).find(Y=>Y.stepId===t)?.captionTiming:void 0,p=me(Y=>Y.captionTimingDraftSteps),m=me(Y=>Y.captionTimingDraftStorageFailure),[h,g]=(0,Ya.useState)(!1),[v,b]=(0,Ya.useState)(!1),[y,w]=(0,Ya.useState)(),[_,x]=(0,Ya.useState)(!1),[,k]=(0,Ya.useState)(0),S=(0,Ya.useRef)(new Map),E=(0,Ya.useRef)(!0),P=(0,Ya.useRef)(),T=(0,Ya.useRef)(!1),I=(0,Ya.useRef)(!1),C=(0,Ya.useRef)(!1),A=(0,Ya.useRef)({stepId:t,onChanged:a});if(A.current={stepId:t,onChanged:a},!S.current.has(t)){let Y=s.captionTimingDraft(t,e);Y&&S.current.set(t,Y)}let R=S.current.get(t),O=R&&idt(R),L=u?.production.captionTimings?.[t],D=!!p?.includes(t),$=R&&l?.version!==R.version||R&&f&&(!z3e(R.basis,f)||R.text!==(u&&ef(u,t))),j=!!(l?.version&&l.fingerprint&&!l.loading&&!l.dirty&&!l.saving&&!l.composing&&!l.restored&&!l.recovering&&!l.error&&!i);(0,Ya.useEffect)(()=>(E.current=!0,()=>{E.current=!1,P.current?.abort()}),[]),(0,Ya.useEffect)(()=>{P.current?.abort(),I.current=!1,g(!1),b(!1),w(void 0),x(!1)},[t]);let J=(Y,G=!0)=>{S.current.set(t,Y),G&&s.setCaptionTimingDraft(t,Y,e),x(!1),w(void 0),k(F=>F+1)},te=()=>{if(!u||!l?.version||!f)return;let Y=ef(u,t),G=u.production.captionTimings?.[t],F=G?.sourceFingerprint===um(u,t);J({version:l.version,text:Y,basis:F?{...structuredClone(f),sourceFingerprint:G.sourceFingerprint,playbackFingerprint:G.playbackFingerprint,durationMs:G.durationMs,narrationIds:[...G.narrationIds]}:structuredClone(f),rows:F?G.segments.map(B=>({id:B.id,from:B.from,to:B.to,start:String(B.startMs/1e3),end:String(B.endMs/1e3)})):j3e(Y)},!1)};(0,Ya.useEffect)(()=>{h&&I.current&&!_&&r&&f&&l?.identity===e&&!S.current.has(t)&&te()},[h,_,r,f,l?.identity,l?.version,e,t]);let V=()=>{P.current?.abort(),b(!1),I.current=!1,g(!1),T.current&&(T.current=!1,A.current.onChanged())},ee=async(Y=!1)=>{if(!u||!l?.version||!l.fingerprint||!j||v||C.current||!Y&&(!O||$||!r))return;let G=R,F=t,B={identity:e,version:l.version,fingerprint:l.fingerprint},z=new AbortController,q=Y?{type:"caption.timing.reset",stepId:t}:{type:"caption.timing.set",stepId:t,value:O};P.current=z,b(!0),w(void 0);try{let Z=await s.applyDocumentCaptionTiming(q,Xe(),B,z.signal);if(T.current=!0,!E.current||s.getState().authoring?.identity!==e)return;let X=S.current.get(F)===G;X&&(s.setCaptionTimingDraft(F,void 0,e),Y?S.current.delete(F):G&&S.current.set(F,{...G,version:Z.version})),A.current.stepId===F&&(x(X),k(K=>K+1)),I.current||(T.current=!1,A.current.onChanged())}catch(Z){E.current&&P.current===z&&!z.signal.aborted&&w(Z instanceof Error&&/source|version|playback|revision/.test(Z.message)?d.changed:d.failed)}finally{E.current&&P.current===z&&(P.current=void 0,b(!1))}};return!u?.steps[t]||!ef(u,t).trim()?null:(0,Yr.jsxs)(zf,{children:[(0,Yr.jsx)(he,{small:!0,disabled:i,onClick:()=>{S.current.has(t)||te(),x(!1),I.current=!0,g(!0)},children:d.open}),(0,Yr.jsx)(kn,{open:h,label:d.title,closeLabel:d.cancel,onClose:V,footer:(0,Yr.jsxs)(Yr.Fragment,{children:[(0,Yr.jsx)(he,{small:!0,onClick:V,children:_?d.done:d.cancel}),(0,Yr.jsx)(he,{small:!0,variant:"primary",loading:v,disabled:!j||!r||!O||!!$||z3e(O,L),onClick:()=>void ee(),children:d.apply})]}),children:(0,Yr.jsxs)("div",{className:"pmw-caption-times",onCompositionStart:()=>{C.current=!0},onCompositionEnd:()=>{C.current=!1},children:[(0,Yr.jsx)("span",{children:d.step}),!_&&f?.available===!1&&(0,Yr.jsx)(ke,{tone:"warn",children:d.unavailable}),!_&&!f&&(0,Yr.jsx)(ke,{children:o?d.loading:d.prepare}),$&&(0,Yr.jsxs)(ke,{tone:"warn",children:[d.changed,(0,Yr.jsx)(he,{small:!0,disabled:!f?.available||v||!j||R?.text!==ef(u,t),onClick:()=>{R&&f&&l?.version&&J({...R,version:l.version,basis:structuredClone(f)})},children:d.recheck})]}),R?.rows.map((Y,G)=>(0,Yr.jsxs)("section",{className:"pmw-caption-times","aria-label":d.segment(G+1),children:[(0,Yr.jsx)("p",{className:"pmw-caption-times__text",children:R.text.slice(Y.from,Y.to)}),(0,Yr.jsx)("div",{className:"pmw-caption-times__range",children:["start","end"].map(F=>(0,Yr.jsx)(Kn,{label:F==="start"?d.start:d.end,inputMode:"decimal",maxLength:32,value:Y[F],"aria-invalid":!!(Y[F]&&FY(Y[F])===void 0)||void 0,readOnly:i,onChange:B=>J({...R,rows:R.rows.map(z=>z===Y?{...Y,[F]:B.target.value}:z)})},F))})]},Y.id)),R&&R.rows.length>oT?(0,Yr.jsx)(ke,{tone:"warn",children:d.limit}):R&&R.rows.every(Y=>Y.start&&Y.end)&&!O?(0,Yr.jsx)(ke,{tone:"warn",children:d.invalid}):null,(0,Yr.jsxs)("div",{className:"pmw-caption-times__actions",children:[(0,Yr.jsx)(he,{small:!0,disabled:!f?.available||v||!j,onClick:()=>{u&&f&&l?.version&&J({version:l.version,text:ef(u,t),basis:structuredClone(f),rows:j3e(ef(u,t))})},children:d.split}),(0,Yr.jsx)(he,{small:!0,disabled:!L||v||!j,onClick:()=>void ee(!0),children:d.automatic}),D&&(0,Yr.jsx)(he,{small:!0,disabled:v,onClick:()=>{s.setCaptionTimingDraft(t,void 0,e),S.current.delete(t),te()},children:d.discard})]}),m&&(0,Yr.jsx)(ke,{tone:"warn",children:d.storageFailed}),_&&(0,Yr.jsx)(ke,{tone:"ok",children:d.saved}),y&&(0,Yr.jsx)(ke,{tone:"danger",children:y})]})})]})}var M0=require("react");function l6(){return new DOMException("Waveform reading cancelled","AbortError")}async function adt(e,t,n,r){if(r.throwIfAborted(),!e.size||e.size>16777216)throw new Error("waveform-size-limit");if(typeof OfflineAudioContext!="function")throw new Error("waveform-decoder-unavailable");let o=await e.arrayBuffer();r.throwIfAborted();let i=new OfflineAudioContext(1,1,8e3),a;try{a=await i.decodeAudioData(o)}catch{throw r.throwIfAborted(),new Error("waveform-invalid-audio")}r.throwIfAborted();let s=a.duration*1e3;if(!Number.isFinite(s)||s<=0||s>6e5)throw new Error("waveform-duration-limit");if(Math.abs(s-t)>Math.max(100,t*.01))throw new Error("waveform-duration-changed");let l=Array.from({length:n},()=>0);for(let c=0;c<a.numberOfChannels;c++){let d=a.getChannelData(c);for(let u=0;u<d.length;u++){let f=Math.min(n-1,Math.floor(u*n/d.length)),p=d[u];if(!Number.isFinite(p))throw new Error("waveform-invalid-audio");l[f]=Math.max(l[f],Math.min(1,Math.abs(p)))}}return r.throwIfAborted(),Object.freeze({durationMs:Math.round(s),peaks:Object.freeze(l)})}var mD=class{#t=[];#n=new Set;#o=new Map;#s=!1;read(t,n,r,o,i=128){if(this.#s||o?.aborted)return Promise.reject(o?.reason??l6());if(!Number.isFinite(r)||r<=0||r>6e5)return Promise.reject(new Error("waveform-duration-limit"));if(!Number.isInteger(i)||i<16||i>2048)return Promise.reject(new Error("waveform-bin-limit"));let a=JSON.stringify([t,r,i]),s=this.#o.get(a);return s?(this.#o.delete(a),this.#o.set(a,s),Promise.resolve(s)):this.#t.length>=128?Promise.reject(new Error("waveform-queue-limit")):new Promise((l,c)=>{let d=()=>{let f=this.#t.indexOf(u);f<0||(this.#t.splice(f,1),u.unlisten(),c(o?.reason??l6()))},u={key:a,load:n,durationMs:r,bins:i,signal:o,resolve:l,reject:c,unlisten:()=>o?.removeEventListener("abort",d)};o?.addEventListener("abort",d,{once:!0}),this.#t.push(u),this.#r()})}dispose(){this.#s=!0;for(let t of this.#t.splice(0))t.unlisten(),t.reject(l6());for(let t of this.#n)t.abort(l6());this.#o.clear()}#r(){for(;!this.#s&&this.#n.size<2&&this.#t.length;){let t=this.#t.shift();t.unlisten();let n=new AbortController,r=t.signal?AbortSignal.any([n.signal,t.signal]):n.signal;this.#n.add(n),(async()=>{r.throwIfAborted();let o=await adt(await t.load(r),t.durationMs,t.bins,r);if(r.throwIfAborted(),this.#s)throw l6();return this.#o.delete(t.key),this.#o.set(t.key,o),this.#o.size>24&&this.#o.delete(this.#o.keys().next().value),o})().then(t.resolve,t.reject).finally(()=>{this.#n.delete(n),this.#r()})}}};var q3e=require("react/jsx-runtime");function H3e({plan:e,sectionId:t,stepId:n,active:r,current:o,seekEnabled:i,loading:a,seeking:s,disabled:l,onSeek:c,onSelectStep:d}){let u=tt(),f=me(D=>D.locale),p=Gi[f],m=me(D=>D.authoring),h=me(D=>D.productionPlayback),g=me(D=>D.document),v=(0,M0.useRef)(),[b,y]=(0,M0.useState)({values:{}}),w=b.planId===e?.binding.planId?b.values:{},[_,x]=(0,M0.useState)(1);(0,M0.useEffect)(()=>(v.current=new mD,()=>{v.current?.dispose(),v.current=void 0}),[]),(0,M0.useEffect)(()=>{if(y({planId:e?.binding.planId,values:{}}),!r||!o||!e||g===void 0)return;let D=new AbortController,$=v.current;if(!$)return;let j=new Map(e.tracks.flatMap(J=>J.kind==="voice"?J.segments.filter(te=>te.sectionId===t&&te.status==="cached"&&te.audio).map(te=>[te.audio.clipId,te.audio]):[]));for(let J of j.values())$.read(JSON.stringify([e.binding.planId,J.clipId,J.sha256]),te=>u.client.readProductionMedia(g,{...e.binding,clipId:J.clipId},te),J.durationMs,D.signal).then(te=>{D.signal.aborted||y(V=>V.planId===e.binding.planId?{...V,values:{...V.values,[J.clipId]:te}}:V)},()=>{D.signal.aborted||y(te=>te.planId===e.binding.planId?{...te,values:{...te.values,[J.clipId]:!1}}:te)});return()=>D.abort()},[u,g,e,t,r,o]);let k=m?.content,S=k?.sections[t],E=o?e?.pages.find(D=>D.sectionId===t):void 0,P=!!(o&&e&&S&&!E),T=!!(E&&!E.steps.some(D=>D.stepId===n)),I=E?.startMs,C=E?.endMs,A=I!==void 0&&C!==void 0?Math.max(0,C-I):void 0,R=e&&o&&h&&ci(h.binding,e.binding)&&h.position?.sectionId===t&&I!==void 0?Math.max(0,h.position.timeMs-I):void 0,O=E&&e?e.tracks.map(D=>({id:D.kind,label:p.tracks[D.kind],segments:D.segments.filter($=>$.sectionId===t).map($=>{let j=k?.steps[$.stepId],J=S?.stepOrder.indexOf($.stepId)??-1,te=D.kind==="voice"&&$.audio?w[$.audio.clipId]:void 0,V=$.status?p.segmentStatus[$.status]:void 0;return{id:$.id,stepId:$.stepId,timing:$.timing,label:D.kind==="visual"?j?.title??p.stepNumber(Math.max(0,J)):$.label,...$.startMs!==void 0&&I!==void 0?{startMs:Math.max(0,$.startMs-I)}:{},...$.endMs!==void 0&&I!==void 0?{endMs:Math.max(0,$.endMs-I)}:{},statusLabel:[V,D.kind==="caption"&&p.alignmentStatus[$.alignment??"none"],$.audio&&(te===!1?p.waveformUnavailable:te===void 0?p.waveformLoading:void 0)].filter(Boolean).join(" \xB7 "),waveform:te?te.peaks:void 0}})})):[{id:"visual",label:p.tracks.visual,segments:P?[]:S?.stepOrder.map((D,$)=>({id:D,stepId:D,label:k?.steps[D]?.title??p.stepNumber($),timing:"unknown"}))??[]},{id:"voice",label:p.tracks.voice,segments:[]},{id:"caption",label:p.tracks.caption,segments:[]}],L=o?e?.tracks.find(D=>D.kind==="caption")?.segments.filter(D=>D.stepId===n&&(D.alignment==="words"||D.alignment==="manual")&&D.timing==="confirmed").map(D=>D.id)??[]:[];return(0,q3e.jsx)(Kie,{variant:"editor",label:p.timeline,tracks:O,labels:p.timelineLabels,durationMs:A,durationStatus:E?.timing??"unknown",currentTimeMs:R,selectedStepId:n,showSteps:!1,excluded:P?{status:p.notInLecture,notice:p.notInLectureHint}:void 0,notice:T?p.notInLectureStep:void 0,segmentPicker:{track:"caption",ids:L,label:p.captionSegment,placeholder:p.chooseCaptionSegment},zoom:_,onZoomChange:x,disabled:l,loading:a,seeking:s,seekDisabled:!i||I===void 0,onSelectStep:d,onSelectSegment:(D,$)=>{let j=o?e?.tracks.find(J=>J.kind===D)?.segments.find(J=>J.id===$.id):void 0;D==="caption"&&i&&(j?.alignment==="words"||j?.alignment==="manual")&&j.timing==="confirmed"&&j.startMs!==void 0?c(j.startMs):$.stepId&&d($.stepId)},onSeek:D=>{I!==void 0&&c(I+D)}})}var Ii=require("react");var U3e=new WeakMap,G3e="presmium.media-drafts.v1:",K3e=64,$Y=(e,t)=>G3e+JSON.stringify([e,t]),H1=e=>typeof e=="string",hD=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0;function W3e(e){return xt(e)&&H1(e.id)&&H1(e.assetId)&&xt(e.sourceRange)&&hD(e.sourceRange.startMs)&&hD(e.sourceRange.endMs)&&xt(e.attachment)&&H1(e.attachment.stepId)&&hD(e.attachment.offsetMs)&&hD(e.volume)&&e.volume<=1&&(e.muted===void 0||typeof e.muted=="boolean")}function LY(e){return xt(e)&&(e.selectedClipId===void 0||H1(e.selectedClipId))&&xt(e.entries)&&Object.entries(e.entries).every(([t,n])=>H1(t)&&xt(n)&&H1(n.version)&&W3e(n.clip)&&(n.baseClip===void 0||W3e(n.baseClip))&&[n.startText,n.endText,n.offsetText].every(r=>r===void 0||H1(r)))}function J3e(e){let t=U3e.get(e);return t||U3e.set(e,t=new Map),t}function BY(e){for(let[t,n]of e){if(e.size<=K3e)break;n.volatile||e.delete(t)}}function zY(e,t){let n=J3e(e),r=n.get(t);if(r)return n.delete(t),n.set(t,r),r;let o={value:{entries:{}},failed:!1,volatile:!1};try{let i=sessionStorage.getItem(t);if(i!==null){if(o.unreadable=i,i.length>131072)throw new Error("media-drafts-size");let a=JSON.parse(i);if(!LY(a))throw new Error("media-drafts-shape");o.value=a,delete o.unreadable}}catch{o.failed=!0}return n.set(t,o),BY(n),o}function Y3e(e,t,n){return structuredClone(zY(e,$Y(t,n)).value)}function Z3e(e,t,n){return zY(e,$Y(t,n)).failed}function X3e(e,t,n,r){if(!LY(r))return!1;let o=$Y(t,n),i=zY(e,o);i.value=structuredClone(r),i.volatile=!0;let a=J3e(e);a.set(o,i);try{let s=JSON.stringify(r);if(s.length>131072)throw new Error("media-drafts-size");i.unreadable!==void 0&&sessionStorage.setItem(`${o}:unreadable`,i.unreadable),sessionStorage.setItem(o,s);let l=Array.from({length:sessionStorage.length},(d,u)=>sessionStorage.key(u)).filter(d=>d.startsWith(G3e)&&!d.endsWith(":unreadable")&&d!==o),c=l.length-K3e+1;for(let d of l){if(c<=0)break;let u;try{u=JSON.parse(sessionStorage.getItem(d)??"null")}catch{continue}LY(u)&&!Object.keys(u.entries).length&&sessionStorage.getItem(`${d}:unreadable`)===null&&(sessionStorage.removeItem(d),c--)}return i.failed=!1,i.volatile=!1,delete i.unreadable,BY(a),!0}catch{return i.failed=!0,BY(a),!1}}var t6e=require("react/jsx-runtime"),c6=(e,t)=>({version:e,clip:{id:`clip_${Xe().replaceAll("-","")}`,assetId:"",sourceRange:{startMs:0,endMs:0},attachment:{stepId:t,offsetMs:0},volume:1,muted:!1}}),sdt=(e,t)=>({version:e,clip:structuredClone(t),baseClip:structuredClone(t)}),Q3e=(e,t)=>JSON.stringify(e)===JSON.stringify(t),jY=e=>e===void 0?"new":`clip:${e}`,ih=(e,t)=>Object.hasOwn(e,t)?e[t]:void 0;function e6e({identity:e,version:t,document:n,sectionId:r,stepId:o,binding:i,stepDurationMs:a,disabled:s,onChanged:l}){let c=tt(),d=me(ae=>ae.locale),u=Tb[d],[f,p]=(0,Ii.useState)(()=>Y3e(c.client,e,o)),m=(0,Ii.useRef)(f),[h,g]=(0,Ii.useState)(()=>Z3e(c.client,e,o)),[v,b]=(0,Ii.useState)(),[y,w]=(0,Ii.useState)(!1),[_,x]=(0,Ii.useState)(0),[k,S]=(0,Ii.useState)(),[E,P]=(0,Ii.useState)(),[T,I]=(0,Ii.useState)(),[C,A]=(0,Ii.useState)(!1),R=(0,Ii.useRef)(),O=(0,Ii.useRef)(),L=(0,Ii.useRef)({active:!0,revision:0}),D=(0,Ii.useRef)();D.current??=c6(t,o);let $=n.production.mediaClips.filter(ae=>ae.attachment.stepId===o),j=f.selectedClipId,J=jY(j),te=$.find(ae=>ae.id===j),V=ih(f.entries,J)??(te?sdt(t,te):{...D.current,version:t}),ee=(0,Ii.useRef)(V),Y=(0,Ii.useRef)(J);ee.current=V,Y.current=J,m.current=f;let G=Object.values(n.assets).filter(ae=>ae.kind==="audio").map(ae=>({id:ae.id,label:ae.title||ae.location.split("/").at(-1)||ae.id})),F=()=>L.current.active&&c.getState().authoring?.identity===e,B=ae=>{m.current=ae,p(ae),g(!X3e(c.client,e,o,ae))},z=ae=>{L.current.revision++,P(void 0),I(void 0),B({...m.current,entries:{...m.current.entries,[Y.current]:ae}})},q=()=>{c.stopAuditions(),c.selectDocumentStep(r,o)};(0,Ii.useEffect)(()=>()=>{L.current.active=!1,O.current?.abort(),R.current=void 0},[]),(0,Ii.useEffect)(()=>{let ae=V.clip.assetId,ne=new AbortController,re=J;if(!ae||s||!t||v?.version===t&&v.value.assetId===ae){w(!1);return}return w(!0),c.inspectDocumentAudio(ae,{identity:e,version:t},ne.signal).then(ye=>{if(ne.signal.aborted||!F())return;b({version:ye.version,value:ye.inspection});let fe=ih(m.current.entries,re);fe?.clip.assetId===ae&&fe.clip.sourceRange.endMs===0&&fe.startText===void 0&&fe.endText===void 0&&B({...m.current,entries:{...m.current.entries,[re]:{...fe,clip:{...fe.clip,sourceRange:{startMs:0,endMs:ye.inspection.durationMs}}}}})},ye=>{!ne.signal.aborted&&F()&&P(op(ye,d))}).finally(()=>{!ne.signal.aborted&&F()&&w(!1)}),()=>ne.abort()},[c,e,t,V.clip.assetId,J,s,_]);let Z=ae=>{let ne=c.getState().authoring;if(!F()||s||k||O.current||ne?.version!==t||ne.dirty||ne.saving||ne.loading||ne.composing||ne.restored||ne.error)return;let re=new AbortController;return O.current=re,S(ae),P(void 0),I(void 0),q(),{controller:re,expected:{identity:e,version:t},revision:L.current.revision,key:Y.current,draft:structuredClone(ee.current)}},X=ae=>{O.current===ae&&(O.current=void 0,F()&&S(void 0))},K=(ae,ne)=>{let re=Object.fromEntries(Object.entries(m.current.entries).map(([ye,fe])=>[ye,fe.version===ne?{...fe,version:ae.version}:fe]));return{...m.current,entries:re}},ue=async ae=>{if(!ae.size||ae.size>16*1024*1024){P(u.size),A(!1);return}let ne=Z("import");if(ne){R.current=ae,A(!1);try{let re=await c.ensureDocumentAudio(ae,ne.expected,ne.controller.signal);if(!F()||ne.controller.signal.aborted)return;let ye=K(re,ne.expected.version);if(L.current.revision===ne.revision&&Y.current===ne.key){let fe=c6(re.version,o);fe.clip.assetId=re.inspection.assetId,fe.clip.sourceRange.endMs=re.inspection.durationMs,ye.selectedClipId=void 0,ye.entries.new=fe,b({version:re.version,value:re.inspection})}B(ye),R.current=void 0,I(u.imported),l()}catch(re){F()&&!ne.controller.signal.aborted&&(P(op(re,d)),A(!0))}finally{X(ne.controller)}}},ie=async ae=>{if(!i||a===void 0||V.version!==t||ae.attachment.stepId!==o)return;let ne=Z("apply");if(ne)try{let re=await c.applyDocumentMediaClip(ae,{...ne.expected,binding:i},ne.controller.signal);if(!F()||ne.controller.signal.aborted)return;let ye=K(re,ne.expected.version),fe=ih(m.current.entries,ne.key);if(ne.key==="new"&&(D.current=c6(re.version,o)),fe&&Q3e(fe,ne.draft)?delete ye.entries[ne.key]:fe&&(ye.entries[ne.key]={...ih(ye.entries,ne.key),baseClip:structuredClone(ae)}),Y.current===ne.key){ye.selectedClipId=ae.id;let we=ih(ye.entries,"new");ne.key==="new"&&we&&(ye.entries[jY(ae.id)]=we,delete ye.entries.new)}B(ye),I(u.saved),l()}catch(re){F()&&!ne.controller.signal.aborted&&P(op(re,d))}finally{X(ne.controller)}},W=async()=>{if(!te)return;let ae=Z("remove");if(ae)try{let ne=await c.removeDocumentMediaClip(te.id,ae.expected,ae.controller.signal);if(!F()||ae.controller.signal.aborted)return;let re=K(ne,ae.expected.version),ye=ih(m.current.entries,ae.key);(!ye||Q3e(ye,ae.draft))&&(delete re.entries[ae.key],Y.current===ae.key&&(re.selectedClipId=void 0,D.current=c6(ne.version,o))),B(re),I(u.saved),l()}catch(ne){F()&&!ae.controller.signal.aborted&&P(op(ne,d))}finally{X(ae.controller)}},le=v?.version===t&&v.value.assetId===V.clip.assetId?v.value:void 0;return(0,t6e.jsx)(Fj,{locale:d,assets:G,clips:$,selectedClipId:j,draft:V,inspection:le,stepDurationMs:a,disabled:s,canApply:!!(i&&a!==void 0),loading:y,busy:k,pending:!!ih(f.entries,J),review:!!(ih(f.entries,J)&&V.version!==t),failure:E,storageFailed:h,status:T,retryImport:C,onEditStart:q,onChange:z,onImport:ae=>void ue(ae),onRetryImport:()=>{R.current&&ue(R.current)},onRead:()=>{P(void 0),b(void 0),x(ae=>ae+1)},onReview:()=>{le&&(!V.baseClip||te)&&z({...V,version:t,...te?{baseClip:structuredClone(te)}:{}})},onSelectClip:ae=>{L.current.revision++,P(void 0),I(void 0);let ne={...m.current,selectedClipId:ae};if(!ae&&j&&!te){let re=ih(m.current.entries,jY(j));re&&(ne.entries={...ne.entries,new:{...re,clip:{...re.clip,id:c6(t,o).clip.id},baseClip:void 0}})}B(ne)},onSelectAsset:ae=>{let ne=ee.current;z({...ne,clip:{...ne.clip,assetId:ae,sourceRange:{startMs:0,endMs:0}},startText:void 0,endText:void 0})},onApply:ae=>void ie(ae),onRemove:()=>void W()})}var ks=require("react");var Kl=require("react");var ldt=()=>`recording_${[...crypto.getRandomValues(new Uint8Array(16))].map(e=>e.toString(16).padStart(2,"0")).join("")}`;function n6e(e,t){let n=e?.content,r=n?.steps[t.stepId],o=r&&(n.production.stepOverrides[r.id]?.voiceSource??n.production.sectionOverrides?.[r.sectionId]?.voiceSource??n.production.defaults.voiceSource);return n?.id===t.source.documentId&&o?.type==="recording"&&o.assetId===t.assetId&&n.assets[t.assetId]?.fingerprint===`sha256:${t.sha256}`}function r6e({identity:e,sectionId:t,stepId:n,active:r,disabled:o,candidateAssetId:i,onAdopted:a}){let s=tt(),l=me(R=>R.authoring),[c,d]=(0,Kl.useState)(),[u,f]=(0,Kl.useState)(!1),[p,m]=(0,Kl.useState)(),h=(0,Kl.useRef)({active:!1,revision:0}),g=(0,Kl.useRef)(),v=(0,Kl.useRef)(),b=(0,Kl.useRef)(),y=(0,Kl.useRef)(),w=(0,Kl.useRef)({sectionId:t,stepId:n,active:r,onAdopted:a});w.current={sectionId:t,stepId:n,active:r,onAdopted:a};let _=l?.identity===e?l.content:void 0,x=_&&(_.production.stepOverrides[n]?.voiceSource??_.production.sectionOverrides?.[t]?.voiceSource??_.production.defaults.voiceSource),k=c??i??(x?.type==="recording"?x.assetId:""),S=Object.values(_?.assets??{}).filter(R=>R.kind==="audio"),E=!!(l&&!l.loading&&!l.dirty&&!l.saving&&!l.error&&x?.type==="recording"&&x.assetId===k&&/^sha256:[a-f\d]{64}$/.test(_?.assets[k]?.fingerprint??"")),P=()=>h.current.active&&s.getState().authoring?.identity===e;(0,Kl.useEffect)(()=>(h.current.active=!0,()=>{h.current.active=!1,g.current?.abort()}),[]),(0,Kl.useEffect)(()=>{h.current.revision++,g.current?.abort(),g.current=void 0,f(!1),m(void 0)},[t,n,r]),(0,Kl.useEffect)(()=>{let R=b.current;!R||l?.identity!==e||(n6e(l,R)?(v.current?.id===R.id&&(v.current=void 0),!l.loading&&!l.dirty&&!l.saving&&!l.composing&&!l.error&&y.current!==R.id&&(y.current=R.id,m(void 0),w.current.onAdopted())):l.version!==R.source.version&&g.current&&(g.current.abort(),g.current=void 0,f(!1),m("production-source-changed")))},[e,l?.identity,l?.version,l?.content,l?.loading,l?.dirty,l?.saving,l?.composing,l?.error]);let T=R=>{h.current.revision++,g.current?.abort(),g.current=void 0,v.current=void 0,d(R),f(!1),m(void 0)};return{assets:S,selected:k,choose:T,imported:(R,O)=>{P()&&h.current.revision===O&&T(R)},revision:()=>h.current.revision,adopt:async()=>{if(!k||u||o||!r||!P()||E)return;let R={sectionId:t,stepId:n,assetId:k},O=h.current.revision,L=new AbortController;g.current=L,f(!0),m(void 0);let D=()=>P()&&g.current===L&&!L.signal.aborted&&h.current.revision===O&&w.current.active&&w.current.sectionId===R.sectionId&&w.current.stepId===R.stepId,$;try{if(await s.flushPendingEdits(L.signal),!D())return;let j=s.getState().authoring;if(!j?.version||!j.fingerprint||!j.content||j.identity!==e||j.dirty||j.saving||j.composing||j.restored||j.error)throw new Error("production-source-changed");let J={identity:e,version:j.version},te=await s.inspectDocumentAudio(R.assetId,J,L.signal);if(!D())return;let V={documentId:j.content.id,version:j.version,fingerprint:j.fingerprint},ee=v.current;if($=ee&&ee.source.documentId===V.documentId&&ee.source.version===V.version&&ee.source.fingerprint===V.fingerprint&&ee.stepId===R.stepId&&ee.assetId===R.assetId&&ee.sha256===te.inspection.sha256?ee:{id:ldt(),source:V,stepId:R.stepId,assetId:R.assetId,sha256:te.inspection.sha256},v.current=$,b.current=$,await s.adoptDocumentRecording($,J,L.signal),!D())return;v.current===$&&(v.current=void 0),m(void 0),y.current!==$.id&&(y.current=$.id,w.current.onAdopted())}catch(j){if(D()){let J=$&&n6e(s.getState().authoring,$);J&&v.current===$&&(v.current=void 0),m(J?void 0:j instanceof Error?j.message:"recording-adoption-failed")}}finally{g.current===L&&(g.current=void 0,P()&&f(!1))}},cancel:()=>{h.current.revision++,g.current?.abort(),g.current=void 0,f(!1),m(void 0)},busy:u,failure:p,adopted:E}}var pi=require("react");var fi=require("react/jsx-runtime"),gD=(e,t)=>JSON.stringify(e)===JSON.stringify(t);function o6e({identity:e,sectionId:t,stepId:n,active:r,disabled:o,onChanged:i}){let a=tt(),s=me(W=>W.locale),l=me(W=>W.authoring),c=Tb[s],d=V1[s],u=l?.identity===e?l.content:void 0,f=u?.production.stepOverrides[n]?.voiceSource??u?.production.sectionOverrides?.[t]?.voiceSource??u?.production.defaults.voiceSource,p=f?.type==="recording"?f:void 0,m=JSON.stringify([n,p?.assetId]),h=(0,pi.useRef)(new Map),g=(0,pi.useRef)(!0),v=(0,pi.useRef)(),[b,y]=(0,pi.useState)(),[w,_]=(0,pi.useState)(!1),[x,k]=(0,pi.useState)(!1),[S,E]=(0,pi.useState)(),[P,T]=(0,pi.useState)(0),[,I]=(0,pi.useState)(0),C=(0,pi.useId)(),A=W=>{let le=W instanceof Error?W.message:String(W);return le==="recording-cue-unsupported"||le==="recording-start-conflict"?Gi[s].diagnostics[`production.${le}`]:le==="recording-source-changed"||le==="production-source-changed"||le==="document-version-changed"?d.adoptionSourceChanged:op(W,s)},R=(0,pi.useRef)(),O=(0,pi.useRef)(),L=(0,pi.useRef)({key:m,active:r,disabled:o,onChanged:i});L.current={key:m,active:r,disabled:o,onChanged:i};let D=()=>g.current&&a.getState().authoring?.identity===e,$=b&&b.version===l?.version&&b.value.assetId===p?.assetId?b.value:void 0,j=h.current.get(m)??(p?{version:l?.version??"",voice:p}:void 0),J=j?.range??(j&&$?DT(j.voice,$.durationMs):void 0),te=j?wk(j.startText,J?.startMs??j.voice.sourceRange?.startMs??0):void 0,V=j?wk(j.endText,J?.endMs??j.voice.sourceRange?.endMs??0):void 0,ee=!!($&&te!==void 0&&V!==void 0&&te>=0&&V>te&&V<=$.durationMs),Y=p&&$?DT(p,$.durationMs):void 0,G=!!(ee&&!gD(Y,{startMs:te,endMs:V})),F=(0,pi.useRef)(!1),B=()=>{let W=a.getState().authoring;return W?.identity===e&&!W.loading&&!W.dirty&&!W.saving&&!W.composing&&!W.restored&&!W.recovering&&!W.error?W:void 0},z=()=>{let W=R.current,le=B(),ae=W&&le?.content?.steps[W.request.stepId],ne=ae&&(le.content.production.stepOverrides[ae.id]?.voiceSource??le.content.production.sectionOverrides?.[ae.sectionId]?.voiceSource??le.content.production.defaults.voiceSource);if(!W||!le?.version||ne?.type!=="recording"||ne.assetId!==W.request.assetId||!gD(ne.sourceRange,W.request.sourceRange)||le.content?.assets[ne.assetId]?.fingerprint!==`sha256:${W.request.sha256}`)return!1;let re=h.current.get(W.key);return re===W.draft?h.current.delete(W.key):re?.version===W.draft.version&&gD(re.voice,W.draft.voice)&&h.current.set(W.key,{...re,version:le.version,voice:structuredClone(ne)}),D()&&(E(void 0),I(ye=>ye+1)),L.current.key===W.key&&L.current.active&&!L.current.disabled&&O.current!==W.request.id&&(O.current=W.request.id,L.current.onChanged()),!0};(0,pi.useEffect)(()=>()=>{g.current=!1,v.current?.abort()},[]),(0,pi.useEffect)(()=>{v.current?.abort(),v.current=void 0,k(!1),E(void 0)},[m,r]),(0,pi.useEffect)(()=>{let W=l?.version,le=p?.assetId,ae=new AbortController;if(!r||!W||!le||o){_(!1);return}return _(!0),a.inspectDocumentAudio(le,{identity:e,version:W},ae.signal).then(ne=>{!ae.signal.aborted&&D()&&L.current.key===m&&y({version:ne.version,value:ne.inspection})},ne=>{!ae.signal.aborted&&D()&&L.current.key===m&&E(A(ne))}).finally(()=>{!ae.signal.aborted&&D()&&L.current.key===m&&_(!1)}),()=>ae.abort()},[a,e,l?.version,p?.assetId,m,r,o,P]),(0,pi.useEffect)(()=>{z()},[l?.version,l?.content,l?.loading,l?.dirty,l?.saving,l?.composing,l?.restored,l?.error,r,o,m]);let q=W=>{j&&(h.current.set(m,{...j,...J?{range:{...J}}:{},...W}),E(void 0),I(le=>le+1))},Z=async()=>{if(!p||!j||!$||!ee||!G||x||o||!r||F.current||!D())return;let W=B();if(!W?.version||!W.fingerprint||W.version!==j.version||!W.content)return;let le=new AbortController,ae={startMs:te,endMs:V},ne=R.current?.request,re=ne&&ne.source.version===W.version&&ne.stepId===n&&ne.assetId===p.assetId&&ne.sha256===$.sha256&&gD(ne.sourceRange,ae)?ne:{id:Xe(),source:{documentId:W.content.id,version:W.version,fingerprint:W.fingerprint},stepId:n,assetId:p.assetId,sha256:$.sha256,sourceRange:ae},ye=h.current.get(m)??j;h.current.set(m,ye),R.current={key:m,draft:ye,request:re},v.current=le,k(!0),E(void 0);try{await a.adoptDocumentRecording(re,{identity:e,version:W.version},le.signal),D()&&z()}catch(fe){D()&&v.current===le&&!z()&&!le.signal.aborted&&E(A(fe))}finally{v.current===le&&(v.current=void 0,D()&&k(!1))}};if(!p||!j)return null;let X=j.version!==l?.version,K=te===void 0||V===void 0?c.invalidTime:$&&!ee?c.invalidRange:void 0,ue=!!(Y&&$&&(Y.startMs>0||Y.endMs<$.durationMs)),ie=u?.steps[n]?.narrationIds.some(W=>u.narrations[W]?.content.some(le=>le.type!=="cue"&&(le.type==="text"?le.text:le.display).trim()));return(0,fi.jsxs)("section",{className:"pm-ui-media-clip-editor","aria-label":d.trim,onFocusCapture:()=>{o||a.pausePlayback()},onCompositionStart:()=>{F.current=!0},onCompositionEnd:()=>{F.current=!1},onKeyDown:W=>{W.stopPropagation(),W.key==="Enter"&&W.target instanceof HTMLInputElement&&!W.nativeEvent.isComposing&&!F.current&&(W.preventDefault(),Z())},children:[(0,fi.jsx)("strong",{children:d.trim}),(0,fi.jsx)("span",{children:u?.assets[p.assetId]?.title||d.title}),w?(0,fi.jsx)("span",{role:"status",children:c.loading}):$&&(0,fi.jsx)("output",{className:"pm-ui-field__hint",children:c.original(cu($.durationMs),ee?cu(V-te):void 0)}),(0,fi.jsxs)("div",{className:"pm-ui-media-clip-editor__times",children:[(0,fi.jsx)(Kn,{label:c.in,density:"compact",width:"time",maxLength:32,value:j.startText??cu(J?.startMs??j.voice.sourceRange?.startMs??0),"aria-describedby":K?C:void 0,"aria-invalid":!!K||void 0,readOnly:o||!$,onChange:W=>q({startText:W.target.value})}),(0,fi.jsx)(Kn,{label:c.out,density:"compact",width:"time",maxLength:32,value:j.endText??cu(J?.endMs??j.voice.sourceRange?.endMs??0),"aria-describedby":K?C:void 0,"aria-invalid":!!K||void 0,readOnly:o||!$,onChange:W=>q({endText:W.target.value})})]}),K&&(0,fi.jsx)(ke,{tone:"warn",children:(0,fi.jsx)("span",{id:C,children:K})}),(0,fi.jsxs)("div",{className:"pm-ui-media-clip-editor__actions",children:[(0,fi.jsx)(he,{small:!0,variant:"primary",loading:x,disabled:o||!r||!ee||!G||X,onClick:()=>void Z(),children:c.apply}),(0,fi.jsx)(he,{small:!0,disabled:o||!$,onClick:()=>q({range:{startMs:0,endMs:$.durationMs},startText:void 0,endText:void 0}),children:c.restore}),x&&(0,fi.jsx)(he,{small:!0,onClick:()=>{v.current?.abort(),v.current=void 0,k(!1)},children:V1[s].cancelAdoption})]}),X&&(0,fi.jsxs)(ke,{tone:"warn",children:[c.review,(0,fi.jsx)(he,{small:!0,disabled:o||!$||x,onClick:()=>q({version:l.version,voice:structuredClone(p)}),children:c.check})]}),ue&&ie&&(0,fi.jsx)(ke,{tone:"warn",children:d.captionReview}),S&&(0,fi.jsxs)(ke,{tone:"danger",children:[S,(0,fi.jsx)(he,{small:!0,disabled:o||x,onClick:()=>{y(void 0),E(void 0),T(W=>W+1)},children:c.retry})]}),h.current.has(m)&&(0,fi.jsx)("span",{className:"pm-ui-field__hint",role:"status",children:c.pending})]})}var Mn=require("react/jsx-runtime"),cdt=e=>`${String(Math.floor(e/6e4)).padStart(2,"0")}:${String(Math.floor(e/1e3)%60).padStart(2,"0")}`;function i6e({identity:e,sectionId:t,stepId:n,active:r,disabled:o,onImportStarted:i,onImported:a,onAdopted:s}){let l=tt(),c=me(D=>D.locale),d=V1[c],u=me(D=>D.authoring),[f]=(0,ks.useState)(()=>Qpe(l,e)),p=(0,ks.useSyncExternalStore)(f.subscribe,f.snapshot),m=(0,ks.useRef)(),h=(0,ks.useRef)(),g=(0,ks.useRef)(!1),[v,b]=(0,ks.useState)({status:"idle"}),[y,w]=(0,ks.useState)(!1),[_,x]=(0,ks.useState)(),[k,S]=(0,ks.useState)(!1),[E]=(0,ks.useState)(n4),P=()=>g.current&&l.getState().authoring?.identity===e,T=p.candidate,I=r6e({identity:e,sectionId:t,stepId:n,active:r,disabled:o,candidateAssetId:T?.assetId,onAdopted:s}),C=["requesting","recording","stopping"].includes(p.phase),A=p.phase==="requesting"?d.requesting:p.phase==="recording"?d.recording:p.phase==="stopping"?d.stopping:T?T.assetId?d.imported:d.ready:void 0;(0,ks.useEffect)(()=>(g.current=!0,()=>{g.current=!1,h.current?.abort(),m.current?.dispose(),m.current=void 0,f.stop()}),[f]),(0,ks.useEffect)(()=>()=>{f.stop(),m.current?.stop()},[f,t,n,r]),(0,ks.useEffect)(()=>{r||(f.stop(),m.current?.stop()),T?.assetId&&u?.identity===e&&u.content&&!u.content.assets[T.assetId]&&f.forgetImport(T.assetId)},[r,T?.assetId,u?.content,u?.identity,e,f]);let R=()=>{x(void 0),f.start(async()=>{if(l.stopAuditions(),await l.pausePlayback(!0),!P()||!r)throw new Error("recording-failed");return l.registerAudioCapture(()=>f.stop())})},O=()=>{if(T){if(!m.current){let D=m.current=new R0(l);D.subscribe(()=>{P()&&b(D.snapshot())})}v.status==="playing"||v.status==="loading"?m.current.stop():m.current.play(async()=>({audio:T.file}))}},L=async()=>{if(!T||y||!P())return;let D=T.file,$=I.revision(),j=i(),J=new AbortController;h.current=J,w(!0),x(void 0);let te=()=>P()&&!J.signal.aborted&&h.current===J&&f.snapshot().candidate?.file===D;try{if(await l.flushPendingEdits(J.signal),!te())return;let V=l.getState().authoring;if(!V?.version||V.identity!==e||V.dirty||V.saving||V.composing||V.restored||V.error)throw new Error("production-source-changed");let ee=await l.ensureDocumentAudio(D,{identity:e,version:V.version},J.signal);if(!te())return;f.imported(D,ee.inspection.assetId),I.imported(ee.inspection.assetId,$),a(ee.inspection.assetId,j)}catch(V){te()&&x(`${d.saveFailed} ${op(V,c)}`)}finally{h.current===J&&(h.current=void 0,P()&&w(!1))}};return(0,Mn.jsxs)(zf,{className:"pmw-audio-recording","data-recording":p.phase,children:[(0,Mn.jsx)("strong",{children:d.title}),A&&!(A===d.imported&&I.adopted&&T?.assetId===I.selected)&&(0,Mn.jsxs)("span",{className:"pm-ui-hint",children:[(0,Mn.jsx)("span",{role:"status",children:y?d.saving:A}),p.phase==="recording"&&(0,Mn.jsxs)("span",{"aria-hidden":"true",children:[" \xB7 ",cdt(p.elapsedMs)]})]}),(p.error||E)&&(0,Mn.jsx)(ke,{tone:"warn",children:d.failures[p.error??E]??d.failures["recording-failed"]}),_&&(0,Mn.jsx)(ke,{tone:"danger",children:_}),v.status==="failed"&&(0,Mn.jsx)(ke,{tone:"warn",children:d.failures[v.error??"audition-request"]??d.failures["audition-request"]}),(0,Mn.jsxs)("div",{className:"pmw-voice__actions",children:[!C&&!T&&(0,Mn.jsx)(he,{small:!0,variant:"primary",disabled:o||y||!r||!!E,onClick:R,children:d.start}),p.phase==="requesting"&&(0,Mn.jsx)(he,{small:!0,onClick:()=>f.cancelTake(),children:d.cancel}),p.phase==="recording"&&(0,Mn.jsxs)(Mn.Fragment,{children:[(0,Mn.jsx)(he,{small:!0,onClick:()=>f.stop(),children:d.stop}),(0,Mn.jsx)(he,{small:!0,onClick:()=>f.cancelTake(),children:d.cancelTake})]}),T&&!C&&(0,Mn.jsx)(he,{small:!0,disabled:!r||y,loading:v.status==="loading",onClick:O,children:v.status==="playing"?d.stopAudition:d.audition}),T&&!T.assetId&&!C&&(0,Mn.jsx)(he,{small:!0,variant:"primary",disabled:o||!r,loading:y,onClick:()=>void L(),children:_?d.retry:d.save}),T&&!C&&(0,Mn.jsx)(he,{small:!0,disabled:o||y||!r||!!E,onClick:R,children:d.rerecord}),y&&(0,Mn.jsx)(he,{small:!0,onClick:()=>{h.current?.abort(),w(!1)},children:d.cancelSave}),T&&!C&&!y&&(0,Mn.jsx)(he,{small:!0,onClick:()=>S(!0),children:d.discard})]}),(I.assets.length>0||I.selected)&&(0,Mn.jsxs)(Mn.Fragment,{children:[(0,Mn.jsxs)(sr,{label:d.source,value:I.selected,disabled:o||!r||y,onChange:D=>I.choose(D.target.value),children:[(0,Mn.jsx)("option",{value:"",children:d.choose}),I.selected&&!I.assets.some(D=>D.id===I.selected)&&(0,Mn.jsx)("option",{value:I.selected,disabled:!0,children:d.removedAudio}),I.assets.map(D=>(0,Mn.jsx)("option",{value:D.id,children:D.title||D.location.split("/").at(-1)||D.id},D.id))]}),(0,Mn.jsxs)("div",{className:"pmw-voice__actions",children:[(0,Mn.jsx)(he,{small:!0,variant:"primary",disabled:o||!r||y||C||!I.assets.some(D=>D.id===I.selected)||I.adopted,loading:I.busy,onClick:()=>void I.adopt(),children:I.adopted?d.adopted:I.failure?d.retryAdoption:d.adopt}),I.busy&&(0,Mn.jsx)(he,{small:!0,onClick:I.cancel,children:d.cancelAdoption})]}),I.failure&&(0,Mn.jsx)(ke,{tone:"danger",children:["production-source-changed","document-version-changed"].includes(I.failure)?d.adoptionSourceChanged:I.failure==="recording-cue-unsupported"||I.failure==="recording-start-conflict"?Gi[c].diagnostics[`production.${I.failure}`]:I.failure.startsWith("production.asset-")||I.failure==="production-audio-unavailable"?op(I.failure,c):d.adoptionFailed})]}),(0,Mn.jsx)(o6e,{identity:e,sectionId:t,stepId:n,active:r,disabled:o||C||y,onChanged:s}),k&&(0,Mn.jsx)(kn,{open:!0,label:d.discardTitle,closeLabel:d.cancel,description:d.discardHint,onClose:()=>S(!1),actions:(0,Mn.jsxs)(Mn.Fragment,{children:[(0,Mn.jsx)(he,{onClick:()=>S(!1),children:d.keep}),(0,Mn.jsx)(he,{variant:"danger",onClick:()=>{m.current?.stop(),f.discard(),x(void 0),S(!1)},children:d.discard})]})})]})}var ur=require("react");var x2={"zh-CN":{import:"\u5BFC\u5165\u97F3\u9891",retry:"\u91CD\u8BD5",records:"\u8F6C\u5199\u8BB0\u5F55",partial:"\u90E8\u5206\u8F6C\u5199\u8BB0\u5F55\u65E0\u6CD5\u8BFB\u53D6\u3002",other:"\u53E6\u6709\u8F6C\u5199\u6B63\u5728\u8FDB\u884C\u3002",show:"\u67E5\u770B",audioUnavailable:"\u6682\u65F6\u65E0\u6CD5\u68C0\u67E5\u97F3\u9891\u3002",loading:"\u6B63\u5728\u52A0\u8F7D\u2026",title:"\u8F6C\u5199",audio:"\u97F3\u9891",service:"\u8F6C\u5199\u670D\u52A1",none:"\u8BF7\u9009\u62E9\u97F3\u9891",noAudio:"\u5148\u5F55\u97F3\u6216\u5BFC\u5165\u97F3\u9891\u3002",unavailable:"\u5C1A\u672A\u914D\u7F6E\u8F6C\u5199\u670D\u52A1\u3002",unresolved:"\u6682\u65F6\u65E0\u6CD5\u786E\u8BA4\u8F6C\u5199\u670D\u52A1\u3002",refresh:"\u5237\u65B0\u8F6C\u5199\u72B6\u6001",start:"\u8F6C\u5199",cancel:"\u53D6\u6D88\u8F6C\u5199",cancelTitle:"\u53D6\u6D88\u8F6C\u5199\uFF1F",cancelKeep:"\u7EE7\u7EED\u8F6C\u5199",cancelConfirm:"\u53D6\u6D88",close:"\u5173\u95ED",sending:"\u7B49\u5F85\u670D\u52A1\u786E\u8BA4",queued:"\u7B49\u5F85\u8F6C\u5199",running:"\u6B63\u5728\u8F6C\u5199",cancelling:"\u6B63\u5728\u53D6\u6D88",cancelled:"\u5DF2\u53D6\u6D88",done:"\u8F6C\u5199\u5B8C\u6210",failed:"\u8F6C\u5199\u5931\u8D25",stale:"\u6765\u6E90\u5DF2\u66F4\u65B0",requestFailed:"\u65E0\u6CD5\u786E\u8BA4\u8F6C\u5199\u7ED3\u679C\uFF0C\u8BF7\u5237\u65B0\u6216\u53D6\u6D88\u3002",readFailed:"\u65E0\u6CD5\u8BFB\u53D6\u8F6C\u5199\u7ED3\u679C\uFF0C\u8BF7\u91CD\u8BD5\u3002",storage:"\u672C\u5730\u6062\u590D\u4E0D\u53EF\u7528\uFF0C\u8BF7\u4FDD\u7559\u6B64\u9875\u9762\u3002",text:"\u8F6C\u5199\u6587\u672C",review:"\u5BF9\u7167\u5E76\u91C7\u7528\u4E3A\u8BB2\u7A3F",before:"\u73B0\u6709\u8BB2\u7A3F",after:"\u91C7\u7528\u540E",apply:"\u91C7\u7528\u8BB2\u7A3F",applying:"\u6B63\u5728\u4FDD\u5B58\u2026",adopted:"\u8BB2\u7A3F\u5DF2\u4FDD\u5B58",narration:"\u8BB2\u7A3F",newNarration:"\u65B0\u5EFA\u8BB2\u7A3F",segments:"\u91C7\u7528\u6BB5\u843D",allSegments:"\u5168\u90E8\u6BB5\u843D",segment:e=>`\u7B2C ${e+1} \u6BB5`,empty:"\u6CA1\u6709\u53EF\u91C7\u7528\u7684\u6587\u5B57\u3002",atoms:"\u53D1\u97F3\u4E0E\u63D0\u793A",keepAtom:"\u4FDD\u7559\u5230\u5149\u6807\u5904",removeAtom:"\u79FB\u9664",pronunciation:"\u53D1\u97F3",cue:"\u63D0\u793A",resolveAtoms:"\u8BF7\u6838\u5BF9\u53D1\u97F3\u4E0E\u63D0\u793A\u7684\u4F4D\u7F6E\u3002",unknownAtom:"\u53D1\u97F3\u6216\u63D0\u793A\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u6838\u5BF9\u3002",removed:"\u786E\u8BA4\u79FB\u9664",removeTiming:"\u540C\u65F6\u79FB\u9664\u5BF9\u5E94\u505C\u987F",shared:"\u5171\u4EAB\u8BB2\u7A3F",fork:"\u4EC5\u5F53\u524D\u6B65\u9AA4",editShared:"\u4FEE\u6539\u6240\u6709\u5F15\u7528\u6B65\u9AA4",affected:e=>`\u5C06\u4FEE\u6539 ${e} \u4E2A\u6B65\u9AA4`,conflicts:"\u8FD8\u6709\u672A\u6838\u5BF9\u7684\u4FEE\u6539\u3002",sourceChanged:"\u6587\u7A3F\u5DF2\u66F4\u65B0\uFF0C\u8BF7\u91CD\u65B0\u5BF9\u7167\u3002",confirm:"\u5BF9\u7167\u4FEE\u6539",edit:"\u7EE7\u7EED\u6821\u5BF9",previewFailed:"\u6682\u65F6\u65E0\u6CD5\u5BF9\u7167\uFF0C\u8BF7\u91CD\u8BD5\u3002",applyFailed:"\u65E0\u6CD5\u786E\u8BA4\u5DF2\u4FDD\u5B58\uFF0C\u6821\u5BF9\u5185\u5BB9\u5DF2\u4FDD\u7559\u3002",draftStorage:"\u6821\u5BF9\u5185\u5BB9\u6682\u65F6\u65E0\u6CD5\u6062\u590D\uFF0C\u8BF7\u4FDD\u7559\u6B64\u9875\u9762\u3002",stepChanged:"\u76EE\u6807\u6B65\u9AA4\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u3002"},en:{import:"Import Audio",retry:"Retry",records:"Transcription history",partial:"Some transcription records could not be read.",other:"Another transcription is running.",show:"View",audioUnavailable:"Couldn\u2019t check the audio right now.",loading:"Loading\u2026",title:"Transcription",audio:"Audio",service:"Transcription service",none:"Select audio",noAudio:"Record or import audio first.",unavailable:"No transcription service configured.",unresolved:"Couldn\u2019t confirm the transcription service.",refresh:"Refresh Transcription",start:"Transcribe",cancel:"Cancel Transcription",cancelTitle:"Cancel transcription?",cancelKeep:"Keep Transcribing",cancelConfirm:"Cancel",close:"Close",sending:"Waiting for the service",queued:"Queued",running:"Transcribing",cancelling:"Canceling",cancelled:"Canceled",done:"Transcription completed",failed:"Transcription failed",stale:"Source changed",requestFailed:"Couldn\u2019t confirm the result. Refresh or cancel.",readFailed:"Couldn\u2019t read the transcript. Try again.",storage:"Local recovery is unavailable. Keep this page open.",text:"Transcript",review:"Compare and Use as Script",before:"Current script",after:"Proposed script",apply:"Use Script",applying:"Saving\u2026",adopted:"Script saved",narration:"Script",newNarration:"New Script",segments:"Transcript segments",allSegments:"All segments",segment:e=>`Segment ${e+1}`,empty:"No text to adopt.",atoms:"Pronunciations and cues",keepAtom:"Keep at Cursor",removeAtom:"Remove",pronunciation:"Pronunciation",cue:"Cue",resolveAtoms:"Review pronunciation and cue positions.",unknownAtom:"Pronunciations or cues changed. Review them again.",removed:"Confirm Removal",removeTiming:"Also remove its pause",shared:"Shared script",fork:"This step only",editShared:"All referencing steps",affected:e=>`${e} steps will change`,conflicts:"Some changes still need review.",sourceChanged:"The document changed. Compare again.",confirm:"Compare Changes",edit:"Keep Editing",previewFailed:"Couldn\u2019t prepare the comparison. Try again.",applyFailed:"Couldn\u2019t confirm the save. Your edits are kept.",draftStorage:"Draft recovery is unavailable. Keep this page open.",stepChanged:"The target step changed. Select it again."}};function q1(e,t){let n=x2[t],r=e instanceof Error?e.message:"";return r.includes("version-changed")||r.includes("source-changed")||r.includes("plan-changed")||r.includes("plan-expired")?n.sourceChanged:r.includes("engine-unavailable")||r.includes("engine-unsupported")||r.includes("engine-unknown")||r.includes("speech-unavailable")?n.unavailable:r.includes("services-unavailable")?n.unresolved:n.requestFailed}var Ri=require("react");var tn=require("react/jsx-runtime"),vD=e=>Array.isArray(e)?e.map(vD):e&&typeof e=="object"?Object.fromEntries(Object.keys(e).sort().map(t=>[t,vD(e[t])])):e,a6e=(e,t)=>JSON.stringify(vD(e))===JSON.stringify(vD(t)),VY=e=>e.map(t=>t.type==="text"?t.text:t.type==="pronunciation"?t.display:"").join("");function ddt(e){let t=()=>({draft:{id:Xe(),revision:0,discarded:[],shared:"fork"},failed:!1});try{let n=localStorage.getItem(e);if(!n)return t();let r=JSON.parse(n);if(!r||typeof r.id!="string"||!Number.isSafeInteger(r.revision)||r.revision<0||!Array.isArray(r.discarded)||!r.discarded.every(o=>typeof o=="string")||!["fork","edit-shared"].includes(r.shared)||r.baseVersion!==void 0&&typeof r.baseVersion!="string"||r.applied!==void 0&&typeof r.applied!="boolean"||r.nodes!==void 0&&(!Array.isArray(r.nodes)||!r.nodes.every(o=>o&&(o.type==="text"&&typeof o.text=="string"||o.type==="pronunciation"&&typeof o.display=="string"&&typeof o.spoken=="string"||o.type==="cue"&&typeof o.id=="string"&&typeof o.action=="string"))))throw new Error("invalid-draft");return{draft:r,failed:!1}}catch{return{...t(),failed:!0}}}function s6e(e){let t=me(d=>d.locale),n=x2[t],r=e.document.steps[e.stepId]?.narrationIds??[],[o,i]=(0,Ri.useState)(r[0]??""),[a,s]=(0,Ri.useState)("all"),l=r.includes(o)?o:r[0],c=a==="all"?e.candidate.result.segments.map(d=>d.id):[a];return(0,tn.jsxs)(tn.Fragment,{children:[r.length>1&&(0,tn.jsx)(sr,{label:n.narration,value:l??"",disabled:e.disabled,onChange:d=>i(d.target.value),children:r.map((d,u)=>(0,tn.jsxs)("option",{value:d,children:[n.narration," ",u+1]},d))}),e.candidate.result.segments.length>1&&(0,tn.jsxs)(sr,{label:n.segments,value:a,disabled:e.disabled,onChange:d=>s(d.target.value),children:[(0,tn.jsx)("option",{value:"all",children:n.allSegments}),e.candidate.result.segments.map((d,u)=>(0,tn.jsxs)("option",{value:d.id,children:[n.segment(u)," \xB7 ",d.text.slice(0,30)]},d.id))]}),(0,tn.jsx)(udt,{...e,narrationId:l,segments:c},JSON.stringify([l,c]))]})}function udt({identity:e,candidate:t,document:n,sectionId:r,stepId:o,disabled:i,narrationId:a,segments:s}){let l=tt(),c=me(ie=>ie.locale),d=x2[c],u=me(ie=>ie.authoring),f=`presmium.transcription-draft.v1:${JSON.stringify([e,t.transcriptionId,t.revision,o,a,s])}`,[p]=(0,Ri.useState)(()=>ddt(f)),[m,h]=(0,Ri.useState)(p.draft),g=(0,Ri.useRef)(m),[v,b]=(0,Ri.useState)(p.failed),[y,w]=(0,Ri.useState)(!1),[_,x]=(0,Ri.useState)(),[k,S]=(0,Ri.useState)(!1),[E,P]=(0,Ri.useState)(!1),[T,I]=(0,Ri.useState)(!1),[C,A]=(0,Ri.useState)(),[R,O]=(0,Ri.useState)(),L=(0,Ri.useRef)(),D=(0,Ri.useRef)(0);(0,Ri.useEffect)(()=>()=>{D.current++},[]);let $={documentId:n.id,version:u?.version??"",fingerprint:u?.fingerprint??""},j=a?Object.values(n.steps).filter(ie=>ie.narrationIds.includes(a)).map(ie=>ie.id):[],J={sectionId:r,stepId:o,...a?{narrationId:a}:{},segmentIds:s,...j.length>1?{shared:m.shared,...m.shared==="edit-shared"?{affectedStepIds:j}:{}}:{}},te=(0,Ri.useMemo)(()=>bj(n,t,{id:m.id,source:$,candidate:{id:t.transcriptionId,revision:t.revision},draftRevision:m.revision,targets:[J]}),[n,t,m.id,m.shared,r,o,a,s.join("\0"),$.version,$.fingerprint]),V=te.targets[0],ee=V?.atoms??[],Y=V?.proposed.map(ie=>{if(ie.type!=="cue")return ie;let W=te.impact.forks.flatMap(le=>le.cues).find(le=>le.to===ie.id);return W?ee.find(le=>le.node.type==="cue"&&le.node.id===W.from)?.node??ie:ie}),G=m.nodes??Y??[{type:"text",text:t.result.segments.filter(ie=>s.includes(ie.id)).map(ie=>ie.text).join(`
|
|
1362
1362
|
`)}],F=()=>{let ie=new Set,W=[],le=!1;for(let ae of g.current.nodes??G)if(ae.type==="text")W.push({type:"text",text:ae.text});else{let ne=ee.find(re=>!ie.has(re.key)&&a6e(re.node,ae));ne?(ie.add(ne.key),W.push({type:"preserve",key:ne.key})):le=!0}return{parts:W,used:ie,invalid:le}},B=F(),z=!!(u?.identity===e&&u.version&&u.fingerprint&&!u.loading&&!u.dirty&&!u.saving&&!u.composing&&!u.restored&&!u.error),q=!!(_&&_.source.version===u?.version&&_.source.fingerprint===u?.fingerprint),Z=ie=>{D.current++;let W={...g.current,...ie,revision:g.current.revision+1,applied:!1};g.current=W,h(W),x(void 0),A(void 0),O(void 0);try{localStorage.setItem(f,JSON.stringify(W)),b(!1)}catch{b(!0)}},X=()=>{l.stopAuditions(),l.pausePlayback().catch(()=>{})},K=async()=>{let ie=l.getState().authoring;if(i||k||E||y||!z||!ie?.version||!ie.fingerprint||B.invalid)return;X(),g.current.baseVersion&&g.current.baseVersion!==ie.version?Z({id:Xe(),baseVersion:ie.version}):g.current.baseVersion||Z({baseVersion:ie.version});let W=g.current,le=++D.current,ae=F(),ne=j.length>1&&W.shared==="fork",re=ee.filter(fe=>W.discarded.includes(fe.key)&&fe.node.type==="cue"&&!ne&&Object.hasOwn(n.production.cueTimings??{},fe.node.id)).map(fe=>fe.node.id),ye={id:W.id,source:{documentId:n.id,version:ie.version,fingerprint:ie.fingerprint},candidate:{id:t.transcriptionId,revision:t.revision},draftRevision:W.revision,targets:[{...J,content:ae.parts,discardAtoms:W.discarded.filter(fe=>ee.some(we=>we.key===fe))}],...re.length?{removeCueTimings:re}:{}};S(!0),A(void 0);try{let fe=await l.planDocumentTranscription(ye,{identity:e,version:ie.version});if(le!==D.current||g.current.revision!==ye.draftRevision)return;x(fe),I(!0)}catch{le===D.current&&A(d.previewFailed)}finally{S(!1)}},ue=async()=>{if(!_?.planId||!q||_.conflicts.length||_.draftRevision!==g.current.revision||y||E||!z)return;let ie=_,W=_.planId;P(!0),A(void 0);try{let le=await l.adoptDocumentTranscription({planId:W,source:ie.source,candidate:ie.candidate,draftRevision:ie.draftRevision},{identity:e,version:ie.source.version});if(g.current.id===ie.changeId&&g.current.revision===ie.draftRevision){let ae={...g.current,id:Xe(),revision:0,discarded:[],baseVersion:le.version,applied:!0};g.current=ae,h(ae);try{localStorage.setItem(f,JSON.stringify(ae)),b(!1)}catch{b(!0)}}x(void 0),I(!1),O(d.adopted)}catch{A(d.applyFailed)}finally{P(!1)}};return!VY(G).trim()&&!ee.length?(0,tn.jsx)("span",{children:d.empty}):(0,tn.jsxs)(tn.Fragment,{children:[(0,tn.jsx)(Ut,{label:d.text,group:!0,children:(0,tn.jsx)(iD,{identity:f,fieldId:V?.outputNarrationId??m.id,content:G,getContent:()=>g.current.nodes??G,locale:c,advanced:!1,readOnly:i||E,toNative:ie=>i6(V?.outputNarrationId??m.id,ie),fromNative:RY,onReady:ie=>{L.current=ie},onComposition:w,onFocus:X,onChange:ie=>{let W=new Set;for(let le of ie){let ae=ee.find(ne=>!W.has(ne.key)&&a6e(ne.node,le));ae&&W.add(ae.key)}Z({nodes:ie,discarded:g.current.discarded.filter(le=>!W.has(le))})}})}),j.length>1&&(0,tn.jsxs)(sr,{label:d.shared,value:m.shared,disabled:i||E,onChange:ie=>Z({shared:ie.target.value}),children:[(0,tn.jsx)("option",{value:"fork",children:d.fork}),(0,tn.jsx)("option",{value:"edit-shared",children:d.editShared})]}),ee.length>0&&(0,tn.jsxs)("details",{open:ee.some(ie=>!B.used.has(ie.key)&&!m.discarded.includes(ie.key))||void 0,children:[(0,tn.jsx)("summary",{children:d.atoms}),(0,tn.jsx)("div",{className:"pmw-transcription__atoms",children:ee.map(ie=>{let W=B.used.has(ie.key),le=m.discarded.includes(ie.key),ae=ie.node.type==="cue"&&Object.hasOwn(n.production.cueTimings??{},ie.node.id)&&!(j.length>1&&m.shared==="fork");return(0,tn.jsxs)("div",{className:"pmw-transcription__actions",children:[(0,tn.jsx)("span",{children:ie.node.type==="pronunciation"?`${d.pronunciation} \xB7 ${ie.node.display} \u2192 ${ie.node.spoken}`:`${d.cue} ${ee.indexOf(ie)+1}`}),W?(0,tn.jsx)(Gc,{tone:"ok",children:d.atoms}):(0,tn.jsxs)(tn.Fragment,{children:[(0,tn.jsx)(he,{small:!0,disabled:i||E||y,onClick:()=>{let ne=L.current;ne&&(ne.focus(),ne.insertInlineContent(i6("adoption-atom",[ie.node])[0].content??[]))},children:d.keepAtom}),(0,tn.jsx)(he,{small:!0,"aria-pressed":le,disabled:i||E,onClick:()=>Z({discarded:le?m.discarded.filter(ne=>ne!==ie.key):[...m.discarded,ie.key]}),children:ae?d.removeTiming:d.removeAtom})]})]},ie.key)})})]}),B.invalid&&(0,tn.jsx)(ke,{tone:"warn",children:d.unknownAtom}),v&&(0,tn.jsx)(ke,{tone:"warn",children:d.draftStorage}),C&&(0,tn.jsx)(ke,{tone:"danger",children:C}),R&&(0,tn.jsx)("span",{role:"status",children:R}),(0,tn.jsx)("div",{className:"pmw-transcription__actions",children:(0,tn.jsx)(he,{small:!0,variant:"primary",loading:k,disabled:i||!z||y||E||B.invalid||m.applied,onClick:()=>void K(),children:d.review})}),T&&_&&(0,tn.jsxs)(kn,{open:!0,label:d.confirm,closeLabel:d.edit,busy:E,onClose:()=>I(!1),footer:(0,tn.jsxs)(tn.Fragment,{children:[(0,tn.jsx)(he,{disabled:E,onClick:()=>I(!1),children:d.edit}),(0,tn.jsx)(he,{variant:"primary",loading:E,disabled:!_.planId||!q||_.conflicts.length>0||!z||y||_.draftRevision!==m.revision,onClick:()=>void ue(),children:d.apply})]}),children:[(0,tn.jsxs)("div",{className:"pmw-transcription__review",children:[(0,tn.jsx)(n_,{label:d.before,readOnly:!0,value:VY(_.targets[0]?.before??[])}),(0,tn.jsx)(n_,{label:d.after,readOnly:!0,value:VY(_.targets[0]?.proposed??[])})]}),_.impact.stepIds.length>1&&(0,tn.jsx)(ke,{tone:"warn",children:d.affected(_.impact.stepIds.length)}),_.conflicts.length>0&&(0,tn.jsx)(ke,{tone:"warn",children:d.conflicts}),!q&&(0,tn.jsx)(ke,{tone:"warn",children:d.sourceChanged}),C&&(0,tn.jsx)(ke,{tone:"danger",children:C})]})]})}var ln=require("react/jsx-runtime");function l6e({identity:e,directory:t,document:n,sectionId:r,stepId:o,disabled:i,active:a,selectedAsset:s,onSelectAsset:l}){let c=tt(),d=me(de=>de.locale),u=x2[d],f=me(de=>de.authoring),p=(0,ur.useMemo)(()=>Jpe(c.client,e,t,n.id),[c,e,t,n.id]),m=(0,ur.useMemo)(()=>a?p.subscribe:()=>()=>{},[p,a]),h=(0,ur.useSyncExternalStore)(m,p.getState,p.getState),g=Object.values(n.assets).filter(de=>de.kind==="audio"),[v,b]=(0,ur.useState)(s?.id??h.request?.assetId??h.task?.audio.assetId??g.at(-1)?.id??""),y=(0,ur.useRef)(),[w,_]=(0,ur.useState)(),[x,k]=(0,ur.useState)(""),[S,E]=(0,ur.useState)(0),[P,T]=(0,ur.useState)(),[I,C]=(0,ur.useState)(!1),[A,R]=(0,ur.useState)(),[O,L]=(0,ur.useState)({tasks:[],issues:[]}),[D,$]=(0,ur.useState)(!1),[j,J]=(0,ur.useState)(!1),[te,V]=(0,ur.useState)(!1),[ee,Y]=(0,ur.useState)(),[G,F]=(0,ur.useState)(!1),B=(0,ur.useRef)({active:!0}),z=(0,ur.useRef)(null),q=(0,ur.useRef)(),Z=(0,ur.useRef)(),X=(0,ur.useRef)(),K=()=>B.current.active&&c.getState().authoring?.identity===e,ue=!!(f?.identity===e&&f.version&&f.fingerprint&&!f.loading&&!f.dirty&&!f.saving&&!f.composing&&!f.restored&&!f.error),ie=h.sending||h.cancelling||!!h.request||!!(h.task&&["queued","running","cancelling"].includes(h.task.state))||!!(p.intent&&!h.verified&&!h.failure),W=O.tasks.find(de=>de.id!==h.task?.id&&["queued","running","cancelling"].includes(de.state)),le=ie||!!W;(0,ur.useEffect)(()=>{s&&y.current!==s.revision&&n.assets[s.id]?.kind==="audio"&&(y.current=s.revision,Z.current?.abort(),b(s.id))},[s,n.assets]),(0,ur.useEffect)(()=>(B.current.active=!0,()=>{B.current.active=!1,q.current?.abort(),Z.current?.abort()}),[]),(0,ur.useEffect)(()=>{(!a||i)&&Z.current?.abort()},[a,i]),(0,ur.useEffect)(()=>{if(!a)return;let de=new AbortController,oe,be=async()=>{try{let Ye=await c.client.readTranscriptions(t,de.signal);if(de.signal.aborted||!K())return;if(L(Ye),!p.intent&&!p.getState().failure&&!p.getState().cancelled){let Ae=Ye.tasks.find(Ze=>Ze.source.documentId===n.id&&["queued","running","cancelling"].includes(Ze.state))??Ye.tasks.find(Ze=>Ze.source.documentId===n.id);Ae&&p.select(Ae)}}catch(Ye){!de.signal.aborted&&K()&&R(q1(Ye,d))}finally{de.signal.aborted||(oe=setTimeout(()=>void be(),2e3))}};return be(),()=>{de.abort(),clearTimeout(oe)}},[c,e,t,n.id,f?.version,a,S,d,p]),(0,ur.useEffect)(()=>{let de=new AbortController;if(a)return c.client.readTranscriptionCapabilities(t,de.signal).then(oe=>{!de.signal.aborted&&K()&&(_(oe),k(be=>oe.engines.some(Ye=>Ye.id===be)?be:oe.engines[0]?.id??""))},oe=>{!de.signal.aborted&&K()&&R(q1(oe,d))}),()=>de.abort()},[c,e,t,f?.version,a,S,d]),(0,ur.useEffect)(()=>{let de=h.verified&&h.task?.state==="done"?h.task.result:void 0,oe=new AbortController;if(!a||!de){C(!1),de||T(void 0);return}return C(!0),c.client.readTranscriptionResult(t,de.transcriptionId,de.revision,oe.signal).then(be=>{!oe.signal.aborted&&K()&&be.source.documentId===n.id&&be.transcriptionId===de.transcriptionId&&be.revision===de.revision&&(T(be),R(void 0))},()=>{!oe.signal.aborted&&K()&&R(u.readFailed)}).finally(()=>{!oe.signal.aborted&&K()&&C(!1)}),()=>oe.abort()},[c,e,t,n.id,h.task?.result?.transcriptionId,h.task?.result?.revision,h.task?.state,h.verified,a,S,d]);let ae=async de=>{let oe=c.getState().authoring;if(!K()||q.current||i||!oe?.version)return;l();let be=new AbortController;q.current=be,$(!0),R(void 0),X.current=de;try{let Ye=await c.ensureDocumentAudio(de,{identity:e,version:oe.version},be.signal);K()&&!be.signal.aborted&&(b(Ye.inspection.assetId),X.current=void 0)}catch(Ye){K()&&!be.signal.aborted&&R(q1(Ye,d))}finally{q.current===be&&(q.current=void 0,K()&&$(!1))}},ne=async()=>{let de=c.getState().authoring;if(!K()||Z.current||i||!ue||le||!de?.version||!de.content||!de.fingerprint||!v||!x||!w?.available)return;let oe=new AbortController;Z.current=oe,J(!0),R(void 0);try{let be={identity:e,version:de.version},Ye=await c.inspectDocumentAudio(v,be,oe.signal);if(!K()||oe.signal.aborted)return;let Ae={intent:`transcription_${Xe()}`,source:{documentId:de.content.id,version:de.version,fingerprint:de.fingerprint},assetId:v,audioSha256:Ye.inspection.sha256,engine:x,lang:de.content.metadata.lang,confirmed:!0};await p.start(Ae,()=>c.startDocumentTranscription(Ae,be))}catch(be){K()&&!oe.signal.aborted&&R(q1(be,d))}finally{Z.current===oe&&(Z.current=void 0,K()&&J(!1))}},re=async de=>{if(!de||de.id===h.task?.id)return p.cancel();F(!0);try{await c.client.cancelTranscription(t,{id:de.id}),K()&&E(oe=>oe+1)}catch(oe){K()&&R(q1(oe,d))}finally{K()&&F(!1)}},ye=de=>{de?.state==="running"?(Y(de),V(!0)):re(de)},fe=h.task,we=fe&&(fe.current===!1||f?.version!==fe.source.version||f?.fingerprint!==fe.source.fingerprint),Pe=O.tasks.filter(de=>de.source.documentId===n.id),xe=Pe.some(de=>de.id===fe?.id),ve=h.cancelled?u.cancelled:h.sending||!fe&&h.request?u.sending:fe?u[fe.state]:void 0;return(0,ln.jsxs)(zf,{className:"pmw-transcription","data-transcription":"true",children:[(0,ln.jsxs)("div",{className:"pmw-transcription__actions",children:[(0,ln.jsx)("strong",{children:u.title}),(0,ln.jsx)("span",{className:"pmw-spacer"}),(0,ln.jsx)(he,{small:!0,disabled:i||!ue||D,loading:D,onClick:()=>z.current?.click(),children:u.import}),X.current&&A&&(0,ln.jsx)(he,{small:!0,disabled:i||!ue||D,onClick:()=>{X.current&&ae(X.current)},children:u.retry}),(0,ln.jsx)("input",{ref:z,hidden:!0,type:"file",accept:"audio/*,.wav,.ogg,.mp3,.m4a,.webm",onChange:de=>{let oe=de.currentTarget.files?.[0];de.currentTarget.value="",oe&&ae(oe)}}),(0,ln.jsx)(Et,{small:!0,icon:"refresh",label:u.refresh,loading:h.checking&&!le,onClick:()=>{E(de=>de+1),p.refresh()}})]}),g.length?(0,ln.jsxs)(ln.Fragment,{children:[(0,ln.jsxs)(sr,{label:u.audio,value:n.assets[v]?.kind==="audio"?v:"",disabled:i||D,onChange:de=>{l(),Z.current?.abort(),b(de.target.value)},children:[(0,ln.jsx)("option",{value:"",children:u.none}),g.map(de=>(0,ln.jsx)("option",{value:de.id,children:de.title??de.location.split("/").at(-1)??de.id},de.id))]}),w?.engines.length?(0,ln.jsx)(sr,{label:u.service,value:x,disabled:i||le,onChange:de=>{Z.current?.abort(),k(de.target.value)},children:w.engines.map(de=>(0,ln.jsxs)("option",{value:de.id,children:[de.provider,w.engines.filter(oe=>oe.provider===de.provider).length>1?` \xB7 ${de.id}`:""]},de.id))}):w?(0,ln.jsx)("span",{children:w.status==="unknown"?u.unresolved:u.unavailable}):null,w&&!w.available&&w.engines.length>0&&(0,ln.jsx)("span",{children:w.reason==="audio-unavailable"?u.audioUnavailable:u.unresolved}),(0,ln.jsxs)("div",{className:"pmw-transcription__actions",children:[(0,ln.jsx)(he,{small:!0,disabled:i||!ue||le||j||!v||!x||!w?.available,loading:h.sending||j,onClick:()=>void ne(),children:u.start}),(ie||p.intent&&!h.verified&&!h.cancelled)&&(0,ln.jsx)(he,{small:!0,loading:h.cancelling||fe?.state==="cancelling",disabled:h.cancelling||fe?.state==="cancelling",onClick:()=>ye(fe),children:u.cancel}),ve&&(0,ln.jsx)("span",{role:"status","aria-live":"polite",children:(0,ln.jsx)(Gc,{tone:fe?.state==="done"?"ok":fe?.state==="failed"?"danger":"neutral",children:ve})}),we&&(0,ln.jsx)(Gc,{tone:"warn",children:u.stale})]})]}):(0,ln.jsx)("span",{children:u.noAudio}),Pe.length>0&&(Pe.length>1||!xe)&&(0,ln.jsxs)(sr,{label:u.records,disabled:ie||j,value:xe?fe?.id:"",onChange:de=>{let oe=Pe.find(be=>be.id===de.target.value);oe&&p.select(oe)},children:[!xe&&(0,ln.jsx)("option",{value:"",children:u.show}),Pe.map(de=>(0,ln.jsxs)("option",{value:de.id,children:[u[de.state]," \xB7 ",new Date(de.createdAt).toLocaleTimeString(d)," \xB7 ",n.assets[de.audio.assetId]?.title??u.audio]},de.id))]}),W&&(0,ln.jsxs)("div",{className:"pmw-transcription__actions",children:[(0,ln.jsx)("span",{children:u.other}),W.source.documentId===n.id&&(0,ln.jsx)(he,{small:!0,disabled:ie,onClick:()=>p.select(W),children:u.show}),(0,ln.jsx)(he,{small:!0,loading:G,onClick:()=>ye(W),children:u.cancel})]}),(O.issues.length>0||O.truncated)&&(0,ln.jsx)(ke,{tone:"warn",children:u.partial}),h.storageFailure&&(0,ln.jsx)(ke,{tone:"warn",children:u.storage}),(A||h.failure||fe?.error)&&(0,ln.jsx)(ke,{tone:"danger",children:A??q1(new Error(h.failure??fe?.error),d)}),I&&(0,ln.jsx)(Ut,{label:u.text,children:(0,ln.jsx)("span",{"aria-busy":"true",children:u.loading})}),P&&(0,ln.jsx)(s6e,{identity:e,candidate:P,document:n,sectionId:r,stepId:o,disabled:i},`${e}:${P.transcriptionId}:${P.revision}:${o}`),te&&(0,ln.jsx)(kn,{open:!0,label:u.cancelTitle,closeLabel:u.close,onClose:()=>V(!1),actions:(0,ln.jsxs)(ln.Fragment,{children:[(0,ln.jsx)(he,{onClick:()=>V(!1),children:u.cancelKeep}),(0,ln.jsx)(he,{variant:"danger",onClick:()=>{let de=ee;V(!1),Y(void 0),re(de)},children:u.cancelConfirm})]})})]})}var Qs=require("react");var c6e=e=>["queued","running","cancelling"].includes(e.state);function d6e(e,t,n){return new Promise((r,o)=>{let i=()=>{},a=(c,d)=>{i(),t.removeEventListener("abort",s),c?o(c):r(d)},s=()=>a(t.reason??new DOMException("Cancelled","AbortError")),l=()=>{try{t.throwIfAborted();let c=n(e.getState());c!==void 0&&a(void 0,c)}catch(c){a(c)}};i=e.subscribe(l),t.addEventListener("abort",s,{once:!0}),l()})}function u6e(){let e=tt(),t=me(S=>S.locale),n=me(S=>S.productionPlan),r=me(S=>S.productionPlayback),o=me(S=>S.authoring),i=me(S=>S.voiceServiceVersion),a=me(S=>S.productionNavigationVersion),s=me(S=>!!(S.hasDocumentTimingDrafts||S.documentTimingDraftStorageFailure||Wt(S))),[l,c]=(0,Qs.useState)(!1),[d,u]=(0,Qs.useState)(!1),[f,p]=(0,Qs.useState)(),[m,h]=(0,Qs.useState)(),g=(0,Qs.useRef)(),v=(0,Qs.useRef)(),b=(0,Qs.useRef)(!1),y=(0,Qs.useRef)(!0),w=(0,Qs.useRef)(0),_=()=>{w.current++,b.current=!1,v.current?.abort(),v.current=void 0,g.current?.abort(),g.current=void 0,y.current&&(c(!1),u(!1),h(void 0))};(0,Qs.useEffect)(()=>(y.current=!0,()=>{y.current=!1,_()}),[e]),(0,Qs.useEffect)(()=>{_()},[o?.identity,o?.version,o?.fingerprint,o?.projectRevision,i,a]),(0,Qs.useEffect)(()=>{(s||o?.dirty||o?.saving||o?.composing||o?.restored||o?.error)&&_()},[s,o?.dirty,o?.saving,o?.composing,o?.restored,o?.error]);let x=async(S,E)=>{if(g.current||!b.current||!E.waitingFor)return;let P=new AbortController;g.current=P;let T=AbortSignal.any([P.signal,AbortSignal.timeout(18e4)]),I=e.getState(),C=I.document,A=I.productionNavigationVersion,R=I.authoring?.projectRevision,O,L=!1,D=()=>{};c(!0),p(void 0),h(void 0);try{let $=S.tracks.find(z=>z.kind==="voice")?.segments.find(z=>z.utteranceId===E.waitingFor);if(!$||!E.stepId||!E.sectionId)throw new Error("voice-context-changed");let j=$.sourceStepId??$.stepId,J=await y2(e,j,T);if(C===void 0||J.directory!==C||J.source.version!==S.binding.source.version||J.source.fingerprint!==S.binding.source.fingerprint)throw new Error("voice-context-changed");let te=await e.client.readVoiceover(C,T);if(!Sa(e,J)||te.revision!==J.revision)throw new Error("voice-context-changed");let V=te.steps.find(z=>z.stepId===j),ee=te.unboundByPage?.find(z=>z.section===$.sectionId),Y=($.stepIds?.length??0)>1||!!ee?.utterances,G=Y?ee:V;if(G?.state==="blocked")throw new Error(G.reason??"voice-unavailable");if($.status==="blocked"&&!G?.cached)throw new Error(G?.reason??"voice-unset");let F=()=>{T.throwIfAborted();let z=e.getState();if(!b.current||!Sa(e,J)||z.productionNavigationVersion!==A||z.authoring?.projectRevision!==R||z.productionPlan?.binding.irRevision!==J.revision)throw P.abort(),new Error("voice-context-changed")};if(F(),G?.state!=="ready"&&G?.state!=="empty"){O=await e.client.startVoiceover(C,{source:J.source,revision:J.revision,scope:Y?{kind:"page",section:$.sectionId}:{kind:"step",target:J.target},confirmed:!0},T),F(),e.rememberVoiceoverJob(C,O),D=e.subscribe(()=>{let q=e.getState().voiceoverJobs?.find(Z=>Z.id===O?.id);q&&y.current&&h({completed:q.completed,total:q.total})});let z=c6e(O)?await d6e(e,T,q=>{F();let Z=q.voiceoverJobs?.find(X=>X.id===O.id);return Z&&!c6e(Z)?Z:void 0}):O;if(L=!0,z.state!=="done")throw new Error(z.error??(z.state==="stale"?"voice-context-changed":"voice-generation-failed"))}F(),O||(await e.prepareProductionPlan(T),F());let B=await d6e(e,T,z=>{F();let q=z.productionPlan,Z=z.productionPlayback;return q&&q.binding.irRevision===J.revision&&q.binding.planId!==S.binding.planId&&Z?.status==="ready"&&ci(q.binding,Z.binding)?q:void 0});F(),await e.controlProduction({binding:B.binding,action:"step",sectionId:E.sectionId,stepId:E.stepId,utteranceId:E.waitingFor},T),F(),E.rate!==1&&await e.controlProduction({binding:B.binding,action:"rate",rate:E.rate},T),F(),await e.controlProduction({binding:B.binding,action:"play"},T)}catch($){!P.signal.aborted&&y.current&&(b.current=!1,p(Ki($,t)))}finally{D(),O&&!L&&e.client.cancelVoiceover(C,O.id,AbortSignal.timeout(5e3)).catch(()=>{}),g.current===P&&(g.current=void 0,y.current&&(c(!1),h(void 0)))}};return(0,Qs.useEffect)(()=>{b.current&&!l&&!d&&n&&r?.position?.waitingFor&&ci(n.binding,r.binding)&&x(n,r.position)},[n,r,l,d]),{busy:l||d,failure:f,progress:m,stop:_,toggle:async()=>{let S=e.getState(),E=S.productionPlan;if(!E)return;if(g.current||v.current||S.productionPlayback?.position?.playing){_();try{await e.controlProduction({binding:E.binding,action:"pause"})}catch{}return}let P=new AbortController,T=++w.current;v.current=P,b.current=!0,u(!0),p(void 0);try{await e.controlProduction({binding:E.binding,action:"play"},P.signal)}catch(I){T===w.current&&!P.signal.aborted&&(b.current=!1,y.current&&p(Ki(I,t)))}finally{v.current===P&&(v.current=void 0,y.current&&u(!1))}}}}var Ge=require("react/jsx-runtime"),f6e=e=>{if(e===void 0||!Number.isFinite(e))return"--:--.---";let t=Math.max(0,Math.round(e));return`${String(Math.floor(t/6e4)).padStart(2,"0")}:${(t%6e4/1e3).toFixed(3).padStart(6,"0")}`},fdt={" ":"play-pause",ArrowLeft:"previous",ArrowRight:"next"};function p6e({onClose:e,closing:t,active:n=!0}){let r=tt(),o=vr(),i=me(Se=>Se.locale),a=Gi[i],s=u6e(),l=me(Se=>Se.voiceServiceVersion),c=me(Se=>Se.authoring),d=me(Se=>Se.position),u=me(Se=>Se.presentationSnapshot),f=me(Se=>Se.webView),p=me(Se=>!!Se.isPreparingPresentation),m=me(Se=>Se.productionPlan),h=me(Se=>Se.productionPlayback),g=me(Se=>Se.productionFailure),v=me(Se=>Se.previewConnection),b=me(Se=>Se.previewReload),y=me(Se=>!!(Se.hasDocumentTimingDrafts||Se.documentTimingDraftStorageFailure)),w=me(Se=>Se.captionTimingDraftSteps),_=me(Se=>Se.captionTimingDraftStorageFailure),x=me(Se=>!!(Se.presentationSnapshot&&Se.previewIrRevision===Se.presentationSnapshot.revision)),k=me(Se=>!!(Se.authoring?.loading||Se.authoring?.composing)||Wt(Se)),[S,E]=(0,xr.useState)(()=>matchMedia("(min-width: 1100px)").matches),[P,T]=(0,xr.useState)("preview"),[I,C]=(0,xr.useState)("pages"),[A,R]=(0,xr.useState)("script"),[O,L]=(0,xr.useState)(!1),[D,$]=(0,xr.useState)(),[j,J]=(0,xr.useState)(),[te,V]=(0,xr.useState)(!1),[ee,Y]=(0,xr.useState)(),[G,F]=(0,xr.useState)(0),[B,z]=(0,xr.useState)(!1),[q,Z]=(0,xr.useState)(!1),X=(0,xr.useRef)(),[K,ue]=(0,xr.useState)(!1),[ie,W]=(0,xr.useState)(!1),[le,ae]=(0,xr.useState)(!1),[ne,re]=(0,xr.useState)(),ye=(0,xr.useRef)(0),fe=(0,xr.useRef)({active:!0,generation:0}),we=(0,xr.useRef)(!1),Pe=c?.content,xe=d&&Pe?.sections[d.section]?d.section:Pe?.sectionOrder[0],ve=!!Pe?.metadata.plugins?.includes("@lincyaw/addon-lecture"),de=xe?Pe?.sections[xe]:void 0,oe=de?.stepOrder[d&&d.section===xe?d.step:0]??de?.stepOrder[0],be=!!(c&&u&&c.version===u.version&&c.fingerprint===u.fingerprint&&(c.projectRevision??0)===u.project&&!c.dirty&&!c.saving&&!c.error),Ye=be&&f==="present",Ae=!!(m&&c?.content?.id===m.binding.source.documentId&&c.version===m.binding.source.version&&c.fingerprint===m.binding.source.fingerprint&&!c.loading&&!c.dirty&&!c.saving&&!c.composing&&!c.restored&&!c.error),Ze=!!(Ae&&m&&Ye&&x&&u?.revision===m.binding.irRevision),We=m&&h&&ci(m.binding,h.binding)?h:void 0,Ht=!!(Ze&&m?.canPreview&&We?.status==="ready"&&!y),rr=!S&&P==="timeline",Rr=!S&&P!=="preview";(0,xr.useEffect)(()=>r.observeVoiceoverJobs(),[r,c?.identity]),(0,xr.useEffect)(()=>{let Se=matchMedia("(min-width: 1100px)"),yt=()=>E(Se.matches);return Se.addEventListener("change",yt),()=>Se.removeEventListener("change",yt)},[]),(0,xr.useEffect)(()=>()=>{fe.current.active=!1,fe.current.generation++,X.current?.abort(),r.closeProduction(),r.cancelPreviewPreparation()},[r]),(0,xr.useEffect)(()=>{let Se=new AbortController;if(!ve||!c?.identity||c.loading||c.dirty||c.saving||c.composing||c.restored||c.error||k){V(!1);return}return V(!0),Y(void 0),r.prepareProductionPlan(Se.signal).catch(yt=>{Se.signal.aborted||Y(yt instanceof Error&&yt.message.startsWith("production-")?sD(yt,i):a.planFailed)}).finally(()=>{Se.signal.aborted||V(!1)}),()=>Se.abort()},[r,c?.identity,c?.version,c?.fingerprint,c?.projectRevision,c?.loading,c?.dirty,c?.saving,c?.composing,c?.restored,c?.error,k,ve,G,b,l]),(0,xr.useEffect)(()=>{let Se=new AbortController;if(!m||!Ze||p||k||y){z(!1);return}return z(!0),r.controlProduction({binding:m.binding,action:"load"},Se.signal).catch(()=>{}).finally(()=>{Se.signal.aborted||z(!1)}),()=>Se.abort()},[r,m?.binding.planId,Ze,v,p,k,y]);let _r=async Se=>{if(!fe.current.active||!Ze||k||t||y)return;(Se.action==="pause"||Se.action==="seek"||Se.action==="step")&&s.stop(),X.current?.abort();let yt=new AbortController;X.current=yt,Z(Se.action==="seek");try{await r.controlProduction(Se,yt.signal)}catch{}finally{X.current===yt&&(X.current=void 0,fe.current.active&&Z(!1))}},or=async(Se=!0)=>{if(r.getState().isPreparingPresentation||!c?.identity)return;let yt=c.identity,$t=++fe.current.generation,on=()=>fe.current.active&&$t===fe.current.generation&&r.getState().authoring?.identity===yt;J(void 0);try{if(await r.flushPendingEdits(),!on())return;let lo=await r.preparePresentation();if(!on())return;if(!lo){let tl=r.getState().presentationFailure;J(tl===o.timingDraftPending?void 0:tl);return}r.setWebView("present"),Se&&F(tl=>tl+1)}catch{on()&&J(o.presentationCompileFailed)}};(0,xr.useEffect)(()=>{!le||p||r.getState().isPreparingPresentation||k||t||!c?.identity||c.loading||c.dirty||c.saving||c.composing||c.restored||c.error||(ae(!1),(!be||!x)&&or())},[le,p,k,t,c?.identity,c?.version,c?.fingerprint,c?.loading,c?.dirty,c?.saving,c?.composing,c?.restored,c?.error,be,x]),(0,xr.useEffect)(()=>{we.current||(we.current=!0,or(!1))},[]);let Mi=(Se,yt)=>{s.stop(),r.stopAuditions(),r.selectDocumentStep(Se,yt)},hi=(0,xr.useRef)(()=>{});hi.current=Se=>{if(k||t||!Pe||!xe||!oe)return;if(Se==="play-pause"){(s.busy||m&&Ht&&!B&&!te&&!p&&!q)&&s.toggle();return}let yt=Pe.sectionOrder.flatMap(lo=>Pe.sections[lo]?.stepOrder.map(tl=>({page:lo,step:tl}))??[]),$t=yt.findIndex(lo=>lo.page===xe&&lo.step===oe),on=$t<0?void 0:yt[$t+(Se==="next"?1:-1)];on&&Mi(on.page,on.step)},(0,xr.useEffect)(()=>{if(!n)return;xj();let Se=$t=>{let on=fdt[$t.key];!on||$t.defaultPrevented||$t.altKey||$t.ctrlKey||$t.metaKey||$t.shiftKey||Sj($t)||($t.preventDefault(),$t.stopPropagation(),$t.repeat&&on==="play-pause"||hi.current(on))};window.addEventListener("keydown",Se,!0);let yt=r.observePlaybackKeys($t=>hi.current($t));return()=>{window.removeEventListener("keydown",Se,!0),yt()}},[r,n]);let It=async()=>{if(!(k||t||K)){J(void 0),ue(!0);try{await r.enableDocumentProduction(),fe.current.active&&(r.cancelPreviewPreparation(),await or())}catch(Se){fe.current.active&&J(sD(Se,i))}finally{fe.current.active&&ue(!1)}}},xn=()=>{s.stop(),r.pausePlayback(!0).catch(()=>{}),L(!0)};if(!c?.identity||!Pe||!de||!xe||!oe)return(0,Ge.jsx)(Kc,{icon:"video",children:o.noSections});let vo=[...new Set([_&&a.captionStorageFailed,w?.length&&a.captionDraft,j,ee,Ae&&(g||We?.error)&&sD(g??We?.error,i),y?a.timingDraft:Ae&&m?.timing==="estimated"?a.estimatedPlan:Ae&&m?.timing==="unknown"?a.unknownPlan:Ae&&!Ze&&!p?a.playbackWaiting:void 0].filter(Se=>typeof Se=="string"&&!!Se))],bo=Ae?m?.diagnostics??[]:[],Ji=bo.length+vo.length,Ne=j??ee??(bo[0]&&(a.diagnostics[bo[0].code]??a.diagnosticFallback))??vo[0],it=Pe.sectionOrder.indexOf(xe),Ln=(0,Ge.jsx)(e6e,{identity:c.identity,version:c.version??"",document:Pe,sectionId:xe,stepId:oe,binding:Ae?m?.binding:void 0,stepDurationMs:(()=>{let Se=Ae?m?.pages.find(yt=>yt.sectionId===xe)?.steps.find(yt=>yt.stepId===oe):void 0;return Se?.timing==="confirmed"&&Se.startMs!==void 0&&Se.endMs!==void 0?Se.endMs-Se.startMs:void 0})(),disabled:k||t||!ve||!c.version||!!(c.dirty||c.saving||c.restored||c.error),onChanged:()=>ae(!0)},`${c.identity}:${oe}`);return(0,Ge.jsxs)("section",{className:"pmw-production","aria-label":a.title,children:[(0,Ge.jsx)(Av,{title:a.title,meta:S?Pe.metadata.title:void 0,leading:(0,Ge.jsx)(Et,{small:!0,icon:"arrow-left",label:a.back,loading:t,onClick:e}),actions:(0,Ge.jsxs)(Ge.Fragment,{children:[(0,Ge.jsx)(Gc,{tone:be&&x?"ok":p||be?"accent":"warn",children:be&&x?a.current:p||be?a.preparing:a.outdated}),Ji>0&&(0,Ge.jsx)(hw,{open:ie,onOpenChange:W,label:a.issues(Ji),trigger:S?(0,Ge.jsx)(he,{small:!0,icon:"warning",title:Ne,"aria-label":a.issues(Ji),children:a.issueCount(Ji)}):(0,Ge.jsx)(Et,{small:!0,icon:"warning",label:a.issues(Ji),hint:Ne}),children:(0,Ge.jsxs)("div",{className:"pmw-production__feedback",children:[vo.map(Se=>(0,Ge.jsx)(ke,{tone:"warn",children:Se},Se)),w?.length?Pe.sectionOrder.flatMap(Se=>Pe.sections[Se]?.stepOrder.map((yt,$t)=>w.includes(yt)?(0,Ge.jsxs)(he,{small:!0,onClick:()=>{Mi(Se,yt),W(!1)},children:[Pe.sections[Se].title," \xB7 ",a.stepNumber($t)]},yt):null)??[]):null,bo.map((Se,yt)=>{let $t=Se.sectionId?Pe.sections[Se.sectionId]:void 0,on=$t&&Se.stepId?$t.stepOrder.indexOf(Se.stepId):-1;return(0,Ge.jsxs)(zf,{children:[(0,Ge.jsx)("p",{children:a.diagnostics[Se.code]??a.diagnosticFallback}),$t&&Se.stepId&&on>=0&&(0,Ge.jsxs)(he,{small:!0,disabled:k||t,onClick:()=>{Mi($t.id,Se.stepId),W(!1)},children:[$t.title," \xB7 ",a.stepNumber(on)]})]},`${Se.code}:${Se.sectionId}:${Se.stepId}:${yt}`)})]})}),(0,Ge.jsx)(Et,{small:!0,icon:"refresh",label:a.prepare,loading:p,disabled:k||t,onClick:()=>void or()}),S?(0,Ge.jsx)(he,{small:!0,variant:"accent",icon:"export",disabled:t,onClick:xn,children:a.outputs}):(0,Ge.jsx)(Et,{small:!0,icon:"export",label:a.outputs,disabled:t,onClick:xn})]})}),!ve&&(0,Ge.jsxs)(ke,{tone:"accent",children:[(0,Ge.jsx)("span",{children:a.enableHint}),(0,Ge.jsx)(he,{small:!0,loading:K,disabled:k||t,onClick:()=>void It(),children:a.enable})]}),!S&&(0,Ge.jsx)(Wc,{label:a.title,value:P,options:[{value:"library",label:a.library},{value:"preview",label:a.preview},{value:"properties",label:a.properties},{value:"timeline",label:a.timeline}],onChange:T}),s.failure&&(0,Ge.jsxs)(ke,{tone:"danger",children:[s.failure,r.client.openSpeechSettings&&(0,Ge.jsx)(he,{small:!0,variant:"ghost",icon:"sliders",onClick:()=>{s.stop(),r.client.openSpeechSettings?.()},children:a.serviceSettings})]}),s.busy&&(0,Ge.jsx)("div",{role:"status",children:(0,Ge.jsx)(ke,{children:s.progress?a.generatingProgress(s.progress.completed,s.progress.total):a.generatingPlayback})}),(0,Ge.jsxs)(VL,{orientation:"vertical",disabled:!S,className:"pmw-production__workarea",children:[(0,Ge.jsx)(uw,{id:"production-main",defaultSize:"71%",minSize:S?"32%":0,className:"pmw-production__main",background:rr,children:(0,Ge.jsxs)(VL,{disabled:!S,className:"pmw-production__body",children:[(0,Ge.jsxs)(uw,{id:"production-library",defaultSize:"18%",minSize:S?"12%":0,maxSize:S?"30%":"100%",className:"pmw-production__library",hidden:!S&&P!=="library",children:[(0,Ge.jsx)(Av,{title:a.library}),(0,Ge.jsxs)(HL,{variant:"dock",value:I,label:a.library,tabs:[{value:"pages",label:a.pages,icon:"slides"},{value:"media",label:a.media,icon:"audio"}],onValueChange:C,children:[(0,Ge.jsx)(pw,{value:"pages",keepMounted:!0,children:(0,Ge.jsx)(mw,{label:a.pages,searchLabel:a.searchPages,searchPlaceholder:a.searchPages,value:xe,disabled:k||t,items:Pe.sectionOrder.map((Se,yt)=>({value:Se,label:`${String(yt+1).padStart(2,"0")} \xB7 ${Pe.sections[Se].title}`,description:a.pageSteps(Pe.sections[Se].stepOrder.length),icon:"slides"})),onValueChange:Se=>{let yt=Pe.sections[Se]?.stepOrder[0];yt&&Mi(Se,yt)},resultsLabel:a.pageResults,emptyLabel:a.noPages,loadingLabel:a.planLoading})}),(0,Ge.jsx)(pw,{value:"media",keepMounted:!0,children:Ln})]})]}),S&&(0,Ge.jsx)(z5,{label:a.resizeLibrary}),(0,Ge.jsxs)(uw,{id:"production-visuals",defaultSize:"56%",minSize:S?"30%":0,className:"pmw-production__visuals",background:Rr,children:[(0,Ge.jsx)(Av,{title:a.preview,meta:`${it+1} \xB7 ${de.title}`}),(0,Ge.jsx)("div",{className:"pmw-production__frame",hidden:!Ye,children:(0,Ge.jsx)(Qg,{active:Ye,playbackKeys:!0,onPresentationAction:Se=>{Se==="refresh"?or():e()}})}),!Ye&&(0,Ge.jsx)(Kc,{icon:"slides",title:a.unavailable,action:(0,Ge.jsx)(he,{small:!0,loading:p,disabled:k||t,onClick:()=>void or(),children:a.prepare}),children:a.previewHint}),(0,Ge.jsxs)("div",{className:"pmw-production__monitor-tools",children:[(0,Ge.jsx)(fw,{scroll:!0,label:a.step,children:de.stepOrder.map((Se,yt)=>(0,Ge.jsx)(ra,{asChild:!0,children:(0,Ge.jsx)(he,{small:!0,"aria-label":a.stepNumber(yt),"aria-pressed":oe===Se,disabled:k||t,onClick:()=>Mi(xe,Se),children:yt+1})},Se))}),(0,Ge.jsxs)(fw,{label:a.timeline,className:"pmw-production__transport",children:[(0,Ge.jsxs)("output",{"aria-label":a.timelineLabels.position,children:[f6e(We?.position?.timeMs)," / ",f6e(Ae?m?.durationMs:void 0)]}),(0,Ge.jsx)(ra,{asChild:!0,children:(0,Ge.jsx)(Et,{small:!0,icon:s.busy||We?.position?.playing?"pause":"play",label:s.busy||We?.position?.playing?a.pause:a.play,hint:a.playOnDemand,shortcut:zs.playPause,"aria-keyshortcuts":"Space",loading:B&&!s.busy,disabled:!s.busy&&(!Ht||te||p||k||t||q),onClick:()=>void s.toggle()})}),(0,Ge.jsxs)(sr,{label:a.rate,labelHidden:!0,value:We?.position?.rate===void 0?"":String(We.position.rate),disabled:!Ht||s.busy||B||te||p||k||t||q,onChange:Se=>{m&&_r({binding:m.binding,action:"rate",rate:Number(Se.target.value)})},children:[We?.position?.rate===void 0&&(0,Ge.jsx)("option",{value:"",children:a.timelineLabels.unknown}),tk.map(Se=>(0,Ge.jsxs)("option",{value:Se,children:[Se,"\xD7"]},Se))]}),(ee||g)&&(0,Ge.jsx)(ra,{asChild:!0,children:(0,Ge.jsx)(Et,{small:!0,icon:"refresh",label:a.planRetry,onClick:()=>F(Se=>Se+1)})})]})]})]}),S&&(0,Ge.jsx)(z5,{label:a.resizeProperties}),(0,Ge.jsxs)(uw,{id:"production-properties",defaultSize:"26%",minSize:S?"20%":0,maxSize:S?"42%":"100%",className:"pmw-production__properties",hidden:!S&&P!=="properties",children:[(0,Ge.jsx)(Av,{title:a.properties,meta:a.stepNumber(de.stepOrder.indexOf(oe))}),(0,Ge.jsxs)(HL,{variant:"dock",value:A,label:a.properties,tabs:[{value:"script",label:a.narration},{value:"voice",label:a.voiceTab},{value:"captions",label:a.captionsTab}],onValueChange:R,children:[(0,Ge.jsx)(pw,{value:"script",keepMounted:!0,children:(0,Ge.jsx)("div",{className:"pmw-production__fields pm-ui-block-editor",children:(0,Ge.jsx)(v2,{sectionId:xe,stepId:oe,expanded:!0,advanced:!0,panelId:"production-step-fields",onPause:()=>Mi(xe,oe)})})}),(0,Ge.jsx)(pw,{value:"voice",keepMounted:!0,children:(0,Ge.jsxs)("div",{className:"pmw-production__fields",children:[(0,Ge.jsx)(O3e,{stepId:oe,disabled:k||t,onGenerate:()=>{s.stop(),r.stopAuditions(),$(oe)}},`${c.identity}:${oe}`),(0,Ge.jsx)(i6e,{identity:c.identity,sectionId:xe,stepId:oe,active:!O&&(S||P==="properties")&&A==="voice",disabled:k||t,onImportStarted:()=>ye.current,onImported:(Se,yt)=>{ae(!0),yt===ye.current&&re({identity:c.identity,id:Se,revision:++ye.current})},onAdopted:()=>ae(!0)},c.identity),(0,Ge.jsx)(l6e,{identity:c.identity,directory:c.directory,document:Pe,sectionId:xe,stepId:oe,active:!O&&(S||P==="properties")&&A==="voice",disabled:k||t,selectedAsset:ne?.identity===c.identity?ne:void 0,onSelectAsset:()=>{ye.current++,re(void 0)}},c.identity)]})}),(0,Ge.jsx)(pw,{value:"captions",keepMounted:!0,children:(0,Ge.jsxs)("div",{className:"pmw-production__fields",children:[(0,Ge.jsx)(B3e,{identity:c.identity,document:Pe,disabled:k||t,onChanged:()=>ae(!0)}),(0,Ge.jsx)(V3e,{identity:c.identity,stepId:oe,plan:m,current:Ae,loading:p||te,disabled:k||t,onChanged:()=>ae(!0)},c.identity)]})})]})]})]})}),S&&(0,Ge.jsx)(z5,{label:a.resizeTimeline}),(0,Ge.jsx)(uw,{id:"production-timeline",defaultSize:"29%",minSize:S?"18%":0,maxSize:S?"65%":"100%",scroll:!0,className:"pmw-production__timeline",hidden:!S&&P!=="timeline",children:(0,Ge.jsx)(H3e,{plan:m,sectionId:xe,stepId:oe,active:S||P==="timeline",current:Ae,seekEnabled:Ht&&m?.timing==="confirmed"&&!s.busy&&!B&&!p&&!te,loading:te&&!Ae,seeking:q,disabled:k||t,onSelectStep:Se=>{let yt=Pe.steps[Se];yt&&Mi(yt.sectionId,Se)},onSeek:Se=>{m&&_r({binding:m.binding,action:"seek",timeMs:Se})}})})]}),(0,Ge.jsx)(kn,{open:O,label:a.outputs,closeLabel:o.close,onClose:()=>L(!1),children:O&&(0,Ge.jsx)(A9,{embedded:!0,onClose:()=>L(!1)})}),D&&(0,Ge.jsx)(F3e,{stepId:D,onClose:()=>$(void 0)},`${c.identity}:${D}`)]})}var m6e=require("react");var D0=require("react/jsx-runtime");function h6e({section:e,title:t,trigger:n,onClose:r}){let o=vr(),i=tt(),a=me(d=>!!d.isEditingPage),s=me(d=>d.pageEditFailure),[l,c]=(0,m6e.useState)(t);return(0,D0.jsx)(kn,{open:!0,label:o.pageRenameTitle,closeLabel:o.close,busy:a,onClose:r,onCloseAutoFocus:d=>{n?.isConnected&&(d.preventDefault(),n.focus())},children:(0,D0.jsxs)("form",{className:"pmw-operation",onKeyDown:d=>{d.key==="Enter"&&(d.nativeEvent.isComposing||d.nativeEvent.keyCode===229)&&d.preventDefault()},onSubmit:d=>{d.preventDefault(),!(a||!l.trim())&&i.renamePage(e,l.trim()).then(u=>{u&&r()})},children:[(0,D0.jsx)(Kn,{label:o.pageTitle,density:"regular",value:l,error:s,required:!0,autoFocus:!0,readOnly:a,onChange:d=>c(d.target.value)}),(0,D0.jsxs)("div",{className:"pmw-operation__actions",children:[(0,D0.jsx)(he,{disabled:a,onClick:r,children:o.cancel}),(0,D0.jsx)(he,{type:"submit",variant:"primary",loading:a,disabled:!l.trim(),children:o.save})]})]})})}var U1=require("react");var xf=require("react/jsx-runtime");function g6e({section:e,title:t,trigger:n,onClose:r}){let o=vr(),i=tt(),[a,s]=(0,U1.useState)(),[l,c]=(0,U1.useState)(!0),[d,u]=(0,U1.useState)(),[f,p]=(0,U1.useState)(0),m=me(g=>!!g.isEditingPage),h=me(g=>g.pageEditFailure);return(0,U1.useEffect)(()=>{let g=!0;return c(!0),u(void 0),i.preparePageDeletion(e).then(v=>{g&&s(v)},()=>{g&&u(o.pageEditRequestFailed)}).finally(()=>{g&&c(!1)}),()=>{g=!1}},[i,e,f]),(0,xf.jsx)(kn,{open:!0,label:o.pageDeleteTitle(t),description:a?o.pageDeleteHint(a.counts.steps,a.counts.narration):o.pageDeleteLoading,busy:m,closeLabel:o.close,onClose:r,onCloseAutoFocus:g=>{let v=n?.isConnected?n:document.querySelector(".pmw-navigation__item[aria-current]");v&&(g.preventDefault(),v.focus())},children:(0,xf.jsxs)("div",{className:"pmw-operation",children:[a?.last&&(0,xf.jsx)(ke,{children:o.pageDeleteLast}),a&&!a.allowed&&(0,xf.jsx)(ke,{tone:"warn",children:i.pageDeleteMessage(a.reason??"page-boundary")}),(d||h)&&(0,xf.jsx)(ke,{tone:"danger",children:d||h}),(0,xf.jsxs)("div",{className:"pmw-operation__actions",children:[(0,xf.jsx)(he,{disabled:m,onClick:r,children:o.cancel}),d||h?(0,xf.jsx)(he,{disabled:m,onClick:()=>{i.clearPageEditFailure(),p(g=>g+1)},children:o.retry}):(0,xf.jsx)(he,{variant:"danger",loading:l||m,disabled:!a?.allowed||l,onClick:()=>{a&&i.deletePage(a).then(g=>{g&&r()})},children:o.pageDelete})]})]})})}var Ac=require("react");var _a=require("react");var S2=()=>Xe(),_2=e=>`page:${e}`;function yD(e){return e.map(t=>t.type==="text"?t.text??"":t.type==="break"?`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lincyaw/dsh",
|
|
3
|
-
"version": "0.2.0-rc.
|
|
3
|
+
"version": "0.2.0-rc.32",
|
|
4
4
|
"description": "Presmium's bundle for DeepSeek Harness: the workbench of presmium studio, its host side (Presmium's tools, approvals, document context, skills and routes) and its client side (the root layout and the workbench's panels, precompiled) (experimental)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -85,10 +85,10 @@
|
|
|
85
85
|
"node-addon-require-builtin": "0.1.9",
|
|
86
86
|
"ws": "8.22.0",
|
|
87
87
|
"zod": "4.4.3",
|
|
88
|
-
"@lincyaw/cli": "1.0.0-rc.
|
|
89
|
-
"@lincyaw/
|
|
90
|
-
"@lincyaw/
|
|
91
|
-
"@lincyaw/
|
|
88
|
+
"@lincyaw/cli": "1.0.0-rc.33",
|
|
89
|
+
"@lincyaw/kernel": "1.0.0-rc.33",
|
|
90
|
+
"@lincyaw/mcp": "1.0.0-rc.33",
|
|
91
|
+
"@lincyaw/skills": "1.0.0-rc.33"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"@deepseek-ai/dsh": "0.2.1-alpha.4"
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
"react": "18.3.1",
|
|
105
105
|
"react-dom": "18.3.1",
|
|
106
106
|
"react-resizable-panels": "^4.14.5",
|
|
107
|
-
"@lincyaw/design": "1.0.0-rc.
|
|
108
|
-
"@lincyaw/workbench": "0.2.0-rc.
|
|
107
|
+
"@lincyaw/design": "1.0.0-rc.33",
|
|
108
|
+
"@lincyaw/workbench": "0.2.0-rc.33"
|
|
109
109
|
},
|
|
110
110
|
"scripts": {}
|
|
111
111
|
}
|