superdoc 2.22.0-next.3 → 2.22.0-next.4
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/dist/chunks/{create-super-doc-ui-yKesgn9b.cjs → create-super-doc-ui-DTLJMJIl.cjs} +1 -0
- package/dist/chunks/{create-super-doc-ui-0CZTlOvl.es.js → create-super-doc-ui-Dos1KQcL.es.js} +1 -0
- package/dist/collaboration-upgrade-engine.cjs +1 -1
- package/dist/collaboration-upgrade-engine.es.js +1 -1
- package/dist/document-api/src/contract/operation-definitions.d.ts +2 -2
- package/dist/document-api/src/diff/diff.types.d.ts +9 -0
- package/dist/document-api/src/index.d.ts +1 -1
- package/dist/document-api/src/selection/selection.d.ts +1 -1
- package/dist/document-api/src/selection/selection.types.d.ts +19 -1
- package/dist/layout-engine/contracts/src/index.d.ts +4 -0
- package/dist/public/ui-react.cjs +1 -1
- package/dist/public/ui-react.es.js +1 -1
- package/dist/public/ui-vue.cjs +1 -1
- package/dist/public/ui-vue.es.js +1 -1
- package/dist/public/ui.cjs +1 -1
- package/dist/public/ui.es.js +1 -1
- package/dist/superdoc/src/public/ui/types.d.ts +2 -0
- package/dist/superdoc.cjs +3 -3
- package/dist/superdoc.es.js +3 -3
- package/dist-cdn/superdoc.min.js +4 -4
- package/package.json +2 -2
package/dist-cdn/superdoc.min.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var SuperDoc=(function(){var Fx=Object.create,Jh=Object.defineProperty,Nx=Object.getOwnPropertyDescriptor,Bx=Object.getOwnPropertyNames,zx=Object.getPrototypeOf,jx=Object.prototype.hasOwnProperty,Lr=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(r){throw n=[r],r}},h2=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),Gd=(e,t)=>{let n={};for(var r in e)Jh(n,r,{get:e[r],enumerable:!0});return t||Jh(n,Symbol.toStringTag,{value:"Module"}),n},Vx=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var o=Bx(t),i=0,s=o.length,a;i<s;i++)a=o[i],!jx.call(e,a)&&a!==n&&Jh(e,a,{get:(l=>t[l]).bind(null,a),enumerable:!(r=Nx(t,a))||r.enumerable});return e},p2=(e,t,n)=>(n=e!=null?Fx(zx(e)):{},Vx(t||!e||!e.__esModule?Jh(n,"default",{value:e,enumerable:!0}):n,e)),Ux=new Set(["documentId","actionId","commandId","operation","source","origin","phase","kind","status","success","changed","reason","code","direction","outcome","receipt","result","failure","rejection","txId","documentEpoch","commitSequence","targetCommitSequence","paintedCommitSequence","renderInputEpoch","paintedRenderInputEpoch","health","selection","selectionBefore","selectionAfter","snapshot","target","start","end","anchor","focus","story","storyType","storyId","refId","noteId","textboxId","position","offset","unit","value","blockId","blockOffset","fragmentId","pageIndex","layoutEpoch","revision","sourceCommit","selectionLineageId","selectionIntentSequence","intentSequence","intentId","authoringMode","editableCommandKind","inputKind","visualIntent","preEdit","postEdit","fallback","selectionRevision","timing","selectionTargetMs","textReplaceMs","postEditSelectionMs","totalMs","inputAtMs","dispatchAtMs","committedAtMs","durationMs","elapsedMs","affectedStories","tableId","cellId","contentControlId","outsideContentControl","trackedBlockOffset","projectionBlockId","geometryBlockId","geometryBlockOffset","geometryTrackedBlockOffset","lineAffinity","inlineAffinity","stability","nativeId","paraId","partId","partRevision","storyRevision","pathFingerprint","path","index","name","id","range","hasRangeSelection","inputType","dataLength","isComposing","repeat","altKey","ctrlKey","metaKey","shiftKey","key","button","buttons","pointerType","clickCount","x","y","selector","domPath","scrollLeft","scrollTop","command","segments","nodeId","byteSpan","sdtId","controlId","scope","coordinateSpace","contentControlIds","scrollAncestors","layoutBlockRef","contextSource"]),$x=new Set(["text","data","message","errorMessage","quotedText"]),Hx=["keydown","keyup","beforeinput","pointerdown","pointermove","pointerup","click","dblclick","mousedown","mouseup","scroll","compositionstart","compositionend","paste","cut","drop","dragstart"],Gx=new Set(["Alt","AltGraph","CapsLock","Control","Meta","NumLock","ScrollLock","Shift","Enter","Tab","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","End","Home","PageDown","PageUp","Backspace","Delete","Insert","Escape","ContextMenu","Pause","Dead","Process","Unidentified"]),Wx=0;function cu(e,t){return e&&typeof e=="object"?Object.getOwnPropertyDescriptor(e,t)?.value:void 0}function m2(e,t,n){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0&&e<=n?e:t}var Kx=class{constructor(e,t){this.root=e,this.version=t,this.session=null,this.events=[],this.startMs=0,this.maxEvents=2e4,this.maxBytes=8388608,this.closed=!1,this.pendingIntents=new Set,this.heldKeys=new Set,this.heldButtons=new Set,this.cleanups=[];const n=this;this.api=Object.freeze({get active(){return n.active},start:r=>this.start(r),stop:()=>this.stop(),getSnapshot:()=>this.snapshot()})}attachInputs(){const e=this.root.ownerDocument.defaultView;if(!e)throw new Error("Workflow recording requires a browser window.");try{for(const t of Hx){const n=r=>{if(!(!this.active||!r.isTrusted))try{r.target instanceof e.Node&&this.root.contains(r.target)?this.input(r):(r.type==="keyup"?this.heldKeys.delete(r.key):r.type==="pointerup"&&this.heldButtons.delete(r.button))&&this.unsupported("input-released-outside-mount")}catch{this.fail("capture-failure")}};e.addEventListener(t,n,!0),this.cleanups.push(()=>e.removeEventListener(t,n,!0))}}catch(t){throw this.detachInputs(),t}}detachInputs(){const e=this.cleanups;this.cleanups=[];for(const t of e)try{t()}catch{}}get active(){return this.session?.status==="recording"}start(e={}){if(this.closed)throw new Error("Cannot record a destroyed SuperDoc instance.");if(this.active)throw new Error("Stop the active workflow recording first.");this.maxEvents=m2(cu(e,"maxEvents"),2e4,1e5),this.maxBytes=m2(cu(e,"maxBytes"),8388608,67108864);const t=this.root.ownerDocument.defaultView;this.events=[],this.pendingIntents.clear(),this.startMs=t.performance.now(),this.session={schemaVersion:1,sessionId:`workflow-${Date.now()}-${++Wx}`,version:this.version(),status:"recording",startedAt:Date.now(),durationMs:0,timeOrigin:t.performance.timeOrigin,startTimeMs:this.startMs,captureContent:cu(e,"captureContent")===!0,viewport:{width:t.innerWidth,height:t.innerHeight,devicePixelRatio:t.devicePixelRatio},retainedBytes:0,replayUnsupportedReasons:[],pendingIntentIds:[]};try{this.attachInputs(),this.observe("workflow:started",()=>({scrollTop:this.root.scrollTop,scrollLeft:this.root.scrollLeft}))}catch{this.fail("capture-failure")}return this.snapshot()}observe(e,t){if(this.active)try{let n=4096;const r=(s,a=0)=>{if(--n<0||a>14)throw new Error("payload-limit");if(s===null||typeof s=="boolean")return s;if(typeof s=="number")return Number.isFinite(s)?s:void 0;if(typeof s=="string"){if(s.length>32768)throw new Error("payload-limit");return s}if(!s||typeof s!="object")return;if(Array.isArray(s)){if(s.length>256)throw new Error("payload-limit");return Array.from({length:s.length},(u,d)=>r(cu(s,String(d)),a+1)??null)}const l={};for(const u of Ux){const d=cu(s,u);u==="value"&&typeof d=="string"&&!this.session.captureContent||d!==void 0&&(l[u]=r(d,a+1))}if(this.session.captureContent)for(const u of $x){const d=cu(s,u);d!==void 0&&(l[u]=r(d,a+1))}return l},o={sequence:this.events.length+1,atMs:this.root.ownerDocument.defaultView.performance.now()-this.startMs,type:e,data:r(t())??{}},i=JSON.stringify(o);if(this.events.length>=this.maxEvents||this.session.retainedBytes+i.length*2>this.maxBytes){this.fail("capture-limit");return}if(this.events.push(i),this.session.retainedBytes+=i.length*2,e==="interaction:intent"){const s=`${o.data.documentId??""}/${o.data.selectionLineageId}/${o.data.intentSequence}`;(o.data.phase==="enqueued"||o.data.phase==="executing")&&this.pendingIntents.add(s),(o.data.phase==="settled"||o.data.phase==="failed")&&this.pendingIntents.delete(s)}}catch{this.fail("capture-failure")}}unsupported(e){this.session.replayUnsupportedReasons.includes(e)||this.session.replayUnsupportedReasons.push(e)}fail(e){if(this.session){this.unsupported(e);try{this.session.durationMs=this.root.ownerDocument.defaultView.performance.now()-this.startMs}catch{}this.session.status="incomplete",this.clearHeldInput(),this.detachInputs()}}input(e){if(!(!this.active||!e.isTrusted))try{const t=e.target instanceof this.root.ownerDocument.defaultView.Element?e.target:this.root,n=e;if(e.type==="pointermove"&&n.buttons===0)return;let r=t,o=null;for(;r&&r!==this.root;){for(const l of["data-layout-fragment-id","data-layout-block-ref","data-page-index","data-item","data-testid","aria-label"]){const u=r.getAttribute(l);if(u){o=`[${l}=${JSON.stringify(u)}]`;break}}if(o)break;r=r.parentElement}if(!o&&t!==this.root){const l=[];for(r=t;r&&r!==this.root;){const u=r.parentElement;if(!u)break;l.unshift(`:nth-child(${Array.prototype.indexOf.call(u.children,r)+1})`),r=u}r===this.root&&(o=`:scope > ${l.join(" > ")}`),r=t}const i=e,s={selector:o};if(e.type.startsWith("pointer")||["mousedown","mouseup","click","dblclick"].includes(e.type)){const l=[];let u=r??this.root;for(;u&&u!==this.root;){const p=u.parentElement;if(!p)break;l.unshift(`:nth-child(${Array.prototype.indexOf.call(p.children,u)+1})`),u=p}u===this.root&&l.length&&(s.domPath=`:scope > ${l.join(" > ")}`);const d=new Set;for(let p=t;p&&p!==this.root;p=p.parentElement){for(const[m,v]of[["data-source-node-id","blockId"],["data-layout-fragment-id","fragmentId"],["data-layout-block-ref","layoutBlockRef"],["data-layout-story","storyId"],["data-page-index","pageIndex"]]){const C=p.getAttribute(m);C&&s[v]==null&&(s[v]=v==="pageIndex"?Number(C):C)}const g=p.getAttribute("data-sdt-id")??p.getAttribute("data-sdt-container-id");g&&d.add(g),p.classList.contains("superdoc-table-fragment")&&s.tableId==null&&(s.tableId=p.getAttribute("data-layout-block-ref"))}s.contentControlIds=[...d],s.contextSource="painted-pointer",s.fragmentId&&s.pageIndex!=null&&(s.selector=`[data-page-index="${s.pageIndex}"] ${o}`);const f=[];for(let p=t;p;p=p.parentElement){const g=this.root.ownerDocument.defaultView.getComputedStyle(p),m=p===this.root||/auto|scroll/.test(`${g.overflowX} ${g.overflowY}`);if(p.scrollLeft||p.scrollTop||m&&(p.scrollWidth>p.clientWidth||p.scrollHeight>p.clientHeight)){const v=[];let C=p;for(;C&&C!==this.root;){const w=C.parentElement;if(!w)break;v.unshift(`:nth-child(${Array.prototype.indexOf.call(w.children,C)+1})`),C=w}C===this.root&&f.push({selector:p===this.root?null:`:scope > ${v.join(" > ")}`,scrollLeft:p.scrollLeft,scrollTop:p.scrollTop})}if(p===this.root)break;if(f.length>=32)throw new Error("scroll-ancestor-limit")}s.scrollAncestors=f}const a={target:s,inputAtMs:e.timeStamp>this.root.ownerDocument.defaultView.performance.timeOrigin?e.timeStamp-this.root.ownerDocument.defaultView.performance.timeOrigin:e.timeStamp,altKey:i.altKey,ctrlKey:i.ctrlKey,metaKey:i.metaKey,shiftKey:i.shiftKey};if(e.type==="keydown"||e.type==="keyup"){const l=i.key;e.type==="keydown"?this.heldKeys.add(l):this.heldKeys.delete(l);const u=Gx.has(l)||/^F(?:[1-9]|1\d|2[0-4])$/.test(l);a.key=!u&&!this.session.captureContent?void 0:l,a.repeat=i.repeat,a.isComposing=i.isComposing,!u&&!this.session.captureContent&&this.unsupported("content-redacted"),(i.isComposing||l==="Dead"||l==="Process")&&this.unsupported("ime")}else if(e.type.startsWith("pointer")||["mousedown","mouseup","click","dblclick"].includes(e.type)){const l=(r??this.root).getBoundingClientRect();e.type==="pointerdown"&&this.heldButtons.add(n.button),e.type==="pointerup"&&this.heldButtons.delete(n.button),Object.assign(a,{button:n.button,buttons:n.buttons,pointerType:n.pointerType??"mouse",clickCount:n.detail,x:n.clientX-l.left,y:n.clientY-l.top}),n.pointerType&&n.pointerType!=="mouse"&&this.unsupported("non-mouse-pointer"),o||this.unsupported("unresolved-pointer-target")}else if(e.type==="scroll")Object.assign(a,{scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t!==this.root&&!o&&this.unsupported("unresolved-scroll-target");else{const l=e;Object.assign(a,{inputType:l.inputType,dataLength:l.data?.length,...this.session.captureContent?{data:l.data}:{}}),l.data&&!this.session.captureContent&&this.unsupported("content-redacted"),["paste","cut","drop","dragstart","compositionstart","compositionend"].includes(e.type)&&this.unsupported(e.type),e.type==="beforeinput"&&l.inputType!=="insertText"&&!l.inputType?.startsWith("delete")&&this.unsupported(`beforeinput:${l.inputType}`)}this.observe(`browser:${e.type}`,()=>a)}catch{this.fail("capture-failure")}}clearHeldInput(){this.heldKeys.clear(),this.heldButtons.clear()}stop(){return this.active&&((this.heldKeys.size||this.heldButtons.size)&&this.unsupported("held-input-at-stop"),this.session.durationMs=this.root.ownerDocument.defaultView.performance.now()-this.startMs,this.session.status="stopped",this.clearHeldInput()),this.detachInputs(),this.snapshot()}snapshot(){return this.session?{...this.session,viewport:{...this.session.viewport},durationMs:this.active?this.root.ownerDocument.defaultView.performance.now()-this.startMs:this.session.durationMs,replayUnsupportedReasons:[...this.session.replayUnsupportedReasons],events:this.events.map(e=>JSON.parse(e)),pendingIntentIds:[...this.pendingIntents]}:null}close(){this.active&&this.fail("instance-destroyed"),this.closed=!0,this.detachInputs()}};function g2(e){try{return ls(ls(ls(e,"diagnostics"),"recording"),"enabled")===!0}catch{return!1}}var uu=new WeakMap,qx=0,v2=["documentId","generation","actionId","commandId","operation","source","origin","outcome","phase","success","changed","dryRun","revision","txId","direction","inputType","inputKind","editableCommandKind","dataLength","isComposing","hasRangeSelection","durationMs","elapsedMs","code","reason","failureSource","diagnosticCode","diagnosticStage","internalCode","severity","status","state","beforeHello","remoteGeneration","changedStoryIds","changedPartUris","reviewChanged","saveId","byteLength","targetCommitSequence","paintedCommitSequence","paintedRenderInputEpoch","health","commitSequence","documentEpoch","renderInputEpoch","layoutEpoch","renderEpoch","hasCommitEvent","input","receipt","result","failure","selection","target","selectionTarget","start","end","from","to","offset","blockId","nodeId","kind","story","storyType","id","empty","activeMarks","affectedStories","inserted","updated","removed","invalidatedRefs","remappedRefs","textRangeShifts","insertedLength","deletedLength","renderCommit","snapshot","lifecycle","workerFailure","timing","selectionBefore","selectionAfter"],Yx=["text","data","message","errorMessage","quotedText","value"];function ls(e,t){if(!(!e||typeof e!="object"))return Object.getOwnPropertyDescriptor(e,t)?.value}function y2(e,t,n){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0&&e<=n?e:t}var Xx=class{constructor(e,t,n){if(this.version=t,this.sessionId=`interaction-${++qx}`,this.slots=[],this.head=0,this.count=0,this.sequence=0,this.actions=0,this.bytes=0,this.evicted=0,this.truncated=0,this.failures=0,this.closed=!1,this.cleanups=[],g2(e))try{this.workflow=new Kx(n,t)}catch{}const r=ls(ls(e,"diagnostics"),"history");this.enabled=ls(r,"enabled")!==!1,this.captureContent=ls(r,"captureContent")===!0,this.maxEvents=y2(ls(r,"maxEvents"),500,1e4),this.maxBytes=y2(ls(r,"maxBytes"),1048576,16777216)}record(e,t){if(this.workflow?.observe(e,t),!(!this.enabled||this.closed))try{let n=!1,r=128;const o=(l,u=0)=>{if(--r<0||u>5){n=!0;return}if(l===null||typeof l=="boolean")return l;if(typeof l=="number")return Number.isFinite(l)?l:void 0;if(typeof l=="string")return l.length>512&&(n=!0),l.slice(0,512);if(!l||typeof l!="object")return;if(Array.isArray(l)){const f=Math.min(l.length,16);l.length>f&&(n=!0);const p=[];for(let g=0;g<f&&r>0;g++)p.push(o(ls(l,String(g)),u+1)??null);return p}const d={};for(const f of this.captureContent?[...v2,...Yx]:v2){if(r<=0){n=!0;break}const p=ls(l,f);if(p===void 0)continue;const g=o(p,u+1);g!==void 0&&(d[f]=g)}return d},i=o(t())??{};if(e==="selection:changed"){const l=JSON.stringify(i);if(l===this.lastSelection)return;this.lastSelection=l}else this.lastSelection=void 0;const s={sequence:++this.sequence,observedAt:Date.now(),type:e,data:i,truncated:n};let a=JSON.stringify(s);if(a.length*2>Math.min(8192,this.maxBytes)&&(s.data={},s.truncated=!0,a=JSON.stringify(s)),s.truncated&&this.truncated++,a.length*2>this.maxBytes){this.evicted++;return}for(;this.count&&(this.count>=this.maxEvents||this.bytes+a.length*2>this.maxBytes);){const l=this.slots[this.head];this.bytes-=l.length*2,this.slots[this.head]=void 0,this.head=(this.head+1)%this.maxEvents,this.count--,this.evicted++}this.slots[(this.head+this.count)%this.maxEvents]=a,this.count++,this.bytes+=a.length*2}catch{this.failures++}}action(){return(this.enabled||this.workflow?.active)&&!this.closed?`${this.sessionId}:${++this.actions}`:void 0}snapshot(){const e=[];try{for(let n=0;n<this.count;n++)e.push(JSON.parse(this.slots[(this.head+n)%this.maxEvents]))}catch{this.failures++}let t="unknown";try{t=this.version()}catch{this.failures++}return{schemaVersion:1,sessionId:this.sessionId,version:t,enabled:this.enabled,events:e,retainedBytes:this.bytes,evictedEvents:this.evicted,truncatedEvents:this.truncated,captureFailures:this.failures}}clear(){this.slots=[],this.head=0,this.count=0,this.bytes=0,this.evicted=0,this.truncated=0,this.failures=0,this.lastSelection=void 0}attach(e){if(this.enabled)for(const t of["keydown","beforeinput","compositionstart","compositionend","paste","cut","drop"]){const n=r=>this.record(`input:${t}`,()=>{const o=r;if(r.type==="keydown"){const i=r;return{inputKind:["Backspace","Delete","Enter","Tab","Escape","ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(i.key)?i.key:"key",dataLength:i.key.length===1?1:void 0,isComposing:i.isComposing}}return{inputType:o.inputType,dataLength:o.data?.length,isComposing:o.isComposing,...this.captureContent?{data:o.data}:{}}});try{e.addEventListener(t,n,!0),this.cleanups.push(()=>e.removeEventListener(t,n,!0))}catch{this.failures++}}}close(){this.workflow?.close(),this.closed=!0;for(const e of this.cleanups)try{e()}catch{this.failures++}this.cleanups=[]}},b2=()=>({schemaVersion:1,sessionId:"unavailable",version:"unknown",enabled:!1,events:[],retainedBytes:0,evictedEvents:0,truncatedEvents:0,captureFailures:1}),Zx=Object.freeze({getSnapshot:b2,clear(){}});function Qx(e,t,n,r){try{const o=new Xx(t,n,r);uu.set(e,o),o.attach(r);const i=Object.freeze({...o.workflow?{recording:o.workflow.api}:{},getSnapshot:()=>{try{return o.snapshot()}catch{return b2()}},clear:()=>{try{o.clear()}catch{}}});return o.record("instance:created",()=>({})),i}catch{return Zx}}function Wd(e,t,n){try{e&&uu.get(e)?.record(t,n)}catch{}}function Jx(e,t,n){try{const r=uu.get(e),o=r?.action();return o&&r?.record(t,()=>({...n(),actionId:o})),o}catch{return}}function eT(e){try{uu.get(e)?.close(),uu.delete(e)}catch{}}function tT(e){return uu.get(e)?.workflow?.api}var nT=h2(((e,t)=>{var n=Object.prototype.hasOwnProperty,r="~";function o(){}Object.create&&(o.prototype=Object.create(null),new o().__proto__||(r=!1));function i(u,d,f){this.fn=u,this.context=d,this.once=f||!1}function s(u,d,f,p,g){if(typeof f!="function")throw new TypeError("The listener must be a function");var m=new i(f,p||u,g),v=r?r+d:d;return u._events[v]?u._events[v].fn?u._events[v]=[u._events[v],m]:u._events[v].push(m):(u._events[v]=m,u._eventsCount++),u}function a(u,d){--u._eventsCount===0?u._events=new o:delete u._events[d]}function l(){this._events=new o,this._eventsCount=0}l.prototype.eventNames=function(){var d=[],f,p;if(this._eventsCount===0)return d;for(p in f=this._events)n.call(f,p)&&d.push(r?p.slice(1):p);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(f)):d},l.prototype.listeners=function(d){var f=r?r+d:d,p=this._events[f];if(!p)return[];if(p.fn)return[p.fn];for(var g=0,m=p.length,v=new Array(m);g<m;g++)v[g]=p[g].fn;return v},l.prototype.listenerCount=function(d){var f=r?r+d:d,p=this._events[f];return p?p.fn?1:p.length:0},l.prototype.emit=function(d,f,p,g,m,v){var C=r?r+d:d;if(!this._events[C])return!1;var w=this._events[C],S=arguments.length,b,k;if(w.fn){switch(w.once&&this.removeListener(d,w.fn,void 0,!0),S){case 1:return w.fn.call(w.context),!0;case 2:return w.fn.call(w.context,f),!0;case 3:return w.fn.call(w.context,f,p),!0;case 4:return w.fn.call(w.context,f,p,g),!0;case 5:return w.fn.call(w.context,f,p,g,m),!0;case 6:return w.fn.call(w.context,f,p,g,m,v),!0}for(k=1,b=new Array(S-1);k<S;k++)b[k-1]=arguments[k];w.fn.apply(w.context,b)}else{var x=w.length,M;for(k=0;k<x;k++)switch(w[k].once&&this.removeListener(d,w[k].fn,void 0,!0),S){case 1:w[k].fn.call(w[k].context);break;case 2:w[k].fn.call(w[k].context,f);break;case 3:w[k].fn.call(w[k].context,f,p);break;case 4:w[k].fn.call(w[k].context,f,p,g);break;default:if(!b)for(M=1,b=new Array(S-1);M<S;M++)b[M-1]=arguments[M];w[k].fn.apply(w[k].context,b)}}return!0},l.prototype.on=function(d,f,p){return s(this,d,f,p,!1)},l.prototype.once=function(d,f,p){return s(this,d,f,p,!0)},l.prototype.removeListener=function(d,f,p,g){var m=r?r+d:d;if(!this._events[m])return this;if(!f)return a(this,m),this;var v=this._events[m];if(v.fn)v.fn===f&&(!g||v.once)&&(!p||v.context===p)&&a(this,m);else{for(var C=0,w=[],S=v.length;C<S;C++)(v[C].fn!==f||g&&!v[C].once||p&&v[C].context!==p)&&w.push(v[C]);w.length?this._events[m]=w.length===1?w[0]:w:a(this,m)}return this},l.prototype.removeAllListeners=function(d){var f;return d?(f=r?r+d:d,this._events[f]&&a(this,f)):(this._events=new o,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=r,l.EventEmitter=l,typeof t<"u"&&(t.exports=l)})),av=p2(nT(),1),Co=[];for(let e=0;e<256;++e)Co.push((e+256).toString(16).slice(1));function rT(e,t=0){return(Co[e[t+0]]+Co[e[t+1]]+Co[e[t+2]]+Co[e[t+3]]+"-"+Co[e[t+4]]+Co[e[t+5]]+"-"+Co[e[t+6]]+Co[e[t+7]]+"-"+Co[e[t+8]]+Co[e[t+9]]+"-"+Co[e[t+10]]+Co[e[t+11]]+Co[e[t+12]]+Co[e[t+13]]+Co[e[t+14]]+Co[e[t+15]]).toLowerCase()}var lv,oT=new Uint8Array(16);function iT(){if(!lv){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");lv=crypto.getRandomValues.bind(crypto)}return lv(oT)}var sT=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),w2={randomUUID:sT};function fl(e,t,n){if(w2.randomUUID&&!t&&!e)return w2.randomUUID();e=e||{};const r=e.random??e.rng?.()??iT();if(r.length<16)throw new Error("Random bytes length must be >= 16");if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n=n||0,n<0||n+16>t.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let o=0;o<16;++o)t[n+o]=r[o];return t}return rT(r)}function Kd(e){const t=Object.create(null);for(const n of e.split(","))t[n]=1;return n=>n in t}function An(e){if(Vt(e)){const t={};for(let n=0;n<e.length;n++){const r=e[n],o=rr(r)?aT(r):An(r);if(o)for(const i in o)t[i]=o[i]}return t}else if(rr(e)||Un(e))return e}function aT(e){const t={};return e.replace(M2,"").split(T2).forEach(n=>{if(n){const r=n.split(R2);r.length>1&&(t[r[0].trim()]=r[1].trim())}}),t}function Zt(e){let t="";if(rr(e))t=e;else if(Vt(e))for(let n=0;n<e.length;n++){const r=Zt(e[n]);r&&(t+=r+" ")}else if(Un(e))for(const n in e)e[n]&&(t+=n+" ");return t.trim()}function cv(e){if(!e)return null;let{class:t,style:n}=e;return t&&!rr(t)&&(e.class=Zt(t)),n&&(e.style=An(n)),e}function C2(e){return!!e||e===""}function lT(e,t){if(e.length!==t.length)return!1;let n=!0;for(let r=0;n&&r<e.length;r++)n=ba(e[r],t[r]);return n}function ba(e,t){if(e===t)return!0;let n=dv(e),r=dv(t);if(n||r)return n&&r?e.getTime()===t.getTime():!1;if(n=ri(e),r=ri(t),n||r)return e===t;if(n=Vt(e),r=Vt(t),n||r)return n&&r?lT(e,t):!1;if(n=Un(e),r=Un(t),n||r){if(!n||!r||Object.keys(e).length!==Object.keys(t).length)return!1;for(const o in e){const i=e.hasOwnProperty(o),s=t.hasOwnProperty(o);if(i&&!s||!i&&s||!ba(e[o],t[o]))return!1}}return String(e)===String(t)}function ep(e,t){return e.findIndex(n=>ba(n,t))}function cT(e){return e==null?"initial":typeof e=="string"?e===""?" ":e:(typeof e!="number"||Number.isFinite(e),String(e))}var Fn,fc,Ci,uv,du,qd,Yn,tp,k2,Gn,Vt,hc,hl,dv,S2,nn,rr,ri,Un,np,fv,pc,_2,Yd,Xd,pl,Zd,A2,jr,I2,Go,fu,hu,so,mc,hv,Qd,Jd,E2,ef,x2,T2,R2,M2,pv,L2,uT,mv,Et,gv,rp,vv=Lr((()=>{Fn={},fc=[],Ci=()=>{},uv=()=>!1,du=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),qd=e=>e.startsWith("onUpdate:"),Yn=Object.assign,tp=(e,t)=>{const n=e.indexOf(t);n>-1&&e.splice(n,1)},k2=Object.prototype.hasOwnProperty,Gn=(e,t)=>k2.call(e,t),Vt=Array.isArray,hc=e=>pc(e)==="[object Map]",hl=e=>pc(e)==="[object Set]",dv=e=>pc(e)==="[object Date]",S2=e=>pc(e)==="[object RegExp]",nn=e=>typeof e=="function",rr=e=>typeof e=="string",ri=e=>typeof e=="symbol",Un=e=>e!==null&&typeof e=="object",np=e=>(Un(e)||nn(e))&&nn(e.then)&&nn(e.catch),fv=Object.prototype.toString,pc=e=>fv.call(e),_2=e=>pc(e).slice(8,-1),Yd=e=>pc(e)==="[object Object]",Xd=e=>rr(e)&&e!=="NaN"&&e[0]!=="-"&&""+parseInt(e,10)===e,pl=Kd(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),Zd=e=>{const t=Object.create(null);return(n=>t[n]||(t[n]=e(n)))},A2=/-\w/g,jr=Zd(e=>e.replace(A2,t=>t.slice(1).toUpperCase())),I2=/\B([A-Z])/g,Go=Zd(e=>e.replace(I2,"-$1").toLowerCase()),fu=Zd(e=>e.charAt(0).toUpperCase()+e.slice(1)),hu=Zd(e=>e?`on${fu(e)}`:""),so=(e,t)=>!Object.is(e,t),mc=(e,...t)=>{for(let n=0;n<e.length;n++)e[n](...t)},hv=(e,t,n,r=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:n})},Qd=e=>{const t=parseFloat(e);return isNaN(t)?e:t},Jd=e=>{const t=rr(e)?Number(e):NaN;return isNaN(t)?e:t},ef=()=>E2||(E2=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),x2=Kd("Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error,Symbol"),T2=/;(?![^(]*\))/g,R2=/:([^]+)/,M2=/\/\*[^]*?\*\//g,pv="itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly",L2=Kd(pv),uT=Kd(pv+",async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected"),mv=e=>!!(e&&e.__v_isRef===!0),Et=e=>rr(e)?e:e==null?"":Vt(e)||Un(e)&&(e.toString===fv||!nn(e.toString))?mv(e)?Et(e.value):JSON.stringify(e,gv,2):String(e),gv=(e,t)=>mv(t)?gv(e,t.value):hc(t)?{[`Map(${t.size})`]:[...t.entries()].reduce((n,[r,o],i)=>(n[rp(r,i)+" =>"]=o,n),{})}:hl(t)?{[`Set(${t.size})`]:[...t.values()].map(n=>rp(n))}:ri(t)?rp(t):Un(t)&&!Vt(t)&&!Yd(t)?String(t):t,rp=(e,t="")=>{var n;return ri(e)?`Symbol(${(n=e.description)!=null?n:t})`:e}}));function yv(e){return new cp(e)}function bv(){return Po}function P2(e,t=!1){Po&&Po.cleanups.push(e)}function D2(e,t=!1){if(e.flags|=8,t){e.next=of,of=e;return}e.next=rf,rf=e}function wv(){xv++}function Cv(){if(--xv>0)return;if(of){let t=of;for(of=void 0;t;){const n=t.next;t.next=void 0,t.flags&=-9,t=n}}let e;for(;rf;){let t=rf;for(rf=void 0;t;){const n=t.next;if(t.next=void 0,t.flags&=-9,t.flags&1)try{t.trigger()}catch(r){e||(e=r)}t=n}}if(e)throw e}function O2(e){for(let t=e.deps;t;t=t.nextDep)t.version=-1,t.prevActiveLink=t.dep.activeLink,t.dep.activeLink=t}function F2(e){let t,n=e.depsTail,r=n;for(;r;){const o=r.prevDep;r.version===-1?(r===n&&(n=o),Sv(r),dT(r)):t=r,r.dep.activeLink=r.prevActiveLink,r.prevActiveLink=void 0,r=o}e.deps=t,e.depsTail=n}function kv(e){for(let t=e.deps;t;t=t.nextDep)if(t.dep.version!==t.version||t.dep.computed&&(N2(t.dep.computed)||t.dep.version!==t.version))return!0;return!!e._dirty}function N2(e){if(e.flags&4&&!(e.flags&16)||(e.flags&=-17,e.globalVersion===gu)||(e.globalVersion=gu,!e.isSSR&&e.flags&128&&(!e.deps&&!e._dirty||!kv(e))))return;e.flags|=2;const t=e.dep,n=cr,r=ji;cr=e,ji=!0;try{O2(e);const o=e.fn(e._value);(t.version===0||so(o,e._value))&&(e.flags|=128,e._value=o,t.version++)}catch(o){throw t.version++,o}finally{cr=n,ji=r,F2(e),e.flags&=-3}}function Sv(e,t=!1){const{dep:n,prevSub:r,nextSub:o}=e;if(r&&(r.nextSub=o,e.prevSub=void 0),o&&(o.prevSub=r,e.nextSub=void 0),n.subs===e&&(n.subs=r,!r&&n.computed)){n.computed.flags&=-5;for(let i=n.computed.deps;i;i=i.nextDep)Sv(i,!0)}!t&&!--n.sc&&n.map&&n.map.delete(n.key)}function dT(e){const{prevDep:t,nextDep:n}=e;t&&(t.nextDep=n,e.prevDep=void 0),n&&(n.prevDep=t,e.nextDep=void 0)}function fT(e,t){e.effect instanceof mu&&(e=e.effect.fn);const n=new mu(e);t&&Yn(n,t);try{n.run()}catch(o){throw n.stop(),o}const r=n.run.bind(n);return r.effect=n,r}function hT(e){e.effect.stop()}function wa(){Tv.push(ji),ji=!1}function Ca(){const e=Tv.pop();ji=e===void 0?!0:e}function B2(e){const{cleanup:t}=e;if(e.cleanup=void 0,t){const n=cr;cr=void 0;try{t()}finally{cr=n}}}function z2(e){if(e.dep.sc++,e.sub.flags&4){const t=e.dep.computed;if(t&&!e.dep.subs){t.flags|=20;for(let r=t.deps;r;r=r.nextDep)z2(r)}const n=e.dep.subs;n!==e&&(e.prevSub=n,n&&(n.nextSub=e)),e.dep.subs=e}}function Lo(e,t,n){if(ji&&cr){let r=af.get(e);r||af.set(e,r=new Map);let o=r.get(n);o||(r.set(n,o=new sf),o.map=r,o.key=n),o.track()}}function ka(e,t,n,r,o,i){const s=af.get(e);if(!s){gu++;return}const a=l=>{l&&l.trigger()};if(wv(),t==="clear")s.forEach(a);else{const l=Vt(e),u=l&&Xd(n);if(l&&n==="length"){const d=Number(r);s.forEach((f,p)=>{(p==="length"||p===vu||!ri(p)&&p>=d)&&a(f)})}else switch((n!==void 0||s.has(void 0))&&a(s.get(n)),u&&a(s.get(vu)),t){case"add":l?u&&a(s.get("length")):(a(s.get(ml)),hc(e)&&a(s.get(dp)));break;case"delete":l||(a(s.get(ml)),hc(e)&&a(s.get(dp)));break;case"set":hc(e)&&a(s.get(ml));break}}Cv()}function pT(e,t){const n=af.get(e);return n&&n.get(t)}function pu(e){const t=Cn(e);return t===e?t:(Lo(t,"iterate",vu),oi(e)?t:t.map(Vi))}function op(e){return Lo(e=Cn(e),"iterate",vu),e}function zs(e,t){return js(e)?gc(zi(e)?Vi(t):t):Vi(t)}function _v(e,t,n){const r=op(e),o=r[t]();return r!==e&&!oi(e)&&(o._next=o.next,o.next=()=>{const i=o._next();return i.done||(i.value=n(i.value)),i}),o}function Sa(e,t,n,r,o,i){const s=op(e),a=s!==e&&!oi(e),l=s[t];if(l!==Y2[t]){const f=l.apply(e,i);return a?Vi(f):f}let u=n;s!==e&&(a?u=function(f,p){return n.call(this,zs(e,f),p,e)}:n.length>2&&(u=function(f,p){return n.call(this,f,p,e)}));const d=l.call(s,u,r);return a&&o?o(d):d}function j2(e,t,n,r){const o=op(e),i=o!==e&&!oi(e);let s=n,a=!1;o!==e&&(i?(a=r.length===0,s=function(u,d,f){return a&&(a=!1,u=zs(e,u)),n.call(this,u,zs(e,d),f,e)}):n.length>3&&(s=function(u,d,f){return n.call(this,u,d,f,e)}));const l=o[t](s,...r);return a?zs(e,l):l}function Av(e,t,n){const r=Cn(e);Lo(r,"iterate",vu);const o=r[t](...n);return(o===-1||o===!1)&&nf(n[0])?(n[0]=Cn(n[0]),r[t](...n)):o}function tf(e,t,n=[]){wa(),wv();const r=Cn(e)[t].apply(e,n);return Cv(),Ca(),r}function mT(e){ri(e)||(e=String(e));const t=Cn(this);return Lo(t,"has",e),t.hasOwnProperty(e)}function gT(e,t,n){return function(...r){const o=this.__v_raw,i=Cn(o),s=hc(i),a=e==="entries"||e===Symbol.iterator&&s,l=e==="keys"&&s,u=o[e](...r),d=n?fp:t?gc:Vi;return!t&&Lo(i,"iterate",l?dp:ml),Yn(Object.create(u),{next(){const{value:f,done:p}=u.next();return p?{value:f,done:p}:{value:a?[d(f[0]),d(f[1])]:d(f),done:p}}})}}function ip(e){return function(...t){return e==="delete"?!1:e==="clear"?void 0:this}}function vT(e,t){const n={get(r){const o=this.__v_raw,i=Cn(o),s=Cn(r);e||(so(r,s)&&Lo(i,"get",r),Lo(i,"get",s));const{has:a}=lf(i),l=t?fp:e?gc:Vi;if(a.call(i,r))return l(o.get(r));if(a.call(i,s))return l(o.get(s));o!==i&&o.get(r)},get size(){const r=this.__v_raw;return!e&&Lo(Cn(r),"iterate",ml),r.size},has(r){const o=this.__v_raw,i=Cn(o),s=Cn(r);return e||(so(r,s)&&Lo(i,"has",r),Lo(i,"has",s)),r===s?o.has(r):o.has(r)||o.has(s)},forEach(r,o){const i=this,s=i.__v_raw,a=Cn(s),l=t?fp:e?gc:Vi;return!e&&Lo(a,"iterate",ml),s.forEach((u,d)=>r.call(o,l(u),l(d),i))}};return Yn(n,e?{add:ip("add"),set:ip("set"),delete:ip("delete"),clear:ip("clear")}:{add(r){const o=Cn(this),i=lf(o),s=Cn(r),a=!t&&!oi(r)&&!js(r)?s:r;return i.has.call(o,a)||so(r,a)&&i.has.call(o,r)||so(s,a)&&i.has.call(o,s)||(o.add(a),ka(o,"add",a,a)),this},set(r,o){!t&&!oi(o)&&!js(o)&&(o=Cn(o));const i=Cn(this),{has:s,get:a}=lf(i);let l=s.call(i,r);l||(r=Cn(r),l=s.call(i,r));const u=a.call(i,r);return i.set(r,o),l?so(o,u)&&ka(i,"set",r,o,u):ka(i,"add",r,o),this},delete(r){const o=Cn(this),{has:i,get:s}=lf(o);let a=i.call(o,r);a||(r=Cn(r),a=i.call(o,r));const l=s?s.call(o,r):void 0,u=o.delete(r);return a&&ka(o,"delete",r,void 0,l),u},clear(){const r=Cn(this),o=r.size!==0,i=void 0,s=r.clear();return o&&ka(r,"clear",void 0,void 0,i),s}}),["keys","values","entries",Symbol.iterator].forEach(r=>{n[r]=gT(r,e,t)}),n}function sp(e,t){const n=vT(e,t);return(r,o,i)=>o==="__v_isReactive"?!e:o==="__v_isReadonly"?e:o==="__v_raw"?r:Reflect.get(Gn(n,o)&&o in r?n:r,o,i)}function yT(e){switch(e){case"Object":case"Array":return 1;case"Map":case"Set":case"WeakMap":case"WeakSet":return 2;default:return 0}}function bT(e){return e.__v_skip||!Object.isExtensible(e)?0:yT(_2(e))}function Qr(e){return js(e)?e:lp(e,!1,Z2,tw,Dv)}function V2(e){return lp(e,!1,J2,nw,Ov)}function ap(e){return lp(e,!0,Q2,rw,Fv)}function wT(e){return lp(e,!0,ew,ow,Nv)}function lp(e,t,n,r,o){if(!Un(e)||e.__v_raw&&!(t&&e.__v_isReactive))return e;const i=bT(e);if(i===0)return e;const s=o.get(e);if(s)return s;const a=new Proxy(e,i===2?r:n);return o.set(e,a),a}function zi(e){return js(e)?zi(e.__v_raw):!!(e&&e.__v_isReactive)}function js(e){return!!(e&&e.__v_isReadonly)}function oi(e){return!!(e&&e.__v_isShallow)}function nf(e){return e?!!e.__v_raw:!1}function Cn(e){const t=e&&e.__v_raw;return t?Cn(t):e}function Gr(e){return!Gn(e,"__v_skip")&&Object.isExtensible(e)&&hv(e,"__v_skip",!0),e}function hr(e){return e?e.__v_isRef===!0:!1}function te(e){return U2(e,!1)}function Pr(e){return U2(e,!0)}function U2(e,t){return hr(e)?e:new iw(e,t)}function CT(e){e.dep&&e.dep.trigger()}function et(e){return hr(e)?e.value:e}function kT(e){return nn(e)?e():et(e)}function Iv(e){return zi(e)?e:new Proxy(e,sw)}function $2(e){return new aw(e)}function H2(e){const t=Vt(e)?new Array(e.length):{};for(const n in e)t[n]=G2(e,n);return t}function Ev(e,t,n){return hr(e)?e:nn(e)?new cw(e):Un(e)&&arguments.length>1?G2(e,t,n):te(e)}function G2(e,t,n){return new lw(e,t,n)}function ST(e,t,n=!1){let r,o;return nn(e)?r=e:(r=e.get,o=e.set),new uw(r,o,n)}function _T(){return Aa}function W2(e,t=!1,n=Aa){if(n){let r=uf.get(n);r||uf.set(n,r=[]),r.push(e)}}function AT(e,t,n=Fn){const{immediate:r,deep:o,once:i,scheduler:s,augmentJob:a,call:l}=n,u=k=>o?k:oi(k)||o===!1||o===0?_a(k,1):_a(k);let d,f,p,g,m=!1,v=!1;if(hr(e)?(f=()=>e.value,m=oi(e)):zi(e)?(f=()=>u(e),m=!0):Vt(e)?(v=!0,m=e.some(k=>zi(k)||oi(k)),f=()=>e.map(k=>{if(hr(k))return k.value;if(zi(k))return u(k);if(nn(k))return l?l(k,2):k()})):nn(e)?t?f=l?()=>l(e,2):e:f=()=>{if(p){wa();try{p()}finally{Ca()}}const k=Aa;Aa=d;try{return l?l(e,3,[g]):e(g)}finally{Aa=k}}:f=Ci,t&&o){const k=f,x=o===!0?1/0:o;f=()=>_a(k(),x)}const C=bv(),w=()=>{d.stop(),C&&C.active&&tp(C.effects,d)};if(i&&t){const k=t;t=(...x)=>{k(...x),w()}}let S=v?new Array(e.length).fill(cf):cf;const b=k=>{if(!(!(d.flags&1)||!d.dirty&&!k))if(t){const x=d.run();if(o||m||(v?x.some((M,z)=>so(M,S[z])):so(x,S))){p&&p();const M=Aa;Aa=d;try{const z=[x,S===cf?void 0:v&&S[0]===cf?[]:S,g];S=x,l?l(t,3,z):t(...z)}finally{Aa=M}}}else d.run()};return a&&a(b),d=new mu(f),d.scheduler=s?()=>s(b,!1):b,g=k=>W2(k,!1,d),p=d.onStop=()=>{const k=uf.get(d);if(k){if(l)l(k,4);else for(const x of k)x();uf.delete(d)}},t?r?b(!0):S=d.run():s?s(b.bind(null,!0),!0):d.run(),w.pause=d.pause.bind(d),w.resume=d.resume.bind(d),w.stop=w,w}function _a(e,t=1/0,n){if(t<=0||!Un(e)||e.__v_skip||(n=n||new Map,(n.get(e)||0)>=t))return e;if(n.set(e,t),t--,hr(e))_a(e.value,t,n);else if(Vt(e))for(let r=0;r<e.length;r++)_a(e[r],t,n);else if(hl(e)||hc(e))e.forEach(r=>{_a(r,t,n)});else if(Yd(e)){for(const r in e)_a(e[r],t,n);for(const r of Object.getOwnPropertySymbols(e))Object.prototype.propertyIsEnumerable.call(e,r)&&_a(e[r],t,n)}return e}var Po,cp,cr,up,mu,xv,rf,of,ji,Tv,gu,K2,sf,af,ml,dp,vu,q2,Y2,X2,Rv,Mv,Lv,Pv,Z2,Q2,J2,ew,fp,lf,tw,nw,rw,ow,Dv,Ov,Fv,Nv,Vi,gc,iw,sw,aw,lw,cw,uw,dw,fw,cf,uf,Aa,IT=Lr((()=>{vv(),cp=class{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this.__v_skip=!0,this.parent=Po,!e&&Po&&(this.index=(Po.scopes||(Po.scopes=[])).push(this)-1)}get active(){return this._active}pause(){if(this._active){this._isPaused=!0;let e,t;if(this.scopes)for(e=0,t=this.scopes.length;e<t;e++)this.scopes[e].pause();for(e=0,t=this.effects.length;e<t;e++)this.effects[e].pause()}}resume(){if(this._active&&this._isPaused){this._isPaused=!1;let e,t;if(this.scopes)for(e=0,t=this.scopes.length;e<t;e++)this.scopes[e].resume();for(e=0,t=this.effects.length;e<t;e++)this.effects[e].resume()}}run(e){if(this._active){const t=Po;try{return Po=this,e()}finally{Po=t}}}on(){++this._on===1&&(this.prevScope=Po,Po=this)}off(){this._on>0&&--this._on===0&&(Po=this.prevScope,this.prevScope=void 0)}stop(e){if(this._active){this._active=!1;let t,n;for(t=0,n=this.effects.length;t<n;t++)this.effects[t].stop();for(this.effects.length=0,t=0,n=this.cleanups.length;t<n;t++)this.cleanups[t]();if(this.cleanups.length=0,this.scopes){for(t=0,n=this.scopes.length;t<n;t++)this.scopes[t].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){const r=this.parent.scopes.pop();r&&r!==this&&(this.parent.scopes[this.index]=r,r.index=this.index)}this.parent=void 0}}},up=new WeakSet,mu=class{constructor(e){this.fn=e,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0,Po&&Po.active&&Po.effects.push(this)}pause(){this.flags|=64}resume(){this.flags&64&&(this.flags&=-65,up.has(this)&&(up.delete(this),this.trigger()))}notify(){this.flags&2&&!(this.flags&32)||this.flags&8||D2(this)}run(){if(!(this.flags&1))return this.fn();this.flags|=2,B2(this),O2(this);const e=cr,t=ji;cr=this,ji=!0;try{return this.fn()}finally{F2(this),cr=e,ji=t,this.flags&=-3}}stop(){if(this.flags&1){for(let e=this.deps;e;e=e.nextDep)Sv(e);this.deps=this.depsTail=void 0,B2(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){this.flags&64?up.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){kv(this)&&this.run()}get dirty(){return kv(this)}},xv=0,ji=!0,Tv=[],gu=0,K2=class{constructor(e,t){this.sub=e,this.dep=t,this.version=t.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}},sf=class{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(e){if(!cr||!ji||cr===this.computed)return;let t=this.activeLink;if(t===void 0||t.sub!==cr)t=this.activeLink=new K2(cr,this),cr.deps?(t.prevDep=cr.depsTail,cr.depsTail.nextDep=t,cr.depsTail=t):cr.deps=cr.depsTail=t,z2(t);else if(t.version===-1&&(t.version=this.version,t.nextDep)){const n=t.nextDep;n.prevDep=t.prevDep,t.prevDep&&(t.prevDep.nextDep=n),t.prevDep=cr.depsTail,t.nextDep=void 0,cr.depsTail.nextDep=t,cr.depsTail=t,cr.deps===t&&(cr.deps=n)}return t}trigger(e){this.version++,gu++,this.notify(e)}notify(e){wv();try{for(let t=this.subs;t;t=t.prevSub)t.sub.notify()&&t.sub.dep.notify()}finally{Cv()}}},af=new WeakMap,ml=Symbol(""),dp=Symbol(""),vu=Symbol(""),q2={__proto__:null,[Symbol.iterator](){return _v(this,Symbol.iterator,e=>zs(this,e))},concat(...e){return pu(this).concat(...e.map(t=>Vt(t)?pu(t):t))},entries(){return _v(this,"entries",e=>(e[1]=zs(this,e[1]),e))},every(e,t){return Sa(this,"every",e,t,void 0,arguments)},filter(e,t){return Sa(this,"filter",e,t,n=>n.map(r=>zs(this,r)),arguments)},find(e,t){return Sa(this,"find",e,t,n=>zs(this,n),arguments)},findIndex(e,t){return Sa(this,"findIndex",e,t,void 0,arguments)},findLast(e,t){return Sa(this,"findLast",e,t,n=>zs(this,n),arguments)},findLastIndex(e,t){return Sa(this,"findLastIndex",e,t,void 0,arguments)},forEach(e,t){return Sa(this,"forEach",e,t,void 0,arguments)},includes(...e){return Av(this,"includes",e)},indexOf(...e){return Av(this,"indexOf",e)},join(e){return pu(this).join(e)},lastIndexOf(...e){return Av(this,"lastIndexOf",e)},map(e,t){return Sa(this,"map",e,t,void 0,arguments)},pop(){return tf(this,"pop")},push(...e){return tf(this,"push",e)},reduce(e,...t){return j2(this,"reduce",e,t)},reduceRight(e,...t){return j2(this,"reduceRight",e,t)},shift(){return tf(this,"shift")},some(e,t){return Sa(this,"some",e,t,void 0,arguments)},splice(...e){return tf(this,"splice",e)},toReversed(){return pu(this).toReversed()},toSorted(e){return pu(this).toSorted(e)},toSpliced(...e){return pu(this).toSpliced(...e)},unshift(...e){return tf(this,"unshift",e)},values(){return _v(this,"values",e=>zs(this,e))}},Y2=Array.prototype,X2=Kd("__proto__,__v_isRef,__isVue"),Rv=new Set(Object.getOwnPropertyNames(Symbol).filter(e=>e!=="arguments"&&e!=="caller").map(e=>Symbol[e]).filter(ri)),Mv=class{constructor(e=!1,t=!1){this._isReadonly=e,this._isShallow=t}get(e,t,n){if(t==="__v_skip")return e.__v_skip;const r=this._isReadonly,o=this._isShallow;if(t==="__v_isReactive")return!r;if(t==="__v_isReadonly")return r;if(t==="__v_isShallow")return o;if(t==="__v_raw")return n===(r?o?Nv:Fv:o?Ov:Dv).get(e)||Object.getPrototypeOf(e)===Object.getPrototypeOf(n)?e:void 0;const i=Vt(e);if(!r){let a;if(i&&(a=q2[t]))return a;if(t==="hasOwnProperty")return mT}const s=Reflect.get(e,t,hr(e)?e:n);if((ri(t)?Rv.has(t):X2(t))||(r||Lo(e,"get",t),o))return s;if(hr(s)){const a=i&&Xd(t)?s:s.value;return r&&Un(a)?ap(a):a}return Un(s)?r?ap(s):Qr(s):s}},Lv=class extends Mv{constructor(e=!1){super(!1,e)}set(e,t,n,r){let o=e[t];const i=Vt(e)&&Xd(t);if(!this._isShallow){const l=js(o);if(!oi(n)&&!js(n)&&(o=Cn(o),n=Cn(n)),!i&&hr(o)&&!hr(n))return l||(o.value=n),!0}const s=i?Number(t)<e.length:Gn(e,t),a=Reflect.set(e,t,n,hr(e)?e:r);return e===Cn(r)&&(s?so(n,o)&&ka(e,"set",t,n,o):ka(e,"add",t,n)),a}deleteProperty(e,t){const n=Gn(e,t),r=e[t],o=Reflect.deleteProperty(e,t);return o&&n&&ka(e,"delete",t,void 0,r),o}has(e,t){const n=Reflect.has(e,t);return(!ri(t)||!Rv.has(t))&&Lo(e,"has",t),n}ownKeys(e){return Lo(e,"iterate",Vt(e)?"length":ml),Reflect.ownKeys(e)}},Pv=class extends Mv{constructor(e=!1){super(!0,e)}set(e,t){return!0}deleteProperty(e,t){return!0}},Z2=new Lv,Q2=new Pv,J2=new Lv(!0),ew=new Pv(!0),fp=e=>e,lf=e=>Reflect.getPrototypeOf(e),tw={get:sp(!1,!1)},nw={get:sp(!1,!0)},rw={get:sp(!0,!1)},ow={get:sp(!0,!0)},Dv=new WeakMap,Ov=new WeakMap,Fv=new WeakMap,Nv=new WeakMap,Vi=e=>Un(e)?Qr(e):e,gc=e=>Un(e)?ap(e):e,iw=class{constructor(e,t){this.dep=new sf,this.__v_isRef=!0,this.__v_isShallow=!1,this._rawValue=t?e:Cn(e),this._value=t?e:Vi(e),this.__v_isShallow=t}get value(){return this.dep.track(),this._value}set value(e){const t=this._rawValue,n=this.__v_isShallow||oi(e)||js(e);e=n?e:Cn(e),so(e,t)&&(this._rawValue=e,this._value=n?e:Vi(e),this.dep.trigger())}},sw={get:(e,t,n)=>t==="__v_raw"?e:et(Reflect.get(e,t,n)),set:(e,t,n,r)=>{const o=e[t];return hr(o)&&!hr(n)?(o.value=n,!0):Reflect.set(e,t,n,r)}},aw=class{constructor(e){this.__v_isRef=!0,this._value=void 0;const t=this.dep=new sf,{get:n,set:r}=e(t.track.bind(t),t.trigger.bind(t));this._get=n,this._set=r}get value(){return this._value=this._get()}set value(e){this._set(e)}},lw=class{constructor(e,t,n){this._object=e,this._defaultValue=n,this.__v_isRef=!0,this._value=void 0,this._key=ri(t)?t:String(t),this._raw=Cn(e);let r=!0,o=e;if(!Vt(e)||ri(this._key)||!Xd(this._key))do r=!nf(o)||oi(o);while(r&&(o=o.__v_raw));this._shallow=r}get value(){let e=this._object[this._key];return this._shallow&&(e=et(e)),this._value=e===void 0?this._defaultValue:e}set value(e){if(this._shallow&&hr(this._raw[this._key])){const t=this._object[this._key];if(hr(t)){t.value=e;return}}this._object[this._key]=e}get dep(){return pT(this._raw,this._key)}},cw=class{constructor(e){this._getter=e,this.__v_isRef=!0,this.__v_isReadonly=!0,this._value=void 0}get value(){return this._value=this._getter()}},uw=class{constructor(e,t,n){this.fn=e,this.setter=t,this._value=void 0,this.dep=new sf(this),this.__v_isRef=!0,this.deps=void 0,this.depsTail=void 0,this.flags=16,this.globalVersion=gu-1,this.next=void 0,this.effect=this,this.__v_isReadonly=!t,this.isSSR=n}notify(){if(this.flags|=16,!(this.flags&8)&&cr!==this)return D2(this,!0),!0}get value(){const e=this.dep.track();return N2(this),e&&(e.version=this.dep.version),this._value}set value(e){this.setter&&this.setter(e)}},dw={GET:"get",HAS:"has",ITERATE:"iterate"},fw={SET:"set",ADD:"add",DELETE:"delete",CLEAR:"clear"},cf={},uf=new WeakMap,Aa=void 0}));function ET(e){ry.push(e)}function xT(){ry.pop()}function TT(e,t){}function yu(e,t,n,r){try{return r?e(...r):e()}catch(o){vc(o,t,n)}}function Ui(e,t,n,r){if(nn(e)){const o=yu(e,t,n,r);return o&&np(o)&&o.catch(i=>{vc(i,t,n)}),o}if(Vt(e)){const o=[];for(let i=0;i<e.length;i++)o.push(Ui(e[i],t,n,r));return o}}function vc(e,t,n,r=!0){const o=t?t.vnode:null,{errorHandler:i,throwUnhandledErrorInProduction:s}=t&&t.appContext.config||Fn;if(t){let a=t.parent;const l=t.proxy,u=`https://vuejs.org/error-reference/#runtime-${n}`;for(;a;){const d=a.ec;if(d){for(let f=0;f<d.length;f++)if(d[f](e,l,u)===!1)return}a=a.parent}if(i){wa(),yu(i,null,10,[e,l,u]),Ca();return}}RT(e,n,o,r,s)}function RT(e,t,n,r=!0,o=!1){if(o)throw e;console.error(e)}function Ct(e){const t=Cf||oy;return e?t.then(this?e.bind(this):e):t}function MT(e){let t=us+1,n=Do.length;for(;t<n;){const r=t+n>>>1,o=Do[r],i=Su(o);i<e||i===e&&o.flags&2?t=r+1:n=r}return t}function Bv(e){if(!(e.flags&1)){const t=Su(e),n=Do[Do.length-1];!n||!(e.flags&2)&&t>=Su(n)?Do.push(e):Do.splice(MT(t),0,e),e.flags|=1,hw()}}function hw(){Cf||(Cf=oy.then(mw))}function df(e){Vt(e)?bc.push(...e):Ta&&e.id===-1?Ta.splice(wc+1,0,e):e.flags&1||(bc.push(e),e.flags|=1),hw()}function pw(e,t,n=us+1){for(;n<Do.length;n++){const r=Do[n];if(r&&r.flags&2){if(e&&r.id!==e.uid)continue;Do.splice(n,1),n--,r.flags&4&&(r.flags&=-2),r(),r.flags&4||(r.flags&=-2)}}}function hp(e){if(bc.length){const t=[...new Set(bc)].sort((n,r)=>Su(n)-Su(r));if(bc.length=0,Ta){Ta.push(...t);return}for(Ta=t,wc=0;wc<Ta.length;wc++){const n=Ta[wc];n.flags&4&&(n.flags&=-2),n.flags&8||n(),n.flags&=-2}Ta=null,wc=0}}function mw(e){try{for(us=0;us<Do.length;us++){const t=Do[us];t&&!(t.flags&8)&&(t.flags&4&&(t.flags&=-2),yu(t,t.i,t.i?15:14),t.flags&4||(t.flags&=-2))}}finally{for(;us<Do.length;us++){const t=Do[us];t&&(t.flags&=-2)}us=-1,Do.length=0,hp(e),Cf=null,(Do.length||bc.length)&&mw(e)}}function gw(e,t){var n,r;_u=e,_u?(_u.enabled=!0,kf.forEach(({event:o,args:i})=>_u.emit(o,...i)),kf=[]):typeof window<"u"&&window.HTMLElement&&!((r=(n=window.navigator)==null?void 0:n.userAgent)!=null&&r.includes("jsdom"))?((t.__VUE_DEVTOOLS_HOOK_REPLAY__=t.__VUE_DEVTOOLS_HOOK_REPLAY__||[]).push(o=>{gw(o,t)}),setTimeout(()=>{_u||(t.__VUE_DEVTOOLS_HOOK_REPLAY__=null,kf=[])},3e3)):kf=[]}function ff(e){const t=lo;return lo=e,Sf=e&&e.type.__scopeId||null,t}function LT(e){Sf=e}function PT(){Sf=null}function ao(e,t=lo,n){if(!t||e._n)return e;const r=(...o)=>{r._d&&bf(-1);const i=ff(t);let s;try{s=e(...o)}finally{ff(i),r._d&&bf(1)}return s};return r._n=!0,r._c=!0,r._d=!0,r}function ki(e,t){if(lo===null)return e;const n=wf(lo),r=e.dirs||(e.dirs=[]);for(let o=0;o<t.length;o++){let[i,s,a,l=Fn]=t[o];i&&(nn(i)&&(i={mounted:i,updated:i}),i.deep&&_a(s),r.push({dir:i,instance:n,value:s,oldValue:void 0,arg:a,modifiers:l}))}return e}function Vs(e,t,n,r){const o=e.dirs,i=t&&t.dirs;for(let s=0;s<o.length;s++){const a=o[s];i&&(a.oldValue=i[s].value);let l=a.dir[r];l&&(wa(),Ui(l,n,8,[e.el,a,e,t]),Ca())}}function vw(e,t){if(co){let n=co.provides;const r=co.parent&&co.parent.provides;r===n&&(n=co.provides=Object.create(r)),n[e]=t}}function gl(e,t,n=!1){const r=yr();if(r||Cl){let o=Cl?Cl._context.provides:r?r.parent==null||r.ce?r.vnode.appContext&&r.vnode.appContext.provides:r.parent.provides:void 0;if(o&&e in o)return o[e];if(arguments.length>1)return n&&nn(t)?t.call(r&&r.proxy):t}}function yw(){return!!(yr()||Cl)}function DT(e,t){return hf(e,null,t)}function OT(e,t){return hf(e,null,{flush:"post"})}function bw(e,t){return hf(e,null,{flush:"sync"})}function jt(e,t,n){return hf(e,t,n)}function hf(e,t,n=Fn){const{immediate:r,deep:o,flush:i,once:s}=n,a=Yn({},n),l=t&&r||!t&&i!=="post";let u;if(_l){if(i==="sync"){const g=sy();u=g.__watcherHandles||(g.__watcherHandles=[])}else if(!l){const g=()=>{};return g.stop=Ci,g.resume=Ci,g.pause=Ci,g}}const d=co;a.call=(g,m,v)=>Ui(g,d,m,v);let f=!1;i==="post"?a.scheduler=g=>{Vr(g,d&&d.suspense)}:i!=="sync"&&(f=!0,a.scheduler=(g,m)=>{m?g():Bv(g)}),a.augmentJob=g=>{t&&(g.flags|=4),f&&(g.flags|=2,d&&(g.id=d.uid,g.i=d))};const p=AT(e,t,a);return _l&&(u?u.push(p):l&&p()),p}function FT(e,t,n){const r=this.proxy,o=rr(e)?e.includes(".")?ww(r,e):()=>r[e]:e.bind(r,r);let i;nn(t)?i=t:(i=t.handler,n=t);const s=Sc(this),a=hf(o,i.bind(r),n);return s(),a}function ww(e,t){const n=t.split(".");return()=>{let r=e;for(let o=0;o<n.length&&r;o++)r=r[n[o]];return r}}function pp(e,t,n,{o:{insert:r},m:o},i=2){i===0&&r(e.targetAnchor,t,n);const{el:s,anchor:a,shapeFlag:l,children:u,props:d}=e,f=i===2;if(f&&r(s,t,n),(!f||bl(d))&&l&16)for(let p=0;p<u.length;p++)o(u[p],t,n,2);f&&r(a,t,n)}function NT(e,t,n,r,o,i,{o:{nextSibling:s,parentNode:a,querySelector:l,insert:u,createText:d}},f){function p(C,w){let S=w;for(;S;){if(S&&S.nodeType===8){if(S.data==="teleport start anchor")t.targetStart=S;else if(S.data==="teleport anchor"){t.targetAnchor=S,C._lpa=t.targetAnchor&&s(t.targetAnchor);break}}S=s(S)}}function g(C,w){w.anchor=f(s(C),w,a(C),n,r,o,i)}const m=t.target=Ap(t.props,l),v=bl(t.props);if(m){const C=m._lpa||m.firstChild;t.shapeFlag&16&&(v?(g(e,t),p(m,C),t.targetAnchor||zv(m,t,d,u,a(e)===m?e:null)):(t.anchor=s(e),p(m,C),t.targetAnchor||zv(m,t,d,u),f(C&&s(C),t,m,n,r,o,i))),pf(t,v)}else v&&t.shapeFlag&16&&(g(e,t),t.targetStart=e,t.targetAnchor=s(e));return t.anchor&&s(t.anchor)}function pf(e,t){const n=e.ctx;if(n&&n.ut){let r,o;for(t?(r=e.el,o=e.anchor):(r=e.targetStart,o=e.targetAnchor);r&&r!==o;)r.nodeType===1&&r.setAttribute("data-v-owner",n.uid),r=r.nextSibling;n.ut()}}function zv(e,t,n,r,o=null){const i=t.targetStart=n(""),s=t.targetAnchor=n("");return i[ay]=s,e&&(r(i,e,o),r(s,e,o)),s}function jv(){const e={isMounted:!1,isLeaving:!1,isUnmounting:!1,leavingVNodes:new Map};return zn(()=>{e.isMounted=!0}),ur(()=>{e.isUnmounting=!0}),e}function Cw(e){let t=e[0];if(e.length>1){for(const n of e)if(n.type!==Or){t=n;break}}return t}function kw(e,t){const{leavingVNodes:n}=e;let r=n.get(t.type);return r||(r=Object.create(null),n.set(t.type,r)),r}function bu(e,t,n,r,o){const{appear:i,mode:s,persisted:a=!1,onBeforeEnter:l,onEnter:u,onAfterEnter:d,onEnterCancelled:f,onBeforeLeave:p,onLeave:g,onAfterLeave:m,onLeaveCancelled:v,onBeforeAppear:C,onAppear:w,onAfterAppear:S,onAppearCancelled:b}=t,k=String(e.key),x=kw(n,e),M=(F,L)=>{F&&Ui(F,r,9,L)},z=(F,L)=>{const $=L[1];M(F,L),Vt(F)?F.every(T=>T.length<=1)&&$():F.length<=1&&$()},G={mode:s,persisted:a,beforeEnter(F){let L=l;if(!n.isMounted)if(i)L=C||l;else return;F[ds]&&F[ds](!0);const $=x[k];$&&cs(e,$)&&$.el[ds]&&$.el[ds](),M(L,[F])},enter(F){if(x[k]===e)return;let L=u,$=d,T=f;if(!n.isMounted)if(i)L=w||u,$=S||d,T=b||f;else return;let H=!1;F[Au]=U=>{H||(H=!0,U?M(T,[F]):M($,[F]),G.delayedLeave&&G.delayedLeave(),F[Au]=void 0)};const R=F[Au].bind(null,!1);L?z(L,[F,R]):R()},leave(F,L){const $=String(e.key);if(F[Au]&&F[Au](!0),n.isUnmounting)return L();M(p,[F]);let T=!1;F[ds]=R=>{T||(T=!0,L(),R?M(v,[F]):M(m,[F]),F[ds]=void 0,x[$]===e&&delete x[$])};const H=F[ds].bind(null,!1);x[$]=e,g?z(g,[F,H]):H()},clone(F){const L=bu(F,t,n,r,o);return o&&o(L),L}};return G}function Vv(e){if(Iu(e))return e=Us(e),e.children=null,e}function Sw(e){if(!Iu(e))return ly(e.type)&&e.children?Cw(e.children):e;if(e.component)return e.component.subTree;const{shapeFlag:t,children:n}=e;if(n){if(t&16)return n[0];if(t&32&&nn(n.default))return n.default()}}function Ia(e,t){e.shapeFlag&6&&e.component?(e.transition=t,Ia(e.component.subTree,t)):e.shapeFlag&128?(e.ssContent.transition=t.clone(e.ssContent),e.ssFallback.transition=t.clone(e.ssFallback)):e.transition=t}function mp(e,t=!1,n){let r=[],o=0;for(let i=0;i<e.length;i++){let s=e[i];const a=n==null?s.key:String(n)+String(s.key!=null?s.key:i);s.type===Bt?(s.patchFlag&128&&o++,r=r.concat(mp(s.children,t,a))):(t||s.type!==Or)&&r.push(a!=null?Us(s,{key:a}):s)}if(o>1)for(let i=0;i<r.length;i++)r[i].patchFlag=-2;return r}function vl(e,t){return nn(e)?Yn({name:e.name},t,{setup:e}):e}function BT(){const e=yr();return e?(e.appContext.config.idPrefix||"v")+"-"+e.ids[0]+e.ids[1]++:""}function Uv(e){e.ids=[e.ids[0]+e.ids[2]+++"-",0,0]}function zT(e){const t=yr(),n=Pr(null);if(t){const r=t.refs===Fn?t.refs={}:t.refs;Object.defineProperty(r,e,{enumerable:!0,get:()=>n.value,set:o=>n.value=o})}return n}function _w(e,t){let n;return!!((n=Object.getOwnPropertyDescriptor(e,t))&&!n.configurable)}function wu(e,t,n,r,o=!1){if(Vt(e)){e.forEach((v,C)=>wu(v,t&&(Vt(t)?t[C]:t),n,r,o));return}if(Hs(r)&&!o){r.shapeFlag&512&&r.type.__asyncResolved&&r.component.subTree.component&&wu(e,t,n,r.component.subTree);return}const i=r.shapeFlag&4?wf(r.component):r.el,s=o?null:i,{i:a,r:l}=e,u=t&&t.r,d=a.refs===Fn?a.refs={}:a.refs,f=a.setupState,p=Cn(f),g=f===Fn?uv:v=>_w(d,v)?!1:Gn(p,v),m=(v,C)=>!(C&&_w(d,C));if(u!=null&&u!==l){if(Aw(t),rr(u))d[u]=null,g(u)&&(f[u]=null);else if(hr(u)){const v=t;m(u,v.k)&&(u.value=null),v.k&&(d[v.k]=null)}}if(nn(l))yu(l,a,12,[s,d]);else{const v=rr(l),C=hr(l);if(v||C){const w=()=>{if(e.f){const S=v?g(l)?f[l]:d[l]:m(l)||!e.k?l.value:d[e.k];if(o)Vt(S)&&tp(S,i);else if(Vt(S))S.includes(i)||S.push(i);else if(v)d[l]=[i],g(l)&&(f[l]=d[l]);else{const b=[i];m(l,e.k)&&(l.value=b),e.k&&(d[e.k]=b)}}else v?(d[l]=s,g(l)&&(f[l]=s)):C&&(m(l,e.k)&&(l.value=s),e.k&&(d[e.k]=s))};if(s){const S=()=>{w(),_f.delete(e)};S.id=-1,_f.set(e,S),Vr(S,n)}else Aw(e),w()}}}function Aw(e){const t=_f.get(e);t&&(t.flags|=8,_f.delete(e))}function jT(e){const{mt:t,p:n,o:{patchProp:r,createText:o,nextSibling:i,parentNode:s,remove:a,insert:l,createComment:u}}=e,d=(b,k)=>{if(!k.hasChildNodes()){n(null,b,k),hp(),k._vnode=b;return}f(k.firstChild,b,null,null,null),hp(),k._vnode=b},f=(b,k,x,M,z,G=!1)=>{G=G||!!k.dynamicChildren;const F=kc(b)&&b.data==="[",L=()=>v(b,k,x,M,z,F),{type:$,ref:T,shapeFlag:H,patchFlag:R}=k;let U=b.nodeType;k.el=b,R===-2&&(G=!1,k.dynamicChildren=null);let W=null;switch($){case Ra:U!==3?k.children===""?(l(k.el=o(""),s(b),b),W=b):W=L():(b.data!==k.children&&(Cc(),b.data=k.children),W=i(b));break;case Or:S(b)?(W=i(b),w(k.el=b.content.firstChild,b,x)):U!==8||F?W=L():W=i(b);break;case kl:if(F&&(b=i(b),U=b.nodeType),U===1||U===3){W=b;const ee=!k.children.length;for(let J=0;J<k.staticCount;J++)ee&&(k.children+=W.nodeType===1?W.outerHTML:W.data),J===k.staticCount-1&&(k.anchor=W),W=i(W);return F?i(W):W}else L();break;case Bt:F?W=m(b,k,x,M,z,G):W=L();break;default:if(H&1)(U!==1||k.type.toLowerCase()!==b.tagName.toLowerCase())&&!S(b)?W=L():W=p(b,k,x,M,z,G);else if(H&6){k.slotScopeIds=z;const ee=s(b);if(F?W=C(b):kc(b)&&b.data==="teleport start"?W=C(b,b.data,"teleport end"):W=i(b),t(k,ee,null,x,M,Af(ee),G),Hs(k)&&!k.type.__asyncResolved){let J;F?(J=en(Bt),J.anchor=W?W.previousSibling:ee.lastChild):J=b.nodeType===3?Si(""):en("div"),J.el=b,k.component.subTree=J}}else H&64?U!==8?W=L():W=k.type.hydrate(b,k,x,M,z,G,e,g):H&128&&(W=k.type.hydrate(b,k,x,M,Af(s(b)),z,G,e,f))}return T!=null&&wu(T,null,M,k),W},p=(b,k,x,M,z,G)=>{G=G||!!k.dynamicChildren;const{type:F,props:L,patchFlag:$,shapeFlag:T,dirs:H,transition:R}=k,U=F==="input"||F==="option";if(U||$!==-1){H&&Vs(k,null,x,"created");let W=!1;if(S(b)){W=qw(null,R)&&x&&x.vnode.props&&x.vnode.props.appear;const J=b.content.firstChild;if(W){const Z=J.getAttribute("class");Z&&(J.$cls=Z),R.beforeEnter(J)}w(J,b,x),k.el=b=J}if(T&16&&!(L&&(L.innerHTML||L.textContent))){let J=g(b.firstChild,k,b,x,M,z,G);for(;J;){gp(b,1)||Cc();const Z=J;J=J.nextSibling,a(Z)}}else if(T&8){let J=k.children;J[0]===`
|
|
2
2
|
`&&(b.tagName==="PRE"||b.tagName==="TEXTAREA")&&(J=J.slice(1));const{textContent:Z}=b;Z!==J&&Z!==J.replace(/\r\n|\r/g,`
|
|
3
3
|
`)&&(gp(b,0)||Cc(),b.textContent=k.children)}if(L){if(U||!G||$&48){const J=b.tagName.includes("-");for(const Z in L)(U&&(Z.endsWith("value")||Z==="indeterminate")||du(Z)&&!pl(Z)||Z[0]==="."||J&&!pl(Z))&&r(b,Z,null,L[Z],void 0,x)}else if(L.onClick)r(b,"onClick",null,L.onClick,void 0,x);else if($&4&&zi(L.style))for(const J in L.style)L.style[J]}let ee;(ee=L&&L.onVnodeBeforeMount)&&si(ee,x,k),H&&Vs(k,null,x,"beforeMount"),((ee=L&&L.onVnodeMounted)||H||W)&&Jw(()=>{ee&&si(ee,x,k),W&&R.enter(b),H&&Vs(k,null,x,"mounted")},M)}return b.nextSibling},g=(b,k,x,M,z,G,F)=>{F=F||!!k.dynamicChildren;const L=k.children,$=L.length;for(let T=0;T<$;T++){const H=F?L[T]:L[T]=ii(L[T]),R=H.type===Ra;b?(R&&!F&&T+1<$&&ii(L[T+1]).type===Ra&&(l(o(b.data.slice(H.children.length)),x,i(b)),b.data=H.children),b=f(b,H,M,z,G,F)):R&&!H.children?l(H.el=o(""),x):(gp(x,1)||Cc(),n(null,H,x,null,M,z,Af(x),G))}return b},m=(b,k,x,M,z,G)=>{const{slotScopeIds:F}=k;F&&(z=z?z.concat(F):F);const L=s(b),$=g(i(b),k,L,x,M,z,G);return $&&kc($)&&$.data==="]"?i(k.anchor=$):(Cc(),l(k.anchor=u("]"),L,$),$)},v=(b,k,x,M,z,G)=>{if(gp(b.parentElement,1)||Cc(),k.el=null,G){const $=C(b);for(;;){const T=i(b);if(T&&T!==$)a(T);else break}}const F=i(b),L=s(b);return a(b),n(null,k,L,F,x,M,Af(L),z),x&&(x.vnode.el=k.el,Sp(x,k.el)),F},C=(b,k="[",x="]")=>{let M=0;for(;b;)if(b=i(b),b&&kc(b)&&(b.data===k&&M++,b.data===x)){if(M===0)return i(b);M--}return b},w=(b,k,x)=>{const M=k.parentNode;M&&M.replaceChild(b,k);let z=x;for(;z;)z.vnode.el===k&&(z.vnode.el=z.subTree.el=b),z=z.parent},S=b=>b.nodeType===1&&b.tagName==="TEMPLATE";return[d,f]}function gp(e,t){if(t===0||t===1)for(;e&&!e.hasAttribute(py);)e=e.parentElement;const n=e&&e.getAttribute(py);if(n==null)return!1;if(n==="")return!0;{const r=n.split(",");return t===0&&r.includes("children")?!0:r.includes(yC[t])}}function VT(e){const{top:t,left:n,bottom:r,right:o}=e.getBoundingClientRect(),{innerHeight:i,innerWidth:s}=window;return(t>0&&t<i||r>0&&r<i)&&(n>0&&n<s||o>0&&o<s)}function UT(e,t){if(kc(e)&&e.data==="["){let n=1,r=e.nextSibling;for(;r;){if(r.nodeType===1){if(t(r)===!1)break}else if(kc(r))if(r.data==="]"){if(--n===0)break}else r.data==="["&&n++;r=r.nextSibling}}else t(e)}function Iw(e){nn(e)&&(e={loader:e});const{loader:t,loadingComponent:n,errorComponent:r,delay:o=200,hydrate:i,timeout:s,suspensible:a=!0,onError:l}=e;let u=null,d,f=0;const p=()=>(f++,u=null,g()),g=()=>{let m;return u||(m=u=t().catch(v=>{if(v=v instanceof Error?v:new Error(String(v)),l)return new Promise((C,w)=>{l(v,()=>C(p()),()=>w(v),f+1)});throw v}).then(v=>m!==u&&u?u:(v&&(v.__esModule||v[Symbol.toStringTag]==="Module")&&(v=v.default),d=v,v)))};return vl({name:"AsyncComponentWrapper",__asyncLoader:g,__asyncHydrate(m,v,C){let w=!1;(v.bu||(v.bu=[])).push(()=>w=!0);const S=()=>{w||C()},b=i?()=>{const k=i(S,x=>UT(m,x));k&&(v.bum||(v.bum=[])).push(k)}:S;d?b():g().then(()=>!v.isUnmounted&&b())},get __asyncResolved(){return d},setup(){const m=co;if(Uv(m),d)return()=>vp(d,m);const v=b=>{u=null,vc(b,m,13,!r)};if(a&&m.suspense||_l)return g().then(b=>()=>vp(b,m)).catch(b=>(v(b),()=>r?en(r,{error:b}):null));const C=te(!1),w=te(),S=te(!!o);return o&&setTimeout(()=>{S.value=!1},o),s!=null&&setTimeout(()=>{if(!C.value&&!w.value){const b=new Error(`Async component timed out after ${s}ms.`);v(b),w.value=b}},s),g().then(()=>{C.value=!0,m.parent&&Iu(m.parent.vnode)&&m.parent.update()}).catch(b=>{v(b),w.value=b}),()=>{if(C.value&&d)return vp(d,m);if(w.value&&r)return en(r,{error:w.value});if(n&&!S.value)return vp(n,m)}}})}function vp(e,t){const{ref:n,props:r,children:o,ce:i}=t.vnode,s=en(e,r,o);return s.ref=n,s.ce=i,delete t.vnode.ce,s}function mf(e,t){return Vt(e)?e.some(n=>mf(n,t)):rr(e)?e.split(",").includes(t):S2(e)?(e.lastIndex=0,e.test(t)):!1}function $v(e,t){Ew(e,"a",t)}function Hv(e,t){Ew(e,"da",t)}function Ew(e,t,n=co){const r=e.__wdc||(e.__wdc=()=>{let o=n;for(;o;){if(o.isDeactivated)return;o=o.parent}return e()});if(bp(t,r,n),n){let o=n.parent;for(;o&&o.parent;)Iu(o.parent.vnode)&&$T(r,t,n,o),o=o.parent}}function $T(e,t,n,r){const o=bp(t,e,r,!0);Ef(()=>{tp(r[t],o)},n)}function Gv(e){e.shapeFlag&=-257,e.shapeFlag&=-513}function yp(e){return e.shapeFlag&128?e.ssContent:e}function bp(e,t,n=co,r=!1){if(n){const o=n[e]||(n[e]=[]),i=t.__weh||(t.__weh=(...s)=>{wa();const a=Sc(n),l=Ui(t,n,e,s);return a(),Ca(),l});return r?o.unshift(i):o.push(i),i}}function xw(e,t=co){bp("ec",e,t)}function HT(e,t){return Kv(xp,e,!0,t)||e}function Wv(e){return rr(e)?Kv(xp,e,!1)||e:e||by}function Tw(e){return Kv(IC,e)}function Kv(e,t,n=!0,r=!1){const o=lo||co;if(o){const i=o.type;if(e===xp){const a=ny(i,!1);if(a&&(a===t||a===jr(t)||a===fu(jr(t))))return i}const s=Rw(o[e]||i[e],t)||Rw(o.appContext[e],t);return!s&&r?i:s}}function Rw(e,t){return e&&(e[t]||e[jr(t)]||e[fu(jr(t))])}function Rn(e,t,n,r){let o;const i=n&&n[r],s=Vt(e);if(s||rr(e)){const a=s&&zi(e);let l=!1,u=!1;a&&(l=!oi(e),u=js(e),e=op(e)),o=new Array(e.length);for(let d=0,f=e.length;d<f;d++)o[d]=t(l?u?gc(Vi(e[d])):Vi(e[d]):e[d],d,void 0,i&&i[d])}else if(typeof e=="number"){o=new Array(e);for(let a=0;a<e;a++)o[a]=t(a+1,a,void 0,i&&i[a])}else if(Un(e))if(e[Symbol.iterator])o=Array.from(e,(a,l)=>t(a,l,void 0,i&&i[l]));else{const a=Object.keys(e);o=new Array(a.length);for(let l=0,u=a.length;l<u;l++){const d=a[l];o[l]=t(e[d],d,l,i&&i[l])}}else o=[];return n&&(n[r]=o),o}function GT(e,t){for(let n=0;n<t.length;n++){const r=t[n];if(Vt(r))for(let o=0;o<r.length;o++)e[r[o].name]=r[o].fn;else r&&(e[r.name]=r.key?(...o)=>{const i=r.fn(...o);return i&&(i.key=r.key),i}:r.fn)}return e}function Cu(e,t,n={},r,o){if(lo.ce||lo.parent&&Hs(lo.parent)&&lo.parent.ce){const u=Object.keys(n).length>0;return t!=="default"&&(n.name=t),pe(),hn(Bt,null,[en("slot",n,r&&r())],u?-2:64)}let i=e[t];i&&i._c&&(i._d=!1),pe();const s=i&&qv(i(n)),a=n.key||s&&s.key,l=hn(Bt,{key:(a&&!ri(a)?a:`_${t}`)+(!s&&r?"_fb":"")},s||(r?r():[]),s&&e._===1?64:-2);return!o&&l.scopeId&&(l.slotScopeIds=[l.scopeId+"-s"]),i&&i._c&&(i._d=!0),l}function qv(e){return e.some(t=>Ea(t)?!(t.type===Or||t.type===Bt&&!qv(t.children)):!0)?e:null}function WT(e,t){const n={};for(const r in e)n[t&&/[A-Z]/.test(r)?`on:${r}`:hu(r)]=e[r];return n}function KT(){return null}function qT(){return null}function YT(e){}function XT(e){}function ZT(){return null}function QT(){}function JT(e,t){return null}function Mw(){return Pw("useSlots").slots}function Lw(){return Pw("useAttrs").attrs}function Pw(e){const t=yr();return t.setupContext||(t.setupContext=lC(t))}function gf(e){return Vt(e)?e.reduce((t,n)=>(t[n]=null,t),{}):e}function e5(e,t){const n=gf(e);for(const r in t){if(r.startsWith("__skip"))continue;let o=n[r];o?Vt(o)||nn(o)?o=n[r]={type:o,default:t[r]}:o.default=t[r]:o===null&&(o=n[r]={default:t[r]}),o&&t[`__skip_${r}`]&&(o.skipFactory=!0)}return n}function t5(e,t){return!e||!t?e||t:Vt(e)&&Vt(t)?e.concat(t):Yn({},gf(e),gf(t))}function n5(e,t){const n={};for(const r in e)t.includes(r)||Object.defineProperty(n,r,{enumerable:!0,get:()=>e[r]});return n}function r5(e){const t=yr(),n=_l;let r=e();Ru(),n&&Tu(!1);const o=()=>{Sc(t),n&&Tu(!0)},i=()=>{yr()!==t&&t.scope.off(),Ru(),n&&Tu(!1)};return np(r)&&(r=r.catch(s=>{throw o(),Promise.resolve().then(()=>Promise.resolve().then(i)),s})),[r,()=>{o(),Promise.resolve().then(i)}]}function o5(e){const t=Yv(e),n=e.proxy,r=e.ctx;Lp=!1,t.beforeCreate&&Dw(t.beforeCreate,e,"bc");const{data:o,computed:i,methods:s,watch:a,provide:l,inject:u,created:d,beforeMount:f,mounted:p,beforeUpdate:g,updated:m,activated:v,deactivated:C,beforeDestroy:w,beforeUnmount:S,destroyed:b,unmounted:k,render:x,renderTracked:M,renderTriggered:z,errorCaptured:G,serverPrefetch:F,expose:L,inheritAttrs:$,components:T,directives:H,filters:R}=t;if(u&&i5(u,r,null),s)for(const ee in s){const J=s[ee];nn(J)&&(r[ee]=J.bind(n))}if(o){const ee=o.call(n,n);Un(ee)&&(e.data=Qr(ee))}if(Lp=!0,i)for(const ee in i){const J=i[ee],Z=nn(J)?J.bind(n,n):nn(J.get)?J.get.bind(n,n):Ci,Me=!nn(J)&&nn(J.set)?J.set.bind(n):Ci,fe=_e({get:Z,set:Me});Object.defineProperty(r,ee,{enumerable:!0,configurable:!0,get:()=>fe.value,set:ye=>fe.value=ye})}if(a)for(const ee in a)Ow(a[ee],r,n,ee);if(l){const ee=nn(l)?l.call(n):l;Reflect.ownKeys(ee).forEach(J=>{vw(J,ee[J])})}d&&Dw(d,e,"c");function W(ee,J){Vt(J)?J.forEach(Z=>ee(Z.bind(n))):J&&ee(J.bind(n))}if(W(my,f),W(zn,p),W(Ep,g),W(If,m),W($v,v),W(Hv,C),W(xw,G),W(yy,M),W(vy,z),W(ur,S),W(Ef,k),W(gy,F),Vt(L))if(L.length){const ee=e.exposed||(e.exposed={});L.forEach(J=>{Object.defineProperty(ee,J,{get:()=>n[J],set:Z=>n[J]=Z,enumerable:!0})})}else e.exposed||(e.exposed={});x&&e.render===Ci&&(e.render=x),$!=null&&(e.inheritAttrs=$),T&&(e.components=T),H&&(e.directives=H),F&&Uv(e)}function i5(e,t,n=Ci){Vt(e)&&(e=Xv(e));for(const r in e){const o=e[r];let i;Un(o)?"default"in o?i=gl(o.from||r,o.default,!0):i=gl(o.from||r):i=gl(o),hr(i)?Object.defineProperty(t,r,{enumerable:!0,configurable:!0,get:()=>i.value,set:s=>i.value=s}):t[r]=i}}function Dw(e,t,n){Ui(Vt(e)?e.map(r=>r.bind(t.proxy)):e.bind(t.proxy),t,n)}function Ow(e,t,n,r){let o=r.includes(".")?ww(n,r):()=>n[r];if(rr(e)){const i=t[e];nn(i)&&jt(o,i)}else if(nn(e))jt(o,e.bind(n));else if(Un(e))if(Vt(e))e.forEach(i=>Ow(i,t,n,r));else{const i=nn(e.handler)?e.handler.bind(n):t[e.handler];nn(i)&&jt(o,i,e)}}function Yv(e){const t=e.type,{mixins:n,extends:r}=t,{mixins:o,optionsCache:i,config:{optionMergeStrategies:s}}=e.appContext,a=i.get(t);let l;return a?l=a:!o.length&&!n&&!r?l=t:(l={},o.length&&o.forEach(u=>wp(l,u,s,!0)),wp(l,t,s)),Un(t)&&i.set(t,l),l}function wp(e,t,n,r=!1){const{mixins:o,extends:i}=t;i&&wp(e,i,n,!0),o&&o.forEach(s=>wp(e,s,n,!0));for(const s in t)if(!(r&&s==="expose")){const a=xC[s]||n&&n[s];e[s]=a?a(e[s],t[s]):t[s]}return e}function Fw(e,t){return t?e?function(){return Yn(nn(e)?e.call(this,this):e,nn(t)?t.call(this,this):t)}:t:e}function s5(e,t){return vf(Xv(e),Xv(t))}function Xv(e){if(Vt(e)){const t={};for(let n=0;n<e.length;n++)t[e[n]]=e[n];return t}return e}function Wo(e,t){return e?[...new Set([].concat(e,t))]:t}function vf(e,t){return e?Yn(Object.create(null),e,t):t}function Nw(e,t){return e?Vt(e)&&Vt(t)?[...new Set([...e,...t])]:Yn(Object.create(null),gf(e),gf(t??{})):t}function a5(e,t){if(!e)return t;if(!t)return e;const n=Yn(Object.create(null),e);for(const r in t)n[r]=Wo(e[r],t[r]);return n}function Bw(){return{app:null,config:{isNativeTag:uv,performance:!1,globalProperties:{},optionMergeStrategies:{},errorHandler:void 0,warnHandler:void 0,compilerOptions:{}},mixins:[],components:{},directives:{},provides:Object.create(null),optionsCache:new WeakMap,propsCache:new WeakMap,emitsCache:new WeakMap}}function l5(e,t){return function(r,o=null){nn(r)||(r=Yn({},r)),o!=null&&!Un(o)&&(o=null);const i=Bw(),s=new WeakSet,a=[];let l=!1;const u=i.app={_uid:TC++,_component:r,_props:o,_container:null,_context:i,_instance:null,version:Ty,get config(){return i.config},set config(d){},use(d,...f){return s.has(d)||(d&&nn(d.install)?(s.add(d),d.install(u,...f)):nn(d)&&(s.add(d),d(u,...f))),u},mixin(d){return i.mixins.includes(d)||i.mixins.push(d),u},component(d,f){return f?(i.components[d]=f,u):i.components[d]},directive(d,f){return f?(i.directives[d]=f,u):i.directives[d]},mount(d,f,p){if(!l){const g=u._ceVNode||en(r,o);return g.appContext=i,p===!0?p="svg":p===!1&&(p=void 0),f&&t?t(g,d):e(g,d,p),l=!0,u._container=d,d.__vue_app__=u,wf(g.component)}},onUnmount(d){a.push(d)},unmount(){l&&(Ui(a,u._instance,16),e(null,u._container),delete u._container.__vue_app__)},provide(d,f){return i.provides[d]=f,u},runWithContext(d){const f=Cl;Cl=u;try{return d()}finally{Cl=f}}};return u}}function c5(e,t,n=Fn){const r=yr(),o=jr(t),i=Go(t),s=wy(e,o),a=$2((l,u)=>{let d,f=Fn,p;return bw(()=>{const g=e[o];so(d,g)&&(d=g,u())}),{get(){return l(),n.get?n.get(d):d},set(g){const m=n.set?n.set(g):g;if(!so(m,d)&&!(f!==Fn&&so(g,f)))return;const v=r.vnode.props;v&&(t in v||o in v||i in v)&&(`onUpdate:${t}`in v||`onUpdate:${o}`in v||`onUpdate:${i}`in v)||(d=g,u()),r.emit(`update:${t}`,m),so(g,m)&&so(g,f)&&!so(m,p)&&u(),f=g,p=m}}});return a[Symbol.iterator]=()=>{let l=0;return{next(){return l<2?{value:l++?s||Fn:a,done:!1}:{done:!0}}}},a}function u5(e,t,...n){if(e.isUnmounted)return;const r=e.vnode.props||Fn;let o=n;const i=t.startsWith("update:"),s=i&&wy(r,t.slice(7));s&&(s.trim&&(o=n.map(d=>rr(d)?d.trim():d)),s.number&&(o=n.map(Qd)));let a,l=r[a=hu(t)]||r[a=hu(jr(t))];!l&&i&&(l=r[a=hu(Go(t))]),l&&Ui(l,e,6,o);const u=r[a+"Once"];if(u){if(!e.emitted)e.emitted={};else if(e.emitted[a])return;e.emitted[a]=!0,Ui(u,e,6,o)}}function zw(e,t,n=!1){const r=n?RC:t.emitsCache,o=r.get(e);if(o!==void 0)return o;const i=e.emits;let s={},a=!1;if(!nn(e)){const l=u=>{const d=zw(u,t,!0);d&&(a=!0,Yn(s,d))};!n&&t.mixins.length&&t.mixins.forEach(l),e.extends&&l(e.extends),e.mixins&&e.mixins.forEach(l)}return!i&&!a?(Un(e)&&r.set(e,null),null):(Vt(i)?i.forEach(l=>s[l]=null):Yn(s,i),Un(e)&&r.set(e,s),s)}function Cp(e,t){return!e||!du(t)?!1:(t=t.slice(2).replace(/Once$/,""),Gn(e,t[0].toLowerCase()+t.slice(1))||Gn(e,Go(t))||Gn(e,t))}function kp(e){const{type:t,vnode:n,proxy:r,withProxy:o,propsOptions:[i],slots:s,attrs:a,emit:l,render:u,renderCache:d,props:f,data:p,setupState:g,ctx:m,inheritAttrs:v}=e,C=ff(e);let w,S;try{if(n.shapeFlag&4){const k=o||r,x=k;w=ii(u.call(x,k,d,f,g,p,m)),S=a}else{const k=t;w=ii(k.length>1?k(f,{attrs:a,slots:s,emit:l}):k(f,null)),S=t.props?a:MC(a)}}catch(k){xu.length=0,vc(k,e,1),w=en(Or)}let b=w;if(S&&v!==!1){const k=Object.keys(S),{shapeFlag:x}=b;k.length&&x&7&&(i&&k.some(qd)&&(S=LC(S,i)),b=Us(b,S,!1,!0))}return n.dirs&&(b=Us(b,null,!1,!0),b.dirs=b.dirs?b.dirs.concat(n.dirs):n.dirs),n.transition&&Ia(b,n.transition),w=b,ff(C),w}function d5(e,t=!0){let n;for(let r=0;r<e.length;r++){const o=e[r];if(Ea(o)){if(o.type!==Or||o.children==="v-if"){if(n)return;n=o}}else return}return n}function f5(e,t,n){const{props:r,children:o,component:i}=e,{props:s,children:a,patchFlag:l}=t,u=i.emitsOptions;if(t.dirs||t.transition)return!0;if(n&&l>=0){if(l&1024)return!0;if(l&16)return r?jw(r,s,u):!!s;if(l&8){const d=t.dynamicProps;for(let f=0;f<d.length;f++){const p=d[f];if(Vw(s,r,p)&&!Cp(u,p))return!0}}}else return(o||a)&&(!a||!a.$stable)?!0:r===s?!1:r?s?jw(r,s,u):!0:!!s;return!1}function jw(e,t,n){const r=Object.keys(t);if(r.length!==Object.keys(e).length)return!0;for(let o=0;o<r.length;o++){const i=r[o];if(Vw(t,e,i)&&!Cp(n,i))return!0}return!1}function Vw(e,t,n){const r=e[n],o=t[n];return n==="style"&&Un(r)&&Un(o)?!ba(r,o):r!==o}function Sp({vnode:e,parent:t,suspense:n},r){for(;t;){const o=t.subTree;if(o.suspense&&o.suspense.activeBranch===e&&(o.suspense.vnode.el=o.el=r,e=o),o===e)(e=t.vnode).el=r,t=t.parent;else break}n&&n.activeBranch===e&&(n.vnode.el=r)}function h5(e,t,n,r=!1){const o={},i=ky();e.propsDefaults=Object.create(null),Uw(e,t,o,i);for(const s in e.propsOptions[0])s in o||(o[s]=void 0);n?e.props=r?o:V2(o):e.type.props?e.props=o:e.props=i,e.attrs=i}function p5(e,t,n,r){const{props:o,attrs:i,vnode:{patchFlag:s}}=e,a=Cn(o),[l]=e.propsOptions;let u=!1;if((r||s>0)&&!(s&16)){if(s&8){const d=e.vnode.dynamicProps;for(let f=0;f<d.length;f++){let p=d[f];if(Cp(e.emitsOptions,p))continue;const g=t[p];if(l)if(Gn(i,p))g!==i[p]&&(i[p]=g,u=!0);else{const m=jr(p);o[m]=Zv(l,a,m,g,e,!1)}else g!==i[p]&&(i[p]=g,u=!0)}}}else{Uw(e,t,o,i)&&(u=!0);let d;for(const f in a)(!t||!Gn(t,f)&&((d=Go(f))===f||!Gn(t,d)))&&(l?n&&(n[f]!==void 0||n[d]!==void 0)&&(o[f]=Zv(l,a,f,void 0,e,!0)):delete o[f]);if(i!==a)for(const f in i)(!t||!Gn(t,f))&&(delete i[f],u=!0)}u&&ka(e.attrs,"set","")}function Uw(e,t,n,r){const[o,i]=e.propsOptions;let s=!1,a;if(t)for(let l in t){if(pl(l))continue;const u=t[l];let d;o&&Gn(o,d=jr(l))?!i||!i.includes(d)?n[d]=u:(a||(a={}))[d]=u:Cp(e.emitsOptions,l)||(!(l in r)||u!==r[l])&&(r[l]=u,s=!0)}if(i){const l=Cn(n),u=a||Fn;for(let d=0;d<i.length;d++){const f=i[d];n[f]=Zv(o,l,f,u[f],e,!Gn(u,f))}}return s}function Zv(e,t,n,r,o,i){const s=e[n];if(s!=null){const a=Gn(s,"default");if(a&&r===void 0){const l=s.default;if(s.type!==Function&&!s.skipFactory&&nn(l)){const{propsDefaults:u}=o;if(n in u)r=u[n];else{const d=Sc(o);r=u[n]=l.call(null,t),d()}}else r=l;o.ce&&o.ce._setProp(n,r)}s[0]&&(i&&!a?r=!1:s[1]&&(r===""||r===Go(n))&&(r=!0))}return r}function $w(e,t,n=!1){const r=n?PC:t.propsCache,o=r.get(e);if(o)return o;const i=e.props,s={},a=[];let l=!1;if(!nn(e)){const d=f=>{l=!0;const[p,g]=$w(f,t,!0);Yn(s,p),g&&a.push(...g)};!n&&t.mixins.length&&t.mixins.forEach(d),e.extends&&d(e.extends),e.mixins&&e.mixins.forEach(d)}if(!i&&!l)return Un(e)&&r.set(e,fc),fc;if(Vt(i))for(let d=0;d<i.length;d++){const f=jr(i[d]);Hw(f)&&(s[f]=Fn)}else if(i)for(const d in i){const f=jr(d);if(Hw(f)){const p=i[d],g=s[f]=Vt(p)||nn(p)?{type:p}:Yn({},p),m=g.type;let v=!1,C=!0;if(Vt(m))for(let w=0;w<m.length;++w){const S=m[w],b=nn(S)&&S.name;if(b==="Boolean"){v=!0;break}else b==="String"&&(C=!1)}else v=nn(m)&&m.name==="Boolean";g[0]=v,g[1]=C,(v||Gn(g,"default"))&&a.push(f)}}const u=[s,a];return Un(e)&&r.set(e,u),u}function Hw(e){return e[0]!=="$"&&!pl(e)}function Gw(e){return Kw(e)}function Ww(e){return Kw(e,jT)}function Kw(e,t){const n=ef();n.__VUE__=!0;const{insert:r,remove:o,patchProp:i,createElement:s,createText:a,createComment:l,setText:u,setElementText:d,parentNode:f,nextSibling:p,setScopeId:g=Ci,insertStaticContent:m}=e,v=(Q,I,re,j=null,X=null,K=null,ae=void 0,ke=null,P=!!I.dynamicChildren)=>{if(Q===I)return;Q&&!cs(Q,I)&&(j=ct(Q),ye(Q,X,K,!0),Q=null),I.patchFlag===-2&&(P=!1,I.dynamicChildren=null);const{type:N,ref:me,shapeFlag:Se}=I;switch(N){case Ra:C(Q,I,re,j);break;case Or:w(Q,I,re,j);break;case kl:Q==null&&S(I,re,j,ae);break;case Bt:T(Q,I,re,j,X,K,ae,ke,P);break;default:Se&1?x(Q,I,re,j,X,K,ae,ke,P):Se&6?H(Q,I,re,j,X,K,ae,ke,P):(Se&64||Se&128)&&N.process(Q,I,re,j,X,K,ae,ke,P,Le)}me!=null&&X?wu(me,Q&&Q.ref,K,I||Q,!I):me==null&&Q&&Q.ref!=null&&wu(Q.ref,null,K,Q,!0)},C=(Q,I,re,j)=>{if(Q==null)r(I.el=a(I.children),re,j);else{const X=I.el=Q.el;I.children!==Q.children&&u(X,I.children)}},w=(Q,I,re,j)=>{Q==null?r(I.el=l(I.children||""),re,j):I.el=Q.el},S=(Q,I,re,j)=>{[Q.el,Q.anchor]=m(Q.children,I,re,j,Q.el,Q.anchor)},b=({el:Q,anchor:I},re,j)=>{let X;for(;Q&&Q!==I;)X=p(Q),r(Q,re,j),Q=X;r(I,re,j)},k=({el:Q,anchor:I})=>{let re;for(;Q&&Q!==I;)re=p(Q),o(Q),Q=re;o(I)},x=(Q,I,re,j,X,K,ae,ke,P)=>{if(I.type==="svg"?ae="svg":I.type==="math"&&(ae="mathml"),Q==null)M(I,re,j,X,K,ae,ke,P);else{const N=Q.el&&Q.el._isVueCE?Q.el:null;try{N&&N._beginPatch(),F(Q,I,X,K,ae,ke,P)}finally{N&&N._endPatch()}}},M=(Q,I,re,j,X,K,ae,ke)=>{let P,N;const{props:me,shapeFlag:Se,transition:Re,dirs:ze}=Q;if(P=Q.el=s(Q.type,K,me&&me.is,me),Se&8?d(P,Q.children):Se&16&&G(Q.children,P,null,j,X,Qv(Q,K),ae,ke),ze&&Vs(Q,null,j,"created"),z(P,Q,Q.scopeId,ae,j),me){for(const ot in me)ot!=="value"&&!pl(ot)&&i(P,ot,null,me[ot],K,j);"value"in me&&i(P,"value",null,me.value,K),(N=me.onVnodeBeforeMount)&&si(N,j,Q)}ze&&Vs(Q,null,j,"beforeMount");const Ke=qw(X,Re);Ke&&Re.beforeEnter(P),r(P,I,re),((N=me&&me.onVnodeMounted)||Ke||ze)&&Vr(()=>{N&&si(N,j,Q),Ke&&Re.enter(P),ze&&Vs(Q,null,j,"mounted")},X)},z=(Q,I,re,j,X)=>{if(re&&g(Q,re),j)for(let K=0;K<j.length;K++)g(Q,j[K]);if(X){let K=X.subTree;if(I===K||xf(K.type)&&(K.ssContent===I||K.ssFallback===I)){const ae=X.vnode;z(Q,ae,ae.scopeId,ae.slotScopeIds,X.parent)}}},G=(Q,I,re,j,X,K,ae,ke,P=0)=>{for(let N=P;N<Q.length;N++){const me=Q[N]=ke?xa(Q[N]):ii(Q[N]);v(null,me,I,re,j,X,K,ae,ke)}},F=(Q,I,re,j,X,K,ae)=>{const ke=I.el=Q.el;let{patchFlag:P,dynamicChildren:N,dirs:me}=I;P|=Q.patchFlag&16;const Se=Q.props||Fn,Re=I.props||Fn;let ze;if(re&&yc(re,!1),(ze=Re.onVnodeBeforeUpdate)&&si(ze,re,I,Q),me&&Vs(I,Q,re,"beforeUpdate"),re&&yc(re,!0),(Se.innerHTML&&Re.innerHTML==null||Se.textContent&&Re.textContent==null)&&d(ke,""),N?L(Q.dynamicChildren,N,ke,re,j,Qv(I,X),K):ae||J(Q,I,ke,null,re,j,Qv(I,X),K,!1),P>0){if(P&16)$(ke,Se,Re,re,X);else if(P&2&&Se.class!==Re.class&&i(ke,"class",null,Re.class,X),P&4&&i(ke,"style",Se.style,Re.style,X),P&8){const Ke=I.dynamicProps;for(let ot=0;ot<Ke.length;ot++){const mt=Ke[ot],Ot=Se[mt],Mt=Re[mt];(Mt!==Ot||mt==="value")&&i(ke,mt,Ot,Mt,X,re)}}P&1&&Q.children!==I.children&&d(ke,I.children)}else!ae&&N==null&&$(ke,Se,Re,re,X);((ze=Re.onVnodeUpdated)||me)&&Vr(()=>{ze&&si(ze,re,I,Q),me&&Vs(I,Q,re,"updated")},j)},L=(Q,I,re,j,X,K,ae)=>{for(let ke=0;ke<I.length;ke++){const P=Q[ke],N=I[ke],me=P.el&&(P.type===Bt||!cs(P,N)||P.shapeFlag&198)?f(P.el):re;v(P,N,me,null,j,X,K,ae,!0)}},$=(Q,I,re,j,X)=>{if(I!==re){if(I!==Fn)for(const K in I)!pl(K)&&!(K in re)&&i(Q,K,I[K],null,X,j);for(const K in re){if(pl(K))continue;const ae=re[K],ke=I[K];ae!==ke&&K!=="value"&&i(Q,K,ke,ae,X,j)}"value"in re&&i(Q,"value",I.value,re.value,X)}},T=(Q,I,re,j,X,K,ae,ke,P)=>{const N=I.el=Q?Q.el:a(""),me=I.anchor=Q?Q.anchor:a("");let{patchFlag:Se,dynamicChildren:Re,slotScopeIds:ze}=I;ze&&(ke=ke?ke.concat(ze):ze),Q==null?(r(N,re,j),r(me,re,j),G(I.children||[],re,me,X,K,ae,ke,P)):Se>0&&Se&64&&Re&&Q.dynamicChildren&&Q.dynamicChildren.length===Re.length?(L(Q.dynamicChildren,Re,re,X,K,ae,ke),(I.key!=null||X&&I===X.subTree)&&Jv(Q,I,!0)):J(Q,I,re,me,X,K,ae,ke,P)},H=(Q,I,re,j,X,K,ae,ke,P)=>{I.slotScopeIds=ke,Q==null?I.shapeFlag&512?X.ctx.activate(I,re,j,ae,P):R(I,re,j,X,K,ae,P):U(Q,I,P)},R=(Q,I,re,j,X,K,ae)=>{const ke=Q.component=oC(Q,j,X);if(Iu(Q)&&(ke.ctx.renderer=Le),sC(ke,!1,ae),ke.asyncDep){if(X&&X.registerDep(ke,W,ae),!Q.el){const P=ke.subTree=en(Or);w(null,P,I,re),Q.placeholder=P.el}}else W(ke,Q,I,re,X,K,ae)},U=(Q,I,re)=>{const j=I.component=Q.component;if(f5(Q,I,re))if(j.asyncDep&&!j.asyncResolved){ee(j,I,re);return}else j.next=I,j.update();else I.el=Q.el,j.vnode=I},W=(Q,I,re,j,X,K,ae)=>{const ke=()=>{if(Q.isMounted){let{next:Se,bu:Re,u:ze,parent:Ke,vnode:ot}=Q;{const $e=Yw(Q);if($e){Se&&(Se.el=ot.el,ee(Q,Se,ae)),$e.asyncDep.then(()=>{Vr(()=>{Q.isUnmounted||N()},X)});return}}let mt=Se,Ot;yc(Q,!1),Se?(Se.el=ot.el,ee(Q,Se,ae)):Se=ot,Re&&mc(Re),(Ot=Se.props&&Se.props.onVnodeBeforeUpdate)&&si(Ot,Ke,Se,ot),yc(Q,!0);const Mt=kp(Q),Kt=Q.subTree;Q.subTree=Mt,v(Kt,Mt,f(Kt.el),ct(Kt),Q,X,K),Se.el=Mt.el,mt===null&&Sp(Q,Mt.el),ze&&Vr(ze,X),(Ot=Se.props&&Se.props.onVnodeUpdated)&&Vr(()=>si(Ot,Ke,Se,ot),X)}else{let Se;const{el:Re,props:ze}=I,{bm:Ke,m:ot,parent:mt,root:Ot,type:Mt}=Q,Kt=Hs(I);if(yc(Q,!1),Ke&&mc(Ke),!Kt&&(Se=ze&&ze.onVnodeBeforeMount)&&si(Se,mt,I),yc(Q,!0),Re&&we){const $e=()=>{Q.subTree=kp(Q),we(Re,Q.subTree,Q,X,null)};Kt&&Mt.__asyncHydrate?Mt.__asyncHydrate(Re,Q,$e):$e()}else{Ot.ce&&Ot.ce._hasShadowRoot()&&Ot.ce._injectChildStyle(Mt,Q.parent?Q.parent.type:void 0);const $e=Q.subTree=kp(Q);v(null,$e,re,j,Q,X,K),I.el=$e.el}if(ot&&Vr(ot,X),!Kt&&(Se=ze&&ze.onVnodeMounted)){const $e=I;Vr(()=>si(Se,mt,$e),X)}(I.shapeFlag&256||mt&&Hs(mt.vnode)&&mt.vnode.shapeFlag&256)&&Q.a&&Vr(Q.a,X),Q.isMounted=!0,I=re=j=null}};Q.scope.on();const P=Q.effect=new mu(ke);Q.scope.off();const N=Q.update=P.run.bind(P),me=Q.job=P.runIfDirty.bind(P);me.i=Q,me.id=Q.uid,P.scheduler=()=>Bv(me),yc(Q,!0),N()},ee=(Q,I,re)=>{I.component=Q;const j=Q.vnode.props;Q.vnode=I,Q.next=null,p5(Q,I.props,j,re),FC(Q,I.children,re),wa(),pw(Q),Ca()},J=(Q,I,re,j,X,K,ae,ke,P=!1)=>{const N=Q&&Q.children,me=Q?Q.shapeFlag:0,Se=I.children,{patchFlag:Re,shapeFlag:ze}=I;if(Re>0){if(Re&128){Me(N,Se,re,j,X,K,ae,ke,P);return}else if(Re&256){Z(N,Se,re,j,X,K,ae,ke,P);return}}ze&8?(me&16&&nt(N,X,K),Se!==N&&d(re,Se)):me&16?ze&16?Me(N,Se,re,j,X,K,ae,ke,P):nt(N,X,K,!0):(me&8&&d(re,""),ze&16&&G(Se,re,j,X,K,ae,ke,P))},Z=(Q,I,re,j,X,K,ae,ke,P)=>{Q=Q||fc,I=I||fc;const N=Q.length,me=I.length,Se=Math.min(N,me);let Re;for(Re=0;Re<Se;Re++){const ze=I[Re]=P?xa(I[Re]):ii(I[Re]);v(Q[Re],ze,re,null,X,K,ae,ke,P)}N>me?nt(Q,X,K,!0,!1,Se):G(I,re,j,X,K,ae,ke,P,Se)},Me=(Q,I,re,j,X,K,ae,ke,P)=>{let N=0;const me=I.length;let Se=Q.length-1,Re=me-1;for(;N<=Se&&N<=Re;){const ze=Q[N],Ke=I[N]=P?xa(I[N]):ii(I[N]);if(cs(ze,Ke))v(ze,Ke,re,null,X,K,ae,ke,P);else break;N++}for(;N<=Se&&N<=Re;){const ze=Q[Se],Ke=I[Re]=P?xa(I[Re]):ii(I[Re]);if(cs(ze,Ke))v(ze,Ke,re,null,X,K,ae,ke,P);else break;Se--,Re--}if(N>Se){if(N<=Re){const ze=Re+1,Ke=ze<me?I[ze].el:j;for(;N<=Re;)v(null,I[N]=P?xa(I[N]):ii(I[N]),re,Ke,X,K,ae,ke,P),N++}}else if(N>Re)for(;N<=Se;)ye(Q[N],X,K,!0),N++;else{const ze=N,Ke=N,ot=new Map;for(N=Ke;N<=Re;N++){const qt=I[N]=P?xa(I[N]):ii(I[N]);qt.key!=null&&ot.set(qt.key,N)}let mt,Ot=0;const Mt=Re-Ke+1;let Kt=!1,$e=0;const Qt=new Array(Mt);for(N=0;N<Mt;N++)Qt[N]=0;for(N=ze;N<=Se;N++){const qt=Q[N];if(Ot>=Mt){ye(qt,X,K,!0);continue}let jn;if(qt.key!=null)jn=ot.get(qt.key);else for(mt=Ke;mt<=Re;mt++)if(Qt[mt-Ke]===0&&cs(qt,I[mt])){jn=mt;break}jn===void 0?ye(qt,X,K,!0):(Qt[jn-Ke]=N+1,jn>=$e?$e=jn:Kt=!0,v(qt,I[jn],re,null,X,K,ae,ke,P),Ot++)}const Hn=Kt?m5(Qt):fc;for(mt=Hn.length-1,N=Mt-1;N>=0;N--){const qt=Ke+N,jn=I[qt],Pn=I[qt+1],$r=qt+1<me?Pn.el||Xw(Pn):j;Qt[N]===0?v(null,jn,re,$r,X,K,ae,ke,P):Kt&&(mt<0||N!==Hn[mt]?fe(jn,re,$r,2):mt--)}}},fe=(Q,I,re,j,X=null)=>{const{el:K,type:ae,transition:ke,children:P,shapeFlag:N}=Q;if(N&6){fe(Q.component.subTree,I,re,j);return}if(N&128){Q.suspense.move(I,re,j);return}if(N&64){ae.move(Q,I,re,Le);return}if(ae===Bt){r(K,I,re);for(let me=0;me<P.length;me++)fe(P[me],I,re,j);r(Q.anchor,I,re);return}if(ae===kl){b(Q,I,re);return}if(j!==2&&N&1&&ke)if(j===0)ke.beforeEnter(K),r(K,I,re),Vr(()=>ke.enter(K),X);else{const{leave:me,delayLeave:Se,afterLeave:Re}=ke,ze=()=>{Q.ctx.isUnmounted?o(K):r(K,I,re)},Ke=()=>{K._isLeaving&&K[ds](!0),me(K,()=>{ze(),Re&&Re()})};Se?Se(K,ze,Ke):Ke()}else r(K,I,re)},ye=(Q,I,re,j=!1,X=!1)=>{const{type:K,props:ae,ref:ke,children:P,dynamicChildren:N,shapeFlag:me,patchFlag:Se,dirs:Re,cacheIndex:ze,memo:Ke}=Q;if(Se===-2&&(X=!1),ke!=null&&(wa(),wu(ke,null,re,Q,!0),Ca()),ze!=null&&(I.renderCache[ze]=void 0),me&256){I.ctx.deactivate(Q);return}const ot=me&1&&Re,mt=!Hs(Q);let Ot;if(mt&&(Ot=ae&&ae.onVnodeBeforeUnmount)&&si(Ot,I,Q),me&6)Ve(Q.component,re,j);else{if(me&128){Q.suspense.unmount(re,j);return}ot&&Vs(Q,null,I,"beforeUnmount"),me&64?Q.type.remove(Q,I,re,Le,j):N&&!N.hasOnce&&(K!==Bt||Se>0&&Se&64)?nt(N,I,re,!1,!0):(K===Bt&&Se&384||!X&&me&16)&&nt(P,I,re),j&&ve(Q)}const Mt=Ke!=null&&ze==null;(mt&&(Ot=ae&&ae.onVnodeUnmounted)||ot||Mt)&&Vr(()=>{Ot&&si(Ot,I,Q),ot&&Vs(Q,null,I,"unmounted"),Mt&&(Q.el=null)},re)},ve=Q=>{const{type:I,el:re,anchor:j,transition:X}=Q;if(I===Bt){Pe(re,j);return}if(I===kl){k(Q);return}const K=()=>{o(re),X&&!X.persisted&&X.afterLeave&&X.afterLeave()};if(Q.shapeFlag&1&&X&&!X.persisted){const{leave:ae,delayLeave:ke}=X,P=()=>ae(re,K);ke?ke(Q.el,K,P):P()}else K()},Pe=(Q,I)=>{let re;for(;Q!==I;)re=p(Q),o(Q),Q=re;o(I)},Ve=(Q,I,re)=>{const{bum:j,scope:X,job:K,subTree:ae,um:ke,m:P,a:N}=Q;_p(P),_p(N),j&&mc(j),X.stop(),K&&(K.flags|=8,ye(ae,Q,I,re)),ke&&Vr(ke,I),Vr(()=>{Q.isUnmounted=!0},I)},nt=(Q,I,re,j=!1,X=!1,K=0)=>{for(let ae=K;ae<Q.length;ae++)ye(Q[ae],I,re,j,X)},ct=Q=>{if(Q.shapeFlag&6)return ct(Q.component.subTree);if(Q.shapeFlag&128)return Q.suspense.next();const I=p(Q.anchor||Q.el),re=I&&I[ay];return re?p(re):I};let ft=!1;const It=(Q,I,re)=>{let j;Q==null?I._vnode&&(ye(I._vnode,null,null,!0),j=I._vnode.component):v(I._vnode||null,Q,I,null,null,null,re),I._vnode=Q,ft||(ft=!0,pw(j),hp(),ft=!1)},Le={p:v,um:ye,m:fe,r:ve,mt:R,mc:G,pc:J,pbc:L,n:ct,o:e};let oe,we;return t&&([oe,we]=t(Le)),{render:It,hydrate:oe,createApp:l5(It,oe)}}function Qv({type:e,props:t},n){return n==="svg"&&e==="foreignObject"||n==="mathml"&&e==="annotation-xml"&&t&&t.encoding&&t.encoding.includes("html")?void 0:n}function yc({effect:e,job:t},n){n?(e.flags|=32,t.flags|=4):(e.flags&=-33,t.flags&=-5)}function qw(e,t){return(!e||e&&!e.pendingBranch)&&t&&!t.persisted}function Jv(e,t,n=!1){const r=e.children,o=t.children;if(Vt(r)&&Vt(o))for(let i=0;i<r.length;i++){const s=r[i];let a=o[i];a.shapeFlag&1&&!a.dynamicChildren&&((a.patchFlag<=0||a.patchFlag===32)&&(a=o[i]=xa(o[i]),a.el=s.el),!n&&a.patchFlag!==-2&&Jv(s,a)),a.type===Ra&&(a.patchFlag===-1&&(a=o[i]=xa(a)),a.el=s.el),a.type===Or&&!a.el&&(a.el=s.el)}}function m5(e){const t=e.slice(),n=[0];let r,o,i,s,a;const l=e.length;for(r=0;r<l;r++){const u=e[r];if(u!==0){if(o=n[n.length-1],e[o]<u){t[r]=o,n.push(r);continue}for(i=0,s=n.length-1;i<s;)a=i+s>>1,e[n[a]]<u?i=a+1:s=a;u<e[n[i]]&&(i>0&&(t[r]=n[i-1]),n[i]=r)}}for(i=n.length,s=n[i-1];i-- >0;)n[i]=s,s=t[s];return n}function Yw(e){const t=e.subTree.component;if(t)return t.asyncDep&&!t.asyncResolved?t:Yw(t)}function _p(e){if(e)for(let t=0;t<e.length;t++)e[t].flags|=8}function Xw(e){if(e.placeholder)return e.placeholder;const t=e.component;return t?Xw(t.subTree):null}function yf(e,t){const n=e.props&&e.props[t];nn(n)&&n()}function g5(e,t,n,r,o,i,s,a,l){const{p:u,o:{createElement:d}}=l,f=d("div"),p=e.suspense=Zw(e,o,r,t,f,n,i,s,a,l);u(null,p.pendingBranch=e.ssContent,f,null,r,p,i,s),p.deps>0?(yf(e,"onPending"),yf(e,"onFallback"),u(null,e.ssFallback,t,n,r,null,i,s),ku(p,e.ssFallback)):p.resolve(!1,!0)}function v5(e,t,n,r,o,i,s,a,{p:l,um:u,o:{createElement:d}}){const f=t.suspense=e.suspense;f.vnode=t,t.el=e.el;const p=t.ssContent,g=t.ssFallback,{activeBranch:m,pendingBranch:v,isInFallback:C,isHydrating:w}=f;if(v)f.pendingBranch=p,cs(v,p)?(l(v,p,f.hiddenContainer,null,o,f,i,s,a),f.deps<=0?f.resolve():C&&(w||(l(m,g,n,r,o,null,i,s,a),ku(f,g)))):(f.pendingId=Op++,w?(f.isHydrating=!1,f.activeBranch=v):u(v,o,f),f.deps=0,f.effects.length=0,f.hiddenContainer=d("div"),C?(l(null,p,f.hiddenContainer,null,o,f,i,s,a),f.deps<=0?f.resolve():(l(m,g,n,r,o,null,i,s,a),ku(f,g))):m&&cs(m,p)?(l(m,p,n,r,o,f,i,s,a),f.resolve(!0)):(l(null,p,f.hiddenContainer,null,o,f,i,s,a),f.deps<=0&&f.resolve()));else if(m&&cs(m,p))l(m,p,n,r,o,f,i,s,a),ku(f,p);else if(yf(t,"onPending"),f.pendingBranch=p,p.shapeFlag&512?f.pendingId=p.component.suspenseId:f.pendingId=Op++,l(null,p,f.hiddenContainer,null,o,f,i,s,a),f.deps<=0)f.resolve();else{const{timeout:S,pendingId:b}=f;S>0?setTimeout(()=>{f.pendingId===b&&f.fallback(g)},S):S===0&&f.fallback(g)}}function Zw(e,t,n,r,o,i,s,a,l,u,d=!1){const{p:f,m:p,um:g,n:m,o:{parentNode:v,remove:C}}=u;let w;const S=w5(e);S&&t&&t.pendingBranch&&(w=t.pendingId,t.deps++);const b=e.props?Jd(e.props.timeout):void 0,k=i,x={vnode:e,parent:t,parentComponent:n,namespace:s,container:r,hiddenContainer:o,deps:0,pendingId:Op++,timeout:typeof b=="number"?b:-1,activeBranch:null,isFallbackMountPending:!1,pendingBranch:null,isInFallback:!d,isHydrating:d,isUnmounted:!1,effects:[],resolve(M=!1,z=!1){const{vnode:G,activeBranch:F,pendingBranch:L,pendingId:$,effects:T,parentComponent:H,container:R,isInFallback:U}=x;let W=!1;x.isHydrating?x.isHydrating=!1:M||(W=F&&L.transition&&L.transition.mode==="out-in",W&&(F.transition.afterLeave=()=>{$===x.pendingId&&(p(L,R,i===k?m(F):i,0),df(T),U&&G.ssFallback&&(G.ssFallback.el=null))}),F&&!x.isFallbackMountPending&&(v(F.el)===R&&(i=m(F)),g(F,H,x,!0),!W&&U&&G.ssFallback&&Vr(()=>G.ssFallback.el=null,x)),W||p(L,R,i,0)),x.isFallbackMountPending=!1,ku(x,L),x.pendingBranch=null,x.isInFallback=!1;let ee=x.parent,J=!1;for(;ee;){if(ee.pendingBranch){ee.effects.push(...T),J=!0;break}ee=ee.parent}!J&&!W&&df(T),x.effects=[],S&&t&&t.pendingBranch&&w===t.pendingId&&(t.deps--,t.deps===0&&!z&&t.resolve()),yf(G,"onResolve")},fallback(M){if(!x.pendingBranch)return;const{vnode:z,activeBranch:G,parentComponent:F,container:L,namespace:$}=x;yf(z,"onFallback");const T=m(G),H=()=>{x.isFallbackMountPending=!1,x.isInFallback&&(f(null,M,L,T,F,null,$,a,l),ku(x,M))},R=M.transition&&M.transition.mode==="out-in";R&&(x.isFallbackMountPending=!0,G.transition.afterLeave=H),x.isInFallback=!0,g(G,F,null,!0),R||H()},move(M,z,G){x.activeBranch&&p(x.activeBranch,M,z,G),x.container=M},next(){return x.activeBranch&&m(x.activeBranch)},registerDep(M,z,G){const F=!!x.pendingBranch;F&&x.deps++;const L=M.vnode.el;M.asyncDep.catch($=>{vc($,M,0)}).then($=>{if(M.isUnmounted||x.isUnmounted||x.pendingId!==M.suspenseId)return;Ru(),M.asyncResolved=!0;const{vnode:T}=M;ty(M,$,!1),L&&(T.el=L);const H=!L&&M.subTree.el;z(M,T,v(L||M.subTree.el),L?null:m(M.subTree),x,s,G),H&&(T.placeholder=null,C(H)),Sp(M,T.el),F&&--x.deps===0&&x.resolve()})},unmount(M,z){x.isUnmounted=!0,x.activeBranch&&g(x.activeBranch,n,M,z),x.pendingBranch&&g(x.pendingBranch,n,M,z)}};return x}function y5(e,t,n,r,o,i,s,a,l){const u=t.suspense=Zw(t,r,n,e.parentNode,document.createElement("div"),null,o,i,s,a,!0),d=l(e,u.pendingBranch=t.ssContent,n,u,i,s);return u.deps===0&&u.resolve(!1,!0),d}function b5(e){const{shapeFlag:t,children:n}=e,r=t&32;e.ssContent=Qw(r?n.default:n),e.ssFallback=r?Qw(n.fallback):en(Or)}function Qw(e){let t;if(nn(e)){const n=Sl&&e._c;n&&(e._d=!1,pe()),e=e(),n&&(e._d=!0,t=ko,eC())}return Vt(e)&&(e=d5(e)),e=ii(e),t&&!e.dynamicChildren&&(e.dynamicChildren=t.filter(n=>n!==e)),e}function Jw(e,t){t&&t.pendingBranch?Vt(e)?t.effects.push(...e):t.effects.push(e):df(e)}function ku(e,t){e.activeBranch=t;const{vnode:n,parentComponent:r}=e;let o=t.el;for(;!o&&t.component;)t=t.component.subTree,o=t.el;n.el=o,r&&r.subTree===n&&(r.vnode.el=o,Sp(r,o))}function w5(e){const t=e.props&&e.props.suspensible;return t!=null&&t!==!1}function pe(e=!1){xu.push(ko=e?null:[])}function eC(){xu.pop(),ko=xu[xu.length-1]||null}function bf(e,t=!1){Sl+=e,e<0&&ko&&t&&(ko.hasOnce=!0)}function tC(e){return e.dynamicChildren=Sl>0?ko||fc:null,eC(),Sl>0&&ko&&ko.push(e),e}function Ce(e,t,n,r,o,i){return tC(ce(e,t,n,r,o,i,!0))}function hn(e,t,n,r,o){return tC(en(e,t,n,r,o,!0))}function Ea(e){return e?e.__v_isVNode===!0:!1}function cs(e,t){return e.type===t.type&&e.key===t.key}function C5(e){}function ce(e,t=null,n=null,r=0,o=null,i=e===Bt?0:1,s=!1,a=!1){const l={__v_isVNode:!0,__v_skip:!0,type:e,props:t,key:t&&Ey(t),ref:t&&Tf(t),scopeId:Sf,slotScopeIds:null,children:n,component:null,suspense:null,ssContent:null,ssFallback:null,dirs:null,transition:null,el:null,anchor:null,target:null,targetStart:null,targetAnchor:null,staticCount:0,shapeFlag:i,patchFlag:r,dynamicProps:o,dynamicChildren:null,appContext:null,ctx:lo};return a?(ey(l,n),i&128&&e.normalize(l)):n&&(l.shapeFlag|=rr(n)?8:16),Sl>0&&!s&&ko&&(l.patchFlag>0||i&6)&&l.patchFlag!==32&&ko.push(l),l}function k5(e,t=null,n=null,r=0,o=null,i=!1){if((!e||e===by)&&(e=Or),Ea(e)){const a=Us(e,t,!0);return n&&ey(a,n),Sl>0&&!i&&ko&&(a.shapeFlag&6?ko[ko.indexOf(e)]=a:ko.push(a)),a.patchFlag=-2,a}if(A5(e)&&(e=e.__vccOpts),t){t=nC(t);let{class:a,style:l}=t;a&&!rr(a)&&(t.class=Zt(a)),Un(l)&&(nf(l)&&!Vt(l)&&(l=Yn({},l)),t.style=An(l))}const s=rr(e)?1:xf(e)?128:ly(e)?64:Un(e)?4:nn(e)?2:0;return ce(e,t,n,r,o,s,i,!0)}function nC(e){return e?nf(e)||Sy(e)?Yn({},e):e:null}function Us(e,t,n=!1,r=!1){const{props:o,ref:i,patchFlag:s,children:a,transition:l}=e,u=t?$s(o||{},t):o,d={__v_isVNode:!0,__v_skip:!0,type:e.type,props:u,key:u&&Ey(u),ref:t&&t.ref?n&&i?Vt(i)?i.concat(Tf(t)):[i,Tf(t)]:Tf(t):i,scopeId:e.scopeId,slotScopeIds:e.slotScopeIds,children:a,target:e.target,targetStart:e.targetStart,targetAnchor:e.targetAnchor,staticCount:e.staticCount,shapeFlag:e.shapeFlag,patchFlag:t&&e.type!==Bt?s===-1?16:s|16:s,dynamicProps:e.dynamicProps,dynamicChildren:e.dynamicChildren,appContext:e.appContext,dirs:e.dirs,transition:l,component:e.component,suspense:e.suspense,ssContent:e.ssContent&&Us(e.ssContent),ssFallback:e.ssFallback&&Us(e.ssFallback),placeholder:e.placeholder,el:e.el,anchor:e.anchor,ctx:e.ctx,ce:e.ce};return l&&r&&Ia(d,l.clone(d)),d}function Si(e=" ",t=0){return en(Ra,null,e,t)}function rC(e,t){const n=en(kl,null,e);return n.staticCount=t,n}function ut(e="",t=!1){return t?(pe(),hn(Or,null,e)):en(Or,null,e)}function ii(e){return e==null||typeof e=="boolean"?en(Or):Vt(e)?en(Bt,null,e.slice()):Ea(e)?xa(e):en(Ra,null,String(e))}function xa(e){return e.el===null&&e.patchFlag!==-1||e.memo?e:Us(e)}function ey(e,t){let n=0;const{shapeFlag:r}=e;if(t==null)t=null;else if(Vt(t))n=16;else if(typeof t=="object")if(r&65){const o=t.default;o&&(o._c&&(o._d=!1),ey(e,o()),o._c&&(o._d=!0));return}else{n=32;const o=t._;!o&&!Sy(t)?t._ctx=lo:o===3&&lo&&(lo.slots._===1?t._=1:(t._=2,e.patchFlag|=1024))}else nn(t)?(t={default:t,_ctx:lo},n=32):(t=String(t),r&64?(n=16,t=[Si(t)]):n=8);e.children=t,e.shapeFlag|=n}function $s(...e){const t={};for(let n=0;n<e.length;n++){const r=e[n];for(const o in r)if(o==="class")t.class!==r.class&&(t.class=Zt([t.class,r.class]));else if(o==="style")t.style=An([t.style,r.style]);else if(du(o)){const i=t[o],s=r[o];s&&i!==s&&!(Vt(i)&&i.includes(s))?t[o]=i?[].concat(i,s):s:s==null&&i==null&&!qd(o)&&(t[o]=s)}else o!==""&&(t[o]=r[o])}return t}function si(e,t,n,r=null){Ui(e,t,7,[n,r])}function oC(e,t,n){const r=e.type,o=(t?t.appContext:e.appContext)||BC,i={uid:zC++,vnode:e,type:r,parent:t,appContext:o,root:null,next:null,subTree:null,effect:null,update:null,job:null,scope:new cp(!0),render:null,proxy:null,exposed:null,exposeProxy:null,withProxy:null,provides:t?t.provides:Object.create(o.provides),ids:t?t.ids:["",0,0],accessCache:null,renderCache:[],components:null,directives:null,propsOptions:$w(r,o),emitsOptions:zw(r,o),emit:null,emitted:null,propsDefaults:Fn,inheritAttrs:r.inheritAttrs,ctx:Fn,data:Fn,props:Fn,attrs:Fn,slots:Fn,refs:Fn,setupState:Fn,setupContext:null,suspense:n,suspenseId:n?n.pendingId:0,asyncDep:null,asyncResolved:!1,isMounted:!1,isUnmounted:!1,isDeactivated:!1,bc:null,c:null,bm:null,m:null,bu:null,u:null,um:null,bum:null,da:null,a:null,rtg:null,rtc:null,ec:null,sp:null};return i.ctx={_:i},i.root=t?t.root:i,i.emit=u5.bind(null,i),e.ce&&e.ce(i),i}function iC(e){return e.vnode.shapeFlag&4}function sC(e,t=!1,n=!1){t&&Tu(t);const{props:r,children:o}=e.vnode,i=iC(e);h5(e,r,i,t),OC(e,o,n||t);const s=i?S5(e,t):void 0;return t&&Tu(!1),s}function S5(e,t){const n=e.type;e.accessCache=Object.create(null),e.proxy=new Proxy(e.ctx,Mp);const{setup:r}=n;if(r){wa();const o=e.setupContext=r.length>1?lC(e):null,i=Sc(e),s=yu(r,e,0,[e.props,o]),a=np(s);if(Ca(),i(),(a||e.sp)&&!Hs(e)&&Uv(e),a){if(s.then(Ru,Ru),t)return s.then(l=>{ty(e,l,t)}).catch(l=>{vc(l,e,0)});e.asyncDep=s}else ty(e,s,t)}else aC(e,t)}function ty(e,t,n){nn(t)?e.type.__ssrInlineRender?e.ssrRender=t:e.render=t:Un(t)&&(e.setupState=Iv(t)),aC(e,n)}function _5(e){Np=e,xy=t=>{t.render._rc&&(t.withProxy=new Proxy(t.ctx,EC))}}function aC(e,t,n){const r=e.type;if(!e.render){if(!t&&Np&&!r.render){const o=r.template||Yv(e).template;if(o){const{isCustomElement:i,compilerOptions:s}=e.appContext.config,{delimiters:a,compilerOptions:l}=r,u=Yn(Yn({isCustomElement:i,delimiters:a},s),l);r.render=Np(o,u)}}e.render=r.render||Ci,xy&&xy(e)}{const o=Sc(e);wa();try{o5(e)}finally{Ca(),o()}}}function lC(e){const t=n=>{e.exposed=n||{}};return{attrs:new Proxy(e.attrs,VC),slots:e.slots,emit:e.emit,expose:t}}function wf(e){return e.exposed?e.exposeProxy||(e.exposeProxy=new Proxy(Iv(Gr(e.exposed)),{get(t,n){if(n in t)return t[n];if(n in Eu)return Eu[n](e)},has(t,n){return n in t||n in Eu}})):e.proxy}function ny(e,t=!0){return nn(e)?e.displayName||e.name:e.name||t&&e.__name}function A5(e){return nn(e)&&"__vccOpts"in e}function Dr(e,t,n){try{bf(-1);const r=arguments.length;return r===2?Un(t)&&!Vt(t)?Ea(t)?en(e,null,[t]):en(e,t):en(e,null,t):(r>3?n=Array.prototype.slice.call(arguments,2):r===3&&Ea(n)&&(n=[n]),en(e,t,n))}finally{bf(1)}}function I5(){return;function e(t,n,r){const o=t[r];if(Vt(o)&&o.includes(n)||Un(o)&&n in o||t.extends&&e(t.extends,n,r)||t.mixins&&t.mixins.some(i=>e(i,n,r)))return!0}}function E5(e,t,n,r){const o=n[r];if(o&&cC(o,e))return o;const i=t();return i.memo=e.slice(),i.cacheIndex=r,n[r]=i}function cC(e,t){const n=e.memo;if(n.length!=t.length)return!1;for(let r=0;r<n.length;r++)if(so(n[r],t[r]))return!1;return Sl>0&&ko&&ko.push(e),!0}var ry,uC,dC,Do,us,bc,Ta,wc,oy,Cf,Su,_u,kf,lo,Sf,fC,iy,sy,yl,ay,ly,bl,hC,cy,uy,Ap,pC,wl,ds,Au,_i,Ip,dy,mC,fy,_f,hy,Cc,gC,vC,Af,kc,py,yC,bC,wC,CC,kC,SC,_C,Hs,Iu,AC,Gs,my,zn,Ep,If,ur,Ef,gy,vy,yy,xp,IC,by,Tp,Eu,Rp,Mp,EC,Lp,xC,TC,Cl,wy,RC,MC,LC,Cy,ky,Sy,PC,Pp,Dp,DC,_y,Ay,Iy,OC,FC,Vr,xf,Op,NC,Bt,Ra,Or,kl,xu,ko,Sl,Ey,Tf,en,BC,zC,co,yr,Fp,Tu,Sc,Ru,_l,Np,xy,jC,VC,_e,Ty,UC,$C,HC,GC,WC,x5,T5,R5,KC=Lr((()=>{IT(),vv(),ry=[],uC={SETUP_FUNCTION:0,0:"SETUP_FUNCTION",RENDER_FUNCTION:1,1:"RENDER_FUNCTION",NATIVE_EVENT_HANDLER:5,5:"NATIVE_EVENT_HANDLER",COMPONENT_EVENT_HANDLER:6,6:"COMPONENT_EVENT_HANDLER",VNODE_HOOK:7,7:"VNODE_HOOK",DIRECTIVE_HOOK:8,8:"DIRECTIVE_HOOK",TRANSITION_HOOK:9,9:"TRANSITION_HOOK",APP_ERROR_HANDLER:10,10:"APP_ERROR_HANDLER",APP_WARN_HANDLER:11,11:"APP_WARN_HANDLER",FUNCTION_REF:12,12:"FUNCTION_REF",ASYNC_COMPONENT_LOADER:13,13:"ASYNC_COMPONENT_LOADER",SCHEDULER:14,14:"SCHEDULER",COMPONENT_UPDATE:15,15:"COMPONENT_UPDATE",APP_UNMOUNT_CLEANUP:16,16:"APP_UNMOUNT_CLEANUP"},dC={sp:"serverPrefetch hook",bc:"beforeCreate hook",c:"created hook",bm:"beforeMount hook",m:"mounted hook",bu:"beforeUpdate hook",u:"updated",bum:"beforeUnmount hook",um:"unmounted hook",a:"activated hook",da:"deactivated hook",ec:"errorCaptured hook",rtc:"renderTracked hook",rtg:"renderTriggered hook",0:"setup function",1:"render function",2:"watcher getter",3:"watcher callback",4:"watcher cleanup function",5:"native event handler",6:"component event handler",7:"vnode hook",8:"directive hook",9:"transition hook",10:"app errorHandler",11:"app warnHandler",12:"ref function",13:"async component loader",14:"scheduler flush",15:"component update",16:"app unmount cleanup function"},Do=[],us=-1,bc=[],Ta=null,wc=0,oy=Promise.resolve(),Cf=null,Su=e=>e.id==null?e.flags&2?-1:1/0:e.id,kf=[],lo=null,Sf=null,fC=e=>ao,iy=Symbol.for("v-scx"),sy=()=>{{const e=gl(iy);return e}},yl=new WeakMap,ay=Symbol("_vte"),ly=e=>e.__isTeleport,bl=e=>e&&(e.disabled||e.disabled===""),hC=e=>e&&(e.defer||e.defer===""),cy=e=>typeof SVGElement<"u"&&e instanceof SVGElement,uy=e=>typeof MathMLElement=="function"&&e instanceof MathMLElement,Ap=(e,t)=>{const n=e&&e.to;return rr(n)?t?t(n):null:n},pC={name:"Teleport",__isTeleport:!0,process(e,t,n,r,o,i,s,a,l,u){const{mc:d,pc:f,pbc:p,o:{insert:g,querySelector:m,createText:v,createComment:C}}=u,w=bl(t.props);let{dynamicChildren:S}=t;const b=(M,z,G)=>{M.shapeFlag&16&&d(M.children,z,G,o,i,s,a,l)},k=(M=t)=>{const z=bl(M.props),G=M.target=Ap(M.props,m),F=zv(G,M,v,g);G&&(s!=="svg"&&cy(G)?s="svg":s!=="mathml"&&uy(G)&&(s="mathml"),o&&o.isCE&&(o.ce._teleportTargets||(o.ce._teleportTargets=new Set)).add(G),z||(b(M,G,F),pf(M,!1)))},x=M=>{const z=()=>{yl.get(M)===z&&(yl.delete(M),bl(M.props)&&(b(M,n,M.anchor),pf(M,!0)),k(M))};yl.set(M,z),Vr(z,i)};if(e==null){const M=t.el=v(""),z=t.anchor=v("");if(g(M,n,r),g(z,n,r),hC(t.props)||i&&i.pendingBranch){x(t);return}w&&(b(t,n,z),pf(t,!0)),k()}else{t.el=e.el;const M=t.anchor=e.anchor,z=yl.get(e);if(z){z.flags|=8,yl.delete(e),x(t);return}t.targetStart=e.targetStart;const G=t.target=e.target,F=t.targetAnchor=e.targetAnchor,L=bl(e.props),$=L?n:G,T=L?M:F;if(s==="svg"||cy(G)?s="svg":(s==="mathml"||uy(G))&&(s="mathml"),S?(p(e.dynamicChildren,S,$,o,i,s,a),Jv(e,t,!0)):l||f(e,t,$,T,o,i,s,a,!1),w)L?t.props&&e.props&&t.props.to!==e.props.to&&(t.props.to=e.props.to):pp(t,n,M,u,1);else if((t.props&&t.props.to)!==(e.props&&e.props.to)){const H=t.target=Ap(t.props,m);H&&pp(t,H,null,u,0)}else L&&pp(t,G,F,u,1);pf(t,w)}},remove(e,t,n,{um:r,o:{remove:o}},i){const{shapeFlag:s,children:a,anchor:l,targetStart:u,targetAnchor:d,target:f,props:p}=e;let g=i||!bl(p);const m=yl.get(e);if(m&&(m.flags|=8,yl.delete(e),g=!1),f&&(o(u),o(d)),i&&o(l),s&16)for(let v=0;v<a.length;v++){const C=a[v];r(C,t,n,g,!!C.dynamicChildren)}},move:pp,hydrate:NT},wl=pC,ds=Symbol("_leaveCb"),Au=Symbol("_enterCb"),_i=[Function,Array],Ip={mode:String,appear:Boolean,persisted:Boolean,onBeforeEnter:_i,onEnter:_i,onAfterEnter:_i,onEnterCancelled:_i,onBeforeLeave:_i,onLeave:_i,onAfterLeave:_i,onLeaveCancelled:_i,onBeforeAppear:_i,onAppear:_i,onAfterAppear:_i,onAppearCancelled:_i},dy=e=>{const t=e.subTree;return t.component?dy(t.component):t},mC={name:"BaseTransition",props:Ip,setup(e,{slots:t}){const n=yr(),r=jv();return()=>{const o=t.default&&mp(t.default(),!0);if(!o||!o.length)return;const i=Cw(o),s=Cn(e),{mode:a}=s;if(r.isLeaving)return Vv(i);const l=Sw(i);if(!l)return Vv(i);let u=bu(l,s,r,n,f=>u=f);l.type!==Or&&Ia(l,u);let d=n.subTree&&Sw(n.subTree);if(d&&d.type!==Or&&!cs(d,l)&&dy(n).type!==Or){let f=bu(d,s,r,n);if(Ia(d,f),a==="out-in"&&l.type!==Or)return r.isLeaving=!0,f.afterLeave=()=>{r.isLeaving=!1,n.job.flags&8||n.update(),delete f.afterLeave,d=void 0},Vv(i);a==="in-out"&&l.type!==Or?f.delayLeave=(p,g,m)=>{const v=kw(r,d);v[String(d.key)]=d,p[ds]=()=>{g(),p[ds]=void 0,delete u.delayedLeave,d=void 0},u.delayedLeave=()=>{m(),delete u.delayedLeave,d=void 0}}:d=void 0}else d&&(d=void 0);return i}}},fy=mC,_f=new WeakMap,hy=!1,Cc=()=>{hy||(console.error("Hydration completed but contains mismatches."),hy=!0)},gC=e=>e.namespaceURI.includes("svg")&&e.tagName!=="foreignObject",vC=e=>e.namespaceURI.includes("MathML"),Af=e=>{if(e.nodeType===1){if(gC(e))return"svg";if(vC(e))return"mathml"}},kc=e=>e.nodeType===8,py="data-allow-mismatch",yC={0:"text",1:"children",2:"class",3:"style",4:"attribute"},bC=ef().requestIdleCallback||(e=>setTimeout(e,1)),wC=ef().cancelIdleCallback||(e=>clearTimeout(e)),CC=(e=1e4)=>t=>{const n=bC(t,{timeout:e});return()=>wC(n)},kC=e=>(t,n)=>{const r=new IntersectionObserver(o=>{for(const i of o)if(i.isIntersecting){r.disconnect(),t();break}},e);return n(o=>{if(o instanceof Element){if(VT(o))return t(),r.disconnect(),!1;r.observe(o)}}),()=>r.disconnect()},SC=e=>t=>{if(e){const n=matchMedia(e);if(n.matches)t();else return n.addEventListener("change",t,{once:!0}),()=>n.removeEventListener("change",t)}},_C=(e=[])=>(t,n)=>{rr(e)&&(e=[e]);let r=!1;const o=s=>{r||(r=!0,i(),t(),s.target.dispatchEvent(new s.constructor(s.type,s)))},i=()=>{n(s=>{for(const a of e)s.removeEventListener(a,o)})};return n(s=>{for(const a of e)s.addEventListener(a,o,{once:!0})}),i},Hs=e=>!!e.type.__asyncLoader,Iu=e=>e.type.__isKeepAlive,AC={name:"KeepAlive",__isKeepAlive:!0,props:{include:[String,RegExp,Array],exclude:[String,RegExp,Array],max:[String,Number]},setup(e,{slots:t}){const n=yr(),r=n.ctx;if(!r.renderer)return()=>{const S=t.default&&t.default();return S&&S.length===1?S[0]:S};const o=new Map,i=new Set;let s=null;const a=n.suspense,{renderer:{p:l,m:u,um:d,o:{createElement:f}}}=r,p=f("div");r.activate=(S,b,k,x,M)=>{const z=S.component;u(S,b,k,0,a),l(z.vnode,S,b,k,z,a,x,S.slotScopeIds,M),Vr(()=>{z.isDeactivated=!1,z.a&&mc(z.a);const G=S.props&&S.props.onVnodeMounted;G&&si(G,z.parent,S)},a)},r.deactivate=S=>{const b=S.component;_p(b.m),_p(b.a),u(S,p,null,1,a),Vr(()=>{b.da&&mc(b.da);const k=S.props&&S.props.onVnodeUnmounted;k&&si(k,b.parent,S),b.isDeactivated=!0},a)};function g(S){Gv(S),d(S,n,a,!0)}function m(S){o.forEach((b,k)=>{const x=ny(Hs(b)?b.type.__asyncResolved||{}:b.type);x&&!S(x)&&v(k)})}function v(S){const b=o.get(S);b&&(!s||!cs(b,s))?g(b):s&&Gv(s),o.delete(S),i.delete(S)}jt(()=>[e.include,e.exclude],([S,b])=>{S&&m(k=>mf(S,k)),b&&m(k=>!mf(b,k))},{flush:"post",deep:!0});let C=null;const w=()=>{C!=null&&(xf(n.subTree.type)?Vr(()=>{o.set(C,yp(n.subTree))},n.subTree.suspense):o.set(C,yp(n.subTree)))};return zn(w),If(w),ur(()=>{o.forEach(S=>{const{subTree:b,suspense:k}=n,x=yp(b);if(S.type===x.type&&S.key===x.key){Gv(x);const M=x.component.da;M&&Vr(M,k);return}g(S)})}),()=>{if(C=null,!t.default)return s=null;const S=t.default(),b=S[0];if(S.length>1)return s=null,S;if(!Ea(b)||!(b.shapeFlag&4)&&!(b.shapeFlag&128))return s=null,b;let k=yp(b);if(k.type===Or)return s=null,k;const x=k.type,M=ny(Hs(k)?k.type.__asyncResolved||{}:x),{include:z,exclude:G,max:F}=e;if(z&&(!M||!mf(z,M))||G&&M&&mf(G,M))return k.shapeFlag&=-257,s=k,b;const L=k.key==null?x:k.key,$=o.get(L);return k.el&&(k=Us(k),b.shapeFlag&128&&(b.ssContent=k)),C=L,$?(k.el=$.el,k.component=$.component,k.transition&&Ia(k,k.transition),k.shapeFlag|=512,i.delete(L),i.add(L)):(i.add(L),F&&i.size>parseInt(F,10)&&v(i.values().next().value)),k.shapeFlag|=256,s=k,xf(b.type)?b:k}}},Gs=e=>(t,n=co)=>{(!_l||e==="sp")&&bp(e,(...r)=>t(...r),n)},my=Gs("bm"),zn=Gs("m"),Ep=Gs("bu"),If=Gs("u"),ur=Gs("bum"),Ef=Gs("um"),gy=Gs("sp"),vy=Gs("rtg"),yy=Gs("rtc"),xp="components",IC="directives",by=Symbol.for("v-ndc"),Tp=e=>e?iC(e)?wf(e):Tp(e.parent):null,Eu=Yn(Object.create(null),{$:e=>e,$el:e=>e.vnode.el,$data:e=>e.data,$props:e=>e.props,$attrs:e=>e.attrs,$slots:e=>e.slots,$refs:e=>e.refs,$parent:e=>Tp(e.parent),$root:e=>Tp(e.root),$host:e=>e.ce,$emit:e=>e.emit,$options:e=>Yv(e),$forceUpdate:e=>e.f||(e.f=()=>{Bv(e.update)}),$nextTick:e=>e.n||(e.n=Ct.bind(e.proxy)),$watch:e=>FT.bind(e)}),Rp=(e,t)=>e!==Fn&&!e.__isScriptSetup&&Gn(e,t),Mp={get({_:e},t){if(t==="__v_skip")return!0;const{ctx:n,setupState:r,data:o,props:i,accessCache:s,type:a,appContext:l}=e;if(t[0]!=="$"){const p=s[t];if(p!==void 0)switch(p){case 1:return r[t];case 2:return o[t];case 4:return n[t];case 3:return i[t]}else{if(Rp(r,t))return s[t]=1,r[t];if(o!==Fn&&Gn(o,t))return s[t]=2,o[t];if(Gn(i,t))return s[t]=3,i[t];if(n!==Fn&&Gn(n,t))return s[t]=4,n[t];Lp&&(s[t]=0)}}const u=Eu[t];let d,f;if(u)return t==="$attrs"&&Lo(e.attrs,"get",""),u(e);if((d=a.__cssModules)&&(d=d[t]))return d;if(n!==Fn&&Gn(n,t))return s[t]=4,n[t];if(f=l.config.globalProperties,Gn(f,t))return f[t]},set({_:e},t,n){const{data:r,setupState:o,ctx:i}=e;return Rp(o,t)?(o[t]=n,!0):r!==Fn&&Gn(r,t)?(r[t]=n,!0):Gn(e.props,t)||t[0]==="$"&&t.slice(1)in e?!1:(i[t]=n,!0)},has({_:{data:e,setupState:t,accessCache:n,ctx:r,appContext:o,props:i,type:s}},a){let l;return!!(n[a]||e!==Fn&&a[0]!=="$"&&Gn(e,a)||Rp(t,a)||Gn(i,a)||Gn(r,a)||Gn(Eu,a)||Gn(o.config.globalProperties,a)||(l=s.__cssModules)&&l[a])},defineProperty(e,t,n){return n.get!=null?e._.accessCache[t]=0:Gn(n,"value")&&this.set(e,t,n.value,null),Reflect.defineProperty(e,t,n)}},EC=Yn({},Mp,{get(e,t){if(t!==Symbol.unscopables)return Mp.get(e,t,e)},has(e,t){return t[0]!=="_"&&!x2(t)}}),Lp=!0,xC={data:Fw,props:Nw,emits:Nw,methods:vf,computed:vf,beforeCreate:Wo,created:Wo,beforeMount:Wo,mounted:Wo,beforeUpdate:Wo,updated:Wo,beforeDestroy:Wo,beforeUnmount:Wo,destroyed:Wo,unmounted:Wo,activated:Wo,deactivated:Wo,errorCaptured:Wo,serverPrefetch:Wo,components:vf,directives:vf,watch:a5,provide:Fw,inject:s5},TC=0,Cl=null,wy=(e,t)=>t==="modelValue"||t==="model-value"?e.modelModifiers:e[`${t}Modifiers`]||e[`${jr(t)}Modifiers`]||e[`${Go(t)}Modifiers`],RC=new WeakMap,MC=e=>{let t;for(const n in e)(n==="class"||n==="style"||du(n))&&((t||(t={}))[n]=e[n]);return t},LC=(e,t)=>{const n={};for(const r in e)(!qd(r)||!(r.slice(9)in t))&&(n[r]=e[r]);return n},Cy={},ky=()=>Object.create(Cy),Sy=e=>Object.getPrototypeOf(e)===Cy,PC=new WeakMap,Pp=e=>e==="_"||e==="_ctx"||e==="$stable",Dp=e=>Vt(e)?e.map(ii):[ii(e)],DC=(e,t,n)=>{if(t._n)return t;const r=ao((...o)=>Dp(t(...o)),n);return r._c=!1,r},_y=(e,t,n)=>{const r=e._ctx;for(const o in e){if(Pp(o))continue;const i=e[o];if(nn(i))t[o]=DC(o,i,r);else if(i!=null){const s=Dp(i);t[o]=()=>s}}},Ay=(e,t)=>{const n=Dp(t);e.slots.default=()=>n},Iy=(e,t,n)=>{for(const r in t)(n||!Pp(r))&&(e[r]=t[r])},OC=(e,t,n)=>{const r=e.slots=ky();if(e.vnode.shapeFlag&32){const o=t._;o?(Iy(r,t,n),n&&hv(r,"_",o,!0)):_y(t,r)}else t&&Ay(e,t)},FC=(e,t,n)=>{const{vnode:r,slots:o}=e;let i=!0,s=Fn;if(r.shapeFlag&32){const a=t._;a?n&&a===1?i=!1:Iy(o,t,n):(i=!t.$stable,_y(t,o)),s=t}else t&&(Ay(e,t),s={default:1});if(i)for(const a in o)!Pp(a)&&s[a]==null&&delete o[a]},Vr=Jw,xf=e=>e.__isSuspense,Op=0,NC={name:"Suspense",__isSuspense:!0,process(e,t,n,r,o,i,s,a,l,u){if(e==null)g5(t,n,r,o,i,s,a,l,u);else{if(i&&i.deps>0&&!e.suspense.isInFallback){t.suspense=e.suspense,t.suspense.vnode=t,t.el=e.el;return}v5(e,t,n,r,o,s,a,l,u)}},hydrate:y5,normalize:b5},Bt=Symbol.for("v-fgt"),Ra=Symbol.for("v-txt"),Or=Symbol.for("v-cmt"),kl=Symbol.for("v-stc"),xu=[],ko=null,Sl=1,Ey=({key:e})=>e??null,Tf=({ref:e,ref_key:t,ref_for:n})=>(typeof e=="number"&&(e=""+e),e!=null?rr(e)||hr(e)||nn(e)?{i:lo,r:e,k:t,f:!!n}:e:null),en=k5,BC=Bw(),zC=0,co=null,yr=()=>co||lo;{const e=ef(),t=(n,r)=>{let o;return(o=e[n])||(o=e[n]=[]),o.push(r),i=>{o.length>1?o.forEach(s=>s(i)):o[0](i)}};Fp=t("__VUE_INSTANCE_SETTERS__",n=>co=n),Tu=t("__VUE_SSR_SETTERS__",n=>_l=n)}Sc=e=>{const t=co;return Fp(e),e.scope.on(),()=>{e.scope.off(),Fp(t)}},Ru=()=>{co&&co.scope.off(),Fp(null)},_l=!1,jC=()=>!Np,VC={get(e,t){return Lo(e,"get",""),e[t]}},_e=(e,t)=>ST(e,t,_l),Ty="3.5.32",UC=Ci,$C=dC,HC=_u,GC=gw,WC={createComponentInstance:oC,setupComponent:sC,renderComponentRoot:kp,setCurrentRenderingInstance:ff,isVNode:Ea,normalizeVNode:ii,getComponentPublicInstance:wf,ensureValidVNode:qv,pushWarningContext:ET,popWarningContext:xT},x5=null,T5=null,R5=null}));function qC(e){const t={};for(const T in e)T in Ny||(t[T]=e[T]);if(e.css===!1)return t;const{name:n="v",type:r,duration:o,enterFromClass:i=`${n}-enter-from`,enterActiveClass:s=`${n}-enter-active`,enterToClass:a=`${n}-enter-to`,appearFromClass:l=i,appearActiveClass:u=s,appearToClass:d=a,leaveFromClass:f=`${n}-leave-from`,leaveActiveClass:p=`${n}-leave-active`,leaveToClass:g=`${n}-leave-to`}=e,m=M5(o),v=m&&m[0],C=m&&m[1],{onBeforeEnter:w,onEnter:S,onEnterCancelled:b,onLeave:k,onLeaveCancelled:x,onBeforeAppear:M=w,onAppear:z=S,onAppearCancelled:G=b}=t,F=(T,H,R,U)=>{T._enterCancelled=U,Al(T,H?d:a),Al(T,H?u:s),R&&R()},L=(T,H)=>{T._isLeaving=!1,Al(T,f),Al(T,g),Al(T,p),H&&H()},$=T=>(H,R)=>{const U=T?z:S,W=()=>F(H,T,R);Il(U,[H,W]),YC(()=>{Al(H,T?l:i),Ws(H,T?d:a),zy(U)||XC(H,r,v,W)})};return Yn(t,{onBeforeEnter(T){Il(w,[T]),Ws(T,i),Ws(T,s)},onBeforeAppear(T){Il(M,[T]),Ws(T,l),Ws(T,u)},onEnter:$(!1),onAppear:$(!0),onLeave(T,H){T._isLeaving=!0;const R=()=>L(T,H);Ws(T,f),T._enterCancelled?(Ws(T,p),My(T)):(My(T),Ws(T,p)),YC(()=>{T._isLeaving&&(Al(T,f),Ws(T,g),zy(k)||XC(T,r,C,R))}),Il(k,[T,R])},onEnterCancelled(T){F(T,!1,void 0,!0),Il(b,[T])},onAppearCancelled(T){F(T,!0,void 0,!0),Il(G,[T])},onLeaveCancelled(T){L(T),Il(x,[T])}})}function M5(e){if(e==null)return null;if(Un(e))return[Ry(e.enter),Ry(e.leave)];{const t=Ry(e);return[t,t]}}function Ry(e){return Jd(e)}function Ws(e,t){t.split(/\s+/).forEach(n=>n&&e.classList.add(n)),(e[_c]||(e[_c]=new Set)).add(t)}function Al(e,t){t.split(/\s+/).forEach(r=>r&&e.classList.remove(r));const n=e[_c];n&&(n.delete(t),n.size||(e[_c]=void 0))}function YC(e){requestAnimationFrame(()=>{requestAnimationFrame(e)})}function XC(e,t,n,r){const o=e._endId=++yk,i=()=>{o===e._endId&&r()};if(n!=null)return setTimeout(i,n);const{type:s,timeout:a,propCount:l}=ZC(e,t);if(!s)return r();const u=s+"end";let d=0;const f=()=>{e.removeEventListener(u,p),i()},p=g=>{g.target===e&&++d>=l&&f()};setTimeout(()=>{d<l&&f()},a+1),e.addEventListener(u,p)}function ZC(e,t){const n=window.getComputedStyle(e),r=m=>(n[m]||"").split(", "),o=r(`${La}Delay`),i=r(`${La}Duration`),s=QC(o,i),a=r(`${Lu}Delay`),l=r(`${Lu}Duration`),u=QC(a,l);let d=null,f=0,p=0;t===La?s>0&&(d=La,f=s,p=i.length):t===Lu?u>0&&(d=Lu,f=u,p=l.length):(f=Math.max(s,u),d=f>0?s>u?La:Lu:null,p=d?d===La?i.length:l.length:0);const g=d===La&&/\b(?:transform|all)(?:,|$)/.test(r(`${La}Property`).toString());return{type:d,timeout:f,propCount:p,hasTransform:g}}function QC(e,t){for(;e.length<t.length;)e=e.concat(e);return Math.max(...t.map((n,r)=>JC(n)+JC(e[r])))}function JC(e){return e==="auto"?0:Number(e.slice(0,-1).replace(",","."))*1e3}function My(e){return(e?e.ownerDocument:document).body.offsetHeight}function L5(e,t,n){const r=e[_c];r&&(t=(t?[t,...r]:[...r]).join(" ")),t==null?e.removeAttribute("class"):n?e.setAttribute("class",t):e.className=t}function Rf(e,t){e.style.display=t?e[Mf]:"none",e[jy]=!t}function P5(){Vy.getSSRProps=({value:e})=>{if(!e)return{style:{display:"none"}}}}function D5(e){const t=yr();if(!t)return;const n=t.ut=(o=e(t.proxy))=>{Array.from(document.querySelectorAll(`[data-v-owner="${t.uid}"]`)).forEach(i=>Bp(i,o))},r=()=>{const o=e(t.proxy);t.ce?Bp(t.ce,o):Ly(t.subTree,o),n(o)};Ep(()=>{df(r)}),zn(()=>{jt(r,Ci,{flush:"post"});const o=new MutationObserver(r);o.observe(t.subTree.el.parentNode,{childList:!0}),Ef(()=>o.disconnect())})}function Ly(e,t){if(e.shapeFlag&128){const n=e.suspense;e=n.activeBranch,n.pendingBranch&&!n.isHydrating&&n.effects.push(()=>{Ly(n.activeBranch,t)})}for(;e.component;)e=e.component.subTree;if(e.shapeFlag&1&&e.el)Bp(e.el,t);else if(e.type===Bt)e.children.forEach(n=>Ly(n,t));else if(e.type===kl){let{el:n,anchor:r}=e;for(;n&&(Bp(n,t),n!==r);)n=n.nextSibling}}function Bp(e,t){if(e.nodeType===1){const n=e.style;let r="";for(const o in t){const i=cT(t[o]);n.setProperty(`--${o}`,i),r+=`--${o}: ${i};`}n[Uy]=r}}function O5(e,t,n){const r=e.style,o=rr(n);let i=!1;if(n&&!o){if(t)if(rr(t))for(const s of t.split(";")){const a=s.slice(0,s.indexOf(":")).trim();n[a]==null&&zp(r,a,"")}else for(const s in t)n[s]==null&&zp(r,s,"");for(const s in n)s==="display"&&(i=!0),zp(r,s,n[s])}else if(o){if(t!==n){const s=r[Uy];s&&(n+=";"+s),r.cssText=n,i=bk.test(n)}}else t&&e.removeAttribute("style");Mf in e&&(e[Mf]=i?r.display:"",e[jy]&&(r.display="none"))}function zp(e,t,n){if(Vt(n))n.forEach(r=>zp(e,t,r));else if(n==null&&(n=""),t.startsWith("--"))e.setProperty(t,n);else{const r=F5(e,t);$y.test(n)?e.setProperty(Go(r),n.replace($y,""),"important"):e[r]=n}}function F5(e,t){const n=$p[t];if(n)return n;let r=jr(t);if(r!=="filter"&&r in e)return $p[t]=r;r=fu(r);for(let o=0;o<Hy.length;o++){const i=Hy[o]+r;if(i in e)return $p[t]=i}return t}function ek(e,t,n,r,o,i=L2(t)){r&&t.startsWith("xlink:")?n==null?e.removeAttributeNS(Gy,t.slice(6,t.length)):e.setAttributeNS(Gy,t,n):n==null||i&&!C2(n)?e.removeAttribute(t):e.setAttribute(t,i?"":ri(n)?String(n):n)}function tk(e,t,n,r,o){if(t==="innerHTML"||t==="textContent"){n!=null&&(e[t]=t==="innerHTML"?Dy(n):n);return}const i=e.tagName;if(t==="value"&&i!=="PROGRESS"&&!i.includes("-")){const a=i==="OPTION"?e.getAttribute("value")||"":e.value,l=n==null?e.type==="checkbox"?"on":"":String(n);(a!==l||!("_value"in e))&&(e.value=l),n==null&&e.removeAttribute(t),e._value=n;return}let s=!1;if(n===""||n==null){const a=typeof e[t];a==="boolean"?n=C2(n):n==null&&a==="string"?(n="",s=!0):a==="number"&&(n=0,s=!0)}try{e[t]=n}catch{}s&&e.removeAttribute(o||t)}function Ma(e,t,n,r){e.addEventListener(t,n,r)}function N5(e,t,n,r){e.removeEventListener(t,n,r)}function B5(e,t,n,r,o=null){const i=e[Wy]||(e[Wy]={}),s=i[t];if(r&&s)s.value=r;else{const[a,l]=z5(t);r?Ma(e,a,i[t]=j5(r,o),l):s&&(N5(e,a,s,l),i[t]=void 0)}}function z5(e){let t;if(Ky.test(e)){t={};let n;for(;n=e.match(Ky);)e=e.slice(0,e.length-n[0].length),t[n[0].toLowerCase()]=!0}return[e[2]===":"?e.slice(3):Go(e.slice(2)),t]}function j5(e,t){const n=r=>{if(!r._vts)r._vts=Date.now();else if(r._vts<=n.attached)return;Ui(V5(r,n.value),t,5,[r])};return n.value=e,n.attached=Ck(),n}function V5(e,t){if(Vt(t)){const n=e.stopImmediatePropagation;return e.stopImmediatePropagation=()=>{n.call(e),e._stopped=!0},t.map(r=>o=>!o._stopped&&r&&r(o))}else return t}function U5(e,t,n,r){if(r)return!!(t==="innerHTML"||t==="textContent"||t in e&&qy(t)&&nn(n));if(t==="spellcheck"||t==="draggable"||t==="translate"||t==="autocorrect"||t==="sandbox"&&e.tagName==="IFRAME"||t==="form"||t==="list"&&e.tagName==="INPUT"||t==="type"&&e.tagName==="TEXTAREA")return!1;if(t==="width"||t==="height"){const o=e.tagName;if(o==="IMG"||o==="VIDEO"||o==="CANVAS"||o==="SOURCE")return!1}return qy(t)&&rr(n)?!1:t in e}function $5(e,t){const n=e._def.props;if(!n)return!1;const r=jr(t);return Array.isArray(n)?n.some(o=>jr(o)===r):Object.keys(n).some(o=>jr(o)===r)}function nk(e,t,n){let r=vl(e,t);Yd(r)&&(r=Yn({},r,t));class o extends Zy{constructor(s){super(r,s,n)}}return o.def=r,o}function rk(e){const t=yr(),n=t&&t.ce;return n||null}function H5(){const e=rk();return e&&e.shadowRoot}function G5(e="$style"){{const t=yr();if(!t)return Fn;const n=t.type.__cssModules;if(!n)return Fn;const r=n[e];return r||Fn}}function W5(e){const t=e.el;t[Lf]&&t[Lf](),t[eb]&&t[eb]()}function K5(e){Jy.set(e,ok(e.el))}function q5(e){const t=Qy.get(e),n=Jy.get(e),r=t.left-n.left,o=t.top-n.top;if(r||o){const i=e.el,s=i.style,a=i.getBoundingClientRect();let l=1,u=1;return i.offsetWidth&&(l=a.width/i.offsetWidth),i.offsetHeight&&(u=a.height/i.offsetHeight),(!Number.isFinite(l)||l===0)&&(l=1),(!Number.isFinite(u)||u===0)&&(u=1),Math.abs(l-1)<.01&&(l=1),Math.abs(u-1)<.01&&(u=1),s.transform=s.webkitTransform=`translate(${r/l}px,${o/u}px)`,s.transitionDuration="0s",e}}function ok(e){const t=e.getBoundingClientRect();return{left:t.left,top:t.top}}function Y5(e,t,n){const r=e.cloneNode(),o=e[_c];o&&o.forEach(a=>{a.split(/\s+/).forEach(l=>l&&r.classList.remove(l))}),n.split(/\s+/).forEach(a=>a&&r.classList.add(a)),r.style.display="none";const i=t.nodeType===1?t:t.parentNode;i.appendChild(r);const{hasTransform:s}=ZC(r);return i.removeChild(r),s}function X5(e){e.target.composing=!0}function ik(e){const t=e.target;t.composing&&(t.composing=!1,t.dispatchEvent(new Event("input")))}function sk(e,t,n){return t&&(e=e.trim()),n&&(e=Qd(e)),e}function ak(e,{value:t,oldValue:n},r){e._modelValue=t;let o;if(Vt(t))o=ep(t,r.props.value)>-1;else if(hl(t))o=t.has(r.props.value);else{if(t===n)return;o=ba(t,ck(e,!0))}e.checked!==o&&(e.checked=o)}function lk(e,t){const n=e.multiple,r=Vt(t);if(!(n&&!r&&!hl(t))){for(let o=0,i=e.options.length;o<i;o++){const s=e.options[o],a=Mu(s);if(n)if(r){const l=typeof a;l==="string"||l==="number"?s.selected=t.some(u=>String(u)===String(a)):s.selected=ep(t,a)>-1}else s.selected=t.has(a);else if(ba(Mu(s),t)){e.selectedIndex!==o&&(e.selectedIndex=o);return}}!n&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function Mu(e){return"_value"in e?e._value:e.value}function ck(e,t){const n=t?"_trueValue":"_falseValue";return n in e?e[n]:t}function uk(e,t){switch(e){case"SELECT":return Wp;case"TEXTAREA":return Ii;default:switch(t){case"checkbox":return Pu;case"radio":return Gp;default:return Ii}}}function jp(e,t,n,r,o){const i=uk(e.tagName,n.props&&n.props.type)[o];i&&i(e,t,n,r)}function Z5(){Ii.getSSRProps=({value:e})=>({value:e}),Gp.getSSRProps=({value:e},t)=>{if(t.props&&ba(t.props.value,e))return{checked:!0}},Pu.getSSRProps=({value:e},t)=>{if(Vt(e)){if(t.props&&ep(e,t.props.value)>-1)return{checked:!0}}else if(hl(e)){if(t.props&&e.has(t.props.value))return{checked:!0}}else if(e)return{checked:!0}},tb.getSSRProps=(e,t)=>{if(typeof t.type!="string")return;const n=uk(t.type.toUpperCase(),t.props&&t.props.type);if(n.getSSRProps)return n.getSSRProps(e,t)}}function dk(){return Pf||(Pf=Gw(nb))}function fk(){return Pf=rb?Pf:Ww(nb),rb=!0,Pf}function hk(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function pk(e){return rr(e)?document.querySelector(e):e}var Vp,Py,Dy,mk,gk,Ks,Oy,Fy,La,Lu,_c,Ny,By,vk,Up,Il,zy,yk,Mf,jy,Vy,Uy,bk,$y,Hy,$p,Gy,Wy,Ky,Hp,wk,Ck,qy,Yy,Xy,kk,Sk,Zy,Qy,Jy,Lf,eb,_k,Ak,Pa,Ai,Ii,Pu,Gp,Wp,tb,Ik,Ek,tn,xk,Ko,nb,Pf,rb,ob,Tk,Ac,ib,sb,Rk,Q5=Lr((()=>{if(KC(),KC(),vv(),Vp=void 0,Py=typeof window<"u"&&window.trustedTypes,Py)try{Vp=Py.createPolicy("vue",{createHTML:e=>e})}catch{}Dy=Vp?e=>Vp.createHTML(e):e=>e,mk="http://www.w3.org/2000/svg",gk="http://www.w3.org/1998/Math/MathML",Ks=typeof document<"u"?document:null,Oy=Ks&&Ks.createElement("template"),Fy={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,r)=>{const o=t==="svg"?Ks.createElementNS(mk,e):t==="mathml"?Ks.createElementNS(gk,e):n?Ks.createElement(e,{is:n}):Ks.createElement(e);return e==="select"&&r&&r.multiple!=null&&o.setAttribute("multiple",r.multiple),o},createText:e=>Ks.createTextNode(e),createComment:e=>Ks.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>Ks.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,n,r,o,i){const s=n?n.previousSibling:t.lastChild;if(o&&(o===i||o.nextSibling))for(;t.insertBefore(o.cloneNode(!0),n),!(o===i||!(o=o.nextSibling)););else{Oy.innerHTML=Dy(r==="svg"?`<svg>${e}</svg>`:r==="mathml"?`<math>${e}</math>`:e);const a=Oy.content;if(r==="svg"||r==="mathml"){const l=a.firstChild;for(;l.firstChild;)a.appendChild(l.firstChild);a.removeChild(l)}t.insertBefore(a,n)}return[s?s.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},La="transition",Lu="animation",_c=Symbol("_vtc"),Ny={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String},By=Yn({},Ip,Ny),vk=e=>(e.displayName="Transition",e.props=By,e),Up=vk((e,{slots:t})=>Dr(fy,qC(e),t)),Il=(e,t=[])=>{Vt(e)?e.forEach(n=>n(...t)):e&&e(...t)},zy=e=>e?Vt(e)?e.some(t=>t.length>1):e.length>1:!1,yk=0,Mf=Symbol("_vod"),jy=Symbol("_vsh"),Vy={name:"show",beforeMount(e,{value:t},{transition:n}){e[Mf]=e.style.display==="none"?"":e.style.display,n&&t?n.beforeEnter(e):Rf(e,t)},mounted(e,{value:t},{transition:n}){n&&t&&n.enter(e)},updated(e,{value:t,oldValue:n},{transition:r}){!t!=!n&&(r?t?(r.beforeEnter(e),Rf(e,!0),r.enter(e)):r.leave(e,()=>{Rf(e,!1)}):Rf(e,t))},beforeUnmount(e,{value:t}){Rf(e,t)}},Uy=Symbol(""),bk=/(?:^|;)\s*display\s*:/,$y=/\s*!important$/,Hy=["Webkit","Moz","ms"],$p={},Gy="http://www.w3.org/1999/xlink",Wy=Symbol("_vei"),Ky=/(?:Once|Passive|Capture)$/,Hp=0,wk=Promise.resolve(),Ck=()=>Hp||(wk.then(()=>Hp=0),Hp=Date.now()),qy=e=>e.charCodeAt(0)===111&&e.charCodeAt(1)===110&&e.charCodeAt(2)>96&&e.charCodeAt(2)<123,Yy=(e,t,n,r,o,i)=>{const s=o==="svg";t==="class"?L5(e,r,s):t==="style"?O5(e,n,r):du(t)?qd(t)||B5(e,t,n,r,i):(t[0]==="."?(t=t.slice(1),!0):t[0]==="^"?(t=t.slice(1),!1):U5(e,t,r,s))?(tk(e,t,r),!e.tagName.includes("-")&&(t==="value"||t==="checked"||t==="selected")&&ek(e,t,r,s,i,t!=="value")):e._isVueCE&&($5(e,t)||e._def.__asyncLoader&&(/[A-Z]/.test(t)||!rr(r)))?tk(e,jr(t),r,i,t):(t==="true-value"?e._trueValue=r:t==="false-value"&&(e._falseValue=r),ek(e,t,r,s))},Xy={},kk=((e,t)=>nk(e,t,ib)),Sk=typeof HTMLElement<"u"?HTMLElement:class{},Zy=class Ax extends Sk{constructor(t,n={},r=Ac){super(),this._def=t,this._props=n,this._createApp=r,this._isVueCE=!0,this._instance=null,this._app=null,this._nonce=this._def.nonce,this._connected=!1,this._resolved=!1,this._patching=!1,this._dirty=!1,this._numberProps=null,this._styleChildren=new WeakSet,this._styleAnchors=new WeakMap,this._ob=null,this.shadowRoot&&r!==Ac?this._root=this.shadowRoot:t.shadowRoot!==!1?(this.attachShadow(Yn({},t.shadowRootOptions,{mode:"open"})),this._root=this.shadowRoot):this._root=this}connectedCallback(){if(!this.isConnected)return;!this.shadowRoot&&!this._resolved&&this._parseSlots(),this._connected=!0;let t=this;for(;t=t&&(t.assignedSlot||t.parentNode||t.host);)if(t instanceof Ax){this._parent=t;break}this._instance||(this._resolved?this._mount(this._def):t&&t._pendingResolve?this._pendingResolve=t._pendingResolve.then(()=>{this._pendingResolve=void 0,this._resolveDef()}):this._resolveDef())}_setParent(t=this._parent){t&&(this._instance.parent=t._instance,this._inheritParentContext(t))}_inheritParentContext(t=this._parent){t&&this._app&&Object.setPrototypeOf(this._app._context.provides,t._instance.provides)}disconnectedCallback(){this._connected=!1,Ct(()=>{this._connected||(this._ob&&(this._ob.disconnect(),this._ob=null),this._app&&this._app.unmount(),this._instance&&(this._instance.ce=void 0),this._app=this._instance=null,this._teleportTargets&&(this._teleportTargets.clear(),this._teleportTargets=void 0))})}_processMutations(t){for(const n of t)this._setAttr(n.attributeName)}_resolveDef(){if(this._pendingResolve)return;for(let r=0;r<this.attributes.length;r++)this._setAttr(this.attributes[r].name);this._ob=new MutationObserver(this._processMutations.bind(this)),this._ob.observe(this,{attributes:!0});const t=(r,o=!1)=>{this._resolved=!0,this._pendingResolve=void 0;const{props:i,styles:s}=r;let a;if(i&&!Vt(i))for(const l in i){const u=i[l];(u===Number||u&&u.type===Number)&&(l in this._props&&(this._props[l]=Jd(this._props[l])),(a||(a=Object.create(null)))[jr(l)]=!0)}this._numberProps=a,this._resolveProps(r),this.shadowRoot&&this._applyStyles(s),this._mount(r)},n=this._def.__asyncLoader;n?this._pendingResolve=n().then(r=>{r.configureApp=this._def.configureApp,t(this._def=r,!0)}):t(this._def)}_mount(t){this._app=this._createApp(t),this._inheritParentContext(),t.configureApp&&t.configureApp(this._app),this._app._ceVNode=this._createVNode(),this._app.mount(this._root);const n=this._instance&&this._instance.exposed;if(n)for(const r in n)Gn(this,r)||Object.defineProperty(this,r,{get:()=>et(n[r])})}_resolveProps(t){const{props:n}=t,r=Vt(n)?n:Object.keys(n||{});for(const o of Object.keys(this))o[0]!=="_"&&r.includes(o)&&this._setProp(o,this[o]);for(const o of r.map(jr))Object.defineProperty(this,o,{get(){return this._getProp(o)},set(i){this._setProp(o,i,!0,!this._patching)}})}_setAttr(t){if(t.startsWith("data-v-"))return;const n=this.hasAttribute(t);let r=n?this.getAttribute(t):Xy;const o=jr(t);n&&this._numberProps&&this._numberProps[o]&&(r=Jd(r)),this._setProp(o,r,!1,!0)}_getProp(t){return this._props[t]}_setProp(t,n,r=!0,o=!1){if(n!==this._props[t]&&(this._dirty=!0,n===Xy?delete this._props[t]:(this._props[t]=n,t==="key"&&this._app&&(this._app._ceVNode.key=n)),o&&this._instance&&this._update(),r)){const i=this._ob;i&&(this._processMutations(i.takeRecords()),i.disconnect()),n===!0?this.setAttribute(Go(t),""):typeof n=="string"||typeof n=="number"?this.setAttribute(Go(t),n+""):n||this.removeAttribute(Go(t)),i&&i.observe(this,{attributes:!0})}}_update(){const t=this._createVNode();this._app&&(t.appContext=this._app._context),ob(t,this._root)}_createVNode(){const t={};this.shadowRoot||(t.onVnodeMounted=t.onVnodeUpdated=this._renderSlots.bind(this));const n=en(this._def,Yn(t,this._props));return this._instance||(n.ce=r=>{this._instance=r,r.ce=this,r.isCE=!0;const o=(i,s)=>{this.dispatchEvent(new CustomEvent(i,Yd(s[0])?Yn({detail:s},s[0]):{detail:s}))};r.emit=(i,...s)=>{o(i,s),Go(i)!==i&&o(Go(i),s)},this._setParent()}),n}_applyStyles(t,n,r){if(!t)return;if(n){if(n===this._def||this._styleChildren.has(n))return;this._styleChildren.add(n)}const o=this._nonce,i=this.shadowRoot,s=r?this._getStyleAnchor(r)||this._getStyleAnchor(this._def):this._getRootStyleInsertionAnchor(i);let a=null;for(let l=t.length-1;l>=0;l--){const u=document.createElement("style");o&&u.setAttribute("nonce",o),u.textContent=t[l],i.insertBefore(u,a||s),a=u,l===0&&(r||this._styleAnchors.set(this._def,u),n&&this._styleAnchors.set(n,u))}}_getStyleAnchor(t){if(!t)return null;const n=this._styleAnchors.get(t);return n&&n.parentNode===this.shadowRoot?n:(n&&this._styleAnchors.delete(t),null)}_getRootStyleInsertionAnchor(t){for(let n=0;n<t.childNodes.length;n++){const r=t.childNodes[n];if(!(r instanceof HTMLStyleElement))return r}return null}_parseSlots(){const t=this._slots={};let n;for(;n=this.firstChild;){const r=n.nodeType===1&&n.getAttribute("slot")||"default";(t[r]||(t[r]=[])).push(n),this.removeChild(n)}}_renderSlots(){const t=this._getSlots(),n=this._instance.type.__scopeId;for(let r=0;r<t.length;r++){const o=t[r],i=o.getAttribute("name")||"default",s=this._slots[i],a=o.parentNode;if(s)for(const l of s){if(n&&l.nodeType===1){const u=n+"-s",d=document.createTreeWalker(l,1);l.setAttribute(u,"");let f;for(;f=d.nextNode();)f.setAttribute(u,"")}a.insertBefore(l,o)}else for(;o.firstChild;)a.insertBefore(o.firstChild,o);a.removeChild(o)}}_getSlots(){const t=[this];this._teleportTargets&&t.push(...this._teleportTargets);const n=new Set;for(const r of t){const o=r.querySelectorAll("slot");for(let i=0;i<o.length;i++)n.add(o[i])}return Array.from(n)}_injectChildStyle(t,n){this._applyStyles(t.styles,t,n)}_beginPatch(){this._patching=!0,this._dirty=!1}_endPatch(){this._patching=!1,this._dirty&&this._instance&&this._update()}_hasShadowRoot(){return this._def.shadowRoot!==!1}_removeChildStyle(t){}},Qy=new WeakMap,Jy=new WeakMap,Lf=Symbol("_moveCb"),eb=Symbol("_enterCb"),_k=e=>(delete e.props.mode,e),Ak=_k({name:"TransitionGroup",props:Yn({},By,{tag:String,moveClass:String}),setup(e,{slots:t}){const n=yr(),r=jv();let o,i;return If(()=>{if(!o.length)return;const s=e.moveClass||`${e.name||"v"}-move`;if(!Y5(o[0].el,n.vnode.el,s)){o=[];return}o.forEach(W5),o.forEach(K5);const a=o.filter(q5);My(n.vnode.el),a.forEach(l=>{const u=l.el,d=u.style;Ws(u,s),d.transform=d.webkitTransform=d.transitionDuration="";const f=u[Lf]=p=>{p&&p.target!==u||(!p||p.propertyName.endsWith("transform"))&&(u.removeEventListener("transitionend",f),u[Lf]=null,Al(u,s))};u.addEventListener("transitionend",f)}),o=[]}),()=>{const s=Cn(e),a=qC(s);let l=s.tag||Bt;if(o=[],i)for(let u=0;u<i.length;u++){const d=i[u];d.el&&d.el instanceof Element&&(o.push(d),Ia(d,bu(d,a,r,n)),Qy.set(d,ok(d.el)))}i=t.default?mp(t.default()):[];for(let u=0;u<i.length;u++){const d=i[u];d.key!=null&&Ia(d,bu(d,a,r,n))}return en(l,null,i)}}}),Pa=e=>{const t=e.props["onUpdate:modelValue"]||!1;return Vt(t)?n=>mc(t,n):t},Ai=Symbol("_assign"),Ii={created(e,{modifiers:{lazy:t,trim:n,number:r}},o){e[Ai]=Pa(o);const i=r||o.props&&o.props.type==="number";Ma(e,t?"change":"input",s=>{s.target.composing||e[Ai](sk(e.value,n,i))}),(n||i)&&Ma(e,"change",()=>{e.value=sk(e.value,n,i)}),t||(Ma(e,"compositionstart",X5),Ma(e,"compositionend",ik),Ma(e,"change",ik))},mounted(e,{value:t}){e.value=t??""},beforeUpdate(e,{value:t,oldValue:n,modifiers:{lazy:r,trim:o,number:i}},s){if(e[Ai]=Pa(s),e.composing)return;const a=(i||e.type==="number")&&!/^0\d/.test(e.value)?Qd(e.value):e.value,l=t??"";if(a===l)return;const u=e.getRootNode();(u instanceof Document||u instanceof ShadowRoot)&&u.activeElement===e&&e.type!=="range"&&(r&&t===n||o&&e.value.trim()===l)||(e.value=l)}},Pu={deep:!0,created(e,t,n){e[Ai]=Pa(n),Ma(e,"change",()=>{const r=e._modelValue,o=Mu(e),i=e.checked,s=e[Ai];if(Vt(r)){const a=ep(r,o),l=a!==-1;if(i&&!l)s(r.concat(o));else if(!i&&l){const u=[...r];u.splice(a,1),s(u)}}else if(hl(r)){const a=new Set(r);i?a.add(o):a.delete(o),s(a)}else s(ck(e,i))})},mounted:ak,beforeUpdate(e,t,n){e[Ai]=Pa(n),ak(e,t,n)}},Gp={created(e,{value:t},n){e.checked=ba(t,n.props.value),e[Ai]=Pa(n),Ma(e,"change",()=>{e[Ai](Mu(e))})},beforeUpdate(e,{value:t,oldValue:n},r){e[Ai]=Pa(r),t!==n&&(e.checked=ba(t,r.props.value))}},Wp={deep:!0,created(e,{value:t,modifiers:{number:n}},r){const o=hl(t);Ma(e,"change",()=>{const i=Array.prototype.filter.call(e.options,s=>s.selected).map(s=>n?Qd(Mu(s)):Mu(s));e[Ai](e.multiple?o?new Set(i):i:i[0]),e._assigning=!0,Ct(()=>{e._assigning=!1})}),e[Ai]=Pa(r)},mounted(e,{value:t}){lk(e,t)},beforeUpdate(e,t,n){e[Ai]=Pa(n)},updated(e,{value:t}){e._assigning||lk(e,t)}},tb={created(e,t,n){jp(e,t,n,null,"created")},mounted(e,t,n){jp(e,t,n,null,"mounted")},beforeUpdate(e,t,n,r){jp(e,t,n,r,"beforeUpdate")},updated(e,t,n,r){jp(e,t,n,r,"updated")}},Ik=["ctrl","shift","alt","meta"],Ek={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&e.button!==0,middle:e=>"button"in e&&e.button!==1,right:e=>"button"in e&&e.button!==2,exact:(e,t)=>Ik.some(n=>e[`${n}Key`]&&!t.includes(n))},tn=(e,t)=>{if(!e)return e;const n=e._withMods||(e._withMods={}),r=t.join(".");return n[r]||(n[r]=((o,...i)=>{for(let s=0;s<t.length;s++){const a=Ek[t[s]];if(a&&a(o,t))return}return e(o,...i)}))},xk={esc:"escape",space:" ",up:"arrow-up",left:"arrow-left",right:"arrow-right",down:"arrow-down",delete:"backspace"},Ko=(e,t)=>{const n=e._withKeys||(e._withKeys={}),r=t.join(".");return n[r]||(n[r]=(o=>{if(!("key"in o))return;const i=Go(o.key);if(t.some(s=>s===i||xk[s]===i))return e(o)}))},nb=Yn({patchProp:Yy},Fy),rb=!1,ob=((...e)=>{dk().render(...e)}),Tk=((...e)=>{fk().hydrate(...e)}),Ac=((...e)=>{const t=dk().createApp(...e),{mount:n}=t;return t.mount=r=>{const o=pk(r);if(!o)return;const i=t._component;!nn(i)&&!i.render&&!i.template&&(i.template=o.innerHTML),o.nodeType===1&&(o.textContent="");const s=n(o,!1,hk(o));return o instanceof Element&&(o.removeAttribute("v-cloak"),o.setAttribute("data-v-app","")),s},t}),ib=((...e)=>{const t=fk().createApp(...e),{mount:n}=t;return t.mount=r=>{const o=pk(r);if(o)return n(o,!0,hk(o))},t}),sb=!1,Rk=()=>{sb||(sb=!0,Z5(),P5())}})),J5=Gd({BaseTransition:()=>fy,BaseTransitionPropsValidators:()=>Ip,Comment:()=>Or,DeprecationTypes:()=>null,EffectScope:()=>cp,ErrorCodes:()=>uC,ErrorTypeStrings:()=>$C,Fragment:()=>Bt,KeepAlive:()=>AC,ReactiveEffect:()=>mu,Static:()=>kl,Suspense:()=>NC,Teleport:()=>wl,Text:()=>Ra,TrackOpTypes:()=>dw,Transition:()=>Up,TransitionGroup:()=>Ak,TriggerOpTypes:()=>fw,VueElement:()=>Zy,assertNumber:()=>TT,callWithAsyncErrorHandling:()=>Ui,callWithErrorHandling:()=>yu,camelize:()=>jr,capitalize:()=>fu,cloneVNode:()=>Us,compatUtils:()=>null,compile:()=>Mk,computed:()=>_e,createApp:()=>Ac,createBlock:()=>hn,createCommentVNode:()=>ut,createElementBlock:()=>Ce,createElementVNode:()=>ce,createHydrationRenderer:()=>Ww,createPropsRestProxy:()=>n5,createRenderer:()=>Gw,createSSRApp:()=>ib,createSlots:()=>GT,createStaticVNode:()=>rC,createTextVNode:()=>Si,createVNode:()=>en,customRef:()=>$2,defineAsyncComponent:()=>Iw,defineComponent:()=>vl,defineCustomElement:()=>nk,defineEmits:()=>qT,defineExpose:()=>YT,defineModel:()=>QT,defineOptions:()=>XT,defineProps:()=>KT,defineSSRCustomElement:()=>kk,defineSlots:()=>ZT,devtools:()=>HC,effect:()=>fT,effectScope:()=>yv,getCurrentInstance:()=>yr,getCurrentScope:()=>bv,getCurrentWatcher:()=>_T,getTransitionRawChildren:()=>mp,guardReactiveProps:()=>nC,h:()=>Dr,handleError:()=>vc,hasInjectionContext:()=>yw,hydrate:()=>Tk,hydrateOnIdle:()=>CC,hydrateOnInteraction:()=>_C,hydrateOnMediaQuery:()=>SC,hydrateOnVisible:()=>kC,initCustomFormatter:()=>I5,initDirectivesForSSR:()=>Rk,inject:()=>gl,isMemoSame:()=>cC,isProxy:()=>nf,isReactive:()=>zi,isReadonly:()=>js,isRef:()=>hr,isRuntimeOnly:()=>jC,isShallow:()=>oi,isVNode:()=>Ea,markRaw:()=>Gr,mergeDefaults:()=>e5,mergeModels:()=>t5,mergeProps:()=>$s,nextTick:()=>Ct,nodeOps:()=>Fy,normalizeClass:()=>Zt,normalizeProps:()=>cv,normalizeStyle:()=>An,onActivated:()=>$v,onBeforeMount:()=>my,onBeforeUnmount:()=>ur,onBeforeUpdate:()=>Ep,onDeactivated:()=>Hv,onErrorCaptured:()=>xw,onMounted:()=>zn,onRenderTracked:()=>yy,onRenderTriggered:()=>vy,onScopeDispose:()=>P2,onServerPrefetch:()=>gy,onUnmounted:()=>Ef,onUpdated:()=>If,onWatcherCleanup:()=>W2,openBlock:()=>pe,patchProp:()=>Yy,popScopeId:()=>PT,provide:()=>vw,proxyRefs:()=>Iv,pushScopeId:()=>LT,queuePostFlushCb:()=>df,reactive:()=>Qr,readonly:()=>ap,ref:()=>te,registerRuntimeCompiler:()=>_5,render:()=>ob,renderList:()=>Rn,renderSlot:()=>Cu,resolveComponent:()=>HT,resolveDirective:()=>Tw,resolveDynamicComponent:()=>Wv,resolveFilter:()=>null,resolveTransitionHooks:()=>bu,setBlockTracking:()=>bf,setDevtoolsHook:()=>GC,setTransitionHooks:()=>Ia,shallowReactive:()=>V2,shallowReadonly:()=>wT,shallowRef:()=>Pr,ssrContextKey:()=>iy,ssrUtils:()=>WC,stop:()=>hT,toDisplayString:()=>Et,toHandlerKey:()=>hu,toHandlers:()=>WT,toRaw:()=>Cn,toRef:()=>Ev,toRefs:()=>H2,toValue:()=>kT,transformVNodeArgs:()=>C5,triggerRef:()=>CT,unref:()=>et,useAttrs:()=>Lw,useCssModule:()=>G5,useCssVars:()=>D5,useHost:()=>rk,useId:()=>BT,useModel:()=>c5,useSSRContext:()=>sy,useShadowRoot:()=>H5,useSlots:()=>Mw,useTemplateRef:()=>zT,useTransitionState:()=>jv,vModelCheckbox:()=>Pu,vModelDynamic:()=>tb,vModelRadio:()=>Gp,vModelSelect:()=>Wp,vModelText:()=>Ii,vShow:()=>Vy,version:()=>Ty,warn:()=>UC,watch:()=>jt,watchEffect:()=>DT,watchPostEffect:()=>OT,watchSyncEffect:()=>bw,withAsyncContext:()=>r5,withCtx:()=>ao,withDefaults:()=>JT,withDirectives:()=>ki,withKeys:()=>Ko,withMemo:()=>E5,withModifiers:()=>tn,withScopeId:()=>fC}),Mk,Ft=Lr((()=>{Q5(),Mk=()=>{}})),e6=h2(((e,t)=>{(function(n){typeof e=="object"&&typeof t<"u"?t.exports=n():typeof define=="function"&&define.amd?define([],n):(typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:this).JSZip=n()})(function(){return(function n(r,o,i){function s(u,d){if(!o[u]){if(!r[u]){var f=typeof require=="function"&&require;if(!d&&f)return f(u,!0);if(a)return a(u,!0);var p=new Error("Cannot find module '"+u+"'");throw p.code="MODULE_NOT_FOUND",p}var g=o[u]={exports:{}};r[u][0].call(g.exports,function(m){var v=r[u][1][m];return s(v||m)},g,g.exports,n,r,o,i)}return o[u].exports}for(var a=typeof require=="function"&&require,l=0;l<i.length;l++)s(i[l]);return s})({1:[function(n,r,o){"use strict";var i=n("./utils"),s=n("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";o.encode=function(l){for(var u,d,f,p,g,m,v,C=[],w=0,S=l.length,b=S,k=i.getTypeOf(l)!=="string";w<l.length;)b=S-w,f=k?(u=l[w++],d=w<S?l[w++]:0,w<S?l[w++]:0):(u=l.charCodeAt(w++),d=w<S?l.charCodeAt(w++):0,w<S?l.charCodeAt(w++):0),p=u>>2,g=(3&u)<<4|d>>4,m=1<b?(15&d)<<2|f>>6:64,v=2<b?63&f:64,C.push(a.charAt(p)+a.charAt(g)+a.charAt(m)+a.charAt(v));return C.join("")},o.decode=function(l){var u,d,f,p,g,m,v=0,C=0,w="data:";if(l.substr(0,w.length)===w)throw new Error("Invalid base64 input, it looks like a data url.");var S,b=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&b--,l.charAt(l.length-2)===a.charAt(64)&&b--,b%1!=0)throw new Error("Invalid base64 input, bad content length.");for(S=s.uint8array?new Uint8Array(0|b):new Array(0|b);v<l.length;)u=a.indexOf(l.charAt(v++))<<2|(p=a.indexOf(l.charAt(v++)))>>4,d=(15&p)<<4|(g=a.indexOf(l.charAt(v++)))>>2,f=(3&g)<<6|(m=a.indexOf(l.charAt(v++))),S[C++]=u,g!==64&&(S[C++]=d),m!==64&&(S[C++]=f);return S}},{"./support":30,"./utils":32}],2:[function(n,r,o){"use strict";var i=n("./external"),s=n("./stream/DataWorker"),a=n("./stream/Crc32Probe"),l=n("./stream/DataLengthProbe");function u(d,f,p,g,m){this.compressedSize=d,this.uncompressedSize=f,this.crc32=p,this.compression=g,this.compressedContent=m}u.prototype={getContentWorker:function(){var d=new s(i.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),f=this;return d.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new s(i.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,f,p){return d.pipe(new a).pipe(new l("uncompressedSize")).pipe(f.compressWorker(p)).pipe(new l("compressedSize")).withStreamInfo("compression",f)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,o){"use strict";var i=n("./stream/GenericWorker");o.STORE={magic:"\0\0",compressWorker:function(){return new i("STORE compression")},uncompressWorker:function(){return new i("STORE decompression")}},o.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,o){"use strict";var i=n("./utils"),s=(function(){for(var a,l=[],u=0;u<256;u++){a=u;for(var d=0;d<8;d++)a=1&a?3988292384^a>>>1:a>>>1;l[u]=a}return l})();r.exports=function(a,l){return a!==void 0&&a.length?i.getTypeOf(a)!=="string"?(function(u,d,f,p){var g=s,m=p+f;u^=-1;for(var v=p;v<m;v++)u=u>>>8^g[255&(u^d[v])];return-1^u})(0|l,a,a.length,0):(function(u,d,f,p){var g=s,m=p+f;u^=-1;for(var v=p;v<m;v++)u=u>>>8^g[255&(u^d.charCodeAt(v))];return-1^u})(0|l,a,a.length,0):0}},{"./utils":32}],5:[function(n,r,o){"use strict";o.base64=!1,o.binary=!1,o.dir=!1,o.createFolders=!0,o.date=null,o.compression=null,o.compressionOptions=null,o.comment=null,o.unixPermissions=null,o.dosPermissions=null},{}],6:[function(n,r,o){"use strict";var i=null;i=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:i}},{lie:37}],7:[function(n,r,o){"use strict";var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=n("pako"),a=n("./utils"),l=n("./stream/GenericWorker"),u=i?"uint8array":"array";function d(f,p){l.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=p,this.meta={}}o.magic="\b\0",a.inherits(d,l),d.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(u,f.data),!1)},d.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(p){f.push({data:p,meta:f.meta})}},o.compressWorker=function(f){return new d("Deflate",f)},o.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,o){"use strict";function i(g,m){var v,C="";for(v=0;v<m;v++)C+=String.fromCharCode(255&g),g>>>=8;return C}function s(g,m,v,C,w,S){var b,k,x=g.file,M=g.compression,z=S!==u.utf8encode,G=a.transformTo("string",S(x.name)),F=a.transformTo("string",u.utf8encode(x.name)),L=x.comment,$=a.transformTo("string",S(L)),T=a.transformTo("string",u.utf8encode(L)),H=F.length!==x.name.length,R=T.length!==L.length,U="",W="",ee="",J=x.dir,Z=x.date,Me={crc32:0,compressedSize:0,uncompressedSize:0};m&&!v||(Me.crc32=g.crc32,Me.compressedSize=g.compressedSize,Me.uncompressedSize=g.uncompressedSize);var fe=0;m&&(fe|=8),z||!H&&!R||(fe|=2048);var ye=0,ve=0;J&&(ye|=16),w==="UNIX"?(ve=798,ye|=(function(Ve,nt){var ct=Ve;return Ve||(ct=nt?16893:33204),(65535&ct)<<16})(x.unixPermissions,J)):(ve=20,ye|=(function(Ve){return 63&(Ve||0)})(x.dosPermissions)),b=Z.getUTCHours(),b<<=6,b|=Z.getUTCMinutes(),b<<=5,b|=Z.getUTCSeconds()/2,k=Z.getUTCFullYear()-1980,k<<=4,k|=Z.getUTCMonth()+1,k<<=5,k|=Z.getUTCDate(),H&&(W=i(1,1)+i(d(G),4)+F,U+="up"+i(W.length,2)+W),R&&(ee=i(1,1)+i(d($),4)+T,U+="uc"+i(ee.length,2)+ee);var Pe="";return Pe+=`
|
|
4
|
-
\0`,Pe+=i(fe,2),Pe+=M.magic,Pe+=i(b,2),Pe+=i(k,2),Pe+=i(Me.crc32,4),Pe+=i(Me.compressedSize,4),Pe+=i(Me.uncompressedSize,4),Pe+=i(G.length,2),Pe+=i(U.length,2),{fileRecord:f.LOCAL_FILE_HEADER+Pe+G+U,dirRecord:f.CENTRAL_FILE_HEADER+i(ve,2)+Pe+i($.length,2)+"\0\0\0\0"+i(ye,4)+i(C,4)+G+U+$}}var a=n("../utils"),l=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function p(g,m,v,C){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=m,this.zipPlatform=v,this.encodeFileName=C,this.streamFiles=g,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(p,l),p.prototype.push=function(g){var m=g.meta.percent||0,v=this.entriesCount,C=this._sources.length;this.accumulate?this.contentBuffer.push(g):(this.bytesWritten+=g.data.length,l.prototype.push.call(this,{data:g.data,meta:{currentFile:this.currentFile,percent:v?(m+100*(v-C-1))/v:100}}))},p.prototype.openedSource=function(g){this.currentSourceOffset=this.bytesWritten,this.currentFile=g.file.name;var m=this.streamFiles&&!g.file.dir;if(m){var v=s(g,m,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:v.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(g){this.accumulate=!1;var m=this.streamFiles&&!g.file.dir,v=s(g,m,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(v.dirRecord),m)this.push({data:(function(C){return f.DATA_DESCRIPTOR+i(C.crc32,4)+i(C.compressedSize,4)+i(C.uncompressedSize,4)})(g),meta:{percent:100}});else for(this.push({data:v.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var g=this.bytesWritten,m=0;m<this.dirRecords.length;m++)this.push({data:this.dirRecords[m],meta:{percent:100}});var v=this.bytesWritten-g,C=(function(w,S,b,k,x){var M=a.transformTo("string",x(k));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+i(w,2)+i(w,2)+i(S,4)+i(b,4)+i(M.length,2)+M})(this.dirRecords.length,v,g,this.zipComment,this.encodeFileName);this.push({data:C,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(g){this._sources.push(g);var m=this;return g.on("data",function(v){m.processChunk(v)}),g.on("end",function(){m.closedSource(m.previous.streamInfo),m._sources.length?m.prepareNextSource():m.end()}),g.on("error",function(v){m.error(v)}),this},p.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},p.prototype.error=function(g){var m=this._sources;if(!l.prototype.error.call(this,g))return!1;for(var v=0;v<m.length;v++)try{m[v].error(g)}catch{}return!0},p.prototype.lock=function(){l.prototype.lock.call(this);for(var g=this._sources,m=0;m<g.length;m++)g[m].lock()},r.exports=p},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,o){"use strict";var i=n("../compressions"),s=n("./ZipFileWorker");o.generateWorker=function(a,l,u){var d=new s(l.streamFiles,u,l.platform,l.encodeFileName),f=0;try{a.forEach(function(p,g){f++;var m=(function(S,b){var k=S||b,x=i[k];if(!x)throw new Error(k+" is not a valid compression method !");return x})(g.options.compression,l.compression),v=g.options.compressionOptions||l.compressionOptions||{},C=g.dir,w=g.date;g._compressWorker(m,v).withStreamInfo("file",{name:p,dir:C,date:w,comment:g.comment||"",unixPermissions:g.unixPermissions,dosPermissions:g.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(p){d.error(p)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,o){"use strict";function i(){if(!(this instanceof i))return new i;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var s=new i;for(var a in this)typeof this[a]!="function"&&(s[a]=this[a]);return s}}(i.prototype=n("./object")).loadAsync=n("./load"),i.support=n("./support"),i.defaults=n("./defaults"),i.version="3.10.1",i.loadAsync=function(s,a){return new i().loadAsync(s,a)},i.external=n("./external"),r.exports=i},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,o){"use strict";var i=n("./utils"),s=n("./external"),a=n("./utf8"),l=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function f(p){return new s.Promise(function(g,m){var v=p.decompressed.getContentWorker().pipe(new u);v.on("error",function(C){m(C)}).on("end",function(){v.streamInfo.crc32!==p.decompressed.crc32?m(new Error("Corrupted zip : CRC32 mismatch")):g()}).resume()})}r.exports=function(p,g){var m=this;return g=i.extend(g||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),d.isNode&&d.isStream(p)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):i.prepareContent("the loaded zip file",p,!0,g.optimizedBinaryString,g.base64).then(function(v){var C=new l(g);return C.load(v),C}).then(function(v){var C=[s.Promise.resolve(v)],w=v.files;if(g.checkCRC32)for(var S=0;S<w.length;S++)C.push(f(w[S]));return s.Promise.all(C)}).then(function(v){for(var C=v.shift(),w=C.files,S=0;S<w.length;S++){var b=w[S],k=b.fileNameStr,x=i.resolve(b.fileNameStr);m.file(x,b.decompressed,{binary:!0,optimizedBinaryString:!0,date:b.date,dir:b.dir,comment:b.fileCommentStr.length?b.fileCommentStr:null,unixPermissions:b.unixPermissions,dosPermissions:b.dosPermissions,createFolders:g.createFolders}),b.dir||(m.file(x).unsafeOriginalName=k)}return C.zipComment.length&&(m.comment=C.zipComment),m})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,o){"use strict";var i=n("../utils"),s=n("../stream/GenericWorker");function a(l,u){s.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(u)}i.inherits(a,s),a.prototype._bindStream=function(l){var u=this;(this._stream=l).pause(),l.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},a.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,o){"use strict";var i=n("readable-stream").Readable;function s(a,l,u){i.call(this,l),this._helper=a;var d=this;a.on("data",function(f,p){d.push(f)||d._helper.pause(),u&&u(p)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(s,i),s.prototype._read=function(){this._helper.resume()},r.exports=s},{"../utils":32,"readable-stream":16}],14:[function(n,r,o){"use strict";r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(i,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(i,s);if(typeof i=="number")throw new Error('The "data" argument must not be a number');return new Buffer(i,s)},allocBuffer:function(i){if(Buffer.alloc)return Buffer.alloc(i);var s=new Buffer(i);return s.fill(0),s},isBuffer:function(i){return Buffer.isBuffer(i)},isStream:function(i){return i&&typeof i.on=="function"&&typeof i.pause=="function"&&typeof i.resume=="function"}}},{}],15:[function(n,r,o){"use strict";function i(k,x,M){var z,G=a.getTypeOf(x),F=a.extend(M||{},d);F.date=F.date||new Date,F.compression!==null&&(F.compression=F.compression.toUpperCase()),typeof F.unixPermissions=="string"&&(F.unixPermissions=parseInt(F.unixPermissions,8)),F.unixPermissions&&16384&F.unixPermissions&&(F.dir=!0),F.dosPermissions&&16&F.dosPermissions&&(F.dir=!0),F.dir&&(k=w(k)),F.createFolders&&(z=C(k))&&S.call(this,z,!0);var L=G==="string"&&F.binary===!1&&F.base64===!1;M&&M.binary!==void 0||(F.binary=!L),(x instanceof f&&x.uncompressedSize===0||F.dir||!x||x.length===0)&&(F.base64=!1,F.binary=!0,x="",F.compression="STORE",G="string");var $=null;$=x instanceof f||x instanceof l?x:m.isNode&&m.isStream(x)?new v(k,x):a.prepareContent(k,x,F.binary,F.optimizedBinaryString,F.base64);var T=new p(k,$,F);this.files[k]=T}var s=n("./utf8"),a=n("./utils"),l=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),p=n("./zipObject"),g=n("./generate"),m=n("./nodejsUtils"),v=n("./nodejs/NodejsStreamInputAdapter"),C=function(k){k.slice(-1)==="/"&&(k=k.substring(0,k.length-1));var x=k.lastIndexOf("/");return 0<x?k.substring(0,x):""},w=function(k){return k.slice(-1)!=="/"&&(k+="/"),k},S=function(k,x){return x=x!==void 0?x:d.createFolders,k=w(k),this.files[k]||i.call(this,k,null,{dir:!0,createFolders:x}),this.files[k]};function b(k){return Object.prototype.toString.call(k)==="[object RegExp]"}r.exports={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(k){var x,M,z;for(x in this.files)z=this.files[x],(M=x.slice(this.root.length,x.length))&&x.slice(0,this.root.length)===this.root&&k(M,z)},filter:function(k){var x=[];return this.forEach(function(M,z){k(M,z)&&x.push(z)}),x},file:function(k,x,M){if(arguments.length!==1)return k=this.root+k,i.call(this,k,x,M),this;if(b(k)){var z=k;return this.filter(function(F,L){return!L.dir&&z.test(F)})}var G=this.files[this.root+k];return G&&!G.dir?G:null},folder:function(k){if(!k)return this;if(b(k))return this.filter(function(G,F){return F.dir&&k.test(G)});var x=this.root+k,M=S.call(this,x),z=this.clone();return z.root=M.name,z},remove:function(k){k=this.root+k;var x=this.files[k];if(x||(k.slice(-1)!=="/"&&(k+="/"),x=this.files[k]),x&&!x.dir)delete this.files[k];else for(var M=this.filter(function(G,F){return F.name.slice(0,k.length)===k}),z=0;z<M.length;z++)delete this.files[M[z].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(k){var x,M={};try{if((M=a.extend(k||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=M.type.toLowerCase(),M.compression=M.compression.toUpperCase(),M.type==="binarystring"&&(M.type="string"),!M.type)throw new Error("No output type specified.");a.checkSupport(M.type),M.platform!=="darwin"&&M.platform!=="freebsd"&&M.platform!=="linux"&&M.platform!=="sunos"||(M.platform="UNIX"),M.platform==="win32"&&(M.platform="DOS");var z=M.comment||this.comment||"";x=g.generateWorker(this,M,z)}catch(G){(x=new l("error")).error(G)}return new u(x,M.type||"string",M.mimeType)},generateAsync:function(k,x){return this.generateInternalStream(k).accumulate(x)},generateNodeStream:function(k,x){return(k=k||{}).type||(k.type="nodebuffer"),this.generateInternalStream(k).toNodejsStream(x)}}},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,o){"use strict";r.exports=n("stream")},{stream:void 0}],17:[function(n,r,o){"use strict";var i=n("./DataReader");function s(a){i.call(this,a);for(var l=0;l<this.data.length;l++)a[l]=255&a[l]}n("../utils").inherits(s,i),s.prototype.byteAt=function(a){return this.data[this.zero+a]},s.prototype.lastIndexOfSignature=function(a){for(var l=a.charCodeAt(0),u=a.charCodeAt(1),d=a.charCodeAt(2),f=a.charCodeAt(3),p=this.length-4;0<=p;--p)if(this.data[p]===l&&this.data[p+1]===u&&this.data[p+2]===d&&this.data[p+3]===f)return p-this.zero;return-1},s.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),u=a.charCodeAt(1),d=a.charCodeAt(2),f=a.charCodeAt(3),p=this.readData(4);return l===p[0]&&u===p[1]&&d===p[2]&&f===p[3]},s.prototype.readData=function(a){if(this.checkOffset(a),a===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./DataReader":18}],18:[function(n,r,o){"use strict";var i=n("../utils");function s(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var l,u=0;for(this.checkOffset(a),l=this.index+a-1;l>=this.index;l--)u=(u<<8)+this.byteAt(l);return this.index+=a,u},readString:function(a){return i.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},r.exports=s},{"../utils":32}],19:[function(n,r,o){"use strict";var i=n("./Uint8ArrayReader");function s(a){i.call(this,a)}n("../utils").inherits(s,i),s.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,o){"use strict";var i=n("./DataReader");function s(a){i.call(this,a)}n("../utils").inherits(s,i),s.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},s.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},s.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},s.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./DataReader":18}],21:[function(n,r,o){"use strict";var i=n("./ArrayReader");function s(a){i.call(this,a)}n("../utils").inherits(s,i),s.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,o){"use strict";var i=n("../utils"),s=n("../support"),a=n("./ArrayReader"),l=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(f){var p=i.getTypeOf(f);return i.checkSupport(p),p!=="string"||s.uint8array?p==="nodebuffer"?new u(f):s.uint8array?new d(i.transformTo("uint8array",f)):new a(i.transformTo("array",f)):new l(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,o){"use strict";o.LOCAL_FILE_HEADER="PK",o.CENTRAL_FILE_HEADER="PK",o.CENTRAL_DIRECTORY_END="PK",o.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",o.ZIP64_CENTRAL_DIRECTORY_END="PK",o.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,o){"use strict";var i=n("./GenericWorker"),s=n("../utils");function a(l){i.call(this,"ConvertWorker to "+l),this.destType=l}s.inherits(a,i),a.prototype.processChunk=function(l){this.push({data:s.transformTo(this.destType,l.data),meta:l.meta})},r.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,o){"use strict";var i=n("./GenericWorker"),s=n("../crc32");function a(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(a,i),a.prototype.processChunk=function(l){this.streamInfo.crc32=s(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,o){"use strict";var i=n("../utils"),s=n("./GenericWorker");function a(l){s.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}i.inherits(a,s),a.prototype.processChunk=function(l){if(l){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+l.data.length}s.prototype.processChunk.call(this,l)},r.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,o){"use strict";var i=n("../utils"),s=n("./GenericWorker");function a(l){s.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(d){u.dataIsReady=!0,u.data=d,u.max=d&&d.length||0,u.type=i.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}i.inherits(a,s),a.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,u);break;case"uint8array":l=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":l=this.data.slice(this.index,u)}return this.index=u,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,o){"use strict";function i(s){this.name=s||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}i.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,a){return this._listeners[s].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,a){if(this._listeners[s])for(var l=0;l<this._listeners[s].length;l++)this._listeners[s][l].call(this,a)},pipe:function(s){return s.registerPrevious(this)},registerPrevious:function(s){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=s.streamInfo,this.mergeStreamInfo(),this.previous=s;var a=this;return s.on("data",function(l){a.processChunk(l)}),s.on("end",function(){a.end()}),s.on("error",function(l){a.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var s=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),s=!0),this.previous&&this.previous.resume(),!s},flush:function(){},processChunk:function(s){this.push(s)},withStreamInfo:function(s,a){return this.extraStreamInfo[s]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var s in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,s)&&(this.streamInfo[s]=this.extraStreamInfo[s])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var s="Worker "+this.name;return this.previous?this.previous+" -> "+s:s}},r.exports=i},{}],29:[function(n,r,o){"use strict";var i=n("../utils"),s=n("./ConvertWorker"),a=n("./GenericWorker"),l=n("../base64"),u=n("../support"),d=n("../external"),f=null;if(u.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(m,v){return new d.Promise(function(C,w){var S=[],b=m._internalType,k=m._outputType,x=m._mimeType;m.on("data",function(M,z){S.push(M),v&&v(z)}).on("error",function(M){S=[],w(M)}).on("end",function(){try{C((function(M,z,G){switch(M){case"blob":return i.newBlob(i.transformTo("arraybuffer",z),G);case"base64":return l.encode(z);default:return i.transformTo(M,z)}})(k,(function(M,z){var G,F=0,L=null,$=0;for(G=0;G<z.length;G++)$+=z[G].length;switch(M){case"string":return z.join("");case"array":return Array.prototype.concat.apply([],z);case"uint8array":for(L=new Uint8Array($),G=0;G<z.length;G++)L.set(z[G],F),F+=z[G].length;return L;case"nodebuffer":return Buffer.concat(z);default:throw new Error("concat : unsupported type '"+M+"'")}})(b,S),x))}catch(M){w(M)}S=[]}).resume()})}function g(m,v,C){var w=v;switch(v){case"blob":case"arraybuffer":w="uint8array";break;case"base64":w="string"}try{this._internalType=w,this._outputType=v,this._mimeType=C,i.checkSupport(w),this._worker=m.pipe(new s(w)),m.lock()}catch(S){this._worker=new a("error"),this._worker.error(S)}}g.prototype={accumulate:function(m){return p(this,m)},on:function(m,v){var C=this;return m==="data"?this._worker.on(m,function(w){v.call(C,w.data,w.meta)}):this._worker.on(m,function(){i.delay(v,arguments,C)}),this},resume:function(){return i.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(m){if(i.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},m)}},r.exports=g},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,o){"use strict";if(o.base64=!0,o.array=!0,o.string=!0,o.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",o.nodebuffer=typeof Buffer<"u",o.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")o.blob=!1;else{var i=new ArrayBuffer(0);try{o.blob=new Blob([i],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(i),o.blob=s.getBlob("application/zip").size===0}catch{o.blob=!1}}}try{o.nodestream=!!n("readable-stream").Readable}catch{o.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,o){"use strict";for(var i=n("./utils"),s=n("./support"),a=n("./nodejsUtils"),l=n("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function f(){l.call(this,"utf-8 decode"),this.leftOver=null}function p(){l.call(this,"utf-8 encode")}o.utf8encode=function(g){return s.nodebuffer?a.newBufferFrom(g,"utf-8"):(function(m){var v,C,w,S,b,k=m.length,x=0;for(S=0;S<k;S++)(64512&(C=m.charCodeAt(S)))==55296&&S+1<k&&(64512&(w=m.charCodeAt(S+1)))==56320&&(C=65536+(C-55296<<10)+(w-56320),S++),x+=C<128?1:C<2048?2:C<65536?3:4;for(v=s.uint8array?new Uint8Array(x):new Array(x),S=b=0;b<x;S++)(64512&(C=m.charCodeAt(S)))==55296&&S+1<k&&(64512&(w=m.charCodeAt(S+1)))==56320&&(C=65536+(C-55296<<10)+(w-56320),S++),C<128?v[b++]=C:(C<2048?v[b++]=192|C>>>6:(C<65536?v[b++]=224|C>>>12:(v[b++]=240|C>>>18,v[b++]=128|C>>>12&63),v[b++]=128|C>>>6&63),v[b++]=128|63&C);return v})(g)},o.utf8decode=function(g){return s.nodebuffer?i.transformTo("nodebuffer",g).toString("utf-8"):(function(m){var v,C,w,S,b=m.length,k=new Array(2*b);for(v=C=0;v<b;)if((w=m[v++])<128)k[C++]=w;else if(4<(S=u[w]))k[C++]=65533,v+=S-1;else{for(w&=S===2?31:S===3?15:7;1<S&&v<b;)w=w<<6|63&m[v++],S--;1<S?k[C++]=65533:w<65536?k[C++]=w:(w-=65536,k[C++]=55296|w>>10&1023,k[C++]=56320|1023&w)}return k.length!==C&&(k.subarray?k=k.subarray(0,C):k.length=C),i.applyFromCharCode(k)})(g=i.transformTo(s.uint8array?"uint8array":"array",g))},i.inherits(f,l),f.prototype.processChunk=function(g){var m=i.transformTo(s.uint8array?"uint8array":"array",g.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var v=m;(m=new Uint8Array(v.length+this.leftOver.length)).set(this.leftOver,0),m.set(v,this.leftOver.length)}else m=this.leftOver.concat(m);this.leftOver=null}var C=(function(S,b){var k;for((b=b||S.length)>S.length&&(b=S.length),k=b-1;0<=k&&(192&S[k])==128;)k--;return k<0||k===0?b:k+u[S[k]]>b?k:b})(m),w=m;C!==m.length&&(s.uint8array?(w=m.subarray(0,C),this.leftOver=m.subarray(C,m.length)):(w=m.slice(0,C),this.leftOver=m.slice(C,m.length))),this.push({data:o.utf8decode(w),meta:g.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:o.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},o.Utf8DecodeWorker=f,i.inherits(p,l),p.prototype.processChunk=function(g){this.push({data:o.utf8encode(g.data),meta:g.meta})},o.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,o){"use strict";var i=n("./support"),s=n("./base64"),a=n("./nodejsUtils"),l=n("./external");function u(v){return v}function d(v,C){for(var w=0;w<v.length;++w)C[w]=255&v.charCodeAt(w);return C}n("setimmediate"),o.newBlob=function(v,C){o.checkSupport("blob");try{return new Blob([v],{type:C})}catch{try{var w=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return w.append(v),w.getBlob(C)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(v,C,w){var S=[],b=0,k=v.length;if(k<=w)return String.fromCharCode.apply(null,v);for(;b<k;)C==="array"||C==="nodebuffer"?S.push(String.fromCharCode.apply(null,v.slice(b,Math.min(b+w,k)))):S.push(String.fromCharCode.apply(null,v.subarray(b,Math.min(b+w,k)))),b+=w;return S.join("")},stringifyByChar:function(v){for(var C="",w=0;w<v.length;w++)C+=String.fromCharCode(v[w]);return C},applyCanBeUsed:{uint8array:(function(){try{return i.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return i.nodebuffer&&String.fromCharCode.apply(null,a.allocBuffer(1)).length===1}catch{return!1}})()}};function p(v){var C=65536,w=o.getTypeOf(v),S=!0;if(w==="uint8array"?S=f.applyCanBeUsed.uint8array:w==="nodebuffer"&&(S=f.applyCanBeUsed.nodebuffer),S)for(;1<C;)try{return f.stringifyByChunk(v,w,C)}catch{C=Math.floor(C/2)}return f.stringifyByChar(v)}function g(v,C){for(var w=0;w<v.length;w++)C[w]=v[w];return C}o.applyFromCharCode=p;var m={};m.string={string:u,array:function(v){return d(v,new Array(v.length))},arraybuffer:function(v){return m.string.uint8array(v).buffer},uint8array:function(v){return d(v,new Uint8Array(v.length))},nodebuffer:function(v){return d(v,a.allocBuffer(v.length))}},m.array={string:p,array:u,arraybuffer:function(v){return new Uint8Array(v).buffer},uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return a.newBufferFrom(v)}},m.arraybuffer={string:function(v){return p(new Uint8Array(v))},array:function(v){return g(new Uint8Array(v),new Array(v.byteLength))},arraybuffer:u,uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return a.newBufferFrom(new Uint8Array(v))}},m.uint8array={string:p,array:function(v){return g(v,new Array(v.length))},arraybuffer:function(v){return v.buffer},uint8array:u,nodebuffer:function(v){return a.newBufferFrom(v)}},m.nodebuffer={string:p,array:function(v){return g(v,new Array(v.length))},arraybuffer:function(v){return m.nodebuffer.uint8array(v).buffer},uint8array:function(v){return g(v,new Uint8Array(v.length))},nodebuffer:u},o.transformTo=function(v,C){return C=C||"",v?(o.checkSupport(v),m[o.getTypeOf(C)][v](C)):C},o.resolve=function(v){for(var C=v.split("/"),w=[],S=0;S<C.length;S++){var b=C[S];b==="."||b===""&&S!==0&&S!==C.length-1||(b===".."?w.pop():w.push(b))}return w.join("/")},o.getTypeOf=function(v){return typeof v=="string"?"string":Object.prototype.toString.call(v)==="[object Array]"?"array":i.nodebuffer&&a.isBuffer(v)?"nodebuffer":i.uint8array&&v instanceof Uint8Array?"uint8array":i.arraybuffer&&v instanceof ArrayBuffer?"arraybuffer":void 0},o.checkSupport=function(v){if(!i[v.toLowerCase()])throw new Error(v+" is not supported by this platform")},o.MAX_VALUE_16BITS=65535,o.MAX_VALUE_32BITS=-1,o.pretty=function(v){var C,w,S="";for(w=0;w<(v||"").length;w++)S+="\\x"+((C=v.charCodeAt(w))<16?"0":"")+C.toString(16).toUpperCase();return S},o.delay=function(v,C,w){setImmediate(function(){v.apply(w||null,C||[])})},o.inherits=function(v,C){function w(){}w.prototype=C.prototype,v.prototype=new w},o.extend=function(){var v,C,w={};for(v=0;v<arguments.length;v++)for(C in arguments[v])Object.prototype.hasOwnProperty.call(arguments[v],C)&&w[C]===void 0&&(w[C]=arguments[v][C]);return w},o.prepareContent=function(v,C,w,S,b){return l.Promise.resolve(C).then(function(k){return i.blob&&(k instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(k))!==-1)&&typeof FileReader<"u"?new l.Promise(function(x,M){var z=new FileReader;z.onload=function(G){x(G.target.result)},z.onerror=function(G){M(G.target.error)},z.readAsArrayBuffer(k)}):k}).then(function(k){var x=o.getTypeOf(k);return x?(x==="arraybuffer"?k=o.transformTo("uint8array",k):x==="string"&&(b?k=s.decode(k):w&&S!==!0&&(k=(function(M){return d(M,i.uint8array?new Uint8Array(M.length):new Array(M.length))})(k))),k):l.Promise.reject(new Error("Can't read the data of '"+v+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,o){"use strict";var i=n("./reader/readerFor"),s=n("./utils"),a=n("./signature"),l=n("./zipEntry"),u=n("./support");function d(f){this.files=[],this.loadOptions=f}d.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(p)+", expected "+s.pretty(f)+")")}},isSignature:function(f,p){var g=this.reader.index;this.reader.setIndex(f);var m=this.reader.readString(4)===p;return this.reader.setIndex(g),m},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),p=u.uint8array?"uint8array":"array",g=s.transformTo(p,f);this.zipComment=this.loadOptions.decodeFileName(g)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,p,g,m=this.zip64EndOfCentralSize-44;0<m;)f=this.reader.readInt(2),p=this.reader.readInt(4),g=this.reader.readData(p),this.zip64ExtensibleData[f]={id:f,length:p,value:g}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,p;for(f=0;f<this.files.length;f++)p=this.files[f],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(f=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,a.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var p=f;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===s.MAX_VALUE_16BITS||this.diskWithCentralDirStart===s.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===s.MAX_VALUE_16BITS||this.centralDirRecords===s.MAX_VALUE_16BITS||this.centralDirSize===s.MAX_VALUE_32BITS||this.centralDirOffset===s.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var g=this.centralDirOffset+this.centralDirSize;this.zip64&&(g+=20,g+=12+this.zip64EndOfCentralSize);var m=p-g;if(0<m)this.isSignature(p,a.CENTRAL_FILE_HEADER)||(this.reader.zero=m);else if(m<0)throw new Error("Corrupted zip: missing "+Math.abs(m)+" bytes.")},prepareReader:function(f){this.reader=i(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,o){"use strict";var i=n("./reader/readerFor"),s=n("./utils"),a=n("./compressedObject"),l=n("./crc32"),u=n("./utf8"),d=n("./compressions"),f=n("./support");function p(g,m){this.options=g,this.loadOptions=m}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(g){var m,v;if(g.skip(22),this.fileNameLength=g.readInt(2),v=g.readInt(2),this.fileName=g.readData(this.fileNameLength),g.skip(v),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((m=(function(C){for(var w in d)if(Object.prototype.hasOwnProperty.call(d,w)&&d[w].magic===C)return d[w];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,m,g.readData(this.compressedSize))},readCentralPart:function(g){this.versionMadeBy=g.readInt(2),g.skip(2),this.bitFlag=g.readInt(2),this.compressionMethod=g.readString(2),this.date=g.readDate(),this.crc32=g.readInt(4),this.compressedSize=g.readInt(4),this.uncompressedSize=g.readInt(4);var m=g.readInt(2);if(this.extraFieldsLength=g.readInt(2),this.fileCommentLength=g.readInt(2),this.diskNumberStart=g.readInt(2),this.internalFileAttributes=g.readInt(2),this.externalFileAttributes=g.readInt(4),this.localHeaderOffset=g.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");g.skip(m),this.readExtraFields(g),this.parseZIP64ExtraField(g),this.fileComment=g.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var g=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),g==0&&(this.dosPermissions=63&this.externalFileAttributes),g==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var g=i(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=g.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=g.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=g.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=g.readInt(4))}},readExtraFields:function(g){var m,v,C,w=g.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});g.index+4<w;)m=g.readInt(2),v=g.readInt(2),C=g.readData(v),this.extraFields[m]={id:m,length:v,value:C};g.setIndex(w)},handleUTF8:function(){var g=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var m=this.findExtraFieldUnicodePath();if(m!==null)this.fileNameStr=m;else{var v=s.transformTo(g,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(v)}var C=this.findExtraFieldUnicodeComment();if(C!==null)this.fileCommentStr=C;else{var w=s.transformTo(g,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(w)}}},findExtraFieldUnicodePath:function(){var g=this.extraFields[28789];if(g){var m=i(g.value);return m.readInt(1)!==1||l(this.fileName)!==m.readInt(4)?null:u.utf8decode(m.readData(g.length-5))}return null},findExtraFieldUnicodeComment:function(){var g=this.extraFields[25461];if(g){var m=i(g.value);return m.readInt(1)!==1||l(this.fileComment)!==m.readInt(4)?null:u.utf8decode(m.readData(g.length-5))}return null}},r.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,o){"use strict";function i(m,v,C){this.name=m,this.dir=C.dir,this.date=C.date,this.comment=C.comment,this.unixPermissions=C.unixPermissions,this.dosPermissions=C.dosPermissions,this._data=v,this._dataBinary=C.binary,this.options={compression:C.compression,compressionOptions:C.compressionOptions}}var s=n("./stream/StreamHelper"),a=n("./stream/DataWorker"),l=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");i.prototype={internalStream:function(m){var v=null,C="string";try{if(!m)throw new Error("No output type specified.");var w=(C=m.toLowerCase())==="string"||C==="text";C!=="binarystring"&&C!=="text"||(C="string"),v=this._decompressWorker();var S=!this._dataBinary;S&&!w&&(v=v.pipe(new l.Utf8EncodeWorker)),!S&&w&&(v=v.pipe(new l.Utf8DecodeWorker))}catch(b){(v=new d("error")).error(b)}return new s(v,C,"")},async:function(m,v){return this.internalStream(m).accumulate(v)},nodeStream:function(m,v){return this.internalStream(m||"nodebuffer").toNodejsStream(v)},_compressWorker:function(m,v){if(this._data instanceof u&&this._data.compression.magic===m.magic)return this._data.getCompressedWorker();var C=this._decompressWorker();return this._dataBinary||(C=C.pipe(new l.Utf8EncodeWorker)),u.createWorkerFrom(C,m,v)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new a(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},g=0;g<f.length;g++)i.prototype[f[g]]=p;r.exports=i},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,o){(function(i){"use strict";var s,a,l=i.MutationObserver||i.WebKitMutationObserver;if(l){var u=0,d=new l(m),f=i.document.createTextNode("");d.observe(f,{characterData:!0}),s=function(){f.data=u=++u%2}}else if(i.setImmediate||i.MessageChannel===void 0)s="document"in i&&"onreadystatechange"in i.document.createElement("script")?function(){var v=i.document.createElement("script");v.onreadystatechange=function(){m(),v.onreadystatechange=null,v.parentNode.removeChild(v),v=null},i.document.documentElement.appendChild(v)}:function(){setTimeout(m,0)};else{var p=new i.MessageChannel;p.port1.onmessage=m,s=function(){p.port2.postMessage(0)}}var g=[];function m(){var v,C;a=!0;for(var w=g.length;w;){for(C=g,g=[],v=-1;++v<w;)C[v]();w=g.length}a=!1}r.exports=function(v){g.push(v)!==1||a||s()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,o){"use strict";var i=n("immediate");function s(){}var a={},l=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(w){if(typeof w!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,w!==s&&v(this,w)}function p(w,S,b){this.promise=w,typeof S=="function"&&(this.onFulfilled=S,this.callFulfilled=this.otherCallFulfilled),typeof b=="function"&&(this.onRejected=b,this.callRejected=this.otherCallRejected)}function g(w,S,b){i(function(){var k;try{k=S(b)}catch(x){return a.reject(w,x)}k===w?a.reject(w,new TypeError("Cannot resolve promise with itself")):a.resolve(w,k)})}function m(w){var S=w&&w.then;if(w&&(typeof w=="object"||typeof w=="function")&&typeof S=="function")return function(){S.apply(w,arguments)}}function v(w,S){var b=!1;function k(z){b||(b=!0,a.reject(w,z))}function x(z){b||(b=!0,a.resolve(w,z))}var M=C(function(){S(x,k)});M.status==="error"&&k(M.value)}function C(w,S){var b={};try{b.value=w(S),b.status="success"}catch(k){b.status="error",b.value=k}return b}(r.exports=f).prototype.finally=function(w){if(typeof w!="function")return this;var S=this.constructor;return this.then(function(b){return S.resolve(w()).then(function(){return b})},function(b){return S.resolve(w()).then(function(){throw b})})},f.prototype.catch=function(w){return this.then(null,w)},f.prototype.then=function(w,S){if(typeof w!="function"&&this.state===u||typeof S!="function"&&this.state===l)return this;var b=new this.constructor(s);return this.state!==d?g(b,this.state===u?w:S,this.outcome):this.queue.push(new p(b,w,S)),b},p.prototype.callFulfilled=function(w){a.resolve(this.promise,w)},p.prototype.otherCallFulfilled=function(w){g(this.promise,this.onFulfilled,w)},p.prototype.callRejected=function(w){a.reject(this.promise,w)},p.prototype.otherCallRejected=function(w){g(this.promise,this.onRejected,w)},a.resolve=function(w,S){var b=C(m,S);if(b.status==="error")return a.reject(w,b.value);var k=b.value;if(k)v(w,k);else{w.state=u,w.outcome=S;for(var x=-1,M=w.queue.length;++x<M;)w.queue[x].callFulfilled(S)}return w},a.reject=function(w,S){w.state=l,w.outcome=S;for(var b=-1,k=w.queue.length;++b<k;)w.queue[b].callRejected(S);return w},f.resolve=function(w){return w instanceof this?w:a.resolve(new this(s),w)},f.reject=function(w){var S=new this(s);return a.reject(S,w)},f.all=function(w){var S=this;if(Object.prototype.toString.call(w)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=w.length,k=!1;if(!b)return this.resolve([]);for(var x=new Array(b),M=0,z=-1,G=new this(s);++z<b;)F(w[z],z);return G;function F(L,$){S.resolve(L).then(function(T){x[$]=T,++M!==b||k||(k=!0,a.resolve(G,x))},function(T){k||(k=!0,a.reject(G,T))})}},f.race=function(w){var S=this;if(Object.prototype.toString.call(w)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=w.length,k=!1;if(!b)return this.resolve([]);for(var x=-1,M=new this(s);++x<b;)z=w[x],S.resolve(z).then(function(G){k||(k=!0,a.resolve(M,G))},function(G){k||(k=!0,a.reject(M,G))});var z;return M}},{immediate:36}],38:[function(n,r,o){"use strict";var i={};(0,n("./lib/utils/common").assign)(i,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=i},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,o){"use strict";var i=n("./zlib/deflate"),s=n("./utils/common"),a=n("./utils/strings"),l=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,f=0,p=-1,g=0,m=8;function v(w){if(!(this instanceof v))return new v(w);this.options=s.assign({level:p,method:m,chunkSize:16384,windowBits:15,memLevel:8,strategy:g,to:""},w||{});var S=this.options;S.raw&&0<S.windowBits?S.windowBits=-S.windowBits:S.gzip&&0<S.windowBits&&S.windowBits<16&&(S.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var b=i.deflateInit2(this.strm,S.level,S.method,S.windowBits,S.memLevel,S.strategy);if(b!==f)throw new Error(l[b]);if(S.header&&i.deflateSetHeader(this.strm,S.header),S.dictionary){var k;if(k=typeof S.dictionary=="string"?a.string2buf(S.dictionary):d.call(S.dictionary)==="[object ArrayBuffer]"?new Uint8Array(S.dictionary):S.dictionary,(b=i.deflateSetDictionary(this.strm,k))!==f)throw new Error(l[b]);this._dict_set=!0}}function C(w,S){var b=new v(S);if(b.push(w,!0),b.err)throw b.msg||l[b.err];return b.result}v.prototype.push=function(w,S){var b,k,x=this.strm,M=this.options.chunkSize;if(this.ended)return!1;k=S===~~S?S:S===!0?4:0,typeof w=="string"?x.input=a.string2buf(w):d.call(w)==="[object ArrayBuffer]"?x.input=new Uint8Array(w):x.input=w,x.next_in=0,x.avail_in=x.input.length;do{if(x.avail_out===0&&(x.output=new s.Buf8(M),x.next_out=0,x.avail_out=M),(b=i.deflate(x,k))!==1&&b!==f)return this.onEnd(b),!(this.ended=!0);x.avail_out!==0&&(x.avail_in!==0||k!==4&&k!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(s.shrinkBuf(x.output,x.next_out))):this.onData(s.shrinkBuf(x.output,x.next_out)))}while((0<x.avail_in||x.avail_out===0)&&b!==1);return k===4?(b=i.deflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===f):k!==2||(this.onEnd(f),!(x.avail_out=0))},v.prototype.onData=function(w){this.chunks.push(w)},v.prototype.onEnd=function(w){w===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=w,this.msg=this.strm.msg},o.Deflate=v,o.deflate=C,o.deflateRaw=function(w,S){return(S=S||{}).raw=!0,C(w,S)},o.gzip=function(w,S){return(S=S||{}).gzip=!0,C(w,S)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,o){"use strict";var i=n("./zlib/inflate"),s=n("./utils/common"),a=n("./utils/strings"),l=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),f=n("./zlib/gzheader"),p=Object.prototype.toString;function g(v){if(!(this instanceof g))return new g(v);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},v||{});var C=this.options;C.raw&&0<=C.windowBits&&C.windowBits<16&&(C.windowBits=-C.windowBits,C.windowBits===0&&(C.windowBits=-15)),!(0<=C.windowBits&&C.windowBits<16)||v&&v.windowBits||(C.windowBits+=32),15<C.windowBits&&C.windowBits<48&&(15&C.windowBits)==0&&(C.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var w=i.inflateInit2(this.strm,C.windowBits);if(w!==l.Z_OK)throw new Error(u[w]);this.header=new f,i.inflateGetHeader(this.strm,this.header)}function m(v,C){var w=new g(C);if(w.push(v,!0),w.err)throw w.msg||u[w.err];return w.result}g.prototype.push=function(v,C){var w,S,b,k,x,M,z=this.strm,G=this.options.chunkSize,F=this.options.dictionary,L=!1;if(this.ended)return!1;S=C===~~C?C:C===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof v=="string"?z.input=a.binstring2buf(v):p.call(v)==="[object ArrayBuffer]"?z.input=new Uint8Array(v):z.input=v,z.next_in=0,z.avail_in=z.input.length;do{if(z.avail_out===0&&(z.output=new s.Buf8(G),z.next_out=0,z.avail_out=G),(w=i.inflate(z,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&F&&(M=typeof F=="string"?a.string2buf(F):p.call(F)==="[object ArrayBuffer]"?new Uint8Array(F):F,w=i.inflateSetDictionary(this.strm,M)),w===l.Z_BUF_ERROR&&L===!0&&(w=l.Z_OK,L=!1),w!==l.Z_STREAM_END&&w!==l.Z_OK)return this.onEnd(w),!(this.ended=!0);z.next_out&&(z.avail_out!==0&&w!==l.Z_STREAM_END&&(z.avail_in!==0||S!==l.Z_FINISH&&S!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(b=a.utf8border(z.output,z.next_out),k=z.next_out-b,x=a.buf2string(z.output,b),z.next_out=k,z.avail_out=G-k,k&&s.arraySet(z.output,z.output,b,k,0),this.onData(x)):this.onData(s.shrinkBuf(z.output,z.next_out)))),z.avail_in===0&&z.avail_out===0&&(L=!0)}while((0<z.avail_in||z.avail_out===0)&&w!==l.Z_STREAM_END);return w===l.Z_STREAM_END&&(S=l.Z_FINISH),S===l.Z_FINISH?(w=i.inflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===l.Z_OK):S!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(z.avail_out=0))},g.prototype.onData=function(v){this.chunks.push(v)},g.prototype.onEnd=function(v){v===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},o.Inflate=g,o.inflate=m,o.inflateRaw=function(v,C){return(C=C||{}).raw=!0,m(v,C)},o.ungzip=m},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,o){"use strict";var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";o.assign=function(l){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(l[f]=d[f])}}return l},o.shrinkBuf=function(l,u){return l.length===u?l:l.subarray?l.subarray(0,u):(l.length=u,l)};var s={arraySet:function(l,u,d,f,p){if(u.subarray&&l.subarray)l.set(u.subarray(d,d+f),p);else for(var g=0;g<f;g++)l[p+g]=u[d+g]},flattenChunks:function(l){var u,d,f,p,g,m;for(u=f=0,d=l.length;u<d;u++)f+=l[u].length;for(m=new Uint8Array(f),u=p=0,d=l.length;u<d;u++)g=l[u],m.set(g,p),p+=g.length;return m}},a={arraySet:function(l,u,d,f,p){for(var g=0;g<f;g++)l[p+g]=u[d+g]},flattenChunks:function(l){return[].concat.apply([],l)}};o.setTyped=function(l){l?(o.Buf8=Uint8Array,o.Buf16=Uint16Array,o.Buf32=Int32Array,o.assign(o,s)):(o.Buf8=Array,o.Buf16=Array,o.Buf32=Array,o.assign(o,a))},o.setTyped(i)},{}],42:[function(n,r,o){"use strict";var i=n("./common"),s=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var l=new i.Buf8(256),u=0;u<256;u++)l[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(f,p){if(p<65537&&(f.subarray&&a||!f.subarray&&s))return String.fromCharCode.apply(null,i.shrinkBuf(f,p));for(var g="",m=0;m<p;m++)g+=String.fromCharCode(f[m]);return g}l[254]=l[254]=1,o.string2buf=function(f){var p,g,m,v,C,w=f.length,S=0;for(v=0;v<w;v++)(64512&(g=f.charCodeAt(v)))==55296&&v+1<w&&(64512&(m=f.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(m-56320),v++),S+=g<128?1:g<2048?2:g<65536?3:4;for(p=new i.Buf8(S),v=C=0;C<S;v++)(64512&(g=f.charCodeAt(v)))==55296&&v+1<w&&(64512&(m=f.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(m-56320),v++),g<128?p[C++]=g:(g<2048?p[C++]=192|g>>>6:(g<65536?p[C++]=224|g>>>12:(p[C++]=240|g>>>18,p[C++]=128|g>>>12&63),p[C++]=128|g>>>6&63),p[C++]=128|63&g);return p},o.buf2binstring=function(f){return d(f,f.length)},o.binstring2buf=function(f){for(var p=new i.Buf8(f.length),g=0,m=p.length;g<m;g++)p[g]=f.charCodeAt(g);return p},o.buf2string=function(f,p){var g,m,v,C,w=p||f.length,S=new Array(2*w);for(g=m=0;g<w;)if((v=f[g++])<128)S[m++]=v;else if(4<(C=l[v]))S[m++]=65533,g+=C-1;else{for(v&=C===2?31:C===3?15:7;1<C&&g<w;)v=v<<6|63&f[g++],C--;1<C?S[m++]=65533:v<65536?S[m++]=v:(v-=65536,S[m++]=55296|v>>10&1023,S[m++]=56320|1023&v)}return d(S,m)},o.utf8border=function(f,p){var g;for((p=p||f.length)>f.length&&(p=f.length),g=p-1;0<=g&&(192&f[g])==128;)g--;return g<0||g===0?p:g+l[f[g]]>p?g:p}},{"./common":41}],43:[function(n,r,o){"use strict";r.exports=function(i,s,a,l){for(var u=65535&i|0,d=i>>>16&65535|0,f=0;a!==0;){for(a-=f=2e3<a?2e3:a;d=d+(u=u+s[l++]|0)|0,--f;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(n,r,o){"use strict";r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,o){"use strict";var i=(function(){for(var s,a=[],l=0;l<256;l++){s=l;for(var u=0;u<8;u++)s=1&s?3988292384^s>>>1:s>>>1;a[l]=s}return a})();r.exports=function(s,a,l,u){var d=i,f=u+l;s^=-1;for(var p=u;p<f;p++)s=s>>>8^d[255&(s^a[p])];return-1^s}},{}],46:[function(n,r,o){"use strict";var i,s=n("../utils/common"),a=n("./trees"),l=n("./adler32"),u=n("./crc32"),d=n("./messages"),f=0,p=4,g=0,m=-2,v=-1,C=4,w=2,S=8,b=9,k=286,x=30,M=19,z=2*k+1,G=15,F=3,L=258,$=L+F+1,T=42,H=113,R=1,U=2,W=3,ee=4;function J(I,re){return I.msg=d[re],re}function Z(I){return(I<<1)-(4<I?9:0)}function Me(I){for(var re=I.length;0<=--re;)I[re]=0}function fe(I){var re=I.state,j=re.pending;j>I.avail_out&&(j=I.avail_out),j!==0&&(s.arraySet(I.output,re.pending_buf,re.pending_out,j,I.next_out),I.next_out+=j,re.pending_out+=j,I.total_out+=j,I.avail_out-=j,re.pending-=j,re.pending===0&&(re.pending_out=0))}function ye(I,re){a._tr_flush_block(I,0<=I.block_start?I.block_start:-1,I.strstart-I.block_start,re),I.block_start=I.strstart,fe(I.strm)}function ve(I,re){I.pending_buf[I.pending++]=re}function Pe(I,re){I.pending_buf[I.pending++]=re>>>8&255,I.pending_buf[I.pending++]=255&re}function Ve(I,re){var j,X,K=I.max_chain_length,ae=I.strstart,ke=I.prev_length,P=I.nice_match,N=I.strstart>I.w_size-$?I.strstart-(I.w_size-$):0,me=I.window,Se=I.w_mask,Re=I.prev,ze=I.strstart+L,Ke=me[ae+ke-1],ot=me[ae+ke];I.prev_length>=I.good_match&&(K>>=2),P>I.lookahead&&(P=I.lookahead);do if(me[(j=re)+ke]===ot&&me[j+ke-1]===Ke&&me[j]===me[ae]&&me[++j]===me[ae+1]){ae+=2,j++;do;while(me[++ae]===me[++j]&&me[++ae]===me[++j]&&me[++ae]===me[++j]&&me[++ae]===me[++j]&&me[++ae]===me[++j]&&me[++ae]===me[++j]&&me[++ae]===me[++j]&&me[++ae]===me[++j]&&ae<ze);if(X=L-(ze-ae),ae=ze-L,ke<X){if(I.match_start=re,P<=(ke=X))break;Ke=me[ae+ke-1],ot=me[ae+ke]}}while((re=Re[re&Se])>N&&--K!=0);return ke<=I.lookahead?ke:I.lookahead}function nt(I){var re,j,X,K,ae,ke,P,N,me,Se,Re=I.w_size;do{if(K=I.window_size-I.lookahead-I.strstart,I.strstart>=Re+(Re-$)){for(s.arraySet(I.window,I.window,Re,Re,0),I.match_start-=Re,I.strstart-=Re,I.block_start-=Re,re=j=I.hash_size;X=I.head[--re],I.head[re]=Re<=X?X-Re:0,--j;);for(re=j=Re;X=I.prev[--re],I.prev[re]=Re<=X?X-Re:0,--j;);K+=Re}if(I.strm.avail_in===0)break;if(ke=I.strm,P=I.window,N=I.strstart+I.lookahead,me=K,Se=void 0,Se=ke.avail_in,me<Se&&(Se=me),j=Se===0?0:(ke.avail_in-=Se,s.arraySet(P,ke.input,ke.next_in,Se,N),ke.state.wrap===1?ke.adler=l(ke.adler,P,Se,N):ke.state.wrap===2&&(ke.adler=u(ke.adler,P,Se,N)),ke.next_in+=Se,ke.total_in+=Se,Se),I.lookahead+=j,I.lookahead+I.insert>=F)for(ae=I.strstart-I.insert,I.ins_h=I.window[ae],I.ins_h=(I.ins_h<<I.hash_shift^I.window[ae+1])&I.hash_mask;I.insert&&(I.ins_h=(I.ins_h<<I.hash_shift^I.window[ae+F-1])&I.hash_mask,I.prev[ae&I.w_mask]=I.head[I.ins_h],I.head[I.ins_h]=ae,ae++,I.insert--,!(I.lookahead+I.insert<F)););}while(I.lookahead<$&&I.strm.avail_in!==0)}function ct(I,re){for(var j,X;;){if(I.lookahead<$){if(nt(I),I.lookahead<$&&re===f)return R;if(I.lookahead===0)break}if(j=0,I.lookahead>=F&&(I.ins_h=(I.ins_h<<I.hash_shift^I.window[I.strstart+F-1])&I.hash_mask,j=I.prev[I.strstart&I.w_mask]=I.head[I.ins_h],I.head[I.ins_h]=I.strstart),j!==0&&I.strstart-j<=I.w_size-$&&(I.match_length=Ve(I,j)),I.match_length>=F)if(X=a._tr_tally(I,I.strstart-I.match_start,I.match_length-F),I.lookahead-=I.match_length,I.match_length<=I.max_lazy_match&&I.lookahead>=F){for(I.match_length--;I.strstart++,I.ins_h=(I.ins_h<<I.hash_shift^I.window[I.strstart+F-1])&I.hash_mask,j=I.prev[I.strstart&I.w_mask]=I.head[I.ins_h],I.head[I.ins_h]=I.strstart,--I.match_length!=0;);I.strstart++}else I.strstart+=I.match_length,I.match_length=0,I.ins_h=I.window[I.strstart],I.ins_h=(I.ins_h<<I.hash_shift^I.window[I.strstart+1])&I.hash_mask;else X=a._tr_tally(I,0,I.window[I.strstart]),I.lookahead--,I.strstart++;if(X&&(ye(I,!1),I.strm.avail_out===0))return R}return I.insert=I.strstart<F-1?I.strstart:F-1,re===p?(ye(I,!0),I.strm.avail_out===0?W:ee):I.last_lit&&(ye(I,!1),I.strm.avail_out===0)?R:U}function ft(I,re){for(var j,X,K;;){if(I.lookahead<$){if(nt(I),I.lookahead<$&&re===f)return R;if(I.lookahead===0)break}if(j=0,I.lookahead>=F&&(I.ins_h=(I.ins_h<<I.hash_shift^I.window[I.strstart+F-1])&I.hash_mask,j=I.prev[I.strstart&I.w_mask]=I.head[I.ins_h],I.head[I.ins_h]=I.strstart),I.prev_length=I.match_length,I.prev_match=I.match_start,I.match_length=F-1,j!==0&&I.prev_length<I.max_lazy_match&&I.strstart-j<=I.w_size-$&&(I.match_length=Ve(I,j),I.match_length<=5&&(I.strategy===1||I.match_length===F&&4096<I.strstart-I.match_start)&&(I.match_length=F-1)),I.prev_length>=F&&I.match_length<=I.prev_length){for(K=I.strstart+I.lookahead-F,X=a._tr_tally(I,I.strstart-1-I.prev_match,I.prev_length-F),I.lookahead-=I.prev_length-1,I.prev_length-=2;++I.strstart<=K&&(I.ins_h=(I.ins_h<<I.hash_shift^I.window[I.strstart+F-1])&I.hash_mask,j=I.prev[I.strstart&I.w_mask]=I.head[I.ins_h],I.head[I.ins_h]=I.strstart),--I.prev_length!=0;);if(I.match_available=0,I.match_length=F-1,I.strstart++,X&&(ye(I,!1),I.strm.avail_out===0))return R}else if(I.match_available){if((X=a._tr_tally(I,0,I.window[I.strstart-1]))&&ye(I,!1),I.strstart++,I.lookahead--,I.strm.avail_out===0)return R}else I.match_available=1,I.strstart++,I.lookahead--}return I.match_available&&(X=a._tr_tally(I,0,I.window[I.strstart-1]),I.match_available=0),I.insert=I.strstart<F-1?I.strstart:F-1,re===p?(ye(I,!0),I.strm.avail_out===0?W:ee):I.last_lit&&(ye(I,!1),I.strm.avail_out===0)?R:U}function It(I,re,j,X,K){this.good_length=I,this.max_lazy=re,this.nice_length=j,this.max_chain=X,this.func=K}function Le(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=S,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new s.Buf16(2*z),this.dyn_dtree=new s.Buf16(2*(2*x+1)),this.bl_tree=new s.Buf16(2*(2*M+1)),Me(this.dyn_ltree),Me(this.dyn_dtree),Me(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(G+1),this.heap=new s.Buf16(2*k+1),Me(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*k+1),Me(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function oe(I){var re;return I&&I.state?(I.total_in=I.total_out=0,I.data_type=w,(re=I.state).pending=0,re.pending_out=0,re.wrap<0&&(re.wrap=-re.wrap),re.status=re.wrap?T:H,I.adler=re.wrap===2?0:1,re.last_flush=f,a._tr_init(re),g):J(I,m)}function we(I){var re=oe(I);return re===g&&(function(j){j.window_size=2*j.w_size,Me(j.head),j.max_lazy_match=i[j.level].max_lazy,j.good_match=i[j.level].good_length,j.nice_match=i[j.level].nice_length,j.max_chain_length=i[j.level].max_chain,j.strstart=0,j.block_start=0,j.lookahead=0,j.insert=0,j.match_length=j.prev_length=F-1,j.match_available=0,j.ins_h=0})(I.state),re}function Q(I,re,j,X,K,ae){if(!I)return m;var ke=1;if(re===v&&(re=6),X<0?(ke=0,X=-X):15<X&&(ke=2,X-=16),K<1||b<K||j!==S||X<8||15<X||re<0||9<re||ae<0||C<ae)return J(I,m);X===8&&(X=9);var P=new Le;return(I.state=P).strm=I,P.wrap=ke,P.gzhead=null,P.w_bits=X,P.w_size=1<<P.w_bits,P.w_mask=P.w_size-1,P.hash_bits=K+7,P.hash_size=1<<P.hash_bits,P.hash_mask=P.hash_size-1,P.hash_shift=~~((P.hash_bits+F-1)/F),P.window=new s.Buf8(2*P.w_size),P.head=new s.Buf16(P.hash_size),P.prev=new s.Buf16(P.w_size),P.lit_bufsize=1<<K+6,P.pending_buf_size=4*P.lit_bufsize,P.pending_buf=new s.Buf8(P.pending_buf_size),P.d_buf=1*P.lit_bufsize,P.l_buf=3*P.lit_bufsize,P.level=re,P.strategy=ae,P.method=j,we(I)}i=[new It(0,0,0,0,function(I,re){var j=65535;for(j>I.pending_buf_size-5&&(j=I.pending_buf_size-5);;){if(I.lookahead<=1){if(nt(I),I.lookahead===0&&re===f)return R;if(I.lookahead===0)break}I.strstart+=I.lookahead,I.lookahead=0;var X=I.block_start+j;if((I.strstart===0||I.strstart>=X)&&(I.lookahead=I.strstart-X,I.strstart=X,ye(I,!1),I.strm.avail_out===0)||I.strstart-I.block_start>=I.w_size-$&&(ye(I,!1),I.strm.avail_out===0))return R}return I.insert=0,re===p?(ye(I,!0),I.strm.avail_out===0?W:ee):(I.strstart>I.block_start&&(ye(I,!1),I.strm.avail_out),R)}),new It(4,4,8,4,ct),new It(4,5,16,8,ct),new It(4,6,32,32,ct),new It(4,4,16,16,ft),new It(8,16,32,32,ft),new It(8,16,128,128,ft),new It(8,32,128,256,ft),new It(32,128,258,1024,ft),new It(32,258,258,4096,ft)],o.deflateInit=function(I,re){return Q(I,re,S,15,8,0)},o.deflateInit2=Q,o.deflateReset=we,o.deflateResetKeep=oe,o.deflateSetHeader=function(I,re){return I&&I.state?I.state.wrap!==2?m:(I.state.gzhead=re,g):m},o.deflate=function(I,re){var j,X,K,ae;if(!I||!I.state||5<re||re<0)return I?J(I,m):m;if(X=I.state,!I.output||!I.input&&I.avail_in!==0||X.status===666&&re!==p)return J(I,I.avail_out===0?-5:m);if(X.strm=I,j=X.last_flush,X.last_flush=re,X.status===T)if(X.wrap===2)I.adler=0,ve(X,31),ve(X,139),ve(X,8),X.gzhead?(ve(X,(X.gzhead.text?1:0)+(X.gzhead.hcrc?2:0)+(X.gzhead.extra?4:0)+(X.gzhead.name?8:0)+(X.gzhead.comment?16:0)),ve(X,255&X.gzhead.time),ve(X,X.gzhead.time>>8&255),ve(X,X.gzhead.time>>16&255),ve(X,X.gzhead.time>>24&255),ve(X,X.level===9?2:2<=X.strategy||X.level<2?4:0),ve(X,255&X.gzhead.os),X.gzhead.extra&&X.gzhead.extra.length&&(ve(X,255&X.gzhead.extra.length),ve(X,X.gzhead.extra.length>>8&255)),X.gzhead.hcrc&&(I.adler=u(I.adler,X.pending_buf,X.pending,0)),X.gzindex=0,X.status=69):(ve(X,0),ve(X,0),ve(X,0),ve(X,0),ve(X,0),ve(X,X.level===9?2:2<=X.strategy||X.level<2?4:0),ve(X,3),X.status=H);else{var ke=S+(X.w_bits-8<<4)<<8;ke|=(2<=X.strategy||X.level<2?0:X.level<6?1:X.level===6?2:3)<<6,X.strstart!==0&&(ke|=32),ke+=31-ke%31,X.status=H,Pe(X,ke),X.strstart!==0&&(Pe(X,I.adler>>>16),Pe(X,65535&I.adler)),I.adler=1}if(X.status===69)if(X.gzhead.extra){for(K=X.pending;X.gzindex<(65535&X.gzhead.extra.length)&&(X.pending!==X.pending_buf_size||(X.gzhead.hcrc&&X.pending>K&&(I.adler=u(I.adler,X.pending_buf,X.pending-K,K)),fe(I),K=X.pending,X.pending!==X.pending_buf_size));)ve(X,255&X.gzhead.extra[X.gzindex]),X.gzindex++;X.gzhead.hcrc&&X.pending>K&&(I.adler=u(I.adler,X.pending_buf,X.pending-K,K)),X.gzindex===X.gzhead.extra.length&&(X.gzindex=0,X.status=73)}else X.status=73;if(X.status===73)if(X.gzhead.name){K=X.pending;do{if(X.pending===X.pending_buf_size&&(X.gzhead.hcrc&&X.pending>K&&(I.adler=u(I.adler,X.pending_buf,X.pending-K,K)),fe(I),K=X.pending,X.pending===X.pending_buf_size)){ae=1;break}ae=X.gzindex<X.gzhead.name.length?255&X.gzhead.name.charCodeAt(X.gzindex++):0,ve(X,ae)}while(ae!==0);X.gzhead.hcrc&&X.pending>K&&(I.adler=u(I.adler,X.pending_buf,X.pending-K,K)),ae===0&&(X.gzindex=0,X.status=91)}else X.status=91;if(X.status===91)if(X.gzhead.comment){K=X.pending;do{if(X.pending===X.pending_buf_size&&(X.gzhead.hcrc&&X.pending>K&&(I.adler=u(I.adler,X.pending_buf,X.pending-K,K)),fe(I),K=X.pending,X.pending===X.pending_buf_size)){ae=1;break}ae=X.gzindex<X.gzhead.comment.length?255&X.gzhead.comment.charCodeAt(X.gzindex++):0,ve(X,ae)}while(ae!==0);X.gzhead.hcrc&&X.pending>K&&(I.adler=u(I.adler,X.pending_buf,X.pending-K,K)),ae===0&&(X.status=103)}else X.status=103;if(X.status===103&&(X.gzhead.hcrc?(X.pending+2>X.pending_buf_size&&fe(I),X.pending+2<=X.pending_buf_size&&(ve(X,255&I.adler),ve(X,I.adler>>8&255),I.adler=0,X.status=H)):X.status=H),X.pending!==0){if(fe(I),I.avail_out===0)return X.last_flush=-1,g}else if(I.avail_in===0&&Z(re)<=Z(j)&&re!==p)return J(I,-5);if(X.status===666&&I.avail_in!==0)return J(I,-5);if(I.avail_in!==0||X.lookahead!==0||re!==f&&X.status!==666){var P=X.strategy===2?(function(N,me){for(var Se;;){if(N.lookahead===0&&(nt(N),N.lookahead===0)){if(me===f)return R;break}if(N.match_length=0,Se=a._tr_tally(N,0,N.window[N.strstart]),N.lookahead--,N.strstart++,Se&&(ye(N,!1),N.strm.avail_out===0))return R}return N.insert=0,me===p?(ye(N,!0),N.strm.avail_out===0?W:ee):N.last_lit&&(ye(N,!1),N.strm.avail_out===0)?R:U})(X,re):X.strategy===3?(function(N,me){for(var Se,Re,ze,Ke,ot=N.window;;){if(N.lookahead<=L){if(nt(N),N.lookahead<=L&&me===f)return R;if(N.lookahead===0)break}if(N.match_length=0,N.lookahead>=F&&0<N.strstart&&(Re=ot[ze=N.strstart-1])===ot[++ze]&&Re===ot[++ze]&&Re===ot[++ze]){Ke=N.strstart+L;do;while(Re===ot[++ze]&&Re===ot[++ze]&&Re===ot[++ze]&&Re===ot[++ze]&&Re===ot[++ze]&&Re===ot[++ze]&&Re===ot[++ze]&&Re===ot[++ze]&&ze<Ke);N.match_length=L-(Ke-ze),N.match_length>N.lookahead&&(N.match_length=N.lookahead)}if(N.match_length>=F?(Se=a._tr_tally(N,1,N.match_length-F),N.lookahead-=N.match_length,N.strstart+=N.match_length,N.match_length=0):(Se=a._tr_tally(N,0,N.window[N.strstart]),N.lookahead--,N.strstart++),Se&&(ye(N,!1),N.strm.avail_out===0))return R}return N.insert=0,me===p?(ye(N,!0),N.strm.avail_out===0?W:ee):N.last_lit&&(ye(N,!1),N.strm.avail_out===0)?R:U})(X,re):i[X.level].func(X,re);if(P!==W&&P!==ee||(X.status=666),P===R||P===W)return I.avail_out===0&&(X.last_flush=-1),g;if(P===U&&(re===1?a._tr_align(X):re!==5&&(a._tr_stored_block(X,0,0,!1),re===3&&(Me(X.head),X.lookahead===0&&(X.strstart=0,X.block_start=0,X.insert=0))),fe(I),I.avail_out===0))return X.last_flush=-1,g}return re!==p?g:X.wrap<=0?1:(X.wrap===2?(ve(X,255&I.adler),ve(X,I.adler>>8&255),ve(X,I.adler>>16&255),ve(X,I.adler>>24&255),ve(X,255&I.total_in),ve(X,I.total_in>>8&255),ve(X,I.total_in>>16&255),ve(X,I.total_in>>24&255)):(Pe(X,I.adler>>>16),Pe(X,65535&I.adler)),fe(I),0<X.wrap&&(X.wrap=-X.wrap),X.pending!==0?g:1)},o.deflateEnd=function(I){var re;return I&&I.state?(re=I.state.status)!==T&&re!==69&&re!==73&&re!==91&&re!==103&&re!==H&&re!==666?J(I,m):(I.state=null,re===H?J(I,-3):g):m},o.deflateSetDictionary=function(I,re){var j,X,K,ae,ke,P,N,me,Se=re.length;if(!I||!I.state||(ae=(j=I.state).wrap)===2||ae===1&&j.status!==T||j.lookahead)return m;for(ae===1&&(I.adler=l(I.adler,re,Se,0)),j.wrap=0,Se>=j.w_size&&(ae===0&&(Me(j.head),j.strstart=0,j.block_start=0,j.insert=0),me=new s.Buf8(j.w_size),s.arraySet(me,re,Se-j.w_size,j.w_size,0),re=me,Se=j.w_size),ke=I.avail_in,P=I.next_in,N=I.input,I.avail_in=Se,I.next_in=0,I.input=re,nt(j);j.lookahead>=F;){for(X=j.strstart,K=j.lookahead-(F-1);j.ins_h=(j.ins_h<<j.hash_shift^j.window[X+F-1])&j.hash_mask,j.prev[X&j.w_mask]=j.head[j.ins_h],j.head[j.ins_h]=X,X++,--K;);j.strstart=X,j.lookahead=F-1,nt(j)}return j.strstart+=j.lookahead,j.block_start=j.strstart,j.insert=j.lookahead,j.lookahead=0,j.match_length=j.prev_length=F-1,j.match_available=0,I.next_in=P,I.input=N,I.avail_in=ke,j.wrap=ae,g},o.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,o){"use strict";r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,o){"use strict";r.exports=function(i,s){var a=i.state,l=i.next_in,u,d,f,p,g,m,v,C,w,S,b,k,x,M,z,G,F,L,$,T,H,R=i.input,U;u=l+(i.avail_in-5),d=i.next_out,U=i.output,f=d-(s-i.avail_out),p=d+(i.avail_out-257),g=a.dmax,m=a.wsize,v=a.whave,C=a.wnext,w=a.window,S=a.hold,b=a.bits,k=a.lencode,x=a.distcode,M=(1<<a.lenbits)-1,z=(1<<a.distbits)-1;e:do{b<15&&(S+=R[l++]<<b,b+=8,S+=R[l++]<<b,b+=8),G=k[S&M];t:for(;;){if(S>>>=F=G>>>24,b-=F,(F=G>>>16&255)===0)U[d++]=65535&G;else{if(!(16&F)){if((64&F)==0){G=k[(65535&G)+(S&(1<<F)-1)];continue t}if(32&F){a.mode=12;break e}i.msg="invalid literal/length code",a.mode=30;break e}L=65535&G,(F&=15)&&(b<F&&(S+=R[l++]<<b,b+=8),L+=S&(1<<F)-1,S>>>=F,b-=F),b<15&&(S+=R[l++]<<b,b+=8,S+=R[l++]<<b,b+=8),G=x[S&z];n:for(;;){if(S>>>=F=G>>>24,b-=F,!(16&(F=G>>>16&255))){if((64&F)==0){G=x[(65535&G)+(S&(1<<F)-1)];continue n}i.msg="invalid distance code",a.mode=30;break e}if($=65535&G,b<(F&=15)&&(S+=R[l++]<<b,(b+=8)<F&&(S+=R[l++]<<b,b+=8)),g<($+=S&(1<<F)-1)){i.msg="invalid distance too far back",a.mode=30;break e}if(S>>>=F,b-=F,(F=d-f)<$){if(v<(F=$-F)&&a.sane){i.msg="invalid distance too far back",a.mode=30;break e}if(H=w,(T=0)===C){if(T+=m-F,F<L){for(L-=F;U[d++]=w[T++],--F;);T=d-$,H=U}}else if(C<F){if(T+=m+C-F,(F-=C)<L){for(L-=F;U[d++]=w[T++],--F;);if(T=0,C<L){for(L-=F=C;U[d++]=w[T++],--F;);T=d-$,H=U}}}else if(T+=C-F,F<L){for(L-=F;U[d++]=w[T++],--F;);T=d-$,H=U}for(;2<L;)U[d++]=H[T++],U[d++]=H[T++],U[d++]=H[T++],L-=3;L&&(U[d++]=H[T++],1<L&&(U[d++]=H[T++]))}else{for(T=d-$;U[d++]=U[T++],U[d++]=U[T++],U[d++]=U[T++],2<(L-=3););L&&(U[d++]=U[T++],1<L&&(U[d++]=U[T++]))}break}}break}}while(l<u&&d<p);l-=L=b>>3,S&=(1<<(b-=L<<3))-1,i.next_in=l,i.next_out=d,i.avail_in=l<u?u-l+5:5-(l-u),i.avail_out=d<p?p-d+257:257-(d-p),a.hold=S,a.bits=b}},{}],49:[function(n,r,o){"use strict";var i=n("../utils/common"),s=n("./adler32"),a=n("./crc32"),l=n("./inffast"),u=n("./inftrees"),d=1,f=2,p=0,g=-2,m=1,v=852,C=592;function w(T){return(T>>>24&255)+(T>>>8&65280)+((65280&T)<<8)+((255&T)<<24)}function S(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function b(T){var H;return T&&T.state?(H=T.state,T.total_in=T.total_out=H.total=0,T.msg="",H.wrap&&(T.adler=1&H.wrap),H.mode=m,H.last=0,H.havedict=0,H.dmax=32768,H.head=null,H.hold=0,H.bits=0,H.lencode=H.lendyn=new i.Buf32(v),H.distcode=H.distdyn=new i.Buf32(C),H.sane=1,H.back=-1,p):g}function k(T){var H;return T&&T.state?((H=T.state).wsize=0,H.whave=0,H.wnext=0,b(T)):g}function x(T,H){var R,U;return T&&T.state?(U=T.state,H<0?(R=0,H=-H):(R=1+(H>>4),H<48&&(H&=15)),H&&(H<8||15<H)?g:(U.window!==null&&U.wbits!==H&&(U.window=null),U.wrap=R,U.wbits=H,k(T))):g}function M(T,H){var R,U;return T?(U=new S,(T.state=U).window=null,(R=x(T,H))!==p&&(T.state=null),R):g}var z,G,F=!0;function L(T){if(F){var H;for(z=new i.Buf32(512),G=new i.Buf32(32),H=0;H<144;)T.lens[H++]=8;for(;H<256;)T.lens[H++]=9;for(;H<280;)T.lens[H++]=7;for(;H<288;)T.lens[H++]=8;for(u(d,T.lens,0,288,z,0,T.work,{bits:9}),H=0;H<32;)T.lens[H++]=5;u(f,T.lens,0,32,G,0,T.work,{bits:5}),F=!1}T.lencode=z,T.lenbits=9,T.distcode=G,T.distbits=5}function $(T,H,R,U){var W,ee=T.state;return ee.window===null&&(ee.wsize=1<<ee.wbits,ee.wnext=0,ee.whave=0,ee.window=new i.Buf8(ee.wsize)),U>=ee.wsize?(i.arraySet(ee.window,H,R-ee.wsize,ee.wsize,0),ee.wnext=0,ee.whave=ee.wsize):(U<(W=ee.wsize-ee.wnext)&&(W=U),i.arraySet(ee.window,H,R-U,W,ee.wnext),(U-=W)?(i.arraySet(ee.window,H,R-U,U,0),ee.wnext=U,ee.whave=ee.wsize):(ee.wnext+=W,ee.wnext===ee.wsize&&(ee.wnext=0),ee.whave<ee.wsize&&(ee.whave+=W))),0}o.inflateReset=k,o.inflateReset2=x,o.inflateResetKeep=b,o.inflateInit=function(T){return M(T,15)},o.inflateInit2=M,o.inflate=function(T,H){var R,U,W,ee,J,Z,Me,fe,ye,ve,Pe,Ve,nt,ct,ft,It,Le,oe,we,Q,I,re,j,X,K=0,ae=new i.Buf8(4),ke=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!T||!T.state||!T.output||!T.input&&T.avail_in!==0)return g;(R=T.state).mode===12&&(R.mode=13),J=T.next_out,W=T.output,Me=T.avail_out,ee=T.next_in,U=T.input,Z=T.avail_in,fe=R.hold,ye=R.bits,ve=Z,Pe=Me,re=p;e:for(;;)switch(R.mode){case m:if(R.wrap===0){R.mode=13;break}for(;ye<16;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}if(2&R.wrap&&fe===35615){ae[R.check=0]=255&fe,ae[1]=fe>>>8&255,R.check=a(R.check,ae,2,0),ye=fe=0,R.mode=2;break}if(R.flags=0,R.head&&(R.head.done=!1),!(1&R.wrap)||(((255&fe)<<8)+(fe>>8))%31){T.msg="incorrect header check",R.mode=30;break}if((15&fe)!=8){T.msg="unknown compression method",R.mode=30;break}if(ye-=4,I=8+(15&(fe>>>=4)),R.wbits===0)R.wbits=I;else if(I>R.wbits){T.msg="invalid window size",R.mode=30;break}R.dmax=1<<I,T.adler=R.check=1,R.mode=512&fe?10:12,ye=fe=0;break;case 2:for(;ye<16;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}if(R.flags=fe,(255&R.flags)!=8){T.msg="unknown compression method",R.mode=30;break}if(57344&R.flags){T.msg="unknown header flags set",R.mode=30;break}R.head&&(R.head.text=fe>>8&1),512&R.flags&&(ae[0]=255&fe,ae[1]=fe>>>8&255,R.check=a(R.check,ae,2,0)),ye=fe=0,R.mode=3;case 3:for(;ye<32;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}R.head&&(R.head.time=fe),512&R.flags&&(ae[0]=255&fe,ae[1]=fe>>>8&255,ae[2]=fe>>>16&255,ae[3]=fe>>>24&255,R.check=a(R.check,ae,4,0)),ye=fe=0,R.mode=4;case 4:for(;ye<16;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}R.head&&(R.head.xflags=255&fe,R.head.os=fe>>8),512&R.flags&&(ae[0]=255&fe,ae[1]=fe>>>8&255,R.check=a(R.check,ae,2,0)),ye=fe=0,R.mode=5;case 5:if(1024&R.flags){for(;ye<16;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}R.length=fe,R.head&&(R.head.extra_len=fe),512&R.flags&&(ae[0]=255&fe,ae[1]=fe>>>8&255,R.check=a(R.check,ae,2,0)),ye=fe=0}else R.head&&(R.head.extra=null);R.mode=6;case 6:if(1024&R.flags&&(Z<(Ve=R.length)&&(Ve=Z),Ve&&(R.head&&(I=R.head.extra_len-R.length,R.head.extra||(R.head.extra=new Array(R.head.extra_len)),i.arraySet(R.head.extra,U,ee,Ve,I)),512&R.flags&&(R.check=a(R.check,U,Ve,ee)),Z-=Ve,ee+=Ve,R.length-=Ve),R.length))break e;R.length=0,R.mode=7;case 7:if(2048&R.flags){if(Z===0)break e;for(Ve=0;I=U[ee+Ve++],R.head&&I&&R.length<65536&&(R.head.name+=String.fromCharCode(I)),I&&Ve<Z;);if(512&R.flags&&(R.check=a(R.check,U,Ve,ee)),Z-=Ve,ee+=Ve,I)break e}else R.head&&(R.head.name=null);R.length=0,R.mode=8;case 8:if(4096&R.flags){if(Z===0)break e;for(Ve=0;I=U[ee+Ve++],R.head&&I&&R.length<65536&&(R.head.comment+=String.fromCharCode(I)),I&&Ve<Z;);if(512&R.flags&&(R.check=a(R.check,U,Ve,ee)),Z-=Ve,ee+=Ve,I)break e}else R.head&&(R.head.comment=null);R.mode=9;case 9:if(512&R.flags){for(;ye<16;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}if(fe!==(65535&R.check)){T.msg="header crc mismatch",R.mode=30;break}ye=fe=0}R.head&&(R.head.hcrc=R.flags>>9&1,R.head.done=!0),T.adler=R.check=0,R.mode=12;break;case 10:for(;ye<32;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}T.adler=R.check=w(fe),ye=fe=0,R.mode=11;case 11:if(R.havedict===0)return T.next_out=J,T.avail_out=Me,T.next_in=ee,T.avail_in=Z,R.hold=fe,R.bits=ye,2;T.adler=R.check=1,R.mode=12;case 12:if(H===5||H===6)break e;case 13:if(R.last){fe>>>=7&ye,ye-=7&ye,R.mode=27;break}for(;ye<3;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}switch(R.last=1&fe,ye-=1,3&(fe>>>=1)){case 0:R.mode=14;break;case 1:if(L(R),R.mode=20,H!==6)break;fe>>>=2,ye-=2;break e;case 2:R.mode=17;break;case 3:T.msg="invalid block type",R.mode=30}fe>>>=2,ye-=2;break;case 14:for(fe>>>=7&ye,ye-=7&ye;ye<32;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}if((65535&fe)!=(fe>>>16^65535)){T.msg="invalid stored block lengths",R.mode=30;break}if(R.length=65535&fe,ye=fe=0,R.mode=15,H===6)break e;case 15:R.mode=16;case 16:if(Ve=R.length){if(Z<Ve&&(Ve=Z),Me<Ve&&(Ve=Me),Ve===0)break e;i.arraySet(W,U,ee,Ve,J),Z-=Ve,ee+=Ve,Me-=Ve,J+=Ve,R.length-=Ve;break}R.mode=12;break;case 17:for(;ye<14;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}if(R.nlen=257+(31&fe),fe>>>=5,ye-=5,R.ndist=1+(31&fe),fe>>>=5,ye-=5,R.ncode=4+(15&fe),fe>>>=4,ye-=4,286<R.nlen||30<R.ndist){T.msg="too many length or distance symbols",R.mode=30;break}R.have=0,R.mode=18;case 18:for(;R.have<R.ncode;){for(;ye<3;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}R.lens[ke[R.have++]]=7&fe,fe>>>=3,ye-=3}for(;R.have<19;)R.lens[ke[R.have++]]=0;if(R.lencode=R.lendyn,R.lenbits=7,j={bits:R.lenbits},re=u(0,R.lens,0,19,R.lencode,0,R.work,j),R.lenbits=j.bits,re){T.msg="invalid code lengths set",R.mode=30;break}R.have=0,R.mode=19;case 19:for(;R.have<R.nlen+R.ndist;){for(;It=(K=R.lencode[fe&(1<<R.lenbits)-1])>>>16&255,Le=65535&K,!((ft=K>>>24)<=ye);){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}if(Le<16)fe>>>=ft,ye-=ft,R.lens[R.have++]=Le;else{if(Le===16){for(X=ft+2;ye<X;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}if(fe>>>=ft,ye-=ft,R.have===0){T.msg="invalid bit length repeat",R.mode=30;break}I=R.lens[R.have-1],Ve=3+(3&fe),fe>>>=2,ye-=2}else if(Le===17){for(X=ft+3;ye<X;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}ye-=ft,I=0,Ve=3+(7&(fe>>>=ft)),fe>>>=3,ye-=3}else{for(X=ft+7;ye<X;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}ye-=ft,I=0,Ve=11+(127&(fe>>>=ft)),fe>>>=7,ye-=7}if(R.have+Ve>R.nlen+R.ndist){T.msg="invalid bit length repeat",R.mode=30;break}for(;Ve--;)R.lens[R.have++]=I}}if(R.mode===30)break;if(R.lens[256]===0){T.msg="invalid code -- missing end-of-block",R.mode=30;break}if(R.lenbits=9,j={bits:R.lenbits},re=u(d,R.lens,0,R.nlen,R.lencode,0,R.work,j),R.lenbits=j.bits,re){T.msg="invalid literal/lengths set",R.mode=30;break}if(R.distbits=6,R.distcode=R.distdyn,j={bits:R.distbits},re=u(f,R.lens,R.nlen,R.ndist,R.distcode,0,R.work,j),R.distbits=j.bits,re){T.msg="invalid distances set",R.mode=30;break}if(R.mode=20,H===6)break e;case 20:R.mode=21;case 21:if(6<=Z&&258<=Me){T.next_out=J,T.avail_out=Me,T.next_in=ee,T.avail_in=Z,R.hold=fe,R.bits=ye,l(T,Pe),J=T.next_out,W=T.output,Me=T.avail_out,ee=T.next_in,U=T.input,Z=T.avail_in,fe=R.hold,ye=R.bits,R.mode===12&&(R.back=-1);break}for(R.back=0;It=(K=R.lencode[fe&(1<<R.lenbits)-1])>>>16&255,Le=65535&K,!((ft=K>>>24)<=ye);){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}if(It&&(240&It)==0){for(oe=ft,we=It,Q=Le;It=(K=R.lencode[Q+((fe&(1<<oe+we)-1)>>oe)])>>>16&255,Le=65535&K,!(oe+(ft=K>>>24)<=ye);){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}fe>>>=oe,ye-=oe,R.back+=oe}if(fe>>>=ft,ye-=ft,R.back+=ft,R.length=Le,It===0){R.mode=26;break}if(32&It){R.back=-1,R.mode=12;break}if(64&It){T.msg="invalid literal/length code",R.mode=30;break}R.extra=15&It,R.mode=22;case 22:if(R.extra){for(X=R.extra;ye<X;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}R.length+=fe&(1<<R.extra)-1,fe>>>=R.extra,ye-=R.extra,R.back+=R.extra}R.was=R.length,R.mode=23;case 23:for(;It=(K=R.distcode[fe&(1<<R.distbits)-1])>>>16&255,Le=65535&K,!((ft=K>>>24)<=ye);){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}if((240&It)==0){for(oe=ft,we=It,Q=Le;It=(K=R.distcode[Q+((fe&(1<<oe+we)-1)>>oe)])>>>16&255,Le=65535&K,!(oe+(ft=K>>>24)<=ye);){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}fe>>>=oe,ye-=oe,R.back+=oe}if(fe>>>=ft,ye-=ft,R.back+=ft,64&It){T.msg="invalid distance code",R.mode=30;break}R.offset=Le,R.extra=15&It,R.mode=24;case 24:if(R.extra){for(X=R.extra;ye<X;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}R.offset+=fe&(1<<R.extra)-1,fe>>>=R.extra,ye-=R.extra,R.back+=R.extra}if(R.offset>R.dmax){T.msg="invalid distance too far back",R.mode=30;break}R.mode=25;case 25:if(Me===0)break e;if(Ve=Pe-Me,R.offset>Ve){if((Ve=R.offset-Ve)>R.whave&&R.sane){T.msg="invalid distance too far back",R.mode=30;break}nt=Ve>R.wnext?(Ve-=R.wnext,R.wsize-Ve):R.wnext-Ve,Ve>R.length&&(Ve=R.length),ct=R.window}else ct=W,nt=J-R.offset,Ve=R.length;for(Me<Ve&&(Ve=Me),Me-=Ve,R.length-=Ve;W[J++]=ct[nt++],--Ve;);R.length===0&&(R.mode=21);break;case 26:if(Me===0)break e;W[J++]=R.length,Me--,R.mode=21;break;case 27:if(R.wrap){for(;ye<32;){if(Z===0)break e;Z--,fe|=U[ee++]<<ye,ye+=8}if(Pe-=Me,T.total_out+=Pe,R.total+=Pe,Pe&&(T.adler=R.check=R.flags?a(R.check,W,Pe,J-Pe):s(R.check,W,Pe,J-Pe)),Pe=Me,(R.flags?fe:w(fe))!==R.check){T.msg="incorrect data check",R.mode=30;break}ye=fe=0}R.mode=28;case 28:if(R.wrap&&R.flags){for(;ye<32;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}if(fe!==(4294967295&R.total)){T.msg="incorrect length check",R.mode=30;break}ye=fe=0}R.mode=29;case 29:re=1;break e;case 30:re=-3;break e;case 31:return-4;default:return g}return T.next_out=J,T.avail_out=Me,T.next_in=ee,T.avail_in=Z,R.hold=fe,R.bits=ye,(R.wsize||Pe!==T.avail_out&&R.mode<30&&(R.mode<27||H!==4))&&$(T,T.output,T.next_out,Pe-T.avail_out)?(R.mode=31,-4):(ve-=T.avail_in,Pe-=T.avail_out,T.total_in+=ve,T.total_out+=Pe,R.total+=Pe,R.wrap&&Pe&&(T.adler=R.check=R.flags?a(R.check,W,Pe,T.next_out-Pe):s(R.check,W,Pe,T.next_out-Pe)),T.data_type=R.bits+(R.last?64:0)+(R.mode===12?128:0)+(R.mode===20||R.mode===15?256:0),(ve==0&&Pe===0||H===4)&&re===p&&(re=-5),re)},o.inflateEnd=function(T){if(!T||!T.state)return g;var H=T.state;return H.window&&(H.window=null),T.state=null,p},o.inflateGetHeader=function(T,H){var R;return T&&T.state?(2&(R=T.state).wrap)==0?g:((R.head=H).done=!1,p):g},o.inflateSetDictionary=function(T,H){var R,U=H.length;return T&&T.state?(R=T.state).wrap!==0&&R.mode!==11?g:R.mode===11&&s(1,H,U,0)!==R.check?-3:$(T,H,U,U)?(R.mode=31,-4):(R.havedict=1,p):g},o.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,o){"use strict";var i=n("../utils/common"),s=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,f,p,g,m,v,C,w){var S,b,k,x,M,z,G,F,L,$=w.bits,T=0,H=0,R=0,U=0,W=0,ee=0,J=0,Z=0,Me=0,fe=0,ye=null,ve=0,Pe=new i.Buf16(16),Ve=new i.Buf16(16),nt=null,ct=0;for(T=0;T<=15;T++)Pe[T]=0;for(H=0;H<g;H++)Pe[f[p+H]]++;for(W=$,U=15;1<=U&&Pe[U]===0;U--);if(U<W&&(W=U),U===0)return m[v++]=20971520,m[v++]=20971520,w.bits=1,0;for(R=1;R<U&&Pe[R]===0;R++);for(W<R&&(W=R),T=Z=1;T<=15;T++)if(Z<<=1,(Z-=Pe[T])<0)return-1;if(0<Z&&(d===0||U!==1))return-1;for(Ve[1]=0,T=1;T<15;T++)Ve[T+1]=Ve[T]+Pe[T];for(H=0;H<g;H++)f[p+H]!==0&&(C[Ve[f[p+H]]++]=H);if(z=d===0?(ye=nt=C,19):d===1?(ye=s,ve-=257,nt=a,ct-=257,256):(ye=l,nt=u,-1),T=R,M=v,J=H=fe=0,k=-1,x=(Me=1<<(ee=W))-1,d===1&&852<Me||d===2&&592<Me)return 1;for(;;){for(G=T-J,L=C[H]<z?(F=0,C[H]):C[H]>z?(F=nt[ct+C[H]],ye[ve+C[H]]):(F=96,0),S=1<<T-J,R=b=1<<ee;m[M+(fe>>J)+(b-=S)]=G<<24|F<<16|L|0,b!==0;);for(S=1<<T-1;fe&S;)S>>=1;if(S!==0?(fe&=S-1,fe+=S):fe=0,H++,--Pe[T]==0){if(T===U)break;T=f[p+C[H]]}if(W<T&&(fe&x)!==k){for(J===0&&(J=W),M+=R,Z=1<<(ee=T-J);ee+J<U&&!((Z-=Pe[ee+J])<=0);)ee++,Z<<=1;if(Me+=1<<ee,d===1&&852<Me||d===2&&592<Me)return 1;m[k=fe&x]=W<<24|ee<<16|M-v|0}}return fe!==0&&(m[M+fe]=T-J<<24|4194304),w.bits=W,0}},{"../utils/common":41}],51:[function(n,r,o){"use strict";r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,o){"use strict";var i=n("../utils/common"),s=0,a=1;function l(K){for(var ae=K.length;0<=--ae;)K[ae]=0}var u=0,d=29,f=256,p=f+1+d,g=30,m=19,v=2*p+1,C=15,w=16,S=7,b=256,k=16,x=17,M=18,z=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],G=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],F=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],L=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],$=new Array(2*(p+2));l($);var T=new Array(2*g);l(T);var H=new Array(512);l(H);var R=new Array(256);l(R);var U=new Array(d);l(U);var W,ee,J,Z=new Array(g);function Me(K,ae,ke,P,N){this.static_tree=K,this.extra_bits=ae,this.extra_base=ke,this.elems=P,this.max_length=N,this.has_stree=K&&K.length}function fe(K,ae){this.dyn_tree=K,this.max_code=0,this.stat_desc=ae}function ye(K){return K<256?H[K]:H[256+(K>>>7)]}function ve(K,ae){K.pending_buf[K.pending++]=255&ae,K.pending_buf[K.pending++]=ae>>>8&255}function Pe(K,ae,ke){K.bi_valid>w-ke?(K.bi_buf|=ae<<K.bi_valid&65535,ve(K,K.bi_buf),K.bi_buf=ae>>w-K.bi_valid,K.bi_valid+=ke-w):(K.bi_buf|=ae<<K.bi_valid&65535,K.bi_valid+=ke)}function Ve(K,ae,ke){Pe(K,ke[2*ae],ke[2*ae+1])}function nt(K,ae){for(var ke=0;ke|=1&K,K>>>=1,ke<<=1,0<--ae;);return ke>>>1}function ct(K,ae,ke){var P,N,me=new Array(C+1),Se=0;for(P=1;P<=C;P++)me[P]=Se=Se+ke[P-1]<<1;for(N=0;N<=ae;N++){var Re=K[2*N+1];Re!==0&&(K[2*N]=nt(me[Re]++,Re))}}function ft(K){var ae;for(ae=0;ae<p;ae++)K.dyn_ltree[2*ae]=0;for(ae=0;ae<g;ae++)K.dyn_dtree[2*ae]=0;for(ae=0;ae<m;ae++)K.bl_tree[2*ae]=0;K.dyn_ltree[2*b]=1,K.opt_len=K.static_len=0,K.last_lit=K.matches=0}function It(K){8<K.bi_valid?ve(K,K.bi_buf):0<K.bi_valid&&(K.pending_buf[K.pending++]=K.bi_buf),K.bi_buf=0,K.bi_valid=0}function Le(K,ae,ke,P){var N=2*ae,me=2*ke;return K[N]<K[me]||K[N]===K[me]&&P[ae]<=P[ke]}function oe(K,ae,ke){for(var P=K.heap[ke],N=ke<<1;N<=K.heap_len&&(N<K.heap_len&&Le(ae,K.heap[N+1],K.heap[N],K.depth)&&N++,!Le(ae,P,K.heap[N],K.depth));)K.heap[ke]=K.heap[N],ke=N,N<<=1;K.heap[ke]=P}function we(K,ae,ke){var P,N,me,Se,Re=0;if(K.last_lit!==0)for(;P=K.pending_buf[K.d_buf+2*Re]<<8|K.pending_buf[K.d_buf+2*Re+1],N=K.pending_buf[K.l_buf+Re],Re++,P===0?Ve(K,N,ae):(Ve(K,(me=R[N])+f+1,ae),(Se=z[me])!==0&&Pe(K,N-=U[me],Se),Ve(K,me=ye(--P),ke),(Se=G[me])!==0&&Pe(K,P-=Z[me],Se)),Re<K.last_lit;);Ve(K,b,ae)}function Q(K,ae){var ke,P,N,me=ae.dyn_tree,Se=ae.stat_desc.static_tree,Re=ae.stat_desc.has_stree,ze=ae.stat_desc.elems,Ke=-1;for(K.heap_len=0,K.heap_max=v,ke=0;ke<ze;ke++)me[2*ke]!==0?(K.heap[++K.heap_len]=Ke=ke,K.depth[ke]=0):me[2*ke+1]=0;for(;K.heap_len<2;)me[2*(N=K.heap[++K.heap_len]=Ke<2?++Ke:0)]=1,K.depth[N]=0,K.opt_len--,Re&&(K.static_len-=Se[2*N+1]);for(ae.max_code=Ke,ke=K.heap_len>>1;1<=ke;ke--)oe(K,me,ke);for(N=ze;ke=K.heap[1],K.heap[1]=K.heap[K.heap_len--],oe(K,me,1),P=K.heap[1],K.heap[--K.heap_max]=ke,K.heap[--K.heap_max]=P,me[2*N]=me[2*ke]+me[2*P],K.depth[N]=(K.depth[ke]>=K.depth[P]?K.depth[ke]:K.depth[P])+1,me[2*ke+1]=me[2*P+1]=N,K.heap[1]=N++,oe(K,me,1),2<=K.heap_len;);K.heap[--K.heap_max]=K.heap[1],(function(ot,mt){var Ot,Mt,Kt,$e,Qt,Hn,qt=mt.dyn_tree,jn=mt.max_code,Pn=mt.stat_desc.static_tree,$r=mt.stat_desc.has_stree,Nr=mt.stat_desc.extra_bits,_r=mt.stat_desc.extra_base,Tn=mt.stat_desc.max_length,tr=0;for($e=0;$e<=C;$e++)ot.bl_count[$e]=0;for(qt[2*ot.heap[ot.heap_max]+1]=0,Ot=ot.heap_max+1;Ot<v;Ot++)Tn<($e=qt[2*qt[2*(Mt=ot.heap[Ot])+1]+1]+1)&&($e=Tn,tr++),qt[2*Mt+1]=$e,jn<Mt||(ot.bl_count[$e]++,Qt=0,_r<=Mt&&(Qt=Nr[Mt-_r]),Hn=qt[2*Mt],ot.opt_len+=Hn*($e+Qt),$r&&(ot.static_len+=Hn*(Pn[2*Mt+1]+Qt)));if(tr!==0){do{for($e=Tn-1;ot.bl_count[$e]===0;)$e--;ot.bl_count[$e]--,ot.bl_count[$e+1]+=2,ot.bl_count[Tn]--,tr-=2}while(0<tr);for($e=Tn;$e!==0;$e--)for(Mt=ot.bl_count[$e];Mt!==0;)jn<(Kt=ot.heap[--Ot])||(qt[2*Kt+1]!==$e&&(ot.opt_len+=($e-qt[2*Kt+1])*qt[2*Kt],qt[2*Kt+1]=$e),Mt--)}})(K,ae),ct(me,Ke,K.bl_count)}function I(K,ae,ke){var P,N,me=-1,Se=ae[1],Re=0,ze=7,Ke=4;for(Se===0&&(ze=138,Ke=3),ae[2*(ke+1)+1]=65535,P=0;P<=ke;P++)N=Se,Se=ae[2*(P+1)+1],++Re<ze&&N===Se||(Re<Ke?K.bl_tree[2*N]+=Re:N!==0?(N!==me&&K.bl_tree[2*N]++,K.bl_tree[2*k]++):Re<=10?K.bl_tree[2*x]++:K.bl_tree[2*M]++,me=N,Ke=(Re=0)===Se?(ze=138,3):N===Se?(ze=6,3):(ze=7,4))}function re(K,ae,ke){var P,N,me=-1,Se=ae[1],Re=0,ze=7,Ke=4;for(Se===0&&(ze=138,Ke=3),P=0;P<=ke;P++)if(N=Se,Se=ae[2*(P+1)+1],!(++Re<ze&&N===Se)){if(Re<Ke)for(;Ve(K,N,K.bl_tree),--Re!=0;);else N!==0?(N!==me&&(Ve(K,N,K.bl_tree),Re--),Ve(K,k,K.bl_tree),Pe(K,Re-3,2)):Re<=10?(Ve(K,x,K.bl_tree),Pe(K,Re-3,3)):(Ve(K,M,K.bl_tree),Pe(K,Re-11,7));me=N,Ke=(Re=0)===Se?(ze=138,3):N===Se?(ze=6,3):(ze=7,4)}}l(Z);var j=!1;function X(K,ae,ke,P){Pe(K,(u<<1)+(P?1:0),3),(function(N,me,Se,Re){It(N),Re&&(ve(N,Se),ve(N,~Se)),i.arraySet(N.pending_buf,N.window,me,Se,N.pending),N.pending+=Se})(K,ae,ke,!0)}o._tr_init=function(K){j||((function(){var ae,ke,P,N,me,Se=new Array(C+1);for(N=P=0;N<d-1;N++)for(U[N]=P,ae=0;ae<1<<z[N];ae++)R[P++]=N;for(R[P-1]=N,N=me=0;N<16;N++)for(Z[N]=me,ae=0;ae<1<<G[N];ae++)H[me++]=N;for(me>>=7;N<g;N++)for(Z[N]=me<<7,ae=0;ae<1<<G[N]-7;ae++)H[256+me++]=N;for(ke=0;ke<=C;ke++)Se[ke]=0;for(ae=0;ae<=143;)$[2*ae+1]=8,ae++,Se[8]++;for(;ae<=255;)$[2*ae+1]=9,ae++,Se[9]++;for(;ae<=279;)$[2*ae+1]=7,ae++,Se[7]++;for(;ae<=287;)$[2*ae+1]=8,ae++,Se[8]++;for(ct($,p+1,Se),ae=0;ae<g;ae++)T[2*ae+1]=5,T[2*ae]=nt(ae,5);W=new Me($,z,f+1,p,C),ee=new Me(T,G,0,g,C),J=new Me(new Array(0),F,0,m,S)})(),j=!0),K.l_desc=new fe(K.dyn_ltree,W),K.d_desc=new fe(K.dyn_dtree,ee),K.bl_desc=new fe(K.bl_tree,J),K.bi_buf=0,K.bi_valid=0,ft(K)},o._tr_stored_block=X,o._tr_flush_block=function(K,ae,ke,P){var N,me,Se=0;0<K.level?(K.strm.data_type===2&&(K.strm.data_type=(function(Re){var ze,Ke=4093624447;for(ze=0;ze<=31;ze++,Ke>>>=1)if(1&Ke&&Re.dyn_ltree[2*ze]!==0)return s;if(Re.dyn_ltree[18]!==0||Re.dyn_ltree[20]!==0||Re.dyn_ltree[26]!==0)return a;for(ze=32;ze<f;ze++)if(Re.dyn_ltree[2*ze]!==0)return a;return s})(K)),Q(K,K.l_desc),Q(K,K.d_desc),Se=(function(Re){var ze;for(I(Re,Re.dyn_ltree,Re.l_desc.max_code),I(Re,Re.dyn_dtree,Re.d_desc.max_code),Q(Re,Re.bl_desc),ze=m-1;3<=ze&&Re.bl_tree[2*L[ze]+1]===0;ze--);return Re.opt_len+=3*(ze+1)+5+5+4,ze})(K),N=K.opt_len+3+7>>>3,(me=K.static_len+3+7>>>3)<=N&&(N=me)):N=me=ke+5,ke+4<=N&&ae!==-1?X(K,ae,ke,P):K.strategy===4||me===N?(Pe(K,2+(P?1:0),3),we(K,$,T)):(Pe(K,4+(P?1:0),3),(function(Re,ze,Ke,ot){var mt;for(Pe(Re,ze-257,5),Pe(Re,Ke-1,5),Pe(Re,ot-4,4),mt=0;mt<ot;mt++)Pe(Re,Re.bl_tree[2*L[mt]+1],3);re(Re,Re.dyn_ltree,ze-1),re(Re,Re.dyn_dtree,Ke-1)})(K,K.l_desc.max_code+1,K.d_desc.max_code+1,Se+1),we(K,K.dyn_ltree,K.dyn_dtree)),ft(K),P&&It(K)},o._tr_tally=function(K,ae,ke){return K.pending_buf[K.d_buf+2*K.last_lit]=ae>>>8&255,K.pending_buf[K.d_buf+2*K.last_lit+1]=255&ae,K.pending_buf[K.l_buf+K.last_lit]=255&ke,K.last_lit++,ae===0?K.dyn_ltree[2*ke]++:(K.matches++,ae--,K.dyn_ltree[2*(R[ke]+f+1)]++,K.dyn_dtree[2*ye(ae)]++),K.last_lit===K.lit_bufsize-1},o._tr_align=function(K){Pe(K,2,3),Ve(K,b,$),(function(ae){ae.bi_valid===16?(ve(ae,ae.bi_buf),ae.bi_buf=0,ae.bi_valid=0):8<=ae.bi_valid&&(ae.pending_buf[ae.pending++]=255&ae.bi_buf,ae.bi_buf>>=8,ae.bi_valid-=8)})(K)}},{"../utils/common":41}],53:[function(n,r,o){"use strict";r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,o){(function(i){(function(s,a){"use strict";if(!s.setImmediate){var l,u,d,f,p=1,g={},m=!1,v=s.document,C=Object.getPrototypeOf&&Object.getPrototypeOf(s);C=C&&C.setTimeout?C:s,l={}.toString.call(s.process)==="[object process]"?function(k){process.nextTick(function(){S(k)})}:(function(){if(s.postMessage&&!s.importScripts){var k=!0,x=s.onmessage;return s.onmessage=function(){k=!1},s.postMessage("","*"),s.onmessage=x,k}})()?(f="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",b,!1):s.attachEvent("onmessage",b),function(k){s.postMessage(f+k,"*")}):s.MessageChannel?((d=new MessageChannel).port1.onmessage=function(k){S(k.data)},function(k){d.port2.postMessage(k)}):v&&"onreadystatechange"in v.createElement("script")?(u=v.documentElement,function(k){var x=v.createElement("script");x.onreadystatechange=function(){S(k),x.onreadystatechange=null,u.removeChild(x),x=null},u.appendChild(x)}):function(k){setTimeout(S,0,k)},C.setImmediate=function(k){typeof k!="function"&&(k=new Function(""+k));for(var x=new Array(arguments.length-1),M=0;M<x.length;M++)x[M]=arguments[M+1];return g[p]={callback:k,args:x},l(p),p++},C.clearImmediate=w}function w(k){delete g[k]}function S(k){if(m)setTimeout(S,0,k);else{var x=g[k];if(x){m=!0;try{(function(M){var z=M.callback,G=M.args;switch(G.length){case 0:z();break;case 1:z(G[0]);break;case 2:z(G[0],G[1]);break;case 3:z(G[0],G[1],G[2]);break;default:z.apply(a,G)}})(x)}finally{w(k),m=!1}}}}function b(k){k.source===s&&typeof k.data=="string"&&k.data.indexOf(f)===0&&S(+k.data.slice(f.length))}})(typeof self>"u"?i===void 0?this:i:self)}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})),br="application/vnd.openxmlformats-officedocument.wordprocessingml.document",Da="application/pdf",Du="text/html",t6={docx:br,pdf:Da,html:Du},Kp={RESOLVED:"resolved",NEW:"new",ADD:"add",UPDATE:"update",DELETED:"deleted",PENDING:"pending",SELECTED:"selected",COMMENTS_LIST:"comments-list",CHANGE_ACCEPTED:"change-accepted",CHANGE_REJECTED:"change-rejected"};Ft();var n6=p2(e6(),1),r6=e=>typeof e!="string"?"":e.trim(),ab=e=>{if(typeof e!="string")return"";const t=e.trim();return t?t.toLowerCase():""},qp=e=>{if(typeof e!="string")return"";const t=e.trim();return t?t.toLowerCase():""},Ic=e=>{const t=e??{},n=r6(t.id),r=ab(t.email);return{id:n,email:r,name:typeof t.name=="string"?t.name:"",hasId:n.length>0,hasEmail:r.length>0}},Lk=({current:e,other:t})=>{const n=Ic(e),r=Ic(t);return n.hasId&&r.hasId?n.id===r.id:n.hasEmail&&r.hasEmail?n.email===r.email:!1},Ou=({actor:e,fallbackKey:t=""})=>{const n=Ic(e);if(n.hasId)return`id:${n.id}`;if(n.hasEmail)return`email:${n.email}`;const r=typeof t=="number"?String(t):typeof t=="string"?t.trim():"";return r?`fallback:${r}`:""};function o6(e){return typeof e.captureStackTrace=="function"}var Yp=class extends Error{constructor(e,t){super(e),this.cause=t,this.name="FileObjectError",o6(Error)&&Error.captureStackTrace(this,this.constructor)}},i6=class extends Yp{constructor(e){super("Invalid data URI format: URI must contain exactly one comma separator"),this.uri=e,this.name="InvalidDataUriError"}},s6=class extends Yp{constructor(e,t){super(`Failed to fetch file from URL: ${e}`,t),this.url=e,this.name="FetchFailedError"}},lb=async(e,t,n)=>{try{if(e.startsWith("data:")&&e.includes(";base64,")){const i=e.split(",");if(i.length!==2)throw new i6(e);const s=atob(i[1]),a=Uint8Array.from(s,l=>l.charCodeAt(0));return new File([a],t,{type:n})}const r=await fetch(e);if(!r.ok)throw new s6(e,new Error(`HTTP ${r.status}: ${r.statusText}`));const o=await r.blob();return new File([o],t,{type:n})}catch(r){throw r instanceof Yp?r:new Yp("Failed to create file object",r)}};function a6(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const i=n[o]||0,s=r[o]||0;if(i>s)return 1;if(i<s)return-1}return 0}var Xp=new WeakMap;function Pk(e){return e.ownerDocument??document}function Dk(e,t){const n=Xp.get(t);n?.bindings.delete(e),n&&n.bindings.size===0&&(t.removeEventListener("click",n.listener),Xp.delete(t))}function Ok(e,t){const n=Pk(e);e.__clickOutsideDocument&&e.__clickOutsideDocument!==n&&Dk(e,e.__clickOutsideDocument);let r=Xp.get(n);if(!r){const o=new Map,i=s=>{const a=typeof s.composedPath=="function"?s.composedPath():null;for(const[l,u]of o)(a?.includes(l)??l.contains(s.target))||u.value?.(s)};r={bindings:o,listener:i},Xp.set(n,r),n.addEventListener("click",i)}r.bindings.set(e,t),e.__clickOutsideHandler=r.listener,e.__clickOutsideDocument=n}var cb={mounted(e,t){Ok(e,t)},updated(e,t){Ok(e,t)},unmounted(e){Dk(e,e.__clickOutsideDocument??Pk(e)),delete e.__clickOutsideHandler,delete e.__clickOutsideDocument}};function l6(e){return e[1].user!==void 0}var c6=(e,t)=>{const n=new Set;return Array.from(t.entries()).filter(l6).filter(([r,o])=>{const i=Ou({actor:o.user,fallbackKey:r});return!i||n.has(i)?!1:(n.add(i),!0)}).map(([r,o])=>{const i=Ou({actor:o.user,fallbackKey:r});let s=e.userColorMap.get(i);return s||(s=o.user.color||(e.config.colors.length>0?e.config.colors[e.colorIndex%e.config.colors.length]:void 0),e.userColorMap.set(i,s),e.colorIndex++),{clientId:r,...o.user,color:s}})},u6=e=>{for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e},d6="https://ingest.superdoc.dev/v1/collect",Qq="community-and-eval-agplv3";function f6(){try{return"2.22.0-next.3"}catch{return"unknown"}}var h6=class{constructor(e){this.enabled=e.enabled,this.endpoint=e.endpoint||d6,this.licenseKey=e.licenseKey||"",this.metadata=e.metadata,this.superdocVersion=f6()}getBrowserInfo(){return typeof window>"u"?{userAgent:"",currentUrl:"",hostname:"",screenSize:{width:0,height:0}}:{userAgent:window.navigator.userAgent,currentUrl:window.location.origin,hostname:window.location.hostname,screenSize:{width:window.screen.width,height:window.screen.height}}}trackDocumentOpen(e,t=null){if(!this.enabled)return;const n={timestamp:new Date().toISOString(),documentId:e,documentCreatedAt:t};this.sendEvent(n)}async sendEvent(e){const t={superdocVersion:this.superdocVersion,browserInfo:this.getBrowserInfo(),...this.metadata&&{metadata:this.metadata},events:[e]};try{await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-License-Key":this.licenseKey},body:JSON.stringify(t),credentials:"omit"})}catch{}}},Zp={PAGE:"superdoc-page",FRAGMENT:"superdoc-fragment",FLOATING_FRAGMENT:"superdoc-floating-fragment",LINE:"superdoc-line",INLINE_SDT_WRAPPER:"superdoc-structured-content-inline",INLINE_SDT_LABEL:"superdoc-structured-content-inline__label",BLOCK_SDT:"superdoc-structured-content-block",BLOCK_SDT_LABEL:"superdoc-structured-content__label",TABLE_FRAGMENT:"superdoc-table-fragment",DOCUMENT_SECTION:"superdoc-document-section",SDT_GROUP_HOVER:"sdt-group-hover",TOC_ENTRY:"superdoc-toc-entry",TOC_GROUP_HOVER:"toc-group-hover",IMAGE_FRAGMENT:"superdoc-image-fragment",INLINE_IMAGE:"superdoc-inline-image",LIST_MARKER:"superdoc-list-marker",INLINE_IMAGE_CLIP_WRAPPER:"superdoc-inline-image-clip-wrapper",ANNOTATION:"annotation",ANNOTATION_CONTENT:"annotation-content",ANNOTATION_CARET_ANCHOR:"annotation-caret-anchor"},Jq=[Zp.INLINE_SDT_LABEL,Zp.BLOCK_SDT_LABEL],Fk={PM_START:"data-pm-start",PM_END:"data-pm-end",LAYOUT_EPOCH:"data-layout-epoch",TABLE_BOUNDARIES:"data-table-boundaries",SDT_ID:"data-sdt-id",SDT_TYPE:"data-sdt-type",FIELD_ID:"data-field-id",FIELD_TYPE:"data-field-type",DRAGGABLE:"data-draggable",DISPLAY_LABEL:"data-display-label",VARIANT:"data-variant",TYPE:"data-type",LAYOUT_BOUNDARY_SCHEMA:"data-layout-boundary-schema",LAYOUT_FRAGMENT_ID:"data-layout-fragment-id",LAYOUT_STORY:"data-layout-story",LAYOUT_BLOCK_REF:"data-layout-block-ref",LAYOUT_COLUMN_INDEX:"data-layout-column-index"},p6=e=>{if(!e)return{kind:"unknown"};if(e==="body")return{kind:"body"};const t=e.indexOf(":"),n=t===-1?e:e.slice(0,t),r=t===-1?void 0:e.slice(t+1);switch(n){case"body":case"header":case"footer":case"footnote":case"endnote":case"textbox":return r?{kind:n,id:r}:{kind:n};default:return{kind:"unknown"}}},eY=`.${Zp.BLOCK_SDT}[${Fk.SDT_ID}]`,tY=`[${Fk.DRAGGABLE}="true"]`,m6=typeof window<"u",Nk,Df=e=>Nk=e,Bk=Symbol();function ub(e){return e&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"&&typeof e.toJSON!="function"}var Of;(function(e){e.direct="direct",e.patchObject="patch object",e.patchFunction="patch function"})(Of||(Of={}));var zk=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof global=="object"&&global.global===global?global:typeof globalThis=="object"?globalThis:{HTMLElement:null};function g6(e,{autoBom:t=!1}={}){return t&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\uFEFF",e],{type:e.type}):e}function db(e,t,n){const r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){v6(r.response,t,n)},r.onerror=function(){console.error("could not download file")},r.send()}function jk(e){const t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch{}return t.status>=200&&t.status<=299}function Qp(e){try{e.dispatchEvent(new MouseEvent("click"))}catch{const n=new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window,detail:0,screenX:80,screenY:20,clientX:80,clientY:20,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,button:0,relatedTarget:null});e.dispatchEvent(n)}}var Jp=typeof navigator=="object"?navigator:{userAgent:""},Vk=/Macintosh/.test(Jp.userAgent)&&/AppleWebKit/.test(Jp.userAgent)&&!/Safari/.test(Jp.userAgent),v6=m6?typeof HTMLAnchorElement<"u"&&"download"in HTMLAnchorElement.prototype&&!Vk?y6:"msSaveOrOpenBlob"in Jp?b6:w6:()=>{};function y6(e,t="download",n){const r=document.createElement("a");r.download=t,r.rel="noopener",typeof e=="string"?(r.href=e,r.origin!==location.origin?jk(r.href)?db(e,t,n):(r.target="_blank",Qp(r)):Qp(r)):(r.href=URL.createObjectURL(e),setTimeout(function(){URL.revokeObjectURL(r.href)},4e4),setTimeout(function(){Qp(r)},0))}function b6(e,t="download",n){if(typeof e=="string")if(jk(e))db(e,t,n);else{const r=document.createElement("a");r.href=e,r.target="_blank",setTimeout(function(){Qp(r)})}else navigator.msSaveOrOpenBlob(g6(e,n),t)}function w6(e,t,n,r){if(r=r||open("","_blank"),r&&(r.document.title=r.document.body.innerText="downloading..."),typeof e=="string")return db(e,t,n);const o=e.type==="application/octet-stream",i=/constructor/i.test(String(zk.HTMLElement))||"safari"in zk,s=/CriOS\/[\d]+/.test(navigator.userAgent);if((s||o&&i||Vk)&&typeof FileReader<"u"){const a=new FileReader;a.onloadend=function(){let l=a.result;if(typeof l!="string")throw r=null,new Error("Wrong reader.result type");l=s?l:l.replace(/^data:[^;]*;/,"data:attachment/file;"),r?r.location.href=l:location.assign(l),r=null},a.readAsDataURL(e)}else{const a=URL.createObjectURL(e);r?r.location.assign(a):location.href=a,r=null,setTimeout(function(){URL.revokeObjectURL(a)},4e4)}}var{assign:nY}=Object;function C6(){const e=yv(!0),t=e.run(()=>te({}));let n=[],r=[];const o=Gr({install(i){Df(o),o._a=i,i.provide(Bk,o),i.config.globalProperties.$pinia=o,r.forEach(s=>n.push(s)),r=[]},use(i){return this._a?n.push(i):r.push(i),this},_p:n,_a:null,_e:e,_s:new Map,state:t});return o}var Uk=()=>{};function $k(e,t,n,r=Uk){e.add(t);const o=()=>{e.delete(t)&&r()};return!n&&bv()&&P2(o),o}function Fu(e,...t){e.forEach(n=>{n(...t)})}var k6=e=>e(),Hk=Symbol(),fb=Symbol();function hb(e,t){e instanceof Map&&t instanceof Map?t.forEach((n,r)=>e.set(r,n)):e instanceof Set&&t instanceof Set&&t.forEach(e.add,e);for(const n in t){if(!t.hasOwnProperty(n))continue;const r=t[n],o=e[n];ub(o)&&ub(r)&&e.hasOwnProperty(n)&&!hr(r)&&!zi(r)?e[n]=hb(o,r):e[n]=r}return e}var S6=Symbol();function _6(e){return!ub(e)||!Object.prototype.hasOwnProperty.call(e,S6)}var{assign:El}=Object;function A6(e){return!!(hr(e)&&e.effect)}function I6(e,t,n,r){const{state:o,actions:i,getters:s}=t,a=n.state.value[e];let l;function u(){a||(n.state.value[e]=o?o():{});const d=H2(n.state.value[e]);return El(d,i,Object.keys(s||{}).reduce((f,p)=>(f[p]=Gr(_e(()=>{Df(n);const g=n._s.get(e);return s[p].call(g,g)})),f),{}))}return l=Gk(e,u,t,n,r,!0),l}function Gk(e,t,n={},r,o,i){let s;const a=El({actions:{}},n),l={deep:!0};let u,d,f=new Set,p=new Set,g;const m=r.state.value[e];!i&&!m&&(r.state.value[e]={});let v;function C(M){let z;u=d=!1,typeof M=="function"?(M(r.state.value[e]),z={type:Of.patchFunction,storeId:e,events:g}):(hb(r.state.value[e],M),z={type:Of.patchObject,payload:M,storeId:e,events:g});const G=v=Symbol();Ct().then(()=>{v===G&&(u=!0)}),d=!0,Fu(f,z,r.state.value[e])}const w=i?function(){const{state:z}=n,G=z?z():{};this.$patch(F=>{El(F,G)})}:Uk;function S(){s.stop(),f.clear(),p.clear(),r._s.delete(e)}const b=(M,z="")=>{if(Hk in M)return M[fb]=z,M;const G=function(){Df(r);const F=Array.from(arguments),L=new Set,$=new Set;function T(U){L.add(U)}function H(U){$.add(U)}Fu(p,{args:F,name:G[fb],store:k,after:T,onError:H});let R;try{R=M.apply(this&&this.$id===e?this:k,F)}catch(U){throw Fu($,U),U}return R instanceof Promise?R.then(U=>(Fu(L,U),U)).catch(U=>(Fu($,U),Promise.reject(U))):(Fu(L,R),R)};return G[Hk]=!0,G[fb]=z,G},k=Qr({_p:r,$id:e,$onAction:$k.bind(null,p),$patch:C,$reset:w,$subscribe(M,z={}){const G=$k(f,M,z.detached,()=>F()),F=s.run(()=>jt(()=>r.state.value[e],L=>{(z.flush==="sync"?d:u)&&M({storeId:e,type:Of.direct,events:g},L)},El({},l,z)));return G},$dispose:S});r._s.set(e,k);const x=(r._a&&r._a.runWithContext||k6)(()=>r._e.run(()=>(s=yv()).run(()=>t({action:b}))));for(const M in x){const z=x[M];hr(z)&&!A6(z)||zi(z)?i||(m&&_6(z)&&(hr(z)?z.value=m[M]:hb(z,m[M])),r.state.value[e][M]=z):typeof z=="function"&&(x[M]=b(z,M),a.actions[M]=z)}return El(k,x),El(Cn(k),x),Object.defineProperty(k,"$state",{get:()=>r.state.value[e],set:M=>{C(z=>{El(z,M)})}}),r._p.forEach(M=>{El(k,s.run(()=>M({store:k,app:r._a,pinia:r,options:a})))}),m&&i&&n.hydrate&&n.hydrate(k.$state,m),u=!0,d=!0,k}function Wk(e,t,n){let r;const o=typeof t=="function";r=o?n:t;function i(s,a){const l=yw();return s=s||(l?gl(Bk,null):null),s&&Df(s),s=Nk,s._s.has(e)||(o?Gk(e,t,r,s):I6(e,r,s)),s._s.get(e)}return i.$id=e,i}function qs(e){const t=Cn(e),n={};for(const r in t){const o=t[r];o.effect?n[r]=_e({get:()=>e[r],set(i){e[r]=i}}):(hr(o)||zi(o))&&(n[r]=Ev(e,r))}return n}function Kk(e){return e.collaboration!==void 0?e.collaboration:e.v2Collaboration}function qk(e){if(typeof e!="string"||e.length===0)return"<none>";try{const t=new URL(e);t.search="",t.hash="",t.username="",t.password="";const n=e.includes("?")?"?<redacted>":"";return`${t.toString().replace(/\?$/,"")}${n}`}catch{const t=e.replace(/\/\/[^/@]+@/,"//"),n=t.search(/[?#]/);return n===-1?t:`${t.slice(0,n)}?<redacted>`}}function Ec(e){return typeof e=="string"&&e.length>0?e:null}function E6(e){if(typeof e!="string"||e.length===0)return null;try{const t=new URL(e);return t.protocol==="ws:"||t.protocol==="wss:"?e:null}catch{return null}}function x6(e,t){if(typeof e!="string")return null;const n=e.trim();if(n.length===0)return null;try{const r=new URL(n);return r.protocol==="http:"||r.protocol==="https:"?n:null}catch{if(typeof t!="string"||t.trim().length===0)return null;try{const r=new URL(n,t);return r.protocol==="http:"||r.protocol==="https:"?r.href:null}catch{return null}}}function T6(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t={};for(const[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return Object.keys(t).length>0?t:void 0}function pb(e){return e===void 0?"join":e==="join"||e==="create"?e:null}function R6(e){if(e!==void 0)return typeof e=="number"&&Number.isFinite(e)&&e>0&&e<=2147483647?e:null}function em(e,t){return!e.ok||t===void 0?e:{ok:!0,target:{...e.target,syncTimeoutMs:t}}}function mb(){return{ok:!1,reason:"invalid-room-mode",message:'SuperDoc v2 collaboration roomMode must be either "join" or "create".'}}function M6(e){const t=e.providerType;return typeof t=="string"&&t.length>0?t.toLowerCase():null}function L6(e){if(!e||typeof e!="object")return null;const t=typeof e.providerType=="string"?e.providerType.toLowerCase():"";return t==="hocuspocus"?"hocuspocus":t==="liveblocks"?"liveblocks":t==="superdoc"?"superdoc":e.ydoc!=null||e.provider!=null?"external-ydoc-provider":null}function Yk(e,t){const n=Ec(t.documentId);if(!n)return{ok:!1,reason:"invalid-document-id",message:`SuperDoc v2 collaboration requires a non-empty collaboration.documentId for the "${e}" provider.`};const r=t.url??t.serverUrl,o=E6(r);if(!o)return{ok:!1,reason:"invalid-server-url",message:`SuperDoc v2 collaboration requires a valid ws:// or wss:// URL for the "${e}" provider (received: ${qk(r)}).`};const i=T6(t.params),s=e==="hocuspocus"&&typeof t.token=="function"?t.token:e==="hocuspocus"?Ec(t.token):null,a=pb(t.roomMode);return a?{ok:!0,target:{providerFamily:e,documentId:n,roomMode:a,serverUrl:o,...i?{params:i}:{},...s?{token:s}:{}}}:mb()}function P6(e){const t=Ec(e.adapterId);if(!t)return{ok:!1,reason:"invalid-adapter-id",message:"SuperDoc v2 provider extensions require a non-empty collaboration.adapterId."};const n=Ec(e.documentId);if(!n)return{ok:!1,reason:"invalid-document-id",message:"SuperDoc v2 provider extensions require a non-empty collaboration.documentId."};const r=pb(e.roomMode);if(!r)return mb();if(Object.prototype.hasOwnProperty.call(e,"providerOptions"))try{structuredClone(e.providerOptions)}catch{return{ok:!1,reason:"invalid-provider-options",message:"SuperDoc v2 provider extension options must be structured-clone-safe."}}const o=typeof e.token=="function"?e.token:Ec(e.token);return{ok:!0,target:{providerFamily:"extension",adapterId:t,documentId:n,roomMode:r,...Object.prototype.hasOwnProperty.call(e,"providerOptions")?{providerOptions:e.providerOptions}:{},...o?{token:o}:{}}}}function D6(e,t){const n=Ec(e.documentId??e.roomId);if(!n)return{ok:!1,reason:"invalid-document-id",message:'SuperDoc v2 collaboration requires a non-empty collaboration.documentId (or roomId) for the "liveblocks" provider.'};const r=Ec(e.publicApiKey),o=pb(e.roomMode);if(!o)return mb();const i=e.authEndpoint,s=typeof i=="string"&&i.length>0;if(!r&&!s)return{ok:!1,reason:"missing-auth",message:"SuperDoc v2 Liveblocks collaboration requires exactly one auth mode: a publicApiKey or an authEndpoint. None was provided."};if(r&&s)return{ok:!1,reason:"mixed-auth",message:"SuperDoc v2 Liveblocks collaboration accepts exactly one auth mode; pass either publicApiKey or authEndpoint, not both."};if(r)return{ok:!0,target:{providerFamily:"liveblocks",documentId:n,roomMode:o,publicApiKey:r}};const a=x6(i,t);return a?{ok:!0,target:{providerFamily:"liveblocks",documentId:n,roomMode:o,authEndpoint:a}}:{ok:!1,reason:"invalid-auth-endpoint",message:"SuperDoc v2 Liveblocks collaboration requires a valid http(s) authEndpoint URL (received: <redacted>)."}}function Xk(e){const{legacyCollaboration:t,documentType:n,documentCount:r,authEndpointBaseUrl:o}=e,i=Kk(e);if(typeof r=="number"&&r>1)return{ok:!1,reason:"unsupported-multi-document",message:`SuperDoc v2 collaboration supports exactly one document per room; received ${r}.`};if(n!=null&&n!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document")return{ok:!1,reason:"unsupported-document-type",message:"SuperDoc v2 collaboration supports DOCX documents only."};if(!(i!=null&&typeof i=="object")){const u=L6(t);if(u){const d=u==="external-ydoc-provider"?"unsupported-legacy-provider":"unsupported-provider-family",f=qk(t?.url);return{ok:!1,reason:d,message:u==="external-ydoc-provider"?"SuperDoc v2 collaboration cannot use an external { ydoc, provider } pair. Provide a collaboration target (e.g. { providerType, documentId, url }) instead.":`SuperDoc v2 collaboration does not accept "${u}" through the legacy modules.collaboration block (server: ${f}). Configure it as a document.collaboration target ({ providerType: "${u}", documentId, ... }) instead.`}}return{ok:!1,reason:"missing-target",message:"SuperDoc v2 collaboration requires a collaboration target ({ documentId, serverUrl } or { providerType, ... }). None was provided."}}const s=i;if(Object.prototype.hasOwnProperty.call(s,"createIfMissing"))return{ok:!1,reason:"invalid-room-mode",message:'SuperDoc v2 collaboration createIfMissing has been removed. Use roomMode: "create" for creation or roomMode: "join" for normal opens.'};if(s.ydoc!=null||s.provider!=null)return{ok:!1,reason:"unsupported-legacy-provider",message:"SuperDoc v2 collaboration cannot use an external { ydoc, provider } pair. v2 owns its provider; pass a collaboration target ({ providerType, documentId, serverUrl | publicApiKey | authEndpoint }) instead."};const a=R6(s.syncTimeoutMs);if(a===null)return{ok:!1,reason:"invalid-sync-timeout",message:"SuperDoc v2 collaboration syncTimeoutMs must be a finite positive number within the JavaScript timer range."};const l=M6(s);return l===null||l==="y-websocket"?em(Yk("y-websocket",s),a):l==="hocuspocus"?em(Yk("hocuspocus",s),a):l==="liveblocks"?em(D6(s,o),a):l==="extension"?em(P6(s),a):{ok:!1,reason:"unsupported-provider-family",message:`SuperDoc v2 collaboration does not support the "${l}" provider family. Supported families are y-websocket, hocuspocus, liveblocks, and extension.`}}var Ff=(e,t="document")=>{if(!e)return null;if(typeof File=="function"&&e instanceof File)return e;if(typeof Blob=="function"&&e instanceof Blob){if(typeof File=="function"){const n=e.name||t;return new File([e],n,{type:e.type})}return e}return e.originFileObj?Ff(e.originFileObj,e.name||t):e.file?Ff(e.file,e.name||t):e.raw?Ff(e.raw,e.name||t):null},Zk=Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength")?.get,O6=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),Symbol.toStringTag)?.get,xl=e=>{if(ArrayBuffer.isView(e))return O6?.call(e)==="Uint8Array";if(!Zk)return!1;try{return Zk.call(e),!0}catch{return!1}},gb=e=>{if(e instanceof Uint8Array)return e;const t=ArrayBuffer.isView(e)?e:new Uint8Array(e);return Uint8Array.from(t)},vb=(e,t)=>new Blob([gb(e)],{type:t}),yb=e=>{switch(e.toLowerCase()){case"docx":case br:return br;case"pdf":case Da:return Da;case"html":case Du:return Du;default:return e}},tm=(e="")=>{const t=String(e).toLowerCase();return t.endsWith(".docx")?br:t.endsWith(".pdf")?Da:t.endsWith(".html")||t.endsWith(".htm")?Du:t.endsWith(".md")||t.endsWith(".markdown")?"text/markdown":""},F6=e=>e==="application/vnd.openxmlformats-officedocument.wordprocessingml.document"?"document.docx":e==="application/pdf"?"document.pdf":e==="text/html"?"document.html":"document",N6="application/octet-stream",bb=e=>{if(e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"collaboration")){const n={...e};delete n.collaboration,e={...n,v2Collaboration:Kk(e)}}if(xl(e))return{type:br,data:gb(e),name:"document.docx"};const t=Ff(e);if(t){const n=e&&typeof e.name=="string"?e.name:"",r=t.name||"",o=tm(n),i=o||tm(r),s=t.type.toLowerCase()===N6,a=s&&o?n:r||n||"document",l=s&&i?i:t.type||i||"application/vnd.openxmlformats-officedocument.wordprocessingml.document";let u=t;return s&&i&&typeof File=="function"&&t instanceof File?u=new File([t],a,{type:l,lastModified:t.lastModified}):s&&i&&typeof Blob=="function"&&t instanceof Blob&&(u=new Blob([t],{type:l})),{...e.v2Collaboration!==void 0?{v2Collaboration:e.v2Collaboration}:{},type:l,data:u,name:a}}if(e&&typeof e=="object"&&"data"in e){if(xl(e.data)){const r=yb(e.type||tm(e.name)||"application/vnd.openxmlformats-officedocument.wordprocessingml.document");return{...e,type:r,data:r==="application/vnd.openxmlformats-officedocument.wordprocessingml.document"?gb(e.data):vb(e.data,r),name:e.name||F6(r)}}const n=Ff(e.data,e.name);if(n){const r=typeof e.type=="string"&&e.type?yb(e.type):"",o=r||n.type||tm(n.name)||"application/vnd.openxmlformats-officedocument.wordprocessingml.document",i=!n.type||!!(r&&n.type!==r);let s=n;return i&&typeof File=="function"&&n instanceof File?s=new File([n],n.name,{type:o,lastModified:n.lastModified}):i&&typeof Blob=="function"&&n instanceof Blob&&(s=new Blob([n],{type:o})),{...e,type:o,data:s,name:e.name||n.name||"document"}}}if(e&&typeof e=="object"&&"url"in e&&typeof e.type=="string"){const n=yb(e.type);if(n!==e.type)return{...e,type:n}}return e};Ft();function B6(e,t){const n=e.itemid,r=e,o=t!==null&&typeof t=="object"?Qr({...t}):te(t),i=te(null);return jt(o,(a,l)=>{const u={fieldId:n.value,changeTime:Date.now(),oldValue:l,newValue:a,originalField:r};i.value=u}),{value:o}}function z6(e){const t=te(e.itemid),n=te(e.itemicon),r=te(e.itemiconpack),o=te(e.itemdisplaylabel),i=e.itemlinkvalue,s=e.itemplaceholdertext,{value:a}=B6(e,i,te([])),l=te(e.itemtype),u=te(e.itemfieldtype),d=e,f=Qr({fontFamily:e.fontfamily||"Arial",fontSize:e.font_size||"12pt",originalFontSize:e.original_font_size||"12pt"}),p=te(e.logicrules),g=te(!1),m=Qr({}),v={SELECT:V6,IMAGEINPUT:j6,CHECKBOXINPUT:U6};return l.value in v&&Object.assign(m,v[l.value](e)),{id:t,icon:n,iconPack:r,label:o,placeholder:s,fieldType:l,fieldSubType:u,value:a,format:te(e.itemformat),logicRules:p,hidden:g,originalJSON:d,fieldStyle:f,valueGetter:e.valueGetter,...m}}function j6(e){return{fontfamily:te(e.fontfamily),iteminputtype:te(e.iteminputtype)}}function V6(e){return{options:te(e.itemoptions)}}function U6(e){const t=te(e.itemoptions);return t.value&&(t.value=t.value.map(n=>({label:n.itemdisplaylabel,value:n.itemlinkvalue,checked:n.ischecked,id:n.itemid,annotationId:n.annotationId}))),{options:t}}var Ys=()=>new Map,wb=e=>{const t=Ys();return e.forEach((n,r)=>{t.set(r,n)}),t},Nu=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},$6=(e,t)=>{const n=[];for(const[r,o]of e)n.push(t(o,r));return n},H6=(e,t)=>{for(const[n,r]of e)if(t(r,n))return!0;return!1},Bu=()=>new Set,Cb=e=>e[e.length-1],zu=Array.from,kb=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},Qk=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},G6=(e,t)=>{const n=new Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},nm=Array.isArray,W6=class{constructor(){this._observers=Ys()}on(e,t){return Nu(this._observers,e,Bu).add(t),t}once(e,t){const n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){const n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return zu((this._observers.get(e)||Ys()).values()).forEach(n=>n(...t))}destroy(){this._observers=Ys()}},Oa=Math.floor,rm=Math.abs,Jk=(e,t)=>e<t?e:t,ju=(e,t)=>e>t?e:t,rY=Number.isNaN,K6=e=>e!==0?e<0:1/e<0,oY=1,iY=2,sY=4,aY=8,lY=32,cY=64,uY=128,q6=1<<17,Y6=1<<18,X6=1<<19,Z6=1<<20,Q6=1<<21,J6=1<<22,e8=1<<23,t8=1<<24,n8=1<<25,r8=1<<26,o8=1<<27,i8=1<<28,s8=1<<29,a8=1<<30,dY=31,fY=63,hY=127,pY=q6-1,mY=Y6-1,gY=X6-1,vY=Z6-1,yY=Q6-1,bY=J6-1,wY=e8-1,CY=t8-1,kY=n8-1,SY=r8-1,_Y=o8-1,AY=i8-1,IY=s8-1,EY=a8-1,xY=2147483647,e3=Number.MAX_SAFE_INTEGER,t3=Number.MIN_SAFE_INTEGER,l8=Number.isInteger||(e=>typeof e=="number"&&isFinite(e)&&Oa(e)===e),TY=Number.isNaN,RY=Number.parseInt,n3=String.fromCharCode,MY=String.fromCodePoint,LY=n3(65535),c8=e=>e.toLowerCase(),u8=/^\s*/g,d8=e=>e.replace(u8,""),f8=/([A-Z])/g,r3=(e,t)=>d8(e.replace(f8,n=>`${t}${c8(n)}`)),h8=e=>{const t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let o=0;o<n;o++)r[o]=t.codePointAt(o);return r},Nf=typeof TextEncoder<"u"?new TextEncoder:null,p8=e=>Nf.encode(e),m8=Nf?p8:h8,Sb=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Sb&&Sb.decode(new Uint8Array).length===1&&(Sb=null);var g8=(e,t)=>G6(t,()=>e).join(""),Bf=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},_b=()=>new Bf,v8=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},Fa=e=>{const t=new Uint8Array(v8(e));let n=0;for(let r=0;r<e.bufs.length;r++){const o=e.bufs[r];t.set(o,n),n+=o.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},y8=(e,t)=>{const n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(ju(n,t)*2),e.cpos=0)},uo=(e,t)=>{const n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},Ab=uo,or=(e,t)=>{for(;t>127;)uo(e,128|127&t),t=Oa(t/128);uo(e,127&t)},Ib=(e,t)=>{const n=K6(t);for(n&&(t=-t),uo(e,(t>63?128:0)|(n?64:0)|63&t),t=Oa(t/64);t>0;)uo(e,(t>127?128:0)|127&t),t=Oa(t/128)},Eb=new Uint8Array(3e4),b8=Eb.length/3,w8=(e,t)=>{if(t.length<b8){const n=Nf.encodeInto(t,Eb).written||0;or(e,n);for(let r=0;r<n;r++)uo(e,Eb[r])}else Ei(e,m8(t))},C8=(e,t)=>{const n=unescape(encodeURIComponent(t)),r=n.length;or(e,r);for(let o=0;o<r;o++)uo(e,n.codePointAt(o))},Vu=Nf&&Nf.encodeInto?w8:C8,xb=(e,t)=>{const n=e.cbuf.length,r=e.cpos,o=Jk(n-r,t.length),i=t.length-o;e.cbuf.set(t.subarray(0,o),r),e.cpos+=o,i>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(ju(n*2,i)),e.cbuf.set(t.subarray(o)),e.cpos=i)},Ei=(e,t)=>{or(e,t.byteLength),xb(e,t)},Tb=(e,t)=>{y8(e,t);const n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},k8=(e,t)=>Tb(e,4).setFloat32(0,t,!1),S8=(e,t)=>Tb(e,8).setFloat64(0,t,!1),_8=(e,t)=>Tb(e,8).setBigInt64(0,t,!1),o3=new DataView(new ArrayBuffer(4)),A8=e=>(o3.setFloat32(0,e),o3.getFloat32(0)===e),zf=(e,t)=>{switch(typeof t){case"string":uo(e,119),Vu(e,t);break;case"number":l8(t)&&rm(t)<=2147483647?(uo(e,125),Ib(e,t)):A8(t)?(uo(e,124),k8(e,t)):(uo(e,123),S8(e,t));break;case"bigint":uo(e,122),_8(e,t);break;case"object":if(t===null)uo(e,126);else if(nm(t)){uo(e,117),or(e,t.length);for(let n=0;n<t.length;n++)zf(e,t[n])}else if(t instanceof Uint8Array)uo(e,116),Ei(e,t);else{uo(e,118);const n=Object.keys(t);or(e,n.length);for(let r=0;r<n.length;r++){const o=n[r];Vu(e,o),zf(e,t[o])}}break;case"boolean":uo(e,t?120:121);break;default:uo(e,127)}},i3=class extends Bf{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&or(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},s3=e=>{e.count>0&&(Ib(e.encoder,e.count===1?e.s:-e.s),e.count>1&&or(e.encoder,e.count-2))},om=class{constructor(){this.encoder=new Bf,this.s=0,this.count=0}write(e){this.s===e?this.count++:(s3(this),this.count=1,this.s=e)}toUint8Array(){return s3(this),Fa(this.encoder)}},a3=e=>{if(e.count>0){const t=e.diff*2+(e.count===1?0:1);Ib(e.encoder,t),e.count>1&&or(e.encoder,e.count-2)}},Rb=class{constructor(){this.encoder=new Bf,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(a3(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return a3(this),Fa(this.encoder)}},I8=class{constructor(){this.sarr=[],this.s="",this.lensE=new om}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new Bf;return this.sarr.push(this.s),this.s="",Vu(e,this.sarr.join("")),xb(e,this.lensE.toUint8Array()),Fa(e)}},Tl=e=>new Error(e),fs=()=>{throw Tl("Method unimplemented")},Na=()=>{throw Tl("Unexpected case")},PY=crypto.subtle,E8=crypto.getRandomValues.bind(crypto),l3=()=>E8(new Uint32Array(1))[0],x8="10000000-1000-4000-8000-100000000000",T8=()=>x8.replace(/[018]/g,e=>(e^l3()&15>>e/4).toString(16)),R8=Date.now,c3=e=>new Promise(e),DY=Promise.all.bind(Promise),u3=e=>e===void 0?null:e,M8=class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}},d3=new M8,L8=!0;try{typeof localStorage<"u"&&localStorage&&(d3=localStorage,L8=!1)}catch{}var P8=d3,jf=Symbol("Equality"),f3=(e,t)=>e===t||!!e?.[jf]?.(t)||!1,D8=e=>typeof e=="object",O8=Object.assign,F8=Object.keys,N8=(e,t)=>{for(const n in e)t(e[n],n)},im=e=>F8(e).length,B8=e=>{for(const t in e)return!1;return!0},Vf=(e,t)=>{for(const n in e)if(!t(e[n],n))return!1;return!0},Mb=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),z8=(e,t)=>e===t||im(e)===im(t)&&Vf(e,(n,r)=>(n!==void 0||Mb(t,r))&&f3(t[r],n)),j8=Object.freeze,h3=e=>{for(const t in e){const n=e[t];(typeof n=="object"||typeof n=="function")&&h3(e[t])}return j8(e)},Lb=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&Lb(e,t,n+1)}},sm=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[jf]!=null)return e[jf](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(const n of e.keys())if(!t.has(n)||!sm(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(im(e)!==im(t))return!1;for(const n in e)if(!Mb(e,n)||!sm(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!sm(e[n],t[n]))return!1;break;default:return!1}return!0},V8=(e,t)=>t.includes(e),Uf=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",OY=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,Xs,U8=[],$8=()=>{if(Xs===void 0)if(Uf){Xs=Ys();const e=process.argv;let t=null;for(let n=0;n<e.length;n++){const r=e[n];r[0]==="-"?(t!==null&&Xs.set(t,""),t=r):t!==null?(Xs.set(t,r),t=null):U8.push(r)}t!==null&&Xs.set(t,"")}else typeof location=="object"?(Xs=Ys(),(location.search||"?").slice(1).split("&").forEach(e=>{if(e.length!==0){const[t,n]=e.split("=");Xs.set(`--${r3(t,"-")}`,n),Xs.set(`-${r3(t,"-")}`,n)}})):Xs=Ys();return Xs},Pb=e=>$8().has(e),am=e=>u3(Uf?process.env[e.toUpperCase().replaceAll("-","_")]:P8.getItem(e)),p3=e=>Pb("--"+e)||am(e)!==null,H8=p3("production"),G8=Uf&&V8(process.env.FORCE_COLOR,["true","1","2"]),W8=G8||!Pb("--no-colors")&&!p3("no-color")&&(!Uf||process.stdout.isTTY)&&(!Uf||Pb("--color")||am("COLORTERM")!==null||(am("TERM")||"").includes("color")),K8=class{constructor(e,t){this.left=e,this.right=t}},Ba=(e,t)=>new K8(e,t),m3=e=>e.next()>=.5,Db=(e,t,n)=>Oa(e.next()*(n+1-t)+t),g3=(e,t,n)=>Oa(e.next()*(n+1-t)+t),Ob=(e,t,n)=>g3(e,t,n),q8=e=>n3(Ob(e,97,122)),Y8=(e,t=0,n=20)=>{const r=Ob(e,t,n);let o="";for(let i=0;i<r;i++)o+=q8(e);return o},Fb=(e,t)=>t[Ob(e,0,t.length-1)],X8=Symbol("0schema"),Z8=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){const e=[];for(let t=this._rerrs.length-1;t>0;t--){const n=this._rerrs[t];e.push(g8(" ",(this._rerrs.length-t)*2)+`${n.path!=null?`[${n.path}] `:""}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
4
|
+
\0`,Pe+=i(fe,2),Pe+=M.magic,Pe+=i(b,2),Pe+=i(k,2),Pe+=i(Me.crc32,4),Pe+=i(Me.compressedSize,4),Pe+=i(Me.uncompressedSize,4),Pe+=i(G.length,2),Pe+=i(U.length,2),{fileRecord:f.LOCAL_FILE_HEADER+Pe+G+U,dirRecord:f.CENTRAL_FILE_HEADER+i(ve,2)+Pe+i($.length,2)+"\0\0\0\0"+i(ye,4)+i(C,4)+G+U+$}}var a=n("../utils"),l=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function p(g,m,v,C){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=m,this.zipPlatform=v,this.encodeFileName=C,this.streamFiles=g,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(p,l),p.prototype.push=function(g){var m=g.meta.percent||0,v=this.entriesCount,C=this._sources.length;this.accumulate?this.contentBuffer.push(g):(this.bytesWritten+=g.data.length,l.prototype.push.call(this,{data:g.data,meta:{currentFile:this.currentFile,percent:v?(m+100*(v-C-1))/v:100}}))},p.prototype.openedSource=function(g){this.currentSourceOffset=this.bytesWritten,this.currentFile=g.file.name;var m=this.streamFiles&&!g.file.dir;if(m){var v=s(g,m,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:v.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(g){this.accumulate=!1;var m=this.streamFiles&&!g.file.dir,v=s(g,m,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(v.dirRecord),m)this.push({data:(function(C){return f.DATA_DESCRIPTOR+i(C.crc32,4)+i(C.compressedSize,4)+i(C.uncompressedSize,4)})(g),meta:{percent:100}});else for(this.push({data:v.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var g=this.bytesWritten,m=0;m<this.dirRecords.length;m++)this.push({data:this.dirRecords[m],meta:{percent:100}});var v=this.bytesWritten-g,C=(function(w,S,b,k,x){var M=a.transformTo("string",x(k));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+i(w,2)+i(w,2)+i(S,4)+i(b,4)+i(M.length,2)+M})(this.dirRecords.length,v,g,this.zipComment,this.encodeFileName);this.push({data:C,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(g){this._sources.push(g);var m=this;return g.on("data",function(v){m.processChunk(v)}),g.on("end",function(){m.closedSource(m.previous.streamInfo),m._sources.length?m.prepareNextSource():m.end()}),g.on("error",function(v){m.error(v)}),this},p.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},p.prototype.error=function(g){var m=this._sources;if(!l.prototype.error.call(this,g))return!1;for(var v=0;v<m.length;v++)try{m[v].error(g)}catch{}return!0},p.prototype.lock=function(){l.prototype.lock.call(this);for(var g=this._sources,m=0;m<g.length;m++)g[m].lock()},r.exports=p},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(n,r,o){"use strict";var i=n("../compressions"),s=n("./ZipFileWorker");o.generateWorker=function(a,l,u){var d=new s(l.streamFiles,u,l.platform,l.encodeFileName),f=0;try{a.forEach(function(p,g){f++;var m=(function(S,b){var k=S||b,x=i[k];if(!x)throw new Error(k+" is not a valid compression method !");return x})(g.options.compression,l.compression),v=g.options.compressionOptions||l.compressionOptions||{},C=g.dir,w=g.date;g._compressWorker(m,v).withStreamInfo("file",{name:p,dir:C,date:w,comment:g.comment||"",unixPermissions:g.unixPermissions,dosPermissions:g.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(p){d.error(p)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,o){"use strict";function i(){if(!(this instanceof i))return new i;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var s=new i;for(var a in this)typeof this[a]!="function"&&(s[a]=this[a]);return s}}(i.prototype=n("./object")).loadAsync=n("./load"),i.support=n("./support"),i.defaults=n("./defaults"),i.version="3.10.1",i.loadAsync=function(s,a){return new i().loadAsync(s,a)},i.external=n("./external"),r.exports=i},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,o){"use strict";var i=n("./utils"),s=n("./external"),a=n("./utf8"),l=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function f(p){return new s.Promise(function(g,m){var v=p.decompressed.getContentWorker().pipe(new u);v.on("error",function(C){m(C)}).on("end",function(){v.streamInfo.crc32!==p.decompressed.crc32?m(new Error("Corrupted zip : CRC32 mismatch")):g()}).resume()})}r.exports=function(p,g){var m=this;return g=i.extend(g||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),d.isNode&&d.isStream(p)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):i.prepareContent("the loaded zip file",p,!0,g.optimizedBinaryString,g.base64).then(function(v){var C=new l(g);return C.load(v),C}).then(function(v){var C=[s.Promise.resolve(v)],w=v.files;if(g.checkCRC32)for(var S=0;S<w.length;S++)C.push(f(w[S]));return s.Promise.all(C)}).then(function(v){for(var C=v.shift(),w=C.files,S=0;S<w.length;S++){var b=w[S],k=b.fileNameStr,x=i.resolve(b.fileNameStr);m.file(x,b.decompressed,{binary:!0,optimizedBinaryString:!0,date:b.date,dir:b.dir,comment:b.fileCommentStr.length?b.fileCommentStr:null,unixPermissions:b.unixPermissions,dosPermissions:b.dosPermissions,createFolders:g.createFolders}),b.dir||(m.file(x).unsafeOriginalName=k)}return C.zipComment.length&&(m.comment=C.zipComment),m})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(n,r,o){"use strict";var i=n("../utils"),s=n("../stream/GenericWorker");function a(l,u){s.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(u)}i.inherits(a,s),a.prototype._bindStream=function(l){var u=this;(this._stream=l).pause(),l.on("data",function(d){u.push({data:d,meta:{percent:0}})}).on("error",function(d){u.isPaused?this.generatedError=d:u.error(d)}).on("end",function(){u.isPaused?u._upstreamEnded=!0:u.end()})},a.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},r.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(n,r,o){"use strict";var i=n("readable-stream").Readable;function s(a,l,u){i.call(this,l),this._helper=a;var d=this;a.on("data",function(f,p){d.push(f)||d._helper.pause(),u&&u(p)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(s,i),s.prototype._read=function(){this._helper.resume()},r.exports=s},{"../utils":32,"readable-stream":16}],14:[function(n,r,o){"use strict";r.exports={isNode:typeof Buffer<"u",newBufferFrom:function(i,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(i,s);if(typeof i=="number")throw new Error('The "data" argument must not be a number');return new Buffer(i,s)},allocBuffer:function(i){if(Buffer.alloc)return Buffer.alloc(i);var s=new Buffer(i);return s.fill(0),s},isBuffer:function(i){return Buffer.isBuffer(i)},isStream:function(i){return i&&typeof i.on=="function"&&typeof i.pause=="function"&&typeof i.resume=="function"}}},{}],15:[function(n,r,o){"use strict";function i(k,x,M){var z,G=a.getTypeOf(x),F=a.extend(M||{},d);F.date=F.date||new Date,F.compression!==null&&(F.compression=F.compression.toUpperCase()),typeof F.unixPermissions=="string"&&(F.unixPermissions=parseInt(F.unixPermissions,8)),F.unixPermissions&&16384&F.unixPermissions&&(F.dir=!0),F.dosPermissions&&16&F.dosPermissions&&(F.dir=!0),F.dir&&(k=w(k)),F.createFolders&&(z=C(k))&&S.call(this,z,!0);var L=G==="string"&&F.binary===!1&&F.base64===!1;M&&M.binary!==void 0||(F.binary=!L),(x instanceof f&&x.uncompressedSize===0||F.dir||!x||x.length===0)&&(F.base64=!1,F.binary=!0,x="",F.compression="STORE",G="string");var $=null;$=x instanceof f||x instanceof l?x:m.isNode&&m.isStream(x)?new v(k,x):a.prepareContent(k,x,F.binary,F.optimizedBinaryString,F.base64);var T=new p(k,$,F);this.files[k]=T}var s=n("./utf8"),a=n("./utils"),l=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),p=n("./zipObject"),g=n("./generate"),m=n("./nodejsUtils"),v=n("./nodejs/NodejsStreamInputAdapter"),C=function(k){k.slice(-1)==="/"&&(k=k.substring(0,k.length-1));var x=k.lastIndexOf("/");return 0<x?k.substring(0,x):""},w=function(k){return k.slice(-1)!=="/"&&(k+="/"),k},S=function(k,x){return x=x!==void 0?x:d.createFolders,k=w(k),this.files[k]||i.call(this,k,null,{dir:!0,createFolders:x}),this.files[k]};function b(k){return Object.prototype.toString.call(k)==="[object RegExp]"}r.exports={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(k){var x,M,z;for(x in this.files)z=this.files[x],(M=x.slice(this.root.length,x.length))&&x.slice(0,this.root.length)===this.root&&k(M,z)},filter:function(k){var x=[];return this.forEach(function(M,z){k(M,z)&&x.push(z)}),x},file:function(k,x,M){if(arguments.length!==1)return k=this.root+k,i.call(this,k,x,M),this;if(b(k)){var z=k;return this.filter(function(F,L){return!L.dir&&z.test(F)})}var G=this.files[this.root+k];return G&&!G.dir?G:null},folder:function(k){if(!k)return this;if(b(k))return this.filter(function(G,F){return F.dir&&k.test(G)});var x=this.root+k,M=S.call(this,x),z=this.clone();return z.root=M.name,z},remove:function(k){k=this.root+k;var x=this.files[k];if(x||(k.slice(-1)!=="/"&&(k+="/"),x=this.files[k]),x&&!x.dir)delete this.files[k];else for(var M=this.filter(function(G,F){return F.name.slice(0,k.length)===k}),z=0;z<M.length;z++)delete this.files[M[z].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(k){var x,M={};try{if((M=a.extend(k||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=M.type.toLowerCase(),M.compression=M.compression.toUpperCase(),M.type==="binarystring"&&(M.type="string"),!M.type)throw new Error("No output type specified.");a.checkSupport(M.type),M.platform!=="darwin"&&M.platform!=="freebsd"&&M.platform!=="linux"&&M.platform!=="sunos"||(M.platform="UNIX"),M.platform==="win32"&&(M.platform="DOS");var z=M.comment||this.comment||"";x=g.generateWorker(this,M,z)}catch(G){(x=new l("error")).error(G)}return new u(x,M.type||"string",M.mimeType)},generateAsync:function(k,x){return this.generateInternalStream(k).accumulate(x)},generateNodeStream:function(k,x){return(k=k||{}).type||(k.type="nodebuffer"),this.generateInternalStream(k).toNodejsStream(x)}}},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,o){"use strict";r.exports=n("stream")},{stream:void 0}],17:[function(n,r,o){"use strict";var i=n("./DataReader");function s(a){i.call(this,a);for(var l=0;l<this.data.length;l++)a[l]=255&a[l]}n("../utils").inherits(s,i),s.prototype.byteAt=function(a){return this.data[this.zero+a]},s.prototype.lastIndexOfSignature=function(a){for(var l=a.charCodeAt(0),u=a.charCodeAt(1),d=a.charCodeAt(2),f=a.charCodeAt(3),p=this.length-4;0<=p;--p)if(this.data[p]===l&&this.data[p+1]===u&&this.data[p+2]===d&&this.data[p+3]===f)return p-this.zero;return-1},s.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),u=a.charCodeAt(1),d=a.charCodeAt(2),f=a.charCodeAt(3),p=this.readData(4);return l===p[0]&&u===p[1]&&d===p[2]&&f===p[3]},s.prototype.readData=function(a){if(this.checkOffset(a),a===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./DataReader":18}],18:[function(n,r,o){"use strict";var i=n("../utils");function s(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var l,u=0;for(this.checkOffset(a),l=this.index+a-1;l>=this.index;l--)u=(u<<8)+this.byteAt(l);return this.index+=a,u},readString:function(a){return i.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},r.exports=s},{"../utils":32}],19:[function(n,r,o){"use strict";var i=n("./Uint8ArrayReader");function s(a){i.call(this,a)}n("../utils").inherits(s,i),s.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(n,r,o){"use strict";var i=n("./DataReader");function s(a){i.call(this,a)}n("../utils").inherits(s,i),s.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},s.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},s.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},s.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./DataReader":18}],21:[function(n,r,o){"use strict";var i=n("./ArrayReader");function s(a){i.call(this,a)}n("../utils").inherits(s,i),s.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},r.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(n,r,o){"use strict";var i=n("../utils"),s=n("../support"),a=n("./ArrayReader"),l=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(f){var p=i.getTypeOf(f);return i.checkSupport(p),p!=="string"||s.uint8array?p==="nodebuffer"?new u(f):s.uint8array?new d(i.transformTo("uint8array",f)):new a(i.transformTo("array",f)):new l(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,o){"use strict";o.LOCAL_FILE_HEADER="PK",o.CENTRAL_FILE_HEADER="PK",o.CENTRAL_DIRECTORY_END="PK",o.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",o.ZIP64_CENTRAL_DIRECTORY_END="PK",o.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,o){"use strict";var i=n("./GenericWorker"),s=n("../utils");function a(l){i.call(this,"ConvertWorker to "+l),this.destType=l}s.inherits(a,i),a.prototype.processChunk=function(l){this.push({data:s.transformTo(this.destType,l.data),meta:l.meta})},r.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(n,r,o){"use strict";var i=n("./GenericWorker"),s=n("../crc32");function a(){i.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(a,i),a.prototype.processChunk=function(l){this.streamInfo.crc32=s(l.data,this.streamInfo.crc32||0),this.push(l)},r.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(n,r,o){"use strict";var i=n("../utils"),s=n("./GenericWorker");function a(l){s.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}i.inherits(a,s),a.prototype.processChunk=function(l){if(l){var u=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=u+l.data.length}s.prototype.processChunk.call(this,l)},r.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(n,r,o){"use strict";var i=n("../utils"),s=n("./GenericWorker");function a(l){s.call(this,"DataWorker");var u=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(d){u.dataIsReady=!0,u.data=d,u.max=d&&d.length||0,u.type=i.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}i.inherits(a,s),a.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,i.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(i.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,u);break;case"uint8array":l=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":l=this.data.slice(this.index,u)}return this.index=u,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,o){"use strict";function i(s){this.name=s||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}i.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,a){return this._listeners[s].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,a){if(this._listeners[s])for(var l=0;l<this._listeners[s].length;l++)this._listeners[s][l].call(this,a)},pipe:function(s){return s.registerPrevious(this)},registerPrevious:function(s){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=s.streamInfo,this.mergeStreamInfo(),this.previous=s;var a=this;return s.on("data",function(l){a.processChunk(l)}),s.on("end",function(){a.end()}),s.on("error",function(l){a.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var s=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),s=!0),this.previous&&this.previous.resume(),!s},flush:function(){},processChunk:function(s){this.push(s)},withStreamInfo:function(s,a){return this.extraStreamInfo[s]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var s in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,s)&&(this.streamInfo[s]=this.extraStreamInfo[s])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var s="Worker "+this.name;return this.previous?this.previous+" -> "+s:s}},r.exports=i},{}],29:[function(n,r,o){"use strict";var i=n("../utils"),s=n("./ConvertWorker"),a=n("./GenericWorker"),l=n("../base64"),u=n("../support"),d=n("../external"),f=null;if(u.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(m,v){return new d.Promise(function(C,w){var S=[],b=m._internalType,k=m._outputType,x=m._mimeType;m.on("data",function(M,z){S.push(M),v&&v(z)}).on("error",function(M){S=[],w(M)}).on("end",function(){try{C((function(M,z,G){switch(M){case"blob":return i.newBlob(i.transformTo("arraybuffer",z),G);case"base64":return l.encode(z);default:return i.transformTo(M,z)}})(k,(function(M,z){var G,F=0,L=null,$=0;for(G=0;G<z.length;G++)$+=z[G].length;switch(M){case"string":return z.join("");case"array":return Array.prototype.concat.apply([],z);case"uint8array":for(L=new Uint8Array($),G=0;G<z.length;G++)L.set(z[G],F),F+=z[G].length;return L;case"nodebuffer":return Buffer.concat(z);default:throw new Error("concat : unsupported type '"+M+"'")}})(b,S),x))}catch(M){w(M)}S=[]}).resume()})}function g(m,v,C){var w=v;switch(v){case"blob":case"arraybuffer":w="uint8array";break;case"base64":w="string"}try{this._internalType=w,this._outputType=v,this._mimeType=C,i.checkSupport(w),this._worker=m.pipe(new s(w)),m.lock()}catch(S){this._worker=new a("error"),this._worker.error(S)}}g.prototype={accumulate:function(m){return p(this,m)},on:function(m,v){var C=this;return m==="data"?this._worker.on(m,function(w){v.call(C,w.data,w.meta)}):this._worker.on(m,function(){i.delay(v,arguments,C)}),this},resume:function(){return i.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(m){if(i.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},m)}},r.exports=g},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,o){"use strict";if(o.base64=!0,o.array=!0,o.string=!0,o.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",o.nodebuffer=typeof Buffer<"u",o.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")o.blob=!1;else{var i=new ArrayBuffer(0);try{o.blob=new Blob([i],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(i),o.blob=s.getBlob("application/zip").size===0}catch{o.blob=!1}}}try{o.nodestream=!!n("readable-stream").Readable}catch{o.nodestream=!1}},{"readable-stream":16}],31:[function(n,r,o){"use strict";for(var i=n("./utils"),s=n("./support"),a=n("./nodejsUtils"),l=n("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function f(){l.call(this,"utf-8 decode"),this.leftOver=null}function p(){l.call(this,"utf-8 encode")}o.utf8encode=function(g){return s.nodebuffer?a.newBufferFrom(g,"utf-8"):(function(m){var v,C,w,S,b,k=m.length,x=0;for(S=0;S<k;S++)(64512&(C=m.charCodeAt(S)))==55296&&S+1<k&&(64512&(w=m.charCodeAt(S+1)))==56320&&(C=65536+(C-55296<<10)+(w-56320),S++),x+=C<128?1:C<2048?2:C<65536?3:4;for(v=s.uint8array?new Uint8Array(x):new Array(x),S=b=0;b<x;S++)(64512&(C=m.charCodeAt(S)))==55296&&S+1<k&&(64512&(w=m.charCodeAt(S+1)))==56320&&(C=65536+(C-55296<<10)+(w-56320),S++),C<128?v[b++]=C:(C<2048?v[b++]=192|C>>>6:(C<65536?v[b++]=224|C>>>12:(v[b++]=240|C>>>18,v[b++]=128|C>>>12&63),v[b++]=128|C>>>6&63),v[b++]=128|63&C);return v})(g)},o.utf8decode=function(g){return s.nodebuffer?i.transformTo("nodebuffer",g).toString("utf-8"):(function(m){var v,C,w,S,b=m.length,k=new Array(2*b);for(v=C=0;v<b;)if((w=m[v++])<128)k[C++]=w;else if(4<(S=u[w]))k[C++]=65533,v+=S-1;else{for(w&=S===2?31:S===3?15:7;1<S&&v<b;)w=w<<6|63&m[v++],S--;1<S?k[C++]=65533:w<65536?k[C++]=w:(w-=65536,k[C++]=55296|w>>10&1023,k[C++]=56320|1023&w)}return k.length!==C&&(k.subarray?k=k.subarray(0,C):k.length=C),i.applyFromCharCode(k)})(g=i.transformTo(s.uint8array?"uint8array":"array",g))},i.inherits(f,l),f.prototype.processChunk=function(g){var m=i.transformTo(s.uint8array?"uint8array":"array",g.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var v=m;(m=new Uint8Array(v.length+this.leftOver.length)).set(this.leftOver,0),m.set(v,this.leftOver.length)}else m=this.leftOver.concat(m);this.leftOver=null}var C=(function(S,b){var k;for((b=b||S.length)>S.length&&(b=S.length),k=b-1;0<=k&&(192&S[k])==128;)k--;return k<0||k===0?b:k+u[S[k]]>b?k:b})(m),w=m;C!==m.length&&(s.uint8array?(w=m.subarray(0,C),this.leftOver=m.subarray(C,m.length)):(w=m.slice(0,C),this.leftOver=m.slice(C,m.length))),this.push({data:o.utf8decode(w),meta:g.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:o.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},o.Utf8DecodeWorker=f,i.inherits(p,l),p.prototype.processChunk=function(g){this.push({data:o.utf8encode(g.data),meta:g.meta})},o.Utf8EncodeWorker=p},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(n,r,o){"use strict";var i=n("./support"),s=n("./base64"),a=n("./nodejsUtils"),l=n("./external");function u(v){return v}function d(v,C){for(var w=0;w<v.length;++w)C[w]=255&v.charCodeAt(w);return C}n("setimmediate"),o.newBlob=function(v,C){o.checkSupport("blob");try{return new Blob([v],{type:C})}catch{try{var w=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return w.append(v),w.getBlob(C)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(v,C,w){var S=[],b=0,k=v.length;if(k<=w)return String.fromCharCode.apply(null,v);for(;b<k;)C==="array"||C==="nodebuffer"?S.push(String.fromCharCode.apply(null,v.slice(b,Math.min(b+w,k)))):S.push(String.fromCharCode.apply(null,v.subarray(b,Math.min(b+w,k)))),b+=w;return S.join("")},stringifyByChar:function(v){for(var C="",w=0;w<v.length;w++)C+=String.fromCharCode(v[w]);return C},applyCanBeUsed:{uint8array:(function(){try{return i.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return i.nodebuffer&&String.fromCharCode.apply(null,a.allocBuffer(1)).length===1}catch{return!1}})()}};function p(v){var C=65536,w=o.getTypeOf(v),S=!0;if(w==="uint8array"?S=f.applyCanBeUsed.uint8array:w==="nodebuffer"&&(S=f.applyCanBeUsed.nodebuffer),S)for(;1<C;)try{return f.stringifyByChunk(v,w,C)}catch{C=Math.floor(C/2)}return f.stringifyByChar(v)}function g(v,C){for(var w=0;w<v.length;w++)C[w]=v[w];return C}o.applyFromCharCode=p;var m={};m.string={string:u,array:function(v){return d(v,new Array(v.length))},arraybuffer:function(v){return m.string.uint8array(v).buffer},uint8array:function(v){return d(v,new Uint8Array(v.length))},nodebuffer:function(v){return d(v,a.allocBuffer(v.length))}},m.array={string:p,array:u,arraybuffer:function(v){return new Uint8Array(v).buffer},uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return a.newBufferFrom(v)}},m.arraybuffer={string:function(v){return p(new Uint8Array(v))},array:function(v){return g(new Uint8Array(v),new Array(v.byteLength))},arraybuffer:u,uint8array:function(v){return new Uint8Array(v)},nodebuffer:function(v){return a.newBufferFrom(new Uint8Array(v))}},m.uint8array={string:p,array:function(v){return g(v,new Array(v.length))},arraybuffer:function(v){return v.buffer},uint8array:u,nodebuffer:function(v){return a.newBufferFrom(v)}},m.nodebuffer={string:p,array:function(v){return g(v,new Array(v.length))},arraybuffer:function(v){return m.nodebuffer.uint8array(v).buffer},uint8array:function(v){return g(v,new Uint8Array(v.length))},nodebuffer:u},o.transformTo=function(v,C){return C=C||"",v?(o.checkSupport(v),m[o.getTypeOf(C)][v](C)):C},o.resolve=function(v){for(var C=v.split("/"),w=[],S=0;S<C.length;S++){var b=C[S];b==="."||b===""&&S!==0&&S!==C.length-1||(b===".."?w.pop():w.push(b))}return w.join("/")},o.getTypeOf=function(v){return typeof v=="string"?"string":Object.prototype.toString.call(v)==="[object Array]"?"array":i.nodebuffer&&a.isBuffer(v)?"nodebuffer":i.uint8array&&v instanceof Uint8Array?"uint8array":i.arraybuffer&&v instanceof ArrayBuffer?"arraybuffer":void 0},o.checkSupport=function(v){if(!i[v.toLowerCase()])throw new Error(v+" is not supported by this platform")},o.MAX_VALUE_16BITS=65535,o.MAX_VALUE_32BITS=-1,o.pretty=function(v){var C,w,S="";for(w=0;w<(v||"").length;w++)S+="\\x"+((C=v.charCodeAt(w))<16?"0":"")+C.toString(16).toUpperCase();return S},o.delay=function(v,C,w){setImmediate(function(){v.apply(w||null,C||[])})},o.inherits=function(v,C){function w(){}w.prototype=C.prototype,v.prototype=new w},o.extend=function(){var v,C,w={};for(v=0;v<arguments.length;v++)for(C in arguments[v])Object.prototype.hasOwnProperty.call(arguments[v],C)&&w[C]===void 0&&(w[C]=arguments[v][C]);return w},o.prepareContent=function(v,C,w,S,b){return l.Promise.resolve(C).then(function(k){return i.blob&&(k instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(k))!==-1)&&typeof FileReader<"u"?new l.Promise(function(x,M){var z=new FileReader;z.onload=function(G){x(G.target.result)},z.onerror=function(G){M(G.target.error)},z.readAsArrayBuffer(k)}):k}).then(function(k){var x=o.getTypeOf(k);return x?(x==="arraybuffer"?k=o.transformTo("uint8array",k):x==="string"&&(b?k=s.decode(k):w&&S!==!0&&(k=(function(M){return d(M,i.uint8array?new Uint8Array(M.length):new Array(M.length))})(k))),k):l.Promise.reject(new Error("Can't read the data of '"+v+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,o){"use strict";var i=n("./reader/readerFor"),s=n("./utils"),a=n("./signature"),l=n("./zipEntry"),u=n("./support");function d(f){this.files=[],this.loadOptions=f}d.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(p)+", expected "+s.pretty(f)+")")}},isSignature:function(f,p){var g=this.reader.index;this.reader.setIndex(f);var m=this.reader.readString(4)===p;return this.reader.setIndex(g),m},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var f=this.reader.readData(this.zipCommentLength),p=u.uint8array?"uint8array":"array",g=s.transformTo(p,f);this.zipComment=this.loadOptions.decodeFileName(g)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,p,g,m=this.zip64EndOfCentralSize-44;0<m;)f=this.reader.readInt(2),p=this.reader.readInt(4),g=this.reader.readData(p),this.zip64ExtensibleData[f]={id:f,length:p,value:g}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var f,p;for(f=0;f<this.files.length;f++)p=this.files[f],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(f=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,a.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var p=f;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===s.MAX_VALUE_16BITS||this.diskWithCentralDirStart===s.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===s.MAX_VALUE_16BITS||this.centralDirRecords===s.MAX_VALUE_16BITS||this.centralDirSize===s.MAX_VALUE_32BITS||this.centralDirOffset===s.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var g=this.centralDirOffset+this.centralDirSize;this.zip64&&(g+=20,g+=12+this.zip64EndOfCentralSize);var m=p-g;if(0<m)this.isSignature(p,a.CENTRAL_FILE_HEADER)||(this.reader.zero=m);else if(m<0)throw new Error("Corrupted zip: missing "+Math.abs(m)+" bytes.")},prepareReader:function(f){this.reader=i(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,o){"use strict";var i=n("./reader/readerFor"),s=n("./utils"),a=n("./compressedObject"),l=n("./crc32"),u=n("./utf8"),d=n("./compressions"),f=n("./support");function p(g,m){this.options=g,this.loadOptions=m}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(g){var m,v;if(g.skip(22),this.fileNameLength=g.readInt(2),v=g.readInt(2),this.fileName=g.readData(this.fileNameLength),g.skip(v),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((m=(function(C){for(var w in d)if(Object.prototype.hasOwnProperty.call(d,w)&&d[w].magic===C)return d[w];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,m,g.readData(this.compressedSize))},readCentralPart:function(g){this.versionMadeBy=g.readInt(2),g.skip(2),this.bitFlag=g.readInt(2),this.compressionMethod=g.readString(2),this.date=g.readDate(),this.crc32=g.readInt(4),this.compressedSize=g.readInt(4),this.uncompressedSize=g.readInt(4);var m=g.readInt(2);if(this.extraFieldsLength=g.readInt(2),this.fileCommentLength=g.readInt(2),this.diskNumberStart=g.readInt(2),this.internalFileAttributes=g.readInt(2),this.externalFileAttributes=g.readInt(4),this.localHeaderOffset=g.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");g.skip(m),this.readExtraFields(g),this.parseZIP64ExtraField(g),this.fileComment=g.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var g=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),g==0&&(this.dosPermissions=63&this.externalFileAttributes),g==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var g=i(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=g.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=g.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=g.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=g.readInt(4))}},readExtraFields:function(g){var m,v,C,w=g.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});g.index+4<w;)m=g.readInt(2),v=g.readInt(2),C=g.readData(v),this.extraFields[m]={id:m,length:v,value:C};g.setIndex(w)},handleUTF8:function(){var g=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var m=this.findExtraFieldUnicodePath();if(m!==null)this.fileNameStr=m;else{var v=s.transformTo(g,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(v)}var C=this.findExtraFieldUnicodeComment();if(C!==null)this.fileCommentStr=C;else{var w=s.transformTo(g,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(w)}}},findExtraFieldUnicodePath:function(){var g=this.extraFields[28789];if(g){var m=i(g.value);return m.readInt(1)!==1||l(this.fileName)!==m.readInt(4)?null:u.utf8decode(m.readData(g.length-5))}return null},findExtraFieldUnicodeComment:function(){var g=this.extraFields[25461];if(g){var m=i(g.value);return m.readInt(1)!==1||l(this.fileComment)!==m.readInt(4)?null:u.utf8decode(m.readData(g.length-5))}return null}},r.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,o){"use strict";function i(m,v,C){this.name=m,this.dir=C.dir,this.date=C.date,this.comment=C.comment,this.unixPermissions=C.unixPermissions,this.dosPermissions=C.dosPermissions,this._data=v,this._dataBinary=C.binary,this.options={compression:C.compression,compressionOptions:C.compressionOptions}}var s=n("./stream/StreamHelper"),a=n("./stream/DataWorker"),l=n("./utf8"),u=n("./compressedObject"),d=n("./stream/GenericWorker");i.prototype={internalStream:function(m){var v=null,C="string";try{if(!m)throw new Error("No output type specified.");var w=(C=m.toLowerCase())==="string"||C==="text";C!=="binarystring"&&C!=="text"||(C="string"),v=this._decompressWorker();var S=!this._dataBinary;S&&!w&&(v=v.pipe(new l.Utf8EncodeWorker)),!S&&w&&(v=v.pipe(new l.Utf8DecodeWorker))}catch(b){(v=new d("error")).error(b)}return new s(v,C,"")},async:function(m,v){return this.internalStream(m).accumulate(v)},nodeStream:function(m,v){return this.internalStream(m||"nodebuffer").toNodejsStream(v)},_compressWorker:function(m,v){if(this._data instanceof u&&this._data.compression.magic===m.magic)return this._data.getCompressedWorker();var C=this._decompressWorker();return this._dataBinary||(C=C.pipe(new l.Utf8EncodeWorker)),u.createWorkerFrom(C,m,v)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new a(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},g=0;g<f.length;g++)i.prototype[f[g]]=p;r.exports=i},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,o){(function(i){"use strict";var s,a,l=i.MutationObserver||i.WebKitMutationObserver;if(l){var u=0,d=new l(m),f=i.document.createTextNode("");d.observe(f,{characterData:!0}),s=function(){f.data=u=++u%2}}else if(i.setImmediate||i.MessageChannel===void 0)s="document"in i&&"onreadystatechange"in i.document.createElement("script")?function(){var v=i.document.createElement("script");v.onreadystatechange=function(){m(),v.onreadystatechange=null,v.parentNode.removeChild(v),v=null},i.document.documentElement.appendChild(v)}:function(){setTimeout(m,0)};else{var p=new i.MessageChannel;p.port1.onmessage=m,s=function(){p.port2.postMessage(0)}}var g=[];function m(){var v,C;a=!0;for(var w=g.length;w;){for(C=g,g=[],v=-1;++v<w;)C[v]();w=g.length}a=!1}r.exports=function(v){g.push(v)!==1||a||s()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,o){"use strict";var i=n("immediate");function s(){}var a={},l=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(w){if(typeof w!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,w!==s&&v(this,w)}function p(w,S,b){this.promise=w,typeof S=="function"&&(this.onFulfilled=S,this.callFulfilled=this.otherCallFulfilled),typeof b=="function"&&(this.onRejected=b,this.callRejected=this.otherCallRejected)}function g(w,S,b){i(function(){var k;try{k=S(b)}catch(x){return a.reject(w,x)}k===w?a.reject(w,new TypeError("Cannot resolve promise with itself")):a.resolve(w,k)})}function m(w){var S=w&&w.then;if(w&&(typeof w=="object"||typeof w=="function")&&typeof S=="function")return function(){S.apply(w,arguments)}}function v(w,S){var b=!1;function k(z){b||(b=!0,a.reject(w,z))}function x(z){b||(b=!0,a.resolve(w,z))}var M=C(function(){S(x,k)});M.status==="error"&&k(M.value)}function C(w,S){var b={};try{b.value=w(S),b.status="success"}catch(k){b.status="error",b.value=k}return b}(r.exports=f).prototype.finally=function(w){if(typeof w!="function")return this;var S=this.constructor;return this.then(function(b){return S.resolve(w()).then(function(){return b})},function(b){return S.resolve(w()).then(function(){throw b})})},f.prototype.catch=function(w){return this.then(null,w)},f.prototype.then=function(w,S){if(typeof w!="function"&&this.state===u||typeof S!="function"&&this.state===l)return this;var b=new this.constructor(s);return this.state!==d?g(b,this.state===u?w:S,this.outcome):this.queue.push(new p(b,w,S)),b},p.prototype.callFulfilled=function(w){a.resolve(this.promise,w)},p.prototype.otherCallFulfilled=function(w){g(this.promise,this.onFulfilled,w)},p.prototype.callRejected=function(w){a.reject(this.promise,w)},p.prototype.otherCallRejected=function(w){g(this.promise,this.onRejected,w)},a.resolve=function(w,S){var b=C(m,S);if(b.status==="error")return a.reject(w,b.value);var k=b.value;if(k)v(w,k);else{w.state=u,w.outcome=S;for(var x=-1,M=w.queue.length;++x<M;)w.queue[x].callFulfilled(S)}return w},a.reject=function(w,S){w.state=l,w.outcome=S;for(var b=-1,k=w.queue.length;++b<k;)w.queue[b].callRejected(S);return w},f.resolve=function(w){return w instanceof this?w:a.resolve(new this(s),w)},f.reject=function(w){var S=new this(s);return a.reject(S,w)},f.all=function(w){var S=this;if(Object.prototype.toString.call(w)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=w.length,k=!1;if(!b)return this.resolve([]);for(var x=new Array(b),M=0,z=-1,G=new this(s);++z<b;)F(w[z],z);return G;function F(L,$){S.resolve(L).then(function(T){x[$]=T,++M!==b||k||(k=!0,a.resolve(G,x))},function(T){k||(k=!0,a.reject(G,T))})}},f.race=function(w){var S=this;if(Object.prototype.toString.call(w)!=="[object Array]")return this.reject(new TypeError("must be an array"));var b=w.length,k=!1;if(!b)return this.resolve([]);for(var x=-1,M=new this(s);++x<b;)z=w[x],S.resolve(z).then(function(G){k||(k=!0,a.resolve(M,G))},function(G){k||(k=!0,a.reject(M,G))});var z;return M}},{immediate:36}],38:[function(n,r,o){"use strict";var i={};(0,n("./lib/utils/common").assign)(i,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=i},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,o){"use strict";var i=n("./zlib/deflate"),s=n("./utils/common"),a=n("./utils/strings"),l=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,f=0,p=-1,g=0,m=8;function v(w){if(!(this instanceof v))return new v(w);this.options=s.assign({level:p,method:m,chunkSize:16384,windowBits:15,memLevel:8,strategy:g,to:""},w||{});var S=this.options;S.raw&&0<S.windowBits?S.windowBits=-S.windowBits:S.gzip&&0<S.windowBits&&S.windowBits<16&&(S.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var b=i.deflateInit2(this.strm,S.level,S.method,S.windowBits,S.memLevel,S.strategy);if(b!==f)throw new Error(l[b]);if(S.header&&i.deflateSetHeader(this.strm,S.header),S.dictionary){var k;if(k=typeof S.dictionary=="string"?a.string2buf(S.dictionary):d.call(S.dictionary)==="[object ArrayBuffer]"?new Uint8Array(S.dictionary):S.dictionary,(b=i.deflateSetDictionary(this.strm,k))!==f)throw new Error(l[b]);this._dict_set=!0}}function C(w,S){var b=new v(S);if(b.push(w,!0),b.err)throw b.msg||l[b.err];return b.result}v.prototype.push=function(w,S){var b,k,x=this.strm,M=this.options.chunkSize;if(this.ended)return!1;k=S===~~S?S:S===!0?4:0,typeof w=="string"?x.input=a.string2buf(w):d.call(w)==="[object ArrayBuffer]"?x.input=new Uint8Array(w):x.input=w,x.next_in=0,x.avail_in=x.input.length;do{if(x.avail_out===0&&(x.output=new s.Buf8(M),x.next_out=0,x.avail_out=M),(b=i.deflate(x,k))!==1&&b!==f)return this.onEnd(b),!(this.ended=!0);x.avail_out!==0&&(x.avail_in!==0||k!==4&&k!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(s.shrinkBuf(x.output,x.next_out))):this.onData(s.shrinkBuf(x.output,x.next_out)))}while((0<x.avail_in||x.avail_out===0)&&b!==1);return k===4?(b=i.deflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===f):k!==2||(this.onEnd(f),!(x.avail_out=0))},v.prototype.onData=function(w){this.chunks.push(w)},v.prototype.onEnd=function(w){w===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=w,this.msg=this.strm.msg},o.Deflate=v,o.deflate=C,o.deflateRaw=function(w,S){return(S=S||{}).raw=!0,C(w,S)},o.gzip=function(w,S){return(S=S||{}).gzip=!0,C(w,S)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,o){"use strict";var i=n("./zlib/inflate"),s=n("./utils/common"),a=n("./utils/strings"),l=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),f=n("./zlib/gzheader"),p=Object.prototype.toString;function g(v){if(!(this instanceof g))return new g(v);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},v||{});var C=this.options;C.raw&&0<=C.windowBits&&C.windowBits<16&&(C.windowBits=-C.windowBits,C.windowBits===0&&(C.windowBits=-15)),!(0<=C.windowBits&&C.windowBits<16)||v&&v.windowBits||(C.windowBits+=32),15<C.windowBits&&C.windowBits<48&&(15&C.windowBits)==0&&(C.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var w=i.inflateInit2(this.strm,C.windowBits);if(w!==l.Z_OK)throw new Error(u[w]);this.header=new f,i.inflateGetHeader(this.strm,this.header)}function m(v,C){var w=new g(C);if(w.push(v,!0),w.err)throw w.msg||u[w.err];return w.result}g.prototype.push=function(v,C){var w,S,b,k,x,M,z=this.strm,G=this.options.chunkSize,F=this.options.dictionary,L=!1;if(this.ended)return!1;S=C===~~C?C:C===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof v=="string"?z.input=a.binstring2buf(v):p.call(v)==="[object ArrayBuffer]"?z.input=new Uint8Array(v):z.input=v,z.next_in=0,z.avail_in=z.input.length;do{if(z.avail_out===0&&(z.output=new s.Buf8(G),z.next_out=0,z.avail_out=G),(w=i.inflate(z,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&F&&(M=typeof F=="string"?a.string2buf(F):p.call(F)==="[object ArrayBuffer]"?new Uint8Array(F):F,w=i.inflateSetDictionary(this.strm,M)),w===l.Z_BUF_ERROR&&L===!0&&(w=l.Z_OK,L=!1),w!==l.Z_STREAM_END&&w!==l.Z_OK)return this.onEnd(w),!(this.ended=!0);z.next_out&&(z.avail_out!==0&&w!==l.Z_STREAM_END&&(z.avail_in!==0||S!==l.Z_FINISH&&S!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(b=a.utf8border(z.output,z.next_out),k=z.next_out-b,x=a.buf2string(z.output,b),z.next_out=k,z.avail_out=G-k,k&&s.arraySet(z.output,z.output,b,k,0),this.onData(x)):this.onData(s.shrinkBuf(z.output,z.next_out)))),z.avail_in===0&&z.avail_out===0&&(L=!0)}while((0<z.avail_in||z.avail_out===0)&&w!==l.Z_STREAM_END);return w===l.Z_STREAM_END&&(S=l.Z_FINISH),S===l.Z_FINISH?(w=i.inflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===l.Z_OK):S!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(z.avail_out=0))},g.prototype.onData=function(v){this.chunks.push(v)},g.prototype.onEnd=function(v){v===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=v,this.msg=this.strm.msg},o.Inflate=g,o.inflate=m,o.inflateRaw=function(v,C){return(C=C||{}).raw=!0,m(v,C)},o.ungzip=m},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(n,r,o){"use strict";var i=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";o.assign=function(l){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(l[f]=d[f])}}return l},o.shrinkBuf=function(l,u){return l.length===u?l:l.subarray?l.subarray(0,u):(l.length=u,l)};var s={arraySet:function(l,u,d,f,p){if(u.subarray&&l.subarray)l.set(u.subarray(d,d+f),p);else for(var g=0;g<f;g++)l[p+g]=u[d+g]},flattenChunks:function(l){var u,d,f,p,g,m;for(u=f=0,d=l.length;u<d;u++)f+=l[u].length;for(m=new Uint8Array(f),u=p=0,d=l.length;u<d;u++)g=l[u],m.set(g,p),p+=g.length;return m}},a={arraySet:function(l,u,d,f,p){for(var g=0;g<f;g++)l[p+g]=u[d+g]},flattenChunks:function(l){return[].concat.apply([],l)}};o.setTyped=function(l){l?(o.Buf8=Uint8Array,o.Buf16=Uint16Array,o.Buf32=Int32Array,o.assign(o,s)):(o.Buf8=Array,o.Buf16=Array,o.Buf32=Array,o.assign(o,a))},o.setTyped(i)},{}],42:[function(n,r,o){"use strict";var i=n("./common"),s=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var l=new i.Buf8(256),u=0;u<256;u++)l[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(f,p){if(p<65537&&(f.subarray&&a||!f.subarray&&s))return String.fromCharCode.apply(null,i.shrinkBuf(f,p));for(var g="",m=0;m<p;m++)g+=String.fromCharCode(f[m]);return g}l[254]=l[254]=1,o.string2buf=function(f){var p,g,m,v,C,w=f.length,S=0;for(v=0;v<w;v++)(64512&(g=f.charCodeAt(v)))==55296&&v+1<w&&(64512&(m=f.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(m-56320),v++),S+=g<128?1:g<2048?2:g<65536?3:4;for(p=new i.Buf8(S),v=C=0;C<S;v++)(64512&(g=f.charCodeAt(v)))==55296&&v+1<w&&(64512&(m=f.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(m-56320),v++),g<128?p[C++]=g:(g<2048?p[C++]=192|g>>>6:(g<65536?p[C++]=224|g>>>12:(p[C++]=240|g>>>18,p[C++]=128|g>>>12&63),p[C++]=128|g>>>6&63),p[C++]=128|63&g);return p},o.buf2binstring=function(f){return d(f,f.length)},o.binstring2buf=function(f){for(var p=new i.Buf8(f.length),g=0,m=p.length;g<m;g++)p[g]=f.charCodeAt(g);return p},o.buf2string=function(f,p){var g,m,v,C,w=p||f.length,S=new Array(2*w);for(g=m=0;g<w;)if((v=f[g++])<128)S[m++]=v;else if(4<(C=l[v]))S[m++]=65533,g+=C-1;else{for(v&=C===2?31:C===3?15:7;1<C&&g<w;)v=v<<6|63&f[g++],C--;1<C?S[m++]=65533:v<65536?S[m++]=v:(v-=65536,S[m++]=55296|v>>10&1023,S[m++]=56320|1023&v)}return d(S,m)},o.utf8border=function(f,p){var g;for((p=p||f.length)>f.length&&(p=f.length),g=p-1;0<=g&&(192&f[g])==128;)g--;return g<0||g===0?p:g+l[f[g]]>p?g:p}},{"./common":41}],43:[function(n,r,o){"use strict";r.exports=function(i,s,a,l){for(var u=65535&i|0,d=i>>>16&65535|0,f=0;a!==0;){for(a-=f=2e3<a?2e3:a;d=d+(u=u+s[l++]|0)|0,--f;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(n,r,o){"use strict";r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,o){"use strict";var i=(function(){for(var s,a=[],l=0;l<256;l++){s=l;for(var u=0;u<8;u++)s=1&s?3988292384^s>>>1:s>>>1;a[l]=s}return a})();r.exports=function(s,a,l,u){var d=i,f=u+l;s^=-1;for(var p=u;p<f;p++)s=s>>>8^d[255&(s^a[p])];return-1^s}},{}],46:[function(n,r,o){"use strict";var i,s=n("../utils/common"),a=n("./trees"),l=n("./adler32"),u=n("./crc32"),d=n("./messages"),f=0,p=4,g=0,m=-2,v=-1,C=4,w=2,S=8,b=9,k=286,x=30,M=19,z=2*k+1,G=15,F=3,L=258,$=L+F+1,T=42,H=113,R=1,U=2,W=3,ee=4;function J(I,re){return I.msg=d[re],re}function Z(I){return(I<<1)-(4<I?9:0)}function Me(I){for(var re=I.length;0<=--re;)I[re]=0}function fe(I){var re=I.state,j=re.pending;j>I.avail_out&&(j=I.avail_out),j!==0&&(s.arraySet(I.output,re.pending_buf,re.pending_out,j,I.next_out),I.next_out+=j,re.pending_out+=j,I.total_out+=j,I.avail_out-=j,re.pending-=j,re.pending===0&&(re.pending_out=0))}function ye(I,re){a._tr_flush_block(I,0<=I.block_start?I.block_start:-1,I.strstart-I.block_start,re),I.block_start=I.strstart,fe(I.strm)}function ve(I,re){I.pending_buf[I.pending++]=re}function Pe(I,re){I.pending_buf[I.pending++]=re>>>8&255,I.pending_buf[I.pending++]=255&re}function Ve(I,re){var j,X,K=I.max_chain_length,ae=I.strstart,ke=I.prev_length,P=I.nice_match,N=I.strstart>I.w_size-$?I.strstart-(I.w_size-$):0,me=I.window,Se=I.w_mask,Re=I.prev,ze=I.strstart+L,Ke=me[ae+ke-1],ot=me[ae+ke];I.prev_length>=I.good_match&&(K>>=2),P>I.lookahead&&(P=I.lookahead);do if(me[(j=re)+ke]===ot&&me[j+ke-1]===Ke&&me[j]===me[ae]&&me[++j]===me[ae+1]){ae+=2,j++;do;while(me[++ae]===me[++j]&&me[++ae]===me[++j]&&me[++ae]===me[++j]&&me[++ae]===me[++j]&&me[++ae]===me[++j]&&me[++ae]===me[++j]&&me[++ae]===me[++j]&&me[++ae]===me[++j]&&ae<ze);if(X=L-(ze-ae),ae=ze-L,ke<X){if(I.match_start=re,P<=(ke=X))break;Ke=me[ae+ke-1],ot=me[ae+ke]}}while((re=Re[re&Se])>N&&--K!=0);return ke<=I.lookahead?ke:I.lookahead}function nt(I){var re,j,X,K,ae,ke,P,N,me,Se,Re=I.w_size;do{if(K=I.window_size-I.lookahead-I.strstart,I.strstart>=Re+(Re-$)){for(s.arraySet(I.window,I.window,Re,Re,0),I.match_start-=Re,I.strstart-=Re,I.block_start-=Re,re=j=I.hash_size;X=I.head[--re],I.head[re]=Re<=X?X-Re:0,--j;);for(re=j=Re;X=I.prev[--re],I.prev[re]=Re<=X?X-Re:0,--j;);K+=Re}if(I.strm.avail_in===0)break;if(ke=I.strm,P=I.window,N=I.strstart+I.lookahead,me=K,Se=void 0,Se=ke.avail_in,me<Se&&(Se=me),j=Se===0?0:(ke.avail_in-=Se,s.arraySet(P,ke.input,ke.next_in,Se,N),ke.state.wrap===1?ke.adler=l(ke.adler,P,Se,N):ke.state.wrap===2&&(ke.adler=u(ke.adler,P,Se,N)),ke.next_in+=Se,ke.total_in+=Se,Se),I.lookahead+=j,I.lookahead+I.insert>=F)for(ae=I.strstart-I.insert,I.ins_h=I.window[ae],I.ins_h=(I.ins_h<<I.hash_shift^I.window[ae+1])&I.hash_mask;I.insert&&(I.ins_h=(I.ins_h<<I.hash_shift^I.window[ae+F-1])&I.hash_mask,I.prev[ae&I.w_mask]=I.head[I.ins_h],I.head[I.ins_h]=ae,ae++,I.insert--,!(I.lookahead+I.insert<F)););}while(I.lookahead<$&&I.strm.avail_in!==0)}function ct(I,re){for(var j,X;;){if(I.lookahead<$){if(nt(I),I.lookahead<$&&re===f)return R;if(I.lookahead===0)break}if(j=0,I.lookahead>=F&&(I.ins_h=(I.ins_h<<I.hash_shift^I.window[I.strstart+F-1])&I.hash_mask,j=I.prev[I.strstart&I.w_mask]=I.head[I.ins_h],I.head[I.ins_h]=I.strstart),j!==0&&I.strstart-j<=I.w_size-$&&(I.match_length=Ve(I,j)),I.match_length>=F)if(X=a._tr_tally(I,I.strstart-I.match_start,I.match_length-F),I.lookahead-=I.match_length,I.match_length<=I.max_lazy_match&&I.lookahead>=F){for(I.match_length--;I.strstart++,I.ins_h=(I.ins_h<<I.hash_shift^I.window[I.strstart+F-1])&I.hash_mask,j=I.prev[I.strstart&I.w_mask]=I.head[I.ins_h],I.head[I.ins_h]=I.strstart,--I.match_length!=0;);I.strstart++}else I.strstart+=I.match_length,I.match_length=0,I.ins_h=I.window[I.strstart],I.ins_h=(I.ins_h<<I.hash_shift^I.window[I.strstart+1])&I.hash_mask;else X=a._tr_tally(I,0,I.window[I.strstart]),I.lookahead--,I.strstart++;if(X&&(ye(I,!1),I.strm.avail_out===0))return R}return I.insert=I.strstart<F-1?I.strstart:F-1,re===p?(ye(I,!0),I.strm.avail_out===0?W:ee):I.last_lit&&(ye(I,!1),I.strm.avail_out===0)?R:U}function ft(I,re){for(var j,X,K;;){if(I.lookahead<$){if(nt(I),I.lookahead<$&&re===f)return R;if(I.lookahead===0)break}if(j=0,I.lookahead>=F&&(I.ins_h=(I.ins_h<<I.hash_shift^I.window[I.strstart+F-1])&I.hash_mask,j=I.prev[I.strstart&I.w_mask]=I.head[I.ins_h],I.head[I.ins_h]=I.strstart),I.prev_length=I.match_length,I.prev_match=I.match_start,I.match_length=F-1,j!==0&&I.prev_length<I.max_lazy_match&&I.strstart-j<=I.w_size-$&&(I.match_length=Ve(I,j),I.match_length<=5&&(I.strategy===1||I.match_length===F&&4096<I.strstart-I.match_start)&&(I.match_length=F-1)),I.prev_length>=F&&I.match_length<=I.prev_length){for(K=I.strstart+I.lookahead-F,X=a._tr_tally(I,I.strstart-1-I.prev_match,I.prev_length-F),I.lookahead-=I.prev_length-1,I.prev_length-=2;++I.strstart<=K&&(I.ins_h=(I.ins_h<<I.hash_shift^I.window[I.strstart+F-1])&I.hash_mask,j=I.prev[I.strstart&I.w_mask]=I.head[I.ins_h],I.head[I.ins_h]=I.strstart),--I.prev_length!=0;);if(I.match_available=0,I.match_length=F-1,I.strstart++,X&&(ye(I,!1),I.strm.avail_out===0))return R}else if(I.match_available){if((X=a._tr_tally(I,0,I.window[I.strstart-1]))&&ye(I,!1),I.strstart++,I.lookahead--,I.strm.avail_out===0)return R}else I.match_available=1,I.strstart++,I.lookahead--}return I.match_available&&(X=a._tr_tally(I,0,I.window[I.strstart-1]),I.match_available=0),I.insert=I.strstart<F-1?I.strstart:F-1,re===p?(ye(I,!0),I.strm.avail_out===0?W:ee):I.last_lit&&(ye(I,!1),I.strm.avail_out===0)?R:U}function It(I,re,j,X,K){this.good_length=I,this.max_lazy=re,this.nice_length=j,this.max_chain=X,this.func=K}function Le(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=S,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new s.Buf16(2*z),this.dyn_dtree=new s.Buf16(2*(2*x+1)),this.bl_tree=new s.Buf16(2*(2*M+1)),Me(this.dyn_ltree),Me(this.dyn_dtree),Me(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(G+1),this.heap=new s.Buf16(2*k+1),Me(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*k+1),Me(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function oe(I){var re;return I&&I.state?(I.total_in=I.total_out=0,I.data_type=w,(re=I.state).pending=0,re.pending_out=0,re.wrap<0&&(re.wrap=-re.wrap),re.status=re.wrap?T:H,I.adler=re.wrap===2?0:1,re.last_flush=f,a._tr_init(re),g):J(I,m)}function we(I){var re=oe(I);return re===g&&(function(j){j.window_size=2*j.w_size,Me(j.head),j.max_lazy_match=i[j.level].max_lazy,j.good_match=i[j.level].good_length,j.nice_match=i[j.level].nice_length,j.max_chain_length=i[j.level].max_chain,j.strstart=0,j.block_start=0,j.lookahead=0,j.insert=0,j.match_length=j.prev_length=F-1,j.match_available=0,j.ins_h=0})(I.state),re}function Q(I,re,j,X,K,ae){if(!I)return m;var ke=1;if(re===v&&(re=6),X<0?(ke=0,X=-X):15<X&&(ke=2,X-=16),K<1||b<K||j!==S||X<8||15<X||re<0||9<re||ae<0||C<ae)return J(I,m);X===8&&(X=9);var P=new Le;return(I.state=P).strm=I,P.wrap=ke,P.gzhead=null,P.w_bits=X,P.w_size=1<<P.w_bits,P.w_mask=P.w_size-1,P.hash_bits=K+7,P.hash_size=1<<P.hash_bits,P.hash_mask=P.hash_size-1,P.hash_shift=~~((P.hash_bits+F-1)/F),P.window=new s.Buf8(2*P.w_size),P.head=new s.Buf16(P.hash_size),P.prev=new s.Buf16(P.w_size),P.lit_bufsize=1<<K+6,P.pending_buf_size=4*P.lit_bufsize,P.pending_buf=new s.Buf8(P.pending_buf_size),P.d_buf=1*P.lit_bufsize,P.l_buf=3*P.lit_bufsize,P.level=re,P.strategy=ae,P.method=j,we(I)}i=[new It(0,0,0,0,function(I,re){var j=65535;for(j>I.pending_buf_size-5&&(j=I.pending_buf_size-5);;){if(I.lookahead<=1){if(nt(I),I.lookahead===0&&re===f)return R;if(I.lookahead===0)break}I.strstart+=I.lookahead,I.lookahead=0;var X=I.block_start+j;if((I.strstart===0||I.strstart>=X)&&(I.lookahead=I.strstart-X,I.strstart=X,ye(I,!1),I.strm.avail_out===0)||I.strstart-I.block_start>=I.w_size-$&&(ye(I,!1),I.strm.avail_out===0))return R}return I.insert=0,re===p?(ye(I,!0),I.strm.avail_out===0?W:ee):(I.strstart>I.block_start&&(ye(I,!1),I.strm.avail_out),R)}),new It(4,4,8,4,ct),new It(4,5,16,8,ct),new It(4,6,32,32,ct),new It(4,4,16,16,ft),new It(8,16,32,32,ft),new It(8,16,128,128,ft),new It(8,32,128,256,ft),new It(32,128,258,1024,ft),new It(32,258,258,4096,ft)],o.deflateInit=function(I,re){return Q(I,re,S,15,8,0)},o.deflateInit2=Q,o.deflateReset=we,o.deflateResetKeep=oe,o.deflateSetHeader=function(I,re){return I&&I.state?I.state.wrap!==2?m:(I.state.gzhead=re,g):m},o.deflate=function(I,re){var j,X,K,ae;if(!I||!I.state||5<re||re<0)return I?J(I,m):m;if(X=I.state,!I.output||!I.input&&I.avail_in!==0||X.status===666&&re!==p)return J(I,I.avail_out===0?-5:m);if(X.strm=I,j=X.last_flush,X.last_flush=re,X.status===T)if(X.wrap===2)I.adler=0,ve(X,31),ve(X,139),ve(X,8),X.gzhead?(ve(X,(X.gzhead.text?1:0)+(X.gzhead.hcrc?2:0)+(X.gzhead.extra?4:0)+(X.gzhead.name?8:0)+(X.gzhead.comment?16:0)),ve(X,255&X.gzhead.time),ve(X,X.gzhead.time>>8&255),ve(X,X.gzhead.time>>16&255),ve(X,X.gzhead.time>>24&255),ve(X,X.level===9?2:2<=X.strategy||X.level<2?4:0),ve(X,255&X.gzhead.os),X.gzhead.extra&&X.gzhead.extra.length&&(ve(X,255&X.gzhead.extra.length),ve(X,X.gzhead.extra.length>>8&255)),X.gzhead.hcrc&&(I.adler=u(I.adler,X.pending_buf,X.pending,0)),X.gzindex=0,X.status=69):(ve(X,0),ve(X,0),ve(X,0),ve(X,0),ve(X,0),ve(X,X.level===9?2:2<=X.strategy||X.level<2?4:0),ve(X,3),X.status=H);else{var ke=S+(X.w_bits-8<<4)<<8;ke|=(2<=X.strategy||X.level<2?0:X.level<6?1:X.level===6?2:3)<<6,X.strstart!==0&&(ke|=32),ke+=31-ke%31,X.status=H,Pe(X,ke),X.strstart!==0&&(Pe(X,I.adler>>>16),Pe(X,65535&I.adler)),I.adler=1}if(X.status===69)if(X.gzhead.extra){for(K=X.pending;X.gzindex<(65535&X.gzhead.extra.length)&&(X.pending!==X.pending_buf_size||(X.gzhead.hcrc&&X.pending>K&&(I.adler=u(I.adler,X.pending_buf,X.pending-K,K)),fe(I),K=X.pending,X.pending!==X.pending_buf_size));)ve(X,255&X.gzhead.extra[X.gzindex]),X.gzindex++;X.gzhead.hcrc&&X.pending>K&&(I.adler=u(I.adler,X.pending_buf,X.pending-K,K)),X.gzindex===X.gzhead.extra.length&&(X.gzindex=0,X.status=73)}else X.status=73;if(X.status===73)if(X.gzhead.name){K=X.pending;do{if(X.pending===X.pending_buf_size&&(X.gzhead.hcrc&&X.pending>K&&(I.adler=u(I.adler,X.pending_buf,X.pending-K,K)),fe(I),K=X.pending,X.pending===X.pending_buf_size)){ae=1;break}ae=X.gzindex<X.gzhead.name.length?255&X.gzhead.name.charCodeAt(X.gzindex++):0,ve(X,ae)}while(ae!==0);X.gzhead.hcrc&&X.pending>K&&(I.adler=u(I.adler,X.pending_buf,X.pending-K,K)),ae===0&&(X.gzindex=0,X.status=91)}else X.status=91;if(X.status===91)if(X.gzhead.comment){K=X.pending;do{if(X.pending===X.pending_buf_size&&(X.gzhead.hcrc&&X.pending>K&&(I.adler=u(I.adler,X.pending_buf,X.pending-K,K)),fe(I),K=X.pending,X.pending===X.pending_buf_size)){ae=1;break}ae=X.gzindex<X.gzhead.comment.length?255&X.gzhead.comment.charCodeAt(X.gzindex++):0,ve(X,ae)}while(ae!==0);X.gzhead.hcrc&&X.pending>K&&(I.adler=u(I.adler,X.pending_buf,X.pending-K,K)),ae===0&&(X.status=103)}else X.status=103;if(X.status===103&&(X.gzhead.hcrc?(X.pending+2>X.pending_buf_size&&fe(I),X.pending+2<=X.pending_buf_size&&(ve(X,255&I.adler),ve(X,I.adler>>8&255),I.adler=0,X.status=H)):X.status=H),X.pending!==0){if(fe(I),I.avail_out===0)return X.last_flush=-1,g}else if(I.avail_in===0&&Z(re)<=Z(j)&&re!==p)return J(I,-5);if(X.status===666&&I.avail_in!==0)return J(I,-5);if(I.avail_in!==0||X.lookahead!==0||re!==f&&X.status!==666){var P=X.strategy===2?(function(N,me){for(var Se;;){if(N.lookahead===0&&(nt(N),N.lookahead===0)){if(me===f)return R;break}if(N.match_length=0,Se=a._tr_tally(N,0,N.window[N.strstart]),N.lookahead--,N.strstart++,Se&&(ye(N,!1),N.strm.avail_out===0))return R}return N.insert=0,me===p?(ye(N,!0),N.strm.avail_out===0?W:ee):N.last_lit&&(ye(N,!1),N.strm.avail_out===0)?R:U})(X,re):X.strategy===3?(function(N,me){for(var Se,Re,ze,Ke,ot=N.window;;){if(N.lookahead<=L){if(nt(N),N.lookahead<=L&&me===f)return R;if(N.lookahead===0)break}if(N.match_length=0,N.lookahead>=F&&0<N.strstart&&(Re=ot[ze=N.strstart-1])===ot[++ze]&&Re===ot[++ze]&&Re===ot[++ze]){Ke=N.strstart+L;do;while(Re===ot[++ze]&&Re===ot[++ze]&&Re===ot[++ze]&&Re===ot[++ze]&&Re===ot[++ze]&&Re===ot[++ze]&&Re===ot[++ze]&&Re===ot[++ze]&&ze<Ke);N.match_length=L-(Ke-ze),N.match_length>N.lookahead&&(N.match_length=N.lookahead)}if(N.match_length>=F?(Se=a._tr_tally(N,1,N.match_length-F),N.lookahead-=N.match_length,N.strstart+=N.match_length,N.match_length=0):(Se=a._tr_tally(N,0,N.window[N.strstart]),N.lookahead--,N.strstart++),Se&&(ye(N,!1),N.strm.avail_out===0))return R}return N.insert=0,me===p?(ye(N,!0),N.strm.avail_out===0?W:ee):N.last_lit&&(ye(N,!1),N.strm.avail_out===0)?R:U})(X,re):i[X.level].func(X,re);if(P!==W&&P!==ee||(X.status=666),P===R||P===W)return I.avail_out===0&&(X.last_flush=-1),g;if(P===U&&(re===1?a._tr_align(X):re!==5&&(a._tr_stored_block(X,0,0,!1),re===3&&(Me(X.head),X.lookahead===0&&(X.strstart=0,X.block_start=0,X.insert=0))),fe(I),I.avail_out===0))return X.last_flush=-1,g}return re!==p?g:X.wrap<=0?1:(X.wrap===2?(ve(X,255&I.adler),ve(X,I.adler>>8&255),ve(X,I.adler>>16&255),ve(X,I.adler>>24&255),ve(X,255&I.total_in),ve(X,I.total_in>>8&255),ve(X,I.total_in>>16&255),ve(X,I.total_in>>24&255)):(Pe(X,I.adler>>>16),Pe(X,65535&I.adler)),fe(I),0<X.wrap&&(X.wrap=-X.wrap),X.pending!==0?g:1)},o.deflateEnd=function(I){var re;return I&&I.state?(re=I.state.status)!==T&&re!==69&&re!==73&&re!==91&&re!==103&&re!==H&&re!==666?J(I,m):(I.state=null,re===H?J(I,-3):g):m},o.deflateSetDictionary=function(I,re){var j,X,K,ae,ke,P,N,me,Se=re.length;if(!I||!I.state||(ae=(j=I.state).wrap)===2||ae===1&&j.status!==T||j.lookahead)return m;for(ae===1&&(I.adler=l(I.adler,re,Se,0)),j.wrap=0,Se>=j.w_size&&(ae===0&&(Me(j.head),j.strstart=0,j.block_start=0,j.insert=0),me=new s.Buf8(j.w_size),s.arraySet(me,re,Se-j.w_size,j.w_size,0),re=me,Se=j.w_size),ke=I.avail_in,P=I.next_in,N=I.input,I.avail_in=Se,I.next_in=0,I.input=re,nt(j);j.lookahead>=F;){for(X=j.strstart,K=j.lookahead-(F-1);j.ins_h=(j.ins_h<<j.hash_shift^j.window[X+F-1])&j.hash_mask,j.prev[X&j.w_mask]=j.head[j.ins_h],j.head[j.ins_h]=X,X++,--K;);j.strstart=X,j.lookahead=F-1,nt(j)}return j.strstart+=j.lookahead,j.block_start=j.strstart,j.insert=j.lookahead,j.lookahead=0,j.match_length=j.prev_length=F-1,j.match_available=0,I.next_in=P,I.input=N,I.avail_in=ke,j.wrap=ae,g},o.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,o){"use strict";r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,o){"use strict";r.exports=function(i,s){var a=i.state,l=i.next_in,u,d,f,p,g,m,v,C,w,S,b,k,x,M,z,G,F,L,$,T,H,R=i.input,U;u=l+(i.avail_in-5),d=i.next_out,U=i.output,f=d-(s-i.avail_out),p=d+(i.avail_out-257),g=a.dmax,m=a.wsize,v=a.whave,C=a.wnext,w=a.window,S=a.hold,b=a.bits,k=a.lencode,x=a.distcode,M=(1<<a.lenbits)-1,z=(1<<a.distbits)-1;e:do{b<15&&(S+=R[l++]<<b,b+=8,S+=R[l++]<<b,b+=8),G=k[S&M];t:for(;;){if(S>>>=F=G>>>24,b-=F,(F=G>>>16&255)===0)U[d++]=65535&G;else{if(!(16&F)){if((64&F)==0){G=k[(65535&G)+(S&(1<<F)-1)];continue t}if(32&F){a.mode=12;break e}i.msg="invalid literal/length code",a.mode=30;break e}L=65535&G,(F&=15)&&(b<F&&(S+=R[l++]<<b,b+=8),L+=S&(1<<F)-1,S>>>=F,b-=F),b<15&&(S+=R[l++]<<b,b+=8,S+=R[l++]<<b,b+=8),G=x[S&z];n:for(;;){if(S>>>=F=G>>>24,b-=F,!(16&(F=G>>>16&255))){if((64&F)==0){G=x[(65535&G)+(S&(1<<F)-1)];continue n}i.msg="invalid distance code",a.mode=30;break e}if($=65535&G,b<(F&=15)&&(S+=R[l++]<<b,(b+=8)<F&&(S+=R[l++]<<b,b+=8)),g<($+=S&(1<<F)-1)){i.msg="invalid distance too far back",a.mode=30;break e}if(S>>>=F,b-=F,(F=d-f)<$){if(v<(F=$-F)&&a.sane){i.msg="invalid distance too far back",a.mode=30;break e}if(H=w,(T=0)===C){if(T+=m-F,F<L){for(L-=F;U[d++]=w[T++],--F;);T=d-$,H=U}}else if(C<F){if(T+=m+C-F,(F-=C)<L){for(L-=F;U[d++]=w[T++],--F;);if(T=0,C<L){for(L-=F=C;U[d++]=w[T++],--F;);T=d-$,H=U}}}else if(T+=C-F,F<L){for(L-=F;U[d++]=w[T++],--F;);T=d-$,H=U}for(;2<L;)U[d++]=H[T++],U[d++]=H[T++],U[d++]=H[T++],L-=3;L&&(U[d++]=H[T++],1<L&&(U[d++]=H[T++]))}else{for(T=d-$;U[d++]=U[T++],U[d++]=U[T++],U[d++]=U[T++],2<(L-=3););L&&(U[d++]=U[T++],1<L&&(U[d++]=U[T++]))}break}}break}}while(l<u&&d<p);l-=L=b>>3,S&=(1<<(b-=L<<3))-1,i.next_in=l,i.next_out=d,i.avail_in=l<u?u-l+5:5-(l-u),i.avail_out=d<p?p-d+257:257-(d-p),a.hold=S,a.bits=b}},{}],49:[function(n,r,o){"use strict";var i=n("../utils/common"),s=n("./adler32"),a=n("./crc32"),l=n("./inffast"),u=n("./inftrees"),d=1,f=2,p=0,g=-2,m=1,v=852,C=592;function w(T){return(T>>>24&255)+(T>>>8&65280)+((65280&T)<<8)+((255&T)<<24)}function S(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new i.Buf16(320),this.work=new i.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function b(T){var H;return T&&T.state?(H=T.state,T.total_in=T.total_out=H.total=0,T.msg="",H.wrap&&(T.adler=1&H.wrap),H.mode=m,H.last=0,H.havedict=0,H.dmax=32768,H.head=null,H.hold=0,H.bits=0,H.lencode=H.lendyn=new i.Buf32(v),H.distcode=H.distdyn=new i.Buf32(C),H.sane=1,H.back=-1,p):g}function k(T){var H;return T&&T.state?((H=T.state).wsize=0,H.whave=0,H.wnext=0,b(T)):g}function x(T,H){var R,U;return T&&T.state?(U=T.state,H<0?(R=0,H=-H):(R=1+(H>>4),H<48&&(H&=15)),H&&(H<8||15<H)?g:(U.window!==null&&U.wbits!==H&&(U.window=null),U.wrap=R,U.wbits=H,k(T))):g}function M(T,H){var R,U;return T?(U=new S,(T.state=U).window=null,(R=x(T,H))!==p&&(T.state=null),R):g}var z,G,F=!0;function L(T){if(F){var H;for(z=new i.Buf32(512),G=new i.Buf32(32),H=0;H<144;)T.lens[H++]=8;for(;H<256;)T.lens[H++]=9;for(;H<280;)T.lens[H++]=7;for(;H<288;)T.lens[H++]=8;for(u(d,T.lens,0,288,z,0,T.work,{bits:9}),H=0;H<32;)T.lens[H++]=5;u(f,T.lens,0,32,G,0,T.work,{bits:5}),F=!1}T.lencode=z,T.lenbits=9,T.distcode=G,T.distbits=5}function $(T,H,R,U){var W,ee=T.state;return ee.window===null&&(ee.wsize=1<<ee.wbits,ee.wnext=0,ee.whave=0,ee.window=new i.Buf8(ee.wsize)),U>=ee.wsize?(i.arraySet(ee.window,H,R-ee.wsize,ee.wsize,0),ee.wnext=0,ee.whave=ee.wsize):(U<(W=ee.wsize-ee.wnext)&&(W=U),i.arraySet(ee.window,H,R-U,W,ee.wnext),(U-=W)?(i.arraySet(ee.window,H,R-U,U,0),ee.wnext=U,ee.whave=ee.wsize):(ee.wnext+=W,ee.wnext===ee.wsize&&(ee.wnext=0),ee.whave<ee.wsize&&(ee.whave+=W))),0}o.inflateReset=k,o.inflateReset2=x,o.inflateResetKeep=b,o.inflateInit=function(T){return M(T,15)},o.inflateInit2=M,o.inflate=function(T,H){var R,U,W,ee,J,Z,Me,fe,ye,ve,Pe,Ve,nt,ct,ft,It,Le,oe,we,Q,I,re,j,X,K=0,ae=new i.Buf8(4),ke=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!T||!T.state||!T.output||!T.input&&T.avail_in!==0)return g;(R=T.state).mode===12&&(R.mode=13),J=T.next_out,W=T.output,Me=T.avail_out,ee=T.next_in,U=T.input,Z=T.avail_in,fe=R.hold,ye=R.bits,ve=Z,Pe=Me,re=p;e:for(;;)switch(R.mode){case m:if(R.wrap===0){R.mode=13;break}for(;ye<16;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}if(2&R.wrap&&fe===35615){ae[R.check=0]=255&fe,ae[1]=fe>>>8&255,R.check=a(R.check,ae,2,0),ye=fe=0,R.mode=2;break}if(R.flags=0,R.head&&(R.head.done=!1),!(1&R.wrap)||(((255&fe)<<8)+(fe>>8))%31){T.msg="incorrect header check",R.mode=30;break}if((15&fe)!=8){T.msg="unknown compression method",R.mode=30;break}if(ye-=4,I=8+(15&(fe>>>=4)),R.wbits===0)R.wbits=I;else if(I>R.wbits){T.msg="invalid window size",R.mode=30;break}R.dmax=1<<I,T.adler=R.check=1,R.mode=512&fe?10:12,ye=fe=0;break;case 2:for(;ye<16;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}if(R.flags=fe,(255&R.flags)!=8){T.msg="unknown compression method",R.mode=30;break}if(57344&R.flags){T.msg="unknown header flags set",R.mode=30;break}R.head&&(R.head.text=fe>>8&1),512&R.flags&&(ae[0]=255&fe,ae[1]=fe>>>8&255,R.check=a(R.check,ae,2,0)),ye=fe=0,R.mode=3;case 3:for(;ye<32;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}R.head&&(R.head.time=fe),512&R.flags&&(ae[0]=255&fe,ae[1]=fe>>>8&255,ae[2]=fe>>>16&255,ae[3]=fe>>>24&255,R.check=a(R.check,ae,4,0)),ye=fe=0,R.mode=4;case 4:for(;ye<16;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}R.head&&(R.head.xflags=255&fe,R.head.os=fe>>8),512&R.flags&&(ae[0]=255&fe,ae[1]=fe>>>8&255,R.check=a(R.check,ae,2,0)),ye=fe=0,R.mode=5;case 5:if(1024&R.flags){for(;ye<16;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}R.length=fe,R.head&&(R.head.extra_len=fe),512&R.flags&&(ae[0]=255&fe,ae[1]=fe>>>8&255,R.check=a(R.check,ae,2,0)),ye=fe=0}else R.head&&(R.head.extra=null);R.mode=6;case 6:if(1024&R.flags&&(Z<(Ve=R.length)&&(Ve=Z),Ve&&(R.head&&(I=R.head.extra_len-R.length,R.head.extra||(R.head.extra=new Array(R.head.extra_len)),i.arraySet(R.head.extra,U,ee,Ve,I)),512&R.flags&&(R.check=a(R.check,U,Ve,ee)),Z-=Ve,ee+=Ve,R.length-=Ve),R.length))break e;R.length=0,R.mode=7;case 7:if(2048&R.flags){if(Z===0)break e;for(Ve=0;I=U[ee+Ve++],R.head&&I&&R.length<65536&&(R.head.name+=String.fromCharCode(I)),I&&Ve<Z;);if(512&R.flags&&(R.check=a(R.check,U,Ve,ee)),Z-=Ve,ee+=Ve,I)break e}else R.head&&(R.head.name=null);R.length=0,R.mode=8;case 8:if(4096&R.flags){if(Z===0)break e;for(Ve=0;I=U[ee+Ve++],R.head&&I&&R.length<65536&&(R.head.comment+=String.fromCharCode(I)),I&&Ve<Z;);if(512&R.flags&&(R.check=a(R.check,U,Ve,ee)),Z-=Ve,ee+=Ve,I)break e}else R.head&&(R.head.comment=null);R.mode=9;case 9:if(512&R.flags){for(;ye<16;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}if(fe!==(65535&R.check)){T.msg="header crc mismatch",R.mode=30;break}ye=fe=0}R.head&&(R.head.hcrc=R.flags>>9&1,R.head.done=!0),T.adler=R.check=0,R.mode=12;break;case 10:for(;ye<32;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}T.adler=R.check=w(fe),ye=fe=0,R.mode=11;case 11:if(R.havedict===0)return T.next_out=J,T.avail_out=Me,T.next_in=ee,T.avail_in=Z,R.hold=fe,R.bits=ye,2;T.adler=R.check=1,R.mode=12;case 12:if(H===5||H===6)break e;case 13:if(R.last){fe>>>=7&ye,ye-=7&ye,R.mode=27;break}for(;ye<3;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}switch(R.last=1&fe,ye-=1,3&(fe>>>=1)){case 0:R.mode=14;break;case 1:if(L(R),R.mode=20,H!==6)break;fe>>>=2,ye-=2;break e;case 2:R.mode=17;break;case 3:T.msg="invalid block type",R.mode=30}fe>>>=2,ye-=2;break;case 14:for(fe>>>=7&ye,ye-=7&ye;ye<32;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}if((65535&fe)!=(fe>>>16^65535)){T.msg="invalid stored block lengths",R.mode=30;break}if(R.length=65535&fe,ye=fe=0,R.mode=15,H===6)break e;case 15:R.mode=16;case 16:if(Ve=R.length){if(Z<Ve&&(Ve=Z),Me<Ve&&(Ve=Me),Ve===0)break e;i.arraySet(W,U,ee,Ve,J),Z-=Ve,ee+=Ve,Me-=Ve,J+=Ve,R.length-=Ve;break}R.mode=12;break;case 17:for(;ye<14;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}if(R.nlen=257+(31&fe),fe>>>=5,ye-=5,R.ndist=1+(31&fe),fe>>>=5,ye-=5,R.ncode=4+(15&fe),fe>>>=4,ye-=4,286<R.nlen||30<R.ndist){T.msg="too many length or distance symbols",R.mode=30;break}R.have=0,R.mode=18;case 18:for(;R.have<R.ncode;){for(;ye<3;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}R.lens[ke[R.have++]]=7&fe,fe>>>=3,ye-=3}for(;R.have<19;)R.lens[ke[R.have++]]=0;if(R.lencode=R.lendyn,R.lenbits=7,j={bits:R.lenbits},re=u(0,R.lens,0,19,R.lencode,0,R.work,j),R.lenbits=j.bits,re){T.msg="invalid code lengths set",R.mode=30;break}R.have=0,R.mode=19;case 19:for(;R.have<R.nlen+R.ndist;){for(;It=(K=R.lencode[fe&(1<<R.lenbits)-1])>>>16&255,Le=65535&K,!((ft=K>>>24)<=ye);){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}if(Le<16)fe>>>=ft,ye-=ft,R.lens[R.have++]=Le;else{if(Le===16){for(X=ft+2;ye<X;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}if(fe>>>=ft,ye-=ft,R.have===0){T.msg="invalid bit length repeat",R.mode=30;break}I=R.lens[R.have-1],Ve=3+(3&fe),fe>>>=2,ye-=2}else if(Le===17){for(X=ft+3;ye<X;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}ye-=ft,I=0,Ve=3+(7&(fe>>>=ft)),fe>>>=3,ye-=3}else{for(X=ft+7;ye<X;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}ye-=ft,I=0,Ve=11+(127&(fe>>>=ft)),fe>>>=7,ye-=7}if(R.have+Ve>R.nlen+R.ndist){T.msg="invalid bit length repeat",R.mode=30;break}for(;Ve--;)R.lens[R.have++]=I}}if(R.mode===30)break;if(R.lens[256]===0){T.msg="invalid code -- missing end-of-block",R.mode=30;break}if(R.lenbits=9,j={bits:R.lenbits},re=u(d,R.lens,0,R.nlen,R.lencode,0,R.work,j),R.lenbits=j.bits,re){T.msg="invalid literal/lengths set",R.mode=30;break}if(R.distbits=6,R.distcode=R.distdyn,j={bits:R.distbits},re=u(f,R.lens,R.nlen,R.ndist,R.distcode,0,R.work,j),R.distbits=j.bits,re){T.msg="invalid distances set",R.mode=30;break}if(R.mode=20,H===6)break e;case 20:R.mode=21;case 21:if(6<=Z&&258<=Me){T.next_out=J,T.avail_out=Me,T.next_in=ee,T.avail_in=Z,R.hold=fe,R.bits=ye,l(T,Pe),J=T.next_out,W=T.output,Me=T.avail_out,ee=T.next_in,U=T.input,Z=T.avail_in,fe=R.hold,ye=R.bits,R.mode===12&&(R.back=-1);break}for(R.back=0;It=(K=R.lencode[fe&(1<<R.lenbits)-1])>>>16&255,Le=65535&K,!((ft=K>>>24)<=ye);){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}if(It&&(240&It)==0){for(oe=ft,we=It,Q=Le;It=(K=R.lencode[Q+((fe&(1<<oe+we)-1)>>oe)])>>>16&255,Le=65535&K,!(oe+(ft=K>>>24)<=ye);){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}fe>>>=oe,ye-=oe,R.back+=oe}if(fe>>>=ft,ye-=ft,R.back+=ft,R.length=Le,It===0){R.mode=26;break}if(32&It){R.back=-1,R.mode=12;break}if(64&It){T.msg="invalid literal/length code",R.mode=30;break}R.extra=15&It,R.mode=22;case 22:if(R.extra){for(X=R.extra;ye<X;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}R.length+=fe&(1<<R.extra)-1,fe>>>=R.extra,ye-=R.extra,R.back+=R.extra}R.was=R.length,R.mode=23;case 23:for(;It=(K=R.distcode[fe&(1<<R.distbits)-1])>>>16&255,Le=65535&K,!((ft=K>>>24)<=ye);){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}if((240&It)==0){for(oe=ft,we=It,Q=Le;It=(K=R.distcode[Q+((fe&(1<<oe+we)-1)>>oe)])>>>16&255,Le=65535&K,!(oe+(ft=K>>>24)<=ye);){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}fe>>>=oe,ye-=oe,R.back+=oe}if(fe>>>=ft,ye-=ft,R.back+=ft,64&It){T.msg="invalid distance code",R.mode=30;break}R.offset=Le,R.extra=15&It,R.mode=24;case 24:if(R.extra){for(X=R.extra;ye<X;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}R.offset+=fe&(1<<R.extra)-1,fe>>>=R.extra,ye-=R.extra,R.back+=R.extra}if(R.offset>R.dmax){T.msg="invalid distance too far back",R.mode=30;break}R.mode=25;case 25:if(Me===0)break e;if(Ve=Pe-Me,R.offset>Ve){if((Ve=R.offset-Ve)>R.whave&&R.sane){T.msg="invalid distance too far back",R.mode=30;break}nt=Ve>R.wnext?(Ve-=R.wnext,R.wsize-Ve):R.wnext-Ve,Ve>R.length&&(Ve=R.length),ct=R.window}else ct=W,nt=J-R.offset,Ve=R.length;for(Me<Ve&&(Ve=Me),Me-=Ve,R.length-=Ve;W[J++]=ct[nt++],--Ve;);R.length===0&&(R.mode=21);break;case 26:if(Me===0)break e;W[J++]=R.length,Me--,R.mode=21;break;case 27:if(R.wrap){for(;ye<32;){if(Z===0)break e;Z--,fe|=U[ee++]<<ye,ye+=8}if(Pe-=Me,T.total_out+=Pe,R.total+=Pe,Pe&&(T.adler=R.check=R.flags?a(R.check,W,Pe,J-Pe):s(R.check,W,Pe,J-Pe)),Pe=Me,(R.flags?fe:w(fe))!==R.check){T.msg="incorrect data check",R.mode=30;break}ye=fe=0}R.mode=28;case 28:if(R.wrap&&R.flags){for(;ye<32;){if(Z===0)break e;Z--,fe+=U[ee++]<<ye,ye+=8}if(fe!==(4294967295&R.total)){T.msg="incorrect length check",R.mode=30;break}ye=fe=0}R.mode=29;case 29:re=1;break e;case 30:re=-3;break e;case 31:return-4;default:return g}return T.next_out=J,T.avail_out=Me,T.next_in=ee,T.avail_in=Z,R.hold=fe,R.bits=ye,(R.wsize||Pe!==T.avail_out&&R.mode<30&&(R.mode<27||H!==4))&&$(T,T.output,T.next_out,Pe-T.avail_out)?(R.mode=31,-4):(ve-=T.avail_in,Pe-=T.avail_out,T.total_in+=ve,T.total_out+=Pe,R.total+=Pe,R.wrap&&Pe&&(T.adler=R.check=R.flags?a(R.check,W,Pe,T.next_out-Pe):s(R.check,W,Pe,T.next_out-Pe)),T.data_type=R.bits+(R.last?64:0)+(R.mode===12?128:0)+(R.mode===20||R.mode===15?256:0),(ve==0&&Pe===0||H===4)&&re===p&&(re=-5),re)},o.inflateEnd=function(T){if(!T||!T.state)return g;var H=T.state;return H.window&&(H.window=null),T.state=null,p},o.inflateGetHeader=function(T,H){var R;return T&&T.state?(2&(R=T.state).wrap)==0?g:((R.head=H).done=!1,p):g},o.inflateSetDictionary=function(T,H){var R,U=H.length;return T&&T.state?(R=T.state).wrap!==0&&R.mode!==11?g:R.mode===11&&s(1,H,U,0)!==R.check?-3:$(T,H,U,U)?(R.mode=31,-4):(R.havedict=1,p):g},o.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,o){"use strict";var i=n("../utils/common"),s=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,f,p,g,m,v,C,w){var S,b,k,x,M,z,G,F,L,$=w.bits,T=0,H=0,R=0,U=0,W=0,ee=0,J=0,Z=0,Me=0,fe=0,ye=null,ve=0,Pe=new i.Buf16(16),Ve=new i.Buf16(16),nt=null,ct=0;for(T=0;T<=15;T++)Pe[T]=0;for(H=0;H<g;H++)Pe[f[p+H]]++;for(W=$,U=15;1<=U&&Pe[U]===0;U--);if(U<W&&(W=U),U===0)return m[v++]=20971520,m[v++]=20971520,w.bits=1,0;for(R=1;R<U&&Pe[R]===0;R++);for(W<R&&(W=R),T=Z=1;T<=15;T++)if(Z<<=1,(Z-=Pe[T])<0)return-1;if(0<Z&&(d===0||U!==1))return-1;for(Ve[1]=0,T=1;T<15;T++)Ve[T+1]=Ve[T]+Pe[T];for(H=0;H<g;H++)f[p+H]!==0&&(C[Ve[f[p+H]]++]=H);if(z=d===0?(ye=nt=C,19):d===1?(ye=s,ve-=257,nt=a,ct-=257,256):(ye=l,nt=u,-1),T=R,M=v,J=H=fe=0,k=-1,x=(Me=1<<(ee=W))-1,d===1&&852<Me||d===2&&592<Me)return 1;for(;;){for(G=T-J,L=C[H]<z?(F=0,C[H]):C[H]>z?(F=nt[ct+C[H]],ye[ve+C[H]]):(F=96,0),S=1<<T-J,R=b=1<<ee;m[M+(fe>>J)+(b-=S)]=G<<24|F<<16|L|0,b!==0;);for(S=1<<T-1;fe&S;)S>>=1;if(S!==0?(fe&=S-1,fe+=S):fe=0,H++,--Pe[T]==0){if(T===U)break;T=f[p+C[H]]}if(W<T&&(fe&x)!==k){for(J===0&&(J=W),M+=R,Z=1<<(ee=T-J);ee+J<U&&!((Z-=Pe[ee+J])<=0);)ee++,Z<<=1;if(Me+=1<<ee,d===1&&852<Me||d===2&&592<Me)return 1;m[k=fe&x]=W<<24|ee<<16|M-v|0}}return fe!==0&&(m[M+fe]=T-J<<24|4194304),w.bits=W,0}},{"../utils/common":41}],51:[function(n,r,o){"use strict";r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,o){"use strict";var i=n("../utils/common"),s=0,a=1;function l(K){for(var ae=K.length;0<=--ae;)K[ae]=0}var u=0,d=29,f=256,p=f+1+d,g=30,m=19,v=2*p+1,C=15,w=16,S=7,b=256,k=16,x=17,M=18,z=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],G=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],F=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],L=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],$=new Array(2*(p+2));l($);var T=new Array(2*g);l(T);var H=new Array(512);l(H);var R=new Array(256);l(R);var U=new Array(d);l(U);var W,ee,J,Z=new Array(g);function Me(K,ae,ke,P,N){this.static_tree=K,this.extra_bits=ae,this.extra_base=ke,this.elems=P,this.max_length=N,this.has_stree=K&&K.length}function fe(K,ae){this.dyn_tree=K,this.max_code=0,this.stat_desc=ae}function ye(K){return K<256?H[K]:H[256+(K>>>7)]}function ve(K,ae){K.pending_buf[K.pending++]=255&ae,K.pending_buf[K.pending++]=ae>>>8&255}function Pe(K,ae,ke){K.bi_valid>w-ke?(K.bi_buf|=ae<<K.bi_valid&65535,ve(K,K.bi_buf),K.bi_buf=ae>>w-K.bi_valid,K.bi_valid+=ke-w):(K.bi_buf|=ae<<K.bi_valid&65535,K.bi_valid+=ke)}function Ve(K,ae,ke){Pe(K,ke[2*ae],ke[2*ae+1])}function nt(K,ae){for(var ke=0;ke|=1&K,K>>>=1,ke<<=1,0<--ae;);return ke>>>1}function ct(K,ae,ke){var P,N,me=new Array(C+1),Se=0;for(P=1;P<=C;P++)me[P]=Se=Se+ke[P-1]<<1;for(N=0;N<=ae;N++){var Re=K[2*N+1];Re!==0&&(K[2*N]=nt(me[Re]++,Re))}}function ft(K){var ae;for(ae=0;ae<p;ae++)K.dyn_ltree[2*ae]=0;for(ae=0;ae<g;ae++)K.dyn_dtree[2*ae]=0;for(ae=0;ae<m;ae++)K.bl_tree[2*ae]=0;K.dyn_ltree[2*b]=1,K.opt_len=K.static_len=0,K.last_lit=K.matches=0}function It(K){8<K.bi_valid?ve(K,K.bi_buf):0<K.bi_valid&&(K.pending_buf[K.pending++]=K.bi_buf),K.bi_buf=0,K.bi_valid=0}function Le(K,ae,ke,P){var N=2*ae,me=2*ke;return K[N]<K[me]||K[N]===K[me]&&P[ae]<=P[ke]}function oe(K,ae,ke){for(var P=K.heap[ke],N=ke<<1;N<=K.heap_len&&(N<K.heap_len&&Le(ae,K.heap[N+1],K.heap[N],K.depth)&&N++,!Le(ae,P,K.heap[N],K.depth));)K.heap[ke]=K.heap[N],ke=N,N<<=1;K.heap[ke]=P}function we(K,ae,ke){var P,N,me,Se,Re=0;if(K.last_lit!==0)for(;P=K.pending_buf[K.d_buf+2*Re]<<8|K.pending_buf[K.d_buf+2*Re+1],N=K.pending_buf[K.l_buf+Re],Re++,P===0?Ve(K,N,ae):(Ve(K,(me=R[N])+f+1,ae),(Se=z[me])!==0&&Pe(K,N-=U[me],Se),Ve(K,me=ye(--P),ke),(Se=G[me])!==0&&Pe(K,P-=Z[me],Se)),Re<K.last_lit;);Ve(K,b,ae)}function Q(K,ae){var ke,P,N,me=ae.dyn_tree,Se=ae.stat_desc.static_tree,Re=ae.stat_desc.has_stree,ze=ae.stat_desc.elems,Ke=-1;for(K.heap_len=0,K.heap_max=v,ke=0;ke<ze;ke++)me[2*ke]!==0?(K.heap[++K.heap_len]=Ke=ke,K.depth[ke]=0):me[2*ke+1]=0;for(;K.heap_len<2;)me[2*(N=K.heap[++K.heap_len]=Ke<2?++Ke:0)]=1,K.depth[N]=0,K.opt_len--,Re&&(K.static_len-=Se[2*N+1]);for(ae.max_code=Ke,ke=K.heap_len>>1;1<=ke;ke--)oe(K,me,ke);for(N=ze;ke=K.heap[1],K.heap[1]=K.heap[K.heap_len--],oe(K,me,1),P=K.heap[1],K.heap[--K.heap_max]=ke,K.heap[--K.heap_max]=P,me[2*N]=me[2*ke]+me[2*P],K.depth[N]=(K.depth[ke]>=K.depth[P]?K.depth[ke]:K.depth[P])+1,me[2*ke+1]=me[2*P+1]=N,K.heap[1]=N++,oe(K,me,1),2<=K.heap_len;);K.heap[--K.heap_max]=K.heap[1],(function(ot,mt){var Ot,Mt,Kt,$e,Qt,Hn,qt=mt.dyn_tree,jn=mt.max_code,Pn=mt.stat_desc.static_tree,$r=mt.stat_desc.has_stree,Nr=mt.stat_desc.extra_bits,_r=mt.stat_desc.extra_base,Tn=mt.stat_desc.max_length,tr=0;for($e=0;$e<=C;$e++)ot.bl_count[$e]=0;for(qt[2*ot.heap[ot.heap_max]+1]=0,Ot=ot.heap_max+1;Ot<v;Ot++)Tn<($e=qt[2*qt[2*(Mt=ot.heap[Ot])+1]+1]+1)&&($e=Tn,tr++),qt[2*Mt+1]=$e,jn<Mt||(ot.bl_count[$e]++,Qt=0,_r<=Mt&&(Qt=Nr[Mt-_r]),Hn=qt[2*Mt],ot.opt_len+=Hn*($e+Qt),$r&&(ot.static_len+=Hn*(Pn[2*Mt+1]+Qt)));if(tr!==0){do{for($e=Tn-1;ot.bl_count[$e]===0;)$e--;ot.bl_count[$e]--,ot.bl_count[$e+1]+=2,ot.bl_count[Tn]--,tr-=2}while(0<tr);for($e=Tn;$e!==0;$e--)for(Mt=ot.bl_count[$e];Mt!==0;)jn<(Kt=ot.heap[--Ot])||(qt[2*Kt+1]!==$e&&(ot.opt_len+=($e-qt[2*Kt+1])*qt[2*Kt],qt[2*Kt+1]=$e),Mt--)}})(K,ae),ct(me,Ke,K.bl_count)}function I(K,ae,ke){var P,N,me=-1,Se=ae[1],Re=0,ze=7,Ke=4;for(Se===0&&(ze=138,Ke=3),ae[2*(ke+1)+1]=65535,P=0;P<=ke;P++)N=Se,Se=ae[2*(P+1)+1],++Re<ze&&N===Se||(Re<Ke?K.bl_tree[2*N]+=Re:N!==0?(N!==me&&K.bl_tree[2*N]++,K.bl_tree[2*k]++):Re<=10?K.bl_tree[2*x]++:K.bl_tree[2*M]++,me=N,Ke=(Re=0)===Se?(ze=138,3):N===Se?(ze=6,3):(ze=7,4))}function re(K,ae,ke){var P,N,me=-1,Se=ae[1],Re=0,ze=7,Ke=4;for(Se===0&&(ze=138,Ke=3),P=0;P<=ke;P++)if(N=Se,Se=ae[2*(P+1)+1],!(++Re<ze&&N===Se)){if(Re<Ke)for(;Ve(K,N,K.bl_tree),--Re!=0;);else N!==0?(N!==me&&(Ve(K,N,K.bl_tree),Re--),Ve(K,k,K.bl_tree),Pe(K,Re-3,2)):Re<=10?(Ve(K,x,K.bl_tree),Pe(K,Re-3,3)):(Ve(K,M,K.bl_tree),Pe(K,Re-11,7));me=N,Ke=(Re=0)===Se?(ze=138,3):N===Se?(ze=6,3):(ze=7,4)}}l(Z);var j=!1;function X(K,ae,ke,P){Pe(K,(u<<1)+(P?1:0),3),(function(N,me,Se,Re){It(N),Re&&(ve(N,Se),ve(N,~Se)),i.arraySet(N.pending_buf,N.window,me,Se,N.pending),N.pending+=Se})(K,ae,ke,!0)}o._tr_init=function(K){j||((function(){var ae,ke,P,N,me,Se=new Array(C+1);for(N=P=0;N<d-1;N++)for(U[N]=P,ae=0;ae<1<<z[N];ae++)R[P++]=N;for(R[P-1]=N,N=me=0;N<16;N++)for(Z[N]=me,ae=0;ae<1<<G[N];ae++)H[me++]=N;for(me>>=7;N<g;N++)for(Z[N]=me<<7,ae=0;ae<1<<G[N]-7;ae++)H[256+me++]=N;for(ke=0;ke<=C;ke++)Se[ke]=0;for(ae=0;ae<=143;)$[2*ae+1]=8,ae++,Se[8]++;for(;ae<=255;)$[2*ae+1]=9,ae++,Se[9]++;for(;ae<=279;)$[2*ae+1]=7,ae++,Se[7]++;for(;ae<=287;)$[2*ae+1]=8,ae++,Se[8]++;for(ct($,p+1,Se),ae=0;ae<g;ae++)T[2*ae+1]=5,T[2*ae]=nt(ae,5);W=new Me($,z,f+1,p,C),ee=new Me(T,G,0,g,C),J=new Me(new Array(0),F,0,m,S)})(),j=!0),K.l_desc=new fe(K.dyn_ltree,W),K.d_desc=new fe(K.dyn_dtree,ee),K.bl_desc=new fe(K.bl_tree,J),K.bi_buf=0,K.bi_valid=0,ft(K)},o._tr_stored_block=X,o._tr_flush_block=function(K,ae,ke,P){var N,me,Se=0;0<K.level?(K.strm.data_type===2&&(K.strm.data_type=(function(Re){var ze,Ke=4093624447;for(ze=0;ze<=31;ze++,Ke>>>=1)if(1&Ke&&Re.dyn_ltree[2*ze]!==0)return s;if(Re.dyn_ltree[18]!==0||Re.dyn_ltree[20]!==0||Re.dyn_ltree[26]!==0)return a;for(ze=32;ze<f;ze++)if(Re.dyn_ltree[2*ze]!==0)return a;return s})(K)),Q(K,K.l_desc),Q(K,K.d_desc),Se=(function(Re){var ze;for(I(Re,Re.dyn_ltree,Re.l_desc.max_code),I(Re,Re.dyn_dtree,Re.d_desc.max_code),Q(Re,Re.bl_desc),ze=m-1;3<=ze&&Re.bl_tree[2*L[ze]+1]===0;ze--);return Re.opt_len+=3*(ze+1)+5+5+4,ze})(K),N=K.opt_len+3+7>>>3,(me=K.static_len+3+7>>>3)<=N&&(N=me)):N=me=ke+5,ke+4<=N&&ae!==-1?X(K,ae,ke,P):K.strategy===4||me===N?(Pe(K,2+(P?1:0),3),we(K,$,T)):(Pe(K,4+(P?1:0),3),(function(Re,ze,Ke,ot){var mt;for(Pe(Re,ze-257,5),Pe(Re,Ke-1,5),Pe(Re,ot-4,4),mt=0;mt<ot;mt++)Pe(Re,Re.bl_tree[2*L[mt]+1],3);re(Re,Re.dyn_ltree,ze-1),re(Re,Re.dyn_dtree,Ke-1)})(K,K.l_desc.max_code+1,K.d_desc.max_code+1,Se+1),we(K,K.dyn_ltree,K.dyn_dtree)),ft(K),P&&It(K)},o._tr_tally=function(K,ae,ke){return K.pending_buf[K.d_buf+2*K.last_lit]=ae>>>8&255,K.pending_buf[K.d_buf+2*K.last_lit+1]=255&ae,K.pending_buf[K.l_buf+K.last_lit]=255&ke,K.last_lit++,ae===0?K.dyn_ltree[2*ke]++:(K.matches++,ae--,K.dyn_ltree[2*(R[ke]+f+1)]++,K.dyn_dtree[2*ye(ae)]++),K.last_lit===K.lit_bufsize-1},o._tr_align=function(K){Pe(K,2,3),Ve(K,b,$),(function(ae){ae.bi_valid===16?(ve(ae,ae.bi_buf),ae.bi_buf=0,ae.bi_valid=0):8<=ae.bi_valid&&(ae.pending_buf[ae.pending++]=255&ae.bi_buf,ae.bi_buf>>=8,ae.bi_valid-=8)})(K)}},{"../utils/common":41}],53:[function(n,r,o){"use strict";r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,o){(function(i){(function(s,a){"use strict";if(!s.setImmediate){var l,u,d,f,p=1,g={},m=!1,v=s.document,C=Object.getPrototypeOf&&Object.getPrototypeOf(s);C=C&&C.setTimeout?C:s,l={}.toString.call(s.process)==="[object process]"?function(k){process.nextTick(function(){S(k)})}:(function(){if(s.postMessage&&!s.importScripts){var k=!0,x=s.onmessage;return s.onmessage=function(){k=!1},s.postMessage("","*"),s.onmessage=x,k}})()?(f="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",b,!1):s.attachEvent("onmessage",b),function(k){s.postMessage(f+k,"*")}):s.MessageChannel?((d=new MessageChannel).port1.onmessage=function(k){S(k.data)},function(k){d.port2.postMessage(k)}):v&&"onreadystatechange"in v.createElement("script")?(u=v.documentElement,function(k){var x=v.createElement("script");x.onreadystatechange=function(){S(k),x.onreadystatechange=null,u.removeChild(x),x=null},u.appendChild(x)}):function(k){setTimeout(S,0,k)},C.setImmediate=function(k){typeof k!="function"&&(k=new Function(""+k));for(var x=new Array(arguments.length-1),M=0;M<x.length;M++)x[M]=arguments[M+1];return g[p]={callback:k,args:x},l(p),p++},C.clearImmediate=w}function w(k){delete g[k]}function S(k){if(m)setTimeout(S,0,k);else{var x=g[k];if(x){m=!0;try{(function(M){var z=M.callback,G=M.args;switch(G.length){case 0:z();break;case 1:z(G[0]);break;case 2:z(G[0],G[1]);break;case 3:z(G[0],G[1],G[2]);break;default:z.apply(a,G)}})(x)}finally{w(k),m=!1}}}}function b(k){k.source===s&&typeof k.data=="string"&&k.data.indexOf(f)===0&&S(+k.data.slice(f.length))}})(typeof self>"u"?i===void 0?this:i:self)}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})),br="application/vnd.openxmlformats-officedocument.wordprocessingml.document",Da="application/pdf",Du="text/html",t6={docx:br,pdf:Da,html:Du},Kp={RESOLVED:"resolved",NEW:"new",ADD:"add",UPDATE:"update",DELETED:"deleted",PENDING:"pending",SELECTED:"selected",COMMENTS_LIST:"comments-list",CHANGE_ACCEPTED:"change-accepted",CHANGE_REJECTED:"change-rejected"};Ft();var n6=p2(e6(),1),r6=e=>typeof e!="string"?"":e.trim(),ab=e=>{if(typeof e!="string")return"";const t=e.trim();return t?t.toLowerCase():""},qp=e=>{if(typeof e!="string")return"";const t=e.trim();return t?t.toLowerCase():""},Ic=e=>{const t=e??{},n=r6(t.id),r=ab(t.email);return{id:n,email:r,name:typeof t.name=="string"?t.name:"",hasId:n.length>0,hasEmail:r.length>0}},Lk=({current:e,other:t})=>{const n=Ic(e),r=Ic(t);return n.hasId&&r.hasId?n.id===r.id:n.hasEmail&&r.hasEmail?n.email===r.email:!1},Ou=({actor:e,fallbackKey:t=""})=>{const n=Ic(e);if(n.hasId)return`id:${n.id}`;if(n.hasEmail)return`email:${n.email}`;const r=typeof t=="number"?String(t):typeof t=="string"?t.trim():"";return r?`fallback:${r}`:""};function o6(e){return typeof e.captureStackTrace=="function"}var Yp=class extends Error{constructor(e,t){super(e),this.cause=t,this.name="FileObjectError",o6(Error)&&Error.captureStackTrace(this,this.constructor)}},i6=class extends Yp{constructor(e){super("Invalid data URI format: URI must contain exactly one comma separator"),this.uri=e,this.name="InvalidDataUriError"}},s6=class extends Yp{constructor(e,t){super(`Failed to fetch file from URL: ${e}`,t),this.url=e,this.name="FetchFailedError"}},lb=async(e,t,n)=>{try{if(e.startsWith("data:")&&e.includes(";base64,")){const i=e.split(",");if(i.length!==2)throw new i6(e);const s=atob(i[1]),a=Uint8Array.from(s,l=>l.charCodeAt(0));return new File([a],t,{type:n})}const r=await fetch(e);if(!r.ok)throw new s6(e,new Error(`HTTP ${r.status}: ${r.statusText}`));const o=await r.blob();return new File([o],t,{type:n})}catch(r){throw r instanceof Yp?r:new Yp("Failed to create file object",r)}};function a6(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const i=n[o]||0,s=r[o]||0;if(i>s)return 1;if(i<s)return-1}return 0}var Xp=new WeakMap;function Pk(e){return e.ownerDocument??document}function Dk(e,t){const n=Xp.get(t);n?.bindings.delete(e),n&&n.bindings.size===0&&(t.removeEventListener("click",n.listener),Xp.delete(t))}function Ok(e,t){const n=Pk(e);e.__clickOutsideDocument&&e.__clickOutsideDocument!==n&&Dk(e,e.__clickOutsideDocument);let r=Xp.get(n);if(!r){const o=new Map,i=s=>{const a=typeof s.composedPath=="function"?s.composedPath():null;for(const[l,u]of o)(a?.includes(l)??l.contains(s.target))||u.value?.(s)};r={bindings:o,listener:i},Xp.set(n,r),n.addEventListener("click",i)}r.bindings.set(e,t),e.__clickOutsideHandler=r.listener,e.__clickOutsideDocument=n}var cb={mounted(e,t){Ok(e,t)},updated(e,t){Ok(e,t)},unmounted(e){Dk(e,e.__clickOutsideDocument??Pk(e)),delete e.__clickOutsideHandler,delete e.__clickOutsideDocument}};function l6(e){return e[1].user!==void 0}var c6=(e,t)=>{const n=new Set;return Array.from(t.entries()).filter(l6).filter(([r,o])=>{const i=Ou({actor:o.user,fallbackKey:r});return!i||n.has(i)?!1:(n.add(i),!0)}).map(([r,o])=>{const i=Ou({actor:o.user,fallbackKey:r});let s=e.userColorMap.get(i);return s||(s=o.user.color||(e.config.colors.length>0?e.config.colors[e.colorIndex%e.config.colors.length]:void 0),e.userColorMap.set(i,s),e.colorIndex++),{clientId:r,...o.user,color:s}})},u6=e=>{for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e},d6="https://ingest.superdoc.dev/v1/collect",Qq="community-and-eval-agplv3";function f6(){try{return"2.22.0-next.4"}catch{return"unknown"}}var h6=class{constructor(e){this.enabled=e.enabled,this.endpoint=e.endpoint||d6,this.licenseKey=e.licenseKey||"",this.metadata=e.metadata,this.superdocVersion=f6()}getBrowserInfo(){return typeof window>"u"?{userAgent:"",currentUrl:"",hostname:"",screenSize:{width:0,height:0}}:{userAgent:window.navigator.userAgent,currentUrl:window.location.origin,hostname:window.location.hostname,screenSize:{width:window.screen.width,height:window.screen.height}}}trackDocumentOpen(e,t=null){if(!this.enabled)return;const n={timestamp:new Date().toISOString(),documentId:e,documentCreatedAt:t};this.sendEvent(n)}async sendEvent(e){const t={superdocVersion:this.superdocVersion,browserInfo:this.getBrowserInfo(),...this.metadata&&{metadata:this.metadata},events:[e]};try{await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-License-Key":this.licenseKey},body:JSON.stringify(t),credentials:"omit"})}catch{}}},Zp={PAGE:"superdoc-page",FRAGMENT:"superdoc-fragment",FLOATING_FRAGMENT:"superdoc-floating-fragment",LINE:"superdoc-line",INLINE_SDT_WRAPPER:"superdoc-structured-content-inline",INLINE_SDT_LABEL:"superdoc-structured-content-inline__label",BLOCK_SDT:"superdoc-structured-content-block",BLOCK_SDT_LABEL:"superdoc-structured-content__label",TABLE_FRAGMENT:"superdoc-table-fragment",DOCUMENT_SECTION:"superdoc-document-section",SDT_GROUP_HOVER:"sdt-group-hover",TOC_ENTRY:"superdoc-toc-entry",TOC_GROUP_HOVER:"toc-group-hover",IMAGE_FRAGMENT:"superdoc-image-fragment",INLINE_IMAGE:"superdoc-inline-image",LIST_MARKER:"superdoc-list-marker",INLINE_IMAGE_CLIP_WRAPPER:"superdoc-inline-image-clip-wrapper",ANNOTATION:"annotation",ANNOTATION_CONTENT:"annotation-content",ANNOTATION_CARET_ANCHOR:"annotation-caret-anchor"},Jq=[Zp.INLINE_SDT_LABEL,Zp.BLOCK_SDT_LABEL],Fk={PM_START:"data-pm-start",PM_END:"data-pm-end",LAYOUT_EPOCH:"data-layout-epoch",TABLE_BOUNDARIES:"data-table-boundaries",SDT_ID:"data-sdt-id",SDT_TYPE:"data-sdt-type",FIELD_ID:"data-field-id",FIELD_TYPE:"data-field-type",DRAGGABLE:"data-draggable",DISPLAY_LABEL:"data-display-label",VARIANT:"data-variant",TYPE:"data-type",LAYOUT_BOUNDARY_SCHEMA:"data-layout-boundary-schema",LAYOUT_FRAGMENT_ID:"data-layout-fragment-id",LAYOUT_STORY:"data-layout-story",LAYOUT_BLOCK_REF:"data-layout-block-ref",LAYOUT_COLUMN_INDEX:"data-layout-column-index"},p6=e=>{if(!e)return{kind:"unknown"};if(e==="body")return{kind:"body"};const t=e.indexOf(":"),n=t===-1?e:e.slice(0,t),r=t===-1?void 0:e.slice(t+1);switch(n){case"body":case"header":case"footer":case"footnote":case"endnote":case"textbox":return r?{kind:n,id:r}:{kind:n};default:return{kind:"unknown"}}},eY=`.${Zp.BLOCK_SDT}[${Fk.SDT_ID}]`,tY=`[${Fk.DRAGGABLE}="true"]`,m6=typeof window<"u",Nk,Df=e=>Nk=e,Bk=Symbol();function ub(e){return e&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"&&typeof e.toJSON!="function"}var Of;(function(e){e.direct="direct",e.patchObject="patch object",e.patchFunction="patch function"})(Of||(Of={}));var zk=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof global=="object"&&global.global===global?global:typeof globalThis=="object"?globalThis:{HTMLElement:null};function g6(e,{autoBom:t=!1}={}){return t&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\uFEFF",e],{type:e.type}):e}function db(e,t,n){const r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){v6(r.response,t,n)},r.onerror=function(){console.error("could not download file")},r.send()}function jk(e){const t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch{}return t.status>=200&&t.status<=299}function Qp(e){try{e.dispatchEvent(new MouseEvent("click"))}catch{const n=new MouseEvent("click",{bubbles:!0,cancelable:!0,view:window,detail:0,screenX:80,screenY:20,clientX:80,clientY:20,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,button:0,relatedTarget:null});e.dispatchEvent(n)}}var Jp=typeof navigator=="object"?navigator:{userAgent:""},Vk=/Macintosh/.test(Jp.userAgent)&&/AppleWebKit/.test(Jp.userAgent)&&!/Safari/.test(Jp.userAgent),v6=m6?typeof HTMLAnchorElement<"u"&&"download"in HTMLAnchorElement.prototype&&!Vk?y6:"msSaveOrOpenBlob"in Jp?b6:w6:()=>{};function y6(e,t="download",n){const r=document.createElement("a");r.download=t,r.rel="noopener",typeof e=="string"?(r.href=e,r.origin!==location.origin?jk(r.href)?db(e,t,n):(r.target="_blank",Qp(r)):Qp(r)):(r.href=URL.createObjectURL(e),setTimeout(function(){URL.revokeObjectURL(r.href)},4e4),setTimeout(function(){Qp(r)},0))}function b6(e,t="download",n){if(typeof e=="string")if(jk(e))db(e,t,n);else{const r=document.createElement("a");r.href=e,r.target="_blank",setTimeout(function(){Qp(r)})}else navigator.msSaveOrOpenBlob(g6(e,n),t)}function w6(e,t,n,r){if(r=r||open("","_blank"),r&&(r.document.title=r.document.body.innerText="downloading..."),typeof e=="string")return db(e,t,n);const o=e.type==="application/octet-stream",i=/constructor/i.test(String(zk.HTMLElement))||"safari"in zk,s=/CriOS\/[\d]+/.test(navigator.userAgent);if((s||o&&i||Vk)&&typeof FileReader<"u"){const a=new FileReader;a.onloadend=function(){let l=a.result;if(typeof l!="string")throw r=null,new Error("Wrong reader.result type");l=s?l:l.replace(/^data:[^;]*;/,"data:attachment/file;"),r?r.location.href=l:location.assign(l),r=null},a.readAsDataURL(e)}else{const a=URL.createObjectURL(e);r?r.location.assign(a):location.href=a,r=null,setTimeout(function(){URL.revokeObjectURL(a)},4e4)}}var{assign:nY}=Object;function C6(){const e=yv(!0),t=e.run(()=>te({}));let n=[],r=[];const o=Gr({install(i){Df(o),o._a=i,i.provide(Bk,o),i.config.globalProperties.$pinia=o,r.forEach(s=>n.push(s)),r=[]},use(i){return this._a?n.push(i):r.push(i),this},_p:n,_a:null,_e:e,_s:new Map,state:t});return o}var Uk=()=>{};function $k(e,t,n,r=Uk){e.add(t);const o=()=>{e.delete(t)&&r()};return!n&&bv()&&P2(o),o}function Fu(e,...t){e.forEach(n=>{n(...t)})}var k6=e=>e(),Hk=Symbol(),fb=Symbol();function hb(e,t){e instanceof Map&&t instanceof Map?t.forEach((n,r)=>e.set(r,n)):e instanceof Set&&t instanceof Set&&t.forEach(e.add,e);for(const n in t){if(!t.hasOwnProperty(n))continue;const r=t[n],o=e[n];ub(o)&&ub(r)&&e.hasOwnProperty(n)&&!hr(r)&&!zi(r)?e[n]=hb(o,r):e[n]=r}return e}var S6=Symbol();function _6(e){return!ub(e)||!Object.prototype.hasOwnProperty.call(e,S6)}var{assign:El}=Object;function A6(e){return!!(hr(e)&&e.effect)}function I6(e,t,n,r){const{state:o,actions:i,getters:s}=t,a=n.state.value[e];let l;function u(){a||(n.state.value[e]=o?o():{});const d=H2(n.state.value[e]);return El(d,i,Object.keys(s||{}).reduce((f,p)=>(f[p]=Gr(_e(()=>{Df(n);const g=n._s.get(e);return s[p].call(g,g)})),f),{}))}return l=Gk(e,u,t,n,r,!0),l}function Gk(e,t,n={},r,o,i){let s;const a=El({actions:{}},n),l={deep:!0};let u,d,f=new Set,p=new Set,g;const m=r.state.value[e];!i&&!m&&(r.state.value[e]={});let v;function C(M){let z;u=d=!1,typeof M=="function"?(M(r.state.value[e]),z={type:Of.patchFunction,storeId:e,events:g}):(hb(r.state.value[e],M),z={type:Of.patchObject,payload:M,storeId:e,events:g});const G=v=Symbol();Ct().then(()=>{v===G&&(u=!0)}),d=!0,Fu(f,z,r.state.value[e])}const w=i?function(){const{state:z}=n,G=z?z():{};this.$patch(F=>{El(F,G)})}:Uk;function S(){s.stop(),f.clear(),p.clear(),r._s.delete(e)}const b=(M,z="")=>{if(Hk in M)return M[fb]=z,M;const G=function(){Df(r);const F=Array.from(arguments),L=new Set,$=new Set;function T(U){L.add(U)}function H(U){$.add(U)}Fu(p,{args:F,name:G[fb],store:k,after:T,onError:H});let R;try{R=M.apply(this&&this.$id===e?this:k,F)}catch(U){throw Fu($,U),U}return R instanceof Promise?R.then(U=>(Fu(L,U),U)).catch(U=>(Fu($,U),Promise.reject(U))):(Fu(L,R),R)};return G[Hk]=!0,G[fb]=z,G},k=Qr({_p:r,$id:e,$onAction:$k.bind(null,p),$patch:C,$reset:w,$subscribe(M,z={}){const G=$k(f,M,z.detached,()=>F()),F=s.run(()=>jt(()=>r.state.value[e],L=>{(z.flush==="sync"?d:u)&&M({storeId:e,type:Of.direct,events:g},L)},El({},l,z)));return G},$dispose:S});r._s.set(e,k);const x=(r._a&&r._a.runWithContext||k6)(()=>r._e.run(()=>(s=yv()).run(()=>t({action:b}))));for(const M in x){const z=x[M];hr(z)&&!A6(z)||zi(z)?i||(m&&_6(z)&&(hr(z)?z.value=m[M]:hb(z,m[M])),r.state.value[e][M]=z):typeof z=="function"&&(x[M]=b(z,M),a.actions[M]=z)}return El(k,x),El(Cn(k),x),Object.defineProperty(k,"$state",{get:()=>r.state.value[e],set:M=>{C(z=>{El(z,M)})}}),r._p.forEach(M=>{El(k,s.run(()=>M({store:k,app:r._a,pinia:r,options:a})))}),m&&i&&n.hydrate&&n.hydrate(k.$state,m),u=!0,d=!0,k}function Wk(e,t,n){let r;const o=typeof t=="function";r=o?n:t;function i(s,a){const l=yw();return s=s||(l?gl(Bk,null):null),s&&Df(s),s=Nk,s._s.has(e)||(o?Gk(e,t,r,s):I6(e,r,s)),s._s.get(e)}return i.$id=e,i}function qs(e){const t=Cn(e),n={};for(const r in t){const o=t[r];o.effect?n[r]=_e({get:()=>e[r],set(i){e[r]=i}}):(hr(o)||zi(o))&&(n[r]=Ev(e,r))}return n}function Kk(e){return e.collaboration!==void 0?e.collaboration:e.v2Collaboration}function qk(e){if(typeof e!="string"||e.length===0)return"<none>";try{const t=new URL(e);t.search="",t.hash="",t.username="",t.password="";const n=e.includes("?")?"?<redacted>":"";return`${t.toString().replace(/\?$/,"")}${n}`}catch{const t=e.replace(/\/\/[^/@]+@/,"//"),n=t.search(/[?#]/);return n===-1?t:`${t.slice(0,n)}?<redacted>`}}function Ec(e){return typeof e=="string"&&e.length>0?e:null}function E6(e){if(typeof e!="string"||e.length===0)return null;try{const t=new URL(e);return t.protocol==="ws:"||t.protocol==="wss:"?e:null}catch{return null}}function x6(e,t){if(typeof e!="string")return null;const n=e.trim();if(n.length===0)return null;try{const r=new URL(n);return r.protocol==="http:"||r.protocol==="https:"?n:null}catch{if(typeof t!="string"||t.trim().length===0)return null;try{const r=new URL(n,t);return r.protocol==="http:"||r.protocol==="https:"?r.href:null}catch{return null}}}function T6(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t={};for(const[n,r]of Object.entries(e))typeof r=="string"&&(t[n]=r);return Object.keys(t).length>0?t:void 0}function pb(e){return e===void 0?"join":e==="join"||e==="create"?e:null}function R6(e){if(e!==void 0)return typeof e=="number"&&Number.isFinite(e)&&e>0&&e<=2147483647?e:null}function em(e,t){return!e.ok||t===void 0?e:{ok:!0,target:{...e.target,syncTimeoutMs:t}}}function mb(){return{ok:!1,reason:"invalid-room-mode",message:'SuperDoc v2 collaboration roomMode must be either "join" or "create".'}}function M6(e){const t=e.providerType;return typeof t=="string"&&t.length>0?t.toLowerCase():null}function L6(e){if(!e||typeof e!="object")return null;const t=typeof e.providerType=="string"?e.providerType.toLowerCase():"";return t==="hocuspocus"?"hocuspocus":t==="liveblocks"?"liveblocks":t==="superdoc"?"superdoc":e.ydoc!=null||e.provider!=null?"external-ydoc-provider":null}function Yk(e,t){const n=Ec(t.documentId);if(!n)return{ok:!1,reason:"invalid-document-id",message:`SuperDoc v2 collaboration requires a non-empty collaboration.documentId for the "${e}" provider.`};const r=t.url??t.serverUrl,o=E6(r);if(!o)return{ok:!1,reason:"invalid-server-url",message:`SuperDoc v2 collaboration requires a valid ws:// or wss:// URL for the "${e}" provider (received: ${qk(r)}).`};const i=T6(t.params),s=e==="hocuspocus"&&typeof t.token=="function"?t.token:e==="hocuspocus"?Ec(t.token):null,a=pb(t.roomMode);return a?{ok:!0,target:{providerFamily:e,documentId:n,roomMode:a,serverUrl:o,...i?{params:i}:{},...s?{token:s}:{}}}:mb()}function P6(e){const t=Ec(e.adapterId);if(!t)return{ok:!1,reason:"invalid-adapter-id",message:"SuperDoc v2 provider extensions require a non-empty collaboration.adapterId."};const n=Ec(e.documentId);if(!n)return{ok:!1,reason:"invalid-document-id",message:"SuperDoc v2 provider extensions require a non-empty collaboration.documentId."};const r=pb(e.roomMode);if(!r)return mb();if(Object.prototype.hasOwnProperty.call(e,"providerOptions"))try{structuredClone(e.providerOptions)}catch{return{ok:!1,reason:"invalid-provider-options",message:"SuperDoc v2 provider extension options must be structured-clone-safe."}}const o=typeof e.token=="function"?e.token:Ec(e.token);return{ok:!0,target:{providerFamily:"extension",adapterId:t,documentId:n,roomMode:r,...Object.prototype.hasOwnProperty.call(e,"providerOptions")?{providerOptions:e.providerOptions}:{},...o?{token:o}:{}}}}function D6(e,t){const n=Ec(e.documentId??e.roomId);if(!n)return{ok:!1,reason:"invalid-document-id",message:'SuperDoc v2 collaboration requires a non-empty collaboration.documentId (or roomId) for the "liveblocks" provider.'};const r=Ec(e.publicApiKey),o=pb(e.roomMode);if(!o)return mb();const i=e.authEndpoint,s=typeof i=="string"&&i.length>0;if(!r&&!s)return{ok:!1,reason:"missing-auth",message:"SuperDoc v2 Liveblocks collaboration requires exactly one auth mode: a publicApiKey or an authEndpoint. None was provided."};if(r&&s)return{ok:!1,reason:"mixed-auth",message:"SuperDoc v2 Liveblocks collaboration accepts exactly one auth mode; pass either publicApiKey or authEndpoint, not both."};if(r)return{ok:!0,target:{providerFamily:"liveblocks",documentId:n,roomMode:o,publicApiKey:r}};const a=x6(i,t);return a?{ok:!0,target:{providerFamily:"liveblocks",documentId:n,roomMode:o,authEndpoint:a}}:{ok:!1,reason:"invalid-auth-endpoint",message:"SuperDoc v2 Liveblocks collaboration requires a valid http(s) authEndpoint URL (received: <redacted>)."}}function Xk(e){const{legacyCollaboration:t,documentType:n,documentCount:r,authEndpointBaseUrl:o}=e,i=Kk(e);if(typeof r=="number"&&r>1)return{ok:!1,reason:"unsupported-multi-document",message:`SuperDoc v2 collaboration supports exactly one document per room; received ${r}.`};if(n!=null&&n!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document")return{ok:!1,reason:"unsupported-document-type",message:"SuperDoc v2 collaboration supports DOCX documents only."};if(!(i!=null&&typeof i=="object")){const u=L6(t);if(u){const d=u==="external-ydoc-provider"?"unsupported-legacy-provider":"unsupported-provider-family",f=qk(t?.url);return{ok:!1,reason:d,message:u==="external-ydoc-provider"?"SuperDoc v2 collaboration cannot use an external { ydoc, provider } pair. Provide a collaboration target (e.g. { providerType, documentId, url }) instead.":`SuperDoc v2 collaboration does not accept "${u}" through the legacy modules.collaboration block (server: ${f}). Configure it as a document.collaboration target ({ providerType: "${u}", documentId, ... }) instead.`}}return{ok:!1,reason:"missing-target",message:"SuperDoc v2 collaboration requires a collaboration target ({ documentId, serverUrl } or { providerType, ... }). None was provided."}}const s=i;if(Object.prototype.hasOwnProperty.call(s,"createIfMissing"))return{ok:!1,reason:"invalid-room-mode",message:'SuperDoc v2 collaboration createIfMissing has been removed. Use roomMode: "create" for creation or roomMode: "join" for normal opens.'};if(s.ydoc!=null||s.provider!=null)return{ok:!1,reason:"unsupported-legacy-provider",message:"SuperDoc v2 collaboration cannot use an external { ydoc, provider } pair. v2 owns its provider; pass a collaboration target ({ providerType, documentId, serverUrl | publicApiKey | authEndpoint }) instead."};const a=R6(s.syncTimeoutMs);if(a===null)return{ok:!1,reason:"invalid-sync-timeout",message:"SuperDoc v2 collaboration syncTimeoutMs must be a finite positive number within the JavaScript timer range."};const l=M6(s);return l===null||l==="y-websocket"?em(Yk("y-websocket",s),a):l==="hocuspocus"?em(Yk("hocuspocus",s),a):l==="liveblocks"?em(D6(s,o),a):l==="extension"?em(P6(s),a):{ok:!1,reason:"unsupported-provider-family",message:`SuperDoc v2 collaboration does not support the "${l}" provider family. Supported families are y-websocket, hocuspocus, liveblocks, and extension.`}}var Ff=(e,t="document")=>{if(!e)return null;if(typeof File=="function"&&e instanceof File)return e;if(typeof Blob=="function"&&e instanceof Blob){if(typeof File=="function"){const n=e.name||t;return new File([e],n,{type:e.type})}return e}return e.originFileObj?Ff(e.originFileObj,e.name||t):e.file?Ff(e.file,e.name||t):e.raw?Ff(e.raw,e.name||t):null},Zk=Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength")?.get,O6=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),Symbol.toStringTag)?.get,xl=e=>{if(ArrayBuffer.isView(e))return O6?.call(e)==="Uint8Array";if(!Zk)return!1;try{return Zk.call(e),!0}catch{return!1}},gb=e=>{if(e instanceof Uint8Array)return e;const t=ArrayBuffer.isView(e)?e:new Uint8Array(e);return Uint8Array.from(t)},vb=(e,t)=>new Blob([gb(e)],{type:t}),yb=e=>{switch(e.toLowerCase()){case"docx":case br:return br;case"pdf":case Da:return Da;case"html":case Du:return Du;default:return e}},tm=(e="")=>{const t=String(e).toLowerCase();return t.endsWith(".docx")?br:t.endsWith(".pdf")?Da:t.endsWith(".html")||t.endsWith(".htm")?Du:t.endsWith(".md")||t.endsWith(".markdown")?"text/markdown":""},F6=e=>e==="application/vnd.openxmlformats-officedocument.wordprocessingml.document"?"document.docx":e==="application/pdf"?"document.pdf":e==="text/html"?"document.html":"document",N6="application/octet-stream",bb=e=>{if(e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"collaboration")){const n={...e};delete n.collaboration,e={...n,v2Collaboration:Kk(e)}}if(xl(e))return{type:br,data:gb(e),name:"document.docx"};const t=Ff(e);if(t){const n=e&&typeof e.name=="string"?e.name:"",r=t.name||"",o=tm(n),i=o||tm(r),s=t.type.toLowerCase()===N6,a=s&&o?n:r||n||"document",l=s&&i?i:t.type||i||"application/vnd.openxmlformats-officedocument.wordprocessingml.document";let u=t;return s&&i&&typeof File=="function"&&t instanceof File?u=new File([t],a,{type:l,lastModified:t.lastModified}):s&&i&&typeof Blob=="function"&&t instanceof Blob&&(u=new Blob([t],{type:l})),{...e.v2Collaboration!==void 0?{v2Collaboration:e.v2Collaboration}:{},type:l,data:u,name:a}}if(e&&typeof e=="object"&&"data"in e){if(xl(e.data)){const r=yb(e.type||tm(e.name)||"application/vnd.openxmlformats-officedocument.wordprocessingml.document");return{...e,type:r,data:r==="application/vnd.openxmlformats-officedocument.wordprocessingml.document"?gb(e.data):vb(e.data,r),name:e.name||F6(r)}}const n=Ff(e.data,e.name);if(n){const r=typeof e.type=="string"&&e.type?yb(e.type):"",o=r||n.type||tm(n.name)||"application/vnd.openxmlformats-officedocument.wordprocessingml.document",i=!n.type||!!(r&&n.type!==r);let s=n;return i&&typeof File=="function"&&n instanceof File?s=new File([n],n.name,{type:o,lastModified:n.lastModified}):i&&typeof Blob=="function"&&n instanceof Blob&&(s=new Blob([n],{type:o})),{...e,type:o,data:s,name:e.name||n.name||"document"}}}if(e&&typeof e=="object"&&"url"in e&&typeof e.type=="string"){const n=yb(e.type);if(n!==e.type)return{...e,type:n}}return e};Ft();function B6(e,t){const n=e.itemid,r=e,o=t!==null&&typeof t=="object"?Qr({...t}):te(t),i=te(null);return jt(o,(a,l)=>{const u={fieldId:n.value,changeTime:Date.now(),oldValue:l,newValue:a,originalField:r};i.value=u}),{value:o}}function z6(e){const t=te(e.itemid),n=te(e.itemicon),r=te(e.itemiconpack),o=te(e.itemdisplaylabel),i=e.itemlinkvalue,s=e.itemplaceholdertext,{value:a}=B6(e,i,te([])),l=te(e.itemtype),u=te(e.itemfieldtype),d=e,f=Qr({fontFamily:e.fontfamily||"Arial",fontSize:e.font_size||"12pt",originalFontSize:e.original_font_size||"12pt"}),p=te(e.logicrules),g=te(!1),m=Qr({}),v={SELECT:V6,IMAGEINPUT:j6,CHECKBOXINPUT:U6};return l.value in v&&Object.assign(m,v[l.value](e)),{id:t,icon:n,iconPack:r,label:o,placeholder:s,fieldType:l,fieldSubType:u,value:a,format:te(e.itemformat),logicRules:p,hidden:g,originalJSON:d,fieldStyle:f,valueGetter:e.valueGetter,...m}}function j6(e){return{fontfamily:te(e.fontfamily),iteminputtype:te(e.iteminputtype)}}function V6(e){return{options:te(e.itemoptions)}}function U6(e){const t=te(e.itemoptions);return t.value&&(t.value=t.value.map(n=>({label:n.itemdisplaylabel,value:n.itemlinkvalue,checked:n.ischecked,id:n.itemid,annotationId:n.annotationId}))),{options:t}}var Ys=()=>new Map,wb=e=>{const t=Ys();return e.forEach((n,r)=>{t.set(r,n)}),t},Nu=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},$6=(e,t)=>{const n=[];for(const[r,o]of e)n.push(t(o,r));return n},H6=(e,t)=>{for(const[n,r]of e)if(t(r,n))return!0;return!1},Bu=()=>new Set,Cb=e=>e[e.length-1],zu=Array.from,kb=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},Qk=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},G6=(e,t)=>{const n=new Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},nm=Array.isArray,W6=class{constructor(){this._observers=Ys()}on(e,t){return Nu(this._observers,e,Bu).add(t),t}once(e,t){const n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){const n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return zu((this._observers.get(e)||Ys()).values()).forEach(n=>n(...t))}destroy(){this._observers=Ys()}},Oa=Math.floor,rm=Math.abs,Jk=(e,t)=>e<t?e:t,ju=(e,t)=>e>t?e:t,rY=Number.isNaN,K6=e=>e!==0?e<0:1/e<0,oY=1,iY=2,sY=4,aY=8,lY=32,cY=64,uY=128,q6=1<<17,Y6=1<<18,X6=1<<19,Z6=1<<20,Q6=1<<21,J6=1<<22,e8=1<<23,t8=1<<24,n8=1<<25,r8=1<<26,o8=1<<27,i8=1<<28,s8=1<<29,a8=1<<30,dY=31,fY=63,hY=127,pY=q6-1,mY=Y6-1,gY=X6-1,vY=Z6-1,yY=Q6-1,bY=J6-1,wY=e8-1,CY=t8-1,kY=n8-1,SY=r8-1,_Y=o8-1,AY=i8-1,IY=s8-1,EY=a8-1,xY=2147483647,e3=Number.MAX_SAFE_INTEGER,t3=Number.MIN_SAFE_INTEGER,l8=Number.isInteger||(e=>typeof e=="number"&&isFinite(e)&&Oa(e)===e),TY=Number.isNaN,RY=Number.parseInt,n3=String.fromCharCode,MY=String.fromCodePoint,LY=n3(65535),c8=e=>e.toLowerCase(),u8=/^\s*/g,d8=e=>e.replace(u8,""),f8=/([A-Z])/g,r3=(e,t)=>d8(e.replace(f8,n=>`${t}${c8(n)}`)),h8=e=>{const t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let o=0;o<n;o++)r[o]=t.codePointAt(o);return r},Nf=typeof TextEncoder<"u"?new TextEncoder:null,p8=e=>Nf.encode(e),m8=Nf?p8:h8,Sb=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Sb&&Sb.decode(new Uint8Array).length===1&&(Sb=null);var g8=(e,t)=>G6(t,()=>e).join(""),Bf=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},_b=()=>new Bf,v8=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},Fa=e=>{const t=new Uint8Array(v8(e));let n=0;for(let r=0;r<e.bufs.length;r++){const o=e.bufs[r];t.set(o,n),n+=o.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},y8=(e,t)=>{const n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(ju(n,t)*2),e.cpos=0)},uo=(e,t)=>{const n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},Ab=uo,or=(e,t)=>{for(;t>127;)uo(e,128|127&t),t=Oa(t/128);uo(e,127&t)},Ib=(e,t)=>{const n=K6(t);for(n&&(t=-t),uo(e,(t>63?128:0)|(n?64:0)|63&t),t=Oa(t/64);t>0;)uo(e,(t>127?128:0)|127&t),t=Oa(t/128)},Eb=new Uint8Array(3e4),b8=Eb.length/3,w8=(e,t)=>{if(t.length<b8){const n=Nf.encodeInto(t,Eb).written||0;or(e,n);for(let r=0;r<n;r++)uo(e,Eb[r])}else Ei(e,m8(t))},C8=(e,t)=>{const n=unescape(encodeURIComponent(t)),r=n.length;or(e,r);for(let o=0;o<r;o++)uo(e,n.codePointAt(o))},Vu=Nf&&Nf.encodeInto?w8:C8,xb=(e,t)=>{const n=e.cbuf.length,r=e.cpos,o=Jk(n-r,t.length),i=t.length-o;e.cbuf.set(t.subarray(0,o),r),e.cpos+=o,i>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(ju(n*2,i)),e.cbuf.set(t.subarray(o)),e.cpos=i)},Ei=(e,t)=>{or(e,t.byteLength),xb(e,t)},Tb=(e,t)=>{y8(e,t);const n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},k8=(e,t)=>Tb(e,4).setFloat32(0,t,!1),S8=(e,t)=>Tb(e,8).setFloat64(0,t,!1),_8=(e,t)=>Tb(e,8).setBigInt64(0,t,!1),o3=new DataView(new ArrayBuffer(4)),A8=e=>(o3.setFloat32(0,e),o3.getFloat32(0)===e),zf=(e,t)=>{switch(typeof t){case"string":uo(e,119),Vu(e,t);break;case"number":l8(t)&&rm(t)<=2147483647?(uo(e,125),Ib(e,t)):A8(t)?(uo(e,124),k8(e,t)):(uo(e,123),S8(e,t));break;case"bigint":uo(e,122),_8(e,t);break;case"object":if(t===null)uo(e,126);else if(nm(t)){uo(e,117),or(e,t.length);for(let n=0;n<t.length;n++)zf(e,t[n])}else if(t instanceof Uint8Array)uo(e,116),Ei(e,t);else{uo(e,118);const n=Object.keys(t);or(e,n.length);for(let r=0;r<n.length;r++){const o=n[r];Vu(e,o),zf(e,t[o])}}break;case"boolean":uo(e,t?120:121);break;default:uo(e,127)}},i3=class extends Bf{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&or(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},s3=e=>{e.count>0&&(Ib(e.encoder,e.count===1?e.s:-e.s),e.count>1&&or(e.encoder,e.count-2))},om=class{constructor(){this.encoder=new Bf,this.s=0,this.count=0}write(e){this.s===e?this.count++:(s3(this),this.count=1,this.s=e)}toUint8Array(){return s3(this),Fa(this.encoder)}},a3=e=>{if(e.count>0){const t=e.diff*2+(e.count===1?0:1);Ib(e.encoder,t),e.count>1&&or(e.encoder,e.count-2)}},Rb=class{constructor(){this.encoder=new Bf,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(a3(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return a3(this),Fa(this.encoder)}},I8=class{constructor(){this.sarr=[],this.s="",this.lensE=new om}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new Bf;return this.sarr.push(this.s),this.s="",Vu(e,this.sarr.join("")),xb(e,this.lensE.toUint8Array()),Fa(e)}},Tl=e=>new Error(e),fs=()=>{throw Tl("Method unimplemented")},Na=()=>{throw Tl("Unexpected case")},PY=crypto.subtle,E8=crypto.getRandomValues.bind(crypto),l3=()=>E8(new Uint32Array(1))[0],x8="10000000-1000-4000-8000-100000000000",T8=()=>x8.replace(/[018]/g,e=>(e^l3()&15>>e/4).toString(16)),R8=Date.now,c3=e=>new Promise(e),DY=Promise.all.bind(Promise),u3=e=>e===void 0?null:e,M8=class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}},d3=new M8,L8=!0;try{typeof localStorage<"u"&&localStorage&&(d3=localStorage,L8=!1)}catch{}var P8=d3,jf=Symbol("Equality"),f3=(e,t)=>e===t||!!e?.[jf]?.(t)||!1,D8=e=>typeof e=="object",O8=Object.assign,F8=Object.keys,N8=(e,t)=>{for(const n in e)t(e[n],n)},im=e=>F8(e).length,B8=e=>{for(const t in e)return!1;return!0},Vf=(e,t)=>{for(const n in e)if(!t(e[n],n))return!1;return!0},Mb=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),z8=(e,t)=>e===t||im(e)===im(t)&&Vf(e,(n,r)=>(n!==void 0||Mb(t,r))&&f3(t[r],n)),j8=Object.freeze,h3=e=>{for(const t in e){const n=e[t];(typeof n=="object"||typeof n=="function")&&h3(e[t])}return j8(e)},Lb=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&Lb(e,t,n+1)}},sm=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[jf]!=null)return e[jf](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(const n of e.keys())if(!t.has(n)||!sm(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(im(e)!==im(t))return!1;for(const n in e)if(!Mb(e,n)||!sm(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!sm(e[n],t[n]))return!1;break;default:return!1}return!0},V8=(e,t)=>t.includes(e),Uf=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",OY=typeof navigator<"u"?/Mac/.test(navigator.platform):!1,Xs,U8=[],$8=()=>{if(Xs===void 0)if(Uf){Xs=Ys();const e=process.argv;let t=null;for(let n=0;n<e.length;n++){const r=e[n];r[0]==="-"?(t!==null&&Xs.set(t,""),t=r):t!==null?(Xs.set(t,r),t=null):U8.push(r)}t!==null&&Xs.set(t,"")}else typeof location=="object"?(Xs=Ys(),(location.search||"?").slice(1).split("&").forEach(e=>{if(e.length!==0){const[t,n]=e.split("=");Xs.set(`--${r3(t,"-")}`,n),Xs.set(`-${r3(t,"-")}`,n)}})):Xs=Ys();return Xs},Pb=e=>$8().has(e),am=e=>u3(Uf?process.env[e.toUpperCase().replaceAll("-","_")]:P8.getItem(e)),p3=e=>Pb("--"+e)||am(e)!==null,H8=p3("production"),G8=Uf&&V8(process.env.FORCE_COLOR,["true","1","2"]),W8=G8||!Pb("--no-colors")&&!p3("no-color")&&(!Uf||process.stdout.isTTY)&&(!Uf||Pb("--color")||am("COLORTERM")!==null||(am("TERM")||"").includes("color")),K8=class{constructor(e,t){this.left=e,this.right=t}},Ba=(e,t)=>new K8(e,t),m3=e=>e.next()>=.5,Db=(e,t,n)=>Oa(e.next()*(n+1-t)+t),g3=(e,t,n)=>Oa(e.next()*(n+1-t)+t),Ob=(e,t,n)=>g3(e,t,n),q8=e=>n3(Ob(e,97,122)),Y8=(e,t=0,n=20)=>{const r=Ob(e,t,n);let o="";for(let i=0;i<r;i++)o+=q8(e);return o},Fb=(e,t)=>t[Ob(e,0,t.length-1)],X8=Symbol("0schema"),Z8=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){const e=[];for(let t=this._rerrs.length-1;t>0;t--){const n=this._rerrs[t];e.push(g8(" ",(this._rerrs.length-t)*2)+`${n.path!=null?`[${n.path}] `:""}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
5
5
|
`)}},Nb=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[jf]?f3(e,t):nm(e)?kb(e,n=>Qk(t,r=>Nb(n,r))):D8(e)?Vf(e,(n,r)=>Nb(n,t[r])):!1,qo=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),Nb(t,n)}equals(e){return this.constructor===e.constructor&&sm(this.shape,e.shape)}[X8](){return!0}[jf](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){fs()}get nullable(){return Uu(this,hm)}get optional(){return new b3(this)}cast(e){return P3(e,this),e}expect(e){return P3(e,this),e}},Bb=class extends qo{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){const n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor!==this.shape?"Constructor match failed":"Check failed"),n}},Wr=(e,t=null)=>new Bb(e,t),FY=Wr(Bb),zb=class extends qo{constructor(e){super(),this.shape=e}check(e,t){const n=this.shape(e);return!n&&t?.extend(null,"custom prop",e?.constructor.name,"failed to check custom prop"),n}},fo=e=>new zb(e),NY=Wr(zb),lm=class extends qo{constructor(e){super(),this.shape=e}check(e,t){const n=this.shape.some(r=>r===e);return!n&&t?.extend(null,this.shape.join(" | "),e.toString()),n}},cm=(...e)=>new lm(e),v3=Wr(lm),Q8=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,t=>"\\"+t)),y3=e=>{if(Hu.check(e))return[Q8(e)];if(v3.check(e))return e.shape.map(t=>t+"");if(R3.check(e))return["[+-]?\\d+.?\\d*"];if(M3.check(e))return[".*"];if(um.check(e))return e.shape.map(y3).flat(1);Na()},J8=class extends qo{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(y3).map(t=>`(${t.join("|")})`).join("")+"$")}check(e,t){const n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),"String doesn't match string template."),n}},BY=Wr(J8),eR=Symbol("optional"),b3=class extends qo{constructor(e){super(),this.shape=e}check(e,t){const n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,"undefined (optional)","()"),n}get[eR](){return!0}},tR=Wr(b3),w3=class extends qo{check(e,t){return t?.extend(null,"never",typeof e),!1}},zY=new w3,jY=Wr(w3),C3=class Ix extends qo{constructor(t,n=!1){super(),this.shape=t,this._isPartial=n}static _dilutes=!0;get partial(){return new Ix(this.shape,!0)}check(t,n){return t==null?(n?.extend(null,"object","null"),!1):Vf(this.shape,(r,o)=>{const i=this._isPartial&&!Mb(t,o)||r.check(t[o],n);return!i&&n?.extend(o.toString(),r.toString(),typeof t[o],"Object property does not match"),i})}},nR=e=>new C3(e),rR=Wr(C3),oR=fo(e=>e!=null&&(e.constructor===Object||e.constructor==null)),k3=class extends qo{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&Vf(e,(n,r)=>{const o=this.shape.keys.check(r,t);return!o&&t?.extend(r+"","Record",typeof e,o?"Key doesn't match schema":"Value doesn't match value"),o&&this.shape.values.check(n,t)})}},S3=(e,t)=>new k3(e,t),iR=Wr(k3),_3=class extends qo{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&Vf(this.shape,(n,r)=>{const o=n.check(e[r],t);return!o&&t?.extend(r.toString(),"Tuple",typeof n),o})}},sR=(...e)=>new _3(e),VY=Wr(_3),A3=class extends qo{constructor(e){super(),this.shape=e.length===1?e[0]:new jb(e)}check(e,t){const n=nm(e)&&kb(e,r=>this.shape.check(r));return!n&&t?.extend(null,"Array",""),n}},I3=(...e)=>new A3(e),aR=Wr(A3),lR=fo(e=>nm(e)),E3=class extends qo{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){const n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}},cR=(e,t=null)=>new E3(e,t),UY=Wr(E3),uR=cR(qo),dR=class extends qo{constructor(e){super(),this.len=e.length-1,this.args=sR(...e.slice(-1)),this.res=e[this.len]}check(e,t){const n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,"function",typeof e),n}},fR=Wr(dR),hR=fo(e=>typeof e=="function"),pR=class extends qo{constructor(e){super(),this.shape=e}check(e,t){const n=kb(this.shape,r=>r.check(e,t));return!n&&t?.extend(null,"Intersectinon",typeof e),n}},$Y=Wr(pR,e=>e.shape.length>0),jb=class extends qo{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){const n=Qk(this.shape,r=>r.check(e,t));return t?.extend(null,"Union",typeof e),n}},Uu=(...e)=>e.findIndex(t=>um.check(t))>=0?Uu(...e.map(t=>$f(t)).map(t=>um.check(t)?t.shape:[t]).flat(1)):e.length===1?e[0]:new jb(e),um=Wr(jb),x3=()=>!0,dm=fo(x3),mR=Wr(zb,e=>e.shape===x3),Vb=fo(e=>typeof e=="bigint"),gR=fo(e=>e===Vb),T3=fo(e=>typeof e=="symbol"),HY=fo(e=>e===T3),$u=fo(e=>typeof e=="number"),R3=fo(e=>e===$u),Hu=fo(e=>typeof e=="string"),M3=fo(e=>e===Hu),fm=fo(e=>typeof e=="boolean"),vR=fo(e=>e===fm),L3=cm(void 0),GY=Wr(lm,e=>e.shape.length===1&&e.shape[0]===void 0),WY=cm(void 0),hm=cm(null),yR=Wr(lm,e=>e.shape.length===1&&e.shape[0]===null),KY=Wr(Uint8Array),qY=Wr(Bb,e=>e.shape===Uint8Array),bR=Uu($u,Hu,hm,L3,Vb,fm,T3),YY=(()=>{const e=I3(dm),t=S3(Hu,dm),n=Uu($u,Hu,hm,fm,e,t);return e.shape=n,t.shape.values=n,n})(),$f=e=>{if(uR.check(e))return e;if(oR.check(e)){const t={};for(const n in e)t[n]=$f(e[n]);return nR(t)}else{if(lR.check(e))return Uu(...e.map($f));if(bR.check(e))return cm(e);if(hR.check(e))return Wr(e)}Na()},P3=H8?()=>{}:(e,t)=>{const n=new Z8;if(!t.check(e,n))throw Tl(`Expected value to be of type ${t.constructor.name}.
|
|
6
6
|
${n.toString()}`)},wR=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:$f(e),h:t}),this}else(e){return this.if(dm,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){const r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw Tl("Unhandled pattern")}}},CR=e=>new wR(e),D3=CR(dm).if(R3,(e,t)=>Db(t,t3,e3)).if(M3,(e,t)=>Y8(t)).if(vR,(e,t)=>m3(t)).if(gR,(e,t)=>BigInt(Db(t,t3,e3))).if(um,(e,t)=>Gu(t,Fb(t,e.shape))).if(rR,(e,t)=>{const n={};for(const r in e.shape){let o=e.shape[r];if(tR.check(o)){if(m3(t))continue;o=o.shape}n[r]=D3(o,t)}return n}).if(aR,(e,t)=>{const n=[],r=g3(t,0,42);for(let o=0;o<r;o++)n.push(Gu(t,e.shape));return n}).if(v3,(e,t)=>Fb(t,e.shape)).if(yR,(e,t)=>null).if(fR,(e,t)=>{const n=Gu(t,e.res);return()=>n}).if(mR,(e,t)=>Gu(t,Fb(t,[$u,Hu,hm,L3,Vb,fm,I3($u),S3(Uu("a","b","c"),$u)]))).if(iR,(e,t)=>{const n={},r=Db(t,0,3);for(let o=0;o<r;o++){const i=Gu(t,e.shape.keys);n[i]=Gu(t,e.shape.values)}return n}).done(),Gu=(e,t)=>D3($f(t),e),xc=typeof document<"u"?document:{},XY=fo(e=>e.nodeType===IR),ZY=typeof DOMParser<"u"?new DOMParser:null,QY=fo(e=>e.nodeType===SR),JY=fo(e=>e.nodeType===_R),kR=e=>$6(e,(t,n)=>`${n}:${t};`).join(""),SR=xc.ELEMENT_NODE,_R=xc.TEXT_NODE,eX=xc.CDATA_SECTION_NODE,tX=xc.COMMENT_NODE,AR=xc.DOCUMENT_NODE,nX=xc.DOCUMENT_TYPE_NODE,IR=xc.DOCUMENT_FRAGMENT_NODE,rX=fo(e=>e.nodeType===AR),za=Symbol,O3=za(),F3=za(),ER=za(),xR=za(),TR=za(),N3=za(),RR=za(),Ub=za(),MR=za(),LR=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());const t=[],n=[];let r=0;for(;r<e.length;r++){const o=e[r];if(o===void 0)break;if(o.constructor===String||o.constructor===Number)t.push(o);else if(o.constructor===Object)break}for(r>0&&n.push(t.join(""));r<e.length;r++){const o=e[r];o instanceof Symbol||n.push(o)}return n},oX=R8(),PR={[O3]:Ba("font-weight","bold"),[F3]:Ba("font-weight","normal"),[ER]:Ba("color","blue"),[TR]:Ba("color","green"),[xR]:Ba("color","grey"),[N3]:Ba("color","red"),[RR]:Ba("color","purple"),[Ub]:Ba("color","orange"),[MR]:Ba("color","black")},DR=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());const t=[],n=[],r=Ys();let o=[],i=0;for(;i<e.length;i++){const s=e[i],a=PR[s];if(a!==void 0)r.set(a.left,a.right);else{if(s===void 0)break;if(s.constructor===String||s.constructor===Number){const l=kR(r);i>0||l.length>0?(t.push("%c"+s),n.push(l)):t.push(s)}else break}}for(i>0&&(o=n,o.unshift(t.join("")));i<e.length;i++){const s=e[i];s instanceof Symbol||o.push(s)}return o},B3=W8?DR:LR,OR=(...e)=>{console.log(...B3(e)),z3.forEach(t=>t.print(e))},FR=(...e)=>{console.warn(...B3(e)),e.unshift(Ub),z3.forEach(t=>t.print(e))},z3=Bu(),j3=e=>({[Symbol.iterator](){return this},next:e}),NR=(e,t)=>j3(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),$b=(e,t)=>j3(()=>{const{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),V3=class{constructor(e,t){this.clock=e,this.len=t}},U3=class{constructor(){this.clients=new Map}},$3=(e,t,n)=>t.clients.forEach((r,o)=>{const i=e.doc.store.clients.get(o);if(i!=null){const s=i[i.length-1],a=s.id.clock+s.length;for(let l=0,u=r[l];l<r.length&&u.clock<a;u=r[++l])eS(e,i,u.clock,u.len,n)}}),BR=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){const o=Oa((n+r)/2),i=e[o],s=i.clock;if(s<=t){if(t<s+i.len)return o;n=o+1}else r=o-1}return null},H3=(e,t)=>{const n=e.clients.get(t.client);return n!==void 0&&BR(n,t.clock)!==null},G3=e=>{e.clients.forEach(t=>{t.sort((o,i)=>o.clock-i.clock);let n,r;for(n=1,r=1;n<t.length;n++){const o=t[r-1],i=t[n];o.clock+o.len>=i.clock?t[r-1]=new V3(o.clock,ju(o.len,i.clock+i.len-o.clock)):(r<n&&(t[r]=i),r++)}t.length=r})},W3=(e,t,n,r)=>{Nu(e.clients,t,()=>[]).push(new V3(n,r))},zR=()=>new U3,jR=(e,t)=>{or(e.restEncoder,t.clients.size),zu(t.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{e.resetDsCurVal(),or(e.restEncoder,n);const o=r.length;or(e.restEncoder,o);for(let i=0;i<o;i++){const s=r[i];e.writeDsClock(s.clock),e.writeDsLen(s.len)}})},K3=l3,Hb=class Ex extends W6{constructor({guid:t=T8(),collectionid:n=null,gc:r=!0,gcFilter:o=()=>!0,meta:i=null,autoLoad:s=!1,shouldLoad:a=!0}={}){super(),this.gc=r,this.gcFilter=o,this.clientID=K3(),this.guid=t,this.collectionid=n,this.share=new Map,this.store=new QR,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=a,this.autoLoad=s,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=c3(u=>{this.on("load",()=>{this.isLoaded=!0,u(this)})});const l=()=>c3(u=>{const d=f=>{(f===void 0||f===!0)&&(this.off("sync",d),u())};this.on("sync",d)});this.on("sync",u=>{u===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=u===void 0||u===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const t=this._item;t!==null&&!this.shouldLoad&&pr(t.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(zu(this.subdocs).map(t=>t.guid))}transact(t,n=null){return pr(this,t,n)}get(t,n=So){const r=Nu(this.share,t,()=>{const i=new n;return i._integrate(this,null),i}),o=r.constructor;if(n!==So&&o!==n)if(o===So){const i=new n;i._map=r._map,r._map.forEach(s=>{for(;s!==null;s=s.left)s.parent=i}),i._start=r._start;for(let s=i._start;s!==null;s=s.right)s.parent=i;return i._length=r._length,this.share.set(t,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${t} has already been defined with a different constructor`);return r}getArray(t=""){return this.get(t,f7)}getText(t=""){return this.get(t,y7)}getMap(t=""){return this.get(t,Qb)}getXmlElement(t=""){return this.get(t,SS)}getXmlFragment(t=""){return this.get(t,n0)}toJSON(){const t={};return this.share.forEach((n,r)=>{t[r]=n.toJSON()}),t}destroy(){this.isDestroyed=!0,zu(this.subdocs).forEach(n=>n.destroy());const t=this._item;if(t!==null){this._item=null;const n=t.content;n.doc=new Ex({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,pr(t.parent.doc,r=>{const o=n.doc;t.deleted||r.subdocsAdded.add(o),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}},VR=class{constructor(){this.restEncoder=_b()}toUint8Array(){return Fa(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){or(this.restEncoder,e)}writeDsLen(e){or(this.restEncoder,e)}},UR=class extends VR{writeLeftID(e){or(this.restEncoder,e.client),or(this.restEncoder,e.clock)}writeRightID(e){or(this.restEncoder,e.client),or(this.restEncoder,e.clock)}writeClient(e){or(this.restEncoder,e)}writeInfo(e){Ab(this.restEncoder,e)}writeString(e){Vu(this.restEncoder,e)}writeParentInfo(e){or(this.restEncoder,e?1:0)}writeTypeRef(e){or(this.restEncoder,e)}writeLen(e){or(this.restEncoder,e)}writeAny(e){zf(this.restEncoder,e)}writeBuf(e){Ei(this.restEncoder,e)}writeJSON(e){Vu(this.restEncoder,JSON.stringify(e))}writeKey(e){Vu(this.restEncoder,e)}},$R=class{constructor(){this.restEncoder=_b(),this.dsCurrVal=0}toUint8Array(){return Fa(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,or(this.restEncoder,t)}writeDsLen(e){e===0&&Na(),or(this.restEncoder,e-1),this.dsCurrVal+=e}},HR=class extends $R{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Rb,this.clientEncoder=new om,this.leftClockEncoder=new Rb,this.rightClockEncoder=new Rb,this.infoEncoder=new i3(Ab),this.stringEncoder=new I8,this.parentInfoEncoder=new i3(Ab),this.typeRefEncoder=new om,this.lenEncoder=new om}toUint8Array(){const e=_b();return or(e,0),Ei(e,this.keyClockEncoder.toUint8Array()),Ei(e,this.clientEncoder.toUint8Array()),Ei(e,this.leftClockEncoder.toUint8Array()),Ei(e,this.rightClockEncoder.toUint8Array()),Ei(e,Fa(this.infoEncoder)),Ei(e,this.stringEncoder.toUint8Array()),Ei(e,Fa(this.parentInfoEncoder)),Ei(e,this.typeRefEncoder.toUint8Array()),Ei(e,this.lenEncoder.toUint8Array()),xb(e,Fa(this.restEncoder)),Fa(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){zf(this.restEncoder,e)}writeBuf(e){Ei(this.restEncoder,e)}writeJSON(e){zf(this.restEncoder,e)}writeKey(e){const t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}},GR=(e,t,n,r)=>{r=ju(r,t[0].id.clock);const o=ja(t,r);or(e.restEncoder,t.length-o),e.writeClient(n),or(e.restEncoder,r);const i=t[o];i.write(e,r-i.id.clock);for(let s=o+1;s<t.length;s++)t[s].write(e,0)},WR=(e,t,n)=>{const r=new Map;n.forEach((o,i)=>{ai(t,i)>o&&r.set(i,o)}),Wb(t).forEach((o,i)=>{n.has(i)||r.set(i,0)}),or(e.restEncoder,r.size),zu(r.entries()).sort((o,i)=>i[0]-o[0]).forEach(([o,i])=>{GR(e,t.clients.get(o),o,i)})},KR=(e,t)=>WR(e,t.doc.store,t.beforeState),qR=class{constructor(){this.l=[]}},q3=()=>new qR,Y3=(e,t)=>e.l.push(t),X3=(e,t)=>{const n=e.l,r=n.length;e.l=n.filter(o=>t!==o),r===e.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},Z3=(e,t,n)=>Lb(e.l,[t,n]),pm=class{constructor(e,t){this.client=e,this.clock=t}},mm=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,Fr=(e,t)=>new pm(e,t),YR=e=>{for(const[t,n]of e.doc.share.entries())if(n===e)return t;throw Na()},XR=class{constructor(e,t){this.ds=e,this.sv=t}},ZR=(e,t)=>new XR(e,t),iX=ZR(zR(),new Map),Wu=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!H3(t.ds,e.id),Gb=(e,t)=>{const n=Nu(e.meta,Gb,Bu),r=e.doc.store;n.has(t)||(t.sv.forEach((o,i)=>{o<ai(r,i)&&Rl(e,Fr(i,o))}),$3(e,t.ds,o=>{}),n.add(t))},QR=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},Wb=e=>{const t=new Map;return e.clients.forEach((n,r)=>{const o=n[n.length-1];t.set(r,o.id.clock+o.length)}),t},ai=(e,t)=>{const n=e.clients.get(t);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},Q3=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==t.id.clock)throw Na()}n.push(t)},ja=(e,t)=>{let n=0,r=e.length-1,o=e[r],i=o.id.clock;if(i===t)return r;let s=Oa(t/(i+o.length-1)*r);for(;n<=r;){if(o=e[s],i=o.id.clock,i<=t){if(t<i+o.length)return s;n=s+1}else r=s-1;s=Oa((n+r)/2)}throw Na()},JR=(e,t)=>{const n=e.clients.get(t.client);return n[ja(n,t.clock)]},Kb=JR,qb=(e,t,n)=>{const r=ja(t,n),o=t[r];return o.id.clock<n&&o instanceof xi?(t.splice(r+1,0,ES(e,o,n-o.id.clock)),r+1):r},Rl=(e,t)=>{const n=e.doc.store.clients.get(t.client);return n[qb(e,n,t.clock)]},J3=(e,t,n)=>{const r=t.clients.get(n.client),o=ja(r,n.clock),i=r[o];return n.clock!==i.id.clock+i.length-1&&i.constructor!==Ll&&r.splice(o+1,0,ES(e,i,n.clock-i.id.clock+1)),i},e7=(e,t,n)=>{const r=e.clients.get(t.id.client);r[ja(r,t.id.clock)]=n},eS=(e,t,n,r,o)=>{if(r===0)return;const i=n+r;let s=qb(e,t,n),a;do a=t[s++],i<a.id.clock+a.length&&qb(e,t,i),o(a);while(s<t.length&&t[s].id.clock<i)},t7=class{constructor(e,t,n){this.doc=e,this.deleteSet=new U3,this.beforeState=Wb(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},tS=(e,t)=>t.deleteSet.clients.size===0&&!H6(t.afterState,(n,r)=>t.beforeState.get(r)!==n)?!1:(G3(t.deleteSet),KR(e,t),jR(e,t.deleteSet),!0),nS=(e,t,n)=>{const r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&Nu(e.changed,t,Bu).add(n)},gm=(e,t)=>{let n=e[t],r=e[t-1],o=t;for(;o>0;n=r,r=e[--o-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof xi&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const i=t-o;return i&&e.splice(t+1-i,i),i},n7=(e,t,n)=>{for(const[r,o]of e.clients.entries()){const i=t.clients.get(r);for(let s=o.length-1;s>=0;s--){const a=o[s],l=a.clock+a.len;for(let u=ja(i,a.clock),d=i[u];u<i.length&&d.id.clock<l;d=i[++u]){const f=i[u];if(a.clock+a.len<=f.id.clock)break;f instanceof xi&&f.deleted&&!f.keep&&n(f)&&f.gc(t,!1)}}}},r7=(e,t)=>{e.clients.forEach((n,r)=>{const o=t.clients.get(r);for(let i=n.length-1;i>=0;i--){const s=n[i],a=Jk(o.length-1,1+ja(o,s.clock+s.len-1));for(let l=a,u=o[l];l>0&&u.id.clock>=s.clock;u=o[l])l-=1+gm(o,l)}})},rS=(e,t)=>{if(t<e.length){const n=e[t],r=n.doc,o=r.store,i=n.deleteSet,s=n._mergeStructs;try{G3(i),n.afterState=Wb(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const a=[];n.changed.forEach((l,u)=>a.push(()=>{(u._item===null||!u._item.deleted)&&u._callObserver(n,l)})),a.push(()=>{n.changedParentTypes.forEach((l,u)=>{u._dEH.l.length>0&&(u._item===null||!u._item.deleted)&&(l=l.filter(d=>d.target._item===null||!d.target._item.deleted),l.forEach(d=>{d.currentTarget=u,d._path=null}),l.sort((d,f)=>d.path.length-f.path.length),a.push(()=>{Z3(u._dEH,l,n)}))}),a.push(()=>r.emit("afterTransaction",[n,r])),a.push(()=>{n._needFormattingCleanup&&g7(n)})}),Lb(a,[])}finally{r.gc&&n7(i,o,r.gcFilter),r7(i,o),n.afterState.forEach((d,f)=>{const p=n.beforeState.get(f)||0;if(p!==d){const g=o.clients.get(f),m=ju(ja(g,p),1);for(let v=g.length-1;v>=m;)v-=1+gm(g,v)}});for(let d=s.length-1;d>=0;d--){const{client:f,clock:p}=s[d].id,g=o.clients.get(f),m=ja(g,p);m+1<g.length&&gm(g,m+1)>1||m>0&&gm(g,m)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(OR(Ub,O3,"[yjs] ",F3,N3,"Changed the client-id because another client seems to be using it."),r.clientID=K3()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const d=new UR;tS(d,n)&&r.emit("update",[d.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const d=new HR;tS(d,n)&&r.emit("updateV2",[d.toUint8Array(),n.origin,r,n])}const{subdocsAdded:a,subdocsLoaded:l,subdocsRemoved:u}=n;(a.size>0||u.size>0||l.size>0)&&(a.forEach(d=>{d.clientID=r.clientID,d.collectionid==null&&(d.collectionid=r.collectionid),r.subdocs.add(d)}),u.forEach(d=>r.subdocs.delete(d)),r.emit("subdocs",[{loaded:l,added:a,removed:u},r,n]),u.forEach(d=>d.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,e])):rS(e,t+1)}}},pr=(e,t,n=null,r=!0)=>{const o=e._transactionCleanups;let i=!1,s=null;e._transaction===null&&(i=!0,e._transaction=new t7(e,n,r),o.push(e._transaction),o.length===1&&e.emit("beforeAllTransactions",[e]),e.emit("beforeTransaction",[e._transaction,e]));try{s=t(e._transaction)}finally{if(i){const a=e._transaction===o[0];e._transaction=null,a&&rS(o,0)}}return s},oS="You must not compute changes after the event-handler fired.",vm=class{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=o7(this.currentTarget,this.target))}deletes(e){return H3(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Tl(oS);const e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){const r=t._map.get(n);let o,i;if(this.adds(r)){let s=r.left;for(;s!==null&&this.adds(s);)s=s.left;if(this.deletes(r))if(s!==null&&this.deletes(s))o="delete",i=Cb(s.content.getContent());else return;else s!==null&&this.deletes(s)?(o="update",i=Cb(s.content.getContent())):(o="add",i=void 0)}else if(this.deletes(r))o="delete",i=Cb(r.content.getContent());else return;e.set(n,{action:o,oldValue:i})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw Tl(oS);const t=this.target,n=Bu(),r=Bu(),o=[];if(e={added:n,deleted:r,delta:o,keys:this.keys},this.transaction.changed.get(t).has(null)){let i=null;const s=()=>{i&&o.push(i)};for(let a=t._start;a!==null;a=a.right)a.deleted?this.deletes(a)&&!this.adds(a)&&((i===null||i.delete===void 0)&&(s(),i={delete:0}),i.delete+=a.length,r.add(a)):this.adds(a)?((i===null||i.insert===void 0)&&(s(),i={insert:[]}),i.insert=i.insert.concat(a.content.getContent()),n.add(a)):((i===null||i.retain===void 0)&&(s(),i={retain:0}),i.retain+=a.length);i!==null&&i.retain===void 0&&s()}this._changes=e}return e}},o7=(e,t)=>{const n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let r=0,o=t._item.parent._start;for(;o!==t._item&&o!==null;)!o.deleted&&o.countable&&(r+=o.length),o=o.right;n.unshift(r)}t=t._item.parent}return n},Oo=()=>{FR("Invalid access: Add Yjs type to a document before reading data.")},iS=80,Yb=0,i7=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Yb++}},s7=e=>{e.timestamp=Yb++},sS=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=Yb++},a7=(e,t,n)=>{if(e.length>=iS){const r=e.reduce((o,i)=>o.timestamp<i.timestamp?o:i);return sS(r,t,n),r}else{const r=new i7(t,n);return e.push(r),r}},ym=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;const n=e._searchMarker.length===0?null:e._searchMarker.reduce((i,s)=>rm(t-i.index)<rm(t-s.index)?i:s);let r=e._start,o=0;for(n!==null&&(r=n.p,o=n.index,s7(n));r.right!==null&&o<t;){if(!r.deleted&&r.countable){if(t<o+r.length)break;o+=r.length}r=r.right}for(;r.left!==null&&o>t;)r=r.left,!r.deleted&&r.countable&&(o-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(o-=r.length);return n!==null&&rm(n.index-o)<r.parent.length/iS?(sS(n,r,o),n):a7(e._searchMarker,r,o)},Hf=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){const o=e[r];if(n>0){let i=o.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(o.index-=i.length);if(i===null||i.marker===!0){e.splice(r,1);continue}o.p=i,i.marker=!0}(t<o.index||n>0&&t===o.index)&&(o.index=ju(t,o.index+n))}},bm=(e,t,n)=>{const r=e,o=t.changedParentTypes;for(;Nu(o,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;Z3(r._eH,n,t)},So=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=q3(),this._dEH=q3(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw fs()}clone(){throw fs()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){Y3(this._eH,e)}observeDeep(e){Y3(this._dEH,e)}unobserve(e){X3(this._eH,e)}unobserveDeep(e){X3(this._dEH,e)}toJSON(){}},aS=(e,t,n)=>{e.doc??Oo(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t;const o=[];let i=e._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){const s=i.content.getContent();if(s.length<=t)t-=s.length;else{for(let a=t;a<s.length&&r>0;a++)o.push(s[a]),r--;t=0}}i=i.right}return o},lS=e=>{e.doc??Oo();const t=[];let n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let o=0;o<r.length;o++)t.push(r[o])}n=n.right}return t},Gf=(e,t)=>{let n=0,r=e._start;for(e.doc??Oo();r!==null;){if(r.countable&&!r.deleted){const o=r.content.getContent();for(let i=0;i<o.length;i++)t(o[i],n++,e)}r=r.right}},cS=(e,t)=>{const n=[];return Gf(e,(r,o)=>{n.push(t(r,o,e))}),n},l7=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}const o=n[r++];return n.length<=r&&(n=null),{done:!1,value:o}}}},uS=(e,t)=>{e.doc??Oo();const n=ym(e,t);let r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},wm=(e,t,n,r)=>{let o=n;const i=e.doc,s=i.clientID,a=i.store,l=n===null?t._start:n.right;let u=[];const d=()=>{u.length>0&&(o=new xi(Fr(s,ai(a,s)),o,o&&o.lastId,l,l&&l.id,t,null,new r0(u)),o.integrate(e,0),u=[])};r.forEach(f=>{if(f===null)u.push(f);else switch(f.constructor){case Number:case Object:case Boolean:case Array:case String:u.push(f);break;default:switch(d(),f.constructor){case Uint8Array:case ArrayBuffer:o=new xi(Fr(s,ai(a,s)),o,o&&o.lastId,l,l&&l.id,t,null,new AS(new Uint8Array(f))),o.integrate(e,0);break;case Hb:o=new xi(Fr(s,ai(a,s)),o,o&&o.lastId,l,l&&l.id,t,null,new IS(f)),o.integrate(e,0);break;default:if(f instanceof So)o=new xi(Fr(s,ai(a,s)),o,o&&o.lastId,l,l&&l.id,t,null,new Yu(f)),o.integrate(e,0);else throw new Error("Unexpected content type in insert operation")}}}),d()},dS=()=>Tl("Length exceeded!"),fS=(e,t,n,r)=>{if(n>t._length)throw dS();if(n===0)return t._searchMarker&&Hf(t._searchMarker,n,r.length),wm(e,t,null,r);const o=n,i=ym(t,n);let s=t._start;for(i!==null&&(s=i.p,n-=i.index,n===0&&(s=s.prev,n+=s&&s.countable&&!s.deleted?s.length:0));s!==null;s=s.right)if(!s.deleted&&s.countable){if(n<=s.length){n<s.length&&Rl(e,Fr(s.id.client,s.id.clock+n));break}n-=s.length}return t._searchMarker&&Hf(t._searchMarker,o,r.length),wm(e,t,s,r)},c7=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((o,i)=>i.index>o.index?i:o,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return wm(e,t,r,n)},hS=(e,t,n,r)=>{if(r===0)return;const o=n,i=r,s=ym(t,n);let a=t._start;for(s!==null&&(a=s.p,n-=s.index);a!==null&&n>0;a=a.right)!a.deleted&&a.countable&&(n<a.length&&Rl(e,Fr(a.id.client,a.id.clock+n)),n-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&Rl(e,Fr(a.id.client,a.id.clock+r)),a.delete(e),r-=a.length),a=a.right;if(r>0)throw dS();t._searchMarker&&Hf(t._searchMarker,o,-i+r)},Cm=(e,t,n)=>{const r=t._map.get(n);r!==void 0&&r.delete(e)},Xb=(e,t,n,r)=>{const o=t._map.get(n)||null,i=e.doc,s=i.clientID;let a;if(r==null)a=new r0([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:a=new r0([r]);break;case Uint8Array:a=new AS(r);break;case Hb:a=new IS(r);break;default:if(r instanceof So)a=new Yu(r);else throw new Error("Unexpected content type")}new xi(Fr(s,ai(i.store,s)),o,o&&o.lastId,null,null,t,n,a).integrate(e,0)},Zb=(e,t)=>{e.doc??Oo();const n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},pS=e=>{const t={};return e.doc??Oo(),e._map.forEach((n,r)=>{n.deleted||(t[r]=n.content.getContent()[n.length-1])}),t},mS=(e,t)=>{e.doc??Oo();const n=e._map.get(t);return n!==void 0&&!n.deleted},u7=(e,t)=>{const n={};return e._map.forEach((r,o)=>{let i=r;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&Wu(i,t)&&(n[o]=i.content.getContent()[i.length-1])}),n},km=e=>(e.doc??Oo(),NR(e._map.entries(),t=>!t[1].deleted)),d7=class extends vm{},f7=class sv extends So{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){const n=new sv;return n.push(t),n}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new sv}clone(){const t=new sv;return t.insert(0,this.toArray().map(n=>n instanceof So?n.clone():n)),t}get length(){return this.doc??Oo(),this._length}_callObserver(t,n){super._callObserver(t,n),bm(this,t,new d7(this,t))}insert(t,n){this.doc!==null?pr(this.doc,r=>{fS(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}push(t){this.doc!==null?pr(this.doc,n=>{c7(n,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,n=1){this.doc!==null?pr(this.doc,r=>{hS(r,this,t,n)}):this._prelimContent.splice(t,n)}get(t){return uS(this,t)}toArray(){return lS(this)}slice(t=0,n=this.length){return aS(this,t,n)}toJSON(){return this.map(t=>t instanceof So?t.toJSON():t)}map(t){return cS(this,t)}forEach(t){Gf(this,t)}[Symbol.iterator](){return l7(this)}_write(t){t.writeTypeRef(_7)}},h7=class extends vm{constructor(e,t,n){super(e,t),this.keysChanged=n}},Qb=class i2 extends So{constructor(t){super(),this._prelimContent=null,t===void 0?this._prelimContent=new Map:this._prelimContent=new Map(t)}_integrate(t,n){super._integrate(t,n),this._prelimContent.forEach((r,o)=>{this.set(o,r)}),this._prelimContent=null}_copy(){return new i2}clone(){const t=new i2;return this.forEach((n,r)=>{t.set(r,n instanceof So?n.clone():n)}),t}_callObserver(t,n){bm(this,t,new h7(this,t,n))}toJSON(){this.doc??Oo();const t={};return this._map.forEach((n,r)=>{if(!n.deleted){const o=n.content.getContent()[n.length-1];t[r]=o instanceof So?o.toJSON():o}}),t}get size(){return[...km(this)].length}keys(){return $b(km(this),t=>t[0])}values(){return $b(km(this),t=>t[1].content.getContent()[t[1].length-1])}entries(){return $b(km(this),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??Oo(),this._map.forEach((n,r)=>{n.deleted||t(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(t){this.doc!==null?pr(this.doc,n=>{Cm(n,this,t)}):this._prelimContent.delete(t)}set(t,n){return this.doc!==null?pr(this.doc,r=>{Xb(r,this,t,n)}):this._prelimContent.set(t,n),n}get(t){return Zb(this,t)}has(t){return mS(this,t)}clear(){this.doc!==null?pr(this.doc,t=>{this.forEach(function(n,r,o){Cm(t,o,r)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(A7)}},Ml=(e,t)=>e===t||typeof e=="object"&&typeof t=="object"&&e&&t&&z8(e,t),Jb=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){this.right===null&&Na(),this.right.content.constructor===Fo?this.right.deleted||Ku(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}},gS=(e,t,n)=>{for(;t.right!==null&&n>0;)t.right.content.constructor===Fo?t.right.deleted||Ku(t.currentAttributes,t.right.content):t.right.deleted||(n<t.right.length&&Rl(e,Fr(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length),t.left=t.right,t.right=t.right.right;return t},Sm=(e,t,n,r)=>{const o=new Map,i=r?ym(t,n):null;if(i){const s=new Jb(i.p.left,i.p,i.index,o);return gS(e,s,n-i.index)}else{const s=new Jb(null,t._start,0,o);return gS(e,s,n)}},vS=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Fo&&Ml(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const o=e.doc,i=o.clientID;r.forEach((s,a)=>{const l=n.left,u=n.right,d=new xi(Fr(i,ai(o.store,i)),l,l&&l.lastId,u,u&&u.id,t,null,new Fo(a,s));d.integrate(e,0),n.right=d,n.forward()})},Ku=(e,t)=>{const{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},yS=(e,t)=>{for(;e.right!==null;){if(!(e.right.deleted||e.right.content.constructor===Fo&&Ml(t[e.right.content.key]??null,e.right.content.value)))break;e.forward()}},bS=(e,t,n,r)=>{const o=e.doc,i=o.clientID,s=new Map;for(const a in r){const l=r[a],u=n.currentAttributes.get(a)??null;if(!Ml(u,l)){s.set(a,u);const{left:d,right:f}=n;n.right=new xi(Fr(i,ai(o.store,i)),d,d&&d.lastId,f,f&&f.id,t,null,new Fo(a,l)),n.right.integrate(e,0),n.forward()}}return s},e0=(e,t,n,r,o)=>{n.currentAttributes.forEach((p,g)=>{o[g]===void 0&&(o[g]=null)});const i=e.doc,s=i.clientID;yS(n,o);const a=bS(e,t,n,o),l=r.constructor===String?new qu(r):r instanceof So?new Yu(r):new _m(r);let{left:u,right:d,index:f}=n;t._searchMarker&&Hf(t._searchMarker,n.index,l.getLength()),d=new xi(Fr(s,ai(i.store,s)),u,u&&u.lastId,d,d&&d.id,t,null,l),d.integrate(e,0),n.right=d,n.index=f,n.forward(),vS(e,t,n,a)},wS=(e,t,n,r,o)=>{const i=e.doc,s=i.clientID;yS(n,o);const a=bS(e,t,n,o);e:for(;n.right!==null&&(r>0||a.size>0&&(n.right.deleted||n.right.content.constructor===Fo));){if(!n.right.deleted)switch(n.right.content.constructor){case Fo:{const{key:l,value:u}=n.right.content,d=o[l];if(d!==void 0){if(Ml(d,u))a.delete(l);else{if(r===0)break e;a.set(l,u)}n.right.delete(e)}else n.currentAttributes.set(l,u);break}default:r<n.right.length&&Rl(e,Fr(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
|
|
7
7
|
`;n.right=new xi(Fr(s,ai(i.store,s)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new qu(l)),n.right.integrate(e,0),n.forward()}vS(e,t,n,a)},CS=(e,t,n,r,o)=>{let i=t;const s=Ys();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===Fo){const u=i.content;s.set(u.key,u)}i=i.right}let a=0,l=!1;for(;t!==i;){if(n===t&&(l=!0),!t.deleted){const u=t.content;if(u.constructor===Fo){const{key:d,value:f}=u,p=r.get(d)??null;(s.get(d)!==u||p===f)&&(t.delete(e),a++,!l&&(o.get(d)??null)===f&&p!==f&&(p===null?o.delete(d):o.set(d,p))),!l&&!t.deleted&&Ku(o,u)}}t=t.right}return a},p7=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;const n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===Fo){const r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},m7=e=>{let t=0;return pr(e.doc,n=>{let r=e._start,o=e._start,i=Ys();const s=wb(i);for(;o;)o.deleted===!1&&(o.content.constructor===Fo?Ku(s,o.content):(t+=CS(n,r,o,i,s),i=wb(s),r=o)),o=o.right}),t},g7=e=>{const t=new Set,n=e.doc;for(const[r,o]of e.afterState.entries()){const i=e.beforeState.get(r)||0;o!==i&&eS(e,n.store.clients.get(r),i,o,s=>{!s.deleted&&s.content.constructor===Fo&&s.constructor!==Ll&&t.add(s.parent)})}pr(n,r=>{$3(e,e.deleteSet,o=>{if(o instanceof Ll||!o.parent._hasFormatting||t.has(o.parent))return;const i=o.parent;o.content.constructor===Fo?t.add(i):p7(r,o)});for(const o of t)m7(o)})},kS=(e,t,n)=>{const r=n,o=wb(t.currentAttributes),i=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Yu:case _m:case qu:n<t.right.length&&Rl(e,Fr(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}i&&CS(e,i,t.right,o,t.currentAttributes);const s=(t.left||t.right).parent;return s._searchMarker&&Hf(s._searchMarker,t.index,-r+n),t},v7=class extends vm{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(r=>{r===null?this.childListChanged=!0:this.keysChanged.add(r)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,t=[];pr(e,n=>{const r=new Map,o=new Map;let i=this.target._start,s=null;const a={};let l="",u=0,d=0;const f=()=>{if(s!==null){let p=null;switch(s){case"delete":d>0&&(p={delete:d}),d=0;break;case"insert":(typeof l=="object"||l.length>0)&&(p={insert:l},r.size>0&&(p.attributes={},r.forEach((g,m)=>{g!==null&&(p.attributes[m]=g)}))),l="";break;case"retain":u>0&&(p={retain:u},B8(a)||(p.attributes=O8({},a))),u=0;break}p&&t.push(p),s=null}};for(;i!==null;){switch(i.content.constructor){case Yu:case _m:this.adds(i)?this.deletes(i)||(f(),s="insert",l=i.content.getContent()[0],f()):this.deletes(i)?(s!=="delete"&&(f(),s="delete"),d+=1):i.deleted||(s!=="retain"&&(f(),s="retain"),u+=1);break;case qu:this.adds(i)?this.deletes(i)||(s!=="insert"&&(f(),s="insert"),l+=i.content.str):this.deletes(i)?(s!=="delete"&&(f(),s="delete"),d+=i.length):i.deleted||(s!=="retain"&&(f(),s="retain"),u+=i.length);break;case Fo:{const{key:p,value:g}=i.content;if(this.adds(i)){if(!this.deletes(i)){const m=r.get(p)??null;Ml(m,g)?g!==null&&i.delete(n):(s==="retain"&&f(),Ml(g,o.get(p)??null)?delete a[p]:a[p]=g)}}else if(this.deletes(i)){o.set(p,g);const m=r.get(p)??null;Ml(m,g)||(s==="retain"&&f(),a[p]=m)}else if(!i.deleted){o.set(p,g);const m=a[p];m!==void 0&&(Ml(m,g)?m!==null&&i.delete(n):(s==="retain"&&f(),g===null?delete a[p]:a[p]=g))}i.deleted||(s==="insert"&&f(),Ku(r,i.content));break}}i=i.right}for(f();t.length>0;){const p=t[t.length-1];if(p.retain!==void 0&&p.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},y7=class s2 extends So{constructor(t){super(),this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Oo(),this._length}_integrate(t,n){super._integrate(t,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new s2}clone(){const t=new s2;return t.applyDelta(this.toDelta()),t}_callObserver(t,n){super._callObserver(t,n);const r=new v7(this,t,n);bm(this,t,r),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){this.doc??Oo();let t="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===qu&&(t+=n.content.str),n=n.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:n=!0}={}){this.doc!==null?pr(this.doc,r=>{const o=new Jb(null,this._start,0,new Map);for(let i=0;i<t.length;i++){const s=t[i];if(s.insert!==void 0){const a=!n&&typeof s.insert=="string"&&i===t.length-1&&o.right===null&&s.insert.slice(-1)===`
|
|
@@ -13,7 +13,7 @@ ${n.toString()}`)},wR=class{constructor(e){this.patterns=[],this.$state=e}if(e,t
|
|
|
13
13
|
`).replace(/<[^>]+>/g,"");const Me=document.createElement("div");return Me.innerHTML=Z,Me.innerText||Me.textContent||""},x=J=>{const Z=String(J??"").replace(/\r\n/g,`
|
|
14
14
|
`).trim();return Z?Z.split(/\n{2,}/).map(Me=>`<p>${b(Me).replace(/\n/g,"<br>")}</p>`).join(""):"<p></p>"},M=_e({get:()=>k(a.value),set:J=>{a.value=x(J)}}),z=J=>J?.name?.trim()||J?.email?.trim()||"",G=J=>String(J?.id??J?.email??J?.name??""),F=J=>J?.role==="viewer"||J?.access==="viewer"||typeof J?.access=="object"&&J.access?.role==="viewer",L=J=>({...J?.id!=null?{id:J.id}:{},...J?.name!=null?{name:J.name}:{},...J?.email!=null?{email:J.email}:{}}),$=_e(()=>{if(d.value==null)return[];const J=f.value.toLocaleLowerCase();return s.users.filter(Z=>!F(Z)&&z(Z)).filter(Z=>{const Me=z(Z).toLocaleLowerCase(),fe=Z?.email?.toLocaleLowerCase()??"";return!J||Me.startsWith(J)||fe.startsWith(J)}).slice(0,8)}),T=_e(()=>$.value.length>0),H=_e(()=>{const J=$.value[p.value];return J?`${g}-${G(J)}`:void 0}),R=J=>{const Z=M.value.slice(0,J),Me=/(?:^|\s)@([^\s@]{0,40})$/.exec(Z);d.value=Me?J-Me[1].length-1:null,f.value=Me?.[1]??"",p.value=0},U=J=>{l.value=l.value.filter(Z=>M.value.includes(`@${z(Z)}`)),R(J.target.selectionStart??M.value.length),w()},W=J=>{if(d.value==null)return;const Z=d.value,Me=u.value?.selectionStart??M.value.length,fe=`@${z(J)}`,ye=L(J);M.value=`${M.value.slice(0,Z)}${fe}${M.value.slice(Me)}`,l.value.some(ve=>G(ve)===G(ye))||(l.value=[...l.value,ye]),d.value=null,f.value="",Ct(()=>{const ve=Z+fe.length;u.value?.focus(),u.value?.setSelectionRange(ve,ve),w()})},ee=J=>{if(T.value){if(J.key==="ArrowDown"||J.key==="ArrowUp"){J.preventDefault(),J.stopPropagation();const Z=J.key==="ArrowDown"?1:-1;p.value=(p.value+Z+$.value.length)%$.value.length;return}if(J.key==="Enter"){J.preventDefault(),J.stopPropagation();const Z=$.value[p.value];Z&&W(Z);return}J.key==="Escape"&&(J.preventDefault(),J.stopPropagation(),d.value=null)}};return zn(S),jt(a,S),t({focus:C}),(J,Z)=>(pe(),Ce("div",$L,[e.includeHeader?(pe(),hn(I0,{key:0,config:e.config,comment:e.comment,"is-pending-input":!0},null,8,["config","comment"])):ut("",!0),ce("div",{class:Zt(["comment-entry",{"sd-input-active":e.isFocused}])},[ce("div",HL,[ki(ce("textarea",{ref_key:"inputRef",ref:u,"onUpdate:modelValue":Z[0]||(Z[0]=Me=>M.value=Me),class:"superdoc-field",role:"combobox","aria-autocomplete":"list","aria-expanded":T.value,"aria-controls":T.value?g:void 0,"aria-activedescendant":H.value,"data-sd-comment-mention-input":"","data-sd-comment-text":"",placeholder:"Add a comment",rows:"1",onInput:U,onKeydown:ee,onFocus:Z[1]||(Z[1]=Me=>m(!0)),onBlur:Z[2]||(Z[2]=Me=>m(!1))},null,40,GL),[[Ii,M.value]]),T.value?(pe(),Ce("div",{key:0,id:g,class:"comment-mention-list",role:"listbox","data-sd-comment-mention-list":""},[(pe(!0),Ce(Bt,null,Rn($.value,(Me,fe)=>(pe(),Ce("button",{id:`${g}-${G(Me)}`,key:G(Me),type:"button",class:Zt(["comment-mention-option",{"comment-mention-option--active":fe===p.value}]),role:"option","aria-selected":fe===p.value,"data-sd-comment-mention-option":G(Me),onMousedown:tn(ye=>W(Me),["prevent"])},[ce("span",KL,Et(z(Me)),1),Me.email?(pe(),Ce("span",qL,Et(Me.email),1)):ut("",!0)],42,WL))),128))])):ut("",!0)])],2)]))}},E0=mn(XL,[["__scopeId","data-v-87953125"]]);Ft(),yn();var ZL=["aria-label","data-comment-instance-id","data-comment-thread-id","data-comment-position-key","data-comment-page-index"],QL={key:0,class:"existing-internal-input"},JL={class:"new-comment-input-wrapper"},eP={class:"reply-actions"},tP=["disabled"],nP={key:0,class:"resolved-badge"},rP=["innerHTML"],oP={key:1,class:"existing-internal-input"},iP={key:0,class:"card-section comment-body"},sP=["data-track-change-semantic-color-key"],aP={key:0},lP={class:"change-type tracked-change-label"},cP={key:0,class:"tracked-change-detail-lines"},uP={key:0,class:"tracked-change-text"},dP={key:1,class:"change-type"},fP={class:"change-type"},hP={key:1},pP={class:"tracked-change-text is-inserted"},mP={key:2},gP={class:"tracked-change-text is-inserted"},vP={key:3},yP={key:4},bP={key:5},wP={key:6},CP={class:"tracked-change-text"},kP={key:7},SP={class:"tracked-change-text is-deleted"},_P={class:"tracked-change-text is-inserted"},AP={key:8},IP={key:9},EP={key:10},xP={class:"tracked-change-text is-deleted"},TP={key:11},RP={class:"tracked-change-text is-inserted"},MP=["data-track-change-image-preview-role"],LP=["src","alt"],PP={key:1,class:"card-section comment-body"},DP=["innerHTML"],OP={key:1,class:"comment"},FP={key:2,class:"reply-expanded"},NP={class:"reply-input-wrapper"},BP={class:"reply-actions"},zP=["onClick"],jP=["onClick","disabled","data-disabled-reason"],VP={class:"collapsed-avatars"},UP={key:3,class:"comment-separator"},$P={key:2,class:"tracked-change-decision-alert",role:"alert"},HP={class:"tracked-change-decision-alert__message"},GP=["disabled","data-disabled-reason"],WP={key:1,class:"reply-expanded"},KP={class:"reply-input-wrapper"},qP={class:"reply-actions"},YP=["disabled","data-disabled-reason"],f_=3,h_=90,XP={__name:"CommentDialog",props:{comment:{type:Object,required:!0},autoFocus:{type:Boolean,default:!1},parent:{type:Object,required:!1},floatingInstanceId:{type:String,default:null},floatingPageIndex:{type:Number,default:null},floatingPositionEntry:{type:Object,default:null},isFloatingInstanceActive:{type:Boolean,default:void 0},threadComments:{type:Array,default:null}},emits:["click-outside","ready","dialog-exit","resize"],setup(e,{emit:t}){const n=t,r=e,{proxy:o}=yr(),i=Xu(),s=Js(),{addComment:a,cancelComment:l,deleteComment:u,getCommentAliasIds:d,removePendingComment:f,getCommentDocumentId:p,requestInstantSidebarAlignment:g,resolveCommentPositionEntry:m,clearInstantSidebarAlignment:v,setActiveFloatingCommentInstance:C}=s,{suppressInternalExternal:w,getConfig:S,activeComment:b,activeFloatingCommentInstanceId:k,floatingCommentsOffset:x,pendingComment:M,currentCommentText:z,currentCommentMentions:G,isDebugging:F,editingCommentId:L,editorCommentPositions:$,isCommentHighlighted:T}=qs(s),H=te(!0),R=te(null),U=te(new Map),W=te(null),ee=[[0,0],[-3,0],[f_,0],[0,-3],[0,f_]],J=Ie=>{const Ue=typeof Ie?.width=="number"&&Number.isFinite(Ie.width)?Ie.width:null,vt=typeof Ie?.height=="number"&&Number.isFinite(Ie.height)?Ie.height:null;if(!Ue||!vt||Ue<=0||vt<=0)return{};const dt=Math.min(h_/Ue,h_/vt,1);return{width:`${Math.max(1,Math.round(Ue*dt))}px`,height:`${Math.max(1,Math.round(vt*dt))}px`}},Z=[".comments-dropdown__option-label",".comments-dropdown__menu",".comments-dropdown__option",".comments-dropdown__option-icon",".comments-dropdown__trigger",".superdoc-comment-highlight",".sd-editor-comment-highlight",".sd-editor-tracked-change-highlight","[data-track-change-id]",".track-insert",".track-insert-dec",".track-delete",".track-delete-dec",".track-format",".track-format-dec"].join(","),Me=Ie=>Ue=>{Ie&&(Ue?(U.value.set(Ie,Ue),L.value===Ie&&Ct(()=>{ve(Ie)})):U.value.delete(Ie))},fe=(Ie,Ue,vt)=>{const dt=Ie?.getBoundingClientRect?.();return!dt||![dt.left,dt.top,dt.right,dt.bottom].every(Number.isFinite)||dt.width<=0||dt.height<=0?!1:ee.some(([Vn,Dn])=>{const eo=Ue+Vn,to=vt+Dn;return eo>=dt.left&&eo<=dt.right&&to>=dt.top&&to<=dt.bottom})},ye=(Ie,Ue)=>{if(!Number.isFinite(Ie)||!Number.isFinite(Ue))return null;const vt=document.querySelectorAll(Z);for(const dt of vt)if(dt instanceof HTMLElement&&fe(dt,Ie,Ue))return dt;return null},ve=Ie=>{U.value.get(Ie)?.focus?.()},Pe=te(null),Ve=Ie=>Ie.resolvedTime?Ie.commentId:Ie.importedId||Ie.commentId,nt=Ie=>Ie?Ie.trackedChange&&Ie.trackedChangeCanonicalId!=null?String(Ie.trackedChangeCanonicalId):Ie.commentId!=null?String(Ie.commentId):null:null,ct=Ie=>{if(!Ie?.trackedChange)return null;const Ue=nt(Ie);if(!Ue)return null;const vt={kind:"trackedChange",trackedChangeId:Ue};return Ie.trackedChangeStory&&(vt.story=Ie.trackedChangeStory),Ie.semanticColorKey==="move-from"&&(vt.side="source"),Ie.semanticColorKey==="move-to"&&(vt.side="destination"),vt},ft=(Ie,Ue)=>{const vt=Ie?.bounds?.[Ue];return Number.isFinite(vt)?vt:null},It=(Ie,Ue)=>{if(!Ie||!Ue||Ie.pageIndex!==Ue.pageIndex)return!1;const vt=ft(Ie,"top"),dt=ft(Ue,"top");return vt!=null&&dt!=null&&Math.abs(vt-dt)<.5},Le=(Ie,Ue)=>{const vt=ft(Ie,"left"),dt=ft(Ue,"left"),Vn=ft(Ie,"right"),Dn=ft(Ue,"right");return[vt,dt,Vn,Dn].some(eo=>eo==null)?!1:dt<Vn&&vt<Dn},oe=(Ie,Ue)=>{const vt=Ie?.start,dt=Ie?.end,Vn=Ue?.start,Dn=Ue?.end;return[vt,dt,Vn,Dn].every(Number.isFinite)?Vn<=dt&&vt<=Dn:!1},we=(Ie,Ue)=>!Ie||!Ue||Ie.kind&&Ue.kind&&Ie.kind!==Ue.kind||Ie.storyKey&&Ue.storyKey&&Ie.storyKey!==Ue.storyKey?!1:Ue.start===Ie.start&&Ue.end===Ie.end?!0:It(Ie,Ue)&&Le(Ie,Ue)&&oe(Ie,Ue),Q=Ie=>{const Ue=new Set(d(Ie)),{key:vt,entry:dt}=m(Ie);return vt&&Ue.add(vt),dt?(Object.entries($.value??{}).forEach(([Vn,Dn])=>{we(dt,Dn)&&Ue.add(Vn)}),[...Ue]):[...Ue]},I=(Ie,Ue,vt=24)=>{if(!Number.isFinite(Ue)||typeof Ie?.getBoundingClientRect!="function")return!1;const dt=Ie.getBoundingClientRect().top;return Number.isFinite(dt)&&Math.abs(dt-Ue)<=vt},re=_e(()=>r.floatingInstanceId??r.comment.commentId??null),j=_e(()=>typeof r.isFloatingInstanceActive=="boolean"?r.isFloatingInstanceActive:b.value!==r.comment.commentId?!1:r.floatingInstanceId==null?!0:k.value===r.floatingInstanceId),X=_e(()=>r.comment.resolvedTime?r.comment.trackedChange?r.comment.trackedChangeDecision==="reject"?"Rejected":"Accepted":"Resolved":null),K=_e(()=>M.value&&M.value.commentId===r.comment.commentId),ae=_e(()=>Ie=>{const Ue=tr.value;return ke.value&&Ie===Ue.length-1?!0:Ue.length>1&&Ie!==Ue.length-1}),ke=_e(()=>!S.readOnly&&j.value&&!r.comment.resolvedTime&&!Xt.value),P=()=>({ok:!1,reason:"read-only-document"}),N=()=>S.value?.readOnly===!0,me=()=>{const Ie=o.$superdoc?.interactionConfig?.trackedChanges?.allowDecisions;return typeof Ie=="boolean"?!Ie:N()},Se=()=>({ok:!1,reason:N()?"read-only-document":"tracked-change-decisions-disabled"}),Re=te(!1),ze=te(!1),Ke=te(!1),ot=()=>{if(N())return P();if(In.value)return{ok:!1,reason:Ht.value?.reason??"v2-write-unavailable"};Re.value=!0,Ct(()=>{R.value?.focus?.(),n("resize")})},mt=_e(()=>{const Ie=r.comment;return Array.isArray(r.threadComments)?[...r.threadComments].sort((Ue,vt)=>Ue.commentId===Ie.commentId?-1:vt.commentId===Ie.commentId?1:Ue.createdTime-vt.createdTime):Ie.trackedChange?s.getTrackedChangeThread(Ie):s.commentsList.filter(Ue=>{const vt=Ue.parentCommentId===Ie.commentId,dt=Ue.commentId===Ie.commentId;return vt||dt}).sort((Ue,vt)=>Ue.commentId===Ie.commentId?-1:vt.commentId===Ie.commentId?1:Ue.createdTime-vt.createdTime)}),Ot=_e(()=>r.comment.trackedChangeLabel?r.comment.trackedChangeLabel:r.comment.trackedChange?"Tracked change discussion":r.comment.creatorName?`Comment by ${r.comment.creatorName}`:"Comment thread"),Mt=te(!1),Kt=te(null),$e=te(!1),Qt=_e(()=>!Mt.value),Hn=_e(()=>({"is-truncated":Qt.value,"is-scrollable":Mt.value&&$e.value})),qt=()=>{Mt.value=!Mt.value,Ct(()=>n("resize"))},jn=Ie=>{Kt.value=Ie??null},Pn=()=>{if(Mt.value)return;const Ie=Kt.value;if(!Ie){$e.value=!1;return}$e.value=Ie.scrollHeight>Ie.clientHeight+1};jt(Kt,()=>{Ct(Pn)});const $r=()=>L.value?mt.value.some(Ie=>Ie.commentId===L.value):!1;jt(j,Ie=>{Ie||((Re.value||$r())&&(z.value="",G.value=[],L.value=null),Mt.value=!1,Nr.value=!1,Re.value=!1,Ct(()=>n("resize")))});const Nr=te(!1),_r=_e(()=>mt.value.slice(1)),Tn=_e(()=>Nr.value?!1:_r.value.length>=2),tr=_e(()=>Tn.value?[mt.value[0],_r.value[_r.value.length-1]].filter(Boolean):mt.value);jt(_e(()=>{const Ie=tr.value[0];return Ie?JSON.stringify({commentId:Ie.commentId,commentText:Ie.commentText,trackedChange:Ie.trackedChange,trackedChangeText:Ie.trackedChangeText,deletedText:Ie.deletedText,trackedChangeLabel:Ie.trackedChangeLabel,trackedChangeDisplayType:Ie.trackedChangeDisplayType,trackedChangeDetailLines:Ie.trackedChangeDetailLines}):""}),()=>{Ct(Pn)});const qn=_e(()=>Tn.value?_r.value.length-1:0),Bn=_e(()=>{if(!Tn.value)return[];const Ie=_r.value.slice(0,-1),Ue=new Set;return Ie.map(vt=>typeof vt.getCommentUser=="function"?vt.getCommentUser():{name:vt.creatorName,email:vt.creatorEmail||vt.email}).filter(vt=>{if(!vt)return!1;const dt=vt.email||vt.name;return Ue.has(dt)?!1:(Ue.add(dt),!0)}).slice(0,3)}),st=()=>{Nr.value=!0,Ne(),Ct(()=>n("resize"))},_t=_e(()=>r.comment.resolvedTime?!0:S.value.readOnly),gt=_e(()=>Ie=>j.value&&L.value===Ie.commentId),Xt=_e(()=>!L.value||!j.value?!1:mt.value.some(Ie=>Ie.commentId===L.value)),gn=_e(()=>S.value.readOnly||!o.$superdoc.config.isInternal||Nt.value?!1:!w.value&&!r.comment.trackedChange),Te=_e(()=>z.value&&z.value!=="<p></p>"),Ne=async()=>{const Ie=o.$superdoc.activeEditor,Ue=Ie?.editorVersion===2?Ie?.v2Comments??null:null,vt=!!r.comment?.trackedChange,dt=lL(),Vn=r.floatingInstanceId!=null,Dn=Pe.value?.getBoundingClientRect?.().top,eo=!r.comment.resolvedTime&&(b.value!==r.comment.commentId||Vn&&re.value!==k.value);let to=dt;if(Ue){const go=!vt&&!r.comment.resolvedTime&&String(r.comment?.trackedChangeParentId??"").trim()?r.comment.trackedChangeParentId:null,Qo=Ie?.editorVersion===2&&(vt||go!=null)?Ie?.v2TrackedChanges??null:null,li=go!=null?s.getComment(go):null,zo=vt?r.comment:li?.trackedChange?li:go;let Ir=await(Qo?Qo.focusTrackedChange(zo):Ue.focusComment(r.comment));return!vt&&Ir?.reason==="tracked-change-anchor-not-found"&&(Ir=await Ue.focusComment(r.comment)),Ir?.ok?(r.comment.resolvedTime||(b.value=r.comment.commentId,r.floatingInstanceId&&C(r.floatingInstanceId)),eo&&!Vn?g(dt,r.comment.commentId,r.floatingInstanceId??null):eo&&Number.isFinite(Dn)?g(Dn,r.comment.commentId,r.floatingInstanceId):v(),Ir):(v(),Ir)}if(Ie){const{entry:go}=m(r.comment),Qo=r.floatingPositionEntry??go,li=Number.isFinite(r.floatingPageIndex)&&r.comment?.trackedChangeStory?.storyType==="headerFooterPart",zo=l_(r.parent,Qo),Ir=li?null:cL(Q(r.comment)),Jo=Number.isFinite(Ir)?Ir:zo,Cs=I(Pe.value,Jo),jo=Ve(r.comment),lr=null;let no=null;if(vt)if(r.comment.trackedChangeStory&&(r.comment.trackedChangeStory,{...Number.isFinite(r.floatingPageIndex)?{pageIndex:r.floatingPageIndex}:{}}),r.comment.resolvedTime)Ie.commands?.setCursorById(jo);else{const ci=r.comment.commentId;Ie.commands?.setCursorById(jo,{activeCommentId:ci})||Ie.commands?.setActiveComment({commentId:ci})}else{if(r.comment.resolvedTime)Ie.commands?.setCursorById(jo);else{const Vo=r.comment.commentId;Ie.commands?.setCursorById(jo,{activeCommentId:Vo})||Ie.commands?.setActiveComment({commentId:Vo})}const ci=r.comment.commentId;no=Cs?null:uL(lr,jo,ci,dt)}Number.isFinite(Ir)?to=Ir:Number.isFinite(zo)?to=zo:Number.isFinite(no)&&(to=no)}eo&&!Vn?r.floatingInstanceId?g(to,r.comment.commentId,r.floatingInstanceId):g(to,r.comment.commentId):v(),r.comment.resolvedTime||(b.value=r.comment.commentId,r.floatingInstanceId&&C(r.floatingInstanceId))},Qe=Ie=>{const Ue=Ie.target instanceof Element?Ie.target:Ie.target?.parentElement,vt=document.elementFromPoint(Ie.clientX,Ie.clientY);if(!(Ue?.closest?.(Z)||vt?.closest?.(Z)||ye(Ie.clientX,Ie.clientY)||T.value)&&!(Ie.target.closest?.(".comments-dialog")&&!Pe.value?.contains(Ie.target))){if(K.value){l(o.$superdoc);return}j.value&&(x.value=0,n("dialog-exit"),b.value=null,s.setActiveComment(o.$superdoc,b.value),T.value=!1)}},bt=async()=>{if(N())return P();if(In.value)return{ok:!1,reason:Ht.value?.reason??"v2-write-unavailable"};if(Nt.value&&Dt.value&&!K.value){if(ze.value)return{ok:!1,reason:"reply-submit-in-flight"};ze.value=!0;try{const vt=nt(r.comment),dt=ct(r.comment),Vn=await s.replyCommentV2({superdoc:o.$superdoc,parentCommentId:vt,text:z.value,...G.value.length?{mentions:G.value}:{},...dt?{trackedChangeTarget:dt}:{}});return Vn?.ok?(Re.value=!1,z.value="",G.value=[],Ct(()=>n("resize")),Vn):(Ct(()=>n("resize")),Vn)}finally{ze.value=!1}}if(K.value){if(Ke.value)return{ok:!1,reason:"comment-submit-in-flight"};Ke.value=!0}const Ie={documentId:r.comment.fileId,isInternal:M.value?M.value.isInternal:H.value,parentCommentId:M.value?null:r.comment.commentId};M.value&&(Ie.selection=M.value.selection.getValues());const Ue=s.getPendingComment(Ie);!M.value&&z.value&&Ue.setText({text:z.value,suppressUpdate:!0}),Promise.resolve().then(()=>a({superdoc:o.$superdoc,comment:Ue})).catch(vt=>{console.error("[SuperDoc] addComment failed",vt)}).finally(()=>{Ke.value=!1,Re.value=!1,Ct(()=>n("resize"))})},Nt=_e(()=>o.$superdoc?.activeEditor?.editorVersion===2),Dt=_e(()=>Nt.value?o.$superdoc?.activeEditor?.v2Comments??null:null),kn=_e(()=>Nt.value?o.$superdoc?.activeEditor?.v2TrackedChanges??null:null),Ht=_e(()=>{if(!Dt.value)return null;const Ie=s.viewingVisibility.documentMode,Ue=K.value?"comments.createFromSelection":null,vt=Dt.value.getCapabilityState?.(Ue)??null;return Ie==="viewing"&&!K.value?{...vt??{},canWrite:!1,reason:"review-surface-read-only"}:vt}),In=_e(()=>{if(!Nt.value)return!1;const Ie=Ht.value;return Ie?Ie.canWrite===!1:!1}),sn=_e(()=>ze.value?"reply-submit-in-flight":In.value?Ht.value?.reason??"v2-write-unavailable":null),Ao=_e(()=>{if(!kn.value)return null;const Ie=s.viewingVisibility.documentMode,Ue=kn.value.getCapabilityState?.()??null;return Ie==="viewing"&&Ue?.canDecide!==!1?{canDecide:!1,reason:"review-surface-read-only"}:Ue}),qi=Ie=>{if(Nt.value&&Ie?.trackedChange){if(!kn.value)return"v2-tracked-change-adapter-missing";const Ue=Ao.value;return Ue&&Ue.canDecide===!1?Ue.reason??"v2-tracked-change-unavailable":null}return In.value?Ht.value?.reason??"v2-write-unavailable":null},dn=Ie=>{if(Nt.value&&Ie?.trackedChange){if(!kn.value)return"v2-tracked-change-adapter-missing";const Ue=Ao.value;return Ue&&Ue.canDecide===!1?Ue.reason??"v2-tracked-change-unavailable":null}return In.value?Ht.value?.reason??"v2-write-unavailable":null},sr=()=>Nt.value?Dt.value?S.value?.readOnly?"read-only-document":In.value?Ht.value?.reason??"v2-write-unavailable":null:"v2-comments-adapter-missing":null,ar=_e(()=>!Nt.value||!In.value?null:Ht.value?.reason??"v2-write-unavailable"),No=(Ie,Ue)=>{W.value={decision:Ie,reason:Ue?.reason??null},Ct(()=>n("resize"))},ln=()=>{W.value&&(W.value=null,Ct(()=>n("resize")))},Mn=_e(()=>{const Ie=W.value;if(!Ie)return null;const Ue=Ie.decision==="reject"?"reject":"accept";return Ie.reason==="stale-catalog"?`Couldn't ${Ue} this change because the review list is stale.`:`Couldn't ${Ue} this change.`}),Jn=()=>{const Ie=W.value;if(Ie){if(W.value=null,Ie.decision==="reject"){Yr();return}Yi()}},Yr=async()=>{if(r.comment.trackedChange){if(me())return Se()}else if(N())return P();const Ie=o.$superdoc.config.onTrackedChangeBubbleReject;if(r.comment.trackedChange){if(Nt.value){const vt=await s.decideTrackedChangeFromSidebar({superdoc:o.$superdoc,comment:r.comment,decision:"reject"});if(!vt?.ok||vt.success===!1){No("reject",vt);return}ln(),typeof Ie=="function"&&Ie(r.comment,o.$superdoc.activeEditor),Ct(()=>{s.lastUpdate=new Date,b.value=null,s.setActiveComment(o.$superdoc,b.value),o.$superdoc.focus?.({preventScroll:!0})});return}let Ue=!0;if(typeof Ie=="function")Ie(r.comment,o.$superdoc.activeEditor);else{const vt=await s.decideTrackedChangeFromSidebar({superdoc:o.$superdoc,comment:r.comment,decision:"reject"});Ue=!!vt?.ok&&vt.success!==!1}Ue&&r.comment.resolveComment({id:i.user.id,email:i.user.email,name:i.user.name,superdoc:o.$superdoc,decision:"reject",reconciliationToken:Xf})}else if(Nt.value&&Dt.value){if(!(await s.deleteComment({superdoc:o.$superdoc,commentId:r.comment.commentId}))?.ok)return}else s.deleteComment({superdoc:o.$superdoc,commentId:r.comment.commentId});Ct(()=>{s.lastUpdate=new Date,b.value=null,s.setActiveComment(o.$superdoc,b.value),o.$superdoc.focus?.()})},Yi=async()=>{if(r.comment.trackedChange){if(me())return Se()}else{if(N())return P();if(S.value?.allowResolve===!1)return{ok:!1,reason:"resolve-disabled"}}const Ie=o.$superdoc.config.onTrackedChangeBubbleAccept;if(r.comment.trackedChange&&Nt.value){const vt=await s.decideTrackedChangeFromSidebar({superdoc:o.$superdoc,comment:r.comment,decision:"accept"});if(!vt?.ok||vt.success===!1){No("accept",vt);return}ln(),typeof Ie=="function"&&Ie(r.comment,o.$superdoc.activeEditor),Ct(()=>{s.lastUpdate=new Date,b.value=null,s.setActiveComment(o.$superdoc,b.value),o.$superdoc.focus?.({preventScroll:!0})});return}let Ue=!0;if(r.comment.trackedChange&&typeof Ie=="function")Ie(r.comment,o.$superdoc.activeEditor);else if(r.comment.trackedChange){const vt=await s.decideTrackedChangeFromSidebar({superdoc:o.$superdoc,comment:r.comment,decision:"accept"});Ue=!!vt?.ok&&vt.success!==!1}else if(Nt.value&&Dt.value){if(!(await s.resolveCommentV2({superdoc:o.$superdoc,commentId:r.comment.commentId}))?.ok)return}else r.comment.resolveComment({id:i.user.id,email:i.user.email,name:i.user.name,superdoc:o.$superdoc});r.comment.trackedChange&&!Nt.value&&Ue&&r.comment.resolveComment({id:i.user.id,email:i.user.email,name:i.user.name,superdoc:o.$superdoc,decision:"accept",reconciliationToken:Xf}),Ct(()=>{s.lastUpdate=new Date,b.value=null,s.setActiveComment(o.$superdoc,b.value),o.$superdoc.focus?.()})},$c=async()=>{if(N())return P();if(S.value?.allowResolve===!1)return{ok:!1,reason:"resolve-disabled"};!Nt.value||!Dt.value||(await s.reopenCommentV2({superdoc:o.$superdoc,commentId:r.comment.commentId}))?.ok&&Ct(()=>{s.lastUpdate=new Date,s.setActiveComment(o.$superdoc,b.value),o.$superdoc.focus?.()})},sa=(Ie,Ue)=>{if(N())return P();switch(Ie){case"edit":z.value=Ue?.commentText?.value??Ue?.commentText??"",G.value=Array.isArray(Ue?.mentions)?[...Ue.mentions]:[],b.value=r.comment.commentId,r.floatingInstanceId&&C(r.floatingInstanceId),L.value=Ue.commentId,s.setActiveComment(o.$superdoc,b.value),Ct(()=>{ve(Ue.commentId)});break;case"delete":u({superdoc:o.$superdoc,commentId:Ue.commentId});break}},Za=async Ie=>{if(N())return P();if(Nt.value&&Dt.value){const Ue=await s.editCommentV2({superdoc:o.$superdoc,commentId:Ie.commentId,text:z.value});return Ue?.ok&&(L.value=null,f(o.$superdoc)),Ue}L.value=null,Ie.setText({text:z.value,superdoc:o.$superdoc}),f(o.$superdoc)},Bo=Ie=>{if(N())return P();const Ue=!!M.value,vt=Ie.toLowerCase()==="internal";Ue?M.value.isInternal=vt:r.comment.setIsInternal({isInternal:vt,superdoc:o.$superdoc})},Io=_e(()=>{const Ie={};return(j.value||K.value||Xt.value)&&(Ie.zIndex=50),Ie}),Xi=Ie=>typeof Ie=="string"?new Date(Ie).getTime():Ie,Zo=Ie=>{L.value=null,Re.value=!1,l(o.$superdoc)},Xr=_e(()=>{const Ie=o.$superdoc.users;return r.comment.isInternal===!0?Ie.filter(Ue=>Ue.access==="internal"||Ue.access?.role==="internal"):Ie});return zn(()=>{r.autoFocus&&Ct(()=>Ne()),K.value&&Ct(()=>{R.value?.focus?.({preventScroll:!0})}),Ct(()=>{const Ie=r.floatingInstanceId??(r.comment.importedId!==void 0?r.comment.importedId:r.comment.commentId);n("ready",{commentId:Ie,elementRef:Pe}),Pn()})}),jt(ke,Ie=>{Ie&&Ct(()=>{R.value?.focus?.(K.value?{preventScroll:!0}:void 0)})},{immediate:!0}),jt(L,Ie=>{if(!Ie||!j.value)return;const Ue=mt.value.find(vt=>vt.commentId===Ie);!Ue||Ue.trackedChange||Ct(()=>{ve(Ie)})}),jt(()=>S.value?.readOnly===!0,Ie=>{Ie&&(Re.value=!1,mt.value.some(Ue=>Ue.commentId===L.value)&&(L.value=null),K.value&&l(o.$superdoc),Ct(()=>n("resize")))},{immediate:!0}),jt(In,Ie=>{Ie&&(Re.value=!1,Ct(()=>n("resize")))}),(Ie,Ue)=>{const vt=Tw("click-outside");return ki((pe(),Ce("div",{class:Zt(["comments-dialog",{"is-active":j.value||K.value,"is-resolved":r.comment.resolvedTime}]),onClick:tn(Ne,["stop","prevent"]),style:An(Io.value),ref_key:"commentDialogElement",ref:Pe,role:"dialog","aria-label":Ot.value,"data-sd-part":"comment-thread","data-editor-ui-surface":"","data-comment-instance-id":r.floatingInstanceId??"","data-comment-thread-id":r.comment.commentId??"","data-comment-position-key":r.comment.trackedChangeAnchorKey??"","data-comment-page-index":Number.isFinite(r.floatingPageIndex)?r.floatingPageIndex:""},[K.value?(pe(),Ce(Bt,{key:0},[gn.value?(pe(),Ce("div",QL,[en(u_,{onClick:Ue[0]||(Ue[0]=tn(()=>{},["stop","prevent"])),class:"sd-internal-dropdown","is-disabled":!1,state:et(M).isInternal?"internal":"external",onSelect:Bo},null,8,["state"])])):ut("",!0),en(I0,{config:et(S),comment:r.comment,"is-pending-input":!0},null,8,["config","comment"]),ce("div",JL,[en(E0,{ref_key:"commentInput",ref:R,users:Xr.value,config:et(S),comment:r.comment,"include-header":!1},null,8,["users","config","comment"])]),ce("div",eP,[ce("button",{class:"sd-button reply-btn-cancel",onClick:tn(Zo,["stop","prevent"])},"Cancel"),ce("button",{class:Zt(["sd-button primary reply-btn-primary",{"sd-is-disabled":!Te.value||Ke.value}]),onClick:tn(bt,["stop","prevent"]),disabled:!Te.value||Ke.value}," Comment ",10,tP)])],64)):(pe(),Ce(Bt,{key:1},[X.value?(pe(),Ce("div",nP,[ce("span",{class:"resolved-badge__icon",innerHTML:et(Ua).markDone},null,8,rP),Si(" "+Et(X.value),1)])):ut("",!0),gn.value?(pe(),Ce("div",oP,[en(u_,{onClick:Ue[1]||(Ue[1]=tn(()=>{},["stop","prevent"])),class:"sd-internal-dropdown","is-disabled":_t.value,state:e.comment.isInternal?"internal":"external",onSelect:Bo},null,8,["is-disabled","state"])])):ut("",!0),(pe(!0),Ce(Bt,null,Rn(tr.value,(dt,Vn)=>(pe(),Ce("div",{key:dt.commentId,class:"conversation-item"},[en(I0,{config:et(S),timestamp:Xi(dt.createdTime),comment:dt,"is-active":j.value,"resolve-disabled-reason":qi(dt),"reject-disabled-reason":dn(dt),"reopen-supported":Nt.value&&!!Dt.value,"reopen-disabled-reason":sr(),"write-disabled-reason":ar.value,onResolve:Yi,onReject:Yr,onReopen:$c,onOverflowSelect:Dn=>sa(Dn,dt)},null,8,["config","timestamp","comment","is-active","resolve-disabled-reason","reject-disabled-reason","reopen-supported","reopen-disabled-reason","write-disabled-reason","onOverflowSelect"]),dt.trackedChange?(pe(),Ce("div",iP,[ce("div",{class:Zt(["tracked-change",Vn===0?Hn.value:void 0]),"data-track-change-semantic-color-key":dt.semanticColorKey??void 0,ref_for:!0,ref:Vn===0?jn:void 0},[dt.trackedChangeLabel?(pe(),Ce("div",aP,[ce("span",lP,Et(dt.trackedChangeLabel),1),dt.trackedChangeDetailLines&&dt.trackedChangeDetailLines.length?(pe(),Ce("div",cP,[(pe(!0),Ce(Bt,null,Rn(dt.trackedChangeDetailLines,(Dn,eo)=>(pe(),Ce("div",{key:eo,class:"tracked-change-detail-line"},[Dn.excerpt?(pe(),Ce("span",uP,'"'+Et(Dn.excerpt)+'"',1)):ut("",!0),Dn.excerpt?(pe(),Ce("span",dP," — ")):ut("",!0),ce("span",fP,Et(Dn.label),1)]))),128))])):ut("",!0)])):dt.trackedChangeDisplayType==="hyperlinkAdded"?(pe(),Ce("div",hP,[Ue[2]||(Ue[2]=ce("span",{class:"change-type"},"Added hyperlink ",-1)),ce("span",pP,'"'+Et(dt.trackedChangeText)+'"',1)])):dt.trackedChangeDisplayType==="hyperlinkModified"?(pe(),Ce("div",mP,[Ue[3]||(Ue[3]=ce("span",{class:"change-type"},"Changed hyperlink to ",-1)),ce("span",gP,'"'+Et(dt.trackedChangeText)+'"',1)])):dt.trackedChangeDisplayType==="paragraphSplit"?(pe(),Ce("div",vP,[...Ue[4]||(Ue[4]=[ce("span",{class:"change-type"},"Added new line",-1)])])):dt.trackedChangeDisplayType==="tableInsert"?(pe(),Ce("div",yP,[...Ue[5]||(Ue[5]=[ce("span",{class:"change-type"},"Added table",-1)])])):dt.trackedChangeDisplayType==="tableDelete"?(pe(),Ce("div",bP,[...Ue[6]||(Ue[6]=[ce("span",{class:"change-type"},"Deleted table",-1)])])):dt.trackedChangeType==="trackFormat"?(pe(),Ce("div",wP,[Ue[7]||(Ue[7]=ce("span",{class:"change-type"},"Format: ",-1)),ce("span",CP,Et(dt.trackedChangeText),1)])):dt.trackedChangeType==="both"?(pe(),Ce("div",kP,[Ue[8]||(Ue[8]=ce("span",{class:"change-type"},"Replaced ",-1)),ce("span",SP,'"'+Et(dt.deletedText)+'"',1),Ue[9]||(Ue[9]=ce("span",{class:"change-type"}," with ",-1)),ce("span",_P,'"'+Et(dt.trackedChangeText)+'"',1)])):dt.deletedText&&dt.deletedText===`
|
|
15
15
|
`?(pe(),Ce("div",AP,[...Ue[10]||(Ue[10]=[ce("span",{class:"change-type"},"Deleted line break",-1)])])):dt.trackedChangeText&&dt.trackedChangeText===`
|
|
16
|
-
`?(pe(),Ce("div",IP,[...Ue[11]||(Ue[11]=[ce("span",{class:"change-type"},"Added line break",-1)])])):dt.deletedText?(pe(),Ce("div",EP,[Ue[12]||(Ue[12]=ce("span",{class:"change-type"},"Deleted ",-1)),ce("span",xP,'"'+Et(dt.deletedText)+'"',1)])):dt.trackedChangeText?(pe(),Ce("div",TP,[Ue[13]||(Ue[13]=ce("span",{class:"change-type"},"Added ",-1)),ce("span",RP,'"'+Et(dt.trackedChangeText)+'"',1)])):ut("",!0),dt.trackedChangeImagePreview?.src?(pe(),Ce("div",{key:12,class:"tracked-change-image-preview","data-track-change-image-preview-role":dt.trackedChangeImagePreview.role??void 0},[ce("img",{class:"tracked-change-image-preview__image",src:dt.trackedChangeImagePreview.src,alt:dt.trackedChangeImagePreview.alt||"Tracked image preview",style:An(J(dt.trackedChangeImagePreview)),loading:"lazy",decoding:"async"},null,12,LP)],8,MP)):ut("",!0)],10,sP),Qt.value&&$e.value&&Vn===0?(pe(),Ce("div",{key:0,class:"show-more-toggle",onClick:tn(qt,["stop","prevent"])}," Show more ")):ut("",!0),Mt.value&&$e.value&&Vn===0?(pe(),Ce("div",{key:1,class:"show-more-toggle",onClick:tn(qt,["stop","prevent"])}," Show less ")):ut("",!0)])):ut("",!0),dt.trackedChange?ut("",!0):(pe(),Ce("div",PP,[!et(F)&&!gt.value(dt)?(pe(),Ce("div",{key:0,class:Zt(["comment",Vn===0?Hn.value:void 0]),ref_for:!0,ref:Vn===0?jn:void 0,innerHTML:dt.commentText},null,10,DP)):et(F)&&!gt.value(dt)?(pe(),Ce("div",OP,Et(et($)[dt.importedId!==void 0?dt.importedId:dt.commentId]?.bounds),1)):(pe(),Ce("div",FP,[ce("div",NP,[en(E0,{ref_for:!0,ref:Me(dt.commentId),users:[],config:et(S),"include-header":!1,comment:dt},null,8,["config","comment"])]),ce("div",BP,[ce("button",{class:"sd-button reply-btn-cancel",onClick:tn(Dn=>Zo(dt),["stop","prevent"])},"Cancel",8,zP),ce("button",{class:Zt(["sd-button primary reply-btn-primary",{"sd-is-disabled":!Te.value||In.value}]),onClick:tn(Dn=>Za(dt),["stop","prevent"]),disabled:!Te.value||In.value,"data-disabled-reason":In.value?Ht.value?.reason??null:null}," Update ",10,jP)])])),Qt.value&&$e.value&&Vn===0&&!gt.value(dt)?(pe(),Ce("div",{key:3,class:"show-more-toggle",onClick:tn(qt,["stop","prevent"])}," Show more ")):ut("",!0),Mt.value&&$e.value&&Vn===0&&!gt.value(dt)?(pe(),Ce("div",{key:4,class:"show-more-toggle",onClick:tn(qt,["stop","prevent"])}," Show less ")):ut("",!0)])),Tn.value&&Vn===0?(pe(),Ce(Bt,{key:2},[Ue[14]||(Ue[14]=ce("div",{class:"comment-separator"},null,-1)),ce("div",{class:"collapsed-replies",onClick:tn(st,["stop","prevent"])},[ce("div",VP,[(pe(!0),Ce(Bt,null,Rn(Bn.value,Dn=>(pe(),hn(d_,{key:Dn.email||Dn.name,user:Dn,class:"mini-avatar"},null,8,["user"]))),128))]),ce("span",null,Et(qn.value)+" more "+Et(qn.value===1?"reply":"replies"),1)])],64)):ut("",!0),ae.value(Vn)?(pe(),Ce("div",UP)):ut("",!0)]))),128)),W.value?(pe(),Ce("div",$P,[ce("span",HP,Et(Mn.value),1),ce("button",{type:"button",class:"sd-button tracked-change-decision-alert__retry",onClick:tn(Jn,["stop","prevent"])}," Retry ")])):ut("",!0),ke.value&&!et(S).readOnly?(pe(),Ce(Bt,{key:3},[Re.value?(pe(),Ce("div",WP,[ce("div",KP,[en(E0,{ref_key:"commentInput",ref:R,users:Xr.value,config:et(S),comment:r.comment,"include-header":!1},null,8,["users","config","comment"])]),ce("div",qP,[ce("button",{class:"sd-button reply-btn-cancel",onClick:tn(Zo,["stop","prevent"])},"Cancel"),ce("button",{class:Zt(["sd-button primary reply-btn-primary",{"sd-is-disabled":!Te.value||In.value||ze.value}]),onClick:tn(bt,["stop","prevent"]),disabled:!Te.value||In.value||ze.value,"data-disabled-reason":sn.value}," Reply ",10,YP)])])):(pe(),Ce("button",{key:0,type:"button",class:Zt(["reply-pill",{"sd-is-disabled":In.value}]),onClick:tn(ot,["stop","prevent"]),disabled:In.value,"data-disabled-reason":In.value?Ht.value?.reason??null:null}," Reply or add others with @ ",10,GP))],64)):ut("",!0)],64))],14,ZL)),[[vt,Qe]])}}},x0=mn(XP,[["__scopeId","data-v-eefd4750"]]);Ft(),yn();var ZP=["tabindex","aria-posinset","aria-setsize","aria-label","data-comment-instance-id","data-comment-thread-id","data-comment-position-key","data-comment-page-index","data-review-directory-index"],QP={__name:"ReviewDirectoryListItem",props:{item:{type:Object,required:!0},index:{type:Number,required:!0},total:{type:Number,required:!0},tabIndex:{type:Number,default:-1}},emits:["focus-item","navigate"],setup(e,{emit:t}){const n=e,r=t,{activeComment:o,editingCommentId:i,pendingComment:s}=qs(Js()),a=te(null),l=te(112),u=te(typeof IntersectionObserver>"u"),d=te(!1);let f=null,p=null;const g=_e(()=>new Set((n.item.threadComments??[]).flatMap(x=>[x?.commentId,x?.importedId,x?.trackedChangeCanonicalId]).filter(x=>x!=null).map(String))),m=_e(()=>{const x=s.value?.commentId;return d.value||o.value!=null&&g.value.has(String(o.value))||i.value!=null&&g.value.has(String(i.value))||x!=null&&g.value.has(String(x))}),v=_e(()=>u.value||m.value),C=_e(()=>v.value?void 0:{minHeight:`${Math.max(1,l.value)}px`}),w=_e(()=>{const x=n.item.comment,M=x?.trackedChangeLabel??x?.commentText??x?.trackedChangeText??"Review item";return String(M).replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim().slice(0,160)||"Review item"}),S=()=>{const x=a.value?.getBoundingClientRect?.().height;Number.isFinite(x)&&x>0&&(l.value=x)},b=()=>{d.value=!0,r("focus-item",n.index)},k=x=>{["ArrowDown","ArrowUp","Home","End"].includes(x.key)&&(x.target?.closest?.('input, textarea, select, button, [contenteditable="true"]')||(x.preventDefault(),r("navigate",{index:n.index,key:x.key})))};return zn(()=>{typeof IntersectionObserver<"u"&&(f=new IntersectionObserver(x=>{const M=x[0];M&&(u.value=M.isIntersecting,M.isIntersecting&&Ct(S))},{root:null,rootMargin:"600px 0px"}),f.observe(a.value)),typeof ResizeObserver<"u"&&(p=new ResizeObserver(S),p.observe(a.value)),Ct(S)}),ur(()=>{f?.disconnect(),p?.disconnect()}),(x,M)=>(pe(),Ce("div",{ref_key:"shell",ref:a,class:"comment-item",role:"listitem",tabindex:e.tabIndex,"aria-posinset":e.index+1,"aria-setsize":e.total,"aria-label":w.value,style:An(C.value),"data-comment-instance-id":e.item.floatingInstanceId??"","data-comment-thread-id":e.item.comment.commentId??"","data-comment-position-key":e.item.comment.trackedChangeAnchorKey??"","data-comment-page-index":Number.isFinite(e.item.floatingPageIndex)?e.item.floatingPageIndex:"","data-review-directory-index":e.index,onFocusin:b,onFocusout:M[0]||(M[0]=z=>d.value=a.value?.contains?.(z.relatedTarget)===!0),onKeydown:k},[v.value?(pe(),hn(x0,{key:0,comment:e.item.comment,"thread-comments":e.item.threadComments,"floating-instance-id":e.item.floatingInstanceId,"floating-page-index":e.item.floatingPageIndex,"floating-position-entry":e.item.floatingPositionEntry,"is-floating-instance-active":e.item.isFloatingInstanceActive,onResize:S},null,8,["comment","thread-comments","floating-instance-id","floating-page-index","floating-position-entry","is-floating-instance-active"])):ut("",!0)],44,ZP))}},p_=mn(QP,[["__scopeId","data-v-29650a06"]]);Ft(),yn();var JP=["aria-busy"],eD={key:0},tD={key:1},nD="headerFooterPart",rD={__name:"commentsList",props:{showMainComments:{type:Boolean,default:!0},showResolvedComments:{type:Boolean,default:!0}},setup(e){const t=e,n=Js(),r=te(null),o=te(0),i=Ev(n,"isCommentsListVisible"),s=_e(()=>n.getFloatingCommentInstances),{activeComment:a,activeFloatingCommentInstanceId:l,commentsList:u,reviewDirectoryList:d,isReviewDirectoryActive:f,isReviewDirectoryLoading:p}=qs(n),g=_e(()=>f.value?n.getGroupedReviewDirectory:n.getGroupedComments),m=_e(()=>f.value?d.value:u.value),v=$=>[$?.commentId,$?.importedId,$?.trackedChangeCanonicalId].filter(T=>T!=null).map(String),C=_e(()=>{const $=new Map;for(const T of m.value){const H=[T];for(const R of v(T))$.set(R,H)}for(const T of m.value){const H=[T?.parentCommentId,T?.threadingParentCommentId,T?.trackedChangeThreadParentId].filter(R=>R!=null).map(String).map(R=>$.get(R)).find(Boolean);H&&!H.includes(T)&&H.push(T)}return $}),w=$=>{for(const T of v($)){const H=C.value.get(T);if(H)return H}return[$]},S=$=>{const T=s.value.filter(H=>H?.comment?.commentId===$?.commentId);return T.length<2?[]:$?.trackedChange?$?.trackedChangeStory?.storyType!==nD?[]:T:[]},b=$=>!$?.comment?.commentId||a.value!==$.comment.commentId?!1:l.value==null?$.isPrimary===!0:String(l.value)===String($.id),k=$=>{const T=S($);return T.length?T.map(H=>({id:H.id,comment:$,floatingInstanceId:String(H.id),floatingPageIndex:H.pageIndex,floatingPositionEntry:H.positionEntry??null,isFloatingInstanceActive:b(H),threadComments:w($)})):[{id:$.commentId,comment:$,floatingInstanceId:null,floatingPageIndex:null,floatingPositionEntry:null,isFloatingInstanceActive:void 0,threadComments:w($)}]},x=_e(()=>g.value.parentComments.flatMap($=>k($))),M=_e(()=>t.showResolvedComments&&g.value?.resolvedComments?.length>0),z=_e(()=>g.value.resolvedComments.map($=>({id:$.commentId,comment:$,floatingInstanceId:null,floatingPageIndex:null,floatingPositionEntry:null,isFloatingInstanceActive:void 0,threadComments:w($)}))),G=_e(()=>t.showMainComments?x.value.length:0),F=_e(()=>G.value+(M.value?z.value.length:0));jt(F,$=>{o.value=Math.max(0,Math.min(o.value,$-1))});const L=async({index:$,key:T})=>{const H=F.value-1;if(H<0)return;const R=T==="Home"?0:T==="End"?H:T==="ArrowUp"?Math.max(0,$-1):Math.min(H,$+1);o.value=R,await Ct();const U=r.value?.querySelector?.(`[data-review-directory-index="${R}"]`);U?.scrollIntoView?.({block:"nearest"}),U?.focus?.({preventScroll:!0})};return zn(()=>{i.value=!0}),ur(()=>{i.value=!1}),($,T)=>(pe(),Ce("div",{ref_key:"listRoot",ref:r,class:"comments-list",role:"list","aria-busy":et(f)&&et(p)?"true":"false"},[e.showMainComments?(pe(),Ce("div",eD,[(pe(!0),Ce(Bt,null,Rn(x.value,(H,R)=>(pe(),hn(p_,{key:H.id,item:H,index:R,total:F.value,"tab-index":R===o.value?0:-1,onFocusItem:T[0]||(T[0]=U=>o.value=U),onNavigate:L},null,8,["item","index","total","tab-index"]))),128))])):ut("",!0),M.value?(pe(),Ce("div",tD,[T[2]||(T[2]=ce("div",{class:"comment-title"},"Resolved",-1)),(pe(!0),Ce(Bt,null,Rn(z.value,(H,R)=>(pe(),hn(p_,{key:H.id,item:H,index:G.value+R,total:F.value,"tab-index":G.value+R===o.value?0:-1,onFocusItem:T[1]||(T[1]=U=>o.value=U),onNavigate:L},null,8,["item","index","total","tab-index"]))),128))])):ut("",!0)],8,JP))}},oD=mn(rD,[["__scopeId","data-v-89244745"]]);Ft();var iD=class extends av.default{element;config={comments:[],element:null,commentsStore:null};constructor(e,t){super(),this.config={...this.config,...e},this.element=this.config.element,this.app=null,this.superdoc=t,this.stopDirectoryObservers=[],this.directorySnapshots={comments:null,trackChanges:null},this.directoryItemRefs={comments:null,trackChanges:null},this.directoryGeneration=0,this.open()}syncDirectory(){const e=this.superdoc?.commentsStore;if(!e)return;const t=this.directorySnapshots.comments,n=this.directorySnapshots.trackChanges;e.isReviewDirectoryLoading=t==null||n==null,!(t==null&&n==null)&&e.setReviewDirectoryFromV2({superdoc:this.superdoc,commentItems:t??[],trackedChangeItems:n??[]})}startDirectoryObservers(){const e=++this.directoryGeneration,t=(r,o)=>{const i=l=>{if(e!==this.directoryGeneration)return;if((l?.listStatus??l?.status)!=="ready"){this.superdoc?.commentsStore&&(this.superdoc.commentsStore.isReviewDirectoryLoading=!0);return}const u=Array.isArray(l.items)?l.items:[];if(this.directoryItemRefs[o]===u){this.superdoc?.commentsStore&&(this.superdoc.commentsStore.isReviewDirectoryLoading=this.directorySnapshots.comments==null||this.directorySnapshots.trackChanges==null);return}this.directoryItemRefs[o]=u,this.directorySnapshots[o]=u,this.syncDirectory()},s=r.observe(l=>{i(l)}),a=()=>i(r.getSnapshot());return typeof globalThis.queueMicrotask=="function"?globalThis.queueMicrotask(a):Promise.resolve().then(a),s},n=this.superdoc?.ui;n&&(this.superdoc?.commentsStore&&(this.superdoc.commentsStore.isReviewDirectoryActive=!0,this.superdoc.commentsStore.isReviewDirectoryLoading=!0),this.stopDirectoryObservers=[t(n.comments,"comments"),t(n.trackChanges,"trackChanges")])}createVueApp(){this.app=Ac(oD);const e=this.superdoc?.app?._context?.provides;e&&this.app?._context?.provides&&Object.setPrototypeOf(this.app._context.provides,e),this.superdoc?.pinia&&(Df(this.superdoc.pinia),this.app.use(this.superdoc.pinia),this.app.config.globalProperties.$pinia=this.superdoc.pinia),this.app.directive("click-outside",cb),this.app.config.globalProperties.$superdoc=this.superdoc,!this.element&&this.config.selector&&(this.element=document.getElementById(this.config.selector)),this.container=this.app.mount(this.element),this.startDirectoryObservers()}close(){this.directoryGeneration+=1;for(const e of this.stopDirectoryObservers.splice(0))e?.();this.directorySnapshots={comments:null,trackChanges:null},this.directoryItemRefs={comments:null,trackChanges:null},this.superdoc?.commentsStore&&(this.superdoc.commentsStore.clearReviewDirectory(),this.superdoc.commentsStore.isReviewDirectoryActive=!1,this.superdoc.commentsStore.isReviewDirectoryLoading=!1),this.app&&(this.app.unmount(),this.app=null,this.container=null,this.element=null)}open(){this.app||this.createVueApp()}},Pl,T0=Lr((()=>{Pl=96/72}));Ft(),T0();var sD=96,aD=".superdoc__right-sidebar",lD=".sd-pdf-viewer-page",R0=Object.freeze({min:10,max:100,padding:0}),M0=e=>{const t=e&&typeof e=="object"?e:{},n=(s,a)=>typeof s=="number"&&Number.isFinite(s)&&s>0?s:a,r=n(t.min,R0.min),o=n(t.max,R0.max),i=typeof t.padding=="number"&&Number.isFinite(t.padding)&&t.padding>=0?t.padding:R0.padding;return{min:Math.min(r,o),max:Math.max(r,o),padding:i}},m_=(e,t)=>!(e>0)||!(t>0)?null:Math.round(e/t*100),g_=(e,t,n)=>{const r=m_(e-n.padding,t);return r===null?null:Math.max(1,Math.round(Math.min(n.max,Math.max(n.min,r))))},cD=(e,t,n)=>e>0?Number.isFinite(t)&&t>0?e/t*Pl:n>0?e/n:e:null,uD=e=>{if(!e||typeof e!="object")return 0;const t=e.widestPageWidthPx;if(typeof t=="number"&&Number.isFinite(t))return t;let n=0;const r=e.pages;if(Array.isArray(r))for(const o of r){const i=o?.base?.widthPx;typeof i=="number"&&Number.isFinite(i)&&i>n&&(n=i)}return n},v_=e=>{if(!e)return null;let t=0;try{t=uD(e.pageMetrics?.getSnapshot?.())}catch{t=0}if(t>0)return t;try{const o=e.getPages?.();if(Array.isArray(o))for(const i of o){const s=i?.size?.w;typeof s=="number"&&Number.isFinite(s)&&s>t&&(t=s)}}catch{t=0}if(t>0)return t;let n=null;try{n=e.getPageStyles?.()??null}catch{n=null}const r=n?.pageSize?.width;return typeof r=="number"&&Number.isFinite(r)&&r>0?r*sD:null};function dD({getSuperdoc:e,superdocContainerWidth:t,isReady:n,activeZoom:r,zoomMode:o,viewportMetrics:i,showCommentsSidebar:s,rightSidebarRef:a,superdocRoot:l,documents:u}){const d=()=>{if(!(u?.value??[]).some(x=>x?.type==="application/pdf"))return null;const b=l.value;if(!b?.querySelectorAll)return null;let k=0;for(const x of b.querySelectorAll(lD)){const M=Number(x.clientWidth)||Number(x.getBoundingClientRect?.().width)||0;let z=NaN;typeof window<"u"&&typeof window.getComputedStyle=="function"&&(z=Number.parseFloat(window.getComputedStyle(x).getPropertyValue("--scale-factor")));const G=(r.value??100)/100,F=cD(M,z,G);F!==null&&F>k&&(k=F)}return k>0?k:null},f=()=>{const b=e();if(!b)return null;const k=[],x=u?.value??[];for(const z of x){if(z?.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document")continue;const G=v_(z.getEditor?.());G!==null&&k.push(G)}if(k.length===0){const z=v_(b.activeEditor);z!==null&&k.push(z)}const M=d();if(M!==null&&k.push(M),k.length>0)return Math.max(...k);if(b.activeEditor){const z=l.value?.querySelector?.(".superdoc__document"),G=Number(z?.clientWidth)||Number(z?.getBoundingClientRect?.().width)||0;if(G>0){const F=(r.value??100)/100;return F>0?G/F:G}}return null},p=()=>{if(!s?.value)return 0;const b=a?.value??l.value?.querySelector?.(aD),k=Number(b?.offsetWidth)||Number(b?.getBoundingClientRect?.().width)||0;return k>0?k:0},g=(b,k)=>{const x=M0(b.config?.zoom?.fitWidth),M=g_(k.availableWidth,k.documentWidth,x);M!==null&&M!==r.value&&(r.value=M,b.emit("zoomChange",{zoom:M,mode:"fit-width"}))},m=()=>{const b=e();if(!b)return;const k=t.value;if(!(k>0)||!n.value)return;const x=f();if(x===null)return;const M=k-p(),z=m_(M,x);if(z===null)return;const G=Object.freeze({availableWidth:M,documentWidth:x,fitZoom:z}),F=i.value;(!F||F.availableWidth!==M||F.documentWidth!==x||F.fitZoom!==z)&&(i.value=G),(!F||F.fitZoom!==z||Math.round(F.documentWidth)!==Math.round(x))&&b.emit("viewport-change",G),o.value==="fit-width"&&g(b,G)};jt(t,()=>{Ct(()=>m())}),jt(n,b=>{b&&m()}),jt(o,b=>{b==="fit-width"&&m()}),s&&jt(s,()=>{Ct(()=>m())});const v=()=>{Ct(()=>m())},C=()=>{Ct(()=>m())},w=()=>{Ct(()=>m())},S=e();return S?.on?.("editorCreate",v),S?.on?.("pagination-update",C),S?.on?.("pdf:document-ready",w),ur(()=>{S?.off?.("editorCreate",v),S?.off?.("pagination-update",C),S?.off?.("pdf:document-ready",w)}),{evaluateViewport:m}}function fD(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null||Array.isArray(e)!==Array.isArray(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}var y_=".png,.jpg,.jpeg,image/png,image/jpeg",b_=new Set(["image/png","image/jpeg","image/jpg"]),hD=/\.(png|jpe?g)$/i;function w_(e){if(!e)return!1;const t=typeof e.type=="string"?e.type.toLowerCase():"";return t?b_.has(t):hD.test(String(e.name??""))}function L0(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(pD(String(r.result),e)),r.onerror=()=>n(r.error??new Error("image-read-failed")),r.readAsDataURL(e)})}function pD(e,t){const n=/^data:([^;,]*);base64,/.exec(e);if(!n)return e;const r=n[1].toLowerCase();if(b_.has(r))return e;const o=String(t?.name??""),i=/\.jpe?g$/i.test(o)?"image/jpeg":/\.png$/i.test(o)?"image/png":null;return i?`data:${i};base64,${e.slice(n[0].length)}`:e}async function mD(e,t){if(typeof t=="function"){const n=await t(e);if(typeof n!="string"||n.trim()==="")throw new Error("handleImageUpload returned an empty result");return n.startsWith("data:")?n:gD(n,e)}return L0(e)}async function gD(e,t){const n=await fetch(e);if(!n.ok)throw new Error(`image fetch failed: ${n.status}`);const r=await n.blob(),o=(/\.(?:png|jpe?g)(?:$|[?#])/i.test(e)?e.split(/[?#]/)[0]:"")||t?.name||"";return L0(o?Object.assign(r,{name:o}):r)}function vD({ownerDocument:e=document,onPick:t,onError:n}={}){const r=e.createElement("input");return r.type="file",r.accept=y_,r.hidden=!0,r.tabIndex=-1,r.setAttribute("data-superdoc-image-picker","true"),r.setAttribute("aria-hidden","true"),r.addEventListener("change",()=>{const o=r.files&&r.files[0];if(r.value="",!!o){if(!w_(o)){n?.(new Error(`unsupported image type: ${o.type||o.name}`));return}try{const i=t?.(o);i&&typeof i.then=="function"&&i.catch(s=>n?.(s))}catch(i){n?.(i)}}}),e.body?.appendChild(r),{input:r,open(){r.click()},destroy(){r.remove()}}}Ft();var yD={class:"sd-watermark__body"},bD={class:"sd-watermark__settings"},wD=["disabled"],CD={class:"sd-watermark__field"},kD=["value"],SD=["value"],_D={class:"sd-watermark__field"},AD=["value"],ID=["disabled"],ED={class:"sd-watermark__selection-list"},xD=["value","checked","onChange"],TD=["disabled"],RD={key:0,class:"sd-watermark__notice"},MD={key:1,class:"sd-watermark__notice"},LD=["disabled"],PD={class:"sd-watermark__types"},DD=["name","value","checked","onChange"],OD={class:"sd-watermark__field"},FD=["value"],ND={class:"sd-watermark__presets","aria-label":"Text presets"},BD=["onClick"],zD={class:"sd-watermark__font-row"},jD={class:"sd-watermark__field"},VD=["value"],UD=["value"],$D={class:"sd-watermark__field sd-watermark__size"},HD=["list","value"],GD=["id"],WD=["value"],KD={class:"sd-watermark__styles"},qD=["aria-pressed"],YD=["aria-pressed"],XD={class:"sd-watermark__field sd-watermark__font-color"},ZD={class:"sd-watermark__color"},QD=["value"],JD=["value"],e9={class:"sd-watermark__picture"},t9=["src"],n9=["accept"],r9={class:"sd-watermark__field"},o9=["value"],i9={key:0,value:"custom",disabled:""},s9=["value"],a9={class:"sd-watermark__check"},l9=["checked"],c9={class:"sd-watermark__check"},u9=["checked"],d9={key:2,class:"sd-watermark__field sd-watermark__transparency"},f9=["for"],h9={class:"sd-watermark__range"},p9=["id","value"],m9=["value"],g9={key:3,class:"sd-watermark__orientation"},v9=["name","value","checked","onChange"],y9={key:4,class:"sd-watermark__notice"},b9={key:5,class:"sd-watermark__notice"},w9=["aria-busy"],C9={class:"sd-watermark__page"},k9=["src","width","height"],S9={key:1},_9={class:"sd-watermark__impact"},A9={key:0,class:"sd-watermark__impact-details"},I9={key:0,class:"sd-watermark__error",role:"alert"},E9=["disabled"],x9={class:"sd-watermark__footer sd-dialog-footer"},T9={role:"status","aria-live":"polite"},R9={class:"sd-watermark__actions"},M9=["disabled"],L9=vl({__name:"WatermarkSurface",props:{model:{},surfaceId:{default:""},mode:{},request:{},resolve:{},close:{type:Function,default:()=>{}}},setup(e){const t=e,n=Pr(t.model.getSnapshot()),r=te(null),o=te(!1),i=te("");let s=0,a;const l=["DRAFT","CONFIDENTIAL","DO NOT COPY"],u=[{value:"none",label:"No watermark"},{value:"text",label:"Text"},{value:"picture",label:"Picture"}],d=_e(()=>n.value.phase==="loading"||n.value.phase==="applying"),f=_e(()=>!d.value&&!n.value.readonlyReason),p=_e(()=>n.value.canApply&&!d.value&&!o.value&&!n.value.stale),g=_e(()=>i.value||n.value.error),m=_e(()=>o.value?"Preparing picture…":n.value.phase==="loading"?"Loading watermarks…":n.value.phase==="applying"?"Applying changes; closing will not cancel them.":n.value.phase==="previewing"?"Updating preview…":n.value.dirty?"Changes apply when you choose Apply":"No changes"),v=_e(()=>{const{fonts:G,draft:F}=n.value;return G.some(L=>L.value===F.fontFamily)?G:[{value:F.fontFamily,label:F.fontFamily},...G]});function C(){s+=1,o.value=!1}function w(G){f.value&&(i.value="",t.model.patchDraft(G))}function S(G,F){const L=G.target.value;C(),t.model.setScope(F==="section"?L||null:n.value.sectionId,F==="variant"?L:n.value.variant)}function b(G,F){C();const L=new Set(n.value.selectedIds);F.target.checked?L.add(G):L.delete(G),t.model.selectWatermarks([...L])}async function k(G){const F=G.target,L=F.files?.[0];if(F.value="",!L||!f.value)return;if(C(),i.value="",!w_(L)){i.value="Choose a PNG or JPEG picture.";return}const $=s;o.value=!0;try{const T=await L0(L);if($!==s)return;w({src:T,pictureName:L.name,kind:"picture"})}catch{$===s&&(i.value="The picture could not be read. Choose it again.")}finally{$===s&&(o.value=!1)}}async function x(){if(p.value)try{await t.model.apply()}catch{i.value="The watermark could not be applied. Try again."}}async function M(){C(),i.value="";try{await t.model.reload()}catch{i.value="Watermarks could not be loaded. Try again."}}function z(){C(),t.close("user-cancelled")}return jt([()=>n.value.draft.kind,()=>n.value.sectionId,()=>n.value.variant,()=>n.value.selectedIds.join("\0")],C),zn(()=>{a=t.model.subscribe(G=>{n.value=G}),n.value=t.model.getSnapshot()}),ur(()=>{C(),a?.()}),(G,F)=>(pe(),Ce("form",{class:"sd-watermark sd-dialog-content",onSubmit:tn(x,["prevent"])},[ce("header",{class:"sd-watermark__header sd-dialog-header"},[F[17]||(F[17]=ce("h2",null,"Watermark",-1)),ce("button",{type:"button",class:"sd-dialog-close","aria-label":"Close watermark dialog",onClick:z},[...F[16]||(F[16]=[ce("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true"},[ce("path",{d:"m4 4 8 8m0-8-8 8",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"})],-1)])])]),ce("div",yD,[ce("div",bD,[ce("fieldset",{class:"sd-watermark__scope",disabled:d.value},[F[22]||(F[22]=ce("legend",{class:"sd-watermark__sr-only"},"Watermark scope",-1)),ce("label",CD,[F[19]||(F[19]=ce("span",null,"Apply to",-1)),ce("select",{"aria-label":"Apply to",value:n.value.sectionId??"",onChange:F[0]||(F[0]=L=>S(L,"section"))},[F[18]||(F[18]=ce("option",{value:""},"Entire document",-1)),(pe(!0),Ce(Bt,null,Rn(n.value.sections,L=>(pe(),Ce("option",{key:L.id,value:L.id},Et(L.label),9,SD))),128))],40,kD)]),ce("label",_D,[F[21]||(F[21]=ce("span",null,"Page type",-1)),ce("select",{"aria-label":"Page type",value:n.value.variant,onChange:F[1]||(F[1]=L=>S(L,"variant"))},[...F[20]||(F[20]=[ce("option",{value:"all"},"All applicable",-1),ce("option",{value:"default"},"Default",-1),ce("option",{value:"first"},"First",-1),ce("option",{value:"even"},"Even",-1)])],40,AD)])],8,wD),n.value.items.length>1?(pe(),Ce("fieldset",{key:0,class:"sd-watermark__selection",disabled:d.value},[F[23]||(F[23]=ce("legend",null,"Watermarks to edit",-1)),ce("div",ED,[(pe(!0),Ce(Bt,null,Rn(n.value.items,L=>(pe(),Ce("label",{key:L.id,class:"sd-watermark__check"},[ce("input",{type:"checkbox",value:L.id,checked:n.value.selectedIds.includes(L.id),onChange:$=>b(L.id,$)},null,40,xD),ce("span",null,[Si(Et(L.label),1),ce("small",null,Et(L.locations),1)])]))),128))]),ce("button",{type:"button",disabled:!f.value,onClick:F[2]||(F[2]=L=>e.model.selectWatermarks([]))},"Add watermark",8,TD),n.value.selectedIds.length>1?(pe(),Ce("p",RD," Applying uses the settings below for all "+Et(n.value.selectedIds.length)+" selected copies. ",1)):ut("",!0)],8,ID)):ut("",!0),n.value.readonlyReason?(pe(),Ce("p",MD,Et(n.value.readonlyReason),1)):ut("",!0),ce("fieldset",{class:Zt(["sd-watermark__draft",{"sd-watermark__draft--text":n.value.draft.kind==="text"}]),disabled:!f.value},[F[40]||(F[40]=ce("legend",{class:"sd-watermark__sr-only"},"Watermark settings",-1)),ce("fieldset",PD,[F[24]||(F[24]=ce("legend",{class:"sd-watermark__sr-only"},"Watermark type",-1)),(pe(),Ce(Bt,null,Rn(u,L=>ce("label",{key:L.value,class:Zt({"is-selected":n.value.draft.kind===L.value})},[ce("input",{type:"radio",name:`watermark-type-${e.surfaceId}`,value:L.value,checked:n.value.draft.kind===L.value,onChange:$=>w({kind:L.value})},null,40,DD),ce("span",null,Et(L.value==="none"&&n.value.items.length>1&&n.value.selectedIds.length?"Remove selected":L.label),1)],2)),64))]),n.value.draft.kind==="text"?(pe(),Ce(Bt,{key:0},[ce("label",OD,[F[25]||(F[25]=ce("span",null,"Text",-1)),ce("input",{"aria-label":"Watermark text",type:"text",value:n.value.draft.text,onInput:F[3]||(F[3]=L=>w({text:L.target.value}))},null,40,FD)]),ce("div",ND,[(pe(),Ce(Bt,null,Rn(l,L=>ce("button",{key:L,type:"button",onClick:$=>w({text:L})},Et(L),9,BD)),64))]),ce("div",zD,[ce("label",jD,[F[26]||(F[26]=ce("span",null,"Font",-1)),ce("select",{"aria-label":"Font",value:n.value.draft.fontFamily,onChange:F[4]||(F[4]=L=>w({fontFamily:L.target.value}))},[(pe(!0),Ce(Bt,null,Rn(v.value,L=>(pe(),Ce("option",{key:L.value,value:L.value},Et(L.label),9,UD))),128))],40,VD)]),ce("label",$D,[F[28]||(F[28]=ce("span",null,"Size (pt)",-1)),ce("input",{"aria-label":"Font size",list:`watermark-sizes-${e.surfaceId}`,value:n.value.draft.fontSize==="auto"?"Auto":n.value.draft.fontSize,onChange:F[5]||(F[5]=L=>w({fontSize:L.target.value.toLowerCase()==="auto"?"auto":Number(L.target.value)}))},null,40,HD),ce("datalist",{id:`watermark-sizes-${e.surfaceId}`},[F[27]||(F[27]=ce("option",{value:"Auto"},null,-1)),(pe(),Ce(Bt,null,Rn([24,36,48,72,96],L=>ce("option",{key:L,value:L},null,8,WD)),64))],8,GD)]),ce("div",KD,[ce("button",{type:"button","aria-label":"Bold","aria-pressed":n.value.draft.bold,onClick:F[6]||(F[6]=L=>w({bold:!n.value.draft.bold}))},[...F[29]||(F[29]=[ce("b",null,"B",-1)])],8,qD),ce("button",{type:"button","aria-label":"Italic","aria-pressed":n.value.draft.italic,onClick:F[7]||(F[7]=L=>w({italic:!n.value.draft.italic}))},[...F[30]||(F[30]=[ce("i",null,"I",-1)])],8,YD)])]),ce("label",XD,[F[31]||(F[31]=ce("span",null,"Font color",-1)),ce("span",ZD,[ce("input",{type:"color","aria-label":"Choose font color",value:n.value.draft.color,onInput:F[8]||(F[8]=L=>w({color:L.target.value}))},null,40,QD),ce("input",{type:"text","aria-label":"Font color",value:n.value.draft.color,spellcheck:"false",onInput:F[9]||(F[9]=L=>w({color:L.target.value}))},null,40,JD)])])],64)):ut("",!0),n.value.draft.kind==="picture"?(pe(),Ce(Bt,{key:1},[ce("div",e9,[n.value.draft.src?(pe(),Ce("img",{key:0,src:n.value.draft.src,alt:"Selected picture"},null,8,t9)):ut("",!0),ce("div",null,[ce("strong",null,Et(n.value.draft.pictureName||"No picture selected"),1),F[32]||(F[32]=ce("small",null,"PNG or JPEG",-1))]),ce("button",{type:"button",onClick:F[10]||(F[10]=L=>r.value?.click())},Et(n.value.draft.pictureName?"Replace picture":"Choose picture"),1),ce("input",{ref_key:"fileInput",ref:r,type:"file",accept:et(y_),"aria-label":"Choose watermark picture",hidden:"",onChange:k},null,40,n9)]),ce("label",r9,[F[34]||(F[34]=ce("span",null,"Scale",-1)),ce("select",{"aria-label":"Picture scale",value:n.value.draft.customSize?"custom":n.value.draft.scalePercent,onChange:F[11]||(F[11]=L=>w({scalePercent:L.target.value==="auto"?"auto":Number(L.target.value)}))},[n.value.draft.customSize?(pe(),Ce("option",i9,"Custom size retained")):ut("",!0),F[33]||(F[33]=ce("option",{value:"auto"},"Auto",-1)),(pe(),Ce(Bt,null,Rn([50,100,150,200,500],L=>ce("option",{key:L,value:L},Et(L)+"%",9,s9)),64))],40,o9)]),ce("label",a9,[ce("input",{type:"checkbox",checked:n.value.draft.lockAspectRatio,onChange:F[12]||(F[12]=L=>w({lockAspectRatio:L.target.checked}))},null,40,l9),F[35]||(F[35]=ce("span",null,"Preserve aspect ratio",-1))]),ce("label",c9,[ce("input",{type:"checkbox",checked:n.value.draft.washout,onChange:F[13]||(F[13]=L=>w({washout:L.target.checked}))},null,40,u9),F[36]||(F[36]=ce("span",null,[Si("Washout"),ce("small",null,"Lighten the picture's colors.")],-1))])],64)):ut("",!0),n.value.draft.kind!=="none"?(pe(),Ce("div",d9,[ce("label",{for:`watermark-transparency-${e.surfaceId}`},"Transparency",8,f9),ce("div",h9,[ce("input",{id:`watermark-transparency-${e.surfaceId}`,type:"range",min:"0",max:"100",step:"1","aria-label":"Transparency",value:n.value.draft.transparency,onInput:F[14]||(F[14]=L=>w({transparency:Number(L.target.value)}))},null,40,p9),ce("label",null,[ce("input",{type:"number",min:"0",max:"100",step:"any","aria-label":"Transparency percentage",value:n.value.draft.transparency,onInput:F[15]||(F[15]=L=>w({transparency:Number(L.target.value)}))},null,40,m9),F[37]||(F[37]=ce("span",null,"%",-1))])]),F[38]||(F[38]=ce("small",null,"0% opaque, 100% transparent",-1))])):ut("",!0),n.value.draft.kind!=="none"?(pe(),Ce("fieldset",g9,[F[39]||(F[39]=ce("legend",null,"Orientation",-1)),(pe(),Ce(Bt,null,Rn(["horizontal","diagonal"],L=>ce("label",{key:L},[ce("input",{type:"radio",name:`watermark-orientation-${e.surfaceId}`,value:L,checked:!n.value.draft.customOrientation&&n.value.draft.orientation===L,onChange:$=>w({orientation:L})},null,40,v9),ce("span",null,Et(L==="horizontal"?"Horizontal":"Diagonal"),1)])),64))])):ut("",!0),n.value.draft.customPlacement?(pe(),Ce("p",y9,"Custom placement retained.")):ut("",!0),n.value.draft.kind==="none"?(pe(),Ce("p",b9,Et(n.value.selectedIds.length?"The selected watermark will be removed when you apply.":"Choose Text or Picture to add a watermark."),1)):ut("",!0)],10,LD)]),ce("aside",{class:"sd-watermark__preview","aria-label":"Watermark preview","aria-busy":n.value.phase==="previewing"},[F[41]||(F[41]=ce("h3",null,"Preview",-1)),ce("div",C9,[n.value.preview?(pe(),Ce("img",{key:0,src:n.value.preview.url,width:n.value.preview.width,height:n.value.preview.height,alt:"Watermark on a sample page"},null,8,k9)):(pe(),Ce("p",S9,Et(n.value.phase==="loading"||n.value.phase==="previewing"?"Preparing preview…":n.value.draft.kind==="none"?"No watermark in this preview":"Preview unavailable"),1))]),F[42]||(F[42]=ce("p",{class:"sd-watermark__caption"},"Preview at the selected page size",-1)),ce("p",_9,Et(n.value.impact),1),n.value.impactDetails?.length?(pe(),Ce("details",A9,[ce("summary",null,"View "+Et(n.value.impactDetails.length)+" affected locations",1),ce("ul",null,[(pe(!0),Ce(Bt,null,Rn(n.value.impactDetails,L=>(pe(),Ce("li",{key:L},Et(L),1))),128))])])):ut("",!0)],8,w9)]),g.value||n.value.stale?(pe(),Ce("div",I9,[ce("p",null,Et(g.value||"The document changed. Review the latest state before applying."),1),n.value.stale||n.value.error?(pe(),Ce("button",{key:0,type:"button",disabled:d.value,onClick:M}," Review latest state ",8,E9)):ut("",!0)])):ut("",!0),ce("footer",x9,[ce("p",T9,Et(m.value),1),ce("div",R9,[ce("button",{type:"button",class:"sd-dialog-secondary",onClick:z},"Cancel"),ce("button",{type:"submit",class:"sd-watermark__apply sd-dialog-primary",disabled:!p.value},Et(n.value.phase==="applying"?"Applying…":n.value.draft.kind==="none"?n.value.items.length>1?"Remove selected watermark":"Remove watermark":"Apply watermark"),9,M9)])])],32))}});yn();var P9=mn(L9,[["__scopeId","data-v-df56c82c"]]);Ft();function D9(e){let t=null,n=!1;return{component:P9,captureFocusReturn(){const r=e?.()?.ownerDocument,o=r?.activeElement,i=o?.closest('[data-sd-part="toolbar-item"]')??o?.querySelector('[data-sd-part="toolbar-item"]'),s=i?.closest('[data-sd-part="toolbar"]')?.parentElement,a=i?.querySelector('[data-item="btn-watermark"], [data-item="btn-overflow"]');return async l=>{if(await Ct(),n||!l()||!a||o?.isConnected||!s?.isConnected||r?.activeElement!==r?.body)return;const u=s.querySelector('[data-sd-part="toolbar"]');for(const d of["watermark","overflow"]){const f=u?.querySelector(`[data-item="btn-${d}"]`)?.closest('[data-sd-part="toolbar-item"]');if(f instanceof HTMLElement&&f.getClientRects().length&&f.getAttribute("aria-disabled")!=="true"){f.focus({preventScroll:!0});return}}}},mount(){const r=e?.();n||t||!r?.ownerDocument||(t=r.ownerDocument.createElement("div"),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),Object.assign(t.style,{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"}),r.appendChild(t))},announce(r){!n&&t&&(t.textContent=r)},destroy(){n=!0,t?.remove(),t=null}}}function C_(e){const t=e?.rotationDegrees!=null&&![0,315].includes(e.rotationDegrees);return{customOrientation:t,customPlacement:!!(t||e?.behindText===!1||e?.horizontal&&(e.horizontal.alignment!=="center"||e.horizontal.offsetPt)||e?.vertical&&(e.vertical.alignment!=="center"||e.vertical.offsetPt))}}function Rm(e){const t=e?.watermark,n=t?.placement?structuredClone(t.placement):void 0,r=t?.kind==="picture"?t:void 0,o=t?.kind==="text"?t:void 0,i=n?.rotationDegrees??(r||o?.orientation==="horizontal"?0:315);return{kind:t?.kind??"none",geometryKind:t?.kind??null,text:o?.text??"DRAFT",fontFamily:o?.fontFamily??"Calibri",fontSize:o?.fontSizePt??"auto",bold:o?.bold??!1,italic:o?.italic??!1,color:o?.color??"#C0C0C0",transparency:(1-(t?.opacity??.5))*100,orientation:i===0?"horizontal":"diagonal",scalePercent:r?.scalePercent??"auto",washout:r?.washout??!0,lockAspectRatio:r?.lockAspectRatio??!0,pictureName:r?"Image in this document":"",sourceWatermarkId:r?e?.watermarkId:void 0,widthPt:r?.widthPt,heightPt:r?.heightPt,placement:n,...C_(n),customSize:!!(r&&(n?.widthPt!=null||r.widthPt!=null))}}function O9(e,t){const n={...e,...t};if(t.kind&&t.kind!=="none"&&(t.kind!==e.geometryKind&&(n.placement=void 0,n.widthPt=void 0,n.heightPt=void 0,n.customSize=!1,n.orientation=t.kind==="picture"?"horizontal":"diagonal"),n.geometryKind=t.kind),t.orientation!==void 0&&(n.placement={...n.placement,rotationDegrees:t.orientation==="diagonal"?315:0}),t.scalePercent!==void 0||t.src!==void 0){const{widthPt:r,heightPt:o,...i}=n.placement??{};n.placement=Object.keys(i).length?i:void 0,n.widthPt=void 0,n.heightPt=void 0,n.customSize=!1}return{...n,...C_(n.placement)}}function F9(e){return e.kind==="none"?null:!Number.isFinite(e.transparency)||e.transparency<0||e.transparency>100?"Transparency must be between 0 and 100%.":e.kind==="picture"?e.src||e.sourceWatermarkId?null:"Choose a picture.":e.text.trim()?e.fontSize!=="auto"&&(!Number.isFinite(e.fontSize)||e.fontSize<=0)?"Enter a positive font size or choose Auto.":/^#[\da-f]{6}$/i.test(e.color)?e.fontFamily.trim()?null:"Choose a font.":"Enter a six-digit hex color.":"Enter watermark text."}function k_(e){const t={opacity:1-e.transparency/100,...e.placement?{placement:e.placement}:{}};if(e.kind==="text")return{kind:"text",text:e.text,fontFamily:e.fontFamily,fontSizePt:e.fontSize,bold:e.bold,italic:e.italic,color:e.color,orientation:e.orientation,...t};if(e.kind!=="picture")throw new Error("A removal has no watermark input.");return{kind:"picture",...e.src?{src:e.src}:{source:{kind:"existing",watermarkId:e.sourceWatermarkId}},scalePercent:e.scalePercent,washout:e.washout,lockAspectRatio:e.lockAspectRatio,...e.widthPt!=null?{widthPt:e.widthPt}:{},...e.heightPt!=null?{heightPt:e.heightPt}:{},...t}}var N9={default:"Default pages",first:"First page",even:"Even pages"},Mm="The document changed while this dialog was open. Review the latest watermark before applying.";function S_(e,t,n){return e.filter(r=>t==null||r.address.sectionId===t).flatMap(r=>(n==="all"?["default",...r.titlePage?["first"]:[],...r.oddEvenHeadersFooters?["even"]:[]]:[n]).map(o=>({kind:"headerFooterSlot",section:r.address,headerFooterKind:"header",variant:o})))}function __(e){return`${e.section.sectionId}:${e.variant}`}function Lm(e){return e instanceof Error?e.message:"The watermark could not be updated. Try again."}function B9(e){const t=D9(e.getContainer),n={...e,announce:l=>{t.announce(l),e.announce?.(l)}};let r=null,o=!1,i=0;function s(){const l=r;r=null,l?.dispose(),l?.handle.close()}function a(){if(o)return{ok:!1,reason:"not-ready"};const l=e.getEditor();if(!l)return{ok:!1,reason:"not-ready"};if(!l.doc?.watermarks?.list||!l.doc.sections?.list)return{ok:!1,reason:"document-api-unavailable"};if(!e.openSurface||!l.doc.watermarks.apply||!l.host?.watermarkPreview)return{ok:!1,reason:"operation-unavailable"};const u=++i,d=t.captureFocusReturn();s(),t.mount();const f=z9(l,n,()=>{r?.handle===p&&s()});let p;try{p=e.openSurface({mode:"dialog",ariaLabel:"Watermark",component:t.component,props:{model:f.model},dialog:{maxWidth:700}})}catch{return f.dispose(),{ok:!1,reason:"operation-unavailable"}}return r={handle:p,dispose:f.dispose},p.result.then(g=>{f.dispose(),r?.handle===p&&(r=null),(g.status==="closed"||g.status==="submitted")&&d(()=>!o&&u===i&&r===null)}),f.model.reload(),{ok:!0}}return{open:a,close:s,destroy(){o=!0,s(),t.destroy()}}}function z9(e,t,n){const r=new Set;let o=!0,i=0,s,a=[],l=[],u="",d=JSON.stringify(Rm()),f=null,p={phase:"loading",draft:Rm(),sections:[],sectionId:null,variant:"all",items:[],selectedIds:[],fonts:[...t.getFonts()],dirty:!1,canApply:!1,error:null,stale:!1,readonlyReason:null,impact:"",impactDetails:[],preview:null};const g=L=>o&&L===i&&t.getEditor()===e,m=()=>t.getMode()==="editing";function v(L){if(o){p={...p,...L};for(const $ of r)$(p)}}function C(){return clearTimeout(s),f=null,++i}function w(L){const $=l.find(H=>H.address.sectionId===L.section.sectionId),T=L.variant==="first"?!$?.titlePage:L.variant==="even"?!$?.oddEvenHeadersFooters:!1;return`Section ${($?.index??0)+1}, ${N9[L.variant].toLowerCase()}${T?" (inactive)":""}`}function S(){if(p.sectionId==null&&p.variant==="all")return a;const L=new Set(S_(l,p.sectionId,p.variant).map(__));return a.filter($=>$.effectiveIn.some(T=>L.has(__(T))))}function b(){v({items:S().map(L=>({id:L.watermarkId,label:L.watermark.kind==="text"?L.watermark.text:"Picture watermark",locations:L.effectiveIn.map(w).join("; ")}))})}function k(){const L=p.sectionId==null&&p.variant==="all"?{kind:"document"}:{kind:"headerFooterSlots",slots:S_(l,p.sectionId,p.variant)};if(p.draft.kind==="none")return{target:L,action:"remove",watermarkIds:p.selectedIds};const $=k_(p.draft);if(p.selectedIds.length)return{target:L,action:"replace",watermarkIds:p.selectedIds,watermark:$};if("source"in $)throw new Error("Select the existing picture watermark in this scope, or choose a new picture.");return{target:L,action:"insert",watermark:$}}function x(L){if(L.success)return!1;const $=L.failure?.code==="REVISION_MISMATCH";return v({stale:$,phase:"editing",canApply:!1,error:$?Mm:L.failure?.message??"The watermark could not be updated."}),!0}async function M(L){try{const $=F9(p.draft);if($){v({phase:"editing",error:$,canApply:!1,preview:null});return}const T=p.draft.kind==="none"&&!p.selectedIds.length?null:k(),H=p.draft.kind==="none"?null:await e.host.watermarkPreview({watermark:k_(p.draft),sectionId:p.sectionId??l[0]?.address.sectionId,expectedRevision:u});if(!g(L))return;if(!T||!p.dirty||!m()){v({phase:"editing",preview:H,canApply:!1,error:null});return}const R=await e.doc.watermarks.apply(T,{expectedRevision:u,dryRun:!0});if(!g(L))return;if(!R.success){x(R);return}f=T;const U=R.affectedSlots.map(w);v({phase:"editing",preview:H,error:null,canApply:U.length>0&&!p.stale&&m(),impact:U.length?`Changes: ${U.length>3?`${U.length} page locations`:U.join("; ")}. Other locations stay as they are.`:"No matching watermark will change.",impactDetails:U.length>3?U:[]})}catch($){g(L)&&v({phase:"editing",error:Lm($),canApply:!1,preview:null})}}function z(){const L=C();v({phase:"previewing",canApply:!1,error:null,impact:"",impactDetails:[],preview:null}),s=setTimeout(()=>{M(L)},120)}const G={getSnapshot:()=>p,subscribe(L){return r.add(L),L(p),()=>{r.delete(L)}},async reload(){const L=C();v({phase:"loading",canApply:!1,stale:!1,error:null,impactDetails:[],preview:null});try{const[$,T]=await Promise.all([e.doc.watermarks.list(),e.doc.sections.list()]);if(!g(L))return;if($.items.length!==$.total||T.items.length!==T.total)throw new Error("The complete watermark scope could not be loaded.");if(T.evaluatedRevision&&T.evaluatedRevision!==$.evaluatedRevision)throw new Error(Mm);a=$.items,l=T.items,u=$.evaluatedRevision;const H=S(),R=H.length===1?H[0]:void 0,U=Rm(R);d=JSON.stringify(U),v({draft:U,dirty:!1,selectedIds:R?[R.watermarkId]:[],sections:l.map(W=>({id:W.address.sectionId,label:`Section ${W.index+1}`})),readonlyReason:m()?null:t.getMode()==="suggesting"?"Watermarks cannot be changed in Suggesting mode.":"This document is read-only.",impact:H.length>1?"Select the watermark copies you want to edit, or add a new watermark.":""}),b(),await M(L)}catch($){g(L)&&v({phase:"editing",error:Lm($),canApply:!1})}},patchDraft(L){if(!o||p.phase==="loading"||p.phase==="applying"||!m())return;const $=O9(p.draft,L);v({draft:$,dirty:JSON.stringify($)!==d}),z()},setScope(L,$){if(!o||p.phase==="loading"||p.phase==="applying"||L!=null&&!l.some(U=>U.address.sectionId===L))return;v({sectionId:L,variant:$}),b();const T=S(),H=new Set(T.map(U=>U.watermarkId));let R=p.selectedIds.filter(U=>H.has(U));p.dirty&&p.draft.kind==="none"&&!R.length&&T.length===1&&(R=[T[0].watermarkId]),v({selectedIds:R}),p.dirty?z():G.selectWatermarks(T.length===1?[T[0].watermarkId]:[])},selectWatermarks(L){if(!o||p.phase==="loading"||p.phase==="applying")return;const $=S(),T=[...new Set(L)].filter(R=>$.some(U=>U.watermarkId===R)),H=Rm($.find(R=>R.watermarkId===T[0]));d=JSON.stringify(H),v({selectedIds:T,draft:H,dirty:!1}),z()},async apply(){if(!o||!p.canApply||!f||!m()||t.getEditor()!==e)return;const L=f,$=C();v({phase:"applying",canApply:!1,error:null}),t.announce?.("Applying watermark changes. Closing the dialog will not cancel them.");try{const T=await e.doc.watermarks.apply(L,{expectedRevision:u});if(!g($)){t.announce?.(T.success?"Watermark updated.":"The watermark could not be updated.");return}if(x(T))return;t.announce?.(L.action==="remove"?"Watermark removed.":"Watermark updated."),n()}catch(T){g($)?v({phase:"editing",error:Lm(T),canApply:!1}):t.announce?.(Lm(T))}}},F=e.host?.events?.subscribe(L=>{if(!(!o||p.phase==="applying")){if(L.type==="collaboration:document-replaced"){C(),v({phase:"editing",stale:!0,canApply:!1,error:Mm});return}["document:mutated","mutation:committed","collaboration:remote-changed"].includes(L.type)&&(C(),p.dirty?v({phase:"editing",stale:!0,canApply:!1,error:Mm}):s=setTimeout(()=>{G.reload()},120))}});return{model:G,dispose(){o=!1,C(),F?.(),r.clear()}}}function j9(e){if(!e||typeof e!="object")return{};const t={};e.fonts&&(t.rFonts={ascii:e.fonts.ascii,hAnsi:e.fonts.hAnsi,eastAsia:e.fonts.eastAsia,cs:e.fonts.cs,asciiTheme:e.fonts.asciiTheme,hAnsiTheme:e.fonts.hAnsiTheme,eastAsiaTheme:e.fonts.eastAsiaTheme,csTheme:e.fonts.csTheme,hint:e.fonts.hint}),e.fontFamily!=null&&(t.fontFamily=e.fontFamily),e.lang&&(t.lang={val:e.lang.val,eastAsia:e.lang.eastAsia,bidi:e.lang.bidi}),e.fontSize!=null&&(t.fontSize=e.fontSize),e.fontSizeCs!=null&&(t.fontSizeCs=e.fontSizeCs);const n=Pm(e.color);n!=null&&(t.color=n),e.highlight!=null&&(t.highlight=e.highlight);const r=U9(e.shading);r&&(t.shading=r),e.cs!=null&&(t.cs=e.cs),e.rtl!=null&&(t.rtl=e.rtl),e.bold!=null&&(t.bold=e.bold),e.boldCs!=null&&(t.bCs=e.boldCs),e.italic!=null&&(t.italic=e.italic),e.italicCs!=null&&(t.iCs=e.italicCs);const o=V9(e.underline);o!==void 0&&(t.underline=o),e.strikethrough!=null&&(t.strike=e.strikethrough),e.doubleStrikethrough!=null&&(t.dstrike=e.doubleStrikethrough),e.caps!=null&&(t.caps=e.caps),e.smallCaps!=null&&(t.smallCaps=e.smallCaps),e.outline!=null&&(t.outline=e.outline),e.shadow!=null&&(t.shadow=e.shadow),e.emboss!=null&&(t.emboss=e.emboss),e.imprint!=null&&(t.imprint=e.imprint),e.verticalAlign!=null&&(t.vertAlign=e.verticalAlign),e.characterSpacing!=null&&(t.letterSpacing=e.characterSpacing),e.characterScale!=null&&(t.charScale=e.characterScale),e.kern!=null&&(t.kerning=e.kern),e.baselineShift!=null&&(t.position=e.baselineShift),e.fitTextWidth!=null&&(t.fitText={val:e.fitTextWidth}),e.vanish!=null&&(t.vanish=e.vanish),e.webHidden!=null&&(t.webHidden=e.webHidden),e.specVanish!=null&&(t.specVanish=e.specVanish);const i=$9(e.border);return i&&(t.border=i),t}function Pm(e){if(e){if(typeof e=="string")return e;if(e.model==="rgb")return e.value;if(e.model==="auto")return"auto"}}function V9(e){if(e==null)return;const t={};return e.style!=null&&(t.style=e.style),e.color?.model==="rgb"&&(t.color=e.color.value),e.color?.model==="theme"&&(t.themeColor=e.color.theme),Object.keys(t).length>0?t:!0}function U9(e){if(!e)return;const t={},n=Pm(e.fill);n!=null&&(t.fill=n);const r=Pm(e.color);return r!=null&&(t.color=r),e.pattern!=null&&(t.val=e.pattern),Object.keys(t).length>0?t:void 0}function $9(e){if(!e)return;const t={};e.style!=null&&(t.val=e.style),e.width!=null&&(t.sz=e.width),e.space!=null&&(t.space=e.space);const n=Pm(e.color);return n!=null&&(t.color=n),Object.keys(t).length>0?t:void 0}function Mc(e){const t=e?.selectionTarget??e?.target;if(!e||!t)return"";try{return JSON.stringify(t)}catch{return String(t)}}function A_(e){if(e?.type!=="mutation:committed")return null;const t=e.origin==="history"?e.result:e.receipt;if(!t||typeof t!="object")return null;const n=new Set,r=new Set,o=[],i=(l,u)=>{l?.kind!=="entity"||l.entityType!=="trackedChange"||typeof l.entityId=="string"&&l.entityId.length>0&&u.add(l.entityId)},s=l=>l?.kind!=="entity"||l.entityType!=="trackedChange"?null:typeof l.entityId=="string"&&l.entityId.length>0?l.entityId:null;if(Array.isArray(t.inserted)&&t.inserted.forEach(l=>i(l,n)),Array.isArray(t.updated)&&t.updated.forEach(l=>i(l,n)),Array.isArray(t.trackedChangeRefs)&&t.trackedChangeRefs.forEach(l=>i(l,n)),Array.isArray(t.trackedChanges)&&t.trackedChanges.forEach(l=>i(l,n)),Array.isArray(t.steps)){for(const l of t.steps)if(Array.isArray(l?.trackedChangeIds))for(const u of l.trackedChangeIds)typeof u=="string"&&u.length>0&&n.add(u)}if(Array.isArray(t.removed)&&t.removed.forEach(l=>i(l,r)),Array.isArray(t.invalidatedRefs)&&t.invalidatedRefs.forEach(l=>i(l,r)),Array.isArray(t.remappedRefs))for(const l of t.remappedRefs){const u=s(l?.from),d=s(l?.to);u&&r.add(u),d&&n.add(d),u&&d&&u!==d&&o.push({from:u,to:d})}for(const l of r)n.delete(l);const a=W9(e,t);return n.size===0&&r.size===0&&!a?null:{upsertIds:n,removedIds:r,remappedPairs:o,reconcileMode:"targeted",...a?{allResolved:a}:{}}}function H9(e){const t=new Set;if(e?.type!=="mutation:committed")return t;const n=e.origin==="history"?e.result:e.receipt;if(!Array.isArray(n?.invalidatedRefs))return t;for(const r of n.invalidatedRefs)r?.kind==="entity"&&r.entityType==="comment"&&typeof r.entityId=="string"&&r.entityId&&t.add(r.entityId);return t}function G9({event:e,commentsStore:t,superdoc:n,documentId:r}={}){const o=H9(e);return o.size===0?{ok:!0,removedIds:[]}:t?.dropCommentsFromMutationImpact?.({superdoc:n,documentId:r,removedIds:o})??{ok:!0,removedIds:[]}}function W9(e,t){const n=e?.trackedChangeAllResolved;return e?.origin==="history"||!n||n.schemaVersion!==1||n.targetKind!=="all"||n.decision!=="accept"&&n.decision!=="reject"||n.remainingLogicalCount!==0||typeof n.catalogRevision!="string"||!n.catalogRevision||typeof n.sourceCoverageRevision!="string"||!n.sourceCoverageRevision||!Number.isSafeInteger(n.logicalTargetCount)||n.logicalTargetCount<=0||!Number.isSafeInteger(n.physicalCarrierCount)||n.physicalCarrierCount<n.logicalTargetCount||typeof n.txId!="string"||n.txId!==t.txId||typeof n.documentEpoch!="string"||!Number.isSafeInteger(n.commitSequence)||typeof n.packagePreviousRevision!="string"||typeof n.packageNextRevision!="string"||n.packagePreviousRevision===n.packageNextRevision?null:n}var K9=new Set(["insert-text","replace-text","plain-text-paste","delete-backward","delete-forward","text.insert","text.replace","text.pastePlain","text.deleteBackward","text.deleteForward","structural.enter","structural:enter-split-paragraph","structural:enter-insert-paragraph-before","structural:enter-insert-paragraph-after","structural:shift-enter-line-break","structural:backspace-boundary-merge-with-previous","structural:delete-boundary-merge-with-next","backspace:boundary-merge-with-previous","backspace:list-remove","backspace:list-outdent"]),q9=e=>e?.type!=="mutation:committed"||e.origin!=="command"?!1:K9.has(e.editableCommandKind),tt={notReady:"not-ready",documentApiUnavailable:"document-api-unavailable",documentReadonly:"document-readonly",trackedChangeDecisionsDisabled:"tracked-change-decisions-disabled",selectionRequired:"selection-required",rangeSelectionRequired:"range-selection-required",contextUnavailable:"context-unavailable",geometryUnavailable:"geometry-unavailable",targetUnresolved:"target-unresolved",targetNotVisible:"target-not-visible",commandUnsupported:"command-unsupported",commandDeferred:"command-deferred",tableContextUnavailable:"table-context-unavailable",operationUnavailable:"operation-unavailable",bulkDecisionsDisabled:"bulk-decisions-disabled",hostCapabilityUnavailable:"host-capability-unavailable",historyEmpty:"history-empty",searchUnavailable:"search-unavailable",searchInvalidPattern:"search-invalid-pattern",searchTruncated:"search-truncated",replaceUnsupported:"replace-unsupported",contentControlLocked:"content-control-locked",permissionDenied:"permission-denied"},I_={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strikethrough",fontFamily:"font-family",fontSize:"font-size",setFontFamily:"setFontFamily",setFontSize:"setFontSize",undo:"undo",redo:"redo",acceptChange:"acceptChange",rejectChange:"rejectChange",acceptAllChanges:"acceptAllChanges",rejectAllChanges:"rejectAllChanges",bulletList:"bullet-list",numberedList:"numbered-list"};function E_(e){const t=n=>typeof n=="string"?n.replace(/\s*pt$/i,"").trim():n;if(typeof e=="string")return t(e);if(e&&typeof e=="object"&&"value"in e){const n=e;return{...n,value:t(n.value)}}return e}function Y9(e){const t=(n,r)=>!r&&n>0&&n<=5?n*100:n;if(typeof e=="string"){const n=e.includes("%"),r=Number.parseFloat(e.replace("%","").trim());return Number.isFinite(r)?t(r,n):e}return typeof e=="number"&&Number.isFinite(e)?t(e,!1):e}function X9(e){const t=e&&typeof e=="object"&&"value"in e?e.value:e;if(t==="in"||t==="cm")return t;if(typeof t=="string"){const n=t.trim().toLowerCase();if(n==="in"||n==="inch"||n==="inches")return"in";if(n==="cm"||n==="centimeter"||n==="centimeters"||n==="centimetre"||n==="centimetres")return"cm"}return t}function x_(e){const t=n=>{if(n===null)return null;if(typeof n!="string")return n;const r=n.trim();return r===""?n:/^#[0-9a-fA-F]{6}$/.test(r)?r:/^[0-9a-fA-F]{6}$/.test(r)?`#${r}`:r};if(e&&typeof e=="object"&&"value"in e){const n=e;return{...n,value:t(n.value)}}return t(e)}function P0(e,t){if(e&&typeof e=="object"){const n=e;for(const r of t)if(r in n)return n[r]}return e}function Z9(e){const t=P0(e,["alignment","value"]);if(typeof t!="string")return t;const n=t.trim().toLowerCase();return n==="justified"||n==="both"?"justify":n}var Q9=new Set(["left","center","right"]),J9=new Set(["decimal","lowerLetter","upperLetter","lowerRoman","upperRoman","numberInDash","hebrew1","hebrew2"]);function T_(e){if(e.kind!==void 0&&e.kind!=="header"&&e.kind!=="footer")return null;const t=e.position??(e.kind==="header"?"top":e.kind==="footer"?"bottom":void 0);if(t!==void 0)return t!=="top"&&t!=="bottom"?null:t==="top"?"header":"footer"}function R_(e){return e!=null&&typeof e!="object"?null:e??{}}function eO(e){const t=R_(e);if(!t)return null;const n=T_(t);return n===null||t.alignment!==void 0&&!Q9.has(t.alignment)||t.showOnFirstPage!==void 0&&typeof t.showOnFirstPage!="boolean"||t.format!==void 0&&!J9.has(t.format)||t.start!==void 0&&t.start!==null&&(typeof t.start!="number"||!Number.isInteger(t.start)||t.start<0)?null:{kind:n??"footer",...t.alignment!==void 0?{alignment:t.alignment}:{},...t.showOnFirstPage!==void 0?{showOnFirstPage:t.showOnFirstPage}:{},...t.format!==void 0?{format:t.format}:{},...t.start!==void 0?{start:t.start}:{}}}function tO(e){const t=R_(e);if(!t)return null;const n=T_(t);return n===null?null:n?{kind:n}:{}}function nO(e){const t=P0(e,["line","lineHeight","value"]),n=typeof t=="number"?t:typeof t=="string"?Number.parseFloat(t.trim()):NaN;return!Number.isFinite(n)||n<=0?t:n<=10?Math.round(n*240):Math.round(n)}function rO(e){if(e&&typeof e=="object"&&"role"in e)return e;const t=P0(e,["styleId","value","style"]);return typeof t=="string"?t.trim():t}function oO(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e.mode;if(typeof t=="string")return t}return e}var iO=tt.commandUnsupported,ea=tt.tableContextUnavailable,M_=[{id:"bold",family:"inline marks",disposition:"routed",mutates:!0,docRoute:"format.bold",activeMark:"bold",inline:{key:"bold",kind:"toggle"}},{id:"italic",family:"inline marks",disposition:"routed",mutates:!0,docRoute:"format.italic",activeMark:"italic",inline:{key:"italic",kind:"toggle"}},{id:"underline",family:"inline marks",disposition:"routed",mutates:!0,docRoute:"format.underline",activeMark:"underline",inline:{key:"underline",kind:"toggle"}},{id:"strikethrough",family:"inline marks",disposition:"routed",mutates:!0,docRoute:"format.strikethrough",activeMark:"strikethrough",inline:{key:"strike",kind:"toggle"}},{id:"font-family",family:"fonts",disposition:"routed",mutates:!0,docRoute:"format.fontFamily",aliases:["setFontFamily"],inline:{key:"fontFamily",kind:"value-string"}},{id:"font-size",family:"fonts",disposition:"routed",mutates:!0,docRoute:"format.fontSize",aliases:["setFontSize"],normalizePayload:E_,inline:{key:"fontSize",kind:"value-number"}},{id:"setFontFamily",family:"fonts",disposition:"routed",mutates:!0,docRoute:"format.fontFamily",aliasOf:"font-family",inline:{key:"fontFamily",kind:"value-string"}},{id:"setFontSize",family:"fonts",disposition:"routed",mutates:!0,docRoute:"format.fontSize",aliasOf:"font-size",normalizePayload:E_,inline:{key:"fontSize",kind:"value-number"}},{id:"undo",family:"history",disposition:"routed",mutates:!0,docRoute:"history.undo"},{id:"redo",family:"history",disposition:"routed",mutates:!0,docRoute:"history.redo"},{id:"acceptChange",family:"tracked changes",disposition:"routed",mutates:!0,trackDecision:{kind:"accept",scope:"id"},aliases:["track-changes-accept-selection"]},{id:"rejectChange",family:"tracked changes",disposition:"routed",mutates:!0,trackDecision:{kind:"reject",scope:"id"},aliases:["track-changes-reject-selection"]},{id:"acceptAllChanges",family:"tracked changes (bulk)",disposition:"routed",mutates:!0,trackDecision:{kind:"accept",scope:"all"}},{id:"rejectAllChanges",family:"tracked changes (bulk)",disposition:"routed",mutates:!0,trackDecision:{kind:"reject",scope:"all"}},{id:"track-changes-accept-selection",family:"tracked changes",disposition:"routed",mutates:!0,trackDecision:{kind:"accept",scope:"id"},aliasOf:"acceptChange"},{id:"track-changes-reject-selection",family:"tracked changes",disposition:"routed",mutates:!0,trackDecision:{kind:"reject",scope:"id"},aliasOf:"rejectChange"},{id:"zoom",family:"zoom",disposition:"routed",mutates:!1,instanceRoute:"setZoom",valueFrom:"zoom",normalizePayload:Y9},{id:"zoom-fit-width",family:"zoom",disposition:"routed",mutates:!1,instanceRoute:"setZoomMode",fixedArg:"fit-width",valueFrom:"zoom"},{id:"document-mode",family:"document",disposition:"routed",mutates:!1,instanceRoute:"setDocumentMode",valueFrom:"documentMode",normalizePayload:oO},{id:"measurement-unit",family:"measurement",disposition:"routed",mutates:!1,instanceRoute:"setMeasurementUnit",valueFrom:"measurementUnit",normalizePayload:X9},{id:"text-color",family:"color",disposition:"routed",mutates:!0,docRoute:"format.color",inline:{key:"color",kind:"value-string"},normalizePayload:x_},{id:"highlight-color",family:"color",disposition:"routed",mutates:!0,docRoute:"format.highlight",inline:{key:"highlight",kind:"value-string"},normalizePayload:x_},{id:"link",family:"links",disposition:"routed",mutates:!0,docRoute:"hyperlinks.wrap",activeMark:"link",link:{kind:"link"}},{id:"text-align",family:"paragraph",disposition:"routed",mutates:!0,docRoute:"format.paragraph.setAlignment",blockParagraph:{kind:"alignment"},normalizePayload:Z9},{id:"line-height",family:"paragraph",disposition:"routed",mutates:!0,docRoute:"format.paragraph.setSpacing",blockParagraph:{kind:"spacing-line"},normalizePayload:nO},{id:"linked-style",family:"paragraph",disposition:"routed",mutates:!0,docRoute:"styles.paragraph.setStyle",blockParagraph:{kind:"style"},normalizePayload:rO},{id:"bullet-list",family:"lists",disposition:"routed",mutates:!0,docRoute:"lists.apply",list:{mode:"toggle-seed",seed:"bullet"}},{id:"numbered-list",family:"lists",disposition:"routed",mutates:!0,docRoute:"lists.apply",list:{mode:"toggle-seed",seed:"ordered"}},{id:"indent-increase",family:"lists/indent",disposition:"routed",mutates:!0,docRoute:"lists.indent",list:{mode:"indent"}},{id:"indent-decrease",family:"lists/indent",disposition:"routed",mutates:!0,docRoute:"lists.outdent",list:{mode:"outdent"}},{id:"direction-ltr",family:"direction",disposition:"routed",mutates:!0,docRoute:"format.paragraph.setDirection",blockParagraph:{kind:"direction",fixedValue:"ltr"}},{id:"direction-rtl",family:"direction",disposition:"routed",mutates:!0,docRoute:"format.paragraph.setDirection",blockParagraph:{kind:"direction",fixedValue:"rtl"}},{id:"clear-formatting",family:"formatting",disposition:"routed",mutates:!0,docRoute:"format.apply",inline:{key:"*",kind:"clear"}},{id:"image",family:"media",disposition:"routed",mutates:!0,docRoute:"create.image",create:{kind:"image"}},{id:"table-of-contents-insert",family:"TOC",disposition:"routed",mutates:!0,docRoute:"create.tableOfContents",create:{kind:"toc"}},{id:"table-insert",family:"tables",disposition:"routed",mutates:!0,docRoute:"create.table",create:{kind:"table"}},{id:"page-number-insert",family:"fields",disposition:"routed",mutates:!0,docRoute:"fields.insert",field:{instruction:"PAGE"}},{id:"page-numbers-apply",family:"fields",disposition:"routed",mutates:!0,docRoute:"headerFooters.pageNumbers.set",pageNumbers:"set",normalizePayload:eO},{id:"page-numbers-remove",family:"fields",disposition:"routed",mutates:!0,docRoute:"headerFooters.pageNumbers.remove",pageNumbers:"remove",normalizePayload:tO},{id:"table-add-row-before",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.insertRow",table:{action:"insert-row-before",op:"insertRow"},reason:ea},{id:"table-add-row-after",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.insertRow",table:{action:"insert-row-after",op:"insertRow"},reason:ea},{id:"table-delete-row",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.deleteRow",table:{action:"delete-row",op:"deleteRow"},reason:ea},{id:"table-add-column-before",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.insertColumn",table:{action:"insert-column-before",op:"insertColumn"},reason:ea},{id:"table-add-column-after",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.insertColumn",table:{action:"insert-column-after",op:"insertColumn"},reason:ea},{id:"table-delete-column",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.deleteColumn",table:{action:"delete-column",op:"deleteColumn"},reason:ea},{id:"table-delete",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.delete",table:{action:"delete-table",op:"delete"},reason:ea},{id:"table-merge-cells",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.mergeCells",table:{action:"merge-cells",op:"mergeCells"},reason:ea},{id:"table-split-cell",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.splitCell",table:{action:"split-cell",op:"splitCell",requiresCell:!0},reason:ea},{id:"table-remove-borders",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.setBorders",table:{action:"remove-borders",op:"setBorders"},reason:ea},{id:"ruler",family:"UI chrome",disposition:"routed",mutates:!1,instanceRoute:"toggleRuler",valueFrom:"ruler"},{id:"formatting-marks",family:"UI chrome",disposition:"routed",mutates:!1,instanceRoute:"toggleFormattingMarks",valueFrom:"formattingMarks"},{id:"copy-format",family:"formatting",disposition:"routed",mutates:!1},{id:"table-fix",family:"tables",disposition:"unsupported",mutates:!0,reason:iO}],sO=new Map(M_.map(e=>[e.id,e])),aO=M_.map(e=>e.id);function nd(e){return sO.get(e)??null}function L_(e){return e.split(",").map(t=>t.trim()).filter(Boolean)}function lO(e){const t=[],n=o=>{o&&!t.includes(o)&&t.push(o)};n(e.getAttribute("data-track-change-preferred-target-id"));const r=e.getAttribute("data-track-change-ids");if(r)for(const o of L_(r))n(o);return n(e.getAttribute("data-track-change-id")),t}function P_(e,t){if(!e||typeof e.getAttribute!="function")return[];const n=[],r=new Set;let o=[],i=null,s=null,a=e;for(;a;){const l=a;i??=l.getAttribute("data-story-key");const u=lO(l),d=u.length>0?l.getAttribute("data-story-key"):null;for(const C of u){const w=`trackedChange:${C}`;if(!r.has(w)){r.add(w);const S={type:"trackedChange",id:C};d&&(S.storyKey=d),n.push(S),o.push(S)}}const f=l.getAttribute("data-layout-story");if(s??=f,f&&o.length>0){for(const C of o)C.story=f;o=[]}const p=l.getAttribute("data-citation-id");if(p){const C=`citation:${p}`;r.has(C)||(r.add(C),n.push({type:"citation",id:p}))}const g=l.getAttribute("data-comment-ids");if(g)for(const C of L_(g)){const w=`comment:${C}`;r.has(w)||(r.add(w),n.push({type:"comment",id:C}))}const m=l.getAttribute("data-sdt-type"),v=l.getAttribute("data-sdt-id");if(v&&m==="structuredContent"){const C=`contentControl:${v}`;if(!r.has(C)){r.add(C);const w=l.getAttribute("data-sdt-scope"),S=l.getAttribute("data-sdt-tag"),b={type:"contentControl",id:v};i&&(b.storyKey=i),s?b.story=s:o.push(b),(w==="block"||w==="inline")&&(b.scope=w),S&&(b.tag=S),n.push(b)}}if(t&&a===t)break;a=a.parentElement}return n}function cO(e){const t=e?.directionContext?.inlineDirection;if(t!=null)return t;const n=e?.paragraphProperties?.rightToLeft;if(n===!0)return"rtl";if(n===!1)return"ltr"}var D_=["#1f6feb","#d1242f","#8250df","#bf3989","#1a7f37","#9a6700","#bc4c00","#0969da","#cf222e","#6639ba","#116329","#7d4e00"],uO=e=>e?`${typeof e.name=="string"?e.name:""} ${typeof e.email=="string"?e.email:""}`:"",dO=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0},fO=e=>{const t=uO(e),n=dO(t)%D_.length;return D_[n]},Zf=e=>typeof e=="string"&&e.length>0,hO=e=>{if(!e||e.enabled===!1)return;const t=e.overrides&&typeof e.overrides=="object"?e.overrides:void 0,n=typeof e.resolve=="function"?e.resolve:void 0;return r=>{const o=r??{};if(t){if(Zf(o.email)&&Zf(t[o.email]))return t[o.email];if(Zf(o.name)&&Zf(t[o.name]))return t[o.name]}if(n)try{const i=n(o);if(Zf(i))return i}catch{}return fO(o)}},pO=["insertion","deletion","move","move-from","move-to","table-cell-insertion","table-cell-deletion","cell-merge","cell-split","image-insertion","image-deletion","image-property-change"],bX=new Set(pO),Cr={externalImageDeferred:"render.media.external-image-deferred",missingRelationship:"render.drawing.missing-relationship",missingMediaPart:"render.media.missing-part",unsupportedRelationshipType:"render.drawing.unsupported-relationship-type",unsupportedMime:"render.media.unsupported-mime",imageTooLarge:"render.media.image-too-large",unsafeSvg:"render.media.unsafe-svg",unsupportedFormat:"render.media.unsupported-format",embeddedObjectNotSupported:"render.embedded-object-not-supported",unsupportedObject:"render.drawing.unsupported-object",vmlUnsupported:"render.drawing.vml-unsupported",vmlImageUnsupported:"render.drawing.vml-image-unsupported",unsupportedGeometryCommand:"render.drawing.unsupported-geometry-command",anchorUnsupported:"render.drawing.anchor-unsupported",wrapUnsupported:"render.drawing.wrap-unsupported",altContentNoSupportedChoice:"render.drawing.altcontent-no-supported-choice",groupChildUnsupported:"render.drawing.group-child-unsupported"},wX={"render.media.missing-relationship":Cr.missingRelationship,"render.media.wrong-relationship-type":Cr.unsupportedRelationshipType,"render.media.unsupported-target":Cr.unsupportedRelationshipType,"render.media.invalid-image-size":Cr.imageTooLarge,"render.media-resolver-unavailable":Cr.missingMediaPart,"render.chart-not-supported":Cr.unsupportedObject,"render.textbox.vml-unsupported":Cr.vmlUnsupported},mO={inlineBitmap:{family:"inlineBitmap",support:"supported",description:"wp:inline pic:pic with internal media and browser-safe MIME (PNG/JPEG; WebP/SVG once the host media resolver lands).",contract:"ImageRun"},anchoredBitmap:{family:"anchoredBitmap",support:"supported",description:"wp:anchor bitmap with anchor/wrap expressible by ImageAnchor/ImageWrap. Never silently inlined.",contract:"ImageBlock"},imageChildInGroup:{family:"imageChildInGroup",support:"supported",description:"Bitmap child of a supported DrawingML group/drawing wrapper. Supported only when the parent is.",contract:"ImageDrawing"},vectorShape:{family:"vectorShape",support:"supported",description:"Block/floating DrawingML preset/custom shape with the supported geometry/style subset.",contract:"DrawingBlock",drawingKind:"vectorShape"},shapeGroup:{family:"shapeGroup",support:"supported",description:"DrawingML group whose rendered children are supported vector/image children.",contract:"DrawingBlock",drawingKind:"shapeGroup"},chart:{family:"chart",support:"supported",description:"DrawingML chart projected into a ChartDrawing with parsed cached chart XML data. Complete Word chart fidelity remains deferred to chartFidelity.",contract:"DrawingBlock",drawingKind:"chart"},alternateContent:{family:"alternateContent",support:"supported",description:"mc:AlternateContent traversal/select policy. Selected Choice/Fallback maps to its family contract; unselected branches preserved for save/reopen.",contract:"selected-choice"},externalImage:{family:"externalImage",support:"fail-closed",description:'External image relationship (r:link / TargetMode="External"). Not fetched.',contract:"none",diagnostic:Cr.externalImageDeferred},missingRelationship:{family:"missingRelationship",support:"fail-closed",description:"Drawing references a relationship id absent from the owner part .rels.",contract:"none",diagnostic:Cr.missingRelationship},missingMediaPart:{family:"missingMediaPart",support:"fail-closed",description:"Relationship resolves but the target media part bytes are missing or empty.",contract:"none",diagnostic:Cr.missingMediaPart},wrongRelationshipType:{family:"wrongRelationshipType",support:"fail-closed",description:"Relationship exists but is not an image relationship type.",contract:"none",diagnostic:Cr.unsupportedRelationshipType},unsupportedMime:{family:"unsupportedMime",support:"fail-closed",description:"Media MIME outside the supported allowlist (incl. GIF/BMP/ICO).",contract:"none",diagnostic:Cr.unsupportedMime},oversizedMediaPart:{family:"oversizedMediaPart",support:"fail-closed",description:"Media part exceeds the host byte-size policy before bytes are materialized.",contract:"none",diagnostic:Cr.imageTooLarge},unsafeSvg:{family:"unsafeSvg",support:"fail-closed",description:"SVG content rejected by the SVG safety policy.",contract:"none",diagnostic:Cr.unsafeSvg},metafileOrTiff:{family:"metafileOrTiff",support:"fail-closed",description:"EMF/WMF/TIFF and other non-browser-native formats with no approved conversion path.",contract:"none",diagnostic:Cr.unsupportedFormat},embeddedObject:{family:"embeddedObject",support:"fail-closed",description:"OLE / ActiveX / embedded package object.",contract:"none",diagnostic:Cr.embeddedObjectNotSupported},smartArtOrDiagram:{family:"smartArtOrDiagram",support:"fail-closed",description:"SmartArt / diagram / unknown external graphic-data object.",contract:"none",diagnostic:Cr.unsupportedObject},vml:{family:"vml",support:"fail-closed",description:"VML structure outside any supported image-like subset (default fail-closed policy).",contract:"none",diagnostic:Cr.vmlUnsupported},vmlImageLike:{family:"vmlImageLike",support:"fail-closed",description:"Simple VML image references (v:imagedata) / watermark image metadata. Fail-closed unless a later change promotes a named subset with deterministic fixtures and exact oracles.",contract:"none",diagnostic:Cr.vmlImageUnsupported},unsupportedGeometryCommand:{family:"unsupportedGeometryCommand",support:"fail-closed",description:"Custom geometry command the extractor does not implement, e.g. arcTo.",contract:"none",diagnostic:Cr.unsupportedGeometryCommand},unsupportedAnchorFields:{family:"unsupportedAnchorFields",support:"fail-closed",description:"Anchor fields required for honest placement are unsupported (char-relative, alignment modes, etc.).",contract:"none",diagnostic:Cr.anchorUnsupported},unsupportedWrapFields:{family:"unsupportedWrapFields",support:"fail-closed",description:"Wrap fields required for honest placement are unsupported (arbitrary wrap polygons, etc.).",contract:"none",diagnostic:Cr.wrapUnsupported},alternateContentNoSupportedChoice:{family:"alternateContentNoSupportedChoice",support:"fail-closed",description:"mc:AlternateContent with no supported choice and no usable fallback.",contract:"none",diagnostic:Cr.altContentNoSupportedChoice},groupChildUnsupported:{family:"groupChildUnsupported",support:"fail-closed",description:"Unsupported child inside an otherwise-supported group. Supported siblings are not dropped.",contract:"none",diagnostic:Cr.groupChildUnsupported},objectEditing:{family:"objectEditing",support:"deferred",description:"Editing/mutation of anchored/vector objects.",contract:"none"},customWrapPolygon:{family:"customWrapPolygon",support:"deferred",description:"Full Word-compatible text wrapping for arbitrary custom wrap polygons.",contract:"none"},chartFidelity:{family:"chartFidelity",support:"deferred",description:"Complete chart fidelity (a dedicated chart effort owns the parsed subset).",contract:"none"},vmlFidelity:{family:"vmlFidelity",support:"deferred",description:"Complete VML fidelity.",contract:"none"},decorativeAccessibilityUi:{family:"decorativeAccessibilityUi",support:"deferred",description:"Full accessibility UI for decorative image semantics beyond preserving source data.",contract:"none"}},CX=Object.keys(mO),kX=Object.freeze(["multiple-sections","furniture-page-tokens","non-balanceable-multi-column-sections","body-anchored-objects","non-flowing-page-relative-body-anchors","footnotes","page-references","cross-references","keep-constraints","tables","furniture-anchored-objects"]),gO=Object.freeze(["checkpoint-geometry","section-numbering","font-style-inputs","notes","furniture","flowing-anchors","non-flowing-page-anchors","convergence","source-topology"]),SX=new Set(gO),po=()=>({oneOf:[{type:"boolean"},{type:"null"}]}),Dl=()=>({oneOf:[{type:"string",minLength:1},{type:"null"}]}),rd=()=>({oneOf:[{type:"number"},{type:"null"}]}),od=e=>({oneOf:[{type:"object",properties:e,additionalProperties:!1,minProperties:1},{type:"null"}]}),vO={type:"object",properties:{style:{oneOf:[{type:"string",minLength:1},{type:"null"}]},color:{oneOf:[{type:"string",minLength:1},{type:"null"}]},themeColor:{oneOf:[{type:"string",minLength:1},{type:"null"}]}},additionalProperties:!1,minProperties:1},yO={type:"object",properties:{id:{type:"number"},val:{type:"boolean"}},required:["id"],additionalProperties:!1},bO=()=>({oneOf:[{type:"boolean"},{type:"null"},vO]}),wO=()=>({oneOf:[{type:"array",items:yO,minItems:1},{type:"null"}]});function Dm(e,t){return{storage:"mark",markName:e,textStyleAttr:t}}function CO(e){return{storage:"runAttribute",nodeName:"run",runPropertyKey:e}}var D0=(e,t,n)=>({key:e,type:"boolean",ooxmlElement:t,storage:"mark",tracked:!0,carrier:Dm(n),schema:po()}),Lc=(e,t,n,r,o)=>({key:e,type:t,ooxmlElement:n,storage:"mark",tracked:!0,carrier:Dm("textStyle",o??e),schema:r}),Kn=(e,t,n,r,o)=>({key:e,type:t,ooxmlElement:n,storage:"runAttribute",tracked:!1,carrier:CO(o??e),schema:r}),Om=[D0("bold","w:b","bold"),D0("italic","w:i","italic"),D0("strike","w:strike","strike"),{key:"underline",type:"object",ooxmlElement:"w:u",storage:"mark",tracked:!0,carrier:Dm("underline"),schema:bO()},{key:"highlight",type:"string",ooxmlElement:"w:highlight",storage:"mark",tracked:!0,carrier:Dm("highlight"),schema:Dl()},Lc("color","string","w:color",Dl()),Lc("fontSize","number","w:sz",rd()),Lc("fontFamily","string","w:rFonts",Dl()),Lc("letterSpacing","number","w:spacing",rd()),Lc("vertAlign","string","w:vertAlign",{oneOf:[{enum:["superscript","subscript","baseline"]},{type:"null"}]}),Lc("position","number","w:position",rd()),Kn("dstrike","boolean","w:dstrike",po()),Kn("smallCaps","boolean","w:smallCaps",po()),Lc("caps","boolean","w:caps",po(),"textTransform"),Kn("shading","object","w:shd",od({fill:{oneOf:[{type:"string",minLength:1},{type:"null"}]},color:{oneOf:[{type:"string",minLength:1},{type:"null"}]},val:{oneOf:[{type:"string",minLength:1},{type:"null"}]}})),Kn("border","object","w:bdr",od({val:{oneOf:[{type:"string",minLength:1},{type:"null"}]},sz:{oneOf:[{type:"number"},{type:"null"}]},color:{oneOf:[{type:"string",minLength:1},{type:"null"}]},space:{oneOf:[{type:"number"},{type:"null"}]}}),"borders"),Kn("outline","boolean","w:outline",po()),Kn("shadow","boolean","w:shadow",po()),Kn("emboss","boolean","w:emboss",po()),Kn("imprint","boolean","w:imprint",po()),Kn("charScale","number","w:w",rd(),"w"),Kn("kerning","number","w:kern",rd(),"kern"),Kn("vanish","boolean","w:vanish",po()),Kn("webHidden","boolean","w:webHidden",po()),Kn("specVanish","boolean","w:specVanish",po()),Kn("rtl","boolean","w:rtl",po()),Kn("cs","boolean","w:cs",po()),Kn("bCs","boolean","w:bCs",po(),"boldCs"),Kn("iCs","boolean","w:iCs",po(),"italicCs"),Kn("eastAsianLayout","object","w:eastAsianLayout",od({id:{oneOf:[{type:"string",minLength:1},{type:"null"}]},combine:{oneOf:[{type:"boolean"},{type:"null"}]},combineBrackets:{oneOf:[{type:"string",minLength:1},{type:"null"}]},vert:{oneOf:[{type:"boolean"},{type:"null"}]},vertCompress:{oneOf:[{type:"boolean"},{type:"null"}]}})),Kn("em","string","w:em",Dl()),Kn("fitText","object","w:fitText",od({val:{oneOf:[{type:"number"},{type:"null"}]},id:{oneOf:[{type:"string",minLength:1},{type:"null"}]}})),Kn("snapToGrid","boolean","w:snapToGrid",po()),Kn("lang","object","w:lang",od({val:{oneOf:[{type:"string",minLength:1},{type:"null"}]},eastAsia:{oneOf:[{type:"string",minLength:1},{type:"null"}]},bidi:{oneOf:[{type:"string",minLength:1},{type:"null"}]}})),Kn("oMath","boolean","w:oMath",po()),Kn("rStyle","string","w:rStyle",Dl(),"styleId"),Kn("rFonts","object","w:rFonts",od({ascii:{oneOf:[{type:"string",minLength:1},{type:"null"}]},hAnsi:{oneOf:[{type:"string",minLength:1},{type:"null"}]},eastAsia:{oneOf:[{type:"string",minLength:1},{type:"null"}]},cs:{oneOf:[{type:"string",minLength:1},{type:"null"}]},asciiTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},hAnsiTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},eastAsiaTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},csTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},hint:{oneOf:[{type:"string",minLength:1},{type:"null"}]}}),"fontFamily"),Kn("fontSizeCs","number","w:szCs",rd()),Kn("ligatures","string","w14:ligatures",Dl()),Kn("numForm","string","w14:numForm",Dl()),Kn("numSpacing","string","w14:numSpacing",Dl()),Kn("stylisticSets","array","w14:stylisticSets",wO()),Kn("contextualAlternates","boolean","w14:cntxtAlts",po())],_X=new Set(Om.map(e=>e.key)),kO=Object.fromEntries(Om.map(e=>[e.key,e])),AX={mark:Om.filter(e=>e.storage==="mark").map(e=>e.key),runAttribute:Om.filter(e=>e.storage==="runAttribute").map(e=>e.key)},Fm=new WeakMap,O_=new WeakMap;function SO(e,t,n){let r=Fm.get(e);r||(r=new WeakMap,Fm.set(e,r)),r.set(t,n)}var F_=new WeakMap;function _O(e){return F_.get(e)?.()??Promise.resolve(null)}function id(e,t,n){return O_.get(e)?.(t,n)??e.commands.executeAsync(t,n)}function Ha(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Nm(){const e=globalThis;return{sink:typeof e.__superdocV2BenchPipelineTiming=="function"?e.__superdocV2BenchPipelineTiming:null,workerContext:e.__superdocV2BenchWorkerMessageContext??null}}function O0(e){const{sink:t}=Nm();if(t)try{t(e)}catch{}}var F0=new WeakMap;function AO(e){let t=F0.get(e);return t||(t={refCount:0,generation:0,abortController:new AbortController,inFlight:null,activeMutationTokens:new Set},F0.set(e,t)),t.refCount+=1,t}function IO(e,t){t.refCount=Math.max(0,t.refCount-1),!(t.refCount>0)&&(t.abortController.abort("ui-controller-destroyed"),t.inFlight=null,t.activeMutationTokens.clear(),F0.delete(e))}var EO=new Set(Object.values(tt));function Bm(e,t){return typeof e=="string"&&EO.has(e)?e:t}function N0(e){if(e&&typeof e=="object"&&e.ok===!1){const t=e.reason;return t==="host-not-ready"||t==="host-disposed"||t==="editing-mount-required"?{ok:!1,reason:tt.notReady}:{ok:!1,reason:Bm(t,tt.targetUnresolved)}}return{ok:!0}}var xO=["document-replaced","editorCreate","active-editor-change","document-mode-change","zoomChange","measurement-unit-change","viewport-change","fonts-changed"],TO={[I_.bulletList]:"bullet",[I_.numberedList]:"ordered"};function N_(e){return TO[e]??null}var RO={disc:"disc",circle:"circle",square:"square",decimal:"decimal","decimal-paren":"decimalParenthesis","upper-roman":"upperRoman","lower-roman":"lowerRoman","upper-alpha":"upperLetter","upper-alpha-paren":"upperLetterParenthesis","lower-alpha":"lowerLetter","lower-alpha-paren":"lowerLetterParenthesis"};function MO(e){const t=RO[e];return t?{preset:t,behavior:"toggleStyle"}:{}}var LO={status:"ready",empty:!0,target:null,selectionTarget:null,activeMarks:[],activeCommentIds:[],activeChangeIds:[],quotedText:""},PO=[{key:"contentControls",match:"exact",note:"full-document SDT catalog parse (the measured during-load cliff)"},{key:"contentControls:inRange:",match:"prefix",note:"same adapter load() as the catalog, issued per settled selection"},{key:"hyperlinks:",match:"prefix",note:"per-block hyperlink list over the loading story"},{key:"styles:catalog:",match:"prefix",note:"WordStyleModel recompile from package bytes"},{key:"comments",match:"exact",note:"audited: full comments list; stale-served during load"},{key:"trackChanges",match:"exact",note:"audited: shared all-story tracked-changes catalog; stale-served during load"},{key:"trackChanges:all",match:"exact",note:"audited: current-token validation over the shared all-story catalog; consumers fail closed on non-ready"},{key:"tables",match:"exact",note:"reserved: full tables catalog"},{key:"sections",match:"exact",note:"reserved: full sections list"}],DO=new Set(["/word/comments.xml","/word/commentsExtended.xml","/word/commentsIds.xml"]);function OO(e){return PO.some(t=>t.match==="exact"?t.key===e:e.startsWith(t.key))}var B_={ready:0,stale:1,pending:2};function Ol(...e){let t="ready";for(const n of e)B_[n]>B_[t]&&(t=n);return t}function Lt(e,t){if(typeof e!="function")return t;try{const n=e();return n===void 0?t:n}catch{return t}}function kr(e){return!!e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function Sr(e,t){if(!e)return null;const n=t.split(".");let r=e;for(const o of n){if(r==null)return null;r=r[o]}return typeof r=="function"?r:null}function er(e,t="CAPABILITY_UNAVAILABLE"){return{success:!1,failure:{code:t,message:e}}}function Qf(e,t){return{success:!1,failure:{code:"PARTIAL_LINK_EDIT",message:"Hyperlink target was updated, but display text replacement failed."},applied:{href:!0,text:!1},hyperlinkResult:e,textResult:t}}function Jf(e){if(!e||typeof e!="object")return null;const t=e.target;return t&&typeof t=="object"?t:null}function B0(e){if(!e||typeof e!="object")return!1;const t=e,n=i=>{if(!i||typeof i!="object")return!1;const s=i;return s.kind==="text"&&typeof s.blockId=="string"&&typeof s.offset=="number"},r=i=>{if(!i||typeof i!="object")return!1;const s=i,a=s.range;return typeof s.blockId=="string"&&typeof a?.start=="number"&&typeof a.end=="number"};if(Array.isArray(t.segments)){const i=t.segments[0],s=t.segments[t.segments.length-1];return r(i)&&r(s)}if(t.kind==="selection")return n(t.start)&&n(t.end);if(t.kind!=="text"||typeof t.blockId!="string")return!1;const o=t.range;return typeof o?.start=="number"&&typeof o.end=="number"}function z_(e,t){if(!e||typeof e!="object")return null;const n=Jf(e),r=e,o=r.navigationTarget&&typeof r.navigationTarget=="object"?r.navigationTarget:null;if(o?.kind==="block"&&typeof o.blockId=="string"&&o.blockId.length>0){const i={kind:"text",blockId:o.blockId,range:{start:0,end:0},...o.story&&typeof o.story=="object"?{story:o.story}:{},...r.address&&typeof r.address=="object"?{address:r.address}:{}};if(t?.preferStableBlock||!B0(n))return i}return n}function Qn(e){if(!e||typeof e!="object")return"story:body";const t=e,n=typeof t.storyType=="string"?t.storyType:"body";switch(n){case"body":return"story:body";case"headerFooterPart":return`story:headerFooterPart:${typeof t.refId=="string"?t.refId:""}`;case"headerFooterSlot":return JSON.stringify({storyType:n,section:t.section??null,headerFooterKind:t.headerFooterKind??null,variant:t.variant??null,resolution:t.resolution??"effective",onWrite:t.onWrite??"materializeIfInherited"});case"footnote":return`story:footnote:${typeof t.noteId=="string"?t.noteId:""}`;case"endnote":return`story:endnote:${typeof t.noteId=="string"?t.noteId:""}`;case"textbox":return`story:textbox:${typeof t.textboxId=="string"?t.textboxId:""}`;default:return JSON.stringify(t)}}function eh(e){if(!e||typeof e!="object")return null;const t=e,n=t.address&&typeof t.address=="object"?t.address:null;if(n?.story&&typeof n.story=="object")return n.story;if(t.storyLocator&&typeof t.storyLocator=="object")return t.storyLocator;if(t.trackedChangeStory&&typeof t.trackedChangeStory=="object")return t.trackedChangeStory;const r=Jf(e);if(!r||typeof r!="object")return null;const o=r;if(o.story&&typeof o.story=="object")return o.story;const i=o.address&&typeof o.address=="object"?o.address:null;return i?.story&&typeof i.story=="object"?i.story:null}function Ti(e,t,n){return Ur(e)!==t?!1:n?Qn(eh(e))===Qn(n):!0}function th(e){const t=eh(e);if(!(!t||Qn(t)===Qn(null)))return t}function j_(e){if(typeof e!="string"||e.length===0)return;const t=p6(e);switch(t.kind){case"body":return;case"footnote":return t.id?{kind:"story",storyType:"footnote",noteId:t.id}:void 0;case"endnote":return t.id?{kind:"story",storyType:"endnote",noteId:t.id}:void 0;case"header":case"footer":return t.id?{kind:"story",storyType:"headerFooterPart",refId:t.id}:void 0;case"textbox":return t.id?{kind:"story",storyType:"textbox",textboxId:t.id}:void 0;default:return}}function V_(e){if(!(typeof e!="string"||e.length===0||e==="body")){if(e.startsWith("hf:part:")){const t=e.slice(8);return t?{kind:"story",storyType:"headerFooterPart",refId:t}:void 0}if(e.startsWith("fn:")){const t=e.slice(3);return t?{kind:"story",storyType:"footnote",noteId:t}:void 0}if(e.startsWith("en:")){const t=e.slice(3);return t?{kind:"story",storyType:"endnote",noteId:t}:void 0}}}function zm(e){if(!e||typeof e!="object")return null;const t=e.selectionTarget;return t&&typeof t=="object"?t:null}function nh(e){if(!e||typeof e!="object")return null;const t=e.id;return typeof t=="string"&&t.length>0?t:null}function FO(e){if(!e||typeof e!="object")return null;const t=e;if(t.kind!=="selection")return e;const n=t.start;return!n||typeof n!="object"?null:{...t,end:n}}function Ur(e){if(!e||typeof e!="object")return null;const t=e,n=t.id??t.commentId??t.changeId;return typeof n=="string"&&n.length>0?n:null}function sd(e){return typeof e=="string"?e.trim():""}function NO(e,t){const n=t??{},r=sd(n.id).toLowerCase(),o=sd(e.authorId).toLowerCase();if(r&&o)return r===o;const i=sd(n.email).toLowerCase(),s=sd(e.authorEmail).toLowerCase();if(i&&s)return i===s;if(r||i||o||s)return!1;const a=sd(e.author).replace(/\s+/g," ").toLowerCase();if(!a)return!0;const l=sd(n.name).replace(/\s+/g," ").toLowerCase();return!!(l&&l===a)}function BO(e){if(!e||typeof e!="object")return null;const t=e,n=t.anchor,r=t.focus,o=n?.visualCaret,i=r?.visualCaret,s=o?.trackChangeId,a=i?.trackChangeId;return typeof s=="string"&&s.length>0&&s===a?s:null}function zO(e){if(!e||typeof e!="object")return!1;const t=e,n=t.anchor,r=t.focus;return typeof n?.blockId!="string"||!n.blockId||typeof r?.blockId!="string"||!r.blockId||!Number.isFinite(n.blockOffset)||!Number.isFinite(r.blockOffset)?!1:n.blockId!==r.blockId||n.blockOffset!==r.blockOffset||Number.isFinite(n.trackedBlockOffset)&&Number.isFinite(r.trackedBlockOffset)&&n.trackedBlockOffset!==r.trackedBlockOffset}var U_=new WeakMap;function $_(e){const t=[],n=i=>{typeof i=="string"&&i.length>0&&!t.includes(i)&&t.push(i)},r=i=>{if(!i||typeof i!="object")return;const s=i,a=s.sourceIds;if(a&&typeof a=="object"&&(n(a.wordIdInsert),n(a.wordIdDelete),Array.isArray(a.wordIdOther)))for(const f of a.wordIdOther)n(f);const l=s.wordRevisionIds;l&&typeof l=="object"&&(n(l.insert),n(l.delete),n(l.format));const u=s.replacement;if(u&&typeof u=="object")for(const f of[u.inserted,u.deleted])f&&typeof f=="object"&&(n(f.id),n(f.wordId));const d=s.move;if(d&&typeof d=="object")for(const f of[d.source,d.destination])f&&typeof f=="object"&&(n(f.id),n(f.wordId))};r(e);const o=e?.change;return o&&o!==e&&r(o),t}function ta(e){const t=U_.get(e);if(t)return t;const n=new Set,r=new Map;for(const i of e){const s=Ur(i);if(s){n.add(s);for(const a of $_(i)){r.has(a)||r.set(a,s);const l=`imported:${a}`;r.has(l)||r.set(l,s)}}}const o={toPublicId(i){if(n.has(i))return i;const s=r.get(i);return s!=null&&n.has(s)?s:null},aliasesFor(i){const s=[i];for(const[a,l]of r)l===i&&!s.includes(a)&&s.push(a);return s}};return U_.set(e,o),o}var H_=new WeakMap,G_=new WeakMap;function Fl(e,t){const n=Qn(t);let r=H_.get(e);r||(r=new Map,H_.set(e,r));const o=r.get(n);if(o)return o;const i=ta(e.filter(s=>Qn(eh(s))===n));return r.set(n,i),i}function W_(e){return!!e&&typeof e=="object"&&e.storyType==="textbox"}function jO(e,t){const n=t.filter(o=>e.some(i=>Ur(i)===o&&eh(i)==null));if(n.length===0)return null;if(n.length===1)return n[0];const r=new Set;for(const o of n){const i=e.find(s=>Ur(s)===o);if(i)for(const s of $_(i)){if(r.has(s))return null;r.add(s)}}return n[0]}function VO(e){const t=G_.get(e);if(t)return t;const n=e.filter(o=>eh(o)!=null),r=n.length===e.length?e:n;return G_.set(e,r),r}function UO(e){const{selectionIds:t,publicIds:n,selection:r,bodyItems:o,allStoryItems:i}=e;if(t.length===0)return null;const s=u=>{for(const d of t){const f=u.toPublicId(d);if(f)return f}return null},a=hs(r),l=Qn(a)===Qn(null);if(i){const u=l?VO(i):i,d=s(Fl(u,a));if(d)return d;const f=n?.find(p=>u.some(g=>Ti(g,p,a)));return f||(l?s(ta(o)):W_(a)?jO(i,t):null)}return l?s(ta(o))??t[0]??null:null}function $O(e,t){const n=e.find(r=>Ur(r)===t||r.importedId===t);return n?n.rootCommentId??n.parentCommentId??Ur(n)??t:null}function HO(e){const t=e.selectionTarget;if(t){const s=t.start,a=t.end,l=typeof s?.blockId=="string"?s.blockId:void 0,u=typeof a?.blockId=="string"?a.blockId:l;if(l)return{startBlockId:l,endBlockId:u??l}}const n=e.target,r=n&&Array.isArray(n.segments)?n.segments:[],o=r[0]?.blockId,i=r[r.length-1]?.blockId;return typeof o=="string"?{startBlockId:o,endBlockId:typeof i=="string"?i:o}:null}function Kr(e){const t=[],n=s=>{typeof s=="string"&&s.length>0&&!t.includes(s)&&t.push(s)},r=e.target,o=r&&Array.isArray(r.segments)?r.segments:[];for(const s of o)n(s?.blockId);const i=e.selectionTarget;return i&&(n(i.start?.blockId),n(i.end?.blockId)),t}var GO=64;function Pc(e){return e.length<=GO}function hs(e){const t=e.target,n=e.selectionTarget,r=n?.start,o=n?.end,i=t?.story??n?.story??r?.story??o?.story;return i&&typeof i=="object"?i:{kind:"story",storyType:"body"}}function _o(e,t){return{kind:"block",nodeType:"paragraph",nodeId:e,...t&&typeof t=="object"?{story:t}:{}}}function Ga(e){return{kind:"block",nodeType:"paragraph",nodeId:e}}function K_(e,t){return{kind:"block",nodeType:"listItem",nodeId:e,...t&&typeof t=="object"?{story:t}:{}}}var q_=720;function na(e){return Math.round(e*20)}function ad(e){return typeof e=="number"&&Number.isFinite(e)}function WO(e){if(!e||typeof e!="object")return null;const t=e.node;if(!t||typeof t!="object")return null;const n=t.kind==="heading"?t.heading??null:t.kind==="paragraph"?t.paragraph??null:null;if(!n)return null;const r=n.resolved,o=n.props,i=r?.indent??o?.indent;if(!i||typeof i!="object")return null;const s=ad(i.left)?na(i.left):ad(i.start)?na(i.start):void 0,a=ad(i.right)?na(i.right):ad(i.end)?na(i.end):void 0,l=ad(i.firstLine)?na(i.firstLine):void 0,u=ad(i.hanging)?na(i.hanging):void 0;return s==null&&a==null&&l==null&&u==null?null:{...s!=null?{left:s}:{},...a!=null?{right:a}:{},...l!=null?{firstLine:l}:{},...u!=null?{hanging:u}:{}}}function z0(e){const t=e.target,n=t&&Array.isArray(t.segments)?t.segments:[],r=t?.story,o=[];for(const i of n){if(!i||typeof i.blockId!="string")continue;const s=i.range;!s||typeof s.start!="number"||typeof s.end!="number"||s.start===s.end||o.push({kind:"text",blockId:i.blockId,range:{start:s.start,end:s.end},...r?{story:r}:{}})}return o}function KO(e){if(!e||typeof e!="object")return[];const t=e,n=t.story,r=[];if(t.kind==="text"&&t.range&&typeof t.blockId=="string"){const o=t.range;return typeof o.start=="number"&&typeof o.end=="number"&&o.start!==o.end&&r.push({kind:"text",blockId:t.blockId,range:{start:Math.min(o.start,o.end),end:Math.max(o.start,o.end)},...n?{story:n}:{}}),r}if(t.kind==="text"&&Array.isArray(t.segments)){for(const o of t.segments){const i=o?.range;typeof o?.blockId=="string"&&typeof i?.start=="number"&&typeof i?.end=="number"&&i.start!==i.end&&r.push({kind:"text",blockId:o.blockId,range:{start:Math.min(i.start,i.end),end:Math.max(i.start,i.end)},...n?{story:n}:{}})}return r}if(t.kind==="selection"){const o=t.start,i=t.end,s=typeof o?.blockId=="string"&&i?.blockId===o.blockId?o.blockId:null;o?.kind==="text"&&i?.kind==="text"&&s&&typeof o.offset=="number"&&typeof i.offset=="number"&&o.offset!==i.offset&&r.push({kind:"text",blockId:s,range:{start:Math.min(o.offset,i.offset),end:Math.max(o.offset,i.offset)},...t.story??o.story?{story:t.story??o.story}:{}})}return r}function rh(e){if(!e||typeof e!="object")return null;const t=e,n=t.story;if(t.kind==="text"&&t.range&&typeof t.blockId=="string"){const r=t.range;if(typeof r.start=="number"&&typeof r.end=="number"&&r.start===r.end)return{kind:"text",blockId:t.blockId,range:{start:r.start,end:r.end},...n?{story:n}:{}}}if(t.kind==="text"&&Array.isArray(t.segments)){const r=t.segments[0],o=r?.range;if(typeof r?.blockId=="string"&&typeof o?.start=="number"&&typeof o?.end=="number"&&o.start===o.end)return{kind:"text",blockId:r.blockId,range:{start:o.start,end:o.end},...n?{story:n}:{}}}if(t.kind==="selection"){const r=t.start,o=t.end,i=typeof r?.blockId=="string"&&o?.blockId===r.blockId?r.blockId:null;if(r?.kind==="text"&&o?.kind==="text"&&i&&typeof r.offset=="number"&&typeof o.offset=="number"&&r.offset===o.offset)return{kind:"text",blockId:i,range:{start:r.offset,end:r.offset},...t.story??r.story?{story:t.story??r.story}:{}}}return null}function $i(e){return rh(e.target)??rh(e.selectionTarget)}function Y_(e){const t=$i(e)?.story;return t?.storyType==="headerFooterPart"||t?.storyType==="headerFooterSlot"}var X_=["fontFamily","fontSize","color","highlight"],qO={undo:"history.undo",redo:"history.redo"},oh=["bold","italic","underline","strikethrough"];function j0(e){return X_.includes(e)}function ld(e){const t=e.target,n=t&&Array.isArray(t.segments)?t.segments:[],r=[],o=(l,u,d)=>{typeof l!="string"||typeof u!="number"||typeof d!="number"||r.push({blockId:l,start:Math.min(u,d),end:Math.max(u,d)})};for(const l of n){const u=l?.range;o(l?.blockId,u?.start,u?.end)}if(r.length>0)return r;const i=e.selectionTarget,s=i?.start,a=i?.end;return!s||!a||s.blockId!==a.blockId||o(s.blockId,s.offset,a.offset),r}function ps(e){const t=e.target,n=e.selectionTarget,r=n?.start,o=n?.end,i=t?.story??n?.story??r?.story??o?.story;return i&&typeof i=="object"?i:void 0}function YO(e){const t=ps(e);if(!t||typeof t!="object")return"body";const n=t;return JSON.stringify({storyType:typeof n.storyType=="string"?n.storyType:"body",refId:typeof n.refId=="string"?n.refId:null,noteId:typeof n.noteId=="string"?n.noteId:null,textboxId:typeof n.textboxId=="string"?n.textboxId:null})}function Wa(e){const t=ld(e);return t.length===0?null:[YO(e),...t.map(n=>`${n.blockId}:${n.start}-${n.end}`)].join("|")}function Z_(e){const t=e.selectionTarget;return!t||typeof t!="object"?null:Mc({selectionTarget:t})}function XO(e,t){if(e==="fontSize"){const r=typeof t=="number"?t:Number(t);return Number.isFinite(r)&&r>0?String(r):null}if(typeof t!="string")return null;const n=t.trim();return n.length===0?null:e==="color"||e==="highlight"?n.toUpperCase():n}function ZO(e,t){return Math.max(e.start,t.start)<Math.min(e.end,t.end)}function QO(e){if(!e)return[];const t=Array.isArray(e.blocks)?e.blocks:[],n=[];for(const r of t){const o=r?.range,i=r?.blockId;typeof i!="string"||typeof o?.start!="number"||typeof o?.end!="number"||n.push({blockId:i,start:Math.min(o.start,o.end),end:Math.max(o.start,o.end)})}return n}function JO(e,t){return e.length!==t.length?!1:e.every((n,r)=>{const o=t[r];return o?.blockId===n.blockId&&o?.start===n.start&&o?.end===n.end})}function Q_(e,t){const n=ld(t);if(n.length===0)return null;const r=e&&Array.isArray(e.items)?e.items:[];if(r.length===0)return null;const o=r.find(i=>JO(n,QO(i)));if(o)return o;if(n.length===1){const i=r.find(s=>{const a=s?.address;return a?.kind==="block"&&a.nodeId===n[0].blockId});if(i)return i}return r[0]??null}function eF(e,t){const n=t==="fontSize"?e?.fontSizePt??e?.fontSize:t==="highlight"?e?.highlight??e?.backgroundColor:e?.[t];if(typeof n=="number")return Number.isFinite(n)?String(n):void 0;if(typeof n!="string")return;const r=n.trim();if(r.length!==0)return t==="color"||t==="highlight"?r.toUpperCase():r}function V0(e){if(typeof e!="string")return;const t=e.split(",")[0]?.trim().replace(/^['"]+|['"]+$/g,"").trim();if(!t)return;const n=t.toLowerCase();if(!(n==="serif"||n==="sans-serif"||n==="monospace"||n==="cursive"||n==="fantasy"))return t}function tF(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return;const t=Math.round(e*.75*2)/2;if(!(t<=0))return String(t)}function nF(e,t){return e==="fontFamily"?t.toLowerCase():e==="color"||e==="highlight"?t.toUpperCase():t}function J_(e,t){if(!e)return{};const n=new Map;for(const i of ld(t)){const s=n.get(i.blockId)??[];s.push({start:i.start,end:i.end}),n.set(i.blockId,s)}if(n.size===0)return{};const r=Array.isArray(e.blocks)?e.blocks:[],o={};for(const i of X_){const s=new Map;let a=!1,l=!1;for(const u of r){const d=typeof u?.blockId=="string"?u.blockId:null;if(!d)continue;const f=n.get(d);if(!f?.length)continue;const p=Array.isArray(u?.runs)?u.runs:[];for(const g of p){const m=g?.range,v=typeof m?.start=="number"?m.start:null,C=typeof m?.end=="number"?m.end:null;if(v==null||C==null||!f.some(b=>ZO(b,{start:v,end:C})))continue;a=!0;const w=eF(g?.styles,i);if(w===void 0){l=!0;continue}const S=nF(i,w);if(s.has(S)||s.set(S,w),s.size>1)break}if(s.size>1)break}a&&!l&&s.size===1&&(o[i]=[...s.values()][0])}return o}function U0(e,t){const n=Kr(e)[0];return n?t==="nodeId"?{kind:"after",nodeId:n}:{kind:"after",target:_o(n)}:{kind:"documentEnd"}}function rn(e,t){const n=e.supported??t!=="unsupported",r=e.enabled??(e.disabled!==void 0?!e.disabled:n);return{enabled:r,disabled:!r,active:e.active??!1,supported:n,value:e.value,source:t,reason:r?void 0:e.reason}}function cd(e){if(!e||typeof e!="object")return null;const t=e,n=t.change,r=n&&typeof n=="object"?n:t;return{...t,id:t.id??r.id,change:r}}function ud(e){const t=e,n=t.change;return n&&typeof n=="object"?n:t}function ra(e){if(kr(e))return!0;if(e===!1)return!1;if(e===!0||e==null||typeof e!="object")return!0;const t=e;return"success"in t||"failure"in t||"effects"in t?e:t.status!=="rejected"}function jm(e){return!!e&&typeof e=="object"&&e.success===!0}function eA(e){if(e.dryRun===!0)return!1;const t=e.receipt;return!(t&&typeof t=="object"&&t.changed===!1||t&&typeof t=="object"&&t.noop===!0||t&&typeof t=="object"&&t.status==="NO_OP")}function mo(e){return!(e===!1||e&&typeof e=="object"&&e.success===!1)}function ih(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function $0(e){const t=[],n=r=>{if(!r||typeof r!="object")return;const o=r;if(Array.isArray(o.runs)&&t.push(o),Array.isArray(o.rows))for(const i of o.rows){const s=i?.cells;if(Array.isArray(s))for(const a of s){const l=a;if(Array.isArray(l?.blocks))for(const u of l.blocks)n(u);l?.paragraph&&n(l.paragraph)}}};if(Array.isArray(e))for(const r of e)n(r);return t}function Dc(e,t){return e.sourceAnchor?.sourceNodeId===t?!0:e.id===t}function Vm(e){return e.trackedChange?.kind==="delete"?0:typeof e.text=="string"?e.text.length:0}function Ri(e){let t=!1,n=null,r=null,o=null;for(const i of e)t=i,!mo(i)&&n===null&&(n=i),jm(i)&&(o=i),i!==!1&&(r=i);return n??o??r??t}function rF(e){const t=e?.anchor,n=t?.start,r=t?.end;return typeof n?.blockId!="string"||typeof r?.blockId!="string"||n.blockId!==r.blockId||typeof n.offset!="number"||typeof r.offset!="number"?null:{kind:"selection",start:{kind:"text",blockId:n.blockId,offset:n.offset},end:{kind:"text",blockId:r.blockId,offset:r.offset}}}function oF(e){return e.startsWith("#")?{kind:"anchor",anchor:e.slice(1)}:{kind:"external",url:e}}function Um(e){return nd(e)?.trackDecision??null}function iF(e){return{found:e.length>0,success:e.length>0,rects:e,rect:e[0]}}function Nl(e){return{found:!1,success:!1,rects:[],reason:e}}function sF(e,t){if(!t||typeof t.getBoundingClientRect!="function"||e.rects.length===0)return e;let n;try{const o=t.getBoundingClientRect();n={left:o.left,top:o.top}}catch{return e}const r=e.rects.map(o=>({...o,left:o.left-n.left,right:o.right-n.left,top:o.top-n.top,bottom:o.bottom-n.top}));return{...e,rects:r,rect:r[0]}}function aF(e){if(!e||typeof e!="object")return!1;const t=e;if(typeof t.blockId!="string"||!t.range||typeof t.range!="object")return!1;const n=t.range;return Number.isInteger(n.start)&&Number.isInteger(n.end)&&n.start>=0&&n.start<=n.end}function tA(e){if(!e||e.kind!=="text"||!Array.isArray(e.segments)||e.segments.length===0)return null;const t=Array.from(e.segments);if(!t.every(aF))return null;const n=t[0],r=t[t.length-1],o=e.story;return{kind:"selection",start:{kind:"text",blockId:n.blockId,offset:n.range.start,...o?{story:o}:{}},end:{kind:"text",blockId:r.blockId,offset:r.range.end,...o?{story:o}:{}},...o?{story:o}:{}}}function lF(e){return e.selectionTarget?e.selectionTarget:tA(e.target)}function dd(e){if(e.empty)return null;if(e.selectionTarget)return e.selectionTarget;const t=tA(e.target);return t&&t.start.kind==="text"&&t.end.kind==="text"&&t.start.blockId!==t.end.blockId?null:t}function H0(e){return!e.inline||typeof e.docRoute!="string"?null:e.docRoute.startsWith("format.")?e.docRoute.slice(7):null}var G0={bold:null,italic:null,underline:null,strike:null,color:null,highlight:null,fontFamily:null,fontSize:null,vertAlign:null,smallCaps:null,caps:null,letterSpacing:null,dstrike:null},cF=Object.fromEntries(Object.entries(G0).filter(([e])=>kO[e]?.tracked===!0));function uF(e,t,n,r){switch(e.kind){case"toggle":{const o=typeof n=="object"&&n!==null&&"value"in n?n.value:n;return typeof o=="boolean"||o===null?{target:t,value:o}:{target:t,value:!r}}case"value-string":{const o=typeof n=="object"&&n!==null&&"value"in n?n.value:n;return o===null?{target:t,value:null}:typeof o!="string"||o.trim()===""?null:{target:t,value:o}}case"value-number":{const o=typeof n=="object"&&n!==null&&"value"in n?n.value:n,i=typeof o=="number"?o:Number(o);return!Number.isFinite(i)||i<=0?null:{target:t,value:i}}case"clear":return{target:t,inline:{...G0}};default:return null}}function dF(e){const t=o=>{if(!o||typeof o!="object")return null;const i=o,s=i.rowIndex,a=i.columnIndex;return typeof s!="number"||!Number.isInteger(s)||typeof a!="number"||!Number.isInteger(a)?null:{rowIndex:s,columnIndex:a}};if(!e)return null;const n=t(e.start),r=t(e.end);return!n||!r?null:{start:n,end:r}}function fF(e,t){const{tableNodeId:n,rowIndex:r,columnIndex:o,cellNodeId:i,mergeRange:s}=t;switch(e){case"insert-row-before":return{nodeId:n,rowIndex:r,position:"above"};case"insert-row-after":return{nodeId:n,rowIndex:r,position:"below"};case"delete-row":return{nodeId:n,rowIndex:r};case"insert-column-before":return{nodeId:n,columnIndex:o,position:"left"};case"insert-column-after":return{nodeId:n,columnIndex:o,position:"right"};case"delete-column":return{nodeId:n,columnIndex:o};case"delete-table":return{nodeId:n};case"merge-cells":{const a=s??{start:{rowIndex:r,columnIndex:o},end:{rowIndex:r,columnIndex:o}};return{nodeId:n,start:a.start,end:a.end}}case"split-cell":return i?{nodeId:i,rows:1,columns:2}:null;case"remove-borders":return{nodeId:n,mode:"applyTo",applyTo:"all",border:null};default:return null}}function hF(e){const t=e.superdoc,n=new Map,r=new Map;let o=null,i=0;const s=[];let a=null,l=0,u=!1,d=Promise.resolve(),f=null,p={mode:"idle",snapshot:null,sourceSelectionKey:null,lastClickAt:0,pointerSelecting:!1,keyboardSelecting:!1},g=0,m=null;const v=new Set;let C={},w="",S=null;const b=()=>{const c=t?.activeEditor;return c&&typeof c=="object"?c:null},k={open:()=>{if(N)return{ok:!1,reason:tt.notReady};const c=b();if(!c)return{ok:!1,reason:tt.notReady};const h=c.contextMenu;if(!h||typeof h!="object"||typeof h.open!="function")return{ok:!1,reason:tt.operationUnavailable};try{const y=h.open();return y&&typeof y=="object"&&y.ok===!1?{ok:!1,reason:Bm(y.reason,tt.operationUnavailable)}:{ok:!0}}catch{return{ok:!1,reason:tt.operationUnavailable}}},close:()=>{if(N)return;const c=b()?.contextMenu;if(!(!c||typeof c!="object"||typeof c.close!="function"))try{c.close()}catch{}},contextAt:gx};let x;const M=()=>{if(x!==void 0)return x;const c=b()?.doc;return c&&typeof c=="object"?c:null},z=()=>{const c=b()?.v2TrackedChanges;return c&&typeof c=="object"?c:null},G=()=>{const c=b();if(c?.editorVersion!==2)return null;const h=c.reviewWindow;return h&&typeof h=="object"?h:null},F=()=>{const c=G();return!c||typeof c.getSnapshot!="function"?null:Lt(()=>c.getSnapshot(),null)},L=()=>typeof G()?.getSnapshot=="function",$=c=>{const h=c?.status;return h==="ready"||h==="stale"?h:"pending"},T=()=>{const c=b()?.host;return c&&typeof c=="object"?c:null},H=()=>{const c=b(),h=c?.doc;if(c?.editorVersion!==2)return h;const y=T(),_=y?Fm.get(t)?.get(y):null;if(!h||!y||!_)return null;const E=(D,V)=>new Proxy(D,{get(ne,le,xe){const je=Reflect.get(ne,le,xe);if(typeof le!="string")return je;const De=V?`${V}.${le}`:le;return typeof je=="function"&&_.supports(De)?(...Ye)=>b()!==c||T()!==y||c.doc!==h?!1:_.run(De,Ye):je&&(typeof je=="object"||typeof je=="function")?E(je,De):je}});return E(h,"")},R=c=>{if(c.storyType!=="headerFooterPart"||typeof c.refId!="string")return null;const h=b(),y=T(),_=h?.pageLayout??y?.pageLayout;if(!_||typeof _!="object")return null;const E=_.getActiveRulerContext,D=y?.resolveHeaderFooterEditTarget;if(typeof E!="function"||typeof D!="function")return null;const V=Lt(()=>E.call(_),null);if(!V||typeof V.pageIndex!="number")return null;for(const ne of["header","footer"]){const le=Lt(()=>D.call(y,{pageIndex:V.pageIndex,kind:ne}),null);if(!(le?.status!=="ready"||le.refId!==c.refId||typeof le.sectionId!="string"||!["default","first","even"].includes(String(le.slotVariant))))return{kind:"story",storyType:"headerFooterSlot",section:{kind:"section",sectionId:le.sectionId},headerFooterKind:ne,variant:le.slotVariant}}return null},U=()=>{const c=T(),h=c?.getPendingInlineFormat;if(typeof h!="function")return null;const y=Lt(()=>h.call(c),null);return y&&typeof y=="object"?y:null},W=c=>{const h=H0(c);if(!h)return null;const y=U();if(!y||!(h in y))return null;const _=y[h];return c.inline?.kind==="toggle"?_===!0:_!=null&&_!==""},ee=c=>{const h=H0(c);if(!h)return;const y=U();if(!y||!(h in y))return;const _=y[h];if(typeof _=="string"&&_!=="")return _;if(typeof _=="number"&&Number.isFinite(_))return String(_)},J=(c,h)=>{const y=T(),_=y?.setPendingInlineFormat;typeof _=="function"&&Lt(()=>_.call(y,c,h),void 0)},Z=c=>{const h=T(),y=h?.clearPendingInlineFormat;typeof y=="function"&&Lt(()=>y.call(h,c),void 0)},Me=new Set(["bold","italic","underline","strikethrough"]),fe=c=>{const h=U();if(!h)return;const y=Array.isArray(c.activeMarks)?c.activeMarks:[];let _=null;for(const E of Object.keys(h)){const D=h[E];let V;if(Me.has(E)){if(D===!1)continue;V=y.includes(E)===(D===!0)}else if(j0(E)){if(D==null)continue;_||(_=ol(c)),V=_[E]===D}else V=!1;V&&Z(E)}},ye=()=>{const c=b()?.editCommands;return c&&typeof c=="object"?c:null},ve=c=>{const h=ye();if(!h||typeof h.getSnapshot!="function")return null;const y=Lt(()=>h.getSnapshot(),null)?.commands?.[c];return y&&typeof y=="object"?y:null},Pe=()=>ve("lists.apply"),Ve=c=>{const h=c?.value?.seed;return h==="bullet"||h==="ordered"?h:null},nt=c=>{const h=qO[c];return h?ve(h):null},ct=()=>{const c=T();if(!c||typeof c.getTableContext!="function")return null;const h=Lt(()=>c.getTableContext(),null);return h&&typeof h=="object"?h:null},ft=()=>{const c=ct();if(!c||c.inTable!==!0)return null;const h=c.table,y=typeof h?.nodeId=="string"&&h.nodeId.length>0?h.nodeId:null;if(!y)return null;const _=c.row,E=c.column,D=c.cell,V=typeof _?.index=="number"&&Number.isInteger(_.index)?_.index:null,ne=typeof E?.index=="number"&&Number.isInteger(E.index)?E.index:null;if(V==null||ne==null)return null;const le=typeof D?.nodeId=="string"&&D.nodeId.length>0?D.nodeId:null,xe=c.cellRange;return{tableNodeId:y,rowIndex:V,columnIndex:ne,cellNodeId:le,mergeRange:dF(xe)}},It=new Map;let Le=null,oe=null,we=0,Q=0,I=0;const re=new Set,j=(c,h)=>c===h?!0:!c||!h?!1:c.id===h.id&&c.paintedEntityId===h.paintedEntityId&&Qn(c.story)===Qn(h.story),X=c=>Array.from(re).some(h=>j(h,c)),K=c=>{const h=T();if(typeof h?.getHandles!="function")return;const y=Lt(()=>h.getHandles(),null),_=y?.review;if(_){if(c){if(typeof _.setActiveReviewTarget!="function")return;const E=y?.layout;Lt(()=>_.setActiveReviewTarget({entityType:"trackedChange",entityId:c.id,...c.paintedEntityId?{paintedEntityId:c.paintedEntityId}:{},origin:"panel",layoutEpoch:typeof E?.generation=="number"?E.generation:0,story:c.story??{kind:"story",storyType:"body"}}),null);return}typeof _.getActiveReviewTarget!="function"||typeof _.clearActiveReviewTarget!="function"||Lt(()=>_.getActiveReviewTarget(),null)?.entityType==="trackedChange"&&Lt(()=>_.clearActiveReviewTarget(),void 0)}},ae=(c,h)=>{oe=c,we+=1,I+=1,h?.invalidateQueuedNavigation!==!1&&(Q+=1)},ke=new Set;let P,N=!1,me=null;const Se=new Map,Re=new Set;let ze=null,Ke=null,ot=!1,mt=null,Ot=0,Mt=null,Kt=null,$e=!1,Qt=null;const Hn=[],qt=()=>{if(ot||N)return;ot=!0;const c=()=>{ot=!1,N||$t("async-read-settled")};typeof queueMicrotask=="function"?queueMicrotask(c):Promise.resolve().then(c)},jn=250,Pn=5e3,$r=c=>{N||mt&&Ot<=c||(mt&&clearTimeout(mt),Ot=c,mt=setTimeout(()=>{mt=null,Ot=0,N||$t()},Math.max(0,c-Date.now())))},Nr=new WeakMap;let _r=0;const Tn=c=>{if(!c)return"none";let h=Nr.get(c);return h==null&&(h=_r+=1,Nr.set(c,h)),`e${h}`};let tr=0;const qn=e.superdoc,Bn=AO(qn),st=()=>{Bn.abortController.abort("review-mutation-started"),Bn.inFlight=null},_t=()=>{Bn.generation+=1,Bn.abortController=new AbortController,Bn.inFlight=null},gt=c=>{const h=Bn.activeMutationTokens;if(typeof c!="string"||c.length===0||h.has(c))return;const y=h.size===0;h.add(c),y&&st()},Xt=c=>{const h=Bn.activeMutationTokens;typeof c!="string"||!h.delete(c)||h.size===0&&_t()},gn=c=>{const h=z(),y=h?.listTrackedChanges;if(typeof y!="function")return b()?.editorVersion===2?Promise.reject(new Error("v2-tracked-changes-bridge-pending")):c();if(Bn.activeMutationTokens.size>0)return Promise.reject(new Error("ui-review-catalog-superseded"));const _=Bn.generation,E=Bn.inFlight;if(E?.generation===_)return E.promise;const D=Bn.abortController.signal,V=xe=>{if(D.aborted||_!==Bn.generation||xe?.reason==="review-hydration-superseded")throw new Error("ui-review-catalog-superseded");return xe},ne=y.call(h,{blocking:!1,signal:D});if(!kr(ne))return V(ne);const le=Promise.resolve(ne).then(V);return Bn.inFlight={generation:_,promise:le},le.then(()=>{Bn.inFlight?.promise===le&&(Bn.inFlight=null)},()=>{Bn.inFlight?.promise===le&&(Bn.inFlight=null)}),le};let Te=null,Ne=new Set,Qe=null,bt=0,Nt=null;const Dt=new WeakSet,kn=new WeakMap,Ht=c=>{if(kn.has(c))return;const h=typeof c.getLocalMutationRevision=="function"?Lt(()=>c.getLocalMutationRevision(),null):null,y=typeof h=="number"?h:0;kn.set(c,y),y>0?Dt.add(c):h===0&&Dt.delete(c)},In=()=>{const c=T();return c?(Ht(c),Dt.has(c)):!1},sn=()=>`${Tn(b())}|m${tr}`,Ao=()=>{Te=null,Ne=new Set},qi=c=>{for(const h of["trackChanges","trackChanges:all"]){const y=Se.get(h);if(!y?.hasSettled||!Array.isArray(y.value))continue;const _=y.value.filter(E=>{const D=Ur(E);return!D||!c.has(D)});_.length!==y.value.length&&Se.set(h,{...y,value:_})}},dn=c=>{const h=()=>{if(!N)for(const D of[...ke])D(P)},y=ih(c)?c:null,_=b()?.documentMutationReadiness,E=()=>{const D=globalThis.requestAnimationFrame;return typeof D!="function"?Promise.resolve():new Promise(V=>{let ne=!1;const le=()=>{ne||(ne=!0,clearTimeout(xe),V())},xe=setTimeout(le,250);D(()=>D(()=>setTimeout(le,0)))})};if(y?.success===!0&&typeof y.txId=="string"&&y.txId.length>0&&typeof _?.whenPainted=="function")try{Promise.resolve(_.whenPainted.call(_,y)).then(E,()=>{}).then(h,h);return}catch{}h()},sr=(c,h)=>{const y=P.trackChanges,_=y.items.filter(V=>{const ne=Ur(V);return!ne||!c.has(ne)});if(_.length===y.items.length)return;oe&&c.has(oe.id)&&ae(null);const E=new Set;for(const V of _){const ne=ud(V),le=V,xe=ne.author??ne.authorEmail??le.author??le.authorEmail;typeof xe=="string"&&E.add(xe)}const D=y.items.length-_.length;P={...P,trackChanges:{...y,items:_,total:Math.max(_.length,y.total-D),activeId:y.activeId&&c.has(y.activeId)?null:y.activeId,authors:[...E]}},dn(h)},ar=c=>{const h=P.trackChanges,y=h.items.length>0||h.total!==0||h.activeId!==null||h.authors.length>0;Qe=sn(),oe!==null&&ae(null),P={...P,trackChanges:{...h,items:[],total:0,activeId:null,authors:[]}},y&&dn(c)},No=(c,h)=>{if(c.size===0)return;const y=sn(),_=Te===y?Ne:new Set,E=new Set([...c].filter(D=>!_.has(D)));E.size!==0&&(Te=y,Ne=new Set([..._,...E]),qi(Ne),sr(E,h))},ln=c=>Te===c&&Ne.size>0?Ne:null,Mn=c=>{const h=sn(),y=ln(h),_=c.map(cd).filter(E=>{if(E==null)return!1;const D=Ur(E);return D!=null&&!y?.has(D)});for(const E of["trackChanges","trackChanges:all"])Se.set(E,{token:h,value:[..._],hasSettled:!0,inflightToken:null})},Jn=()=>`${sn()}|m${Xn()}|s${bt}`,Yr=c=>JSON.stringify({t:c.target??null,s:c.selectionTarget??null}),Yi=["contentControls:inRange:","query:","effInline:"],$c=120,sa=180,Za=()=>{const c=T(),h=c?.getDocumentLoadingSnapshot;if(typeof h!="function")return"unknown";const y=Lt(()=>h.call(c),null)?.sourceStage;return y==="opening"||y==="bootstrap-ready"||y==="source-loading"?"loading":y==="source-complete"||y==="source-failed"||y==="source-cancelled"?"complete":"unknown"},Bo=new Map,Io=new Map,Xi=new Map;let Zo=null;const Xr={comments:0,trackChanges:0,contentControls:0},Ie=c=>{const h=sn();Bo.get(c)!==h&&(Bo.set(c,h),qt())},Ue=()=>{const c=Se.get("comments");return c?.hasSettled?Array.isArray(c.value)&&c.value.length>0:c?.inflightToken!=null},vt=(c,h)=>Bo.get(c)===h,dt=()=>{const c=sn();let h=!1;for(const[y,_]of Io){if(_!==c){Io.delete(y);continue}if(Xi.get(y)===c)continue;const E=Se.get(y);!E?.hasSettled||E.token!==c||E.inflightToken!=null||(Se.set(y,{...E,token:null,inflightToken:null}),Xi.set(y,c),h=!0)}h&&qt()},Vn=c=>{Xr[c]+=1,Ie(c);let h=!1;return()=>{h||(h=!0,Xr[c]=Math.max(0,Xr[c]-1),Xr[c]===0&&Bo.get(c)===sn()&&Bo.delete(c),qt())}},Dn=c=>{Ie("contentControls")},eo=()=>{const c=Se.get("trackChanges");c?.hasSettled||c?.inflightToken!=null||Ie("trackChanges")},to=()=>{const c=Se.get("comments");c?.hasSettled||c?.inflightToken!=null||Ie("comments")},go=6500,Qo=250;let li=0,zo=0,Ir=!1,Jo=null;const Cs=()=>{if(N||Jo)return;const c=()=>{if(Jo=null,N)return;const h=Date.now()-li;if(Vo()||h<go){Jo=setTimeout(c,Qo);return}Ir=!1,$t()};Jo=setTimeout(c,0)};let jo=null,lr=null;const no=()=>{const c=T();if(!c||jo===c)return;lr&&(lr(),lr=null),jo=c;const h=c.subscribeDocumentLoading;if(typeof h!="function"){jo=null,Uo(go);return}try{const y=D=>{const V=D?.sourceStage;(V==="source-complete"||V==="source-failed"||V==="source-cancelled")&&(Zo=sn(),dt(),li=Math.max(li,Date.now()),Cs())},_=h.call(c,y);typeof _=="function"&&(lr=_);const E=c.getDocumentLoadingSnapshot;typeof E=="function"&&y(Lt(()=>E.call(c),null))}catch{jo=null,Uo(go)}},ci=()=>{const c=b()?.host,h=c?.getForegroundMutationState;if(typeof h!="function")return null;const y=Lt(()=>h.call(c),null);return{active:typeof y?.active=="number"?y.active:0,pending:typeof y?.pending=="number"?y.pending:0}},Vo=()=>{const c=ci();return!!(c&&(c.active>0||c.pending>0))},Uo=(c=$c)=>{N||Mt||(Mt=setTimeout(()=>{if(Mt=null,N)return;if(Vo()){Uo();return}if($e&&Date.now()-zo<go){const y=Jn();Se.get("selection")?.token!==y&&(tl(void 0,!0),Se.get("selection")?.token===y&&$t()),Uo(Qo);return}$e=!1;const h=Kt;Kt=null,h===Jn()&&Zl("selection",h,nc,Qi),$t()},c))},Qa=(c,h)=>{if(!ci())return!1;const y=`${c}\0${h}`;return Re.has(y)?!1:(Re.add(y),Uo(sa),!0)},xh=c=>{if(ze==null||c===ze)return Ke?.timer&&clearTimeout(Ke.timer),Ke=null,ze=c,!1;if(Ke?.key===c)return Ke.ready?(Ke=null,ze=c,!1):!0;Ke?.timer&&clearTimeout(Ke.timer);const h={key:c,ready:!1,timer:null};return h.timer=setTimeout(()=>{N||Ke!==h||(h.timer=null,h.ready=!0,$t())},sa),Ke=h,!0},ql=c=>q9(c),ks=()=>{Zi(),$t()};let ui=null,Ss=null,_s=!1,Yl=0,Ja=!1,di=0;const fi=()=>{ui=null,_s=!1,Yl+=1},Hc=()=>{Ss=null,Ja=!1,di+=1},Xl=()=>{const c=b(),h=c?.documentMutationReadiness;if(!c||typeof h?.whenPainted!="function"||(ui={editor:c,readiness:h,afterEpoch:typeof h.getRenderEpoch=="function"?Lt(()=>h.getRenderEpoch.call(h),null):null},_s))return;_s=!0;const y=Yl;(async()=>{for(;!N&&y===Yl;){const E=ui;if(ui=null,!E){_s=!1;return}let D=!1;try{await E.readiness.whenPainted.call(E.readiness,typeof E.afterEpoch=="number"?{afterEpoch:E.afterEpoch}:void 0),D=!0}catch{}if(N||y!==Yl)return;if(b()!==E.editor){fi();return}D&&ks()}})()},Th=()=>{const c=b(),h=c?.documentMutationReadiness;if(!c||typeof h?.whenPainted!="function")return!1;if(Ss={editor:c,readiness:h,afterEpoch:typeof h.getRenderEpoch=="function"?Lt(()=>h.getRenderEpoch.call(h),null):null},Ja)return!0;Ja=!0;const y=di;return(async()=>{for(;!N&&y===di;){const E=Ss;if(Ss=null,!E){Ja=!1;return}let D=!1;try{await E.readiness.whenPainted.call(E.readiness,typeof E.afterEpoch=="number"?{afterEpoch:E.afterEpoch}:void 0),D=!0}catch{}if(N||y!==di)return;if(b()!==E.editor){Hc();return}Ss||(bt+=1,tl(void 0,!0),$t(D?"post-paint-selection":"post-paint-selection-failed"))}})(),!0},As=()=>{Qt&&clearTimeout(Qt),Qt=setTimeout(()=>{Qt=null,N||(Zi(),$e&&!Vo()&&tl(void 0,!0),$t())},500)},Zl=(c,h,y,_)=>{let E;try{E=y()}catch{E=void 0}if(!kr(E)){const ne={token:h,value:_(E),hasSettled:!0,inflightToken:null,failedToken:null,failureCount:0,retryAtMs:0};return Se.set(c,ne),ne}const D=Se.get(c),V=D?.failedToken===h;return Se.set(c,{token:D?.token??null,value:D?.value??null,hasSettled:D?.hasSettled??!1,inflightToken:h,failedToken:V?h:null,failureCount:V?D.failureCount??0:0,retryAtMs:0}),Promise.resolve(E).then(ne=>{const le=Se.get(c);if(!le||le.inflightToken!==h)return;Se.set(c,{token:h,value:_(ne),hasSettled:!0,inflightToken:null,failedToken:null,failureCount:0,retryAtMs:0});const{sink:xe,workerContext:je}=Nm();if(xe){const De=Ha();Hn.push({key:c,settledAtMs:De,commandId:je?.commandId??null,commandKind:je?.commandKind??null}),O0({stage:"superdoc-ui-async-read-settled",atMs:De,key:c,settledAtMs:De,commandId:je?.commandId??null,commandKind:je?.commandKind??null})}qt()},()=>{const ne=Se.get(c);if(!ne||ne.inflightToken!==h)return;const le=ne.failedToken===h?(ne.failureCount??0)+1:1,xe=Math.min(Pn,jn*2**Math.min(le-1,8)),je=Date.now()+xe;Se.set(c,{...ne,inflightToken:null,failedToken:h,failureCount:le,retryAtMs:je}),$r(je)}),null},Eo=(c,h,y,_)=>{const E=Se.get(c);if(E&&E.token===h&&E.hasSettled)return{value:E.value,status:"ready"};if(c==="selection"&&$e&&Date.now()-zo<go)return Uo(Qo),{value:E?.hasSettled?E.value:null,status:E?.hasSettled?"stale":"pending"};if(OO(c)&&!vt(c,h)){if(Za()==="loading")return Ir=!0,no(),E?.hasSettled?{value:E.value,status:"stale"}:{value:null,status:"pending"};if(Ir)return Cs(),E?.hasSettled?{value:E.value,status:"stale"}:{value:null,status:"pending"};if(Date.now()-zo<go)return Ir=!0,Cs(),E?.hasSettled?{value:E.value,status:"stale"}:{value:null,status:"pending"}}if(Vo())return Uo(),E?.hasSettled?{value:E.value,status:"stale"}:{value:null,status:"pending"};if(E?.failedToken===h&&E.inflightToken==null&&(E.retryAtMs??0)>Date.now())return $r(E.retryAtMs),E.hasSettled?{value:E.value,status:"stale"}:{value:null,status:"pending"};if(!E&&c.startsWith("effInline:")&&xh(c))return{value:null,status:"pending"};if(!E&&Qa(c,h))return{value:null,status:"pending"};if(!E||E.inflightToken!==h){const V=Zl(c,h,y,_);if(V)return{value:V.value,status:"ready"}}const D=Se.get(c);return D?.hasSettled?{value:D.value,status:"stale"}:{value:null,status:"pending"}},bd=c=>{for(const h of Se.keys())c(h)&&Se.delete(h)},Ql=c=>{const h=Yr(c),y=Z_(c);return new Set([`contentControls:inRange:${h}`,`query:${h}`,...y?[`effInline:${y}`]:[]])},Gc=c=>{const h=Ql(c);bd(y=>Yi.some(_=>y.startsWith(_))&&!h.has(y));for(const y of Re){const _=y.split("\0",1)[0];Yi.some(E=>_.startsWith(E))&&!h.has(_)&&Re.delete(y)}},Is=()=>{const c=b();c!==Nt&&(fi(),Hc(),Nt=c,Se.clear(),mt&&clearTimeout(mt),mt=null,Ot=0,Ke?.timer&&clearTimeout(Ke.timer),Ke=null,ze=null,S=null,o=null,Kt=null,$e=!1,Re.clear(),Bo.clear(),Io.clear(),Xi.clear(),Zo=null,Ir=!1,lr&&lr(),lr=null,jo=null,Ao(),Qe=null)},Zi=()=>{tr+=1,Io.clear(),Xi.clear(),Zo=null,Ao()},hi=()=>{const c=Qe===sn();Zi(),c&&(Mn([]),Qe=sn()),$t()},Wc=c=>{if(typeof c!="string"||c.length===0)return er("insertText requires a non-empty string.","INVALID_INPUT");if(Xn()==="viewing")return er("The document is read-only.","DOCUMENT_READONLY");const h=M(),y=h?.insert;if(!h||typeof y!="function")return er("insert is unavailable.");const _=h.selection?.current;if(typeof _!="function")return er("selection.current is unavailable.");const E=V=>{const ne=V&&typeof V=="object"?V:null,le=ne?.selectionTarget??ne?.target??null;return!le||typeof le!="object"?er("insertText requires a live selection target.","PRECONDITION_FAILED"):Lt(()=>dc(y.call(h,{type:"text",value:c,target:le}),er("insert failed.")),er("insert failed."))};let D;try{D=_.call(h.selection)}catch{return er("insertText could not resolve the live selection.","PRECONDITION_FAILED")}return kr(D)?Promise.resolve(D).then(E,()=>er("insertText could not resolve the live selection.","PRECONDITION_FAILED")):E(D)},Kc=(c,h)=>({payload:c,state:P,editor:b(),superdoc:t,context:h,ui:me,execute:(y,_)=>Gh(y,_),executeAsync:(y,_)=>zg(y,_),doc:M(),selection:P.selection,documentMode:Xn(),insertText:Wc}),Jl=c=>c==="editing"||c==="suggesting"||c==="viewing"?c:null,Xn=()=>{const c=b(),h=t&&typeof t=="object"?t:null,y=Jl(h?.config?.documentMode),_=Lt(typeof h?.getActiveRuntime=="function"?()=>{const V=h.getActiveRuntime();return typeof V?.getSnapshot=="function"?V.getSnapshot():null}:void 0,null),E=Jl(_?.documentMode),D=Jl(c?.options?.documentMode);return y&&E&&y!==E?y:E??y??D},ec=()=>{const c=t&&typeof t=="object"?t:null,h=c?.interactionConfig?.comments;if(h&&typeof h.readOnly=="boolean")return h.readOnly===!0;const y=c?.config?.modules?.comments;return!!y&&typeof y=="object"&&y.readOnly===!0},wd=()=>{if(Xn()==="viewing")return tt.documentReadonly;const c=(t&&typeof t=="object"?t:null)?.interactionConfig?.trackedChanges;return c&&typeof c.allowDecisions=="boolean"?c.allowDecisions?void 0:tt.trackedChangeDecisionsDisabled:ec()?tt.documentReadonly:void 0},qc=()=>{const c=t&&typeof t=="object"?t:null,h=c?.interactionConfig?.comments;if(h&&typeof h.allowResolve=="boolean")return h.allowResolve===!1;const y=c?.config?.modules?.comments;return!!y&&typeof y=="object"&&y.allowResolve===!1},tc=()=>ec(),aa=()=>wd()!=null,Qi=c=>c&&typeof c=="object"?c:null,la=(c,h)=>{if(!c)return{...LO,status:h};const y=c.target??null,_=typeof c.text=="string"?c.text:"";return{status:h,empty:c.empty===!0,target:y,selectionTarget:c.selectionTarget??null,activeMarks:Array.isArray(c.activeMarks)?c.activeMarks:[],activeCommentIds:Array.isArray(c.activeCommentIds)?c.activeCommentIds:[],activeChangeIds:Array.isArray(c.activeChangeIds)?c.activeChangeIds:[],quotedText:_}},el=()=>{const c=M()?.selection;return Eo("selection",Jn(),()=>c?.current?c.current({includeText:!0}):void 0,Qi)},Er=()=>{const{value:c,status:h}=el();return la(c,h)},nc=()=>{const c=M()?.selection;return c?.current?c.current({includeText:!0}):void 0},ca=c=>{if(c.empty!==!0)return!1;const h=c.selectionTarget,y=h?.start,_=h?.end;return y?.kind==="text"&&_?.kind==="text"&&typeof y.blockId=="string"&&y.blockId===_.blockId&&typeof y.offset=="number"&&y.offset===_.offset},tl=(c,h=!1)=>{const y=ci();if(zO(c)&&!(y&&y.active>0)){$e=!1,Kt=null,Zl("selection",Jn(),nc,Qi);return}const _=T(),E=_?.readLiveSelectionSyncSnapshot;if(typeof E!="function")return;const D=Qi(Lt(()=>E.call(_),null));if(!D||!ca(D))return;const V=$i(P.selection),ne=rh(D.selectionTarget)??rh(D.target),le=V?.range,xe=ne?.range,je=!!(V&&ne&&V.blockId===ne.blockId&&Qn(V.story)===Qn(ne.story)&&le?.start===xe?.start);$e=!!(y&&y.active>0)||$e&&(h||je);const De=Jn(),Ye=!!(y&&(y.active>0||y.pending>0))||$e&&Date.now()-zo<go;if(Ye)Kt=De,Uo();else if(Kt=null,Zl("selection",De,nc,Qi))return;const Ze=Se.get("selection"),Xe=Array.isArray(D.activeMarks)&&D.activeMarks.length>0?D.activeMarks:Array.isArray(P.selection.activeMarks)?P.selection.activeMarks:[],Ge=Array.isArray(D.activeCommentIds)?D.activeCommentIds:[],rt=BO(c),lt=!!(y&&y.active>0&&V&&ne&&V.blockId===ne.blockId&&Qn(V.story)===Qn(ne.story)&&typeof le?.start=="number"&&typeof xe?.start=="number"&&Math.abs(xe.start-le.start)<=2),We=rt!=null||lt?P.selection.activeChangeIds.filter(Rt=>rt==null||ta(P.trackChanges.items).aliasesFor(Rt).includes(rt)):[],wt=Array.isArray(D.activeChangeIds)&&D.activeChangeIds.length>0?D.activeChangeIds:We;Se.set("selection",{token:De,value:{...D,activeMarks:Xe,activeCommentIds:Ge,activeChangeIds:wt},hasSettled:!0,inflightToken:Ye?null:Ze?.inflightToken??null})},Yc=async(c=0)=>{const h=M()?.selection,y=h?.current,_=Jn();if(typeof y!="function")return Se.set("selection",{token:_,value:null,hasSettled:!0,inflightToken:null}),$t(),P.selection;let E;try{E=y.call(h,{includeText:!0}),kr(E)&&(E=await Promise.resolve(E))}catch{E=null}return N?la(null,"pending"):Jn()!==_?c<1?Yc(c+1):P.selection:(Se.set("selection",{token:_,value:Qi(E),hasSettled:!0,inflightToken:null}),$t(),P.selection)},Xc=()=>{const c=M()?.comments;return Eo("comments",sn(),()=>c?.list?c.list():void 0,h=>h&&Array.isArray(h.items)?h.items:[])},ua=(c="trackChanges")=>{const h=sn(),y=M()?.trackChanges,_=z(),E=typeof _?.listTrackedChanges=="function"?_.listTrackedChanges:null,D=Eo(c,h,()=>E?gn(()=>y?.list?.({in:"all"})):y?.list?y.list({in:"all"}):void 0,V=>{const ne=V&&typeof V=="object"?V:null;if(ne?.complete===!1||ne?.sourceCoverageComplete===!1){if(Io.set(c,h),no(),Zo===h||Za()==="complete"){const le=()=>{N||dt()};typeof queueMicrotask=="function"?queueMicrotask(le):Promise.resolve().then(le)}}else Io.get(c)===h&&Io.delete(c);return ne&&Array.isArray(ne.items)?ne.items:[]});return Io.get(c)===h&&D.status==="ready"?{...D,status:"stale"}:D},Rh=c=>{const h=F(),y=L(),_=y?null:Xc(),E=y&&Array.isArray(h?.commentItems)?h.commentItems:null,D=y?E:_.value,V=y?$(h):_.status,ne=D??[],le=c.activeCommentIds,xe=Se.get("comments"),je=xe?.token===sn()&&xe.hasSettled&&Array.isArray(xe.value)?xe.value:null,De=Xr.comments>0?je:ne;Le&&De&&!De.some(Ze=>Ur(Ze)===Le)&&(Le=null);const Ye=Le??le[0]??null;return{status:Ol(V,c.status),listStatus:V,items:ne,total:ne.length,activeIds:le,activeId:Ye}},Zc=new WeakMap,Ji=c=>{const h=Zc.get(c);if(h)return h;const y=c.map(cd).filter(_=>_!=null);return Zc.set(c,y),y},Qc=new WeakMap,pi=(c,h)=>{const y=Qc.get(c);if(y?.suppressedIds===h)return y.value;const _=h?c.filter(E=>{const D=Ur(E);return!D||!h.has(D)}):c;return Qc.set(c,{suppressedIds:h,value:_}),_},rc=new WeakMap,Jc=c=>{const h=rc.get(c);if(h)return h;const y=new Set;for(const E of c){const D=ud(E),V=E,ne=D.author??D.authorEmail??V.author??V.authorEmail;typeof ne=="string"&&y.add(ne)}const _=[...y];return rc.set(c,_),_},mi=()=>{const c=sn();if(L()){const _=Se.get("trackChanges"),E=_?.token===c&&_.hasSettled&&Array.isArray(_.value)?_.value:F()?.trackedChangeItems;return Array.isArray(E)?Ji(E):null}const{value:h,status:y}=ua("trackChanges:all");return y==="ready"?Ji(h??[]):null},Mh=c=>{const h=sn(),y=ln(h),_=F(),E=L(),D=E?null:ua(),V=E&&Array.isArray(_?.trackedChangeItems)?_.trackedChangeItems:null,ne=E?V:D.value,le=E?$(_):D.status,xe=pi(Ji(ne??[]),y),je=mi(),De=oe;if(De&&!re.has(De)){const Rt=Se.get("trackChanges"),an=Rt?.token===h&&Rt.hasSettled&&Array.isArray(Rt.value)?pi(Ji(Rt.value),y):null,un=Xr.trackChanges>0?an:De.story?je:xe;un&&!un.some(En=>Ti(En,De.id,De.story))&&ae(null)}const Ye=je??xe,Ze=Fl(Ye,hs(c)),Xe=Qe===h?[]:y?c.activeChangeIds.filter(Rt=>!y.has(Rt)):c.activeChangeIds,Ge=Xe.map(Rt=>Ze.toPublicId(Rt)??Rt),rt=oe?.story?Fl(Ye,oe.story):ta(Ye),lt=oe?rt.toPublicId(oe.id)??oe.id:null,We=UO({selectionIds:Xe,publicIds:Ge,selection:c,bodyItems:xe,allStoryItems:je}),wt=lt??We;return{status:Ol(le,c.status),items:xe,total:xe.length,activeId:wt,authors:Jc(xe)}},Cd=(c,h)=>{if(!L())return h;Ie("comments");const y=Xc(),_=y.value??h.items;return{status:Ol(y.status,c.status),listStatus:y.status,items:_,total:_.length,activeIds:c.activeCommentIds,activeId:Le??c.activeCommentIds[0]??null}},eu=(c,h)=>{if(!L())return h;Ie("trackChanges");const y=ua(),_=ln(sn()),E=pi(Ji(y.value??h.items),_),D=oe?.story?Fl(E,oe.story):ta(E),V=oe?D.toPublicId(oe.id)??oe.id:h.activeId;return{status:Ol(y.status,c.status),items:E,total:E.length,activeId:V,authors:Jc(E)}};let kd=null,Sd=[];const oc=(c,h)=>{const y=sn();return h==="ready"?(kd=y,Sd=c,{items:c,status:h}):h==="pending"&&kd===y?{items:Sd,status:"stale"}:{items:c,status:h}},Lh=c=>{const h=M()?.contentControls,{value:y,status:_}=Eo("contentControls",sn(),()=>h?.list?h.list():void 0,De=>De&&Array.isArray(De.items)?De.items:[]),E=y??[],{items:D,status:V}=_d(h,c),ne=new Map(D.map(De=>[De.id,De])),le=new Set(E.map(De=>De.id)),xe=[...E.map(De=>ne.get(De.id)??De),...D.filter(De=>!le.has(De.id))],je=D.map(De=>De.id);return{status:Ol(_,V,c.status),items:xe,total:xe.length,activeId:je[0]??null,activeIds:je}},da=(c,h)=>{if(!c||typeof c.listInRange!="function")return{lockModesById:new Map,rows:[],status:"ready"};const y=HO(h);if(!y)return{lockModesById:new Map,rows:[],status:"ready"};const{value:_,status:E}=Eo(`contentControls:inRange:${Yr(h)}`,sn(),()=>c.listInRange(y),ne=>ne&&Array.isArray(ne.items)?ne.items:[]),D=_??[],V=new Map;for(const ne of D)typeof ne?.id=="string"&&V.set(ne.id,typeof ne.lockMode=="string"?ne.lockMode:"unlocked");return{lockModesById:V,rows:D,status:E}},_d=(c,h)=>{const{rows:y,status:_}=da(c,h),E=h.selectionTarget,D=h.target;let V=E?.start;if(E){if(E.kind!=="selection"||V?.kind!=="text"||typeof V.blockId!="string"||typeof V.offset!="number")return oc([],_)}else{const Ge=D?.kind==="text"&&Array.isArray(D.segments)?D.segments[0]:void 0,rt=Ge?.range;if(typeof Ge?.blockId!="string"||typeof rt?.start!="number")return oc([],_);V={kind:"text",blockId:Ge.blockId,offset:rt.start,story:D?.story}}const ne=(D?.coordinateSpace!=="tracked"&&Array.isArray(D?.segments)?D.segments:[]).find(Ge=>Ge.blockId===V.blockId),le=ne?.range,xe=ne&&typeof ne.blockId=="string"&&typeof le?.start=="number"?{kind:"text",blockId:ne.blockId,offset:le.start,story:D?.story??V.story}:null,je=(E?E.coordinateSpace:D?.coordinateSpace)==="tracked"?"tracked":"visible",De=je==="tracked"?xe:V,Ye=Kr(h),Ze=Ye.indexOf((De??V).blockId),Xe=y.map((Ge,rt)=>({item:Ge,index:rt})).filter(({item:Ge})=>{const rt=Ge.selectionTarget,lt=rt?.coordinateSpace==="tracked"?"tracked":"visible";if(lt==="tracked"&&je!=="tracked")return!1;const We=lt==="tracked"?V:De;if(!We)return!1;const wt=rt?.start,Rt=rt?.end;if(rt?.kind!=="selection"||wt?.kind!=="text"||Rt?.kind!=="text"||typeof wt.blockId!="string"||typeof Rt.blockId!="string"||typeof wt.offset!="number"||typeof Rt.offset!="number"||Qn(rt.story??wt.story??Rt.story)!==Qn(E?.story??We.story))return!1;if(wt.blockId===Rt.blockId){if(We.blockId!==wt.blockId)return!1;const En=Math.min(wt.offset,Rt.offset),io=Math.max(wt.offset,Rt.offset);return En===io?We.offset===En:We.offset>=En&&We.offset<io}if(We.blockId===wt.blockId)return We.offset>=wt.offset;if(We.blockId===Rt.blockId)return We.offset<Rt.offset;if(Ze===-1)return!1;const an=Ye.indexOf(wt.blockId),un=Ye.indexOf(Rt.blockId);return an!==-1&&un!==-1?Ze>Math.min(an,un)&&Ze<Math.max(an,un):an!==-1?Ze>an:un!==-1?Ze<un:!0}).sort((Ge,rt)=>{const lt=Ge.item.selectionTarget,We=rt.item.selectionTarget,wt=lt.start.kind==="text"&<.end.kind==="text"&<.start.blockId===lt.end.blockId,Rt=We.start.kind==="text"&&We.end.kind==="text"&&We.start.blockId===We.end.blockId;if(wt!==Rt)return wt?-1:1;if(Ge.item.kind!==rt.item.kind)return Ge.item.kind==="inline"?-1:1;if(wt&&Rt&<.start.kind==="text"&<.end.kind==="text"&&We.start.kind==="text"&&We.end.kind==="text"){const an=Math.abs(lt.end.offset-lt.start.offset),un=Math.abs(We.end.offset-We.start.offset);if(an!==un)return an-un}return rt.index-Ge.index}).map(({item:Ge})=>Ge);return oc(Xe,_)},Ad=()=>{const c=t?.fonts;return{options:yF(gF(Lt(c?.getDocumentFontOptions?()=>c.getDocumentFontOptions():void 0,[])),vF(Lt(c?.getFontFamilyOptions?()=>c.getFontFamilyOptions():void 0,[]))),sizeOptions:bF}},Id=()=>{const c=Lt(t?.getZoomState?()=>t.getZoomState():void 0,null),h=typeof c?.value=="number"?c.value:100,y=c?.mode;return{mode:y==="manual"||y==="fit-width"?y:y==="fixed"?"manual":null,value:h,min:typeof c?.min=="number"?c.min:10,max:typeof c?.max=="number"?c.max:100}},Ph=()=>Lt(t?.getMeasurementUnit?()=>t.getMeasurementUnit():void 0,"in")==="cm"?"cm":"in",ei=()=>{const c=b(),h=c?c.isDirty:void 0;return{ready:c!=null,mode:Xn(),dirty:c?h===void 0?In():!!h:!1}},nl=c=>{const h=c.quotedText;if(typeof h!="string"||h.length===0)return null;const y=ld(c);if(y.length===0||!Pc(y.map(D=>D.blockId)))return null;const _=c.target,E=y.length===1?_o(y[0].blockId,_?.story):void 0;return{select:{type:"text",pattern:h,mode:"contains",caseSensitive:!0},...E?{within:E}:{},require:"any"}},tu=c=>{const h=M()?.query;if(typeof h?.match!="function")return null;const y=nl(c);if(!y)return null;const{value:_}=Eo(`query:${Yr(c)}`,sn(),()=>h.match(y),E=>E&&typeof E=="object"?E:null);return Q_(_,c)},Ed=c=>{const h=T(),y=new Set(Kr(c));if(y.size===0)return{};const _=h?.readMountedProjectionBlocksByIds,E=h?.readMountedProjectionBlocks;if(typeof _!="function"&&typeof E!="function")return{};const D=Lt(()=>{if(typeof _!="function")return E.call(h);const Ge=ps(c);return Ge?_.call(h,[...y],Ge):_.call(h,[...y])},null);if(!Array.isArray(D))return{};const V=$0(D),ne=Ge=>{const rt={},lt=V0(Ge.fontFamily);lt&&(rt.fontFamily=lt);const We=tF(Ge.fontSize);return We&&(rt.fontSize=We),typeof Ge.color=="string"&&Ge.color.trim()!==""&&(rt.color=Ge.color.trim().toUpperCase()),typeof Ge.highlight=="string"&&Ge.highlight.trim()!==""&&(rt.highlight=Ge.highlight.trim().toUpperCase()),rt},le=$i(c),xe=le&&typeof le.range?.start=="number"?le.range.start:null;if(le&&xe!==null&&y.has(le.blockId)){const Ge=V.find(lt=>Dc(lt,le.blockId)),rt=Ge&&Array.isArray(Ge.runs)?Ge.runs:null;if(rt&&rt.length>0&&rt.every(lt=>lt?.kind==="text"||lt?.kind==="tab")){let lt=0,We=null;for(const wt of rt){const Rt=Vm(wt);if(xe>=lt&&xe<lt+Rt){We=wt;break}lt+=Rt}if(!We){for(let wt=rt.length-1;wt>=0&&!We;wt-=1)rt[wt]?.kind==="text"&&(We=rt[wt]);We??=rt[rt.length-1]??null}return We?ne(We):{}}}const je=ld(c);if(je.length>0){const Ge=new Set,rt=new Set;let lt=!1,We=!0;for(const wt of je){const Rt=V.find(En=>Dc(En,wt.blockId));if(!Rt)return{};const an=Array.isArray(Rt.runs)?Rt.runs:[];if(an.length===0)continue;if(!an.every(En=>En?.kind==="text"||En?.kind==="tab")){We=!1;break}let un=0;for(const En of an){const io=Vm(En),Bi=un,as=un+io;if(Bi<wt.end&&as>wt.start){lt=!0;const wo=ne(En);wo.fontFamily&&Ge.add(wo.fontFamily),wo.fontSize&&rt.add(wo.fontSize)}un=as}}if(We&<){const wt={};return Ge.size===1&&(wt.fontFamily=[...Ge][0]),rt.size===1&&(wt.fontSize=[...rt][0]),wt}}const De=new Set,Ye=new Set;let Ze=!1;for(const Ge of V){if(![...y].some(lt=>Dc(Ge,lt)))continue;const rt=Array.isArray(Ge.runs)?Ge.runs:[];for(const lt of rt){if(lt?.kind!=="text")continue;Ze=!0;const We=ne(lt);We.fontFamily&&De.add(We.fontFamily),We.fontSize&&Ye.add(We.fontSize)}}if(!Ze)return{};const Xe={};return De.size===1&&(Xe.fontFamily=[...De][0]),Ye.size===1&&(Xe.fontSize=[...Ye][0]),Xe},xd=c=>{const h=T(),y=new Set(Kr(c));if(y.size===0)return{};const _=h?.readMountedProjectionBlocksByIds,E=h?.readMountedProjectionBlocks;if(typeof _!="function"&&typeof E!="function")return{};const D=Lt(()=>{if(typeof _!="function")return E.call(h);const Xe=ps(c);return Xe?_.call(h,[...y],Xe):_.call(h,[...y])},null);if(!Array.isArray(D))return{};const V=$0(D),ne=Xe=>({bold:Xe.bold===!0,italic:Xe.italic===!0,underline:Xe.underline!=null,strikethrough:Xe.strike===!0}),le=Xe=>{const Ge={};for(const rt of oh){const lt=Xe[rt];lt.size===1&&(Ge[rt]=[...lt][0])}return Ge},xe=$i(c),je=xe&&typeof xe.range?.start=="number"?xe.range.start:null;if(xe&&je!==null&&y.has(xe.blockId)){const Xe=V.find(rt=>Dc(rt,xe.blockId)),Ge=Xe&&Array.isArray(Xe.runs)?Xe.runs:null;if(Ge&&Ge.length>0&&Ge.every(rt=>rt?.kind==="text"||rt?.kind==="tab")){let rt=0,lt=null;for(const We of Ge){const wt=Vm(We);if(je>=rt&&je<rt+wt){lt=We;break}rt+=wt}if(!lt){for(let We=Ge.length-1;We>=0&&!lt;We-=1)Ge[We]?.kind==="text"&&(lt=Ge[We]);lt??=Ge[Ge.length-1]??null}return lt?ne(lt):{}}}const De=ld(c);if(De.length>0){const Xe={bold:new Set,italic:new Set,underline:new Set,strikethrough:new Set};let Ge=!1,rt=!0;for(const lt of De){const We=V.find(an=>Dc(an,lt.blockId));if(!We)return{};const wt=Array.isArray(We.runs)?We.runs:[];if(wt.length===0)continue;if(!wt.every(an=>an?.kind==="text"||an?.kind==="tab")){rt=!1;break}let Rt=0;for(const an of wt){const un=Vm(an),En=Rt,io=Rt+un;if(En<lt.end&&io>lt.start){Ge=!0;const Bi=ne(an);for(const as of oh)Xe[as].add(Bi[as])}Rt=io}}if(rt&&Ge)return le(Xe)}const Ye={bold:new Set,italic:new Set,underline:new Set,strikethrough:new Set};let Ze=!1;for(const Xe of V){if(![...y].some(rt=>Dc(Xe,rt)))continue;const Ge=Array.isArray(Xe.runs)?Xe.runs:[];for(const rt of Ge){if(rt?.kind!=="text")continue;Ze=!0;const lt=ne(rt);for(const We of oh)Ye[We].add(lt[We])}}return Ze?le(Ye):{}},rl=(c,h)=>{if(h.fontFamily!==void 0&&h.fontSize!==void 0&&h.color!==void 0&&h.highlight!==void 0)return{values:h,effectiveUniformityStatus:"ready"};const y=Ed(c),_={...y.fontFamily!==void 0?{fontFamily:y.fontFamily}:{},...y.fontSize!==void 0?{fontSize:y.fontSize}:{},...y.color!==void 0?{color:y.color}:{},...y.highlight!==void 0?{highlight:y.highlight}:{},...h};if(!c.empty&&(_.fontFamily===void 0||_.fontSize===void 0)){const E=Oh(c);return E.values&&(_.fontFamily===void 0&&E.values.fontFamily!==void 0&&(_.fontFamily=E.values.fontFamily),_.fontSize===void 0&&E.values.fontSize!==void 0&&(_.fontSize=E.values.fontSize)),{values:_,effectiveUniformityStatus:E.status}}return{values:_,effectiveUniformityStatus:"ready"}},Dh=["fontFamily","fontSize","bold","italic","underline","strikethrough"],Td=c=>{const h=c.selectionTarget;if(!h)return{value:null,status:"ready"};const y=Sr(M(),"format.readEffectiveInlineUniformity");if(!y)return{value:null,status:"ready"};const _=Z_(c)??Yr(c);return Eo(`effInline:${_}`,sn(),()=>y({target:h,offsetSpace:"selection",keys:Dh}),E=>E&&typeof E=="object"?E:null)},Oh=c=>{const{value:h,status:y}=Td(c);if(!h||h.success!==!0)return{values:null,status:y};const _=h.values,E=D=>{const V=_?.[D];if(!(!V||V.state!=="uniform"||typeof V.value!="string"))return D==="fontFamily"?V0(V.value):V.value};return{values:{fontFamily:E("fontFamily"),fontSize:E("fontSize")},status:y}},Rd=c=>{const{value:h,status:y}=Td(c);if(!h||h.success!==!0)return{values:null,status:y};const _=h.values,E={};for(const D of oh){const V=_?.[D];V?.state==="uniform"&&(V.value==="true"||V.value==="false")&&(E[D]=V.value==="true")}return{values:E,status:y}},Md=(c,h)=>{const y=c.activeMark;if(!y||!oh.includes(y))return null;const _=y,E=xd(h)[_];if(E!==void 0)return E;const{values:D}=Rd(h),V=D?.[_];return V!==void 0?V:null},Ld=async c=>{const h=c.selectionTarget;if(!h)return null;const y=Sr(M(),"format.readEffectiveInlineUniformity");if(!y)return null;try{const _=await Promise.resolve(y({target:h,offsetSpace:"selection"}));return _&&typeof _=="object"&&_.success===!0?_:null}catch{return null}},Es=(c,h,y)=>{const _=y.values;for(const E of["fontFamily","fontSize"]){if(h[E]!==void 0)continue;const D=_?.[E];D?.state==="uniform"&&typeof D.value=="string"?c[E]=E==="fontFamily"?V0(D.value):D.value:delete c[E]}},fa=c=>rl(c,J_(tu(c),c)),ol=c=>fa(c).values,Fh=async c=>{const h=M()?.query,y=nl(c);if(typeof h?.match!="function"||!y)return ol(c);try{const _=await Promise.resolve(h.match(y)),E=J_(Q_(_&&typeof _=="object"?_:null,c),c),D=rl(c,E);if(D.effectiveUniformityStatus!=="ready"&&(E.fontFamily===void 0||E.fontSize===void 0)){const V=await Ld(c);V&&Es(D.values,E,V)}return D.values}catch{return ol(c)}},ic=async c=>{const h=M();if(h)return typeof h.getNode=="function"?await Promise.resolve(h.getNode(c)):await Promise.resolve(h.getNodeById?.({nodeId:c.nodeId,nodeType:c.nodeType}))},Pd=c=>{const h=M()?.query;if(typeof h?.match!="function")return"ready";const y=nl(c);if(!y)return"ready";const{status:_}=Eo(`query:${Yr(c)}`,sn(),()=>h.match(y),E=>E&&typeof E=="object"?E:null);return _},Dd=c=>{const h=fa(c),y=h.values;if(c.empty)return h;const _=Wa(c);return _?c.status==="ready"&&Pd(c)==="ready"&&h.effectiveUniformityStatus==="ready"?(S={key:_,values:y},h):S&&S.key===_?{...h,values:{...S.values,...y}}:h:h},il=c=>{const h=M(),y=Dd(c),_=y.values;c.status==="ready"&&!c.empty&&Pd(c)==="ready"&&y.effectiveUniformityStatus==="ready"&&(C=_,w=`${Mc(c)}:${sn()}`);const E=h?.contentControls,{lockModesById:D}=da(E,c),V={};for(const ne of al())V[ne]=A(ne,h,c,_,D);return V},es=c=>c?tt.operationUnavailable:b()?tt.documentApiUnavailable:tt.notReady,xs=c=>c==="contentLocked"||c==="sdtContentLocked",xr=c=>{for(const h of c.values())if(xs(h))return tt.contentControlLocked},Od=(c,h,y,_,E)=>{if(!h)return c.scope==="all"?tt.bulkDecisionsDisabled:es(E);if(y)return y;if(c.scope!=="all"&&_.activeChangeIds.length===0)return tt.selectionRequired},ha=c=>{Is();let h;if(L()){const E=mi()?.find(V=>Ur(V)===c);if(E)return ud(E);const D=Se.get("trackChanges");h=D?.hasSettled&&Array.isArray(D.value)?D.value:null}else h=ua("trackChanges:all").value;const y=h?.find(E=>Ur(E)===c),_=cd(y);return _?ud(_):null},nu=(c,h)=>{const y=t.canPerformPermission;if(typeof y!="function"||h.length===0)return;const _=t.config&&typeof t.config=="object"?t.config.user:null;for(const E of h){const D=ha(E)??{id:E},V=NO(D,_),ne=c==="accept"?V?"RESOLVE_OWN":"RESOLVE_OTHER":V?"REJECT_OWN":"REJECT_OTHER";let le;try{le=y.call(t,{permission:ne,trackedChange:D,comment:null})}catch{return}if(le===!1)return tt.permissionDenied}},sc=c=>{const h=T(),y=Lt(typeof h?.getCapabilities=="function"?()=>h.getCapabilities():void 0,null)?.editableSubset?.commands;if(Array.isArray(y))return y.find(_=>_?.command===c||_?.id===c)??null;if(y&&typeof y=="object"){const _=y[c];return _&&typeof _=="object"?_:null}return null},sl=(c,h)=>{if(c.scope!=="all"||typeof h?.[`${c.kind}All`]=="function")return;const y=sc(`trackedChanges.${c.kind}All`);if(!(y&&(y.status==="supported"||y.enabled===!0)))return tt.bulkDecisionsDisabled},ac=c=>c.empty&&$i(c)!=null&&typeof T()?.setPendingInlineFormat=="function",A=(c,h,y,_,E=new Map)=>{if(It.has(c))return rn({supported:!0,enabled:!0,...Lt(It.get(c).getState?()=>It.get(c).getState(Kc(void 0)):void 0,{})},"custom");const D=Xn()==="viewing",V=N_(c);if(V&&typeof ye()?.lists?.apply=="function"){const Ze=Pe(),Xe=typeof Ze?.shippedStatus=="string"?Ze.shippedStatus:null,Ge=Xe!=="not-shipped"&&Xe!=="disabled",rt=Ge&&(typeof Ze?.enabled=="boolean"?Ze.enabled:!0),lt=Ge?Ve(Ze):null;return rn(D?{enabled:!1,active:lt===V,supported:Ge,value:Ze?.value,reason:tt.documentReadonly}:{enabled:rt,active:lt===V,supported:Ge,value:Ze?.value},"builtin")}const ne=Um(c);if(ne){const Ze=h?.trackChanges,Xe=typeof Ze?.decide=="function"||typeof Ze?.[ne.kind]=="function",Ge=typeof Ze?.decide=="function"||typeof Ze?.[`${ne.kind}All`]=="function",rt=ne.scope==="all"?Ge:Xe,lt=sl(ne,Ze)??Od(ne,rt,wd(),y,h)??(ne.scope==="all"?void 0:nu(ne.kind,y.activeChangeIds));return rn({enabled:lt==null,active:!1,supported:rt,reason:lt},"builtin")}if(c==="copy-format")return Xn()==="viewing"?rn({supported:!0,enabled:!1,active:!1},"builtin"):b()?rn({supported:!0,enabled:!0,active:p.mode!=="idle"},"builtin"):rn({supported:!0,enabled:!1,active:!1,reason:tt.notReady},"builtin");const le=nd(c);if(!le)return rn({enabled:!1,active:!1,supported:!1,reason:tt.commandUnsupported},"unsupported");if(le.disposition!=="routed")return rn({enabled:!1,active:!1,supported:!1,reason:le.reason??tt.commandUnsupported},le.disposition==="unsupported"?"unsupported":"builtin");if(le.instanceRoute)return Li(le);if(le.table)return ht(le,h,D);if(le.inline?.kind==="clear"){if(le.mutates&&D)return rn({enabled:!1,active:!1,supported:!0,reason:tt.documentReadonly},"builtin");const Ze=xr(E);if(Ze)return rn({enabled:!1,active:!1,supported:!0,reason:Ze},"builtin");const Xe=Kr(y).length>0||dd(y)!=null;return rn({enabled:Xe,active:!1,supported:!0,reason:Xe?void 0:tt.selectionRequired},"builtin")}const xe=le.docRoute;if(!xe)return rn({enabled:!1,active:!1,supported:!1,reason:tt.commandUnsupported},"unsupported");if(Sr(h,xe)==null)return rn({enabled:!1,active:!1,supported:!1,reason:es(h)},"builtin");const je=nt(c);if(je){const Ze=je.shippedStatus,Xe=Ze!=="not-shipped"&&Ze!=="disabled",Ge=typeof je.enabled=="boolean"?je.enabled:!0,rt=c==="undo"||c==="redo",lt=rt&&je.historyResolved===!1,We=rt&&Xe&&Ge===!1&&je.reason===null&&!lt,wt=je.reason===void 0?void 0:We?tt.historyEmpty:lt?tt.notReady:Bm(je.reason,tt.commandUnsupported);return le.mutates&&D?rn({enabled:!1,active:!1,supported:Xe,reason:tt.documentReadonly},"builtin"):rn({enabled:Xe&&Ge,active:!1,supported:Xe,reason:wt},"builtin")}const De=ie(le,h,y),Ye=se(le,h,y,_);if(le.list?.mode==="indent"||le.list?.mode==="outdent")return gr(le,h,D,y,De,Ye);if(le.list?.mode==="toggle-seed")return Br(le,h,D,y,De,Ye);if(le.mutates&&D)return rn({enabled:!1,active:De,supported:!0,value:Ye,reason:tt.documentReadonly},"builtin");if(le.inline&&!dd(y)){const Ze=xr(E);return rn(Ze?{enabled:!1,active:De,supported:!0,value:Ye,reason:Ze}:ac(y)?{enabled:!0,active:De,supported:!0,value:Ye}:{enabled:!1,active:De,supported:!0,value:Ye,reason:tt.rangeSelectionRequired},"builtin")}if((le.blockParagraph||le.list)&&Kr(y).length===0)return rn({enabled:!1,active:De,supported:!0,value:Ye,reason:tt.selectionRequired},"builtin");if(le.field&&!Y_(y))return rn({enabled:!1,active:De,supported:!0,reason:tt.contextUnavailable},"builtin");if(le.pageNumbers&&Xn()==="suggesting")return rn({enabled:!1,active:De,supported:!0,reason:tt.operationUnavailable},"builtin");if(le.link&&!De&&z0(y).length===0&&!$i(y))return rn({enabled:!1,active:De,supported:!0,reason:tt.rangeSelectionRequired},"builtin");if(le.inline){const Ze=xr(E);if(Ze)return rn({enabled:!1,active:De,supported:!0,value:Ye,reason:Ze},"builtin")}return rn({enabled:!0,active:De,supported:!0,value:Ye},"builtin")};function O(c,h){const y=c.address?.anchor,_=y?.start,E=y?.end,D=typeof _?.blockId=="string"?_.blockId:null,V=typeof E?.blockId=="string"?E.blockId:null;if(!D||!V)return!1;const ne=typeof _?.offset=="number"?_.offset:null,le=typeof E?.offset=="number"?E.offset:null;if(ne==null||le==null)return!1;const xe=h.target,je=xe&&Array.isArray(xe.segments)?xe.segments:[];for(const De of je){const Ye=typeof De?.blockId=="string"?De.blockId:null;if(!Ye)continue;const Ze=De.range,Xe=typeof Ze?.start=="number"?Ze.start:null,Ge=typeof Ze?.end=="number"?Ze.end:null;if(!(Xe==null||Ge==null)){if(D!==V){if(Ye===D&&Ge>ne||Ye===V&&Xe<le)return!0;continue}if(Ye===D){if(Xe===Ge){if(Xe>=ne&&Xe<=le)return!0;continue}if(Math.max(Xe,ne)<Math.min(Ge,le))return!0}}}return!1}const Y=(c,h)=>{const y=c?.hyperlinks;if(!y||typeof y.list!="function")return null;const _=Kr(h);if(!Pc(_))return null;for(const E of _){const D={kind:"block",nodeType:"paragraph",nodeId:E},{value:V}=Eo(`hyperlinks:${E}`,sn(),()=>y.list({within:D}),le=>le&&typeof le=="object"?le:null),ne=(V&&Array.isArray(V.items)?V.items:[]).find(le=>O(le,h));if(ne)return ne}return null},ie=(c,h,y)=>{if(c.link)return Y(h,y)!=null;if(c.list?.mode==="toggle-seed"&&c.list.seed)return Oe(h,y)===c.list.seed;const _=W(c);if(_!==null)return _;const E=r.get(c.id),D=Wa(y);if(D&&E?.selectionSignature===D)return E.active;const V=Md(c,y);return V!==null?V:wF(c,y)},se=(c,h,y,_)=>{if(c.inline&&j0(c.inline.key)){const E=ee(c);if(E!==void 0)return E;const D=_[c.inline.key];if(D!==void 0)return D;const V=Wa(y),ne=V?n.get(c.inline.key):void 0;if(V&&ne?.selectionSignature===V)return ne.value}if(c.id==="linked-style"){const{style:E}=ga(y,Pi().cache);return!E.styleId||E.mixed?void 0:{styleId:E.styleId,styleName:E.styleName}}if(c.id==="text-align")return Gt(h,y);if(c.id==="link")return vo(h,y)??void 0},he=(c,h,y)=>{const _=c?.lists;if(!_)return{value:null,status:"ready"};const E=y.storyType==="body",D=typeof _.getStateInStory=="function"?()=>_.getStateInStory({target:Ga(h),story:y}):E&&typeof _.getState=="function"?()=>_.getState({target:Ga(h)}):null;if(!D)return{value:null,status:"ready"};const{value:V,status:ne}=Eo(`lists:${Qn(y)}:${h}`,sn(),D,le=>le&&typeof le=="object"?le:null);return{value:V?.success===!0?V:null,status:ne}},ue=(c,h,y)=>he(c,h,y).value,de=(c,h,y)=>{const _=ue(c,h,y);return!_||_.isListItem!==!0?null:_.seed==="bullet"||_.seed==="ordered"?_.seed:null},Ae=(c,h,y)=>{const _=he(c,h,y),E=_.value;return{value:E&&typeof E.isListItem=="boolean"?E.isListItem:null,status:_.status}},Oe=(c,h)=>{const y=Kr(h);if(y.length===0||!Pc(y))return null;const _=hs(h),E=de(c,y[0],_);if(E!=="bullet"&&E!=="ordered")return null;for(const D of y.slice(1))if(de(c,D,_)!==E)return null;return E},He=(c,h,y)=>{if(!c)return{value:null,status:"ready",refreshing:!1};const _=Qn(y),E=_==="story:body";if(E&&typeof c.getNodeById!="function")return{value:null,status:"ready",refreshing:!1};if(!E&&typeof c.getNode!="function")return{value:null,status:"ready",refreshing:!1};const D=`node:${_}:${h}`,V=sn(),ne=Eo(D,V,()=>E?c.getNodeById({nodeId:h,nodeType:"paragraph"}):c.getNode(_o(h,y)),xe=>xe&&typeof xe=="object"?xe:null),le=Se.get(D);return{...ne,refreshing:ne.status==="stale"&&le?.inflightToken===V&&le.failedToken!==V}},Fe=c=>c==="left"||c==="center"||c==="right"||c==="justify"?c:void 0,qe=c=>c==="start"||c==="end"||c==="distributed"||c==="numTab"||c==="lowKashida"||c==="mediumKashida"||c==="highKashida"||c==="thaiDistribute",at=(c,h)=>{const y=T(),_=y?.readMountedProjectionBlocksByIds;if(typeof _!="function")return null;const E=ps(c),D=Lt(()=>E?_.call(y,[...h],E):_.call(y,[...h]),null);if(!Array.isArray(D))return new Map;const V=$0(D),ne=new Map;for(const le of h){const xe=V.find(Ze=>Dc(Ze,le));if(!xe)continue;const je=xe.attrs,De=Fe(je?.alignment),Ye=cO(je);ne.set(le,De??(Ye==="rtl"?"right":"left"))}return ne},it=(c,h,y,_)=>{const{value:E,status:D,refreshing:V}=He(c,h,y),ne=_?.get(h);if(D==="pending")return ne?{status:"uniform",value:ne}:{status:"pending"};if(D==="stale"&&!V)return{status:"pending"};if(D==="stale"&&ne)return{status:"uniform",value:ne};if(D==="stale"&&_&&!ne)return{status:"unavailable"};if(!E)return{status:"unavailable"};const le=E.node;if(!le)return{status:"unavailable"};const xe=le.kind;if(xe!=="paragraph"&&xe!=="heading")return{status:"unavailable"};const je=le[xe];if(!je||typeof je!="object")return{status:"unavailable"};const De=je.props?.alignment;if(De==null)return ne?{status:"uniform",value:ne}:{status:"unavailable"};const Ye=Fe(De);return Ye?{status:"uniform",value:Ye}:qe(De)&&ne?{status:"uniform",value:ne}:{status:"unavailable"}},At=(c,h)=>{const y=Kr(h);if(y.length===0||!Pc(y))return{status:"unavailable"};const _=hs(h),E=at(h,y),D=it(c,y[0],_,E);if(D.status!=="uniform")return D;for(const V of y.slice(1)){const ne=it(c,V,_,E);if(ne.status!=="uniform")return ne;if(ne.value!==D.value)return{status:"mixed"}}return D},pt=c=>{const h=Kr(c);return h.length===0?null:`${Qn(hs(c))}:${h.join(",")}`},Gt=(c,h)=>{const y=At(c,h),_=y.status==="uniform"?y.value:void 0,E=o;if(!E)return _;const D=pt(h);return D&&D!==E.selectionSignature?(o=null,_):!D||!E.settled?E.value:y.status!=="pending"?(o=null,_):E.value},bn=(c,h)=>{const y=Fe(h),_=pt(c),E=Kr(c);if(!y||!_||E.length===0)return null;const D=++i;return o={selectionSignature:_,value:y,generation:D,settled:!1,canReconcile:Pc(E)},$t(),D},Tr=(c,h)=>{if(c==null)return;const y=o;if(!(!y||y.generation!==c)){if(!mo(h)){o=null;return}if(!y.canReconcile){o=null;return}y.settled=!0}},Jt=async(c,h,y)=>{const _=c?.lists;if(!_)return null;try{const E=y.storyType==="body",D=typeof _.getStateInStory=="function"?await _.getStateInStory({target:Ga(h),story:y}):E&&typeof _.getState=="function"?await _.getState({target:Ga(h)}):null,V=D&&typeof D=="object"?D:null;return!V||V.success!==!0||typeof V.isListItem!="boolean"?null:V.isListItem}catch{return null}},On=(c,h,y)=>{const _={resolved:!1,seed:null},E=c?.lists;if(!E)return _;const D=y.storyType==="body",V=typeof E.getStateInStory=="function"?()=>E.getStateInStory({target:Ga(h),story:y}):D&&typeof E.getState=="function"?()=>E.getState({target:Ga(h)}):null;if(!V)return _;const ne=le=>{const xe=le&&typeof le=="object"?le:null;return!xe||xe.success!==!0||typeof xe.isListItem!="boolean"?_:{resolved:!0,seed:xe.isListItem===!0&&(xe.seed==="bullet"||xe.seed==="ordered")?xe.seed:null}};try{const le=V();return kr(le)?Promise.resolve(le).then(ne,()=>_):ne(le)}catch{return _}},Sn=async(c,h,y)=>{if(!c)return null;try{const _=!y||y.storyType==="body",E=y&&typeof c.getNode=="function"?await c.getNode(_o(h,y)):_&&typeof c.getNodeById=="function"?await c.getNodeById({nodeId:h,nodeType:"paragraph"}):null;return WO(E&&typeof E=="object"?E:null)}catch{return null}},gr=(c,h,y,_,E,D)=>{if(c.mutates&&y)return rn({enabled:!1,active:E,supported:!0,value:D,reason:tt.documentReadonly},"builtin");const V=Kr(_);if(V.length===0)return rn({enabled:!1,active:E,supported:!0,value:D,reason:tt.selectionRequired},"builtin");const ne=c.docRoute?Sr(h,c.docRoute):null,le=Sr(h,"format.paragraph.setIndentation"),xe=Sr(h,"format.paragraph.clearIndentation"),je=c.list?.mode,De=je==="indent"?le!=null:le!=null||xe!=null,Ye=hs(_);let Ze=null;if(Ye.storyType!=="body"){Ze=[];for(const Xe of V){const{value:Ge,status:rt}=Ae(h,Xe,Ye);if(Ge===null)return rt!=="ready"&&(ne!=null||De)?rn({enabled:!0,active:E,supported:!0,value:D},"builtin"):rn({enabled:!1,active:E,supported:!1,value:D,reason:es(h)},"builtin");Ze.push(Ge)}}if(Ze?.some(Xe=>Xe===!0)){const Xe=je==="indent"?"lists.indentRange":"lists.outdentRange",Ge=Xn()!=="suggesting"&&Ze.every(lt=>lt===!0)&&Sr(h,Xe)!=null,rt=je==="outdent"&&Sr(h,"lists.outdentInStory")!=null;if(!Ge&&!rt)return rn({enabled:!1,active:E,supported:!1,value:D,reason:es(h)},"builtin")}for(const[Xe,Ge]of V.entries()){const rt=Ze?{value:Ze[Xe]??null,status:"ready"}:Ae(h,Ge,Ye),lt=rt.value;if(lt===!0){if(ne!=null)return rn({enabled:!0,active:E,supported:!0,value:D},"builtin");continue}if(lt===!1&&De){if(Ye.storyType!=="body"&&typeof h?.getNode!="function")continue;return rn({enabled:!0,active:E,supported:!0,value:D},"builtin")}if(lt===null)return rt.status!=="ready"&&(ne!=null||De)?rn({enabled:!0,active:E,supported:!0,value:D},"builtin"):rn({enabled:!1,active:E,supported:!1,value:D,reason:es(h)},"builtin")}return rn({enabled:!1,active:E,supported:!1,value:D,reason:es(h)},"builtin")},Br=(c,h,y,_,E,D)=>{if(c.mutates&&y)return rn({enabled:!1,active:E,supported:!0,value:D,reason:tt.documentReadonly},"builtin");const V=Kr(_);if(V.length===0)return rn({enabled:!1,active:E,supported:!0,value:D,reason:tt.selectionRequired},"builtin");const ne=hs(_),le=h?.lists;if(!(typeof le?.getStateInStory=="function"||ne.storyType==="body"&&typeof le?.getState=="function"))return rn({enabled:!1,active:E,supported:!1,value:D,reason:tt.operationUnavailable},"builtin");if(!Pc(V))return rn(ne.storyType==="body"&&Sr(h,"lists.remove")!=null?{enabled:!0,active:E,supported:!0,value:D}:{enabled:!1,active:E,supported:!1,value:D,reason:tt.operationUnavailable},"builtin");const xe=V.map(Ze=>he(h,Ze,ne));if(xe.some(({status:Ze})=>Ze!=="ready"))return rn({enabled:!0,active:E,supported:!0,value:D},"builtin");if(xe.some(({value:Ze})=>Ze===null))return rn({enabled:!1,active:E,supported:!1,value:D,reason:tt.operationUnavailable},"builtin");const je=c.list?.seed,De=xe.every(({value:Ze})=>Ze?.isListItem===!0&&Ze.seed===je);if(ne.storyType==="body")return rn(!De||Sr(h,"lists.remove")!=null?{enabled:!0,active:E,supported:!0,value:D}:{enabled:!1,active:E,supported:!1,value:D,reason:tt.operationUnavailable},"builtin");const Ye=Sr(h,"lists.removeInStory");return rn(De&&Ye?{enabled:!0,active:E,supported:!0,value:D}:{enabled:!1,active:E,supported:!1,value:D,reason:tt.operationUnavailable},"builtin")},vo=(c,h)=>{const y=Y(c,h)?.properties?.href;return typeof y=="string"?y:null},Li=c=>{if(!b())return rn({enabled:!1,active:!1,supported:!1,reason:tt.notReady},"builtin");const h=c.instanceRoute;return typeof t?.[h]!="function"?rn({enabled:!1,active:!1,supported:!1,reason:tt.operationUnavailable},"builtin"):rn({enabled:!0,active:gi(c),supported:!0,value:fn(c)},"builtin")},gi=c=>{const h=t?.config??void 0;return c.valueFrom==="ruler"?!!h?.rulers:c.valueFrom==="formattingMarks"?!!h?.layoutEngineOptions?.showFormattingMarks:!1},ht=(c,h,y)=>{if(y)return rn({enabled:!1,active:!1,supported:!0,reason:tt.documentReadonly},"builtin");const _=ft();return _!=null&&(!c.table.requiresCell||_.cellNodeId!=null)?(c.docRoute?Sr(h,c.docRoute):null)==null?rn({enabled:!1,active:!1,supported:!1,reason:es(h)},"builtin"):rn({enabled:!0,active:!1,supported:!0},"builtin"):rn({enabled:!1,active:!1,supported:!0,reason:tt.tableContextUnavailable},"builtin")},fn=c=>{if(c.valueFrom==="zoom")return Id().value;if(c.valueFrom==="documentMode")return Xn();if(c.valueFrom==="measurementUnit")return Ph();if(c.valueFrom==="ruler"||c.valueFrom==="formattingMarks")return gi(c)},Zr=(c,h)=>c.id==="zoom"?typeof h=="number"&&Number.isFinite(h)&&h>0:c.id==="document-mode"?h==="editing"||h==="suggesting"||h==="viewing":c.id==="measurement-unit"?h==="in"||h==="cm":!0,al=()=>[...new Set([...aO,...It.keys()])],pa="Normal",xo={ready:!1,status:"ready",catalogRevision:null,quickGallery:[],activeParagraphStyleId:null,activeParagraphStyleName:null,mixedSelection:!1,sourceStatus:null,diagnostics:[]},Ts=c=>`styles:catalog:${JSON.stringify(c??{})}`,ma=c=>{const h=M()?.styles;return!h||typeof h.getCatalog!="function"?{value:null,status:"ready"}:Eo(Ts(c),sn(),()=>h.getCatalog(c),y=>y&&typeof y=="object"?y:null)},Pi=()=>{const c=ma({includePreview:!0});if(!c.value)return{cache:null,status:c.status};const h=ma({view:"quickGallery",includePreview:!0}),y=h.value?h.value.items:c.value.styles.filter(E=>E.visibility.quickGallery),_=new Map;for(const E of c.value.styles)_.set(E.id,E);return{cache:{full:c.value,quickGallery:y,byId:_},status:Ol(c.status,h.status)}},ru=(c,h,y)=>{const{value:_,status:E}=He(c,h,y);if(!_)return{ok:!1,styleRef:null,status:E};const D=_.node;if(!D||typeof D!="object")return{ok:!1,styleRef:null,status:E};const V=D.kind,ne=typeof V=="string"?D[V]:void 0,le=ne&&typeof ne=="object"?ne.styleRef:void 0;return{ok:!0,styleRef:typeof le=="string"&&le.length>0?le:null,status:E}},ga=(c,h)=>{const y=[],_=M();if(!_)return y.push({severity:"warning",code:"active-style-unavailable",message:"Active paragraph style is unavailable: the Document API is not reachable."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:y},status:"ready"};const E=Kr(c);if(E.length===0)return y.push({severity:"info",code:"active-style-no-selection",message:"No paragraph block is resolvable from the current selection; active paragraph style is unavailable."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:y},status:"ready"};if(!Pc(E))return y.push({severity:"info",code:"active-style-selection-too-large",message:"Active paragraph style is unavailable for a large multi-paragraph selection."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:y},status:"ready"};const D=h?.full.defaults.paragraphStyleId??(h?pa:null),V=new Set;let ne=0,le=0,xe=0,je="ready";const De=hs(c);for(const Xe of E){const Ge=ru(_,Xe,De);if(je=Ol(je,Ge.status),!Ge.ok){le+=1;continue}if(!Ge.styleRef&&!D){xe+=1;continue}const rt=Ge.styleRef??D;if(!rt){xe+=1;continue}ne+=1,V.add(rt)}if(ne===0){const Xe=xe>0&&le===0;return y.push({severity:"warning",code:Xe?"active-style-default-unavailable":"active-style-read-failed",message:Xe?"Selected paragraphs have no explicit style and the style catalogue is unavailable, so the document default cannot be resolved.":"Could not read the paragraph style of any selected block; active paragraph style is unavailable."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:y},status:je}}const Ye=le+xe;if(Ye>0)return y.push({severity:"warning",code:"active-style-partial",message:`Active paragraph style resolved from ${ne} of ${ne+Ye} selected blocks; ${Ye} could not be read, so the active style is unavailable.`}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:y},status:je};if(V.size>1)return{style:{styleId:null,styleName:null,mixed:!0,diagnostics:y},status:je};const Ze=[...V][0];return{style:{styleId:Ze,styleName:h?.byId.get(Ze)?.name??null,mixed:!1,diagnostics:y},status:je}},ll=c=>{if(!b())return xo;const{cache:h,status:y}=Pi(),{style:_,status:E}=ga(c,h);let D;return h?D=_.diagnostics.length===0?h.full.diagnostics:[...h.full.diagnostics,..._.diagnostics]:D=[{severity:"warning",code:"catalog-unavailable",message:"The style catalogue is unavailable: the Document API styles surface is not reachable (e.g. viewing mode or a worker-backed editor)."},..._.diagnostics],{ready:!0,status:Ol(y,E,c.status),catalogRevision:h?.full.revision??null,quickGallery:h?.quickGallery??[],activeParagraphStyleId:_.styleId,activeParagraphStyleName:_.styleName,mixedSelection:_.mixed,sourceStatus:h?.full.sourceStatus??null,diagnostics:D}},Rs=(c="direct")=>{const{sink:h}=Nm(),y=h?Ha():0,_={},E=(xe,je)=>{if(!h)return je();const De=Ha();try{return je()}finally{_[xe]=Ha()-De}},D=E("documentMode",Xn),V=E("selection",Er);V.status==="ready"&&Gc(V),fe(V);const ne=Wa(V);for(const[xe,je]of r)(!ne||je.selectionSignature!==ne||je.settled&&V.status==="ready")&&r.delete(xe);const le={ready:b()!=null,documentMode:D,document:E("document",ei),selection:V,toolbar:{context:D,commands:E("toolbarCommands",()=>il(V)),copyFormatActive:p.mode!=="idle"},comments:E("comments",()=>Rh(V)),trackChanges:E("trackChanges",()=>Mh(V)),contentControls:E("contentControls",()=>Lh(V)),zoom:E("zoom",Id),fonts:E("fonts",Ad),styles:E("styles",()=>ll(V))};if(h){const xe=Ha();O0({stage:"superdoc-ui-compute-state",atMs:xe,reason:c,startedAtMs:y,completedAtMs:xe,durationMs:xe-y,phaseMs:_,asyncReadSettlements:Hn.splice(0)})}return le},cl=c=>{const h=Wa(c);h&&a&&h!==a&&(n.clear(),r.clear()),h&&(a=h)};let ts=null,vi=null,Ms=null,yi=null,bi=null,ns=null,rs=!1;const Fd=()=>{if(N||rs)return;rs=!0;const c=()=>{rs&&(rs=!1,!N&&$t())};typeof queueMicrotask=="function"?queueMicrotask(c):Promise.resolve().then(c)},lc=()=>{const c=ye();if(c!==Ms&&(yi&&(yi(),yi=null),Ms=c,!(!c||typeof c.subscribe!="function")))try{const h=c.subscribe(()=>Fd());typeof h=="function"&&(yi=h)}catch{Ms=null}},cc=()=>{const c=G();if(c!==bi&&(ns&&(ns(),ns=null),bi=c,!(!c||typeof c.subscribe!="function")))try{const h=c.subscribe(()=>$t());typeof h=="function"&&(ns=h)}catch{bi=null}};let Di=null,ti=null,B=null,q=null,Ee=null,be=null;const Je=()=>{const c=b()?.host,h=Lt(c?.getHandles?()=>c.getHandles():void 0,null)?.editing?.selection;return h&&typeof h.subscribe=="function"?h:null},zt=()=>{const c=T(),h=c?.readLiveSelectionSyncSnapshot;if(typeof h!="function")return!1;const y=Qi(Lt(()=>h.call(c),null));if(!y||!ca(y))return!1;const _=la(y,"ready"),E=$i(P.selection),D=$i(_);if(E&&D&&E.blockId===D.blockId&&Qn(E.story)===Qn(D.story))return!1;const V=Ed(_),ne=P.toolbar.commands["font-family"]?.value,le=P.toolbar.commands["font-size"]?.value,xe=typeof ne=="string"&&ne.length>0,je=typeof le=="string"&&le.length>0||typeof le=="number"&&Number.isFinite(le);return xe&&V.fontFamily===void 0||je&&V.fontSize===void 0},Pt=()=>{const c=Je();if(c!==ts&&(vi&&(vi(),vi=null),ts=c,!!c))try{const h=c.subscribe(y=>{Vo()&&zt()&&Th()||(bt+=1,tl(y),$t("host-selection"))});typeof h=="function"&&(vi=h)}catch{ts=null}},on=()=>{const c=b()?.host,h=Lt(c?.getHandles?()=>c.getHandles():void 0,null)?.review;return h&&typeof h.subscribe=="function"?h:null},cn=c=>c?typeof c.getActiveReviewTarget=="function"?Lt(()=>c.getActiveReviewTarget(),null):typeof c.getSnapshot=="function"?Lt(()=>c.getSnapshot(),null)?.activeReviewTarget??null:null:null;let pn=0;const Ln=(c,h)=>{const y=(h&&typeof h=="object"?h:null)?.lastInteractionRejection;if(c==null&&y&&typeof y=="object"&&y.code==="review-target-invalidated"&&y.detail==="not-painted"&&oe)return!1;const _=c&&typeof c=="object"?c:null;let E=null;if(_?.entityType==="trackedChange"&&typeof _.entityId=="string"&&_.entityId.length>0){const D=_.story&&typeof _.story=="object"?_.story:void 0,V=D&&Qn(D)!==Qn(null)?D:void 0,ne=typeof _.paintedEntityId=="string"&&_.paintedEntityId.length>0?_.paintedEntityId:null,le=ne??_.entityId,xe=(()=>{if(V){const Ye=mi(),Ze=Ye?Fl(Ye,V):null;return Ze?.toPublicId(le)??Ze?.toPublicId(_.entityId)??_.entityId}const De=ta(Array.isArray(P?.trackChanges.items)?P.trackChanges.items:[]);return De.toPublicId(le)??De.toPublicId(_.entityId)??_.entityId})(),je=ne??(le!==xe?le:null);E={id:xe,...V?{story:V}:{},...je&&je!==xe?{paintedEntityId:je}:{}}}return c==null&&E==null&&oe!=null&&X(oe)||j(oe,E)?!1:(ae(E),!0)},Hr=()=>{const c=on();if(c===Di)return;if(ti&&(ti(),ti=null),Di=c,!c){Ln(null);return}let h=!0;try{const y=c.subscribe(_=>{const E=_&&typeof _=="object"?_:null,D=E&&Object.prototype.hasOwnProperty.call(E,"activeReviewTarget")?E.activeReviewTarget:cn(c);!Ln(D,_)||h||$t()});typeof y=="function"&&(ti=y),Ln(cn(c))}catch{Di=null}finally{h=!1}},_n=()=>{if(ts||Xn()!=="viewing")return null;const c=b()?.mount?.container,h=(c&&typeof c=="object"&&"ownerDocument"in c?c.ownerDocument??null:null)??globalThis.document??null;return h&&typeof h.addEventListener=="function"?h:null},Rr=()=>{const c=_n();if(c===Ee||(be&&(be(),be=null),Ee=c,!c))return;const h=()=>{bt+=1,$t()};c.addEventListener("selectionchange",h),c.addEventListener("pointerup",h,!0),c.addEventListener("mouseup",h,!0),be=()=>{c.removeEventListener("selectionchange",h),c.removeEventListener("pointerup",h,!0),c.removeEventListener("mouseup",h,!0)}};Is(),Ln(cn(on())),P=Rs("initial"),a=Wa(P.selection);let Ls=()=>{};const yo=()=>{const c=b()?.host,h=c?.events,y=h&&typeof h.subscribe=="function"?h:null;if(y!==B&&(q&&(q(),q=null),B=y,!!y)){c&&(kn.delete(c),Ht(c));try{const _=y.subscribe(E=>{const D=E?.type,V=D==="document:mutated"&&E.hasCommitEvent!==!0;if((V||D==="mutation:committed"&&eA(E)||D==="collaboration:remote-changed"&&Array.isArray(E.changedStoryIds)&&E.changedStoryIds.length>0)&&Ls(),(D==="document:mutated"||D==="mutation:committed"&&eA(E))&&c&&!Dt.has(c)&&(Dt.add(c),$t("document-dirty")),D==="collaboration:document-replaced"&&c&&(Dt.delete(c),kn.delete(c),Ht(c),$t("document-dirty")),D==="review-mutation:started"){gt(E.reviewMutation?.token);return}if(D==="review-mutation:aborted"){Xt(E.reviewMutation?.token),qt();return}if(D==="mutation:rejected"&&E.reviewMutation&&(Xt(E.reviewMutation.token),qt()),D==="mutation:committed"&&E.reviewMutation&&Xt(E.reviewMutation.token),D==="source:complete"||D==="source:signals-complete"){Zo=sn(),dt();return}if((V||D==="mutation:committed"||D==="collaboration:remote-changed")&&(li=Date.now()),V||D==="mutation:committed"||D==="save:completed"||D==="collaboration:remote-changed"){const ne=D==="mutation:committed"?A_(E):null;if(ne?.allResolved){Mn([]),ar(E.receipt);return}ne?.removedIds.size&&No(new Set(ne.removedIds),E.receipt);const le=D==="mutation:committed"&&ql(E)||D==="collaboration:remote-changed"&&Array.isArray(E.changedStoryIds)&&E.changedStoryIds.length>0;if(le&&(zo=Date.now()),D==="mutation:committed"&&le){As();return}if(ne?.removedIds.size&&ne.upsertIds.size===0)return;(V||D==="collaboration:remote-changed"||D==="mutation:committed"&&!le)&&Xl();const xe=D==="collaboration:remote-changed"&&Array.isArray(E.changedPartUris)&&E.changedPartUris.some(De=>typeof De=="string"&&DO.has(De)),je=D==="collaboration:remote-changed"&&Array.isArray(E.changedStoryIds)&&E.changedStoryIds.length>0&&Ue();xe&&!le&&(Ir=!0),Zi(),xe&&!le?Ie("comments"):je&&(Ir=!0,Cs()),$t()}});typeof _=="function"&&(q=_)}catch{B=null}}},$t=(c="unspecified")=>{if(N)return;const{sink:h}=Nm(),y=h?Ha():0;rs=!1,Is(),Pt(),lc(),cc(),Hr(),Rr(),yo();const _=Rs(c);cl(_.selection),P=_;let E=0,D=0;for(const V of[...ke]){if(!h){V(P);continue}const ne=Ha();V(P);const le=Ha()-ne;E+=le,D=Math.max(D,le)}if(h){const V=Ha();O0({stage:"superdoc-ui-recompute",atMs:V,reason:c,startedAtMs:y,completedAtMs:V,durationMs:V-y,listenerCount:ke.size,listenerTotalMs:E,listenerMaxMs:D})}},ul=[],ou=[],Nh=[],Bh=c=>{for(const h of c)try{h()}catch{}},Nd=()=>Bh(ul),Tg=()=>Bh(ou),Rg=()=>Bh(Nh),zh=[];((c,h)=>{if(!(!c||typeof c.on!="function"))for(const y of h){const _=y==="active-editor-change"?()=>{Nd(),Tg(),$t()}:y==="document-replaced"?E=>{const D=E&&typeof E=="object"?E:null,V=D?.editor,ne=D?.host,le=!!V&&V===b(),xe=!!ne&&ne===T();if(!le&&!xe)return;const je=xe?ne:T();je&&(Dt.delete(je),kn.delete(je)),Tg(),Se.clear(),Zi(),$t()}:y==="document-mode-change"?()=>{$t(),Rg()}:()=>$t();try{c.on(y,_),zh.push(()=>{try{typeof c.off=="function"&&c.off(y,_)}catch{}})}catch{}}})(t,xO),Pt(),lc(),cc(),Hr(),Rr(),yo();const Ps=(c,h=fD)=>({get:()=>c(P),subscribe:y=>{let _=c(P);const E=D=>{const V=c(D);h(_,V)||(_=V,y(V))};return ke.add(E),()=>ke.delete(E)}}),Ds=c=>Ps(c),os=c=>{const h=y=>{const _=D=>{try{y(D)}catch{}},E=c.subscribe(_);return _(c.get()),E};return{get:()=>c.get(),getSnapshot:()=>c.get(),observe:h,subscribe:y=>h(_=>y({snapshot:_}))}},jh=(c,h,y)=>{const _=os(c),E=os(h),D=V=>{const ne=Vn(y);$t();const le=E.observe(V);return()=>{le(),ne()}};return{get:_.get,getSnapshot:_.getSnapshot,observe:D,subscribe:V=>D(ne=>V({snapshot:ne}))}};function Vh(c){return c&&typeof c=="object"&&typeof c.id=="string"?String(c.id):null}function nr(c){const h=ps(c);return h&&Qn(h)!==Qn(null)?h:void 0}function Uh(c,h){return{kind:"id",id:c,...h?{story:h}:{}}}function Mg(c){if(c.empty)return null;const h=c.selectionTarget,y=h?.start,_=h?.end;if(h?.kind!=="selection"||y?.kind!=="text"||_?.kind!=="text"||typeof y.blockId!="string"||y.blockId!==_.blockId||!Number.isInteger(y.offset)||!Number.isInteger(_.offset)||y.offset<0||_.offset<0||y.offset===_.offset)return null;const E=Math.min(y.offset,_.offset),D=Math.max(y.offset,_.offset),V=ps(c);return{kind:"range",coordinateSpace:h.coordinateSpace==="tracked"?"tracked":"visible",range:{kind:"text",...V?{story:V}:{},segments:[{blockId:y.blockId,range:{start:E,end:D}}]}}}function Lg(c,h){if(Qn(h)!==Qn(null))return;const y=M()?.trackChanges,_=y?.list;if(typeof _!="function")return;const E=Lt(()=>_.call(y),null);if(kr(E)||!E||typeof E!="object")return;const D=E.items;if(Array.isArray(D))return D.map(cd).find(V=>V!=null&&Ti(V,c,h))}function U1(c,h){const y=$h(c.quotedText);if(!y)return!1;const _=ud(h);return[_.insertedText,_.deletedText,_.excerpt].some(E=>$h(E)===y)}function $h(c){return typeof c=="string"?c.replace(/\s+/g," ").trim():""}function Pg(){const c=P.selection.activeChangeIds[0];if(!c)return"unavailable";const h=ps(P.selection),y=(P.trackChanges.status==="ready"?P.trackChanges.items.find(V=>Ti(V,c,h)):void 0)??Lg(c,h)??mi()?.find(V=>Ti(V,c,h));if(!y)return"unavailable";const _=ud(y),E=_.type,D=_.grouping;return U1(P.selection,y)?"id":E==="replacement"&&D==="replacement-pair"||(E==="insertion"||E==="deletion"||E==="insert"||E==="delete")&&D==="standalone"?"range":"id"}function Dg(c,h,y,_){const E=()=>X1(c,Uh(y,_),y,_);try{const D=X1(c,h,y,_);if(kr(D))return ro(Promise.resolve(D).then(ne=>mo(ra(ne))?ne:E()));const V=ra(D);return ro(mo(V)?D:E())}catch{return!1}}function Og(c){if(typeof c=="string"&&c.length>0)return{target:{kind:"id",id:c},changeId:c};if(c&&typeof c=="object"){const h=c;if(h.target&&typeof h.target=="object"){const _=h.target;return{target:_,changeId:Vh(_),story:_.story}}const y=typeof h.changeId=="string"?h.changeId:h.id;if(typeof y=="string"&&y.length>0)return{target:Uh(y,h.story),changeId:y,story:h.story}}return null}function Fg(c,h){if(c.scope==="all")return{target:{kind:"all"},changeId:null};const y=Og(h);if(y)return y;const _=P.selection.activeChangeIds[0],E=nr(P.selection);return _?{target:Uh(_,E),changeId:_,story:E}:null}function iu(c,h){if(c.scope==="id"&&h==null){if(P.selection.activeChangeIds.length>1)return au(c.kind,{kind:"ids",ids:P.selection.activeChangeIds},null);if(P.selection.activeChangeIds.length===1&&!P.selection.empty&&P.selection.selectionTarget){const _=Pg();if(_==="unavailable")return!1;if(_==="range"){const E=Mg(P.selection),D=nr(P.selection);return E?Dg(c.kind,E,P.selection.activeChangeIds[0],D):!1}if(_==="id"){const E=P.selection.activeChangeIds[0],D=ps(P.selection),V=D&&Qn(D)!==Qn(null)?D:void 0;return Kh(c.kind,V?{id:E,story:V}:E)}}}const y=Fg(c,h);return y?au(c.kind,y.target,y.changeId,y.story):!1}function uc(c,h){const y=ye()?.lists,_=y?.apply,E=T(),D=x!==void 0&&b()?.editorVersion===2&&E?Fm.get(t)?.get(E):null;if(x!==void 0&&b()?.editorVersion===2&&!D||!D&&typeof _!="function")return!1;const{behavior:V,preset:ne,continuity:le}=typeof h=="string"?MO(h):h&&typeof h=="object"?h:{},xe={kind:c,behavior:V??"toggle"};ne!==void 0&&(xe.preset=ne),le!==void 0&&(xe.continuity=le);try{return ro(D?D.runListApply(xe):_.call(y,xe))}catch{return!1}}let $o=Promise.resolve(!1),kt=null,Ut=null,vn=null,vr=Promise.resolve(!1);const Mr=async c=>{if(!jm(c))return c;const h=b()?.documentMutationReadiness,y=h?.whenPainted;if(typeof y!="function")return c;const _=typeof c.txId=="string"?c.txId:void 0;try{await y.call(h,_?{txId:_}:void 0)}catch{}return c},Zn=c=>{if(kr(c)){const y=Promise.resolve(c);return{immediate:!0,committed:y.then(_=>ra(_),()=>!1),settled:y.then(_=>Mr(ra(_)),()=>!1)}}const h=ra(c);return{immediate:h,committed:Promise.resolve(h),settled:Mr(h)}},Oi=()=>{const c=s.shift();if(!c){u=!1,f?.(),f=null;return}try{c.resolve(N?!1:c.mutate())}catch{c.resolve(!1)}},Os=()=>{let c=!1;return()=>{c||(c=!0,Oi())}},Bd=(c,h)=>{if(!u){u=!0,d=new Promise(D=>{f=D});try{return{result:h(),release:Os()}}catch(D){throw u=!1,f?.(),f=null,D}}const y=s.find(D=>D.key===c);if(y)return y.mutate=h,{result:y.result,release:()=>{}};let _;const E=new Promise(D=>{_=D});return s.push({key:c,mutate:h,result:E,resolve:_}),{result:E,release:Os()}},UK=new Set(["create.tableOfContents","headerFooters.pageNumbers.set","headerFooters.pageNumbers.remove"]),$K=c=>er(`Tracked authoring is not supported for ${c}.`),zd=c=>{if(Xn()==="suggesting")return UK.has(c)?$K(c):{changeMode:"tracked"}},HK=()=>Xn()==="suggesting"?cF:G0,bo=(c,h,y)=>{const _=zd(c);return _&&_.success===!1?_:_?h(y,_):h(y)},GK=(c,h,y,_)=>{const E=c.inline;if(!E)return;const D=ra(_);if(D===!1||typeof D=="object"&&D&&D.success===!1)return;if(E.kind==="clear"){n.clear();return}if(E.kind==="toggle"||!j0(E.key))return;const V=Wa(h);if(!V)return;const ne=XO(E.key,y.value);if(ne==null){n.delete(E.key);return}n.set(E.key,{selectionSignature:V,value:ne})},WK=(c,h,y,_)=>!c.inline||c.inline.kind==="toggle"?_:kr(_)?Promise.resolve(_).then(E=>(GK(c,h,y,E),E)):_,KK=(c,h,y,_)=>{if(c.inline?.kind!=="toggle"||!mo(ra(_))||typeof y.value!="boolean"&&y.value!==null)return null;const E=Wa(h);if(!E)return null;const D=++l;return r.set(c.id,{selectionSignature:E,active:y.value===!0,generation:D,settled:!1}),$t(),D},qK=(c,h,y)=>{if(h==null)return;const _=r.get(c.id);if(!(!_||_.generation!==h)){if(!mo(y)){r.delete(c.id);return}_.settled=!0}},Ng=(c,h)=>c.then(y=>(h?.(y),hi(),y),()=>(h?.(!1),hi(),!1)),ro=(c,h)=>{const y=kt;if(kt=null,y)return $o=Ng(y,h),ra(c);if(kr(c))return $o=Ng(Zn(c).settled,h),!0;const _=ra(c);return jm(_)&&typeof b()?.documentMutationReadiness?.whenPainted=="function"?($o=Ng(Mr(_),h),_):(h?.(_),$o=Promise.resolve(_),hi(),_)},YK=(c,h)=>!c||typeof c!="object"?h:c,dc=(c,h=er("Document API operation failed."))=>{if(kr(c))return Promise.resolve(c).then(_=>dc(_,h),()=>h);const y=YK(c,h);return Zi(),jm(y)&&typeof b()?.documentMutationReadiness?.whenPainted=="function"?(Ng(Mr(y)),$t(),y):($t(),y)},XK=(c,h,y,_)=>{const E=[],D=[];for(const V of y){const ne=_(V);if(ne)try{const le=Zn(bo(c,h,ne));E.push(le.immediate),D.push(le.settled)}catch{E.push(!1),D.push(Promise.resolve(!1))}}return kt=D.length?Promise.all(D).then(V=>Ri(V)):null,Ri(E)},ZK=(c,h,y,_)=>{const E=[],D=[];for(const V of y){const ne=_(V);if(ne)try{const le=Zn(bo(c,h,ne));E.push(le.immediate),D.push(le.settled)}catch{E.push(!1),D.push(Promise.resolve(!1))}}return kt=D.length?Promise.all(D).then(V=>Ri(V)):null,Ri(E)},$1=(c,h,y,_=P.selection)=>{const E=zd(c);return E&&E.success===!1?E:_.selectionTarget?h(y,{...E,offsetSpace:"selection"}):E?h(y,E):h(y)},QK=(c,h,y,_)=>{const E=_o(h,_);switch(c.kind){case"alignment":{const D=y;return D!=="left"&&D!=="center"&&D!=="right"&&D!=="justify"?null:{target:E,alignment:D}}case"spacing-line":{const D=typeof y=="number"?y:Number(y);return!Number.isFinite(D)||D<=0?null:{target:E,line:D,lineRule:"auto"}}case"style":if(y&&typeof y=="object"){const D=y.role;if(D&&typeof D=="object")return{target:E,role:D}}return typeof y!="string"||y.trim()===""?null:{target:E,styleId:y};case"direction":{const D=c.fixedValue;return D!=="ltr"&&D!=="rtl"?null:{target:E,direction:D}}default:return null}},JK=(c,h)=>{const y=c.inline,_=H0(c),E=T();if(!y||typeof E?.setPendingInlineFormat!="function")return!1;if(y.kind==="clear")return Z(),!0;if(!_)return!1;let D;if(y.kind==="toggle")D=!ie(c,M(),P.selection);else{const V=h&&typeof h=="object"&&"value"in h?h.value:h;if(y.kind==="value-number"){const ne=typeof V=="number"?V:Number(V);D=Number.isFinite(ne)&&ne>0?ne:null}else D=typeof V=="string"&&V.trim()!==""?V:null;if(D===null)return J(_,null),!0}return J(_,D),!0},eq=()=>{const c=M(),{lockModesById:h}=da(c?.contentControls,P.selection);if(xr(h))return!1;const y=[],_=[],E=Ze=>{const Xe=Zn(Ze);y.push(Xe.immediate),_.push(Xe.settled)},D=(Ze,Xe,Ge)=>{try{E(Ge?Ze(Xe,Ge):Ze(Xe))}catch{y.push(!1),_.push(Promise.resolve(!1))}},V=Pi().cache?.full.defaults.paragraphStyleId??pa,ne=dd(P.selection);if(ne){const Ze=Sr(c,"format.apply");if(Ze)try{E($1("format.apply",Ze,{target:ne,inline:{...HK()}}))}catch{y.push(!1),_.push(Promise.resolve(!1))}}const le=Sr(c,"format.paragraph.resetDirectFormatting"),xe=Sr(c,"styles.paragraph.setStyleRef"),je=ps(P.selection),De=!je||je.storyType==="body",Ye=Sr(c,De?"lists.remove":"lists.removeInStory");for(const Ze of Kr(P.selection)){const Xe=_o(Ze,je);if(le&&D(le,{target:Xe}),Ye)try{const Ge=Ga(Ze),rt=Zn(Ye(De?{target:Ge}:{target:Ge,story:je}));_.push(rt.settled.then(lt=>mo(lt)?lt:!0))}catch{}xe&&D(xe,{target:Xe,styleId:V})}if(!ne&&Xn()!=="suggesting"){const Ze=Sr(c,"format.paragraph.setMarkRunProps");if(Ze)for(const Xe of Kr(P.selection))D(Ze,{target:_o(Xe,je),markRunProps:{bold:!1,italic:!1,strikethrough:!1,doubleStrikethrough:!1,smallCaps:!1,caps:!1,verticalAlign:"baseline"}})}return kt=_.length?Promise.all(_).then(Ze=>Ri(Ze)):null,Ri(y.length?y:[!1])},tq=(c,h,y)=>{const _=Kr(P.selection);if(_.length===0)return!1;const E=ps(P.selection);return XK(c.docRoute,h,_,D=>QK(c.blockParagraph,D,y,E))},nq=(c,h,y)=>{const _=M(),E=Sr(_,"format.paragraph.setIndentation"),D=Sr(_,"format.paragraph.clearIndentation"),V=c.list?.mode,ne=hs(P.selection),le=ps(P.selection),xe=async je=>{const De=await Jt(_,je,ne);if(De===!0)return{kind:"list",routeToCall:c.docRoute,opToCall:h,input:{target:K_(je)}};if(De===null||le&&le.storyType!=="body"&&typeof _?.getNode!="function")return null;const Ye=await Sn(_,je,le),Ze={};if(Ye?.right!=null&&(Ze.right=Ye.right),Ye?.firstLine!=null&&(Ze.firstLine=Ye.firstLine),Ye?.hanging!=null&&(Ze.hanging=Ye.hanging),V==="indent")return E?{kind:"paragraph",routeToCall:"format.paragraph.setIndentation",opToCall:E,input:{target:_o(je,le),left:Math.max(0,Ye?.left??0)+q_,...Ze}}:null;const Xe=Math.max(0,(Ye?.left??0)-q_);return Xe>0&&(Ze.left=Xe),Object.keys(Ze).length===0?D?{kind:"paragraph",routeToCall:"format.paragraph.clearIndentation",opToCall:D,input:{target:_o(je,le)}}:E?{kind:"paragraph",routeToCall:"format.paragraph.setIndentation",opToCall:E,input:{target:_o(je,le),left:0}}:null:E?{kind:"paragraph",routeToCall:"format.paragraph.setIndentation",opToCall:E,input:{target:_o(je,le),...Ze}}:null};return kt=(async()=>{const je=await Promise.all(y.map(Xe=>xe(Xe).catch(()=>null)));if(je.length===y.length&&je.every(Xe=>Xe?.kind==="list")&&Xn()!=="suggesting"){const Xe=V==="indent"?"lists.indentRange":"lists.outdentRange",Ge=Sr(_,Xe);if(Ge)try{return await Zn(bo(Xe,Ge,{paraIds:y,story:ne})).settled}catch{return!1}}const De=ne.storyType!=="body"&&je.some(Xe=>Xe?.kind==="list"),Ye=De&&V==="outdent"?Sr(_,"lists.outdentInStory"):null;if(De&&!Ye)return!1;const Ze=je.map(Xe=>{if(!Xe)return Promise.resolve(!1);try{return Xe.kind==="list"&&Ye?Zn(bo("lists.outdentInStory",Ye,{target:Xe.input.target,story:ne})).settled:Zn(bo(Xe.routeToCall,Xe.opToCall,Xe.input)).settled}catch{return Promise.resolve(!1)}});return Ri(await Promise.all(Ze))})(),!0},rq=(c,h)=>{const y=c.list,_=M(),E=Kr(P.selection);if(E.length===0)return!1;const D=hs(P.selection),V=D.storyType==="body";if(y.mode==="indent"||y.mode==="outdent")return nq(c,h,E);const ne=y.seed,le=De=>{if(De.some(lt=>!lt.resolved))return{immediate:!1,settled:null};const Ye=De.every(lt=>lt.seed===ne);if(!Ye&&!V)return{immediate:!1,settled:null};const Ze=Ye?V?"lists.remove":"lists.removeInStory":c.docRoute,Xe=Ye?Sr(_,Ze):h;if(!Xe)return{immediate:!1,settled:null};const Ge=[],rt=[];return E.forEach((lt,We)=>{if(!Ye&&De[We]?.seed===ne)return;const wt=Ye?{target:Ga(lt),...V?{}:{story:D}}:{target:Ga(lt),seed:ne};try{const Rt=Zn(bo(Ze,Xe,wt));Ge.push(Rt.immediate),rt.push(Rt.settled)}catch{Ge.push(!1),rt.push(Promise.resolve(!1))}}),{immediate:Ri(Ge),settled:rt.length?Promise.all(rt).then(lt=>Ri(lt)):null}},xe=E.map(De=>On(_,De,D));if(xe.some(kr))return kt=Promise.all(xe).then(async De=>{const Ye=le(De);return Ye.settled?await Ye.settled:Ye.immediate}),!0;const je=le(xe);return kt=je.settled,je.immediate};function Hh(c){return c&&typeof c=="object"?c:{}}function oq(c){if(typeof c=="string")return c;const h=Hh(c);if(Object.prototype.hasOwnProperty.call(h,"href"))return h.href;if(Object.prototype.hasOwnProperty.call(h,"value"))return h.value}function iq(c,h){const y=Hh(c).text;return typeof y=="string"&&y.trim()!==""?y:h}function ex(c){const h=Hh(c),y=h.capture&&typeof h.capture=="object"?h.capture:null;return h.target??y?.target??y?.selectionTarget??h.selectionTarget??h.textTarget??null}const sq=c=>{const h=M(),y=h?.hyperlinks;if(!y)return!1;const _=T(),E=typeof _?.getHandles=="function"?_.getHandles():null,D=x?E?.editing?.hyperlinks:y,V=Hh(c),ne=oq(c),le=ex(c),xe=typeof V.text=="string"?V.text:void 0,je=typeof V.currentText=="string"?V.currentText:void 0,De=ih(V.hyperlinkTarget)?V.hyperlinkTarget:null,Ye=ih(V.textTarget)?V.textTarget:null,Ze=Y(h,P.selection),Xe=typeof De?.storyId=="string"&&typeof De?.hyperlinkNodeId=="string";if(Xe&&ne===null){const Ge=y.remove;if(typeof Ge!="function")return!1;try{return bo("hyperlinks.remove",Ge,{storyId:De.storyId,hyperlinkNodeId:De.hyperlinkNodeId,keepText:!0})}catch{return!1}}if(Ze&&ne===null){const Ge=D?.remove;if(typeof Ge!="function")return!1;try{return bo("hyperlinks.remove",Ge,{target:Ze.address,mode:"unwrap"})}catch{return!1}}if((Ze||De)&&typeof ne=="string"&&ne.trim()!==""){const Ge=D?.patch,rt=y.updateTarget;if(!(!Xe&&Ze&&typeof Ge=="function")&&!(Xe&&typeof rt=="function"))return!1;const lt=typeof xe=="string"&&xe!==(Xe?je:Ze?.text??je),We=h?.text?.replace,wt=lt?Xe?Ye:rF(Ze?.address):null,Rt=lt&&!!wt&&typeof We=="function";if(lt&&!Rt)return!1;const an=[],un=[];let En=null,io=null,Bi=null,as=!1;try{if(Xe){if(typeof rt!="function")return!1;const wo=bo("hyperlinks.updateTarget",rt,{storyId:De.storyId,hyperlinkNodeId:De.hyperlinkNodeId,newTarget:oF(ne)});as=kr(wo);const ni=Zn(wo);if(!mo(ni.immediate))return!1;an.push(ni.immediate),un.push(ni.settled),En=ni.immediate,io=ni.committed,Bi=ni.settled}else if(Ze){if(typeof Ge!="function")return!1;const wo=bo("hyperlinks.patch",Ge,{target:Ze.address,patch:{href:ne}});as=kr(wo);const ni=Zn(wo);if(!mo(ni.immediate))return!1;an.push(ni.immediate),un.push(ni.settled),En=ni.immediate,io=ni.committed,Bi=ni.settled}}catch{return!1}if(Rt){const wo=(Ho,ya)=>mo(ya)?Ri([Ho,ya]):mo(Ho)?Qf(Ho,ya):ya,ni=Ho=>{if(!mo(Ho))return Ho;try{const ya=Zn(bo("text.replace",We,{target:wt,text:xe}));return mo(ya.immediate)?Promise.all([Bi??Promise.resolve(Ho),ya.settled]).then(([o2,Zq])=>wo(o2,Zq)):Qf(Ho,ya.immediate)}catch{return Qf(Ho,!1)}};if(as)return kt=(io??Promise.resolve(En??!1)).then(ni),Ri(an);try{const Ho=Zn(bo("text.replace",We,{target:wt,text:xe}));if(!mo(Ho.immediate))return En?Qf(En,Ho.immediate):Ho.immediate;an.push(Ho.immediate),un.push(Ho.settled),kt=Promise.all([Bi??Promise.resolve(En??!1),Ho.settled]).then(([ya,o2])=>wo(ya,o2))}catch{return En?Qf(En,!1):!1}}return!Rt&&un.length>0&&(kt=Promise.all(un).then(wo=>Ri(wo))),Ri(an)}if(typeof ne=="string"&&ne.trim()!==""){const Ge=ne.trim(),rt=D?.wrap,lt=KO(le),We=lt.length>0?lt:z0(P.selection);if(We.length>0){if(typeof rt!="function")return!1;try{return ZK("hyperlinks.wrap",rt,We,un=>({target:un,link:{destination:{href:Ge}}}))}catch{return!1}}const wt=D?.insert,Rt=iq(c,Ge);if(typeof wt!="function"||Rt.trim()==="")return!1;const an=rh(le)??$i(P.selection);if(!an)return!1;try{return bo("hyperlinks.insert",wt,{target:an,text:Rt,link:{destination:{href:Ge}}})}catch{return!1}}return!1},aq=(c,h,y)=>{const _=c.create.kind,E=y&&typeof y=="object"?y:{};if(_==="table"){const V=Number(E.rows??E.rowCount),ne=Number(E.columns??E.cols??E.colCount);if(!Number.isInteger(V)||V<1||!Number.isInteger(ne)||ne<1)return!1;const le=$i(P.selection),xe=le&&typeof le.blockId=="string"?{kind:"inParagraph",target:_o(le.blockId),offset:le.range?.start??0}:U0(P.selection,"nodeId");try{return bo(c.docRoute,h,{rows:V,columns:ne,at:xe})}catch{return!1}}if(_==="image"){const V=E.src??E.value;if(typeof V!="string"||V.trim()==="")return!1;const ne=$i(P.selection),le=hs(P.selection),xe=le.storyType==="body"?null:le;let je;ne&&typeof ne.blockId=="string"?je={kind:"inParagraph",target:_o(ne.blockId,xe),offset:ne.range?.start??0}:(je=U0(P.selection,"target"),xe&&je.kind==="after"&&(je={...je,target:{...je.target,story:xe}}));const De={src:V,at:je};xe&&(De.in=je.kind==="inParagraph"?R(xe)??xe:xe),typeof E.alt=="string"&&(De.alt=E.alt),typeof E.title=="string"&&(De.title=E.title),E.size&&typeof E.size=="object"&&(De.size=E.size);const Ye=T(),Ze=typeof Ye?.getHandles=="function"?Ye.getHandles():null,Xe=x?Ze?.editing?.images:null,Ge=x?Xe?.create:h;if(typeof Ge!="function")return!1;try{return bo(c.docRoute,Ge,De)}catch{return!1}}const D={at:U0(P.selection,"target")};typeof E.instruction=="string"&&(D.instruction=E.instruction),E.config&&typeof E.config=="object"&&(D.config=E.config);try{return bo(c.docRoute,h,D)}catch{return!1}},lq=()=>{if(x===null)return null;const c=T();return c?x!==void 0?(typeof c.getHandles=="function"?c.getHandles():null)?.editing?.fields??null:typeof c.getCodeFieldEditingCommands=="function"?c.getCodeFieldEditingCommands():null:null},cq=c=>{if(P.selection.status==="ready"&&!Y_(P.selection))return!1;const h=zd(c.docRoute);if(h&&h.success===!1)return h;const y={instruction:c.field.instruction};try{const _=lq();return typeof _?.insertAtSelection!="function"?!1:h?_.insertAtSelection(y,h):_.insertAtSelection(y)}catch{return!1}},tx=()=>{if(x===null)return null;const c=T();return c?x!==void 0?(typeof c.getHandles=="function"?c.getHandles():null)?.editing?.pageNumbers??null:typeof c.getCodePageNumberEditingCommands=="function"?c.getCodePageNumberEditingCommands():null:null},uq=(c,h)=>{if(!h)return!1;const y=zd(c.docRoute);if(y&&y.success===!1)return y;const _=c.pageNumbers;try{const E=tx();if(typeof E?.[_]!="function")return!1;const D=E[_];return y?D(h,y):D(h)}catch{return!1}},dq=async()=>{try{const c=tx();return typeof c?.get!="function"?null:await c.get()??null}catch{return null}},nx=()=>{if(x===null)return null;const c=T();return c?x!==void 0?(typeof c.getHandles=="function"?c.getHandles():null)?.editing?.tables??null:typeof c.getCodeTableEditingCommands=="function"?c.getCodeTableEditingCommands():null:null},fq=(c,h)=>{const y=c.table,_=ft();if(!_||y.requiresCell&&!_.cellNodeId)return!1;const E=fF(y.action,_);if(!E)return!1;try{if(y.action==="insert-row-before"||y.action==="insert-row-after"){const D=nx();if(typeof D?.insertRow!="function")return!1;const V=zd(c.docRoute);return V&&V.success===!1?V:V?D.insertRow(E,V):D.insertRow(E)}if(y.action==="insert-column-before"||y.action==="insert-column-after"){const D=nx();if(typeof D?.insertColumn!="function")return!1;const V=zd(c.docRoute);return V&&V.success===!1?V:V?D.insertColumn(E,_.rowIndex,V):D.insertColumn(E,_.rowIndex)}return bo(c.docRoute,h,E)}catch{return!1}},hq=c=>!c||c.disposition!=="routed"?!1:!!(c.inline||c.blockParagraph||c.list||c.link||c.create),pq=c=>{const h=Hh(c);return!!(ex(c)||ih(h.hyperlinkTarget)||ih(h.textTarget))},mq=(c,h,y)=>P.selection.status!=="ready"?!1:Um(c)?.scope==="id"||!h||h.disposition!=="routed"?!0:h.inline?.kind==="clear"?Kr(P.selection).length>0||dd(P.selection)!=null:h.inline?dd(P.selection)!=null||ac(P.selection):h.blockParagraph||h.list?Kr(P.selection).length>0:h.link?pq(y)||z0(P.selection).length>0||$i(P.selection)!=null||ie(h,M(),P.selection):!0,gq=(c,h)=>{const y=Um(c),_=nd(c);return y?.scope==="id"&&Og(h)||y?.scope!=="id"&&!hq(_)?!1:!mq(c,_,h)},vq=(c,h)=>gq(c,h)?Yc().then(()=>{}):null,yq=(c,h,y)=>{if(kt=null,$o=Promise.resolve(!1),N)return!1;const _=It.get(c);if(_)try{const De=_.execute(Kc(h,y));return ro(De)}catch{return!1}const E=N_(c);if(E){if(Xn()==="viewing")return!1;if(typeof ye()?.lists?.apply=="function")return uc(E,h)}const D=Um(c);if(D)return iu(D,h);if(c==="copy-format")return ro(bq());const V=nd(c);if(!V||V.disposition!=="routed")return!1;const ne=V.normalizePayload?V.normalizePayload(h):h;if(V.instanceRoute){if(!b()||!Zr(V,ne))return!1;const De=t?.[V.instanceRoute];if(typeof De!="function")return!1;try{const Ye=V.fixedArg!==void 0?V.fixedArg:ne,Ze=De.call(t,Ye);return ro(Ze)}catch{return!1}}if(V.inline?.kind==="clear")return V.mutates&&Xn()==="viewing"?!1:ro(eq());const le=V.docRoute;if(!le||V.mutates&&Xn()==="viewing")return!1;const xe=M(),je=Sr(xe,le);if(!je)return!1;if(V.inline){const{lockModesById:De}=da(xe?.contentControls,P.selection);if(xr(De))return!1;const Ye=dd(P.selection);if(!Ye)return ac(P.selection)?ro(JK(V,ne)):ro(!1);const Ze=ie(V,xe,P.selection),Xe=uF(V.inline,Ye,ne,Ze);if(!Xe)return!1;let Ge=null;try{const rt=b(),lt=rt?.doc,We=Xn(),wt=()=>b()!==rt||rt?.doc!==lt||Xn()!==We?!1:$1(le,je,Xe),Rt=Wa(P.selection)??Mc(P.selection),an=V.inline.kind==="toggle"?Bd(`${V.id}:${Rt}`,wt):null;Ge=an?.release??null;const un=an?an.result:wt(),En=KK(V,P.selection,Xe,un),io=WK(V,P.selection,Xe,un),Bi=ro(io,as=>{qK(V,En,as),Ge?.(),Ge=null});return V.inline.kind==="toggle"&&(vr=$o),Bi}catch{return Ge?.(),!1}}if(V.blockParagraph){const De=tq(V,je,ne),Ye=V.blockParagraph.kind==="alignment"&&mo(De)?bn(P.selection,ne):null;return ro(De,Ze=>{Tr(Ye,Ze)})}if(V.list){const De=rq(V,je);return ro(De)}if(V.link){const De=sq(ne);return ro(De)}if(V.create){const De=aq(V,je,ne);return ro(De)}if(V.field){if(Ut)return!1;const De=ro(cq(V)),Ye=$o;return Ut=Ye,Ye.finally(()=>{Ut===Ye&&(Ut=null)}),De}if(V.pageNumbers){if(vn)return!1;const De=ro(uq(V,ne)),Ye=$o;return vn=Ye,Ye.finally(()=>{vn===Ye&&(vn=null)}),De}if(V.table){const De=fq(V,je);return ro(De)}try{return ro(V.mutates?bo(le,je,ne):je(ne))}catch{return!1}},H1=(c,h,y,_)=>{const E=Jx(t,"command:started",()=>({commandId:c,selection:P.selection}));let D;const V=x;x=_&&!It.has(c)?H():void 0;try{D=yq(c,h,y)}catch(le){throw Wd(t,"command:settled",()=>({actionId:E,commandId:c,outcome:"threw"})),le}finally{x=V}const ne=le=>Wd(t,"command:settled",()=>({actionId:E,commandId:c,outcome:mo(le)?"succeeded":"rejected",result:le}));if(D===!1)ne(D);else try{$o.then(ne,()=>ne(!1))}catch{}return D},Gh=(c,h,y)=>H1(c,h,y,!1),Bg=()=>{g+=1,m=null,p={mode:"idle",snapshot:null,sourceSelectionKey:null,lastClickAt:p.lastClickAt,pointerSelecting:!1,keyboardSelecting:!1};for(const c of v)c("idle");$t()},bq=async()=>{const c=x??null,h=["bold","italic","underline","strikethrough"].filter(De=>P.toolbar.commands[De]?.active===!0),y=await vr;await d;const _=mo(y)?h:[],E=500,D=Date.now();if(p.mode!=="idle"){if(p.mode==="armed"&&D-p.lastClickAt<E){p={...p,mode:"persistent",lastClickAt:D};for(const De of v)De("persistent");return $t(),!0}return Bg(),!1}const V=D-p.lastClickAt<E,ne=++g;p={...p,lastClickAt:D};const le=await Yc(),xe=`${Mc(le)}:${sn()}`,je=await wq(null,le,xe&&xe===w?C:void 0,_);if(ne!==g)return!0;p={...p,mode:V?"persistent":"armed",snapshot:je,sourceSelectionKey:Mc(le),lastClickAt:D},m=c;for(const De of v)De(p.mode);return $t(),!0},wq=async(c,h,y,_=[])=>{const E=h?.target??c?.target;if(!E||E.kind!=="text")return null;const D=Array.isArray(E.segments)?E.segments:[];if(D.length===0)return null;const V=M();if(!V)return null;const ne=E.story;let le=null;for(const Xe of D){const Ge=(await ic(_o(Xe.blockId,ne)))?.node??null;if(!Ge)continue;const rt=G1(Ge),lt=Array.isArray(rt?.inlines)?rt.inlines:[],We=Cq(lt,Xe.range);le?le=rx(le,We):le=We}const xe=le?j9(le):{},je={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strike"},De=new Set([...h?.activeMarks??(Array.isArray(c?.activeMarks)?c.activeMarks:[]),..._]);for(const[Xe,Ge]of Object.entries(je))De.has(Xe)&&(xe[Ge]=!0);const Ye=y??await Fh(h??la(c,"ready"));if(Ye.fontFamily&&(xe.fontFamily=Ye.fontFamily),Ye.color&&(xe.color=Ye.color),Ye.highlight&&(xe.highlight=Ye.highlight),Ye.fontSize){const Xe=Number.parseFloat(Ye.fontSize);Number.isNaN(Xe)||(xe.fontSize=Xe)}let Ze=null;if(D.length===1){const Xe=D[0],Ge=(await ic(_o(Xe.blockId,ne)))?.node??null;Ge&&G1(Ge)&&(Ze=await kq(Ge,Xe.blockId,V,ne))}return{story:ne??null,inline:xe,paragraph:Ze}},G1=c=>c?c.kind==="paragraph"?c.paragraph??null:c.kind==="heading"?c.heading??null:null:null,Cq=(c,h)=>{const y=V=>{const ne=V.run;return typeof ne?.text=="string"?ne.text:""},_=V=>V.run?.props;if(h.start===h.end){let V=0;for(const ne of c){const le=y(ne),xe=V,je=V+le.length;if(V=je,h.start>=xe&&h.start<=je){const De=_(ne);return De?{...De}:{}}}return{}}let E=0;const D=[];for(const V of c){const ne=y(V),le=E,xe=E+ne.length;if(E=xe,xe<=h.start||le>=h.end)continue;const je=_(V);je&&D.push(je)}return D.length===0?{}:D.length===1?{...D[0]}:rx(D[0],...D.slice(1))},rx=(c,...h)=>{const y={...c};for(const _ of h)for(const E of Object.keys(y)){if(!(E in _)){delete y[E];continue}const D=y[E],V=_[E];(typeof D!=typeof V||JSON.stringify(D)!==JSON.stringify(V))&&delete y[E]}return y},kq=async(c,h,y,_)=>{const E=G1(c),D=E.props??{},V=E.styleRef??null,ne=D.alignment??null,le=D.spacing??null,xe=D.indent??null,je=xe?{...xe.left!=null?{left:xe.left}:{},...xe.right!=null?{right:xe.right}:{},...xe.firstLine!=null?{firstLine:xe.firstLine}:{},...xe.hanging!=null?{hanging:xe.hanging}:{}}:null,De=D.markRunProps??null,Ye=D.numbering?.numId,Ze=typeof Ye=="string"?parseInt(Ye,10):typeof Ye=="number"?Ye:NaN,Xe=D.numbering?.level,Ge=isNaN(Ze)?null:{numId:Ze,...Xe!=null?{level:Xe}:{}};let rt=null;if(Ge&&typeof y.lists?.getState=="function")try{const lt=await y.lists.getState({target:_o(h,_)});lt&&typeof y.lists?.getStyle=="function"&&(rt=await y.lists.getStyle(lt)??null)}catch{}return{styleId:V,alignment:ne,spacing:le,indentation:je,markRunProps:De,numbering:Ge,listStyle:rt}},ox=async()=>{if(p.mode==="idle"||p.pointerSelecting||p.keyboardSelecting)return;const c=M()?.selection,h=async()=>{const V=typeof c?.current=="function"?await Promise.resolve(c.current({includeText:!0})):el().value;return Qi(V)},y=()=>new Promise(V=>setTimeout(V,16)),_=8;let E=null,D="";for(let V=0;V<_;V+=1){if(V>0&&await y(),p.mode==="idle"||p.pointerSelecting||p.keyboardSelecting)return;if(E=await h(),!(!E||E.empty)&&(D=Mc(E),D!==p.sourceSelectionKey))break}if(E&&!E.empty&&D!==p.sourceSelectionKey){await ix(E);return}if(p.snapshot?.paragraph){const V=await h();if(!V||Mc(V)===p.sourceSelectionKey)return;await ix(V)}},ix=async c=>{const h=p.snapshot;if(!h){p.mode==="armed"&&Bg();return}const y=m??M();if(!y)return;const _=la(c,"ready"),{lockModesById:E}=da(y.contentControls,_);if(xr(E)){$t();return}const D=c.target,V=c.selectionTarget;if(c.empty!==!0&&Object.keys(h.inline).length>0){const ne=Sr(y,"format.apply");if(ne&&V)try{if(!mo(ra(await Promise.resolve($1("format.apply",ne,{target:V,inline:h.inline},c))))){$t();return}}catch{$t();return}}if(h.paragraph){const ne=Array.isArray(D?.segments)?D.segments:[],le=D?.story;for(const xe of ne){const je=_o(xe.blockId,le),De=await ic(je),Ye=De?.node??null,Ze=De?.address??null;if(!Ye)continue;const Xe={kind:"block",nodeType:Ze?.nodeType??Ye.kind??"paragraph",nodeId:xe.blockId,...le&&typeof le=="object"?{story:le}:{}},{styleId:Ge,alignment:rt,spacing:lt,indentation:We,markRunProps:wt,numbering:Rt,listStyle:an}=h.paragraph;if(Ge&&await y.styles?.paragraph?.setStyle?.({target:Xe,styleId:Ge}),rt&&await y.format?.paragraph?.setAlignment?.({target:Xe,alignment:rt}),lt){const un=lt,En=un.lineRule??"auto",io=new Set(["auto","exact","atLeast"]).has(En)?En:"auto",Bi={...un.before!=null?{before:Math.round(un.before*20)}:{},...un.after!=null?{after:Math.round(un.after*20)}:{},...un.line!=null?{line:Math.round(io==="auto"?un.line*240:un.line*20),lineRule:io}:{}};await y.format?.paragraph?.setSpacing?.({target:Xe,...Bi})}if(We){const un={...We.left!=null?{left:na(We.left)}:{},...We.right!=null?{right:na(We.right)}:{},...We.firstLine!=null?{firstLine:na(We.firstLine)}:{},...We.hanging!=null?{hanging:na(We.hanging)}:{}};await y.format?.paragraph?.setIndentation?.({target:Xe,...un})}wt&&await y.format?.paragraph?.setMarkRunProps?.({target:Xe,markRunProps:wt}),Rt&&await y.format?.paragraph?.setNumbering?.({target:Xe,...Rt}),an&&((await ic(je))?.address?.nodeType==="listItem"?await y.lists?.applyStyle?.({target:K_(xe.blockId,le),style:an}):Rt&&await y.format?.paragraph?.setNumbering?.({target:Xe,...Rt}))}}p.mode==="armed"&&Bg(),$t()},sx=(c,h,y,_)=>{const E=vq(c,h),D=E?E.then(()=>(H1(c,h,y,_),$o)):(H1(c,h,y,_),$o);return nd(c)?.inline?.kind==="toggle"&&(vr=D),D},zg=(c,h,y)=>sx(c,h,y,!1),Sq=(c,h)=>sx(c,h,void 0,!0),ax=c=>({id:c,getState:()=>P.toolbar.commands[c]??A(c,M(),P.selection,ol(P.selection)),observe:h=>Ps(y=>y.toolbar.commands[c]??{enabled:!1,active:!1,supported:!1,source:"unsupported",reason:tt.commandUnsupported}).subscribe(h),execute:h=>Gh(c,h),executeAsync:h=>zg(c,h)}),_q=c=>{It.set(c.id,c),$t();const h=()=>{It.delete(c.id),$t()};return Object.assign(h,{handle:ax(c.id),unregister:h})},jg=Ds(c=>c.selection),Vg=os(jg),Ug=()=>{const c=T();if(typeof c?.getHandles!="function")return{reason:tt.hostCapabilityUnavailable};let h=null;try{h=c.getHandles()}catch(E){const D=E?.reason;return{reason:D==="host-not-ready"||D==="host-disposed"||D==="editing-mount-required"?tt.notReady:tt.hostCapabilityUnavailable}}const y=h?.editing?.selectionTargets;if(typeof y?.apply=="function")return{helper:y};const _=h?.selection;return typeof _?.apply=="function"?{helper:_}:{reason:tt.hostCapabilityUnavailable}},Aq=()=>{const c=T();if(typeof c?.getHandles!="function")return null;let h=null;try{h=c.getHandles()}catch{return null}const y=h?.editing?.selection?.toSelectionTarget?.()??h?.selection?.toSelectionTarget?.();if(!y||typeof y!="object"||y.kind!=="ok")return null;const _=y.target;return _&&typeof _=="object"?_:null},Iq=c=>{const h=T();if(typeof h?.getHandles=="function")try{const y=h.getHandles()?.editing?.contentControls;typeof y?.activate=="function"&&y.activate({id:c})}catch{}},W1={get:Vg.get,getSnapshot:Vg.getSnapshot,subscribe:Vg.subscribe,observe:Vg.observe,current:()=>el().value,capture:()=>{const c=jg.get();return c.empty||!c.target&&!c.selectionTarget?null:{...c,capturedAt:Date.now()}},restore:c=>{const h=E=>($t(),{...E,success:E.ok});if(!c||typeof c!="object")return h({ok:!1,reason:tt.targetUnresolved});if(!b())return h({ok:!1,reason:tt.notReady});const y=lF(c);if(!y)return h({ok:!1,reason:tt.targetUnresolved});const _=Ug();if(!("helper"in _))return h({ok:!1,reason:_.reason});try{return h(N0(_.helper.apply(y)))}catch{return h({ok:!1,reason:tt.hostCapabilityUnavailable})}},apply:c=>{if(!b())return{ok:!1,reason:tt.notReady};const h=Ug();if(!("helper"in h))return{ok:!1,reason:h.reason};try{const y=h.helper.apply(c);return $t(),N0(y)}catch{return{ok:!1,reason:tt.hostCapabilityUnavailable}}},placeAroundContentControl:async c=>{if(!b())return{ok:!1,reason:tt.notReady};const h=Ug();if(!("helper"in h))return{ok:!1,reason:h.reason};if(typeof h.helper.placeAroundContentControl!="function")return{ok:!1,reason:tt.hostCapabilityUnavailable};try{const y=await h.helper.placeAroundContentControl(c);return $t(),N0(y)}catch{return{ok:!1,reason:tt.targetUnresolved}}},getAnchorRect:c=>{const h=T();if(typeof h?.getSelectionAnchorRect=="function"){const y=Lt(()=>h.getSelectionAnchorRect(c),null);return y&&typeof y=="object"&&(Number(y.width)>0||Number(y.height)>0)?y:null}return null},getRects:c=>{const h=jg.get(),y=h.selectionTarget??h.target;if(h.empty||!y)return[];const _=Jg.getRect({target:y,relativeTo:c?.relativeTo});return _.found?_.rects:[]}},Eq={get ids(){return al()},has:c=>nd(c)!=null||It.has(c),get:c=>ax(c),execute:Gh,executeAsync:zg,register:_q,getContextMenuItems:c=>{const h=[];for(const y of It.values()){const _=y.contextMenu;_&&Lt(_.when?()=>_.when(c):void 0,!0)&&h.push({id:y.id,label:_.label,group:_.group,order:_.order,invoke:()=>Gh(y.id,void 0,c)})}return h.sort((y,_)=>(y.order??0)-(_.order??0)||y.label.localeCompare(_.label))}},K1=os(Ds(c=>c.toolbar)),xq={get:K1.get,getSnapshot:()=>P.toolbar,subscribe:K1.subscribe,observe:K1.observe,execute:Gh,executeAsync:zg},su=async(c,h)=>{if(!b())return{success:!1,ok:!1,reason:tt.notReady};if(!c)return{success:!1,ok:!1,reason:tt.targetUnresolved};const y=T(),_=y?.scrollTargetIntoView;if(typeof _!="function")return{success:!1,ok:!1,reason:tt.hostCapabilityUnavailable};try{const E={target:c,block:h?.block??"center",behavior:h?.behavior??"smooth"},D=await Promise.resolve(h?.shouldContinue?_.call(y,E,h.shouldContinue):_.call(y,E));return D&&typeof D=="object"&&D.success===!1?{success:!1,ok:!1,reason:Bm(D.reason,tt.targetUnresolved)}:{success:!0,ok:!0}}catch{return{success:!1,ok:!1,reason:tt.hostCapabilityUnavailable}}};let q1=0;ou.push(()=>{q1+=1});const Tq={navigateTo:async(c,h)=>{const y=++q1,_=()=>({success:!1,ok:!1,reason:tt.targetUnresolved}),E=typeof c=="string"?{kind:"entity",entityType:"bookmark",name:c}:c;if(!E||E.kind!=="entity"||E.entityType!=="bookmark"||typeof E.name!="string"||E.name.length===0||E.story!==void 0&&(!E.story||E.story.kind!=="story"||E.story.storyType!=="body"))return _();const D=b();if(!D||N)return{success:!1,ok:!1,reason:tt.notReady};const V=M(),ne=V?.bookmarks;if(typeof ne?.list!="function"||typeof ne?.get!="function")return{success:!1,ok:!1,reason:tt.operationUnavailable};const le=Ug();if(!("helper"in le))return{success:!1,ok:!1,reason:le.reason};const xe=T();if(typeof xe?.scrollTargetIntoView!="function")return{success:!1,ok:!1,reason:tt.hostCapabilityUnavailable};const je=Yh();let De=!0;const Ye=()=>De&&!N&&y===q1&&b()===D&&M()===V&&T()===xe&&Yh()===je,Ze=async()=>{try{const rt=await ne.list.call(ne,E.story?{in:E.story}:{});if(!Ye()||(Array.isArray(rt?.items)?rt.items:[]).filter(En=>En?.name===E.name).length!==1)return _();const lt=await ne.get.call(ne,{target:E});if(!Ye())return _();const We=lt?.range?.from,wt=lt?.range?.to,Rt=En=>typeof En?.blockId=="string"&&En.blockId.length>0&&Number.isInteger(En.offset)&&En.offset>=0;if(lt?.name!==E.name||lt?.address?.story&<.address.story.storyType!=="body"||lt?.tableColumn||!Rt(We)||!Rt(wt)||We.blockId===wt.blockId&&We.offset>wt.offset)return _();const an=await su({kind:"text",segments:[{blockId:We.blockId,range:{start:We.offset,end:We.offset}}]},{block:h?.block??"center",behavior:h?.behavior??"instant",shouldContinue:Ye});if(!Ye())return _();if(!an.ok)return an;const un=W1.apply({kind:"selection",start:{kind:"text",blockId:We.blockId,offset:We.offset},end:{kind:"text",blockId:wt.blockId,offset:wt.offset}});return{...un,success:un.ok}}catch{return _()}};let Xe;const Ge=new Promise(rt=>{Xe=setTimeout(()=>{De=!1,rt(_())},15e3)});try{return await Promise.race([Ze(),Ge])}finally{De=!1,clearTimeout(Xe)}}},lx=c=>{if(!c||typeof c!="object")return null;const h=c,y=h.wordRevisionIds&&typeof h.wordRevisionIds=="object"?h.wordRevisionIds:null,_=h.sourceIds&&typeof h.sourceIds=="object"?h.sourceIds:null,E=Array.isArray(_?.wordIdOther)?_.wordIdOther:void 0,D=y?.insert??y?.delete??y?.format??_?.wordIdInsert??_?.wordIdDelete??E?.[0];return typeof D=="string"&&D.length>0?D:null},cx=async(c,h,y,_,E)=>{const D=await su(h,E);if(D.ok)return D;const V=z(),ne=V?.focusTrackedChange;if(typeof ne!="function")return D;const le=y||_?{commentId:c,...y?{trackedChangeStory:y}:{},..._?{importedId:_}:{}}:c;try{const xe=await Promise.resolve(ne.call(V,le));if(xe&&typeof xe=="object"&&xe.ok===!0)return{success:!0,ok:!0}}catch{}return D},$g=async(c,h,y,_)=>{const E=c==="trackChanges"?_?.story:void 0,D=c==="trackChanges"?_?.matchStory??E:void 0,V=We=>{if(!E||!We||typeof We!="object")return We;const wt=We,Rt=wt.address&&typeof wt.address=="object"?wt.address:null;return wt.story||Rt?.story?We:{...wt,story:E}},ne=c==="trackChanges"?z_:Jf,le=y.find(We=>Ti(We,h,D)),xe=le&&typeof le=="object"?le:null,je=c==="trackChanges"&&xe?.type==="move"&&(xe.subtype==="move-to"||xe.subtype==="move-from")?xe.subtype:null,De=je&&typeof xe?.trackedChangeCanonicalId=="string"?xe.trackedChangeCanonicalId:h,Ye=We=>{if(!je)return c==="trackChanges"?z_(We,{preferStableBlock:!0}):ne(We);const wt=Jf(We);if(wt?.kind!=="move")return null;const Rt=je==="move-to"?wt.destination:wt.source;return B0(Rt)?Rt:null},Ze=ne(le),Xe=c!=="trackChanges"||!je&&B0(Jf(le));if(Ze&&Xe)return V(Ze);const Ge=M()?.[c],rt=c==="comments"?{commentId:h}:{id:De,...E?{story:E}:{}},lt=Ge?.get;if(typeof lt!="function")return V(Ze);try{return V(Ye(await Promise.resolve(lt.call(Ge,rt)))??Ze)}catch{return V(Ze)}};function ux(c,h){if(tc())return er("Comments are read-only.","DOCUMENT_READONLY");if(qc())return er("Resolving comments is disabled.","DOCUMENT_READONLY");const y=M()?.comments,_=y?.patch;if(typeof _!="function")return er("comments.patch is unavailable.");const E=er("comments.patch failed.");return Lt(()=>dc(_.call(y,{commentId:c,status:h}),E),E)}const Wh=()=>tc()?er("Comments are read-only.","DOCUMENT_READONLY"):null,Rq=(c,h)=>{const y=h&&typeof h=="object"?h:null;let _=Array.from(c);y?.includeResolved===!1&&(_=_.filter(le=>le.status!=="resolved"));const E=Number(y?.offset),D=Number.isInteger(E)&&E>0?E:0,V=Number(y?.limit),ne=Number.isInteger(V)&&V>=0?D+V:void 0;return _.slice(D,ne)},jd=Ds(c=>c.comments),Hg=jh(jd,Ps(c=>Cd(c.selection,c.comments)),"comments"),Mq={get:Hg.get,getSnapshot:Hg.getSnapshot,subscribe:Hg.subscribe,observe:Hg.observe,list:c=>{to();const h=Xc();return Rq(h.value??jd.get().items,c)},getById:c=>{const h=jd.get().items.find(E=>Ur(E)===c)??null;if(h)return h;const y=M()?.comments,_=Lt(y?.get?()=>y.get({commentId:c}):void 0,null);return kr(_)?null:_},createFromCapture:(c,h)=>{const y=Wh();if(y)return y;const _=M()?.comments,E=_?.create;if(typeof E!="function")return er("comments.create is unavailable.");const D=er("comments.create failed.");return Lt(()=>{const V=c&&typeof c=="object"?c.target??c.selectionTarget:null;return V==null?er("A range selection is required to comment.","NO_SELECTION"):dc(E.call(_,{target:V,text:h.text}),D)},D)},createFromSelection:c=>{const h=Wh();if(h)return h;const y=M()?.comments,_=y?.create;if(typeof _!="function")return er("comments.create is unavailable.");const E=jg.get();let D=E.target??E.selectionTarget;if(E.empty||!D){const ne=Aq();ne&&(D=ne)}if(!D)return er("A range selection is required to comment.","NO_SELECTION");const V=er("comments.create failed.");return Lt(()=>dc(_.call(y,{target:D,text:c.text}),V),V)},reply:(c,h)=>{const y=Wh();if(y)return y;const _=M()?.comments,E=_?.reply??_?.create;if(typeof E!="function")return er("comments.reply is unavailable.");const D=er("comments.reply failed.");return Lt(()=>dc(E===_?.reply?E.call(_,{parentCommentId:c,text:h.text}):E.call(_,{parentCommentId:c,text:h.text}),D),D)},edit:(c,h)=>{const y=Wh();if(y)return y;const _=M()?.comments,E=_?.patch;if(typeof E!="function")return er("comments.patch is unavailable.");const D=er("comments.patch failed.");return Lt(()=>dc(E.call(_,{commentId:c,text:h.text}),D),D)},resolve:c=>ux(c,"resolved"),reopen:c=>ux(c,"active"),delete:c=>{const h=Wh();if(h)return h;const y=M()?.comments,_=y?.delete??y?.remove;if(typeof _!="function")return er("comments.delete is unavailable.");const E=er("comments.delete failed.");return Lt(()=>dc(_.call(y,{commentId:c}),E),E)},setActive:c=>{if(c==null)return Le=null,$t(),!0;if(!b())return!1;const h=jd.get(),y=Se.get("comments"),_=y?.token===sn()&&y.hasSettled&&Array.isArray(y.value)?y.value:null,E=_??h.items;if(!_&&h.listStatus!=="ready")return!1;const D=$O(E,c);return!D||!E.some(V=>Ur(V)===D)?!1:(Le=D,$t(),!0)},scrollTo:async c=>{if(!M())return{success:!1,ok:!1,reason:b()?tt.documentApiUnavailable:tt.notReady};const h=await $g("comments",c,jd.get().items);return h?su(h):{success:!1,ok:!1,reason:tt.targetUnresolved}}},is=Ds(c=>c.trackChanges),Y1=(c,h)=>{eo();const y=(ua().value??is.get().items).map(cd).filter(De=>De!=null&&Ur(De)!==null);if(y.length===0)return null;const _=P.trackChanges.activeId,E=oe?.id===_?oe.story:void 0,D=y.filter(De=>th(De)==null),V=E||D.length===0?y:D;let ne=_?V.findIndex(De=>Ti(De,_,E)):-1;ne===-1&&_&&E&&(ne=V.findIndex(De=>Ti(De,_)));const le=V[ne===-1?c>0?0:V.length-1:(ne+c+V.length)%V.length],xe=Ur(le),je=th(le);return ae(je?{id:xe,story:je}:{id:xe},h),$t(),xe},dx=async c=>{const h=z(),y=h?.listTrackedChanges;if(typeof y=="function")try{await Promise.resolve(y.call(h,{mode:"visible-window",targetIds:[c],refreshReason:"ui-track-change-reveal-restamp",blocking:!0}))}catch{}};let fx=Promise.resolve();const Lq=c=>{const h=Q;return fx.catch(()=>{}).then(()=>Pq(c,h))},Pq=async(c,h)=>{if(Q!==h)return{success:!1};const y=oe,_=Y1(c,{invalidateQueuedNavigation:!1});if(_==null)return{success:!1};const E=oe,D=we,V=()=>Q===h&&oe===E&&we===D,ne=()=>{V()&&(ae(y,{invalidateQueuedNavigation:!1}),$t())};E&&re.add(E);try{const le=await $g("trackChanges",_,is.get().items,E?.story?{story:E.story}:void 0);if(!V())return{success:!1};if(!le)return ne(),{success:!1};const xe=is.get().items.find(De=>Ti(De,_,E?.story))??is.get().items.find(De=>Ur(De)===_),je=lx(xe);pn+=1;try{const De=await cx(_,le,E?.story,je,{behavior:"auto",shouldContinue:V});if(!V())return{success:!1};if(!De.ok&&De.reason!==tt.targetNotVisible)ne(),K(y);else{if(De.ok&&await dx(_),!V())return{success:!1};K(E)}return{success:De.ok}}finally{pn=Math.max(0,pn-1),pn===0&&(V()?Di&&Ln(cn(Di)):K(oe))}}finally{E&&re.delete(E)}},hx=c=>{const h=Lq(c);return fx=h.then(()=>{},()=>{}),h},Gg=jh(is,Ps(c=>eu(c.selection,c.trackChanges)),"trackChanges"),Dq={get:Gg.get,getSnapshot:Gg.getSnapshot,subscribe:Gg.subscribe,observe:Gg.observe,list:()=>{eo();const c=ua().value??is.get().items,h=ln(sn());return c.map(cd).filter(y=>y!=null).filter(y=>{const _=Ur(y);return!_||!h?.has(_)})},accept:c=>Kh("accept",c),acceptAsync:c=>Wg(()=>Kh("accept",c)),reject:c=>Kh("reject",c),rejectAsync:c=>Wg(()=>Kh("reject",c)),acceptAll:()=>au("accept",{kind:"all"},null),acceptAllAsync:()=>Wg(()=>au("accept",{kind:"all"},null)),rejectAll:()=>au("reject",{kind:"all"},null),rejectAllAsync:()=>Wg(()=>au("reject",{kind:"all"},null)),next:()=>Y1(1),previous:()=>Y1(-1),navigateNext:()=>hx(1),navigatePrevious:()=>hx(-1),getAt:c=>{if(!c||typeof c!="object"||typeof c.x!="number"||typeof c.y!="number")return null;const h=e2(c);if(h.length===0)return null;const y=is.get().items;let _;for(const E of h){if(E.type!=="trackedChange")continue;let D;if(E.story){if(_===void 0&&(_=mi()),!_)continue;D=_}else D=y;const V=D.find(ne=>Ti(ne,E.id,E.story));if(V)return E.story?{id:V.id,item:V,story:E.story}:{id:V.id,item:V}}return null},setActive:c=>{if(c==null)return ae(null),K(null),$t(),!0;if(!b())return!1;const h=typeof c=="string"?{id:c}:{id:c.id,story:c.story};if(typeof h.id!="string"||h.id.length===0)return!1;const y=h.id;if(h.story){const _=mi();if(!_)return!1;const E=Fl(_,h.story).toPublicId(h.id)??h.id;if(!_.some(D=>Ti(D,E,h.story)))return!1;h.id=E}else{const _=mi()??is.get().items,E=ta(_).toPublicId(h.id)??h.id,D=_.find(V=>Ur(V)===E);if(!D)return!1;h.id=E,h.story=th(D)}return y!==h.id&&(h.paintedEntityId=y),ae(h),K(h),$t(),!0},scrollTo:async c=>{if(!M())return{success:!1,ok:!1,reason:b()?tt.documentApiUnavailable:tt.notReady};const h=typeof c=="string"?c:c.id,y=typeof c=="string"||!c.story||typeof c.story!="object"?void 0:c.story,_=y?th({address:{story:y}}):void 0;if(typeof h!="string"||h.length===0)return{success:!1,ok:!1,reason:tt.targetUnresolved};Q+=1,I+=1;const E=I,D=y?mi()??is.get().items:is.get().items,V=y?Fl(D,y).toPublicId(h)??h:ta(D).toPublicId(h)??h,ne=y?D.find(Ye=>Ti(Ye,V,y)):D.find(Ye=>Ur(Ye)===V),le=y?_:th(ne),xe=lx(ne),je=oe,De={id:V,...le?{story:le}:{},...V!==h?{paintedEntityId:h}:{}};re.add(De);try{const Ye=await $g("trackChanges",V,D,le||y?{story:le,matchStory:y}:void 0);if(I!==E)return{success:!1,ok:!1};if(!Ye)return{success:!1,ok:!1,reason:tt.targetUnresolved};ae(De);const Ze=I,Xe=oe,Ge=we,rt=()=>I===Ze&&oe===Xe&&we===Ge,lt=()=>{rt()&&(ae(je,{invalidateQueuedNavigation:!1}),$t())};$t(),pn+=1;try{const We=await cx(V,Ye,le,xe,{behavior:"auto",shouldContinue:rt});if(!rt())return{success:!1,ok:!1};if(!We.ok&&We.reason!==tt.targetNotVisible)lt(),K(je);else{if(We.ok&&await dx(V),!rt())return{success:!1,ok:!1};K(De)}return We}finally{pn=Math.max(0,pn-1),pn===0&&(rt()?Di&&Ln(cn(Di)):K(oe))}}finally{re.delete(De)}}},Kh=(c,h)=>{const{id:y,story:_}=typeof h=="string"?{id:h,story:void 0}:h;if(typeof y!="string"||y.length===0)return!1;const E={kind:"id",id:y,..._?{story:_}:{}};return au(c,E,y,_)},Wg=c=>(kt=null,$o=Promise.resolve(!1),N||c()===!1?Promise.resolve(!1):$o),au=(c,h,y,_)=>{try{return ro(X1(c,h,y,_))}catch{return!1}},X1=(c,h,y,_)=>{if(aa())return!1;const E=M()?.trackChanges,D=h.kind==="all"||h.scope==="all",V=h.kind==="range",ne=h.kind==="ids",le=D?[]:ne&&Array.isArray(h.ids)?h.ids.filter(Ye=>typeof Ye=="string"&&Ye.length>0):y?[y]:[];if(le.length>0&&nu(c,le)||sl({kind:c,scope:D?"all":"id"},E))return!1;if(x){const Ye=T(),Ze=Lt(typeof Ye?.getHandles=="function"?()=>Ye.getHandles():void 0,null)?.trackChanges?.decide;return typeof Ze=="function"?Ze({decision:c,target:h}):!1}const xe=D?`${c}All`:c,je=!V&&!ne&&!_&&E&&typeof E[xe]=="function"?E[xe]:null,De=E&&typeof E.decide=="function"?E.decide:null;return!je&&!De?!1:je?je.call(E,y??{}):De.call(E,{decision:c,target:h})},Kg=Ds(c=>c.contentControls),qh=c=>Kg.get().items.find(h=>h?.id===c)??null,qg=jh(Kg,Ps(c=>(Xr.contentControls>0&&Ie("contentControls"),c.contentControls)),"contentControls"),Oq=(c=>{if(c===void 0)return qg.get();const h=nh(c);return h?qh(h):null}),Fq=os(Kg);let Z1=0,Q1=null;const J1=()=>{Z1+=1;const c=Q1??T();Q1=null,Lt(()=>c?.clearContentControlHighlight?.call(c),void 0)};ou.push(J1);const Nq={clearHighlight:J1,highlight:async c=>{const h=nh(c);if(!h)return{success:!1,reason:"invalid-id"};const y=T(),_=b(),E=M()?.contentControls;if(N||!y||typeof y.highlightContentControl!="function"||typeof E?.list!="function")return{success:!1,reason:"not-ready"};const D=++Z1;Q1=y,Lt(()=>y.cancelContentControlHighlightRequest?.call(y),void 0);const V=()=>N||D!==Z1||_!==b();try{const ne=await E.list.call(E);if(V())return{success:!1,reason:"cancelled"};const le=ne?.items?.find(De=>De.id===h);if(!le)return{success:!1,reason:"not-found"};const xe=zm(le);if(!xe||le.isEmpty)return{success:!1,reason:"not-reachable"};const je=await y.highlightContentControl.call(y,h,xe);return V()?{success:!1,reason:"cancelled"}:je?{success:!0}:{success:!1,reason:"not-reachable"}}catch{return{success:!1,reason:V()?"cancelled":"not-reachable"}}},get:(c=>(c!==void 0&&Dn("api"),Oq(c))),getSnapshot:qg.getSnapshot,subscribe:qg.subscribe,observe:qg.observe,observeActivePath:Fq.observe,list:()=>(Dn("api"),Kg.get().items),getById:c=>(Dn("api"),qh(c)),getRect:c=>{const h=nh(c);if(!h)return Nl("unresolved");Dn("panel");const y=qh(h);if(!y)return Nl("unresolved");const _=zm(y);return _?Jg.getRect({target:_}):Nl("unavailable")},scrollIntoView:async c=>{const h=nh(c);if(!h)return{success:!1};Dn("panel");const y=qh(h);if(!y)return{success:!1};const _=zm(y);return _?{success:(await su(_,{block:c.block,behavior:c.behavior})).ok}:{success:!1}},focus:async c=>{const h=nh(c);if(!h)return{success:!1,reason:"invalid-id"};if(!b())return{success:!1,reason:"not-ready"};Dn("panel");const y=qh(h);if(!y)return{success:!1,reason:"not-found"};const _=zm(y);if(!_)return{success:!1,reason:"not-reachable"};if(!(await su(_,{block:c.block,behavior:c.behavior})).ok)return{success:!1,reason:"not-reachable"};const E=FO(_);if(!E)return{success:!1,reason:"not-reachable"};const D=W1.apply(E);return!D.ok&&D.reason!==tt.hostCapabilityUnavailable?{success:!1,reason:"not-reachable"}:(Iq(h),{success:!0})}},Yg=os(Ds(c=>c.fonts)),px={get:Yg.get,getSnapshot:Yg.getSnapshot,subscribe:Yg.subscribe,observe:Yg.observe,getFamilyOptions:()=>P.fonts.options,getSizeOptions:()=>P.fonts.sizeOptions},Xg=os(Ds(c=>c.zoom)),Bq={get:Xg.get,getSnapshot:Xg.getSnapshot,subscribe:Xg.subscribe,observe:Xg.observe,set:c=>{if(typeof t?.setZoom=="function")try{t.setZoom(c),$t()}catch{}},setMode:c=>{if(typeof t?.setZoomMode=="function")try{t.setZoomMode(c),$t()}catch{}}},Zg=os(Ds(c=>c.document)),zq={get:Zg.get,getSnapshot:Zg.getSnapshot,subscribe:Zg.subscribe,observe:Zg.observe,setMode:c=>{if(typeof t?.setDocumentMode=="function")try{t.setDocumentMode(c),$t()}catch{}},export:c=>{if(typeof t?.export=="function")try{return Promise.resolve(t.export(c))}catch{return}},getText:()=>{const c=M(),h=Lt(c?.getText?()=>c.getText({}):void 0,null);return typeof h=="string"?h:h&&typeof h=="object"&&typeof h.text=="string"?h.text:null},replaceDocument:async c=>{const h=e.superdoc;return typeof h.replaceDocument!="function"?{ok:!1,reason:tt.operationUnavailable}:h.replaceDocument(c)},replaceFile:c=>{const h=t?.replaceFile??t?.loadDocument??t?.reload;if(typeof h=="function")try{return Promise.resolve(h.call(t,c))}catch{return}}},mx=()=>{if(typeof HTMLElement>"u")return null;const c=b()?.mount?.container;if(c instanceof HTMLElement)return c;const h=t?.element;return h instanceof HTMLElement?h:null},jq=(c,h)=>{if(typeof c!="number"||typeof h!="number"||!Number.isFinite(c)||!Number.isFinite(h))return[];const y=globalThis.document;if(!y||typeof y.elementFromPoint!="function")return[];const _=mx();if(!_)return[];const E=y.elementFromPoint(c,h);if(!E||!_.contains(E))return[];const D=[E],V=We=>{We&&_.contains(We)&&!D.includes(We)&&D.push(We)},ne=y.elementsFromPoint;if(typeof ne=="function"){let We=[];try{We=ne.call(y,c,h)??[]}catch{We=[]}for(const wt of We)V(wt)}const le=[],xe=We=>{We&&_.contains(We)&&!le.includes(We)&&!D.includes(We)&&le.push(We)},je=We=>{const wt=We.getBoundingClientRect;if(typeof wt!="function")return!1;let Rt;try{Rt=wt.call(We)}catch{return!1}return Rt!=null&&c>=Rt.left&&c<=Rt.right&&h>=Rt.top&&h<=Rt.bottom};for(const We of D){const wt=We.querySelectorAll;if(typeof wt!="function")continue;let Rt;try{Rt=wt.call(We,"[data-track-change-marker]")}catch{continue}for(let an=0;an<Rt.length;an+=1)je(Rt[an])&&xe(Rt[an])}le.reverse();const De=[...le,...D],Ye=P_(De[0],_);for(let We=1;We<De.length;We+=1)for(const wt of P_(De[We],_))Ye.push(wt);if(Ye.length===0)return Ye;const Ze=is.get().items,Xe=ta(Ze);let Ge;const rt=new Set,lt=[];for(const We of Ye){if(We.type!=="trackedChange"){const un=We.type==="contentControl"?j_(We.story):void 0,En=We.type==="contentControl"?W_(un)?un:V_(We.storyKey)??un:void 0,io=`${We.type}:${We.id}:${JSON.stringify(En??null)}`;if(rt.has(io))continue;if(rt.add(io),We.type==="contentControl"){const{storyKey:Bi,story:as,...wo}=We;lt.push(En?{...wo,story:En}:wo)}else lt.push(We);continue}const wt=V_(We.storyKey)??j_(We.story);let Rt;if(wt){if(Ge===void 0&&(Ge=mi()),!Ge||(Rt=Fl(Ge,wt).toPublicId(We.id),!Rt||!Ge.some(un=>Ti(un,Rt,wt))))continue}else if(Rt=Xe.toPublicId(We.id),!Rt)continue;const an=`trackedChange:${Rt}`;rt.has(an)||(rt.add(an),lt.push(wt?{type:"trackedChange",id:Rt,story:wt}:{type:"trackedChange",id:Rt}))}return lt};function e2(c,h){return typeof c=="object"?jq(c?.x,c?.y):null}function gx(c){const h=!!c&&typeof c.x=="number"&&typeof c.y=="number",y=h?{x:c.x,y:c.y}:{x:0,y:0};return{point:y,entities:h?e2(y):[],selection:P.selection,position:null,insideSelection:!1}}const Vd=new Set;let t2=!1;const vx=c=>{const h=T();if(typeof h?.observeGeometry!="function")return;let y=!1;const _=Lt(()=>{const E=h.observeGeometry(()=>c.schedule());return y=!0,E},null);c.detach=typeof _=="function"?_:null,c.boundHost=y?h:null},Qg=c=>{if(c.detach){try{c.detach()}catch{}c.detach=null}c.boundHost=null},yx=()=>{if(t2=!1,!(N||T()))for(const c of Vd)Qg(c)},Vq=()=>{if(!t2){if(t2=!0,typeof queueMicrotask=="function"){queueMicrotask(yx);return}Promise.resolve().then(yx)}},Uq=()=>{const c=T();if(!c){Vq();return}for(const h of Vd)h.boundHost&&h.boundHost===c||(Qg(h),vx(h),h.schedule())};ul.push(Uq);const Jg={getRect:c=>{const h=T(),y=h?.getTargetRects;if(typeof y=="function"){const _=Lt(()=>y.call(h,{target:c.target}),null);return _&&typeof _=="object"?_.success===!0&&Array.isArray(_.rects)?sF(iF(_.rects.filter(E=>E!=null&&typeof E=="object")),c.relativeTo):Nl(typeof _.reason=="string"?_.reason:"unresolved"):Nl("unresolved")}return Nl("unavailable")},observe:c=>{const h=[];let y=0;const _=typeof requestAnimationFrame=="function",E=()=>{if(!_){c();return}y||(y=requestAnimationFrame(()=>{y=0,c()}))},D=Ps(ne=>({ready:ne.ready,selection:ne.selection,zoom:ne.zoom}));h.push(D.subscribe(()=>E()));const V={schedule:E,detach:null,boundHost:null};return vx(V),Vd.add(V),()=>{Vd.delete(V),Qg(V),y&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(y);for(const ne of h.splice(0))try{ne()}catch{}}},getHost:()=>mx(),entityAt:e2,contextAt:gx,scrollIntoView:async c=>{const h=c?.target;if(!h)return{success:!1};let y=null;if(h.kind==="entity"){const _=h.entityType==="comment"?"comments":"trackChanges",E=_==="comments"?jd.get().items:is.get().items,D=h.entityType==="trackedChange"&&h.story?{story:h.story}:void 0;y=await $g(_,h.entityId,E,D)}else{const _=h,E=h,D=Array.isArray(_.segments)&&_.segments.length>0?_.segments:E.blockId&&E.range?[{blockId:E.blockId,range:E.range}]:null;if(D){const V=h.story;y={kind:"text",segments:D,...V?{story:V}:{}}}}return y?{success:(await su(y,{block:c.block??"center",behavior:c.behavior??"smooth"})).ok}:{success:!1}}},bx=c=>{const h=(c&&typeof c=="object"?c:null)?.target;return h&&typeof h=="object"?h:null},wx=c=>`metadata:resolve:${c}`,Yh=()=>{const c=T(),h=typeof c?.getLocalMutationRevision=="function"?Lt(()=>c.getLocalMutationRevision(),null):null;return`${sn()}|local:${typeof h=="number"?h:"unknown"}`},$q=c=>{const h=M()?.metadata;if(!h||typeof h.resolve!="function")return null;const{value:y,status:_}=Eo(wx(c),Yh(),()=>h.resolve({id:c}),bx);return _==="ready"?y:null},Hq=async c=>{const h=M()?.metadata;if(!h||typeof h.resolve!="function")return null;try{const y=Yh(),_=await Promise.resolve(h.resolve({id:c}));if(y!==Yh())return null;const E=bx(_);return Se.set(wx(c),{token:y,value:E,hasSettled:!0,inflightToken:null}),E}catch{return null}},Gq={getRect:c=>{const h=M()?.metadata;if(!h||typeof h.resolve!="function")return Nl("unavailable");const y=$q(c.id);return y?Jg.getRect({target:y}):Nl("unresolved")},scrollIntoView:async c=>{const h=await Hq(c.id);return h?{success:(await su(h,{block:c.block,behavior:c.behavior})).ok}:{success:!1}}},Wq={inTable:!1,tableNodeId:null,rowIndex:null,columnIndex:null,cellNodeId:null,rows:null,columns:null},Kq={getContext:()=>{const c=ft();if(!c)return{...Wq};const h=ct()?.table;return{inTable:!0,tableNodeId:c.tableNodeId,rowIndex:c.rowIndex,columnIndex:c.columnIndex,cellNodeId:c.cellNodeId,rows:typeof h?.rows=="number"?h.rows:null,columns:typeof h?.columns=="number"?h.columns:null}},isInTable:()=>ft()!=null},ev={query:"",total:0,activeIndex:-1,open:!1,available:!1,caseSensitive:!1,includeTrackedDeletions:!1,includeDeletedText:!1,regex:!1,canReplace:!1,canReplaceAll:!1,reason:tt.searchUnavailable};let Yt={...ev};const tv=new Set,va=()=>{const c=T()?.search;return c&&typeof c=="object"?c:null},Fi=()=>{const c=ye()?.search;return c&&typeof c=="object"?c:null},Xh=()=>{const c=va();if(c&&typeof c.setSession=="function")return!0;const h=Fi();return!!h&&typeof h.query=="function"&&typeof h.getState=="function"},Ni=()=>{for(const c of[...tv])try{c(Yt)}catch{}},To=c=>{Yt={...Yt,...c};const h=c.includeTrackedDeletions??c.includeDeletedText;return h!==void 0&&(Yt.includeTrackedDeletions=h,Yt.includeDeletedText=h),Ni(),Yt};let Wn=0,Fs=null,ss=null,lu=null,Ud=null;const Zh=()=>{const c=Ud;Ud=null,c&&Lt(()=>c(),null)},Cx=()=>{const c=lu;lu=null,c&&Lt(()=>(c(),null),null)},qq=()=>{ss=null,Wn+=1,Fs=null,dl=!1,Zh(),Cx();const c=Xh();Yt={...ev,available:c,reason:c?void 0:tt.searchUnavailable},Ni()};ou.push(qq),Nh.push(()=>{if(Fs===Wn)return;const c=Yt,h=Ns();(h.canReplace!==c.canReplace||h.canReplaceAll!==c.canReplaceAll||h.available!==c.available||h.reason!==c.reason)&&Ni()});const Yq=c=>{if(!c)return!1;const h=c.queryError;if(h&&typeof h=="object"&&h.code==="invalid-pattern")return!0;const y=c.rejection;return c.status==="rejected"&&!!y&&typeof y=="object"&&y.code==="invalid-pattern"},n2=(c,h=!1,y=h)=>{const _=c&&typeof c=="object"?c:null;if(!_)return null;const E=Array.isArray(_.matches)?_.matches:[],D=typeof _.total=="number"&&Number.isFinite(_.total)?_.total:E.length,V=typeof _.activeMatchIndex=="number"?_.activeMatchIndex:typeof _.activeIndex=="number"?_.activeIndex:-1,ne=_.canReplace===!0||h;return{...typeof _.query=="string"?{query:_.query}:{},total:D,activeIndex:V,canReplace:ne,canReplaceAll:ne&&D>0&&_.truncated!==!0&&(_.canReplace===!0||y),...typeof _.caseSensitive=="boolean"?{caseSensitive:_.caseSensitive}:{},...typeof _.includeDeletedText=="boolean"?{includeDeletedText:_.includeDeletedText}:{},..._.regex===!0?{regex:!0}:{},...Yq(_)?{invalidPattern:!0}:{}}};let dl=!1;const r2=()=>{if(!dl)return;dl=!1;const c=Fi();c&&typeof c.query=="function"&&Lt(()=>c.query({query:""}),null)},Ro=()=>Fs!==Wn&&ve("find.replace")?.enabled===!0,Mo=()=>Fs!==Wn&&ve("find.replaceAll")?.enabled===!0,oo=(c,h=!1,y=h)=>{const _=n2(c,h,y);if(!_){To({total:0,activeIndex:-1,canReplace:!1,canReplaceAll:!1,reason:void 0});return}To({..._.query!==void 0?{query:_.query}:{},total:_.total,activeIndex:_.activeIndex,canReplace:_.canReplace,canReplaceAll:_.canReplaceAll,..._.includeDeletedText!==void 0?{includeDeletedText:_.includeDeletedText}:{},..._.regex!==void 0?{regex:_.regex}:{},reason:_.invalidPattern?tt.searchInvalidPattern:void 0})},Ns=()=>{const c=va();if(c&&typeof c.getState!="function")return Yt={...Yt,available:Xh(),reason:Xh()?void 0:tt.searchUnavailable},Yt;if(!c){const y=Fi();if(y&&typeof y.getState=="function"){const _=n2(Lt(()=>y.getState(),null),Ro(),Mo());if(Fs===Wn)return Yt;if(_)return Yt={...Yt,..._.query!==void 0?{query:_.query}:{},total:_.total,activeIndex:_.activeIndex,canReplace:_.canReplace,canReplaceAll:_.canReplaceAll,available:!0,reason:_.invalidPattern?tt.searchInvalidPattern:void 0,open:Yt.open||!!_.query},Yt}return Yt={...ev,query:Yt.query,caseSensitive:Yt.caseSensitive,includeTrackedDeletions:Yt.includeTrackedDeletions,includeDeletedText:Yt.includeDeletedText},Yt}const h=n2(Lt(()=>c.getState(),null));return h&&(Yt={...Yt,...h.query!==void 0?{query:h.query}:{},total:h.total,activeIndex:h.activeIndex,canReplace:h.canReplace,canReplaceAll:h.canReplaceAll,...h.includeDeletedText!==void 0?{includeDeletedText:h.includeDeletedText}:{},...h.includeDeletedText!==void 0?{includeTrackedDeletions:h.includeDeletedText}:{},...h.regex!==void 0?{regex:h.regex}:{},available:!0,reason:h.invalidPattern?tt.searchInvalidPattern:void 0,open:Yt.open||!!h.query}),Yt},$d=c=>{const h=c&&typeof c=="object"?c:null;if(h?.status==="committed")return{ok:!0};if(h?.status==="rejected"&&h.reason==="read-only")return{ok:!1,reason:tt.documentReadonly};const y=h?.rejection;if(h?.status==="rejected"&&y&&typeof y=="object"&&y.code==="read-only-document")return{ok:!1,reason:tt.documentReadonly};if(h?.status==="rejected"&&h.reason==="truncated")return{ok:!1,reason:tt.searchTruncated};const _=h?.failure;return h?.status==="receipt-failure"&&_&&typeof _=="object"&&_.code==="REVISION_MISMATCH"?{ok:!1,reason:tt.targetUnresolved}:{ok:!1,reason:tt.operationUnavailable}},kx=c=>{const h=Wn;return Ns(),Ni(),kr(c)?Promise.resolve(c).then(y=>(h===Wn&&(Ns(),Ni()),$d(y)),()=>(h===Wn&&To({available:!1,reason:tt.searchUnavailable}),{ok:!1,reason:tt.searchUnavailable})):$d(c)},nv=os({get:()=>Ns(),subscribe:c=>(tv.add(c),()=>tv.delete(c))}),Sx={get:nv.get,getSnapshot:nv.getSnapshot,subscribe:nv.subscribe,observe:nv.observe,open:()=>Xh()?(To({available:!0,open:!0,reason:void 0}),{ok:!0}):(To({available:!1,open:!1,reason:tt.searchUnavailable}),{ok:!1,reason:tt.searchUnavailable}),close:()=>{if(ss=null,Wn+=1,Zh(),lu)Cx();else{const c=va();if(c&&typeof c.clear=="function")Lt(()=>c.clear(),null);else{const h=Fi();h&&typeof h.query=="function"&&Lt(()=>h.query({query:""}),null)}}Yt={...ev,available:Xh(),reason:void 0},Yt.available||(Yt.reason=tt.searchUnavailable),Ni()},find:(c,h)=>{const y=va(),_=!!h?.caseSensitive,E=(h?.includeTrackedDeletions??h?.includeDeletedText)===!0,D=h?.regex===!0;if((!y||typeof y.setSession!="function")&&ss!==null&&ss===Fi()&&Fs!==Wn&&Bs===null&&Yt.open&&Yt.available&&!Yt.reason&&Yt.query===c&&Yt.caseSensitive===_&&Yt.includeDeletedText===E&&Yt.regex===D)return Ns(),Ni(),Yt;ss=null,Bs!==null&&(clearTimeout(Bs),Bs=null);const V=++Wn;if(Zh(),r2(),!y||typeof y.setSession!="function"){const le=Fi();if(le&&typeof le.query=="function"&&typeof le.getState=="function"){Fs=V,To({query:c,caseSensitive:_,includeDeletedText:E,regex:D,total:0,activeIndex:-1,canReplace:!1,canReplaceAll:!1,available:!0,open:!0,reason:void 0}),lu=()=>{le.query({query:""})};const xe=Lt(()=>le.query({query:c,caseSensitive:_,includeDeletedText:E,regex:D}),null);return kr(xe)?(dl=!0,Promise.resolve(xe).then(je=>{V===Wn&&(dl=!1,Fs=null,ss=le,oo(je,Ro(),Mo()))},()=>{V===Wn&&(dl=!1,To({available:!1,reason:tt.searchUnavailable}))}),Yt):(Fs=null,ss=le,oo(xe,Ro(),Mo()),oo(Lt(()=>le.getState(),null),Ro(),Mo()),Yt)}return To({query:c,total:0,activeIndex:-1,available:!1,caseSensitive:_,includeDeletedText:E,regex:D,reason:tt.searchUnavailable})}To({query:c,caseSensitive:_,includeDeletedText:E,regex:D,available:!0,open:!0,reason:void 0}),lu=()=>{typeof y.clear=="function"&&y.clear()};const ne=Lt(()=>y.setSession(c,{caseSensitive:_,includeDeletedText:E,...D?{regex:!0}:{},highlight:!0}),null);if(oo(ne),c.length>0&&Yt.total===0&&Yt.reason!==tt.searchInvalidPattern){const le=Fi();if(le&&typeof le.query=="function"&&typeof le.getState=="function"){const xe=lu;lu=()=>{xe?.(),le.query({query:""})};const je=Lt(()=>le.query({query:c,caseSensitive:_,includeDeletedText:E,regex:D}),null);kr(je)?(dl=!0,Promise.resolve(je).then(De=>{V===Wn&&(dl=!1,oo(De,Ro(),Mo()))},()=>{V===Wn&&(dl=!1,To({available:!1,reason:tt.searchUnavailable}))})):oo(je,Ro(),Mo()),oo(Lt(()=>le.getState(),null),Ro(),Mo())}}return Yt},search:(c,h)=>Sx.find(c,h),next:()=>{const c=va();if(!c||typeof c.next!="function"){const h=Fi();if(!h||typeof h.next!="function"||typeof h.getState!="function")return{ok:!1,reason:tt.searchUnavailable};if(Yt.total===0)return{ok:!1,reason:tt.operationUnavailable};const y=Lt(()=>h.next(),null);if(kr(y)){const _=Wn;Promise.resolve(y).then(E=>{_===Wn&&oo(E,Ro(),Mo())}).catch(()=>{_===Wn&&To({available:!1,reason:tt.searchUnavailable})})}else oo(y,Ro(),Mo());return oo(Lt(()=>h.getState(),null),Ro(),Mo()),{ok:!0}}return Yt.total===0?{ok:!1,reason:tt.operationUnavailable}:(oo(Lt(()=>c.next(),null)),{ok:!0})},previous:()=>{const c=va();if(!c||typeof c.previous!="function"){const h=Fi();if(!h||typeof h.previous!="function"||typeof h.getState!="function")return{ok:!1,reason:tt.searchUnavailable};if(Yt.total===0)return{ok:!1,reason:tt.operationUnavailable};const y=Lt(()=>h.previous(),null);if(kr(y)){const _=Wn;Promise.resolve(y).then(E=>{_===Wn&&oo(E,Ro(),Mo())}).catch(()=>{_===Wn&&To({available:!1,reason:tt.searchUnavailable})})}else oo(y,Ro(),Mo());return oo(Lt(()=>h.getState(),null),Ro(),Mo()),{ok:!0}}return Yt.total===0?{ok:!1,reason:tt.operationUnavailable}:(oo(Lt(()=>c.previous(),null)),{ok:!0})},clear:()=>{ss=null,Wn+=1,Zh(),r2();const c=va();if(c&&typeof c.clear=="function"&&Lt(()=>c.clear(),null),!c||typeof c.clear!="function"){const h=Fi();h&&typeof h.query=="function"&&Lt(()=>h.query({query:""}),null)}To({query:"",total:0,activeIndex:-1,canReplace:!1,canReplaceAll:!1,reason:void 0})},replace:c=>{const h=va();if(!h){const _=Fi();if(!_||typeof _.replace!="function"||typeof _.getState!="function")return{ok:!1,reason:tt.searchUnavailable};if(!Ro())return{ok:!1,reason:tt.operationUnavailable};const E=Lt(()=>_.replace({replacement:typeof c=="string"?c:""}),null);if(kr(E)){const D=Wn;Ns(),Ni();const V=()=>D===Wn;return Promise.resolve(E).then(ne=>(V()&&(oo(ne,Ro(),Mo()),Ns(),Ni()),$d(ne)),()=>(V()&&To({available:!1,reason:tt.searchUnavailable}),{ok:!1,reason:tt.searchUnavailable}))}return Ns(),Ni(),$d(E)}if(typeof h.replaceCurrent!="function")return{ok:!1,reason:tt.operationUnavailable};const y=Lt(()=>h.replaceCurrent(typeof c=="string"?c:""),null);return kx(y)},replaceAll:c=>{const h=va();if(!h){const _=Fi();if(!_||typeof _.replaceAll!="function"||typeof _.getState!="function")return{ok:!1,reason:tt.searchUnavailable};if(!Mo())return{ok:!1,reason:ve("find.replaceAll")?.reason==="search-truncated"?tt.searchTruncated:tt.operationUnavailable};const E=Lt(()=>_.replaceAll({replacement:typeof c=="string"?c:""}),null);if(kr(E)){const D=Wn;Ns(),Ni();const V=()=>D===Wn;return Promise.resolve(E).then(ne=>(V()&&(oo(ne,Ro(),Mo()),Ns(),Ni()),$d(ne)),()=>(V()&&To({available:!1,reason:tt.searchUnavailable}),{ok:!1,reason:tt.searchUnavailable}))}return Ns(),Ni(),$d(E)}if(typeof h.replaceAll!="function")return{ok:!1,reason:tt.operationUnavailable};const y=Lt(()=>h.replaceAll(typeof c=="string"?c:""),null);return kx(y)}};let Bs=null;Ls=()=>{if(ss=null,Bs!==null&&clearTimeout(Bs),!Yt.open||!Yt.query)return;const c=Wn;Bs=setTimeout(()=>{if(Bs=null,N||c!==Wn||!Yt.open||!Yt.query)return;const h={query:Yt.query,caseSensitive:Yt.caseSensitive,includeDeletedText:Yt.includeDeletedText,regex:Yt.regex},y=Fi(),_=va();if(typeof y?.refresh!="function"&&typeof _?.refresh!="function")return;const E=++Wn;if(r2(),typeof y?.refresh=="function"&&typeof y.query=="function"){const V=y;Ud=()=>{V.query({query:""})}}const D=typeof y?.refresh=="function"?Lt(()=>y.refresh(h),null):Lt(()=>_.refresh(),null);kr(D)?(Fs=E,To({canReplace:!1,canReplaceAll:!1}),Promise.resolve(D).then(V=>{E!==Wn||N||(Ud=null,Fs=null,ss=y,oo(V,Ro(),Mo()))},()=>{E!==Wn||N||(Ud=null,To({available:!1,reason:tt.searchUnavailable}))})):D!==null&&(Ud=null,ss=y,oo(D))},120)};const _x=Ds(c=>c.styles),rv=os(_x),Xq={get:rv.get,getSnapshot:rv.getSnapshot,subscribe:rv.subscribe,observe:rv.observe,getCatalog:c=>(Ie(Ts(c)),ma(c).value),getQuickGallery:()=>_x.get().quickGallery,getActiveParagraphStyle:()=>ga(P.selection,Pi().cache).style},ov=B9({getEditor:b,getMode:Xn,getFonts:()=>px.getFamilyOptions(),getContainer:()=>t.element??null,openSurface:typeof t.openSurface=="function"?c=>t.openSurface(c):null});ou.push(ov.close),Nh.push(ov.close);const iv={select:Ps,get state(){return P},selection:W1,commands:Eq,toolbar:xq,comments:Mq,trackChanges:Dq,contentControls:Nq,bookmarks:Tq,fonts:px,zoom:Bq,document:zq,viewport:Jg,metadata:Gq,tables:Kq,search:Sx,contextMenu:k,watermark:ov,styles:Xq,formatPainter:{setPointerSelecting(c){N||(p={...p,pointerSelecting:c})},notifyPointerUp(){N||(p={...p,pointerSelecting:!1},ox())},setKeyboardSelecting(c){N||(p={...p,keyboardSelecting:c})},notifyKeyUp(){N||(p={...p,keyboardSelecting:!1},ox())},cancel(){N||Bg()},onModeChange(c){return N?()=>{}:(v.add(c),()=>v.delete(c))}},createScope:()=>{const c=[];return{select:(h,y)=>{const _=Ps(h,y);return{get:_.get,subscribe:E=>{const D=_.subscribe(E);return c.push(D),D}}},dispose:()=>{for(const h of c.splice(0))h()}}},destroy:()=>{if(!N){ov.destroy(),J1(),N=!0,ss=null,Bs!==null&&clearTimeout(Bs),Bs=null,Zh(),IO(qn,Bn),Mt&&(clearTimeout(Mt),Mt=null),mt&&(clearTimeout(mt),mt=null,Ot=0),Ke?.timer&&(clearTimeout(Ke.timer),Ke.timer=null),Ke=null,Qt&&(clearTimeout(Qt),Qt=null),Jo&&(clearTimeout(Jo),Jo=null),lr&&lr(),lr=null,jo=null;for(const c of Object.keys(Xr))Xr[c]=0;Bo.clear(),Io.clear(),Xi.clear(),Zo=null,Re.clear();for(const c of zh.splice(0))c();vi&&vi(),vi=null,ts=null,yi&&yi(),yi=null,Ms=null,ns&&ns(),ns=null,bi=null,ti&&ti(),ti=null,Di=null,q&&q(),q=null,B=null,be&&be(),be=null,Ee=null;for(const c of Vd)Qg(c);Vd.clear(),ke.clear(),tv.clear(),g+=1,m=null,v.clear(),Wn+=1,It.clear()}}};return me=iv,O_.set(iv,Sq),F_.set(iv,dq),iv}var pF=[{value:"Arial",label:"Arial",previewFamily:"Arial, sans-serif"},{value:"Calibri",label:"Calibri",previewFamily:"Calibri, sans-serif"},{value:"Courier New",label:"Courier New",previewFamily:'"Courier New", monospace'},{value:"Georgia",label:"Georgia",previewFamily:"Georgia, serif"},{value:"Times New Roman",label:"Times New Roman",previewFamily:'"Times New Roman", serif'},{value:"Verdana",label:"Verdana",previewFamily:"Verdana, sans-serif"}];function mF(e){const t=e.trim(),n=t[0];if(n==='"'||n==="'"){const o=t.indexOf(n,1);if(o>0)return t.slice(1,o).trim()}const r=t.indexOf(",");return(r===-1?t:t.slice(0,r)).trim().replace(/^["']|["']$/g,"")}function gF(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||typeof n!="object")continue;const r=n,o=typeof r.logicalFamily=="string"?mF(r.logicalFamily):"";if(!o)continue;const i=typeof r.previewFamily=="string"&&r.previewFamily.trim()?r.previewFamily.trim():o;t.push({value:o,label:o,previewFamily:i})}return t}function vF(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||typeof n!="object")continue;const r=n,o=typeof r.value=="string"?r.value.trim():"";if(!o)continue;const i=typeof r.label=="string"&&r.label.trim()?r.label.trim():o,s=typeof r.previewFamily=="string"&&r.previewFamily.trim()?r.previewFamily.trim():o;t.push({value:o,label:i,previewFamily:s})}return t}function yF(e,t=[]){const n=[],r=new Set,o=s=>{const a=String(s.value).trim().toLowerCase();!a||r.has(a)||(r.add(a),n.push(s))};for(const s of e)o(s);const i=t.length?t:pF;for(const s of i)o(s);return n}var bF=[{value:"8",label:"8"},{value:"9",label:"9"},{value:"10",label:"10"},{value:"11",label:"11"},{value:"12",label:"12"},{value:"14",label:"14"},{value:"16",label:"16"},{value:"18",label:"18"},{value:"24",label:"24"},{value:"36",label:"36"}];function wF(e,t){return e.activeMark?t.activeMarks.includes(e.activeMark):!1}var CF=e=>!!e?.trackedChange,kF=e=>e,SF=(e,t,n,r=e)=>!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n)?!1:(Number.isFinite(r)?r:e)<t||e>n,_F=({comment:e,anchorTop:t,anchorBottom:n,viewportTop:r,viewportBottom:o})=>CF(e)&&SF(t,r,o,n),AF=({comment:e,anchorTop:t,anchorBottom:n,cardHeight:r,viewportTop:o,viewportBottom:i})=>!_F({comment:e,anchorTop:t,anchorBottom:n,viewportTop:o,viewportBottom:i})||!Number.isFinite(r)?null:(Number.isFinite(n)?n:t)<o?Math.min(t,o-r-1):t,IF=({id:e,visibleIds:t,activeCommentInstanceId:n})=>e?!!(e==="pending"||n!=null&&String(e)===String(n)||t?.has?.(e)):!1,nA=({previousIds:e,currentIds:t,removedId:n})=>{if(!Array.isArray(e)||!(t instanceof Set)||!n)return null;const r=e.indexOf(n);if(r<0)return null;for(let o=r+1;o<e.length;o+=1){const i=e[o];if(t.has(i))return i}for(let o=r-1;o>=0;o-=1){const i=e[o];if(t.has(i))return i}return null};Ft(),yn();var EF=["data-comment-id","data-comment-instance-id","data-comment-thread-id","data-comment-position-key","data-comment-page-index"],Oc={},xF={__name:"FloatingComments",props:{currentDocument:{type:Object,required:!0},parent:{type:Object,required:!0}},setup(e){const r=new Set(["auto","scroll","hidden","clip"]),o=(Te,Ne,Qe)=>{if(Ne>=0){Te[Ne].top=Te[Ne].anchorTop;let bt=Te[Ne].top+Te[Ne].height+Qe;for(let Dt=Ne+1;Dt<Te.length;Dt++)Te[Dt].top=Math.max(Te[Dt].anchorTop,bt),bt=Te[Dt].top+Te[Dt].height+Qe;bt=Te[Ne].top-Qe;for(let Dt=Ne-1;Dt>=0;Dt--){const kn=bt-Te[Dt].height;Te[Dt].top=Math.min(Te[Dt].anchorTop,kn),bt=Te[Dt].top-Qe}const Nt=Math.min(...Te.map(Dt=>Dt.top));if(Nt<0){const Dt=Math.abs(Nt);for(const kn of Te)kn.top+=Dt}}else for(let bt=1;bt<Te.length;bt++){const Nt=Te[bt-1],Dt=Nt.top+Nt.height+Qe;Te[bt].top<Dt&&(Te[bt].top=Dt)}},i=e,s=Xu(),a=Js(),{clearInstantSidebarAlignment:l}=a,{activeComment:u,activeFloatingCommentInstanceId:d,editorCommentPositions:f,pendingComment:p,editingCommentId:g,instantSidebarAlignmentTargetY:m,instantSidebarAlignmentThreadId:v,instantSidebarAlignmentInstanceId:C}=qs(a),{activeZoom:w}=qs(s),S=_e(()=>{const Te=a.getFloatingCommentInstances;if(!Array.isArray(Te))return[];const Ne=i.currentDocument?.id;return Ne==null?Te:Te.filter(Qe=>a.belongsToDocument(Qe.comment,String(Ne),{allowSingleDocumentMismatch:!0}))}),b=te(null),k=te(0),x=te(0),M=te(!1),z=te(null),G=te(0),F=Te=>{const Ne=p.value?.commentId;return Ne?typeof Te=="object"?Te?.commentId===Ne:Te===Ne||Te==="pending":!1},L=Te=>Te?.commentId??Te?.importedId??null,$=_e(()=>{const Te=new Map,Ne=new Map;for(const Qe of S.value){Qe?.id!=null&&Te.set(String(Qe.id),Qe);const bt=L(Qe?.comment);if(bt==null)continue;const Nt=String(bt),Dt=Ne.get(Nt)??[];Dt.push(Qe),Ne.set(Nt,Dt)}return{byId:Te,byThreadId:Ne}}),T=(Te,Ne=null)=>{if(Te==null)return null;const Qe=String(Te),bt=$.value.byThreadId.get(Qe)??[];if(!bt.length)return null;if(Ne!=null){const Nt=bt.find(Dt=>String(Dt.id)===String(Ne));if(Nt)return Nt.id}return bt.find(Nt=>Nt.isPrimary)?.id??bt[0]?.id??null},H=_e(()=>u.value?T(u.value,d.value):null),R=Te=>{if(typeof Te=="number")return Number.isFinite(Te)?Te:null;if(typeof Te!="string"||Te.trim()==="")return null;const Ne=Number(Te);return Number.isFinite(Ne)?Ne:null},U=te({...Oc}),W=te(new Set),ee=te({});let J=null;const Z=new Set;let Me=null;const fe=()=>{Me==null&&(Me=requestAnimationFrame(()=>{Me=null,G.value+=1}))},ye=Te=>{if(i.currentDocument.type==="application/pdf"){const Ne=(w.value??100)/100,Qe=R(Te?.comment?.selection?.selectionBounds?.top);return Qe==null?null:Qe*Ne}return Te?.positionEntry?.bounds?.top},ve=(Te,Ne)=>{if(i.currentDocument.type==="application/pdf"){const bt=(w.value??100)/100,Nt=R(Te?.comment?.selection?.selectionBounds?.bottom);return Nt!=null?Nt*bt:Ne}const Qe=Te?.positionEntry?.bounds?.bottom;return Number.isFinite(Qe)?Qe:Ne},Pe=_e(()=>{const Te=[];for(const Ne of S.value){const Qe=Ne?.id,bt=L(Ne?.comment),Nt=ye(Ne);if(Qe==null||bt==null||!Number.isFinite(Nt))continue;const Dt=kF(Nt,Ne.comment);Te.push({id:Qe,threadId:bt,instance:Ne,top:Dt,anchorBottom:ve(Ne,Dt)})}return Te}),Ve=()=>{const Te=f.value.pending;if(typeof Te?.bounds?.top=="number"&&!isNaN(Te.bounds.top))return Te.bounds.top;const Ne=i.currentDocument.type==="application/pdf"?(w.value??100)/100:1,Qe=R(p.value?.selection?.selectionBounds?.top);return Qe==null?null:Qe*Ne},nt=Te=>IF({id:Te?.id,visibleIds:W.value,activeCommentInstanceId:H.value,comment:Te?.commentRef}),ct=()=>{const Te=b.value;if(!Te)return null;const Ne=Te.getBoundingClientRect();if(!Number.isFinite(Ne.top)||!Number.isFinite(window.innerHeight))return null;let Qe=0,bt=window.innerHeight;for(let Dt=Te.parentElement;Dt;Dt=Dt.parentElement){const kn=window.getComputedStyle(Dt).overflowY;if(!["auto","scroll","hidden","clip"].includes(kn))continue;const Ht=Dt.getBoundingClientRect();!Number.isFinite(Ht.top)||!Number.isFinite(Ht.bottom)||(Qe=Math.max(Qe,Ht.top),bt=Math.min(bt,Ht.bottom))}if(bt<=Qe)return null;const Nt=i.parent?.getBoundingClientRect?.();if(Nt&&Number.isFinite(Nt.top)&&Number.isFinite(Nt.bottom)){const Dt=Math.max(Qe,Nt.top),kn=Math.min(bt,Nt.bottom);kn>Dt&&(Qe=Dt,bt=kn)}return{top:Qe-Ne.top,bottom:bt-Ne.top}},ft=_e(()=>v.value?T(v.value,C.value):null),It=_e(()=>{G.value;const Te=Pe.value,Ne=p.value&&p.value.fileId===i.currentDocument.id;if(!Te.length&&!S.value.length&&!Ne)return[];const Qe=[],bt=ct()??{top:0,bottom:Math.max(0,i.parent?.clientHeight||window.innerHeight||0)},Nt=bt.top-600,Dt=bt.bottom+600,kn=Ne?"pending":H.value,Ht=new Set,In=({id:dn,threadId:sr,instance:ar,top:No,anchorBottom:ln,hasAnchorGeometry:Mn})=>{const Jn=String(dn);Ht.has(Jn)||(Ht.add(Jn),Qe.push({id:dn,threadId:sr,pageIndex:ar?.pageIndex??null,anchorTop:No,anchorBottom:ln,hasAnchorGeometry:Mn,top:No,height:U.value[dn]||110,commentRef:ar.comment,instanceRef:ar}))};for(const dn of Te){const{id:sr,threadId:ar,instance:No,top:ln,anchorBottom:Mn}=dn,Jn=kn!=null&&String(sr)===String(kn),Yr=g.value!=null&&String(ar)===String(g.value);!Jn&&!Yr&&(Mn<Nt||ln>Dt)||In({id:sr,threadId:ar,instance:No,top:ln,anchorBottom:Mn,hasAnchorGeometry:!0})}const sn=[];if(kn&&kn!=="pending"){const dn=$.value.byId.get(String(kn));dn&&sn.push(dn)}if(g.value!=null){const dn=$.value.byThreadId.get(String(g.value))??[],sr=dn.find(ar=>ar.isPrimary)??dn[0];sr&&sn.push(sr)}for(const dn of sn){const sr=dn.id,ar=L(dn.comment);sr==null||ar==null||Ht.has(String(sr))||In({id:sr,threadId:ar,instance:dn,top:bt.top,anchorBottom:bt.top,hasAnchorGeometry:!1})}if(Ne){const dn=Ve();typeof dn=="number"&&!isNaN(dn)&&Qe.push({id:"pending",anchorTop:dn,anchorBottom:dn,hasAnchorGeometry:!0,top:dn,height:U.value.pending||110,commentRef:p.value})}Qe.sort((dn,sr)=>dn.anchorTop-sr.anchorTop);const Ao=[];for(const dn of Qe){const sr=dn.hasAnchorGeometry?AF({comment:dn.commentRef,anchorTop:dn.anchorTop,anchorBottom:dn.anchorBottom,cardHeight:dn.height,viewportTop:bt.top,viewportBottom:bt.bottom}):null;sr==null?Ao.push(dn):(dn.top=sr,dn.isOffscreenReviewCard=!0)}const qi=kn?Ao.findIndex(dn=>dn.id===kn):-1;return o(Ao,qi,15),Qe}),Le=_e(()=>(G.value,Math.max(0,i.parent?.clientHeight||0,i.parent?.scrollHeight||0))),oe=()=>{J&&J.disconnect(),J=new IntersectionObserver(Te=>{const Ne=new Set(W.value);for(const Qe of Te){const bt=Qe.target.dataset.commentId;bt&&(Qe.isIntersecting?Ne.add(bt):Ne.delete(bt))}W.value=Ne},{rootMargin:"600px 0px 600px 0px"})},we=()=>{if(!J)return;const Te=new Set;for(const Ne of It.value){const Qe=ee.value[Ne.id];Qe&&(Te.add(Qe),Z.has(Qe)||(J.observe(Qe),Z.add(Qe)))}for(const Ne of Z)Te.has(Ne)||(J.unobserve(Ne),Z.delete(Ne))},Q=(Te,Ne)=>{Ne<=0||Ne===U.value[Te]||(Oc[Te]=Ne,U.value={...U.value,[Te]:Ne})},I=Te=>{if(!Te)return;const{elementRef:Ne,commentId:Qe}=Te;Ne&&Ct(()=>{const bt=Ne.value?.getBoundingClientRect();!bt||bt.height<=0||Qe&&Q(Qe,bt.height)})},re=Te=>{const Ne=Te?.id;Ne&&Ct(()=>{const Qe=ee.value[Ne];if(!Qe)return;const bt=Qe.querySelector(".comments-dialog");if(!bt)return;Q(Ne,bt.getBoundingClientRect().height);const Nt=Ne===H.value,Dt=Ne==="pending",kn=!!g.value&&!!u.value&&Te?.threadId!=null&&String(Te.threadId)===String(u.value);!Nt&&!Dt&&!kn||(Qt(It.value.map(Ht=>Ht.id)),jn(()=>It.value.map(Ht=>Ht.id)))})},j=Te=>{!Te&&z.value!=null||(M.value=Te)},X=(Te,Ne,Qe)=>{if(!Number.isFinite(Ne)){Qe?.(!1);return}const bt=ee.value[Te];if(!bt){Qe?.(!1);return}const Nt=bt.getBoundingClientRect().top;x.value+=Ne-Nt,Qe?.(!0)},K=(Te,Ne)=>{if(Ne)ee.value[Te]=Ne,J&&!Z.has(Ne)&&(J.observe(Ne),Z.add(Ne));else{const Qe=ee.value[Te];Qe&&J&&(J.unobserve(Qe),Z.delete(Qe)),delete ee.value[Te]}};let ae=[],ke=null,P=[],N=null,me=!1,Se=0,Re=null,ze=null,Ke=null,ot=null,mt=null;const Ot=new Set,Mt=()=>{Ke=null,ot=null,z.value=null,j(!1)},Kt=Te=>{if(!Ke)return;const Ne=(Te?.target instanceof Element?Te.target:null)?.closest?.("[data-comment-action]"),Qe=Ne?.getAttribute?.("data-comment-action");(Qe==="resolve"||Qe==="reject")&&b.value?.contains?.(Ne)||Mt()},$e=()=>{ae.forEach(clearTimeout),ae=[]},Qt=Te=>{for(const Ne of Te.filter(Boolean)){const Qe=ee.value[Ne];if(!Qe)continue;const bt=Qe.querySelector(".comments-dialog");bt&&Q(Ne,bt.getBoundingClientRect().height)}},Hn=50,qt=350,jn=Te=>{$e();const Ne=typeof Te=="function"?Te:()=>Te;ae.push(setTimeout(()=>Qt(Ne()),Hn)),ae.push(setTimeout(()=>Qt(Ne()),qt))},Pn=()=>{l(),requestAnimationFrame(()=>{j(!1)})},$r=(Te,Ne)=>{!Te||!Number.isFinite(Ne)||(j(!0),Ct(()=>{Qt([Te]),X(Te,Ne,()=>{Pn()})}))},Nr=()=>{N=null,Se+=1,Re!=null&&(cancelAnimationFrame(Re),Re=null),j(!1)},_r=()=>{!Ke&&!N||(Mt(),Nr(),j(!0),x.value=0,mt!=null&&cancelAnimationFrame(mt),mt=requestAnimationFrame(()=>{mt=null,!Ke&&!N&&j(!1)}))},Tn=()=>{_r(),fe()},tr=()=>{const Te=Ne=>{!Ne?.addEventListener||Ot.has(Ne)||(Ne.addEventListener("scroll",Tn,{passive:!0}),Ot.add(Ne))};Te(i.parent);for(let Ne=b.value?.parentElement;Ne;Ne=Ne.parentElement)r.has(window.getComputedStyle(Ne).overflowY)&&Te(Ne);Te(window)},qn=()=>{for(const Te of Ot)Te.removeEventListener?.("scroll",Tn);Ot.clear()},Bn=()=>{if(!N||me)return;me=!0;const Te=Se;Re!=null&&(cancelAnimationFrame(Re),Re=null),j(!0),Ct(()=>{if(me=!1,Te!==Se){Bn();return}const{key:Ne,targetClientY:Qe}=N;Qt([Ne]),X(Ne,Qe,bt=>{if(Te===Se){if(!bt){j(!1);return}Re=requestAnimationFrame(()=>{Re=null,Te===Se&&j(!1)})}})})},st=(Te,Ne)=>{const Qe=nA({previousIds:P,currentIds:Ne,removedId:Te}),bt=(Qe?ee.value[Qe]:null)?.getBoundingClientRect?.().top;return!Qe||!Number.isFinite(bt)?(Nr(),!1):(N={key:Qe,targetClientY:bt},Se+=1,Bn(),!0)},_t=Te=>{const Ne=Te?.target?.closest?.("[data-comment-action]"),Qe=Ne?.getAttribute?.("data-comment-action");if(Qe!=="resolve"&&Qe!=="reject"||(Mt(),Ne.getAttribute?.("aria-disabled")==="true"))return;const bt=Ne.closest?.("[data-comment-id]")?.getAttribute?.("data-comment-id");if(!bt||String(H.value??"")===String(bt))return;const Nt=It.value.filter(Ht=>Ht.commentRef?.trackedChange).map((Ht,In)=>({id:Ht.id,index:In,top:Ht.top})).filter(Ht=>Number.isFinite(Ht.top)).sort((Ht,In)=>Ht.top-In.top||Ht.index-In.index).map(Ht=>Ht.id),Dt=nA({previousIds:Nt,currentIds:new Set(Nt),removedId:bt}),kn=(Dt?ee.value[Dt]:null)?.getBoundingClientRect?.().top;!Dt||!Number.isFinite(kn)||(Ke={removedKey:bt,targetKey:Dt,targetClientY:kn,applied:!1},ot=bt,z.value=Dt,j(!0))};jt(H,(Te,Ne)=>{if($e(),!(Ke!=null&&ot!=null&&[Te,Ne].some(Nt=>Nt!=null&&String(Nt)===String(ot)))){if(ot=null,Te)Mt(),Nr();else if(Ne){const Nt=new Set(It.value.map(Dt=>Dt.id));Nt.has(Ne)?Nr():st(Ne,Nt)}}const Qe=[Te,Ne],bt=Te&&Te===ft.value&&Number.isFinite(m.value);Ct(()=>{if(bt){Qt(Qe);return}jn(Qe)})}),jt([H,ft,m],([Te,Ne,Qe])=>{!Te||!Ne||Te!==Ne||!Number.isFinite(Qe)||$r(Te,Qe)}),jt(g,()=>{$e(),Ct(()=>{jn(()=>It.value.map(Te=>Te.id))})}),jt(u,()=>{if(ke&&clearTimeout(ke),!u.value){if(l(),N){Bn();return}j(!1),x.value=0;return}if(!(F(u.value)?p.value:a.getComment(u.value)))return;const Te=F(u.value)?"pending":H.value;if(Te){if(Te===ft.value&&Number.isFinite(m.value)){j(!0);return}Ct(()=>{ke=setTimeout(()=>{const Qe=ee.value[Te];if(!Qe)return;const bt=i.parent?.getBoundingClientRect?.();if(!bt)return;const Nt=It.value.find(In=>In.id===Te),Dt=Te==="pending"?Ve():Nt?.anchorTop;if(typeof Dt!="number"||isNaN(Dt))return;const kn=Qe.getBoundingClientRect().top,Ht=bt.top+Dt;x.value+=Ht-kn},400)})}}),jt(w,()=>{if(i.currentDocument.type==="application/pdf"){for(const Te in Oc)delete Oc[Te];U.value={},k.value+=1}});let gt=new Set,Xt=null,gn=null;return jt(It,Te=>{const Ne=H.value?Te.find(ln=>ln.id===H.value):null,Qe=typeof Ne?.anchorTop=="number"&&Number.isFinite(Ne.anchorTop)?Ne.anchorTop:null,bt=Qe!=null&&Xt!=null&&Math.abs(Qe-Xt)>1,Nt=typeof Ne?.top=="number"&&Number.isFinite(Ne.top)?Ne.top:null,Dt=Nt!=null&&gn!=null&&Math.abs(Nt-gn)>1;bt&&x.value!==0&&!Number.isFinite(m.value)?(x.value=0,j(!1)):Dt&&x.value!==0&&!Number.isFinite(m.value)&&!N&&(j(!0),x.value+=gn-Nt,ze!=null&&cancelAnimationFrame(ze),ze=requestAnimationFrame(()=>{ze=null,!N&&!Number.isFinite(m.value)&&j(!1)})),Xt=Qe,gn=Nt;const kn=Te.map(ln=>ln.id),Ht=new Set(kn);if(Ke&&!Ke.applied&&!Ht.has(Ke.removedKey)){const{targetKey:ln,targetClientY:Mn}=Ke;Ke.applied=!0,Ht.has(ln)&&Number.isFinite(Mn)?(N={key:ln,targetClientY:Mn},Se+=1,Bn()):Mt()}if(Ke?.applied&&!Ht.has(Ke.targetKey)&&Mt(),N&&!Ht.has(N.key)){const ln=N.key;st(ln,Ht)||(j(!1),x.value=0)}const In=new Set(W.value);let sn=!1,Ao=-1/0,qi=1/0;const dn=b.value;if(dn){const ln=dn.getBoundingClientRect();Ao=-ln.top-600,qi=-ln.top+window.innerHeight+600}const sr=new Map(Te.map(ln=>[ln.id,ln]));for(const ln of Ht)if(!In.has(ln)){const Mn=sr.get(ln);(!Mn||Mn.top>=Ao&&Mn.top<=qi)&&(In.add(ln),sn=!0)}for(const ln of In)Ht.has(ln)||(In.delete(ln),sn=!0);sn&&(W.value=In);for(const ln of gt)Ht.has(ln)||delete Oc[ln];const ar=gt.size!==Ht.size||[...gt].some(ln=>!Ht.has(ln)),No=P.length!==kn.length||P.some((ln,Mn)=>ln!==kn[Mn]);if(ar){const ln={};for(const Mn of Ht)Oc[Mn]&&(ln[Mn]=Oc[Mn]);U.value=ln,Ct(()=>{for(const Mn of Te){const Jn=ee.value[Mn.id];if(!Jn)continue;const Yr=Jn.querySelector(".comments-dialog");Yr&&Q(Mn.id,Yr.getBoundingClientRect().height)}})}N&&(ar||No)&&Bn(),gt=Ht,Ct(()=>{P=kn,we()})}),zn(()=>{oe(),tr(),window.addEventListener("resize",fe,{passive:!0}),document.addEventListener("pointerdown",Kt,!0),Ct(we)}),ur(()=>{$e(),ke&&clearTimeout(ke),Mt(),Nr(),ze!=null&&(cancelAnimationFrame(ze),ze=null),mt!=null&&(cancelAnimationFrame(mt),mt=null),qn(),window.removeEventListener("resize",fe),document.removeEventListener("pointerdown",Kt,!0),Me!=null&&(cancelAnimationFrame(Me),Me=null),J&&(J.disconnect(),J=null,Z.clear())}),(Te,Ne)=>(pe(),Ce("div",{class:"section-wrapper",ref_key:"floatingCommentsContainer",ref:b,onClickCapture:_t,style:An({minHeight:Le.value+"px",transition:M.value?"none":void 0})},[ce("div",{class:"sidebar-container",style:An({transform:`translateY(${x.value}px)`,transition:M.value?"none":void 0})},[(pe(!0),Ce(Bt,null,Rn(It.value,Qe=>(pe(),Ce("div",{key:Qe.id,ref_for:!0,ref:bt=>K(Qe.id,bt),"data-comment-id":Qe.id,"data-comment-instance-id":Qe.id,"data-comment-thread-id":Qe.threadId,"data-comment-position-key":Qe.instanceRef?.positionKey??"","data-comment-page-index":Qe.pageIndex??"",class:Zt([{"is-direct-decision-continuity-target":Qe.id===z.value},"comment-placeholder"]),style:An({top:(Qe.isOffscreenReviewCard?Qe.top-x.value:Qe.top)+"px",height:Qe.height+"px",transition:M.value?"none":void 0})},[nt(Qe)?(pe(),hn(x0,{key:Qe.id+k.value,onReady:I,onResize:bt=>re(Qe),class:"floating-comment",parent:e.parent,comment:Qe.commentRef,"floating-instance-id":Qe.id,"floating-page-index":Qe.pageIndex,"floating-position-entry":Qe.instanceRef?.positionEntry??null,"is-floating-instance-active":Qe.id===H.value},null,8,["onResize","parent","comment","floating-instance-id","floating-page-index","floating-position-entry","is-floating-instance-active"])):ut("",!0)],14,EF))),128))],4)],36))}},TF=mn(xF,[["__scopeId","data-v-8262096d"]]);Ft(),yn();var RF={class:"superdoc__pdf-comments-layer pdf-comments-layer","aria-hidden":"false"},MF=["data-id","data-comment-id","data-page-number","onClick","onKeydown"],LF="pdf",PF="#078383",DF="#B1124B",OF={__name:"PdfCommentsLayer",emits:["anchor-activate"],setup(e,{emit:t}){const n=t,r=Js(),o=Xu(),{activeComment:i}=qs(r),{documents:s,activeZoom:a}=qs(o),{proxy:l}=yr(),u=b=>typeof b=="number"?Number.isFinite(b):typeof b=="string"&&b.trim()!==""?Number.isFinite(Number(b)):!1,d=b=>!!b&&u(b.top)&&u(b.left)&&u(b.right)&&u(b.bottom),f=_e(()=>{const b=Array.isArray(s.value)?s.value:[];return new Set(b.filter(k=>k?.type===Da).map(k=>String(k.id)))}),p=b=>{const k=b?.fileId??b?.documentId??b?.selection?.documentId;return k!=null?String(k):null},g=b=>{const k=b?.commentId??b?.importedId;return k!=null&&String(k)!==""?String(k):null},m=b=>{const k=f.value;if(!k.size)return!1;const x=p(b);return x?k.has(x):k.size===1},v=b=>{const k=Math.min(Number(b.top),Number(b.bottom)),x=Math.max(Number(b.top),Number(b.bottom));return{top:k,left:Math.min(Number(b.left),Number(b.right)),right:Math.max(Number(b.left),Number(b.right)),bottom:x}},C=_e(()=>{const b=r.getFloatingComments;return Array.isArray(b)?b.filter(k=>k?.selection?.source===LF).filter(k=>!k.resolvedTime).filter(k=>g(k)!==null).filter(k=>d(k.selection?.selectionBounds)).filter(k=>m(k)).map(k=>{const x=g(k),M=v(k.selection.selectionBounds);return{commentId:x,page:k.selection?.page??null,isInternal:k.isInternal!==!1,bounds:M}}):[]}),w=b=>{const k=(a.value??100)/100,{top:x,left:M,right:z,bottom:G}=b.bounds,F=i.value===b.commentId,L=(b.isInternal?PF:DF)+(F?"66":"33");return{position:"absolute",top:x*k+"px",left:M*k+"px",width:(z-M)*k+"px",height:(G-x)*k+"px",backgroundColor:L}},S=b=>{r.setActiveComment(l.$superdoc,b.commentId),n("anchor-activate",b.commentId)};return(b,k)=>(pe(),Ce("div",RF,[(pe(!0),Ce(Bt,null,Rn(C.value,x=>(pe(),Ce("div",{key:x.commentId,class:"sd-comment-anchor sd-highlight",role:"button",tabindex:"0","data-id":x.commentId,"data-comment-id":x.commentId,"data-page-number":x.page,style:An(w(x)),onClick:tn(M=>S(x),["stop","prevent"]),onKeydown:[Ko(tn(M=>S(x),["stop","prevent"]),["enter"]),Ko(tn(M=>S(x),["stop","prevent"]),["space"])]},null,44,MF))),128))]))}},FF=mn(OF,[["__scopeId","data-v-b5ad4c58"]]);Ft();var NF=({proxy:e,layers:t,documents:n,modules:r})=>{const o=_e(()=>{const L=r.value?.whiteboard??r.whiteboard;return L===!1||L==null?null:L}),i=e?.$superdoc?.whiteboard,s=Pr([]),a=Qr({}),l=Qr({}),u=te(!1),d=te(0),f=te(0),p=te(1),g=te(o.value?.enabled??!1),m=()=>{if(u.value)return;d.value+=1;const L=f.value||s.value.length;L&&d.value>=L&&(u.value=!0,e?.$superdoc?.emit("whiteboard:ready",{whiteboard:i}))},v=L=>{if(!L)return;const $=n.value?.[0];$&&$.type==="application/pdf"&&C(L)},C=L=>{const{pageIndex:$,width:T,height:H,originalWidth:R,originalHeight:U}=L,W={width:T,height:H,originalWidth:R,originalHeight:U};i?.setPageSize($,W),a[$]=W;const ee=i?.getPage($);ee&&ee.setSize(W),i&&(s.value=i.getPages().sort((J,Z)=>J.pageIndex-Z.pageIndex).map(J=>Gr(J)),f.value=s.value.length),Ct(()=>{G(),m()})},w=L=>{e?.$superdoc?.emit("whiteboard:change",L)},S=L=>{L.forEach($=>{const T=a[$.pageIndex];T&&$.setSize(T)}),s.value=L.map($=>Gr($)),f.value=s.value.length,Ct(()=>G())},b=L=>{g.value=L,e?.$superdoc?.emit("whiteboard:enabled",L)},k=L=>{p.value=L},x=L=>{e?.$superdoc?.emit("whiteboard:tool",L)},M=()=>{const L=n.value?.[0];L&&L.type==="application/pdf"&&z({doc:L})},z=({doc:L})=>{s.value.forEach($=>{const T=`${L.id}-page-${$.pageIndex+1}`,H=document.querySelector(`[data-page-id="${T}"]`);if(!H)return;const R=H.getBoundingClientRect(),U=a[$.pageIndex]||{},W=U.originalWidth??$.size?.originalWidth??R.width,ee=U.originalHeight??$.size?.originalHeight??R.height,J={width:R.width,height:R.height,originalWidth:W,originalHeight:ee};a[$.pageIndex]=J,$.setSize(J)})},G=()=>{const L=t.value?.getBoundingClientRect?.();if(!L)return;const $=n.value?.[0];$&&$.type==="application/pdf"&&F({doc:$,layerBounds:L})},F=({doc:L,layerBounds:$})=>{s.value.forEach(T=>{const H=`${L.id}-page-${T.pageIndex+1}`,R=document.querySelector(`[data-page-id="${H}"]`);if(!R)return;const U=R.getBoundingClientRect();l[T.pageIndex]={top:U.top-$.top,left:U.left-$.left}})};return i&&(i.on("change",w),i.on("setData",S),i.on("enabled",b),i.on("opacity",k),i.on("tool",x)),ur(()=>{i&&(i.off("change",w),i.off("setData",S),i.off("opacity",k),i.off("enabled",b),i.off("tool",x))}),{whiteboard:i,whiteboardModuleConfig:o,whiteboardPages:s,whiteboardPageSizes:a,whiteboardPageOffsets:l,whiteboardEnabled:g,whiteboardOpacity:p,whiteboardReady:u,handleWhiteboardPageReady:v,updateWhiteboardPageSizes:M,updateWhiteboardPageOffsets:G}};Ft(),yn();var BF=["data-page-index"],zF={__name:"WhiteboardPage",props:{whiteboard:{type:Object,required:!0},page:{type:Object,required:!0},pageSize:{type:Object,default:null},pageOffset:{type:Object,default:null},enabled:{type:Boolean,default:!0}},setup(e){const t=e,n=te(null),r=()=>{const u=n.value;!u||!t.page||(t.page.mount(u),t.pageSize&&t.page.resize(t.pageSize.width,t.pageSize.height))},o=u=>{if(!t.page||!u?.dataTransfer||!t.enabled||t.whiteboard.getTool()!=="select")return;u.preventDefault(),u.stopPropagation();const d=n.value;if(!d)return;const f=d.getBoundingClientRect(),p=u.clientX-f.left,g=u.clientY-f.top,m=t.pageSize?.width,v=t.pageSize?.originalWidth??m,C=Number.isFinite(m)&&Number.isFinite(v)&&v?m/v:1;i(u,p,g,C)||s(u,p,g,C)||a(u,p,g)||l(u,p,g)},i=(u,d,f,p)=>{const g=u.dataTransfer.getData("application/sticker");if(!g)return!1;const m=(t.whiteboard.getType("stickers")||[]).find(v=>v.id===g);return m?.src?(t.page.addImage({stickerId:m.id,x:d,y:f,src:m.src,width:Number.isFinite(m.width)?m.width*p:m.width,height:Number.isFinite(m.height)?m.height*p:m.height,type:"sticker"}),!0):!1},s=(u,d,f,p)=>{const g=Array.from(u.dataTransfer.files||[]).find(v=>v.type.startsWith("image/"));if(!g)return!1;const m=new FileReader;return m.onload=()=>{typeof m.result=="string"&&t.page.addImage({x:d,y:f,src:m.result,type:"image"})},m.readAsDataURL(g),!0},a=(u,d,f)=>{const p=u.dataTransfer.getData("application/comment");if(!p)return!1;const g=(t.whiteboard.getType("comments")||[]).find(m=>m.id===p);return g?.text?(t.page.addText({x:d,y:f,content:g.text}),!0):!1},l=(u,d,f)=>{const p=u.dataTransfer.getData("text/plain");return p?(t.page.addText({x:d,y:f,content:p}),!0):!1};return jt(()=>[t.page,t.pageSize?.width,t.pageSize?.height],()=>{Ct(r)}),zn(()=>{r()}),ur(()=>{t.page?.destroy()}),(u,d)=>(pe(),Ce("div",{ref_key:"containerRef",ref:n,class:"whiteboard-page","data-page-index":e.page.pageIndex,onDragover:d[0]||(d[0]=tn(()=>{},["prevent"])),onDrop:tn(o,["prevent"]),style:An({width:(e.pageSize?.width??e.page.size?.width)+"px",height:(e.pageSize?.height??e.page.size?.height)+"px",transform:`translate(${e.pageOffset?.left??0}px, ${e.pageOffset?.top??0}px)`})},null,44,BF))}},jF=mn(zF,[["__scopeId","data-v-c876c9b5"]]);Ft(),yn();var VF={__name:"WhiteboardLayer",props:{whiteboard:{type:Object,required:!0},pages:{type:Array,default:()=>[]},pageSizes:{type:Object,default:()=>({})},pageOffsets:{type:Object,default:()=>({})},enabled:{type:Boolean,default:!0},interactive:{type:Boolean,default:null},opacity:{type:Number,default:1}},setup(e){const t=e,n=_e(()=>t.interactive==null?t.enabled:t.interactive);return(r,o)=>(pe(),Ce("div",{class:"whiteboard-layer","aria-hidden":"true",style:An({opacity:e.opacity,pointerEvents:n.value?"auto":"none"})},[(pe(!0),Ce(Bt,null,Rn(e.pages,i=>(pe(),hn(jF,{key:i.pageIndex,page:i,"page-size":e.pageSizes?.[i.pageIndex],"page-offset":e.pageOffsets?.[i.pageIndex],whiteboard:e.whiteboard,enabled:e.enabled},null,8,["page","page-size","page-offset","whiteboard","enabled"]))),128))],4))}},UF=mn(VF,[["__scopeId","data-v-54546c3d"]]);Ft(),yn();var $F={class:"superdoc-html-viewer"},HF={class:"superdoc-html-viewer__document"},GF=["innerHTML"],WF={__name:"HtmlViewer",props:{fileSource:{type:[File,Blob],required:!0},documentId:{type:String,required:!0}},emits:["ready","selection-change"],setup(e,{emit:t}){const n=e,r=te(""),o=t,i=()=>{const l=window.getSelection();console.debug("selection from html viewer",l),o("selection-change",l)},s=l=>new Promise((u,d)=>{const f=new FileReader;f.onload=p=>{const g=p.target.result;u(g)},f.onerror=p=>d(p),f.readAsText(l)}),a=async()=>{try{const l=await s(n.fileSource);r.value=l,o("ready",n.documentId)}catch(l){o("error",l),console.error("Error loading document",l)}};return zn(()=>{a()}),(l,u)=>(pe(),Ce("div",$F,[ce("div",HF,[ce("div",{class:"superdoc-html-viewer__content",innerHTML:r.value,onMouseup:i},null,40,GF)])]))}},KF=mn(WF,[["__scopeId","data-v-da3494ba"]]),qF=(e,t,n=()=>!0)=>{const r=new Set(t.map(String)),o=new Set;e.forEach(s=>{if(!n(s))return;const a=s.commentId!=null?String(s.commentId):null,l=s.importedId!=null?String(s.importedId):null;!(a&&r.has(a))&&!(l&&r.has(l))||(a&&o.add(a),l&&o.add(l))});let i=!0;for(;i;)i=!1,e.forEach(s=>{if(!n(s))return;const a=s.commentId!=null?String(s.commentId):null,l=s.importedId!=null?String(s.importedId):null,u=s.parentCommentId!=null?String(s.parentCommentId):null,d=Tm(s),f=d!=null?String(d):null,p=a&&o.has(a)||l&&o.has(l),g=u&&o.has(u)||f&&o.has(f);if(!p&&!g)return;const m=o.size;a&&o.add(a),l&&o.add(l),o.size>m&&(i=!0)});return o};Ft();var rA=te(!1);function Hi(){return{isHighContrastMode:rA,setHighContrastMode:t=>{rA.value=t}}}var IX="[data-track-change-id], .superdoc-comment-highlight, .sd-comment-anchor",EX="sidebar",W0=new Set(["auto","sidebar","inline"]),YF=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),K0=(...e)=>e.find(t=>t!==void 0),oA=e=>{if(typeof e=="string")return e.trim()||void 0;if(typeof HTMLElement<"u"&&e instanceof HTMLElement)return e};function XF(e){const t=e;return typeof t?.closest=="function"&&t.closest(".track-change-focused")!=null}function iA(e){if(!e||e===!1||typeof e!="object")return e;const t={...e},n=YF(e.responsive)?e.responsive:{},r=K0(e.layout,e.displayMode),o=oA(K0(n.target,e.compactMeasurementSelector)),i=K0(n.breakpoint,e.compactBreakpointPx),s=e.displayMode;W0.has(s)||delete t.displayMode;const a=oA(e.compactMeasurementSelector);a===void 0?delete t.compactMeasurementSelector:t.compactMeasurementSelector=a;const l=e.compactBreakpointPx;typeof l=="number"&&Number.isFinite(l)&&l>=0||delete t.compactBreakpointPx,delete t.layout,delete t.responsive,W0.has(r)&&(t.layout=r);const u={};return o!==void 0&&(u.target=o),typeof i=="number"&&Number.isFinite(i)&&i>=0&&(u.breakpoint=i),Object.keys(u).length>0&&(t.responsive=u),t}Ft();var sA=".superdoc__document",ZF=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0,QF=e=>e+320+24;function JF({commentsModuleConfig:e,superdocRoot:t,layers:n}){const r=te(0),o=te(!1);let i=null,s=null,a=null,l=[];const u=C=>{if(!(C instanceof HTMLElement)||(typeof window<"u"?window.getComputedStyle(C):null)?.display==="contents")return!1;const w=Number(C.clientWidth??0),S=Number(C.getBoundingClientRect?.().width??0);return Number.isFinite(w)&&w>0||Number.isFinite(S)&&S>0},d=()=>{const C=t.value,w=e.value?.responsive?.target;if(u(w))return w;if(typeof w=="string"&&w.trim().length>0&&typeof document<"u"){let b=null;try{b=document.querySelector(w.trim())}catch{b=null}if(u(b))return b}let S=C?.parentElement??null;for(;S;){if(u(S))return S;S=S.parentElement}return u(C)||C instanceof HTMLElement?C:null},f=()=>{const C=typeof window<"u"?window.ResizeObserver:void 0;if(typeof C>"u")return;const w=d();w!==s&&(i&&(i.disconnect(),i=null),s=w,s&&(i=new C(()=>{v()}),i.observe(s)))},p=()=>{f();const C=Number(s?.clientWidth??0);if(Number.isFinite(C)&&C>0)return C;const w=Number(s?.getBoundingClientRect?.().width??0);return Number.isFinite(w)&&w>0?w:0},g=()=>{const C=typeof window<"u"?window.ResizeObserver:void 0;if(typeof C>"u")return;const w=t.value?.querySelector?.(sA)??null,S=[n.value,w].filter((b,k,x)=>b instanceof HTMLElement&&x.indexOf(b)===k);S.length===l.length&&S.every((b,k)=>b===l[k])||(a&&(a.disconnect(),a=null),l=S,S.length&&(a=new C(()=>{v()}),S.forEach(b=>a.observe(b))))},m=()=>{g();const C=t.value?.querySelector?.(sA),w=n.value,S=Number(C?.clientWidth??C?.getBoundingClientRect?.().width??0);if(Number.isFinite(S)&&S>0)return S;const b=Number(w?.clientWidth??w?.getBoundingClientRect?.().width??0);return Number.isFinite(b)&&b>0?b:816},v=()=>{const C=p(),w=e.value,S=w?.layout??"sidebar";if(S==="sidebar"){r.value=C,o.value=!1;return}if(S==="inline"){r.value=C,o.value=!0;return}if(!(Number.isFinite(C)&&C>0))return;r.value=C;const b=w?.responsive?.breakpoint;if(ZF(b)){o.value=C<b;return}const k=m(),x=QF(k);o.value=C<x};return ur(()=>{i&&(i.disconnect(),i=null),s=null,a&&(a.disconnect(),a=null),l=[]}),{superdocContainerWidth:r,isCompactCommentsMode:o,recalculateCompactCommentsMode:v,ensureCompactMeasurementObserver:f}}Ft();var aA=320,Bl=12,eN=220,tN=16,nN=500,lA=".superdoc-comment-highlight[data-comment-ids]",cA="data-comment-ids",rN=".sd-comment-anchor",q0=(e,t,n)=>Math.min(Math.max(e,t),n),oa=e=>Number(e),ms=e=>Number.isFinite(e),Y0=e=>e?.commentId??e?.importedId??null,uA=e=>String(e||"").split(",").map(t=>t.trim()).filter(Boolean),oN=e=>{const t=e?.value;if(!t)return null;const n=oa(t.ts);if(!ms(n)||Date.now()-n>nN)return null;const r=oa(t.x),o=oa(t.anchorRect?.bottom),i=ms(o)?o:oa(t.y);return!ms(r)||!ms(i)?null:{x:r,y:i}},iN=({rootEl:e,comment:t,pendingComment:n})=>{if(n?.value&&t?.commentId===n.value?.commentId){const a=e.querySelectorAll(lA);for(const l of a)if(uA(l.getAttribute(cA)).includes("pending")&&typeof l.getBoundingClientRect=="function")return l.getBoundingClientRect()}const r=Y0(t);if(!r)return null;const o=String(r),i=e.querySelectorAll(lA);for(const a of i)if(uA(a.getAttribute(cA)).includes(o)&&typeof a.getBoundingClientRect=="function")return a.getBoundingClientRect();const s=e.querySelector(`[data-track-change-id="${o}"]`);return s&&typeof s.getBoundingClientRect=="function"?s.getBoundingClientRect():null},sN=(e,t)=>{const{entry:n}=e(Y0(t)),r=oa(n?.bounds?.bottom);return ms(r)?r:oa(n?.bounds?.top)},aN=({selectionPosition:e,comment:t,pendingComment:n})=>e.value?.source==="pdf"||t?.selection?.source==="pdf"||n.value?.selection?.source==="pdf",lN=({rootEl:e,layersRect:t,comment:n})=>{const r=Y0(n);if(r==null)return NaN;const o=e.querySelector(`${rN}[data-id="${String(r)}"]`);if(!o||typeof o.getBoundingClientRect!="function")return NaN;const i=o.getBoundingClientRect();return oa(i.bottom)-oa(t.top)},cN=({comment:e,pendingComment:t,selectionPosition:n,activeZoom:r})=>{if(!t.value||e?.commentId!==t.value?.commentId)return NaN;const o=oa(n.value?.bottom);if(ms(o))return o*(n.value?.source==="pdf"?(r.value??100)/100:1);const i=oa(n.value?.top);return ms(i)?i*(n.value?.source==="pdf"?(r.value??100)/100:1):NaN},uN=({top:e,left:t})=>({top:`${Math.round(e)}px`,left:`${Math.round(t)}px`,right:"auto"}),dN=({rootRect:e,layersRect:t,anchorBottom:n,anchorClientX:r=NaN})=>{const o=t.top-e.top+n+tN,i=Math.max(Bl,e.height-eN),s=q0(o,Bl,i),a=Math.max(Bl,e.width-aA-Bl);let l;if(ms(r))l=q0(r-e.left+Bl,Bl,a);else{const u=e.width-(t.left-e.left+t.width)+Bl;l=q0(e.width-u-aA,Bl,a)}return{top:s,left:l}};function fN({activeComment:e,pendingComment:t,activeCompactComment:n,showCommentsSidebar:r,selectionPosition:o,activeZoom:i,superdocRoot:s,layers:a,documents:l,resolveCommentPositionEntry:u,clearActiveComment:d,clearPendingComment:f}){const p={top:"12px",right:"12px"},g=te(0),m=te({x:null,y:null,ts:0,anchorRect:null});let v=null,C=null;const w=()=>{m.value={x:null,y:null,ts:0,anchorRect:null}},S=(M,z,G)=>{if(!l.value?.some(L=>L.type==="application/pdf"))return!1;const F=M.querySelector(".superdoc__compact-comment-popover");return!n.value||!F||F.contains(z)||G?!1:(t.value&&f(),d(),w(),!0)},b=M=>{const z=s.value;if(!z||!a.value?.contains(M.target))return;const G=(typeof document.elementsFromPoint=="function"?document.elementsFromPoint(M.clientX,M.clientY):[]).find(L=>L?.nodeType===1&&z.contains(L)&&L.closest("[data-track-change-id], .superdoc-comment-highlight, .sd-comment-anchor"))?.closest("[data-track-change-id], .superdoc-comment-highlight, .sd-comment-anchor")??(M.target?.nodeType===1?M.target.closest("[data-track-change-id], .superdoc-comment-highlight, .sd-comment-anchor"):null);if(S(z,M.target,G)||M.button!==0||M.pointerType!=="mouse")return;const F=G&&typeof G.getBoundingClientRect=="function"?G.getBoundingClientRect():null;F&&(m.value={x:M.clientX,y:F.bottom,ts:Date.now(),anchorRect:{left:F.left,right:F.right,top:F.top,bottom:F.bottom}})},k=_e(()=>{g.value;const M=n.value;if(!M)return p;const z=s.value,G=a.value;if(!z||!G)return p;const F=z.getBoundingClientRect(),L=G.getBoundingClientRect(),$=oN(m),T=$?null:iN({rootEl:z,comment:M,pendingComment:t});let H=NaN,R=NaN;if($?(H=$.y-L.top,R=$.x):T?(H=T.bottom-L.top,R=T.left):H=sN(u,M),!ms(H)&&aN({selectionPosition:o,comment:M,pendingComment:t})&&(H=lN({rootEl:z,layersRect:L,comment:M})),ms(H)||(H=cN({comment:M,pendingComment:t,selectionPosition:o,activeZoom:i})),!ms(H))return p;const U=dN({rootRect:F,layersRect:L,anchorBottom:H,anchorClientX:R});return uN(U)});return jt([e,t,o,i,r,m],()=>{const M=typeof window<"u"?window.requestAnimationFrame:null,z=typeof window<"u"?window.cancelAnimationFrame:null;v!=null&&z?.(v),M&&(v=M(()=>{g.value+=1,v=null}))},{deep:!1}),jt(n,(M,z)=>{if(!z&&M){const G=document.activeElement;G instanceof HTMLElement&&(C=G)}},{deep:!1}),jt(t,(M,z)=>{!z&&M&&w()}),zn(()=>{document.addEventListener("pointerdown",b,!0)}),ur(()=>{document.removeEventListener("pointerdown",b,!0);const M=typeof window<"u"?window.cancelAnimationFrame:null;v!=null&&(M?.(v),v=null),C=null}),{compactCommentPopoverStyle:k,closeCompactCommentPopover:()=>{n.value&&(t.value&&f(),d(),C&&typeof C.focus=="function"&&C.focus(),C=null)},resetClickAnchor:w}}function Yo(...e){const t={};for(const n of e)if(!(typeof n!="object"||n===null))for(const[r,o]of Object.entries(n))o!==void 0&&(t[r]=o);return t}function zl(...e){for(const t of e)if(t!==void 0)return t}function hN(e,t){const n=Yo(e,t),r=Yo(e?.responsive,t?.responsive);return Object.keys(r).length>0?n.responsive=r:delete n.responsive,n}var X0=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function $m(e={}){const t=X0(e.hyperlinks)?e.hyperlinks:{},n=typeof t.onActivate=="function",r=X0(e.ui)?e.ui:{},o=X0(r.linkPopover)?r.linkPopover:{},i=e.hyperlinks===!1,s=e.ui===!1||r.linkPopover===!1,a=[{value:t.onActivate,source:"hyperlinks.onActivate"},{value:o.popoverResolver,source:"compatibility"},{value:e.modules?.links?.popoverResolver,source:"compatibility"}].find(({value:d})=>d!==void 0),l=i||!n&&s,u=!l&&typeof a?.value=="function"?a.value:void 0;return{handler:u,handlerSource:u?a.source:void 0,editableActivationDisabled:l,builtInEditorDisabled:s,interceptsNavigationOnly:i||n}}function pN(e,t){if(!e||typeof e.entityId!="string"||e.entityType!=="comment"&&e.entityType!=="trackedChange")return null;const n=typeof t=="function"?t(e.entityId):null;if(e.entityType==="comment"&&n?.trackedChange)return e.entityId;const r=n?.commentId??n?.importedId??e.entityId;return r!=null?String(r):null}var mN=new Set(["shell","receipt"]),dA=/^[a-zA-Z][a-zA-Z0-9_-]{0,127}$/,gN=/^[a-z][a-z0-9-]*(?::[a-z][a-z0-9-]*)?$/;function fA(e){if(!e||typeof e!="object")return{};const t=e.reason??(e.failureSource==="receipt"?e.failure?.code:void 0);return{...mN.has(e.failureSource)?{failureSource:e.failureSource}:{},...typeof t=="string"&&dA.test(t)?{reason:t}:{},...typeof e.inputKind=="string"&&dA.test(e.inputKind)?{inputKind:e.inputKind}:{},...typeof e.editableCommandKind=="string"&&e.editableCommandKind.length<=128&&gN.test(e.editableCommandKind)?{editableCommandKind:e.editableCommandKind}:{}}}function hA(e){const t=new Map,n=r=>typeof r=="string"&&r.length>0?r:"__default__";return{shouldNotify(r,o){if(!e(o))return!1;const i=n(r);let s=t.get(i);return s||(s=new WeakSet,t.set(i,s)),s.has(o)?!1:(s.add(o),!0)},clear(r){t.delete(n(r))}}}var vN="no-author-configured",yN="author-required",bN="This edit needs an author identity. Set `user.name` in your SuperDoc configuration and reopen the document to make tracked or revision-overlapping edits.";function pA(e){return typeof e=="string"&&e.includes(vN)}function mA(e){if(!e||e.type!=="mutation:rejected")return!1;if(e.failureSource==="receipt"){const t=e.failure;return t?t.code==="PRECONDITION_FAILED"&&pA(t.message):!1}return e.failureSource==="shell"?e.reason==="author-required"?!0:e.reason==="PRECONDITION_FAILED"&&pA(e.message):!1}function wN(){return hA(mA)}function CN(e,t){return t?.schemaVersion!==1||t.decision!=="accept"&&t.decision!=="reject"?null:{documentId:typeof e=="string"?e:null,decision:t.decision,requestedCount:t.requestedCount,successfulCount:t.appliedCount,permissionDeniedCount:t.deniedCount}}var kN=new Set(["keydown","beforeinput","compositionend","cut","paste","drop","pointerup","programmatic"]),SN=new Set(["insert-text","replace-text","delete-backward","delete-forward","plain-text-paste","clipboard-paste","image-delete","image-drop","image-paste","image-move","sdt-move","structural:enter-split-paragraph","structural:enter-insert-paragraph-before","structural:enter-insert-paragraph-after","structural:enter-list-outdent","structural:enter-list-exit","structural:shift-enter-line-break","structural:mod-enter-page-break","structural:backspace-boundary-merge-with-previous","structural:delete-boundary-merge-with-next","structural:list-indent","structural:list-outdent","tab:paragraph-insert-tab","tab:list-indent-range","tab:list-outdent-range","tab:table-append-row"]),_N=new Set(["beforeinput","compositionend","cut","paste","drop"]),AN=new Set(["shell","receipt"]),IN="edit-rejected",EN="This edit couldn’t be completed. Adjust the selection and try again.";function xN(e){return!!(e&&e.type==="mutation:rejected"&&e.origin==="document-surface"&&AN.has(e.failureSource)&&kN.has(e.inputKind)&&(SN.has(e.editableCommandKind)||e.editableCommandKind==null&&_N.has(e.inputKind)))}function TN(e,t){return{error:new Error(EN,{cause:fA(t)}),code:IN,editor:null,...typeof e=="string"&&e.length>0?{documentId:e}:{}}}function RN(){return hA(xN)}var MN=e=>!!(e?.anchor&&e?.focus&&(e.anchor.blockId!==e.focus.blockId||e.anchor.blockOffset!==e.focus.blockOffset)),LN=(e,t)=>{if(!e||e.rangeCount<1||e.isCollapsed||!t)return!1;const n=e.getRangeAt(0);return!t.contains(n.startContainer)&&!t.contains(n.endContainer)},PN=(e,t)=>e!=="editing"&&e!=="suggesting"?!1:MN(t),DN=(e,t)=>e===!0&&t?.source==="document-editor",ON=Lr((()=>{})),FN=Gd({default:()=>IA}),gA,vA,yA,bA,wA,CA,kA,SA,_A,AA,IA,NN=Lr((()=>{Ft(),ON(),yn(),gA=["onKeydown"],vA=["id"],yA={class:"sd-password-prompt__description"},bA={class:"sd-password-prompt__field"},wA=["placeholder","disabled","aria-label"],CA={key:0,class:"sd-password-prompt__error",role:"alert"},kA={class:"sd-password-prompt__actions"},SA=["disabled"],_A=["disabled"],AA={__name:"PasswordPromptSurface",props:{surfaceId:{type:String,default:""},mode:{type:String,default:"dialog"},request:{type:Object,default:()=>({})},resolve:{type:Function,default:()=>{}},close:{type:Function,default:()=>{}},passwordPrompt:{type:Object,required:!0}},setup(e){const t=e,n=te(""),r=te(!1),o=te(t.passwordPrompt.errorCode==="DOCX_PASSWORD_INVALID"),i=te(o.value?t.passwordPrompt.texts.invalidMessage:""),s=_e(()=>o.value?t.passwordPrompt.texts.invalidTitle:t.passwordPrompt.texts.title),a=_e(()=>n.value.length>0&&!r.value);async function l(){if(!a.value)return;r.value=!0,i.value="";const d=await t.passwordPrompt.attemptPassword(n.value);if(d.success){t.resolve({password:n.value});return}r.value=!1,n.value="",d.errorCode==="DOCX_PASSWORD_INVALID"?(o.value=!0,i.value=t.passwordPrompt.texts.invalidMessage):d.errorCode==="timeout"?i.value=t.passwordPrompt.texts.timeoutMessage:i.value=t.passwordPrompt.texts.genericErrorMessage}function u(){t.close("user-cancelled")}return(d,f)=>(pe(),Ce("div",{class:"sd-password-prompt",onKeydown:Ko(tn(l,["prevent"]),["enter"])},[ce("h3",{id:`sd-password-prompt-heading-${e.surfaceId}`,class:"sd-password-prompt__heading"},Et(s.value),9,vA),ce("p",yA,Et(e.passwordPrompt.texts.description),1),ce("div",bA,[ki(ce("input",{"onUpdate:modelValue":f[0]||(f[0]=p=>n.value=p),type:"password",class:"sd-password-prompt__input",placeholder:e.passwordPrompt.texts.placeholder,disabled:r.value,autocomplete:"current-password","aria-label":e.passwordPrompt.texts.inputAriaLabel},null,8,wA),[[Ii,n.value]])]),i.value?(pe(),Ce("p",CA,Et(i.value),1)):ut("",!0),ce("div",kA,[ce("button",{type:"button",class:"sd-password-prompt__btn sd-password-prompt__btn--cancel",disabled:r.value,onClick:u},Et(e.passwordPrompt.texts.cancelLabel),9,SA),ce("button",{type:"button",class:"sd-password-prompt__btn sd-password-prompt__btn--submit",disabled:!a.value,onClick:l},Et(r.value?e.passwordPrompt.texts.busyLabel:e.passwordPrompt.texts.submitLabel),9,_A)])],40,gA))}},IA=mn(AA,[["__scopeId","data-v-ecf7f6fb"]])}));Ft();var BN=["DOCX_PASSWORD_REQUIRED","DOCX_PASSWORD_INVALID"],zN=3e4,Gi={title:"Password Required",invalidTitle:"Incorrect Password",description:"This document is password protected. Enter the password to open it.",placeholder:"Enter password",inputAriaLabel:"Document password",submitLabel:"Open",cancelLabel:"Cancel",busyLabel:"Decrypting…",invalidMessage:"Incorrect password. Please try again.",timeoutMessage:"Timed out while decrypting. Please try again.",genericErrorMessage:"Unable to decrypt this document."};function jN({getSurfaceManager:e,getPasswordPromptConfig:t,onUnhandled:n}){const r=[],o=Pr(null),i=new Map;let s=!1;function a(m,v,C){if(!m||!BN.includes(v)||t()===!1||!e())return!1;const w=i.get(m.id);if(w)return clearTimeout(w.timer),w.resolve({success:!1,errorCode:v}),i.delete(m.id),!0;const S=r.find(b=>b.doc.id===m.id);return S?(S.errorCode=v,S.originalException=C,!0):(o.value?.doc.id===m.id||(r.push({doc:m,errorCode:v,originalException:C}),d()),!0)}function l(m){if(!m)return;const v=i.get(m.id);v&&(clearTimeout(v.timer),v.resolve({success:!0}),i.delete(m.id))}function u(){s=!0;for(const[,m]of i)clearTimeout(m.timer),m.resolve({success:!1,errorCode:"destroyed"});i.clear(),r.length=0,o.value=null}function d(){if(s||o.value||r.length===0)return;const m=r.shift();m&&f(m).catch(v=>{o.value=null,console.error("[SuperDoc] Password prompt error:",v),n?.(m.doc,m.errorCode,m.originalException),d()})}async function f({doc:m,errorCode:v,originalException:C}){const w=e();if(!w||s)return;const S=p(),b=z=>(m.password=z,m.editorMountNonce++,new Promise(G=>{const F=setTimeout(()=>{i.delete(m.id),G({success:!1,errorCode:"timeout"})},zN);i.set(m.id,{resolve:G,timer:F})})),k={documentId:m.id,errorCode:v,texts:S.texts,attemptPassword:b},x=g(S,{documentId:m.id,errorCode:v,texts:S.texts});if(x.suppressed){n?.(m,v,C),d();return}o.value={doc:m,surfaceHandle:null};let M;if(x.component)M=w.open({mode:"dialog",closeOnBackdrop:!1,ariaLabel:S.texts.title,component:Gr(x.component),props:{...x.props,passwordPrompt:k}});else if(x.render){const z=x.render;M=w.open({mode:"dialog",closeOnBackdrop:!1,ariaLabel:S.texts.title,render:G=>z({container:G.container,passwordPrompt:k,resolve:G.resolve,close:G.close,surfaceId:G.surfaceId,mode:G.mode})})}else{const z=(await Promise.resolve().then(()=>(NN(),FN))).default,G=`password-prompt-${m.id}`;M=w.open({id:G,mode:"dialog",closeOnBackdrop:!1,ariaLabelledBy:`sd-password-prompt-heading-${G}`,component:Gr(z),props:{passwordPrompt:k}})}o.value={doc:m,surfaceHandle:M},await M.result,o.value=null,d()}function p(){const m=t();if(m===!1)return{enabled:!1,texts:Gi};const v=typeof m=="object"&&m!==null?m:{};if(v.component!=null&&typeof v.render=="function")throw new Error('modules.surfaces.passwordPrompt cannot provide both "component" and "render". Use one or the other.');return{enabled:!0,texts:{title:v.title??Gi.title,invalidTitle:v.invalidTitle??Gi.invalidTitle,description:v.description??Gi.description,placeholder:v.placeholder??Gi.placeholder,inputAriaLabel:v.inputAriaLabel??Gi.inputAriaLabel,submitLabel:v.submitLabel??Gi.submitLabel,cancelLabel:v.cancelLabel??Gi.cancelLabel,busyLabel:v.busyLabel??Gi.busyLabel,invalidMessage:v.invalidMessage??Gi.invalidMessage,timeoutMessage:v.timeoutMessage??Gi.timeoutMessage,genericErrorMessage:v.genericErrorMessage??Gi.genericErrorMessage},component:v.component,props:v.props,render:v.render,resolver:v.resolver}}function g(m,v){if(typeof m.resolver=="function"){const C=m.resolver(v);if(C!=null&&C.type!=="default"){if(C.type==="none")return{suppressed:!0};if(C.type==="custom")return{component:C.component,props:C.props};if(C.type==="external")return{render:C.render}}}return m.component!=null?{component:m.component,props:m.props}:typeof m.render=="function"?{render:m.render}:{builtin:!0}}return{handleEncryptionError:a,handleEditorReady:l,destroy:u}}function EA(e,{getCurrentSession:t,applySlice:n,onSettled:r}){return()=>{if(e===t())try{n(e.getSnapshot())}catch{}r()}}var VN=Lr((()=>{})),UN=Gd({default:()=>XA}),xA,TA,RA,MA,LA,PA,DA,OA,FA,NA,BA,zA,jA,VA,UA,$A,HA,GA,WA,KA,qA,YA,XA,$N=Lr((()=>{Ft(),VN(),yn(),xA=["onKeydown"],TA={class:"sd-find-replace__row"},RA=["title","aria-label","aria-expanded"],MA=["value","placeholder","aria-label"],LA={key:0,class:"sd-find-replace__count"},PA=["title","aria-label","aria-pressed"],DA=["title","aria-label","aria-pressed"],OA=["title","aria-label","aria-pressed"],FA={class:"sd-find-replace__nav"},NA=["disabled","title","aria-label"],BA=["disabled","title","aria-label"],zA=["title","aria-label"],jA={key:0,class:"sd-find-replace__row"},VA={class:"sd-find-replace__field"},UA=["value","placeholder","aria-label"],$A={class:"sd-find-replace__nav sd-find-replace__nav--actions"},HA=["disabled","title"],GA=["disabled","title"],WA={key:1,class:"sd-find-replace__error",role:"alert"},KA={key:0,class:"sd-find-replace__row-indent","aria-hidden":"true"},qA={class:"sd-find-replace__error-text"},YA={__name:"FindReplaceSurface",props:{surfaceId:{type:String,default:""},mode:{type:String,default:"floating"},request:{type:Object,default:()=>({})},resolve:{type:Function,default:()=>{}},close:{type:Function,default:()=>{}},findReplace:{type:Object,required:!0}},setup(e){const t=e,n=te(null),r=_e(()=>{const v=t.findReplace;return!!(!v.hasMatches?.value||v.replacePending?.value===!0||v.canReplace&&v.canReplace.value===!1)}),o=_e(()=>{if(r.value)return!0;const v=t.findReplace;return!!(v.canReplaceAll&&v.canReplaceAll.value===!1)}),i=_e(()=>t.findReplace.ignoreDiacriticsSupported?.value!==!1),s=_e(()=>t.findReplace.replaceEnabled&&t.findReplace.replaceCanMutate?.value!==!1),a=_e(()=>t.findReplace.regexSupported?.value===!0),l=_e(()=>t.findReplace.searchError?.value??null);function u(v){v.key==="Enter"&&!v.shiftKey?(v.preventDefault(),d()):v.key==="Enter"&&v.shiftKey&&(v.preventDefault(),f())}function d(){t.findReplace.goNext(),m()}function f(){t.findReplace.goPrev(),m()}function p(){t.findReplace.close("user-closed")}function g(v){const C=[];let w=v?.parentElement??null;for(;w;){const b=w.ownerDocument?.defaultView?.getComputedStyle?.(w);if(b){const k=`${b.overflowY} ${b.overflowX}`;(k.includes("auto")||k.includes("scroll"))&&C.push(w)}w=w.parentElement}const S=v?.ownerDocument?.scrollingElement;return S&&!C.includes(S)&&C.push(S),C}function m(){const v=n.value;if(!v)return;const C=g(v).map(w=>({el:w,top:w.scrollTop,left:w.scrollLeft}));v.focus({preventScroll:!0});for(const{el:w,top:S,left:b}of C)w.scrollTop!==S&&(w.scrollTop=S),w.scrollLeft!==b&&(w.scrollLeft=b)}return zn(()=>{t.findReplace.registerFocusFn(m)}),(v,C)=>(pe(),Ce("div",{class:"sd-find-replace",onKeydown:Ko(tn(p,["stop"]),["esc"])},[ce("div",TA,[s.value?(pe(),Ce("button",{key:0,type:"button",class:Zt(["sd-find-replace__btn sd-find-replace__btn--expander",{"sd-find-replace__btn--expander-open":e.findReplace.showReplace.value}]),title:e.findReplace.texts.toggleReplaceLabel,"aria-label":e.findReplace.texts.toggleReplaceAriaLabel,"aria-expanded":e.findReplace.showReplace.value?"true":"false",onClick:C[0]||(C[0]=w=>e.findReplace.showReplace.value=!e.findReplace.showReplace.value)},[...C[14]||(C[14]=[ce("svg",{viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true"},[ce("path",{d:"M6 3.5 10.5 8 6 12.5",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],10,RA)):ut("",!0),ce("div",{class:Zt(["sd-find-replace__field",{"sd-find-replace__field--error":l.value}])},[C[15]||(C[15]=ce("svg",{class:"sd-find-replace__search-icon",viewBox:"0 0 16 16",width:"15",height:"15","aria-hidden":"true"},[ce("path",{d:"M7 1a6 6 0 1 0 3.7 10.7l3.3 3.3 1-1-3.3-3.3A6 6 0 0 0 7 1Zm0 1.5a4.5 4.5 0 1 1 0 9 4.5 4.5 0 0 1 0-9Z",fill:"currentColor"})],-1)),ce("input",{ref_key:"findInputRef",ref:n,value:e.findReplace.findQuery.value,onInput:C[1]||(C[1]=w=>e.findReplace.findQuery.value=w.target.value),type:"text",class:"sd-find-replace__input sd-find-replace__input--search","data-sd-autofocus":"",placeholder:e.findReplace.texts.findPlaceholder,"aria-label":e.findReplace.texts.findAriaLabel,onKeydown:u},null,40,MA),e.findReplace.findQuery.value&&!l.value?(pe(),Ce("span",LA,Et(e.findReplace.matchLabel.value),1)):ut("",!0),ce("button",{type:"button",class:Zt(["sd-find-replace__btn sd-find-replace__btn--toggle",{"sd-find-replace__btn--active":e.findReplace.caseSensitive.value}]),title:e.findReplace.texts.matchCaseAriaLabel,"aria-label":e.findReplace.texts.matchCaseAriaLabel,"aria-pressed":e.findReplace.caseSensitive.value?"true":"false",onMousedown:C[2]||(C[2]=tn(()=>{},["prevent"])),onClick:C[3]||(C[3]=w=>e.findReplace.caseSensitive.value=!e.findReplace.caseSensitive.value)},Et(e.findReplace.texts.matchCaseLabel),43,PA),i.value?(pe(),Ce("button",{key:1,type:"button",class:Zt(["sd-find-replace__btn sd-find-replace__btn--toggle",{"sd-find-replace__btn--active":e.findReplace.ignoreDiacritics.value}]),title:e.findReplace.texts.ignoreDiacriticsAriaLabel,"aria-label":e.findReplace.texts.ignoreDiacriticsAriaLabel,"aria-pressed":e.findReplace.ignoreDiacritics.value?"true":"false",onMousedown:C[4]||(C[4]=tn(()=>{},["prevent"])),onClick:C[5]||(C[5]=w=>e.findReplace.ignoreDiacritics.value=!e.findReplace.ignoreDiacritics.value)},Et(e.findReplace.texts.ignoreDiacriticsLabel),43,DA)):ut("",!0),a.value?(pe(),Ce("button",{key:2,type:"button",class:Zt(["sd-find-replace__btn sd-find-replace__btn--toggle",{"sd-find-replace__btn--active":e.findReplace.regex.value}]),title:e.findReplace.texts.regexAriaLabel,"aria-label":e.findReplace.texts.regexAriaLabel,"aria-pressed":e.findReplace.regex.value?"true":"false",onMousedown:C[6]||(C[6]=tn(()=>{},["prevent"])),onClick:C[7]||(C[7]=w=>e.findReplace.regex.value=!e.findReplace.regex.value)},Et(e.findReplace.texts.regexLabel),43,OA)):ut("",!0)],2),ce("div",FA,[ce("button",{type:"button",class:"sd-find-replace__btn sd-find-replace__btn--icon",disabled:!e.findReplace.hasMatches.value,title:e.findReplace.texts.previousMatchLabel,"aria-label":e.findReplace.texts.previousMatchAriaLabel,onClick:C[8]||(C[8]=w=>f())},[...C[16]||(C[16]=[ce("svg",{viewBox:"0 0 16 16",width:"16",height:"16","aria-hidden":"true"},[ce("path",{d:"M10 3.5 5.5 8 10 12.5",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],8,NA),ce("button",{type:"button",class:"sd-find-replace__btn sd-find-replace__btn--icon",disabled:!e.findReplace.hasMatches.value,title:e.findReplace.texts.nextMatchLabel,"aria-label":e.findReplace.texts.nextMatchAriaLabel,onClick:C[9]||(C[9]=w=>d())},[...C[17]||(C[17]=[ce("svg",{viewBox:"0 0 16 16",width:"16",height:"16","aria-hidden":"true"},[ce("path",{d:"M6 3.5 10.5 8 6 12.5",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],8,BA),C[19]||(C[19]=ce("span",{class:"sd-find-replace__divider","aria-hidden":"true"},null,-1)),ce("button",{type:"button",class:"sd-find-replace__btn sd-find-replace__btn--icon",title:e.findReplace.texts.closeLabel,"aria-label":e.findReplace.texts.closeAriaLabel,onClick:p},[...C[18]||(C[18]=[ce("svg",{viewBox:"0 0 16 16",width:"16",height:"16","aria-hidden":"true"},[ce("path",{d:"m4.5 4.5 7 7m0-7-7 7",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"})],-1)])],8,zA)])]),e.findReplace.showReplace.value&&s.value?(pe(),Ce("div",jA,[C[20]||(C[20]=ce("span",{class:"sd-find-replace__row-indent","aria-hidden":"true"},null,-1)),ce("div",VA,[ce("input",{value:e.findReplace.replaceText.value,onInput:C[10]||(C[10]=w=>e.findReplace.replaceText.value=w.target.value),type:"text",class:"sd-find-replace__input",placeholder:e.findReplace.texts.replacePlaceholder,"aria-label":e.findReplace.texts.replaceAriaLabel,onKeydown:C[11]||(C[11]=Ko(tn(w=>e.findReplace.replaceCurrent(),["prevent"]),["enter"]))},null,40,UA)]),ce("div",$A,[ce("button",{type:"button",class:"sd-find-replace__btn sd-find-replace__btn--action",disabled:r.value,title:e.findReplace.texts.replaceLabel,onClick:C[12]||(C[12]=w=>e.findReplace.replaceCurrent())},Et(e.findReplace.texts.replaceLabel),9,HA),ce("button",{type:"button",class:"sd-find-replace__btn sd-find-replace__btn--action",disabled:o.value,title:e.findReplace.texts.replaceAllLabel,onClick:C[13]||(C[13]=w=>e.findReplace.replaceAll())},Et(e.findReplace.texts.replaceAllLabel),9,GA)])])):ut("",!0),l.value?(pe(),Ce("div",WA,[s.value?(pe(),Ce("span",KA)):ut("",!0),ce("span",qA,Et(l.value),1)])):ut("",!0)],40,xA))}},XA=mn(YA,[["__scopeId","data-v-5dba4c36"]])}));Ft();var mr={findPlaceholder:"Find",findAriaLabel:"Find text",replacePlaceholder:"Replace",replaceAriaLabel:"Replace text",noResultsLabel:"No results",previousMatchLabel:"Previous match (Shift+Enter)",previousMatchAriaLabel:"Previous match",nextMatchLabel:"Next match (Enter)",nextMatchAriaLabel:"Next match",closeLabel:"Close (Escape)",closeAriaLabel:"Close find and replace",replaceLabel:"Replace",replaceAllLabel:"All",toggleReplaceLabel:"Toggle replace",toggleReplaceAriaLabel:"Toggle replace",matchCaseLabel:"Aa",matchCaseAriaLabel:"Match case",regexLabel:".*",regexAriaLabel:"Use regular expression",invalidPatternLabel:"Invalid pattern",ignoreDiacriticsLabel:"ä≡a",ignoreDiacriticsAriaLabel:"Ignore diacritics"};function HN(e){if(!e)return null;const t=e.extensionStorage,n=e.storage,r=t?.Search??n?.Search;if(r?.searchIndex||r?.searchResults)return r;const o=e.extensionStorage??e.storage;if(o)for(const i of Object.keys(o)){const s=o[i];if(s&&typeof s=="object"&&"searchIndex"in s&&"searchResults"in s)return s}return null}function GN({getSurfaceManager:e,getActiveEditor:t,activeEditorRef:n,getFindReplaceConfig:r,getSuperDocUI:o}){let i=null,s=null,a=null,l=!1,u=!1;const d=te(!1);let f=null;const p=te(""),g=te(""),m=te(!1),v=te(!1),C=te(!1),w=te(!1),S=te(0),b=te(-1),k=te(!0),x=te(!0),M=te(!1),z=te(!0),G=te(!1),F=te(null);let L=mr;const $=_e(()=>p.value?S.value===0?L.noResultsLabel:`${b.value+1} of ${S.value}`:""),T=_e(()=>S.value>0),H=_e(()=>T.value&&!M.value&&k.value),R=_e(()=>H.value&&x.value);let U=null,W=null;function ee(P){return typeof P?.commands?.setSearchSession=="function"}function J(){try{const P=(typeof o=="function"?o():null)?.search;return P&&(typeof P.find=="function"||typeof P.search=="function")?P:null}catch{return null}}function Z(P){P&&(S.value=typeof P.total=="number"?P.total:0,b.value=typeof P.activeIndex=="number"?P.activeIndex:-1,k.value=P.canReplace===!0,x.value=typeof P.canReplaceAll=="boolean"?P.canReplaceAll:P.canReplace===!0,F.value=P.reason==="search-invalid-pattern"?L.invalidPatternLabel:null)}function Me(){if(a){fe();return}if(s){if(!p.value){try{s.commands.clearSearchSession()}catch{}S.value=0,b.value=-1;return}try{const P=s.commands.setSearchSession(p.value,{caseSensitive:m.value,ignoreDiacritics:v.value,highlight:!0,searchModel:we().includeDeletedText?"raw":"visible"});S.value=P.matches.length,b.value=P.activeMatchIndex}catch{}}}function fe(){const P=a;if(P){if(!p.value){try{P.clear()}catch{}S.value=0,b.value=-1,F.value=null;return}try{const N={caseSensitive:m.value,regex:C.value},me=we().includeDeletedText===!0;Z(typeof P.find=="function"?P.find(p.value,{...N,includeTrackedDeletions:me}):P.search(p.value,{...N,includeDeletedText:me}))}catch{}}}function ye(){U&&clearTimeout(U),U=setTimeout(Me,150)}jt(p,()=>{d.value&&ye()}),jt(m,()=>{d.value&&Me()}),jt(v,()=>{d.value&&Me()}),jt(C,()=>{d.value&&Me()});let ve=!0;function Pe(){if(T.value){if(a){try{a.next(),Z(a.getSnapshot())}catch{}return}if(s)try{const P=s.commands.nextSearchMatch();b.value=P.activeMatchIndex}catch{}}}function Ve(){if(T.value){if(a){try{a.previous(),Z(a.getSnapshot())}catch{}return}if(s)try{const P=s.commands.previousSearchMatch();b.value=P.activeMatchIndex}catch{}}}function nt(){if(ve&&!M.value&&T.value){if(a){if(!k.value)return;const P=a;M.value=!0;const N=EA(P,{getCurrentSession:()=>a,applySlice:Z,onSettled:()=>{M.value=!1}});let me=null;try{me=P.replace(g.value)}catch{}me&&typeof me.then=="function"?Promise.resolve(me).then(N,N):N();return}if(s)try{const P=s.commands.replaceSearchMatch(g.value);S.value=P.matches.length,b.value=P.activeMatchIndex}catch{}}}function ct(){if(ve&&!M.value&&T.value){if(a){if(!k.value||!x.value)return;const P=a;M.value=!0;const N=EA(P,{getCurrentSession:()=>a,applySlice:Z,onSettled:()=>{M.value=!1}});let me=null;try{me=P.replaceAll(g.value)}catch{}me&&typeof me.then=="function"?Promise.resolve(me).then(N,N):N();return}if(s)try{s.commands.replaceAllSearchMatches(g.value),S.value=0,b.value=-1}catch{}}}function ft(){if(a){try{Z(a.getSnapshot())}catch{}return}const P=HN(s);if(!P)return;const N=P.searchResults,me=Array.isArray(N)?N.length:0,Se=P.activeMatchIndex??-1;me!==S.value&&(S.value=me),Se!==b.value&&(b.value=Se)}function It(){Le(),W=setInterval(ft,200)}function Le(){U&&clearTimeout(U),U=null,W&&clearInterval(W),W=null}function oe(){p.value="",g.value="",m.value=!1,v.value=!1,C.value=!1,F.value=null,w.value=!1,S.value=0,b.value=-1,k.value=!0,x.value=!0,M.value=!1}function we(){const P=typeof r=="function"?r():void 0;if(P===!1||P==null)return{enabled:!1,texts:mr,replaceEnabled:!0};if(P===!0)return{enabled:!0,texts:mr,replaceEnabled:!0};const N=typeof P=="object"?P:{};if(N.component!=null&&typeof N.render=="function")throw new Error('Search configuration cannot provide both "component" and "render". Use one or the other.');return{enabled:!0,texts:{findPlaceholder:N.findPlaceholder??mr.findPlaceholder,findAriaLabel:N.findAriaLabel??mr.findAriaLabel,replacePlaceholder:N.replacePlaceholder??mr.replacePlaceholder,replaceAriaLabel:N.replaceAriaLabel??mr.replaceAriaLabel,noResultsLabel:N.noResultsLabel??mr.noResultsLabel,previousMatchLabel:N.previousMatchLabel??mr.previousMatchLabel,previousMatchAriaLabel:N.previousMatchAriaLabel??mr.previousMatchAriaLabel,nextMatchLabel:N.nextMatchLabel??mr.nextMatchLabel,nextMatchAriaLabel:N.nextMatchAriaLabel??mr.nextMatchAriaLabel,closeLabel:N.closeLabel??mr.closeLabel,closeAriaLabel:N.closeAriaLabel??mr.closeAriaLabel,replaceLabel:N.replaceLabel??mr.replaceLabel,replaceAllLabel:N.replaceAllLabel??mr.replaceAllLabel,toggleReplaceLabel:N.toggleReplaceLabel??mr.toggleReplaceLabel,toggleReplaceAriaLabel:N.toggleReplaceAriaLabel??mr.toggleReplaceAriaLabel,matchCaseLabel:N.matchCaseLabel??mr.matchCaseLabel,matchCaseAriaLabel:N.matchCaseAriaLabel??mr.matchCaseAriaLabel,regexLabel:N.regexLabel??mr.regexLabel,regexAriaLabel:N.regexAriaLabel??mr.regexAriaLabel,invalidPatternLabel:N.invalidPatternLabel??mr.invalidPatternLabel,ignoreDiacriticsLabel:N.ignoreDiacriticsLabel??mr.ignoreDiacriticsLabel,ignoreDiacriticsAriaLabel:N.ignoreDiacriticsAriaLabel??mr.ignoreDiacriticsAriaLabel},replaceEnabled:N.replaceEnabled??!0,includeDeletedText:N.includeDeletedText??!1,component:N.component,props:N.props,render:N.render,resolver:N.resolver,floating:N.floating&&typeof N.floating=="object"?N.floating:void 0}}function Q(P,N){if(typeof P.resolver=="function"){const me=P.resolver(N);if(me!=null&&me.type!=="default"){if(me.type==="none")return{suppressed:!0};if(me.type==="custom")return{component:me.component,props:me.props};if(me.type==="external")return{render:me.render}}}return P.component!=null?{component:P.component,props:P.props}:typeof P.render=="function"?{render:P.render}:{builtin:!0}}function I(P,N){return{findQuery:p,replaceText:g,caseSensitive:m,ignoreDiacritics:v,regex:C,showReplace:w,matchCount:S,activeMatchIndex:b,matchLabel:$,hasMatches:T,canReplace:H,canReplaceAll:R,replaceCanMutate:k,replacePending:M,ignoreDiacriticsSupported:z,regexSupported:G,searchError:F,replaceEnabled:P.replaceEnabled??!0,texts:P.texts,goNext:Pe,goPrev:Ve,replaceCurrent:nt,replaceAll:ct,registerFocusFn:me=>{f=me},close:me=>N(me)}}function re(P){return{get findQuery(){return P.findQuery.value},set findQuery(N){P.findQuery.value=N},get replaceText(){return P.replaceText.value},set replaceText(N){P.replaceText.value=N},get caseSensitive(){return P.caseSensitive.value},set caseSensitive(N){P.caseSensitive.value=N},get ignoreDiacritics(){return P.ignoreDiacritics.value},set ignoreDiacritics(N){P.ignoreDiacritics.value=N},get regex(){return P.regex.value},set regex(N){P.regex.value=N},get regexSupported(){return P.regexSupported.value},get searchError(){return P.searchError.value},get replaceCanMutate(){return P.replaceCanMutate.value},get showReplace(){return P.showReplace.value},set showReplace(N){P.showReplace.value=N},get matchCount(){return P.matchCount.value},get activeMatchIndex(){return P.activeMatchIndex.value},get matchLabel(){return P.matchLabel.value},get hasMatches(){return P.hasMatches.value},get canReplace(){return P.canReplace.value},get canReplaceAll(){return P.canReplaceAll?P.canReplaceAll.value:P.canReplace.value},get replacePending(){return P.replacePending.value},get ignoreDiacriticsSupported(){return P.ignoreDiacriticsSupported.value},replaceEnabled:P.replaceEnabled,texts:P.texts,goNext:P.goNext,goPrev:P.goPrev,replaceCurrent:P.replaceCurrent,replaceAll:P.replaceAll,registerFocusFn:P.registerFocusFn,close:P.close}}function j(P){if(P){if(typeof P?.commands?.clearSearchSession=="function"){try{P.commands.clearSearchSession()}catch{}return}if(a&&P===s)try{a.clear()}catch{}}}function X(){try{if(l||!e()||!t())return!1;if(i&&d.value)return!0;const P=we();if(!P.enabled||Q(P,{texts:P.texts,replaceEnabled:P.replaceEnabled??!0}).suppressed)return!1;if(!ee(t())){const N=J();if(!N)return!1;try{if(N.getSnapshot?.().available!==!0)return!1}catch{return!1}}return!0}catch{return!1}}async function K(){if(l)return;const P=e();if(P){if(i&&d.value){f?.();return}if(!u){u=!0;try{const N=t();if(!N){u=!1;return}const me=we();if(!me.enabled){u=!1;return}const Se=Q(me,{texts:me.texts,replaceEnabled:me.replaceEnabled??!0});if(Se.suppressed){u=!1;return}oe(),L=me.texts,ve=me.replaceEnabled??!0;const Re={placement:"top-right",autoFocus:!0,width:420,...me.floating};if(s&&s!==N&&j(s),s=N,a=ee(N)?null:J(),z.value=!a,G.value=!!a,a)try{Z(a.getSnapshot())}catch{}f=null;let ze=()=>{};const Ke=I(me,Ot=>ze(Ot));let ot;if(Se.component)ot=P.open({mode:"floating",ariaLabel:me.texts.findAriaLabel,closeOnEscape:!0,floating:Re,component:Gr(Se.component),props:{...Se.props,findReplace:Ke}});else if(Se.render){const Ot=Se.render;ot=P.open({mode:"floating",ariaLabel:me.texts.findAriaLabel,closeOnEscape:!0,floating:Re,render:Mt=>Ot({container:Mt.container,findReplace:re(Ke),resolve:Mt.resolve,close:Mt.close,surfaceId:Mt.surfaceId,mode:Mt.mode})})}else{let Ot;try{Ot=(await Promise.resolve().then(()=>($N(),UN))).default}catch{u=!1;return}if(l||i&&d.value){u=!1;return}const Mt=t()||N;s!==Mt&&(j(s),s=Mt,a=ee(Mt)?null:J(),z.value=!a),ot=P.open({mode:"floating",ariaLabel:me.texts.findAriaLabel,component:Gr(Ot),closeOnEscape:!0,floating:Re,props:{findReplace:Ke}})}ze=Ot=>ot.close(Ot??"programmatic"),i=ot,d.value=!0,u=!1,It();const mt=ot.id;ot.result.then(()=>{i?.id===mt?(Le(),j(s),i=null,d.value=!1,f=null):j(N!==s?N:null)})}catch(N){throw u=!1,N}}}}function ae(){i&&i.close("programmatic")}n&&jt(n,(P,N)=>{!d.value||!i||P!==N&&(j(N),ae())});function ke(){l=!0,Le(),ae(),s=null,a=null,f=null}return{open:K,close:ae,isOpen:d,wouldOpen:X,destroy:ke}}var sh=null;function Z0(e){e!=null&&(sh=e)}function WN(e){sh===e&&(sh=null)}function KN(e){return sh===null||sh===e}function qN(e,{focusInside:t,owner:n}){if(e.defaultPrevented)return!1;if(t)return!0;const r=document.activeElement;return(!r||r===document.body||r===document.documentElement)&&KN(n)}var YN=/^(https?|mailto|tel):/i,XN=/^(javascript|data|vbscript):/i,ZN=/^[a-z][a-z0-9+.-]*:/i;function QN(e){if(typeof e!="string")return null;const t=e.trim();return t?t.startsWith("#")?{href:t}:XN.test(t)?null:ZN.test(t)?YN.test(t)?{href:t}:null:{href:t}:null}var JN='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M0 64C0 46.3 14.3 32 32 32l48 0 16 0 128 0c70.7 0 128 57.3 128 128c0 31.3-11.3 60.1-30 82.3c37.1 22.4 62 63.1 62 109.7c0 70.7-57.3 128-128 128L96 480l-16 0-48 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l16 0 0-160L48 96 32 96C14.3 96 0 81.7 0 64zM224 224c35.3 0 64-28.7 64-64s-28.7-64-64-64L112 96l0 128 112 0zM112 288l0 128 144 0c35.3 0 64-28.7 64-64s-28.7-64-64-64l-32 0-112 0z"/></svg>',eB='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M128 64c0-17.7 14.3-32 32-32l192 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-58.7 0L160 416l64 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l58.7 0L224 96l-64 0c-17.7 0-32-14.3-32-32z"/></svg>',tB='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M16 64c0-17.7 14.3-32 32-32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-16 0 0 128c0 53 43 96 96 96s96-43 96-96l0-128-16 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-16 0 0 128c0 88.4-71.6 160-160 160s-160-71.6-160-160L64 96 48 96C30.3 96 16 81.7 16 64zM0 448c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32z"/></svg>',ZA='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M40 48C26.7 48 16 58.7 16 72l0 48c0 13.3 10.7 24 24 24l48 0c13.3 0 24-10.7 24-24l0-48c0-13.3-10.7-24-24-24L40 48zM192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L192 64zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zM16 232l0 48c0 13.3 10.7 24 24 24l48 0c13.3 0 24-10.7 24-24l0-48c0-13.3-10.7-24-24-24l-48 0c-13.3 0-24 10.7-24 24zM40 368c-13.3 0-24 10.7-24 24l0 48c0 13.3 10.7 24 24 24l48 0c13.3 0 24-10.7 24-24l0-48c0-13.3-10.7-24-24-24l-48 0z"/></svg>',nB=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc. (bullet shapes modified)--><path fill-rule="evenodd" d="M192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L192 64zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zM64 48 A48 48 0 1 0 64 144 A48 48 0 1 0 64 48 Z M64 68 A28 28 0 1 1 64 124 A28 28 0 1 1 64 68 Z M64 208 A48 48 0 1 0 64 304 A48 48 0 1 0 64 208 Z M64 228 A28 28 0 1 1 64 284 A28 28 0 1 1 64 228 Z M64 368 A48 48 0 1 0 64 464 A48 48 0 1 0 64 368 Z M64 388 A28 28 0 1 1 64 444 A28 28 0 1 1 64 388 Z"/></svg>
|
|
16
|
+
`?(pe(),Ce("div",IP,[...Ue[11]||(Ue[11]=[ce("span",{class:"change-type"},"Added line break",-1)])])):dt.deletedText?(pe(),Ce("div",EP,[Ue[12]||(Ue[12]=ce("span",{class:"change-type"},"Deleted ",-1)),ce("span",xP,'"'+Et(dt.deletedText)+'"',1)])):dt.trackedChangeText?(pe(),Ce("div",TP,[Ue[13]||(Ue[13]=ce("span",{class:"change-type"},"Added ",-1)),ce("span",RP,'"'+Et(dt.trackedChangeText)+'"',1)])):ut("",!0),dt.trackedChangeImagePreview?.src?(pe(),Ce("div",{key:12,class:"tracked-change-image-preview","data-track-change-image-preview-role":dt.trackedChangeImagePreview.role??void 0},[ce("img",{class:"tracked-change-image-preview__image",src:dt.trackedChangeImagePreview.src,alt:dt.trackedChangeImagePreview.alt||"Tracked image preview",style:An(J(dt.trackedChangeImagePreview)),loading:"lazy",decoding:"async"},null,12,LP)],8,MP)):ut("",!0)],10,sP),Qt.value&&$e.value&&Vn===0?(pe(),Ce("div",{key:0,class:"show-more-toggle",onClick:tn(qt,["stop","prevent"])}," Show more ")):ut("",!0),Mt.value&&$e.value&&Vn===0?(pe(),Ce("div",{key:1,class:"show-more-toggle",onClick:tn(qt,["stop","prevent"])}," Show less ")):ut("",!0)])):ut("",!0),dt.trackedChange?ut("",!0):(pe(),Ce("div",PP,[!et(F)&&!gt.value(dt)?(pe(),Ce("div",{key:0,class:Zt(["comment",Vn===0?Hn.value:void 0]),ref_for:!0,ref:Vn===0?jn:void 0,innerHTML:dt.commentText},null,10,DP)):et(F)&&!gt.value(dt)?(pe(),Ce("div",OP,Et(et($)[dt.importedId!==void 0?dt.importedId:dt.commentId]?.bounds),1)):(pe(),Ce("div",FP,[ce("div",NP,[en(E0,{ref_for:!0,ref:Me(dt.commentId),users:[],config:et(S),"include-header":!1,comment:dt},null,8,["config","comment"])]),ce("div",BP,[ce("button",{class:"sd-button reply-btn-cancel",onClick:tn(Dn=>Zo(dt),["stop","prevent"])},"Cancel",8,zP),ce("button",{class:Zt(["sd-button primary reply-btn-primary",{"sd-is-disabled":!Te.value||In.value}]),onClick:tn(Dn=>Za(dt),["stop","prevent"]),disabled:!Te.value||In.value,"data-disabled-reason":In.value?Ht.value?.reason??null:null}," Update ",10,jP)])])),Qt.value&&$e.value&&Vn===0&&!gt.value(dt)?(pe(),Ce("div",{key:3,class:"show-more-toggle",onClick:tn(qt,["stop","prevent"])}," Show more ")):ut("",!0),Mt.value&&$e.value&&Vn===0&&!gt.value(dt)?(pe(),Ce("div",{key:4,class:"show-more-toggle",onClick:tn(qt,["stop","prevent"])}," Show less ")):ut("",!0)])),Tn.value&&Vn===0?(pe(),Ce(Bt,{key:2},[Ue[14]||(Ue[14]=ce("div",{class:"comment-separator"},null,-1)),ce("div",{class:"collapsed-replies",onClick:tn(st,["stop","prevent"])},[ce("div",VP,[(pe(!0),Ce(Bt,null,Rn(Bn.value,Dn=>(pe(),hn(d_,{key:Dn.email||Dn.name,user:Dn,class:"mini-avatar"},null,8,["user"]))),128))]),ce("span",null,Et(qn.value)+" more "+Et(qn.value===1?"reply":"replies"),1)])],64)):ut("",!0),ae.value(Vn)?(pe(),Ce("div",UP)):ut("",!0)]))),128)),W.value?(pe(),Ce("div",$P,[ce("span",HP,Et(Mn.value),1),ce("button",{type:"button",class:"sd-button tracked-change-decision-alert__retry",onClick:tn(Jn,["stop","prevent"])}," Retry ")])):ut("",!0),ke.value&&!et(S).readOnly?(pe(),Ce(Bt,{key:3},[Re.value?(pe(),Ce("div",WP,[ce("div",KP,[en(E0,{ref_key:"commentInput",ref:R,users:Xr.value,config:et(S),comment:r.comment,"include-header":!1},null,8,["users","config","comment"])]),ce("div",qP,[ce("button",{class:"sd-button reply-btn-cancel",onClick:tn(Zo,["stop","prevent"])},"Cancel"),ce("button",{class:Zt(["sd-button primary reply-btn-primary",{"sd-is-disabled":!Te.value||In.value||ze.value}]),onClick:tn(bt,["stop","prevent"]),disabled:!Te.value||In.value||ze.value,"data-disabled-reason":sn.value}," Reply ",10,YP)])])):(pe(),Ce("button",{key:0,type:"button",class:Zt(["reply-pill",{"sd-is-disabled":In.value}]),onClick:tn(ot,["stop","prevent"]),disabled:In.value,"data-disabled-reason":In.value?Ht.value?.reason??null:null}," Reply or add others with @ ",10,GP))],64)):ut("",!0)],64))],14,ZL)),[[vt,Qe]])}}},x0=mn(XP,[["__scopeId","data-v-eefd4750"]]);Ft(),yn();var ZP=["tabindex","aria-posinset","aria-setsize","aria-label","data-comment-instance-id","data-comment-thread-id","data-comment-position-key","data-comment-page-index","data-review-directory-index"],QP={__name:"ReviewDirectoryListItem",props:{item:{type:Object,required:!0},index:{type:Number,required:!0},total:{type:Number,required:!0},tabIndex:{type:Number,default:-1}},emits:["focus-item","navigate"],setup(e,{emit:t}){const n=e,r=t,{activeComment:o,editingCommentId:i,pendingComment:s}=qs(Js()),a=te(null),l=te(112),u=te(typeof IntersectionObserver>"u"),d=te(!1);let f=null,p=null;const g=_e(()=>new Set((n.item.threadComments??[]).flatMap(x=>[x?.commentId,x?.importedId,x?.trackedChangeCanonicalId]).filter(x=>x!=null).map(String))),m=_e(()=>{const x=s.value?.commentId;return d.value||o.value!=null&&g.value.has(String(o.value))||i.value!=null&&g.value.has(String(i.value))||x!=null&&g.value.has(String(x))}),v=_e(()=>u.value||m.value),C=_e(()=>v.value?void 0:{minHeight:`${Math.max(1,l.value)}px`}),w=_e(()=>{const x=n.item.comment,M=x?.trackedChangeLabel??x?.commentText??x?.trackedChangeText??"Review item";return String(M).replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim().slice(0,160)||"Review item"}),S=()=>{const x=a.value?.getBoundingClientRect?.().height;Number.isFinite(x)&&x>0&&(l.value=x)},b=()=>{d.value=!0,r("focus-item",n.index)},k=x=>{["ArrowDown","ArrowUp","Home","End"].includes(x.key)&&(x.target?.closest?.('input, textarea, select, button, [contenteditable="true"]')||(x.preventDefault(),r("navigate",{index:n.index,key:x.key})))};return zn(()=>{typeof IntersectionObserver<"u"&&(f=new IntersectionObserver(x=>{const M=x[0];M&&(u.value=M.isIntersecting,M.isIntersecting&&Ct(S))},{root:null,rootMargin:"600px 0px"}),f.observe(a.value)),typeof ResizeObserver<"u"&&(p=new ResizeObserver(S),p.observe(a.value)),Ct(S)}),ur(()=>{f?.disconnect(),p?.disconnect()}),(x,M)=>(pe(),Ce("div",{ref_key:"shell",ref:a,class:"comment-item",role:"listitem",tabindex:e.tabIndex,"aria-posinset":e.index+1,"aria-setsize":e.total,"aria-label":w.value,style:An(C.value),"data-comment-instance-id":e.item.floatingInstanceId??"","data-comment-thread-id":e.item.comment.commentId??"","data-comment-position-key":e.item.comment.trackedChangeAnchorKey??"","data-comment-page-index":Number.isFinite(e.item.floatingPageIndex)?e.item.floatingPageIndex:"","data-review-directory-index":e.index,onFocusin:b,onFocusout:M[0]||(M[0]=z=>d.value=a.value?.contains?.(z.relatedTarget)===!0),onKeydown:k},[v.value?(pe(),hn(x0,{key:0,comment:e.item.comment,"thread-comments":e.item.threadComments,"floating-instance-id":e.item.floatingInstanceId,"floating-page-index":e.item.floatingPageIndex,"floating-position-entry":e.item.floatingPositionEntry,"is-floating-instance-active":e.item.isFloatingInstanceActive,onResize:S},null,8,["comment","thread-comments","floating-instance-id","floating-page-index","floating-position-entry","is-floating-instance-active"])):ut("",!0)],44,ZP))}},p_=mn(QP,[["__scopeId","data-v-29650a06"]]);Ft(),yn();var JP=["aria-busy"],eD={key:0},tD={key:1},nD="headerFooterPart",rD={__name:"commentsList",props:{showMainComments:{type:Boolean,default:!0},showResolvedComments:{type:Boolean,default:!0}},setup(e){const t=e,n=Js(),r=te(null),o=te(0),i=Ev(n,"isCommentsListVisible"),s=_e(()=>n.getFloatingCommentInstances),{activeComment:a,activeFloatingCommentInstanceId:l,commentsList:u,reviewDirectoryList:d,isReviewDirectoryActive:f,isReviewDirectoryLoading:p}=qs(n),g=_e(()=>f.value?n.getGroupedReviewDirectory:n.getGroupedComments),m=_e(()=>f.value?d.value:u.value),v=$=>[$?.commentId,$?.importedId,$?.trackedChangeCanonicalId].filter(T=>T!=null).map(String),C=_e(()=>{const $=new Map;for(const T of m.value){const H=[T];for(const R of v(T))$.set(R,H)}for(const T of m.value){const H=[T?.parentCommentId,T?.threadingParentCommentId,T?.trackedChangeThreadParentId].filter(R=>R!=null).map(String).map(R=>$.get(R)).find(Boolean);H&&!H.includes(T)&&H.push(T)}return $}),w=$=>{for(const T of v($)){const H=C.value.get(T);if(H)return H}return[$]},S=$=>{const T=s.value.filter(H=>H?.comment?.commentId===$?.commentId);return T.length<2?[]:$?.trackedChange?$?.trackedChangeStory?.storyType!==nD?[]:T:[]},b=$=>!$?.comment?.commentId||a.value!==$.comment.commentId?!1:l.value==null?$.isPrimary===!0:String(l.value)===String($.id),k=$=>{const T=S($);return T.length?T.map(H=>({id:H.id,comment:$,floatingInstanceId:String(H.id),floatingPageIndex:H.pageIndex,floatingPositionEntry:H.positionEntry??null,isFloatingInstanceActive:b(H),threadComments:w($)})):[{id:$.commentId,comment:$,floatingInstanceId:null,floatingPageIndex:null,floatingPositionEntry:null,isFloatingInstanceActive:void 0,threadComments:w($)}]},x=_e(()=>g.value.parentComments.flatMap($=>k($))),M=_e(()=>t.showResolvedComments&&g.value?.resolvedComments?.length>0),z=_e(()=>g.value.resolvedComments.map($=>({id:$.commentId,comment:$,floatingInstanceId:null,floatingPageIndex:null,floatingPositionEntry:null,isFloatingInstanceActive:void 0,threadComments:w($)}))),G=_e(()=>t.showMainComments?x.value.length:0),F=_e(()=>G.value+(M.value?z.value.length:0));jt(F,$=>{o.value=Math.max(0,Math.min(o.value,$-1))});const L=async({index:$,key:T})=>{const H=F.value-1;if(H<0)return;const R=T==="Home"?0:T==="End"?H:T==="ArrowUp"?Math.max(0,$-1):Math.min(H,$+1);o.value=R,await Ct();const U=r.value?.querySelector?.(`[data-review-directory-index="${R}"]`);U?.scrollIntoView?.({block:"nearest"}),U?.focus?.({preventScroll:!0})};return zn(()=>{i.value=!0}),ur(()=>{i.value=!1}),($,T)=>(pe(),Ce("div",{ref_key:"listRoot",ref:r,class:"comments-list",role:"list","aria-busy":et(f)&&et(p)?"true":"false"},[e.showMainComments?(pe(),Ce("div",eD,[(pe(!0),Ce(Bt,null,Rn(x.value,(H,R)=>(pe(),hn(p_,{key:H.id,item:H,index:R,total:F.value,"tab-index":R===o.value?0:-1,onFocusItem:T[0]||(T[0]=U=>o.value=U),onNavigate:L},null,8,["item","index","total","tab-index"]))),128))])):ut("",!0),M.value?(pe(),Ce("div",tD,[T[2]||(T[2]=ce("div",{class:"comment-title"},"Resolved",-1)),(pe(!0),Ce(Bt,null,Rn(z.value,(H,R)=>(pe(),hn(p_,{key:H.id,item:H,index:G.value+R,total:F.value,"tab-index":G.value+R===o.value?0:-1,onFocusItem:T[1]||(T[1]=U=>o.value=U),onNavigate:L},null,8,["item","index","total","tab-index"]))),128))])):ut("",!0)],8,JP))}},oD=mn(rD,[["__scopeId","data-v-89244745"]]);Ft();var iD=class extends av.default{element;config={comments:[],element:null,commentsStore:null};constructor(e,t){super(),this.config={...this.config,...e},this.element=this.config.element,this.app=null,this.superdoc=t,this.stopDirectoryObservers=[],this.directorySnapshots={comments:null,trackChanges:null},this.directoryItemRefs={comments:null,trackChanges:null},this.directoryGeneration=0,this.open()}syncDirectory(){const e=this.superdoc?.commentsStore;if(!e)return;const t=this.directorySnapshots.comments,n=this.directorySnapshots.trackChanges;e.isReviewDirectoryLoading=t==null||n==null,!(t==null&&n==null)&&e.setReviewDirectoryFromV2({superdoc:this.superdoc,commentItems:t??[],trackedChangeItems:n??[]})}startDirectoryObservers(){const e=++this.directoryGeneration,t=(r,o)=>{const i=l=>{if(e!==this.directoryGeneration)return;if((l?.listStatus??l?.status)!=="ready"){this.superdoc?.commentsStore&&(this.superdoc.commentsStore.isReviewDirectoryLoading=!0);return}const u=Array.isArray(l.items)?l.items:[];if(this.directoryItemRefs[o]===u){this.superdoc?.commentsStore&&(this.superdoc.commentsStore.isReviewDirectoryLoading=this.directorySnapshots.comments==null||this.directorySnapshots.trackChanges==null);return}this.directoryItemRefs[o]=u,this.directorySnapshots[o]=u,this.syncDirectory()},s=r.observe(l=>{i(l)}),a=()=>i(r.getSnapshot());return typeof globalThis.queueMicrotask=="function"?globalThis.queueMicrotask(a):Promise.resolve().then(a),s},n=this.superdoc?.ui;n&&(this.superdoc?.commentsStore&&(this.superdoc.commentsStore.isReviewDirectoryActive=!0,this.superdoc.commentsStore.isReviewDirectoryLoading=!0),this.stopDirectoryObservers=[t(n.comments,"comments"),t(n.trackChanges,"trackChanges")])}createVueApp(){this.app=Ac(oD);const e=this.superdoc?.app?._context?.provides;e&&this.app?._context?.provides&&Object.setPrototypeOf(this.app._context.provides,e),this.superdoc?.pinia&&(Df(this.superdoc.pinia),this.app.use(this.superdoc.pinia),this.app.config.globalProperties.$pinia=this.superdoc.pinia),this.app.directive("click-outside",cb),this.app.config.globalProperties.$superdoc=this.superdoc,!this.element&&this.config.selector&&(this.element=document.getElementById(this.config.selector)),this.container=this.app.mount(this.element),this.startDirectoryObservers()}close(){this.directoryGeneration+=1;for(const e of this.stopDirectoryObservers.splice(0))e?.();this.directorySnapshots={comments:null,trackChanges:null},this.directoryItemRefs={comments:null,trackChanges:null},this.superdoc?.commentsStore&&(this.superdoc.commentsStore.clearReviewDirectory(),this.superdoc.commentsStore.isReviewDirectoryActive=!1,this.superdoc.commentsStore.isReviewDirectoryLoading=!1),this.app&&(this.app.unmount(),this.app=null,this.container=null,this.element=null)}open(){this.app||this.createVueApp()}},Pl,T0=Lr((()=>{Pl=96/72}));Ft(),T0();var sD=96,aD=".superdoc__right-sidebar",lD=".sd-pdf-viewer-page",R0=Object.freeze({min:10,max:100,padding:0}),M0=e=>{const t=e&&typeof e=="object"?e:{},n=(s,a)=>typeof s=="number"&&Number.isFinite(s)&&s>0?s:a,r=n(t.min,R0.min),o=n(t.max,R0.max),i=typeof t.padding=="number"&&Number.isFinite(t.padding)&&t.padding>=0?t.padding:R0.padding;return{min:Math.min(r,o),max:Math.max(r,o),padding:i}},m_=(e,t)=>!(e>0)||!(t>0)?null:Math.round(e/t*100),g_=(e,t,n)=>{const r=m_(e-n.padding,t);return r===null?null:Math.max(1,Math.round(Math.min(n.max,Math.max(n.min,r))))},cD=(e,t,n)=>e>0?Number.isFinite(t)&&t>0?e/t*Pl:n>0?e/n:e:null,uD=e=>{if(!e||typeof e!="object")return 0;const t=e.widestPageWidthPx;if(typeof t=="number"&&Number.isFinite(t))return t;let n=0;const r=e.pages;if(Array.isArray(r))for(const o of r){const i=o?.base?.widthPx;typeof i=="number"&&Number.isFinite(i)&&i>n&&(n=i)}return n},v_=e=>{if(!e)return null;let t=0;try{t=uD(e.pageMetrics?.getSnapshot?.())}catch{t=0}if(t>0)return t;try{const o=e.getPages?.();if(Array.isArray(o))for(const i of o){const s=i?.size?.w;typeof s=="number"&&Number.isFinite(s)&&s>t&&(t=s)}}catch{t=0}if(t>0)return t;let n=null;try{n=e.getPageStyles?.()??null}catch{n=null}const r=n?.pageSize?.width;return typeof r=="number"&&Number.isFinite(r)&&r>0?r*sD:null};function dD({getSuperdoc:e,superdocContainerWidth:t,isReady:n,activeZoom:r,zoomMode:o,viewportMetrics:i,showCommentsSidebar:s,rightSidebarRef:a,superdocRoot:l,documents:u}){const d=()=>{if(!(u?.value??[]).some(x=>x?.type==="application/pdf"))return null;const b=l.value;if(!b?.querySelectorAll)return null;let k=0;for(const x of b.querySelectorAll(lD)){const M=Number(x.clientWidth)||Number(x.getBoundingClientRect?.().width)||0;let z=NaN;typeof window<"u"&&typeof window.getComputedStyle=="function"&&(z=Number.parseFloat(window.getComputedStyle(x).getPropertyValue("--scale-factor")));const G=(r.value??100)/100,F=cD(M,z,G);F!==null&&F>k&&(k=F)}return k>0?k:null},f=()=>{const b=e();if(!b)return null;const k=[],x=u?.value??[];for(const z of x){if(z?.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document")continue;const G=v_(z.getEditor?.());G!==null&&k.push(G)}if(k.length===0){const z=v_(b.activeEditor);z!==null&&k.push(z)}const M=d();if(M!==null&&k.push(M),k.length>0)return Math.max(...k);if(b.activeEditor){const z=l.value?.querySelector?.(".superdoc__document"),G=Number(z?.clientWidth)||Number(z?.getBoundingClientRect?.().width)||0;if(G>0){const F=(r.value??100)/100;return F>0?G/F:G}}return null},p=()=>{if(!s?.value)return 0;const b=a?.value??l.value?.querySelector?.(aD),k=Number(b?.offsetWidth)||Number(b?.getBoundingClientRect?.().width)||0;return k>0?k:0},g=(b,k)=>{const x=M0(b.config?.zoom?.fitWidth),M=g_(k.availableWidth,k.documentWidth,x);M!==null&&M!==r.value&&(r.value=M,b.emit("zoomChange",{zoom:M,mode:"fit-width"}))},m=()=>{const b=e();if(!b)return;const k=t.value;if(!(k>0)||!n.value)return;const x=f();if(x===null)return;const M=k-p(),z=m_(M,x);if(z===null)return;const G=Object.freeze({availableWidth:M,documentWidth:x,fitZoom:z}),F=i.value;(!F||F.availableWidth!==M||F.documentWidth!==x||F.fitZoom!==z)&&(i.value=G),(!F||F.fitZoom!==z||Math.round(F.documentWidth)!==Math.round(x))&&b.emit("viewport-change",G),o.value==="fit-width"&&g(b,G)};jt(t,()=>{Ct(()=>m())}),jt(n,b=>{b&&m()}),jt(o,b=>{b==="fit-width"&&m()}),s&&jt(s,()=>{Ct(()=>m())});const v=()=>{Ct(()=>m())},C=()=>{Ct(()=>m())},w=()=>{Ct(()=>m())},S=e();return S?.on?.("editorCreate",v),S?.on?.("pagination-update",C),S?.on?.("pdf:document-ready",w),ur(()=>{S?.off?.("editorCreate",v),S?.off?.("pagination-update",C),S?.off?.("pdf:document-ready",w)}),{evaluateViewport:m}}function fD(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null||Array.isArray(e)!==Array.isArray(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}var y_=".png,.jpg,.jpeg,image/png,image/jpeg",b_=new Set(["image/png","image/jpeg","image/jpg"]),hD=/\.(png|jpe?g)$/i;function w_(e){if(!e)return!1;const t=typeof e.type=="string"?e.type.toLowerCase():"";return t?b_.has(t):hD.test(String(e.name??""))}function L0(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(pD(String(r.result),e)),r.onerror=()=>n(r.error??new Error("image-read-failed")),r.readAsDataURL(e)})}function pD(e,t){const n=/^data:([^;,]*);base64,/.exec(e);if(!n)return e;const r=n[1].toLowerCase();if(b_.has(r))return e;const o=String(t?.name??""),i=/\.jpe?g$/i.test(o)?"image/jpeg":/\.png$/i.test(o)?"image/png":null;return i?`data:${i};base64,${e.slice(n[0].length)}`:e}async function mD(e,t){if(typeof t=="function"){const n=await t(e);if(typeof n!="string"||n.trim()==="")throw new Error("handleImageUpload returned an empty result");return n.startsWith("data:")?n:gD(n,e)}return L0(e)}async function gD(e,t){const n=await fetch(e);if(!n.ok)throw new Error(`image fetch failed: ${n.status}`);const r=await n.blob(),o=(/\.(?:png|jpe?g)(?:$|[?#])/i.test(e)?e.split(/[?#]/)[0]:"")||t?.name||"";return L0(o?Object.assign(r,{name:o}):r)}function vD({ownerDocument:e=document,onPick:t,onError:n}={}){const r=e.createElement("input");return r.type="file",r.accept=y_,r.hidden=!0,r.tabIndex=-1,r.setAttribute("data-superdoc-image-picker","true"),r.setAttribute("aria-hidden","true"),r.addEventListener("change",()=>{const o=r.files&&r.files[0];if(r.value="",!!o){if(!w_(o)){n?.(new Error(`unsupported image type: ${o.type||o.name}`));return}try{const i=t?.(o);i&&typeof i.then=="function"&&i.catch(s=>n?.(s))}catch(i){n?.(i)}}}),e.body?.appendChild(r),{input:r,open(){r.click()},destroy(){r.remove()}}}Ft();var yD={class:"sd-watermark__body"},bD={class:"sd-watermark__settings"},wD=["disabled"],CD={class:"sd-watermark__field"},kD=["value"],SD=["value"],_D={class:"sd-watermark__field"},AD=["value"],ID=["disabled"],ED={class:"sd-watermark__selection-list"},xD=["value","checked","onChange"],TD=["disabled"],RD={key:0,class:"sd-watermark__notice"},MD={key:1,class:"sd-watermark__notice"},LD=["disabled"],PD={class:"sd-watermark__types"},DD=["name","value","checked","onChange"],OD={class:"sd-watermark__field"},FD=["value"],ND={class:"sd-watermark__presets","aria-label":"Text presets"},BD=["onClick"],zD={class:"sd-watermark__font-row"},jD={class:"sd-watermark__field"},VD=["value"],UD=["value"],$D={class:"sd-watermark__field sd-watermark__size"},HD=["list","value"],GD=["id"],WD=["value"],KD={class:"sd-watermark__styles"},qD=["aria-pressed"],YD=["aria-pressed"],XD={class:"sd-watermark__field sd-watermark__font-color"},ZD={class:"sd-watermark__color"},QD=["value"],JD=["value"],e9={class:"sd-watermark__picture"},t9=["src"],n9=["accept"],r9={class:"sd-watermark__field"},o9=["value"],i9={key:0,value:"custom",disabled:""},s9=["value"],a9={class:"sd-watermark__check"},l9=["checked"],c9={class:"sd-watermark__check"},u9=["checked"],d9={key:2,class:"sd-watermark__field sd-watermark__transparency"},f9=["for"],h9={class:"sd-watermark__range"},p9=["id","value"],m9=["value"],g9={key:3,class:"sd-watermark__orientation"},v9=["name","value","checked","onChange"],y9={key:4,class:"sd-watermark__notice"},b9={key:5,class:"sd-watermark__notice"},w9=["aria-busy"],C9={class:"sd-watermark__page"},k9=["src","width","height"],S9={key:1},_9={class:"sd-watermark__impact"},A9={key:0,class:"sd-watermark__impact-details"},I9={key:0,class:"sd-watermark__error",role:"alert"},E9=["disabled"],x9={class:"sd-watermark__footer sd-dialog-footer"},T9={role:"status","aria-live":"polite"},R9={class:"sd-watermark__actions"},M9=["disabled"],L9=vl({__name:"WatermarkSurface",props:{model:{},surfaceId:{default:""},mode:{},request:{},resolve:{},close:{type:Function,default:()=>{}}},setup(e){const t=e,n=Pr(t.model.getSnapshot()),r=te(null),o=te(!1),i=te("");let s=0,a;const l=["DRAFT","CONFIDENTIAL","DO NOT COPY"],u=[{value:"none",label:"No watermark"},{value:"text",label:"Text"},{value:"picture",label:"Picture"}],d=_e(()=>n.value.phase==="loading"||n.value.phase==="applying"),f=_e(()=>!d.value&&!n.value.readonlyReason),p=_e(()=>n.value.canApply&&!d.value&&!o.value&&!n.value.stale),g=_e(()=>i.value||n.value.error),m=_e(()=>o.value?"Preparing picture…":n.value.phase==="loading"?"Loading watermarks…":n.value.phase==="applying"?"Applying changes; closing will not cancel them.":n.value.phase==="previewing"?"Updating preview…":n.value.dirty?"Changes apply when you choose Apply":"No changes"),v=_e(()=>{const{fonts:G,draft:F}=n.value;return G.some(L=>L.value===F.fontFamily)?G:[{value:F.fontFamily,label:F.fontFamily},...G]});function C(){s+=1,o.value=!1}function w(G){f.value&&(i.value="",t.model.patchDraft(G))}function S(G,F){const L=G.target.value;C(),t.model.setScope(F==="section"?L||null:n.value.sectionId,F==="variant"?L:n.value.variant)}function b(G,F){C();const L=new Set(n.value.selectedIds);F.target.checked?L.add(G):L.delete(G),t.model.selectWatermarks([...L])}async function k(G){const F=G.target,L=F.files?.[0];if(F.value="",!L||!f.value)return;if(C(),i.value="",!w_(L)){i.value="Choose a PNG or JPEG picture.";return}const $=s;o.value=!0;try{const T=await L0(L);if($!==s)return;w({src:T,pictureName:L.name,kind:"picture"})}catch{$===s&&(i.value="The picture could not be read. Choose it again.")}finally{$===s&&(o.value=!1)}}async function x(){if(p.value)try{await t.model.apply()}catch{i.value="The watermark could not be applied. Try again."}}async function M(){C(),i.value="";try{await t.model.reload()}catch{i.value="Watermarks could not be loaded. Try again."}}function z(){C(),t.close("user-cancelled")}return jt([()=>n.value.draft.kind,()=>n.value.sectionId,()=>n.value.variant,()=>n.value.selectedIds.join("\0")],C),zn(()=>{a=t.model.subscribe(G=>{n.value=G}),n.value=t.model.getSnapshot()}),ur(()=>{C(),a?.()}),(G,F)=>(pe(),Ce("form",{class:"sd-watermark sd-dialog-content",onSubmit:tn(x,["prevent"])},[ce("header",{class:"sd-watermark__header sd-dialog-header"},[F[17]||(F[17]=ce("h2",null,"Watermark",-1)),ce("button",{type:"button",class:"sd-dialog-close","aria-label":"Close watermark dialog",onClick:z},[...F[16]||(F[16]=[ce("svg",{width:"16",height:"16",viewBox:"0 0 16 16","aria-hidden":"true"},[ce("path",{d:"m4 4 8 8m0-8-8 8",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"})],-1)])])]),ce("div",yD,[ce("div",bD,[ce("fieldset",{class:"sd-watermark__scope",disabled:d.value},[F[22]||(F[22]=ce("legend",{class:"sd-watermark__sr-only"},"Watermark scope",-1)),ce("label",CD,[F[19]||(F[19]=ce("span",null,"Apply to",-1)),ce("select",{"aria-label":"Apply to",value:n.value.sectionId??"",onChange:F[0]||(F[0]=L=>S(L,"section"))},[F[18]||(F[18]=ce("option",{value:""},"Entire document",-1)),(pe(!0),Ce(Bt,null,Rn(n.value.sections,L=>(pe(),Ce("option",{key:L.id,value:L.id},Et(L.label),9,SD))),128))],40,kD)]),ce("label",_D,[F[21]||(F[21]=ce("span",null,"Page type",-1)),ce("select",{"aria-label":"Page type",value:n.value.variant,onChange:F[1]||(F[1]=L=>S(L,"variant"))},[...F[20]||(F[20]=[ce("option",{value:"all"},"All applicable",-1),ce("option",{value:"default"},"Default",-1),ce("option",{value:"first"},"First",-1),ce("option",{value:"even"},"Even",-1)])],40,AD)])],8,wD),n.value.items.length>1?(pe(),Ce("fieldset",{key:0,class:"sd-watermark__selection",disabled:d.value},[F[23]||(F[23]=ce("legend",null,"Watermarks to edit",-1)),ce("div",ED,[(pe(!0),Ce(Bt,null,Rn(n.value.items,L=>(pe(),Ce("label",{key:L.id,class:"sd-watermark__check"},[ce("input",{type:"checkbox",value:L.id,checked:n.value.selectedIds.includes(L.id),onChange:$=>b(L.id,$)},null,40,xD),ce("span",null,[Si(Et(L.label),1),ce("small",null,Et(L.locations),1)])]))),128))]),ce("button",{type:"button",disabled:!f.value,onClick:F[2]||(F[2]=L=>e.model.selectWatermarks([]))},"Add watermark",8,TD),n.value.selectedIds.length>1?(pe(),Ce("p",RD," Applying uses the settings below for all "+Et(n.value.selectedIds.length)+" selected copies. ",1)):ut("",!0)],8,ID)):ut("",!0),n.value.readonlyReason?(pe(),Ce("p",MD,Et(n.value.readonlyReason),1)):ut("",!0),ce("fieldset",{class:Zt(["sd-watermark__draft",{"sd-watermark__draft--text":n.value.draft.kind==="text"}]),disabled:!f.value},[F[40]||(F[40]=ce("legend",{class:"sd-watermark__sr-only"},"Watermark settings",-1)),ce("fieldset",PD,[F[24]||(F[24]=ce("legend",{class:"sd-watermark__sr-only"},"Watermark type",-1)),(pe(),Ce(Bt,null,Rn(u,L=>ce("label",{key:L.value,class:Zt({"is-selected":n.value.draft.kind===L.value})},[ce("input",{type:"radio",name:`watermark-type-${e.surfaceId}`,value:L.value,checked:n.value.draft.kind===L.value,onChange:$=>w({kind:L.value})},null,40,DD),ce("span",null,Et(L.value==="none"&&n.value.items.length>1&&n.value.selectedIds.length?"Remove selected":L.label),1)],2)),64))]),n.value.draft.kind==="text"?(pe(),Ce(Bt,{key:0},[ce("label",OD,[F[25]||(F[25]=ce("span",null,"Text",-1)),ce("input",{"aria-label":"Watermark text",type:"text",value:n.value.draft.text,onInput:F[3]||(F[3]=L=>w({text:L.target.value}))},null,40,FD)]),ce("div",ND,[(pe(),Ce(Bt,null,Rn(l,L=>ce("button",{key:L,type:"button",onClick:$=>w({text:L})},Et(L),9,BD)),64))]),ce("div",zD,[ce("label",jD,[F[26]||(F[26]=ce("span",null,"Font",-1)),ce("select",{"aria-label":"Font",value:n.value.draft.fontFamily,onChange:F[4]||(F[4]=L=>w({fontFamily:L.target.value}))},[(pe(!0),Ce(Bt,null,Rn(v.value,L=>(pe(),Ce("option",{key:L.value,value:L.value},Et(L.label),9,UD))),128))],40,VD)]),ce("label",$D,[F[28]||(F[28]=ce("span",null,"Size (pt)",-1)),ce("input",{"aria-label":"Font size",list:`watermark-sizes-${e.surfaceId}`,value:n.value.draft.fontSize==="auto"?"Auto":n.value.draft.fontSize,onChange:F[5]||(F[5]=L=>w({fontSize:L.target.value.toLowerCase()==="auto"?"auto":Number(L.target.value)}))},null,40,HD),ce("datalist",{id:`watermark-sizes-${e.surfaceId}`},[F[27]||(F[27]=ce("option",{value:"Auto"},null,-1)),(pe(),Ce(Bt,null,Rn([24,36,48,72,96],L=>ce("option",{key:L,value:L},null,8,WD)),64))],8,GD)]),ce("div",KD,[ce("button",{type:"button","aria-label":"Bold","aria-pressed":n.value.draft.bold,onClick:F[6]||(F[6]=L=>w({bold:!n.value.draft.bold}))},[...F[29]||(F[29]=[ce("b",null,"B",-1)])],8,qD),ce("button",{type:"button","aria-label":"Italic","aria-pressed":n.value.draft.italic,onClick:F[7]||(F[7]=L=>w({italic:!n.value.draft.italic}))},[...F[30]||(F[30]=[ce("i",null,"I",-1)])],8,YD)])]),ce("label",XD,[F[31]||(F[31]=ce("span",null,"Font color",-1)),ce("span",ZD,[ce("input",{type:"color","aria-label":"Choose font color",value:n.value.draft.color,onInput:F[8]||(F[8]=L=>w({color:L.target.value}))},null,40,QD),ce("input",{type:"text","aria-label":"Font color",value:n.value.draft.color,spellcheck:"false",onInput:F[9]||(F[9]=L=>w({color:L.target.value}))},null,40,JD)])])],64)):ut("",!0),n.value.draft.kind==="picture"?(pe(),Ce(Bt,{key:1},[ce("div",e9,[n.value.draft.src?(pe(),Ce("img",{key:0,src:n.value.draft.src,alt:"Selected picture"},null,8,t9)):ut("",!0),ce("div",null,[ce("strong",null,Et(n.value.draft.pictureName||"No picture selected"),1),F[32]||(F[32]=ce("small",null,"PNG or JPEG",-1))]),ce("button",{type:"button",onClick:F[10]||(F[10]=L=>r.value?.click())},Et(n.value.draft.pictureName?"Replace picture":"Choose picture"),1),ce("input",{ref_key:"fileInput",ref:r,type:"file",accept:et(y_),"aria-label":"Choose watermark picture",hidden:"",onChange:k},null,40,n9)]),ce("label",r9,[F[34]||(F[34]=ce("span",null,"Scale",-1)),ce("select",{"aria-label":"Picture scale",value:n.value.draft.customSize?"custom":n.value.draft.scalePercent,onChange:F[11]||(F[11]=L=>w({scalePercent:L.target.value==="auto"?"auto":Number(L.target.value)}))},[n.value.draft.customSize?(pe(),Ce("option",i9,"Custom size retained")):ut("",!0),F[33]||(F[33]=ce("option",{value:"auto"},"Auto",-1)),(pe(),Ce(Bt,null,Rn([50,100,150,200,500],L=>ce("option",{key:L,value:L},Et(L)+"%",9,s9)),64))],40,o9)]),ce("label",a9,[ce("input",{type:"checkbox",checked:n.value.draft.lockAspectRatio,onChange:F[12]||(F[12]=L=>w({lockAspectRatio:L.target.checked}))},null,40,l9),F[35]||(F[35]=ce("span",null,"Preserve aspect ratio",-1))]),ce("label",c9,[ce("input",{type:"checkbox",checked:n.value.draft.washout,onChange:F[13]||(F[13]=L=>w({washout:L.target.checked}))},null,40,u9),F[36]||(F[36]=ce("span",null,[Si("Washout"),ce("small",null,"Lighten the picture's colors.")],-1))])],64)):ut("",!0),n.value.draft.kind!=="none"?(pe(),Ce("div",d9,[ce("label",{for:`watermark-transparency-${e.surfaceId}`},"Transparency",8,f9),ce("div",h9,[ce("input",{id:`watermark-transparency-${e.surfaceId}`,type:"range",min:"0",max:"100",step:"1","aria-label":"Transparency",value:n.value.draft.transparency,onInput:F[14]||(F[14]=L=>w({transparency:Number(L.target.value)}))},null,40,p9),ce("label",null,[ce("input",{type:"number",min:"0",max:"100",step:"any","aria-label":"Transparency percentage",value:n.value.draft.transparency,onInput:F[15]||(F[15]=L=>w({transparency:Number(L.target.value)}))},null,40,m9),F[37]||(F[37]=ce("span",null,"%",-1))])]),F[38]||(F[38]=ce("small",null,"0% opaque, 100% transparent",-1))])):ut("",!0),n.value.draft.kind!=="none"?(pe(),Ce("fieldset",g9,[F[39]||(F[39]=ce("legend",null,"Orientation",-1)),(pe(),Ce(Bt,null,Rn(["horizontal","diagonal"],L=>ce("label",{key:L},[ce("input",{type:"radio",name:`watermark-orientation-${e.surfaceId}`,value:L,checked:!n.value.draft.customOrientation&&n.value.draft.orientation===L,onChange:$=>w({orientation:L})},null,40,v9),ce("span",null,Et(L==="horizontal"?"Horizontal":"Diagonal"),1)])),64))])):ut("",!0),n.value.draft.customPlacement?(pe(),Ce("p",y9,"Custom placement retained.")):ut("",!0),n.value.draft.kind==="none"?(pe(),Ce("p",b9,Et(n.value.selectedIds.length?"The selected watermark will be removed when you apply.":"Choose Text or Picture to add a watermark."),1)):ut("",!0)],10,LD)]),ce("aside",{class:"sd-watermark__preview","aria-label":"Watermark preview","aria-busy":n.value.phase==="previewing"},[F[41]||(F[41]=ce("h3",null,"Preview",-1)),ce("div",C9,[n.value.preview?(pe(),Ce("img",{key:0,src:n.value.preview.url,width:n.value.preview.width,height:n.value.preview.height,alt:"Watermark on a sample page"},null,8,k9)):(pe(),Ce("p",S9,Et(n.value.phase==="loading"||n.value.phase==="previewing"?"Preparing preview…":n.value.draft.kind==="none"?"No watermark in this preview":"Preview unavailable"),1))]),F[42]||(F[42]=ce("p",{class:"sd-watermark__caption"},"Preview at the selected page size",-1)),ce("p",_9,Et(n.value.impact),1),n.value.impactDetails?.length?(pe(),Ce("details",A9,[ce("summary",null,"View "+Et(n.value.impactDetails.length)+" affected locations",1),ce("ul",null,[(pe(!0),Ce(Bt,null,Rn(n.value.impactDetails,L=>(pe(),Ce("li",{key:L},Et(L),1))),128))])])):ut("",!0)],8,w9)]),g.value||n.value.stale?(pe(),Ce("div",I9,[ce("p",null,Et(g.value||"The document changed. Review the latest state before applying."),1),n.value.stale||n.value.error?(pe(),Ce("button",{key:0,type:"button",disabled:d.value,onClick:M}," Review latest state ",8,E9)):ut("",!0)])):ut("",!0),ce("footer",x9,[ce("p",T9,Et(m.value),1),ce("div",R9,[ce("button",{type:"button",class:"sd-dialog-secondary",onClick:z},"Cancel"),ce("button",{type:"submit",class:"sd-watermark__apply sd-dialog-primary",disabled:!p.value},Et(n.value.phase==="applying"?"Applying…":n.value.draft.kind==="none"?n.value.items.length>1?"Remove selected watermark":"Remove watermark":"Apply watermark"),9,M9)])])],32))}});yn();var P9=mn(L9,[["__scopeId","data-v-df56c82c"]]);Ft();function D9(e){let t=null,n=!1;return{component:P9,captureFocusReturn(){const r=e?.()?.ownerDocument,o=r?.activeElement,i=o?.closest('[data-sd-part="toolbar-item"]')??o?.querySelector('[data-sd-part="toolbar-item"]'),s=i?.closest('[data-sd-part="toolbar"]')?.parentElement,a=i?.querySelector('[data-item="btn-watermark"], [data-item="btn-overflow"]');return async l=>{if(await Ct(),n||!l()||!a||o?.isConnected||!s?.isConnected||r?.activeElement!==r?.body)return;const u=s.querySelector('[data-sd-part="toolbar"]');for(const d of["watermark","overflow"]){const f=u?.querySelector(`[data-item="btn-${d}"]`)?.closest('[data-sd-part="toolbar-item"]');if(f instanceof HTMLElement&&f.getClientRects().length&&f.getAttribute("aria-disabled")!=="true"){f.focus({preventScroll:!0});return}}}},mount(){const r=e?.();n||t||!r?.ownerDocument||(t=r.ownerDocument.createElement("div"),t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),Object.assign(t.style,{position:"absolute",width:"1px",height:"1px",overflow:"hidden",clipPath:"inset(50%)",whiteSpace:"nowrap"}),r.appendChild(t))},announce(r){!n&&t&&(t.textContent=r)},destroy(){n=!0,t?.remove(),t=null}}}function C_(e){const t=e?.rotationDegrees!=null&&![0,315].includes(e.rotationDegrees);return{customOrientation:t,customPlacement:!!(t||e?.behindText===!1||e?.horizontal&&(e.horizontal.alignment!=="center"||e.horizontal.offsetPt)||e?.vertical&&(e.vertical.alignment!=="center"||e.vertical.offsetPt))}}function Rm(e){const t=e?.watermark,n=t?.placement?structuredClone(t.placement):void 0,r=t?.kind==="picture"?t:void 0,o=t?.kind==="text"?t:void 0,i=n?.rotationDegrees??(r||o?.orientation==="horizontal"?0:315);return{kind:t?.kind??"none",geometryKind:t?.kind??null,text:o?.text??"DRAFT",fontFamily:o?.fontFamily??"Calibri",fontSize:o?.fontSizePt??"auto",bold:o?.bold??!1,italic:o?.italic??!1,color:o?.color??"#C0C0C0",transparency:(1-(t?.opacity??.5))*100,orientation:i===0?"horizontal":"diagonal",scalePercent:r?.scalePercent??"auto",washout:r?.washout??!0,lockAspectRatio:r?.lockAspectRatio??!0,pictureName:r?"Image in this document":"",sourceWatermarkId:r?e?.watermarkId:void 0,widthPt:r?.widthPt,heightPt:r?.heightPt,placement:n,...C_(n),customSize:!!(r&&(n?.widthPt!=null||r.widthPt!=null))}}function O9(e,t){const n={...e,...t};if(t.kind&&t.kind!=="none"&&(t.kind!==e.geometryKind&&(n.placement=void 0,n.widthPt=void 0,n.heightPt=void 0,n.customSize=!1,n.orientation=t.kind==="picture"?"horizontal":"diagonal"),n.geometryKind=t.kind),t.orientation!==void 0&&(n.placement={...n.placement,rotationDegrees:t.orientation==="diagonal"?315:0}),t.scalePercent!==void 0||t.src!==void 0){const{widthPt:r,heightPt:o,...i}=n.placement??{};n.placement=Object.keys(i).length?i:void 0,n.widthPt=void 0,n.heightPt=void 0,n.customSize=!1}return{...n,...C_(n.placement)}}function F9(e){return e.kind==="none"?null:!Number.isFinite(e.transparency)||e.transparency<0||e.transparency>100?"Transparency must be between 0 and 100%.":e.kind==="picture"?e.src||e.sourceWatermarkId?null:"Choose a picture.":e.text.trim()?e.fontSize!=="auto"&&(!Number.isFinite(e.fontSize)||e.fontSize<=0)?"Enter a positive font size or choose Auto.":/^#[\da-f]{6}$/i.test(e.color)?e.fontFamily.trim()?null:"Choose a font.":"Enter a six-digit hex color.":"Enter watermark text."}function k_(e){const t={opacity:1-e.transparency/100,...e.placement?{placement:e.placement}:{}};if(e.kind==="text")return{kind:"text",text:e.text,fontFamily:e.fontFamily,fontSizePt:e.fontSize,bold:e.bold,italic:e.italic,color:e.color,orientation:e.orientation,...t};if(e.kind!=="picture")throw new Error("A removal has no watermark input.");return{kind:"picture",...e.src?{src:e.src}:{source:{kind:"existing",watermarkId:e.sourceWatermarkId}},scalePercent:e.scalePercent,washout:e.washout,lockAspectRatio:e.lockAspectRatio,...e.widthPt!=null?{widthPt:e.widthPt}:{},...e.heightPt!=null?{heightPt:e.heightPt}:{},...t}}var N9={default:"Default pages",first:"First page",even:"Even pages"},Mm="The document changed while this dialog was open. Review the latest watermark before applying.";function S_(e,t,n){return e.filter(r=>t==null||r.address.sectionId===t).flatMap(r=>(n==="all"?["default",...r.titlePage?["first"]:[],...r.oddEvenHeadersFooters?["even"]:[]]:[n]).map(o=>({kind:"headerFooterSlot",section:r.address,headerFooterKind:"header",variant:o})))}function __(e){return`${e.section.sectionId}:${e.variant}`}function Lm(e){return e instanceof Error?e.message:"The watermark could not be updated. Try again."}function B9(e){const t=D9(e.getContainer),n={...e,announce:l=>{t.announce(l),e.announce?.(l)}};let r=null,o=!1,i=0;function s(){const l=r;r=null,l?.dispose(),l?.handle.close()}function a(){if(o)return{ok:!1,reason:"not-ready"};const l=e.getEditor();if(!l)return{ok:!1,reason:"not-ready"};if(!l.doc?.watermarks?.list||!l.doc.sections?.list)return{ok:!1,reason:"document-api-unavailable"};if(!e.openSurface||!l.doc.watermarks.apply||!l.host?.watermarkPreview)return{ok:!1,reason:"operation-unavailable"};const u=++i,d=t.captureFocusReturn();s(),t.mount();const f=z9(l,n,()=>{r?.handle===p&&s()});let p;try{p=e.openSurface({mode:"dialog",ariaLabel:"Watermark",component:t.component,props:{model:f.model},dialog:{maxWidth:700}})}catch{return f.dispose(),{ok:!1,reason:"operation-unavailable"}}return r={handle:p,dispose:f.dispose},p.result.then(g=>{f.dispose(),r?.handle===p&&(r=null),(g.status==="closed"||g.status==="submitted")&&d(()=>!o&&u===i&&r===null)}),f.model.reload(),{ok:!0}}return{open:a,close:s,destroy(){o=!0,s(),t.destroy()}}}function z9(e,t,n){const r=new Set;let o=!0,i=0,s,a=[],l=[],u="",d=JSON.stringify(Rm()),f=null,p={phase:"loading",draft:Rm(),sections:[],sectionId:null,variant:"all",items:[],selectedIds:[],fonts:[...t.getFonts()],dirty:!1,canApply:!1,error:null,stale:!1,readonlyReason:null,impact:"",impactDetails:[],preview:null};const g=L=>o&&L===i&&t.getEditor()===e,m=()=>t.getMode()==="editing";function v(L){if(o){p={...p,...L};for(const $ of r)$(p)}}function C(){return clearTimeout(s),f=null,++i}function w(L){const $=l.find(H=>H.address.sectionId===L.section.sectionId),T=L.variant==="first"?!$?.titlePage:L.variant==="even"?!$?.oddEvenHeadersFooters:!1;return`Section ${($?.index??0)+1}, ${N9[L.variant].toLowerCase()}${T?" (inactive)":""}`}function S(){if(p.sectionId==null&&p.variant==="all")return a;const L=new Set(S_(l,p.sectionId,p.variant).map(__));return a.filter($=>$.effectiveIn.some(T=>L.has(__(T))))}function b(){v({items:S().map(L=>({id:L.watermarkId,label:L.watermark.kind==="text"?L.watermark.text:"Picture watermark",locations:L.effectiveIn.map(w).join("; ")}))})}function k(){const L=p.sectionId==null&&p.variant==="all"?{kind:"document"}:{kind:"headerFooterSlots",slots:S_(l,p.sectionId,p.variant)};if(p.draft.kind==="none")return{target:L,action:"remove",watermarkIds:p.selectedIds};const $=k_(p.draft);if(p.selectedIds.length)return{target:L,action:"replace",watermarkIds:p.selectedIds,watermark:$};if("source"in $)throw new Error("Select the existing picture watermark in this scope, or choose a new picture.");return{target:L,action:"insert",watermark:$}}function x(L){if(L.success)return!1;const $=L.failure?.code==="REVISION_MISMATCH";return v({stale:$,phase:"editing",canApply:!1,error:$?Mm:L.failure?.message??"The watermark could not be updated."}),!0}async function M(L){try{const $=F9(p.draft);if($){v({phase:"editing",error:$,canApply:!1,preview:null});return}const T=p.draft.kind==="none"&&!p.selectedIds.length?null:k(),H=p.draft.kind==="none"?null:await e.host.watermarkPreview({watermark:k_(p.draft),sectionId:p.sectionId??l[0]?.address.sectionId,expectedRevision:u});if(!g(L))return;if(!T||!p.dirty||!m()){v({phase:"editing",preview:H,canApply:!1,error:null});return}const R=await e.doc.watermarks.apply(T,{expectedRevision:u,dryRun:!0});if(!g(L))return;if(!R.success){x(R);return}f=T;const U=R.affectedSlots.map(w);v({phase:"editing",preview:H,error:null,canApply:U.length>0&&!p.stale&&m(),impact:U.length?`Changes: ${U.length>3?`${U.length} page locations`:U.join("; ")}. Other locations stay as they are.`:"No matching watermark will change.",impactDetails:U.length>3?U:[]})}catch($){g(L)&&v({phase:"editing",error:Lm($),canApply:!1,preview:null})}}function z(){const L=C();v({phase:"previewing",canApply:!1,error:null,impact:"",impactDetails:[],preview:null}),s=setTimeout(()=>{M(L)},120)}const G={getSnapshot:()=>p,subscribe(L){return r.add(L),L(p),()=>{r.delete(L)}},async reload(){const L=C();v({phase:"loading",canApply:!1,stale:!1,error:null,impactDetails:[],preview:null});try{const[$,T]=await Promise.all([e.doc.watermarks.list(),e.doc.sections.list()]);if(!g(L))return;if($.items.length!==$.total||T.items.length!==T.total)throw new Error("The complete watermark scope could not be loaded.");if(T.evaluatedRevision&&T.evaluatedRevision!==$.evaluatedRevision)throw new Error(Mm);a=$.items,l=T.items,u=$.evaluatedRevision;const H=S(),R=H.length===1?H[0]:void 0,U=Rm(R);d=JSON.stringify(U),v({draft:U,dirty:!1,selectedIds:R?[R.watermarkId]:[],sections:l.map(W=>({id:W.address.sectionId,label:`Section ${W.index+1}`})),readonlyReason:m()?null:t.getMode()==="suggesting"?"Watermarks cannot be changed in Suggesting mode.":"This document is read-only.",impact:H.length>1?"Select the watermark copies you want to edit, or add a new watermark.":""}),b(),await M(L)}catch($){g(L)&&v({phase:"editing",error:Lm($),canApply:!1})}},patchDraft(L){if(!o||p.phase==="loading"||p.phase==="applying"||!m())return;const $=O9(p.draft,L);v({draft:$,dirty:JSON.stringify($)!==d}),z()},setScope(L,$){if(!o||p.phase==="loading"||p.phase==="applying"||L!=null&&!l.some(U=>U.address.sectionId===L))return;v({sectionId:L,variant:$}),b();const T=S(),H=new Set(T.map(U=>U.watermarkId));let R=p.selectedIds.filter(U=>H.has(U));p.dirty&&p.draft.kind==="none"&&!R.length&&T.length===1&&(R=[T[0].watermarkId]),v({selectedIds:R}),p.dirty?z():G.selectWatermarks(T.length===1?[T[0].watermarkId]:[])},selectWatermarks(L){if(!o||p.phase==="loading"||p.phase==="applying")return;const $=S(),T=[...new Set(L)].filter(R=>$.some(U=>U.watermarkId===R)),H=Rm($.find(R=>R.watermarkId===T[0]));d=JSON.stringify(H),v({selectedIds:T,draft:H,dirty:!1}),z()},async apply(){if(!o||!p.canApply||!f||!m()||t.getEditor()!==e)return;const L=f,$=C();v({phase:"applying",canApply:!1,error:null}),t.announce?.("Applying watermark changes. Closing the dialog will not cancel them.");try{const T=await e.doc.watermarks.apply(L,{expectedRevision:u});if(!g($)){t.announce?.(T.success?"Watermark updated.":"The watermark could not be updated.");return}if(x(T))return;t.announce?.(L.action==="remove"?"Watermark removed.":"Watermark updated."),n()}catch(T){g($)?v({phase:"editing",error:Lm(T),canApply:!1}):t.announce?.(Lm(T))}}},F=e.host?.events?.subscribe(L=>{if(!(!o||p.phase==="applying")){if(L.type==="collaboration:document-replaced"){C(),v({phase:"editing",stale:!0,canApply:!1,error:Mm});return}["document:mutated","mutation:committed","collaboration:remote-changed"].includes(L.type)&&(C(),p.dirty?v({phase:"editing",stale:!0,canApply:!1,error:Mm}):s=setTimeout(()=>{G.reload()},120))}});return{model:G,dispose(){o=!1,C(),F?.(),r.clear()}}}function j9(e){if(!e||typeof e!="object")return{};const t={};e.fonts&&(t.rFonts={ascii:e.fonts.ascii,hAnsi:e.fonts.hAnsi,eastAsia:e.fonts.eastAsia,cs:e.fonts.cs,asciiTheme:e.fonts.asciiTheme,hAnsiTheme:e.fonts.hAnsiTheme,eastAsiaTheme:e.fonts.eastAsiaTheme,csTheme:e.fonts.csTheme,hint:e.fonts.hint}),e.fontFamily!=null&&(t.fontFamily=e.fontFamily),e.lang&&(t.lang={val:e.lang.val,eastAsia:e.lang.eastAsia,bidi:e.lang.bidi}),e.fontSize!=null&&(t.fontSize=e.fontSize),e.fontSizeCs!=null&&(t.fontSizeCs=e.fontSizeCs);const n=Pm(e.color);n!=null&&(t.color=n),e.highlight!=null&&(t.highlight=e.highlight);const r=U9(e.shading);r&&(t.shading=r),e.cs!=null&&(t.cs=e.cs),e.rtl!=null&&(t.rtl=e.rtl),e.bold!=null&&(t.bold=e.bold),e.boldCs!=null&&(t.bCs=e.boldCs),e.italic!=null&&(t.italic=e.italic),e.italicCs!=null&&(t.iCs=e.italicCs);const o=V9(e.underline);o!==void 0&&(t.underline=o),e.strikethrough!=null&&(t.strike=e.strikethrough),e.doubleStrikethrough!=null&&(t.dstrike=e.doubleStrikethrough),e.caps!=null&&(t.caps=e.caps),e.smallCaps!=null&&(t.smallCaps=e.smallCaps),e.outline!=null&&(t.outline=e.outline),e.shadow!=null&&(t.shadow=e.shadow),e.emboss!=null&&(t.emboss=e.emboss),e.imprint!=null&&(t.imprint=e.imprint),e.verticalAlign!=null&&(t.vertAlign=e.verticalAlign),e.characterSpacing!=null&&(t.letterSpacing=e.characterSpacing),e.characterScale!=null&&(t.charScale=e.characterScale),e.kern!=null&&(t.kerning=e.kern),e.baselineShift!=null&&(t.position=e.baselineShift),e.fitTextWidth!=null&&(t.fitText={val:e.fitTextWidth}),e.vanish!=null&&(t.vanish=e.vanish),e.webHidden!=null&&(t.webHidden=e.webHidden),e.specVanish!=null&&(t.specVanish=e.specVanish);const i=$9(e.border);return i&&(t.border=i),t}function Pm(e){if(e){if(typeof e=="string")return e;if(e.model==="rgb")return e.value;if(e.model==="auto")return"auto"}}function V9(e){if(e==null)return;const t={};return e.style!=null&&(t.style=e.style),e.color?.model==="rgb"&&(t.color=e.color.value),e.color?.model==="theme"&&(t.themeColor=e.color.theme),Object.keys(t).length>0?t:!0}function U9(e){if(!e)return;const t={},n=Pm(e.fill);n!=null&&(t.fill=n);const r=Pm(e.color);return r!=null&&(t.color=r),e.pattern!=null&&(t.val=e.pattern),Object.keys(t).length>0?t:void 0}function $9(e){if(!e)return;const t={};e.style!=null&&(t.val=e.style),e.width!=null&&(t.sz=e.width),e.space!=null&&(t.space=e.space);const n=Pm(e.color);return n!=null&&(t.color=n),Object.keys(t).length>0?t:void 0}function Mc(e){const t=e?.selectionTarget??e?.target;if(!e||!t)return"";try{return JSON.stringify(t)}catch{return String(t)}}function A_(e){if(e?.type!=="mutation:committed")return null;const t=e.origin==="history"?e.result:e.receipt;if(!t||typeof t!="object")return null;const n=new Set,r=new Set,o=[],i=(l,u)=>{l?.kind!=="entity"||l.entityType!=="trackedChange"||typeof l.entityId=="string"&&l.entityId.length>0&&u.add(l.entityId)},s=l=>l?.kind!=="entity"||l.entityType!=="trackedChange"?null:typeof l.entityId=="string"&&l.entityId.length>0?l.entityId:null;if(Array.isArray(t.inserted)&&t.inserted.forEach(l=>i(l,n)),Array.isArray(t.updated)&&t.updated.forEach(l=>i(l,n)),Array.isArray(t.trackedChangeRefs)&&t.trackedChangeRefs.forEach(l=>i(l,n)),Array.isArray(t.trackedChanges)&&t.trackedChanges.forEach(l=>i(l,n)),Array.isArray(t.steps)){for(const l of t.steps)if(Array.isArray(l?.trackedChangeIds))for(const u of l.trackedChangeIds)typeof u=="string"&&u.length>0&&n.add(u)}if(Array.isArray(t.removed)&&t.removed.forEach(l=>i(l,r)),Array.isArray(t.invalidatedRefs)&&t.invalidatedRefs.forEach(l=>i(l,r)),Array.isArray(t.remappedRefs))for(const l of t.remappedRefs){const u=s(l?.from),d=s(l?.to);u&&r.add(u),d&&n.add(d),u&&d&&u!==d&&o.push({from:u,to:d})}for(const l of r)n.delete(l);const a=W9(e,t);return n.size===0&&r.size===0&&!a?null:{upsertIds:n,removedIds:r,remappedPairs:o,reconcileMode:"targeted",...a?{allResolved:a}:{}}}function H9(e){const t=new Set;if(e?.type!=="mutation:committed")return t;const n=e.origin==="history"?e.result:e.receipt;if(!Array.isArray(n?.invalidatedRefs))return t;for(const r of n.invalidatedRefs)r?.kind==="entity"&&r.entityType==="comment"&&typeof r.entityId=="string"&&r.entityId&&t.add(r.entityId);return t}function G9({event:e,commentsStore:t,superdoc:n,documentId:r}={}){const o=H9(e);return o.size===0?{ok:!0,removedIds:[]}:t?.dropCommentsFromMutationImpact?.({superdoc:n,documentId:r,removedIds:o})??{ok:!0,removedIds:[]}}function W9(e,t){const n=e?.trackedChangeAllResolved;return e?.origin==="history"||!n||n.schemaVersion!==1||n.targetKind!=="all"||n.decision!=="accept"&&n.decision!=="reject"||n.remainingLogicalCount!==0||typeof n.catalogRevision!="string"||!n.catalogRevision||typeof n.sourceCoverageRevision!="string"||!n.sourceCoverageRevision||!Number.isSafeInteger(n.logicalTargetCount)||n.logicalTargetCount<=0||!Number.isSafeInteger(n.physicalCarrierCount)||n.physicalCarrierCount<n.logicalTargetCount||typeof n.txId!="string"||n.txId!==t.txId||typeof n.documentEpoch!="string"||!Number.isSafeInteger(n.commitSequence)||typeof n.packagePreviousRevision!="string"||typeof n.packageNextRevision!="string"||n.packagePreviousRevision===n.packageNextRevision?null:n}var K9=new Set(["insert-text","replace-text","plain-text-paste","delete-backward","delete-forward","text.insert","text.replace","text.pastePlain","text.deleteBackward","text.deleteForward","structural.enter","structural:enter-split-paragraph","structural:enter-insert-paragraph-before","structural:enter-insert-paragraph-after","structural:shift-enter-line-break","structural:backspace-boundary-merge-with-previous","structural:delete-boundary-merge-with-next","backspace:boundary-merge-with-previous","backspace:list-remove","backspace:list-outdent"]),q9=e=>e?.type!=="mutation:committed"||e.origin!=="command"?!1:K9.has(e.editableCommandKind),tt={notReady:"not-ready",documentApiUnavailable:"document-api-unavailable",documentReadonly:"document-readonly",trackedChangeDecisionsDisabled:"tracked-change-decisions-disabled",selectionRequired:"selection-required",rangeSelectionRequired:"range-selection-required",contextUnavailable:"context-unavailable",geometryUnavailable:"geometry-unavailable",targetUnresolved:"target-unresolved",targetNotVisible:"target-not-visible",commandUnsupported:"command-unsupported",commandDeferred:"command-deferred",tableContextUnavailable:"table-context-unavailable",operationUnavailable:"operation-unavailable",bulkDecisionsDisabled:"bulk-decisions-disabled",hostCapabilityUnavailable:"host-capability-unavailable",historyEmpty:"history-empty",searchUnavailable:"search-unavailable",searchInvalidPattern:"search-invalid-pattern",searchTruncated:"search-truncated",replaceUnsupported:"replace-unsupported",contentControlLocked:"content-control-locked",permissionDenied:"permission-denied"},I_={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strikethrough",fontFamily:"font-family",fontSize:"font-size",setFontFamily:"setFontFamily",setFontSize:"setFontSize",undo:"undo",redo:"redo",acceptChange:"acceptChange",rejectChange:"rejectChange",acceptAllChanges:"acceptAllChanges",rejectAllChanges:"rejectAllChanges",bulletList:"bullet-list",numberedList:"numbered-list"};function E_(e){const t=n=>typeof n=="string"?n.replace(/\s*pt$/i,"").trim():n;if(typeof e=="string")return t(e);if(e&&typeof e=="object"&&"value"in e){const n=e;return{...n,value:t(n.value)}}return e}function Y9(e){const t=(n,r)=>!r&&n>0&&n<=5?n*100:n;if(typeof e=="string"){const n=e.includes("%"),r=Number.parseFloat(e.replace("%","").trim());return Number.isFinite(r)?t(r,n):e}return typeof e=="number"&&Number.isFinite(e)?t(e,!1):e}function X9(e){const t=e&&typeof e=="object"&&"value"in e?e.value:e;if(t==="in"||t==="cm")return t;if(typeof t=="string"){const n=t.trim().toLowerCase();if(n==="in"||n==="inch"||n==="inches")return"in";if(n==="cm"||n==="centimeter"||n==="centimeters"||n==="centimetre"||n==="centimetres")return"cm"}return t}function x_(e){const t=n=>{if(n===null)return null;if(typeof n!="string")return n;const r=n.trim();return r===""?n:/^#[0-9a-fA-F]{6}$/.test(r)?r:/^[0-9a-fA-F]{6}$/.test(r)?`#${r}`:r};if(e&&typeof e=="object"&&"value"in e){const n=e;return{...n,value:t(n.value)}}return t(e)}function P0(e,t){if(e&&typeof e=="object"){const n=e;for(const r of t)if(r in n)return n[r]}return e}function Z9(e){const t=P0(e,["alignment","value"]);if(typeof t!="string")return t;const n=t.trim().toLowerCase();return n==="justified"||n==="both"?"justify":n}var Q9=new Set(["left","center","right"]),J9=new Set(["decimal","lowerLetter","upperLetter","lowerRoman","upperRoman","numberInDash","hebrew1","hebrew2"]);function T_(e){if(e.kind!==void 0&&e.kind!=="header"&&e.kind!=="footer")return null;const t=e.position??(e.kind==="header"?"top":e.kind==="footer"?"bottom":void 0);if(t!==void 0)return t!=="top"&&t!=="bottom"?null:t==="top"?"header":"footer"}function R_(e){return e!=null&&typeof e!="object"?null:e??{}}function eO(e){const t=R_(e);if(!t)return null;const n=T_(t);return n===null||t.alignment!==void 0&&!Q9.has(t.alignment)||t.showOnFirstPage!==void 0&&typeof t.showOnFirstPage!="boolean"||t.format!==void 0&&!J9.has(t.format)||t.start!==void 0&&t.start!==null&&(typeof t.start!="number"||!Number.isInteger(t.start)||t.start<0)?null:{kind:n??"footer",...t.alignment!==void 0?{alignment:t.alignment}:{},...t.showOnFirstPage!==void 0?{showOnFirstPage:t.showOnFirstPage}:{},...t.format!==void 0?{format:t.format}:{},...t.start!==void 0?{start:t.start}:{}}}function tO(e){const t=R_(e);if(!t)return null;const n=T_(t);return n===null?null:n?{kind:n}:{}}function nO(e){const t=P0(e,["line","lineHeight","value"]),n=typeof t=="number"?t:typeof t=="string"?Number.parseFloat(t.trim()):NaN;return!Number.isFinite(n)||n<=0?t:n<=10?Math.round(n*240):Math.round(n)}function rO(e){if(e&&typeof e=="object"&&"role"in e)return e;const t=P0(e,["styleId","value","style"]);return typeof t=="string"?t.trim():t}function oO(e){if(typeof e=="string")return e;if(e&&typeof e=="object"){const t=e.mode;if(typeof t=="string")return t}return e}var iO=tt.commandUnsupported,ea=tt.tableContextUnavailable,M_=[{id:"bold",family:"inline marks",disposition:"routed",mutates:!0,docRoute:"format.bold",activeMark:"bold",inline:{key:"bold",kind:"toggle"}},{id:"italic",family:"inline marks",disposition:"routed",mutates:!0,docRoute:"format.italic",activeMark:"italic",inline:{key:"italic",kind:"toggle"}},{id:"underline",family:"inline marks",disposition:"routed",mutates:!0,docRoute:"format.underline",activeMark:"underline",inline:{key:"underline",kind:"toggle"}},{id:"strikethrough",family:"inline marks",disposition:"routed",mutates:!0,docRoute:"format.strikethrough",activeMark:"strikethrough",inline:{key:"strike",kind:"toggle"}},{id:"font-family",family:"fonts",disposition:"routed",mutates:!0,docRoute:"format.fontFamily",aliases:["setFontFamily"],inline:{key:"fontFamily",kind:"value-string"}},{id:"font-size",family:"fonts",disposition:"routed",mutates:!0,docRoute:"format.fontSize",aliases:["setFontSize"],normalizePayload:E_,inline:{key:"fontSize",kind:"value-number"}},{id:"setFontFamily",family:"fonts",disposition:"routed",mutates:!0,docRoute:"format.fontFamily",aliasOf:"font-family",inline:{key:"fontFamily",kind:"value-string"}},{id:"setFontSize",family:"fonts",disposition:"routed",mutates:!0,docRoute:"format.fontSize",aliasOf:"font-size",normalizePayload:E_,inline:{key:"fontSize",kind:"value-number"}},{id:"undo",family:"history",disposition:"routed",mutates:!0,docRoute:"history.undo"},{id:"redo",family:"history",disposition:"routed",mutates:!0,docRoute:"history.redo"},{id:"acceptChange",family:"tracked changes",disposition:"routed",mutates:!0,trackDecision:{kind:"accept",scope:"id"},aliases:["track-changes-accept-selection"]},{id:"rejectChange",family:"tracked changes",disposition:"routed",mutates:!0,trackDecision:{kind:"reject",scope:"id"},aliases:["track-changes-reject-selection"]},{id:"acceptAllChanges",family:"tracked changes (bulk)",disposition:"routed",mutates:!0,trackDecision:{kind:"accept",scope:"all"}},{id:"rejectAllChanges",family:"tracked changes (bulk)",disposition:"routed",mutates:!0,trackDecision:{kind:"reject",scope:"all"}},{id:"track-changes-accept-selection",family:"tracked changes",disposition:"routed",mutates:!0,trackDecision:{kind:"accept",scope:"id"},aliasOf:"acceptChange"},{id:"track-changes-reject-selection",family:"tracked changes",disposition:"routed",mutates:!0,trackDecision:{kind:"reject",scope:"id"},aliasOf:"rejectChange"},{id:"zoom",family:"zoom",disposition:"routed",mutates:!1,instanceRoute:"setZoom",valueFrom:"zoom",normalizePayload:Y9},{id:"zoom-fit-width",family:"zoom",disposition:"routed",mutates:!1,instanceRoute:"setZoomMode",fixedArg:"fit-width",valueFrom:"zoom"},{id:"document-mode",family:"document",disposition:"routed",mutates:!1,instanceRoute:"setDocumentMode",valueFrom:"documentMode",normalizePayload:oO},{id:"measurement-unit",family:"measurement",disposition:"routed",mutates:!1,instanceRoute:"setMeasurementUnit",valueFrom:"measurementUnit",normalizePayload:X9},{id:"text-color",family:"color",disposition:"routed",mutates:!0,docRoute:"format.color",inline:{key:"color",kind:"value-string"},normalizePayload:x_},{id:"highlight-color",family:"color",disposition:"routed",mutates:!0,docRoute:"format.highlight",inline:{key:"highlight",kind:"value-string"},normalizePayload:x_},{id:"link",family:"links",disposition:"routed",mutates:!0,docRoute:"hyperlinks.wrap",activeMark:"link",link:{kind:"link"}},{id:"text-align",family:"paragraph",disposition:"routed",mutates:!0,docRoute:"format.paragraph.setAlignment",blockParagraph:{kind:"alignment"},normalizePayload:Z9},{id:"line-height",family:"paragraph",disposition:"routed",mutates:!0,docRoute:"format.paragraph.setSpacing",blockParagraph:{kind:"spacing-line"},normalizePayload:nO},{id:"linked-style",family:"paragraph",disposition:"routed",mutates:!0,docRoute:"styles.paragraph.setStyle",blockParagraph:{kind:"style"},normalizePayload:rO},{id:"bullet-list",family:"lists",disposition:"routed",mutates:!0,docRoute:"lists.apply",list:{mode:"toggle-seed",seed:"bullet"}},{id:"numbered-list",family:"lists",disposition:"routed",mutates:!0,docRoute:"lists.apply",list:{mode:"toggle-seed",seed:"ordered"}},{id:"indent-increase",family:"lists/indent",disposition:"routed",mutates:!0,docRoute:"lists.indent",list:{mode:"indent"}},{id:"indent-decrease",family:"lists/indent",disposition:"routed",mutates:!0,docRoute:"lists.outdent",list:{mode:"outdent"}},{id:"direction-ltr",family:"direction",disposition:"routed",mutates:!0,docRoute:"format.paragraph.setDirection",blockParagraph:{kind:"direction",fixedValue:"ltr"}},{id:"direction-rtl",family:"direction",disposition:"routed",mutates:!0,docRoute:"format.paragraph.setDirection",blockParagraph:{kind:"direction",fixedValue:"rtl"}},{id:"clear-formatting",family:"formatting",disposition:"routed",mutates:!0,docRoute:"format.apply",inline:{key:"*",kind:"clear"}},{id:"image",family:"media",disposition:"routed",mutates:!0,docRoute:"create.image",create:{kind:"image"}},{id:"table-of-contents-insert",family:"TOC",disposition:"routed",mutates:!0,docRoute:"create.tableOfContents",create:{kind:"toc"}},{id:"table-insert",family:"tables",disposition:"routed",mutates:!0,docRoute:"create.table",create:{kind:"table"}},{id:"page-number-insert",family:"fields",disposition:"routed",mutates:!0,docRoute:"fields.insert",field:{instruction:"PAGE"}},{id:"page-numbers-apply",family:"fields",disposition:"routed",mutates:!0,docRoute:"headerFooters.pageNumbers.set",pageNumbers:"set",normalizePayload:eO},{id:"page-numbers-remove",family:"fields",disposition:"routed",mutates:!0,docRoute:"headerFooters.pageNumbers.remove",pageNumbers:"remove",normalizePayload:tO},{id:"table-add-row-before",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.insertRow",table:{action:"insert-row-before",op:"insertRow"},reason:ea},{id:"table-add-row-after",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.insertRow",table:{action:"insert-row-after",op:"insertRow"},reason:ea},{id:"table-delete-row",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.deleteRow",table:{action:"delete-row",op:"deleteRow"},reason:ea},{id:"table-add-column-before",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.insertColumn",table:{action:"insert-column-before",op:"insertColumn"},reason:ea},{id:"table-add-column-after",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.insertColumn",table:{action:"insert-column-after",op:"insertColumn"},reason:ea},{id:"table-delete-column",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.deleteColumn",table:{action:"delete-column",op:"deleteColumn"},reason:ea},{id:"table-delete",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.delete",table:{action:"delete-table",op:"delete"},reason:ea},{id:"table-merge-cells",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.mergeCells",table:{action:"merge-cells",op:"mergeCells"},reason:ea},{id:"table-split-cell",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.splitCell",table:{action:"split-cell",op:"splitCell",requiresCell:!0},reason:ea},{id:"table-remove-borders",family:"tables",disposition:"routed",mutates:!0,docRoute:"tables.setBorders",table:{action:"remove-borders",op:"setBorders"},reason:ea},{id:"ruler",family:"UI chrome",disposition:"routed",mutates:!1,instanceRoute:"toggleRuler",valueFrom:"ruler"},{id:"formatting-marks",family:"UI chrome",disposition:"routed",mutates:!1,instanceRoute:"toggleFormattingMarks",valueFrom:"formattingMarks"},{id:"copy-format",family:"formatting",disposition:"routed",mutates:!1},{id:"table-fix",family:"tables",disposition:"unsupported",mutates:!0,reason:iO}],sO=new Map(M_.map(e=>[e.id,e])),aO=M_.map(e=>e.id);function nd(e){return sO.get(e)??null}function L_(e){return e.split(",").map(t=>t.trim()).filter(Boolean)}function lO(e){const t=[],n=o=>{o&&!t.includes(o)&&t.push(o)};n(e.getAttribute("data-track-change-preferred-target-id"));const r=e.getAttribute("data-track-change-ids");if(r)for(const o of L_(r))n(o);return n(e.getAttribute("data-track-change-id")),t}function P_(e,t){if(!e||typeof e.getAttribute!="function")return[];const n=[],r=new Set;let o=[],i=null,s=null,a=e;for(;a;){const l=a;i??=l.getAttribute("data-story-key");const u=lO(l),d=u.length>0?l.getAttribute("data-story-key"):null;for(const C of u){const w=`trackedChange:${C}`;if(!r.has(w)){r.add(w);const S={type:"trackedChange",id:C};d&&(S.storyKey=d),n.push(S),o.push(S)}}const f=l.getAttribute("data-layout-story");if(s??=f,f&&o.length>0){for(const C of o)C.story=f;o=[]}const p=l.getAttribute("data-citation-id");if(p){const C=`citation:${p}`;r.has(C)||(r.add(C),n.push({type:"citation",id:p}))}const g=l.getAttribute("data-comment-ids");if(g)for(const C of L_(g)){const w=`comment:${C}`;r.has(w)||(r.add(w),n.push({type:"comment",id:C}))}const m=l.getAttribute("data-sdt-type"),v=l.getAttribute("data-sdt-id");if(v&&m==="structuredContent"){const C=`contentControl:${v}`;if(!r.has(C)){r.add(C);const w=l.getAttribute("data-sdt-scope"),S=l.getAttribute("data-sdt-tag"),b={type:"contentControl",id:v};i&&(b.storyKey=i),s?b.story=s:o.push(b),(w==="block"||w==="inline")&&(b.scope=w),S&&(b.tag=S),n.push(b)}}if(t&&a===t)break;a=a.parentElement}return n}function cO(e){const t=e?.directionContext?.inlineDirection;if(t!=null)return t;const n=e?.paragraphProperties?.rightToLeft;if(n===!0)return"rtl";if(n===!1)return"ltr"}var D_=["#1f6feb","#d1242f","#8250df","#bf3989","#1a7f37","#9a6700","#bc4c00","#0969da","#cf222e","#6639ba","#116329","#7d4e00"],uO=e=>e?`${typeof e.name=="string"?e.name:""} ${typeof e.email=="string"?e.email:""}`:"",dO=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0},fO=e=>{const t=uO(e),n=dO(t)%D_.length;return D_[n]},Zf=e=>typeof e=="string"&&e.length>0,hO=e=>{if(!e||e.enabled===!1)return;const t=e.overrides&&typeof e.overrides=="object"?e.overrides:void 0,n=typeof e.resolve=="function"?e.resolve:void 0;return r=>{const o=r??{};if(t){if(Zf(o.email)&&Zf(t[o.email]))return t[o.email];if(Zf(o.name)&&Zf(t[o.name]))return t[o.name]}if(n)try{const i=n(o);if(Zf(i))return i}catch{}return fO(o)}},pO=["insertion","deletion","move","move-from","move-to","table-cell-insertion","table-cell-deletion","cell-merge","cell-split","image-insertion","image-deletion","image-property-change"],bX=new Set(pO),Cr={externalImageDeferred:"render.media.external-image-deferred",missingRelationship:"render.drawing.missing-relationship",missingMediaPart:"render.media.missing-part",unsupportedRelationshipType:"render.drawing.unsupported-relationship-type",unsupportedMime:"render.media.unsupported-mime",imageTooLarge:"render.media.image-too-large",unsafeSvg:"render.media.unsafe-svg",unsupportedFormat:"render.media.unsupported-format",embeddedObjectNotSupported:"render.embedded-object-not-supported",unsupportedObject:"render.drawing.unsupported-object",vmlUnsupported:"render.drawing.vml-unsupported",vmlImageUnsupported:"render.drawing.vml-image-unsupported",unsupportedGeometryCommand:"render.drawing.unsupported-geometry-command",anchorUnsupported:"render.drawing.anchor-unsupported",wrapUnsupported:"render.drawing.wrap-unsupported",altContentNoSupportedChoice:"render.drawing.altcontent-no-supported-choice",groupChildUnsupported:"render.drawing.group-child-unsupported"},wX={"render.media.missing-relationship":Cr.missingRelationship,"render.media.wrong-relationship-type":Cr.unsupportedRelationshipType,"render.media.unsupported-target":Cr.unsupportedRelationshipType,"render.media.invalid-image-size":Cr.imageTooLarge,"render.media-resolver-unavailable":Cr.missingMediaPart,"render.chart-not-supported":Cr.unsupportedObject,"render.textbox.vml-unsupported":Cr.vmlUnsupported},mO={inlineBitmap:{family:"inlineBitmap",support:"supported",description:"wp:inline pic:pic with internal media and browser-safe MIME (PNG/JPEG; WebP/SVG once the host media resolver lands).",contract:"ImageRun"},anchoredBitmap:{family:"anchoredBitmap",support:"supported",description:"wp:anchor bitmap with anchor/wrap expressible by ImageAnchor/ImageWrap. Never silently inlined.",contract:"ImageBlock"},imageChildInGroup:{family:"imageChildInGroup",support:"supported",description:"Bitmap child of a supported DrawingML group/drawing wrapper. Supported only when the parent is.",contract:"ImageDrawing"},vectorShape:{family:"vectorShape",support:"supported",description:"Block/floating DrawingML preset/custom shape with the supported geometry/style subset.",contract:"DrawingBlock",drawingKind:"vectorShape"},shapeGroup:{family:"shapeGroup",support:"supported",description:"DrawingML group whose rendered children are supported vector/image children.",contract:"DrawingBlock",drawingKind:"shapeGroup"},chart:{family:"chart",support:"supported",description:"DrawingML chart projected into a ChartDrawing with parsed cached chart XML data. Complete Word chart fidelity remains deferred to chartFidelity.",contract:"DrawingBlock",drawingKind:"chart"},alternateContent:{family:"alternateContent",support:"supported",description:"mc:AlternateContent traversal/select policy. Selected Choice/Fallback maps to its family contract; unselected branches preserved for save/reopen.",contract:"selected-choice"},externalImage:{family:"externalImage",support:"fail-closed",description:'External image relationship (r:link / TargetMode="External"). Not fetched.',contract:"none",diagnostic:Cr.externalImageDeferred},missingRelationship:{family:"missingRelationship",support:"fail-closed",description:"Drawing references a relationship id absent from the owner part .rels.",contract:"none",diagnostic:Cr.missingRelationship},missingMediaPart:{family:"missingMediaPart",support:"fail-closed",description:"Relationship resolves but the target media part bytes are missing or empty.",contract:"none",diagnostic:Cr.missingMediaPart},wrongRelationshipType:{family:"wrongRelationshipType",support:"fail-closed",description:"Relationship exists but is not an image relationship type.",contract:"none",diagnostic:Cr.unsupportedRelationshipType},unsupportedMime:{family:"unsupportedMime",support:"fail-closed",description:"Media MIME outside the supported allowlist (incl. GIF/BMP/ICO).",contract:"none",diagnostic:Cr.unsupportedMime},oversizedMediaPart:{family:"oversizedMediaPart",support:"fail-closed",description:"Media part exceeds the host byte-size policy before bytes are materialized.",contract:"none",diagnostic:Cr.imageTooLarge},unsafeSvg:{family:"unsafeSvg",support:"fail-closed",description:"SVG content rejected by the SVG safety policy.",contract:"none",diagnostic:Cr.unsafeSvg},metafileOrTiff:{family:"metafileOrTiff",support:"fail-closed",description:"EMF/WMF/TIFF and other non-browser-native formats with no approved conversion path.",contract:"none",diagnostic:Cr.unsupportedFormat},embeddedObject:{family:"embeddedObject",support:"fail-closed",description:"OLE / ActiveX / embedded package object.",contract:"none",diagnostic:Cr.embeddedObjectNotSupported},smartArtOrDiagram:{family:"smartArtOrDiagram",support:"fail-closed",description:"SmartArt / diagram / unknown external graphic-data object.",contract:"none",diagnostic:Cr.unsupportedObject},vml:{family:"vml",support:"fail-closed",description:"VML structure outside any supported image-like subset (default fail-closed policy).",contract:"none",diagnostic:Cr.vmlUnsupported},vmlImageLike:{family:"vmlImageLike",support:"fail-closed",description:"Simple VML image references (v:imagedata) / watermark image metadata. Fail-closed unless a later change promotes a named subset with deterministic fixtures and exact oracles.",contract:"none",diagnostic:Cr.vmlImageUnsupported},unsupportedGeometryCommand:{family:"unsupportedGeometryCommand",support:"fail-closed",description:"Custom geometry command the extractor does not implement, e.g. arcTo.",contract:"none",diagnostic:Cr.unsupportedGeometryCommand},unsupportedAnchorFields:{family:"unsupportedAnchorFields",support:"fail-closed",description:"Anchor fields required for honest placement are unsupported (char-relative, alignment modes, etc.).",contract:"none",diagnostic:Cr.anchorUnsupported},unsupportedWrapFields:{family:"unsupportedWrapFields",support:"fail-closed",description:"Wrap fields required for honest placement are unsupported (arbitrary wrap polygons, etc.).",contract:"none",diagnostic:Cr.wrapUnsupported},alternateContentNoSupportedChoice:{family:"alternateContentNoSupportedChoice",support:"fail-closed",description:"mc:AlternateContent with no supported choice and no usable fallback.",contract:"none",diagnostic:Cr.altContentNoSupportedChoice},groupChildUnsupported:{family:"groupChildUnsupported",support:"fail-closed",description:"Unsupported child inside an otherwise-supported group. Supported siblings are not dropped.",contract:"none",diagnostic:Cr.groupChildUnsupported},objectEditing:{family:"objectEditing",support:"deferred",description:"Editing/mutation of anchored/vector objects.",contract:"none"},customWrapPolygon:{family:"customWrapPolygon",support:"deferred",description:"Full Word-compatible text wrapping for arbitrary custom wrap polygons.",contract:"none"},chartFidelity:{family:"chartFidelity",support:"deferred",description:"Complete chart fidelity (a dedicated chart effort owns the parsed subset).",contract:"none"},vmlFidelity:{family:"vmlFidelity",support:"deferred",description:"Complete VML fidelity.",contract:"none"},decorativeAccessibilityUi:{family:"decorativeAccessibilityUi",support:"deferred",description:"Full accessibility UI for decorative image semantics beyond preserving source data.",contract:"none"}},CX=Object.keys(mO),kX=Object.freeze(["multiple-sections","furniture-page-tokens","non-balanceable-multi-column-sections","body-anchored-objects","non-flowing-page-relative-body-anchors","footnotes","page-references","cross-references","keep-constraints","tables","furniture-anchored-objects"]),gO=Object.freeze(["checkpoint-geometry","section-numbering","font-style-inputs","notes","furniture","flowing-anchors","non-flowing-page-anchors","convergence","source-topology"]),SX=new Set(gO),po=()=>({oneOf:[{type:"boolean"},{type:"null"}]}),Dl=()=>({oneOf:[{type:"string",minLength:1},{type:"null"}]}),rd=()=>({oneOf:[{type:"number"},{type:"null"}]}),od=e=>({oneOf:[{type:"object",properties:e,additionalProperties:!1,minProperties:1},{type:"null"}]}),vO={type:"object",properties:{style:{oneOf:[{type:"string",minLength:1},{type:"null"}]},color:{oneOf:[{type:"string",minLength:1},{type:"null"}]},themeColor:{oneOf:[{type:"string",minLength:1},{type:"null"}]}},additionalProperties:!1,minProperties:1},yO={type:"object",properties:{id:{type:"number"},val:{type:"boolean"}},required:["id"],additionalProperties:!1},bO=()=>({oneOf:[{type:"boolean"},{type:"null"},vO]}),wO=()=>({oneOf:[{type:"array",items:yO,minItems:1},{type:"null"}]});function Dm(e,t){return{storage:"mark",markName:e,textStyleAttr:t}}function CO(e){return{storage:"runAttribute",nodeName:"run",runPropertyKey:e}}var D0=(e,t,n)=>({key:e,type:"boolean",ooxmlElement:t,storage:"mark",tracked:!0,carrier:Dm(n),schema:po()}),Lc=(e,t,n,r,o)=>({key:e,type:t,ooxmlElement:n,storage:"mark",tracked:!0,carrier:Dm("textStyle",o??e),schema:r}),Kn=(e,t,n,r,o)=>({key:e,type:t,ooxmlElement:n,storage:"runAttribute",tracked:!1,carrier:CO(o??e),schema:r}),Om=[D0("bold","w:b","bold"),D0("italic","w:i","italic"),D0("strike","w:strike","strike"),{key:"underline",type:"object",ooxmlElement:"w:u",storage:"mark",tracked:!0,carrier:Dm("underline"),schema:bO()},{key:"highlight",type:"string",ooxmlElement:"w:highlight",storage:"mark",tracked:!0,carrier:Dm("highlight"),schema:Dl()},Lc("color","string","w:color",Dl()),Lc("fontSize","number","w:sz",rd()),Lc("fontFamily","string","w:rFonts",Dl()),Lc("letterSpacing","number","w:spacing",rd()),Lc("vertAlign","string","w:vertAlign",{oneOf:[{enum:["superscript","subscript","baseline"]},{type:"null"}]}),Lc("position","number","w:position",rd()),Kn("dstrike","boolean","w:dstrike",po()),Kn("smallCaps","boolean","w:smallCaps",po()),Lc("caps","boolean","w:caps",po(),"textTransform"),Kn("shading","object","w:shd",od({fill:{oneOf:[{type:"string",minLength:1},{type:"null"}]},color:{oneOf:[{type:"string",minLength:1},{type:"null"}]},val:{oneOf:[{type:"string",minLength:1},{type:"null"}]}})),Kn("border","object","w:bdr",od({val:{oneOf:[{type:"string",minLength:1},{type:"null"}]},sz:{oneOf:[{type:"number"},{type:"null"}]},color:{oneOf:[{type:"string",minLength:1},{type:"null"}]},space:{oneOf:[{type:"number"},{type:"null"}]}}),"borders"),Kn("outline","boolean","w:outline",po()),Kn("shadow","boolean","w:shadow",po()),Kn("emboss","boolean","w:emboss",po()),Kn("imprint","boolean","w:imprint",po()),Kn("charScale","number","w:w",rd(),"w"),Kn("kerning","number","w:kern",rd(),"kern"),Kn("vanish","boolean","w:vanish",po()),Kn("webHidden","boolean","w:webHidden",po()),Kn("specVanish","boolean","w:specVanish",po()),Kn("rtl","boolean","w:rtl",po()),Kn("cs","boolean","w:cs",po()),Kn("bCs","boolean","w:bCs",po(),"boldCs"),Kn("iCs","boolean","w:iCs",po(),"italicCs"),Kn("eastAsianLayout","object","w:eastAsianLayout",od({id:{oneOf:[{type:"string",minLength:1},{type:"null"}]},combine:{oneOf:[{type:"boolean"},{type:"null"}]},combineBrackets:{oneOf:[{type:"string",minLength:1},{type:"null"}]},vert:{oneOf:[{type:"boolean"},{type:"null"}]},vertCompress:{oneOf:[{type:"boolean"},{type:"null"}]}})),Kn("em","string","w:em",Dl()),Kn("fitText","object","w:fitText",od({val:{oneOf:[{type:"number"},{type:"null"}]},id:{oneOf:[{type:"string",minLength:1},{type:"null"}]}})),Kn("snapToGrid","boolean","w:snapToGrid",po()),Kn("lang","object","w:lang",od({val:{oneOf:[{type:"string",minLength:1},{type:"null"}]},eastAsia:{oneOf:[{type:"string",minLength:1},{type:"null"}]},bidi:{oneOf:[{type:"string",minLength:1},{type:"null"}]}})),Kn("oMath","boolean","w:oMath",po()),Kn("rStyle","string","w:rStyle",Dl(),"styleId"),Kn("rFonts","object","w:rFonts",od({ascii:{oneOf:[{type:"string",minLength:1},{type:"null"}]},hAnsi:{oneOf:[{type:"string",minLength:1},{type:"null"}]},eastAsia:{oneOf:[{type:"string",minLength:1},{type:"null"}]},cs:{oneOf:[{type:"string",minLength:1},{type:"null"}]},asciiTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},hAnsiTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},eastAsiaTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},csTheme:{oneOf:[{type:"string",minLength:1},{type:"null"}]},hint:{oneOf:[{type:"string",minLength:1},{type:"null"}]}}),"fontFamily"),Kn("fontSizeCs","number","w:szCs",rd()),Kn("ligatures","string","w14:ligatures",Dl()),Kn("numForm","string","w14:numForm",Dl()),Kn("numSpacing","string","w14:numSpacing",Dl()),Kn("stylisticSets","array","w14:stylisticSets",wO()),Kn("contextualAlternates","boolean","w14:cntxtAlts",po())],_X=new Set(Om.map(e=>e.key)),kO=Object.fromEntries(Om.map(e=>[e.key,e])),AX={mark:Om.filter(e=>e.storage==="mark").map(e=>e.key),runAttribute:Om.filter(e=>e.storage==="runAttribute").map(e=>e.key)},Fm=new WeakMap,O_=new WeakMap;function SO(e,t,n){let r=Fm.get(e);r||(r=new WeakMap,Fm.set(e,r)),r.set(t,n)}var F_=new WeakMap;function _O(e){return F_.get(e)?.()??Promise.resolve(null)}function id(e,t,n){return O_.get(e)?.(t,n)??e.commands.executeAsync(t,n)}function Ha(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Nm(){const e=globalThis;return{sink:typeof e.__superdocV2BenchPipelineTiming=="function"?e.__superdocV2BenchPipelineTiming:null,workerContext:e.__superdocV2BenchWorkerMessageContext??null}}function O0(e){const{sink:t}=Nm();if(t)try{t(e)}catch{}}var F0=new WeakMap;function AO(e){let t=F0.get(e);return t||(t={refCount:0,generation:0,abortController:new AbortController,inFlight:null,activeMutationTokens:new Set},F0.set(e,t)),t.refCount+=1,t}function IO(e,t){t.refCount=Math.max(0,t.refCount-1),!(t.refCount>0)&&(t.abortController.abort("ui-controller-destroyed"),t.inFlight=null,t.activeMutationTokens.clear(),F0.delete(e))}var EO=new Set(Object.values(tt));function Bm(e,t){return typeof e=="string"&&EO.has(e)?e:t}function N0(e){if(e&&typeof e=="object"&&e.ok===!1){const t=e.reason;return t==="host-not-ready"||t==="host-disposed"||t==="editing-mount-required"?{ok:!1,reason:tt.notReady}:{ok:!1,reason:Bm(t,tt.targetUnresolved)}}return{ok:!0}}var xO=["document-replaced","editorCreate","active-editor-change","document-mode-change","zoomChange","measurement-unit-change","viewport-change","fonts-changed"],TO={[I_.bulletList]:"bullet",[I_.numberedList]:"ordered"};function N_(e){return TO[e]??null}var RO={disc:"disc",circle:"circle",square:"square",decimal:"decimal","decimal-paren":"decimalParenthesis","upper-roman":"upperRoman","lower-roman":"lowerRoman","upper-alpha":"upperLetter","upper-alpha-paren":"upperLetterParenthesis","lower-alpha":"lowerLetter","lower-alpha-paren":"lowerLetterParenthesis"};function MO(e){const t=RO[e];return t?{preset:t,behavior:"toggleStyle"}:{}}var LO={status:"ready",empty:!0,target:null,selectionTarget:null,activeMarks:[],activeCommentIds:[],activeChangeIds:[],quotedText:""},PO=[{key:"contentControls",match:"exact",note:"full-document SDT catalog parse (the measured during-load cliff)"},{key:"contentControls:inRange:",match:"prefix",note:"same adapter load() as the catalog, issued per settled selection"},{key:"hyperlinks:",match:"prefix",note:"per-block hyperlink list over the loading story"},{key:"styles:catalog:",match:"prefix",note:"WordStyleModel recompile from package bytes"},{key:"comments",match:"exact",note:"audited: full comments list; stale-served during load"},{key:"trackChanges",match:"exact",note:"audited: shared all-story tracked-changes catalog; stale-served during load"},{key:"trackChanges:all",match:"exact",note:"audited: current-token validation over the shared all-story catalog; consumers fail closed on non-ready"},{key:"tables",match:"exact",note:"reserved: full tables catalog"},{key:"sections",match:"exact",note:"reserved: full sections list"}],DO=new Set(["/word/comments.xml","/word/commentsExtended.xml","/word/commentsIds.xml"]);function OO(e){return PO.some(t=>t.match==="exact"?t.key===e:e.startsWith(t.key))}var B_={ready:0,stale:1,pending:2};function Ol(...e){let t="ready";for(const n of e)B_[n]>B_[t]&&(t=n);return t}function Lt(e,t){if(typeof e!="function")return t;try{const n=e();return n===void 0?t:n}catch{return t}}function kr(e){return!!e&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function"}function Sr(e,t){if(!e)return null;const n=t.split(".");let r=e;for(const o of n){if(r==null)return null;r=r[o]}return typeof r=="function"?r:null}function er(e,t="CAPABILITY_UNAVAILABLE"){return{success:!1,failure:{code:t,message:e}}}function Qf(e,t){return{success:!1,failure:{code:"PARTIAL_LINK_EDIT",message:"Hyperlink target was updated, but display text replacement failed."},applied:{href:!0,text:!1},hyperlinkResult:e,textResult:t}}function Jf(e){if(!e||typeof e!="object")return null;const t=e.target;return t&&typeof t=="object"?t:null}function B0(e){if(!e||typeof e!="object")return!1;const t=e,n=i=>{if(!i||typeof i!="object")return!1;const s=i;return s.kind==="text"&&typeof s.blockId=="string"&&typeof s.offset=="number"},r=i=>{if(!i||typeof i!="object")return!1;const s=i,a=s.range;return typeof s.blockId=="string"&&typeof a?.start=="number"&&typeof a.end=="number"};if(Array.isArray(t.segments)){const i=t.segments[0],s=t.segments[t.segments.length-1];return r(i)&&r(s)}if(t.kind==="selection")return n(t.start)&&n(t.end);if(t.kind!=="text"||typeof t.blockId!="string")return!1;const o=t.range;return typeof o?.start=="number"&&typeof o.end=="number"}function z_(e,t){if(!e||typeof e!="object")return null;const n=Jf(e),r=e,o=r.navigationTarget&&typeof r.navigationTarget=="object"?r.navigationTarget:null;if(o?.kind==="block"&&typeof o.blockId=="string"&&o.blockId.length>0){const i={kind:"text",blockId:o.blockId,range:{start:0,end:0},...o.story&&typeof o.story=="object"?{story:o.story}:{},...r.address&&typeof r.address=="object"?{address:r.address}:{}};if(t?.preferStableBlock||!B0(n))return i}return n}function Qn(e){if(!e||typeof e!="object")return"story:body";const t=e,n=typeof t.storyType=="string"?t.storyType:"body";switch(n){case"body":return"story:body";case"headerFooterPart":return`story:headerFooterPart:${typeof t.refId=="string"?t.refId:""}`;case"headerFooterSlot":return JSON.stringify({storyType:n,section:t.section??null,headerFooterKind:t.headerFooterKind??null,variant:t.variant??null,resolution:t.resolution??"effective",onWrite:t.onWrite??"materializeIfInherited"});case"footnote":return`story:footnote:${typeof t.noteId=="string"?t.noteId:""}`;case"endnote":return`story:endnote:${typeof t.noteId=="string"?t.noteId:""}`;case"textbox":return`story:textbox:${typeof t.textboxId=="string"?t.textboxId:""}`;default:return JSON.stringify(t)}}function eh(e){if(!e||typeof e!="object")return null;const t=e,n=t.address&&typeof t.address=="object"?t.address:null;if(n?.story&&typeof n.story=="object")return n.story;if(t.storyLocator&&typeof t.storyLocator=="object")return t.storyLocator;if(t.trackedChangeStory&&typeof t.trackedChangeStory=="object")return t.trackedChangeStory;const r=Jf(e);if(!r||typeof r!="object")return null;const o=r;if(o.story&&typeof o.story=="object")return o.story;const i=o.address&&typeof o.address=="object"?o.address:null;return i?.story&&typeof i.story=="object"?i.story:null}function Ti(e,t,n){return Ur(e)!==t?!1:n?Qn(eh(e))===Qn(n):!0}function th(e){const t=eh(e);if(!(!t||Qn(t)===Qn(null)))return t}function j_(e){if(typeof e!="string"||e.length===0)return;const t=p6(e);switch(t.kind){case"body":return;case"footnote":return t.id?{kind:"story",storyType:"footnote",noteId:t.id}:void 0;case"endnote":return t.id?{kind:"story",storyType:"endnote",noteId:t.id}:void 0;case"header":case"footer":return t.id?{kind:"story",storyType:"headerFooterPart",refId:t.id}:void 0;case"textbox":return t.id?{kind:"story",storyType:"textbox",textboxId:t.id}:void 0;default:return}}function V_(e){if(!(typeof e!="string"||e.length===0||e==="body")){if(e.startsWith("hf:part:")){const t=e.slice(8);return t?{kind:"story",storyType:"headerFooterPart",refId:t}:void 0}if(e.startsWith("fn:")){const t=e.slice(3);return t?{kind:"story",storyType:"footnote",noteId:t}:void 0}if(e.startsWith("en:")){const t=e.slice(3);return t?{kind:"story",storyType:"endnote",noteId:t}:void 0}}}function zm(e){if(!e||typeof e!="object")return null;const t=e.selectionTarget;return t&&typeof t=="object"?t:null}function nh(e){if(!e||typeof e!="object")return null;const t=e.id;return typeof t=="string"&&t.length>0?t:null}function FO(e){if(!e||typeof e!="object")return null;const t=e;if(t.kind!=="selection")return e;const n=t.start;return!n||typeof n!="object"?null:{...t,end:n}}function Ur(e){if(!e||typeof e!="object")return null;const t=e,n=t.id??t.commentId??t.changeId;return typeof n=="string"&&n.length>0?n:null}function sd(e){return typeof e=="string"?e.trim():""}function NO(e,t){const n=t??{},r=sd(n.id).toLowerCase(),o=sd(e.authorId).toLowerCase();if(r&&o)return r===o;const i=sd(n.email).toLowerCase(),s=sd(e.authorEmail).toLowerCase();if(i&&s)return i===s;if(r||i||o||s)return!1;const a=sd(e.author).replace(/\s+/g," ").toLowerCase();if(!a)return!0;const l=sd(n.name).replace(/\s+/g," ").toLowerCase();return!!(l&&l===a)}function BO(e){if(!e||typeof e!="object")return null;const t=e,n=t.anchor,r=t.focus,o=n?.visualCaret,i=r?.visualCaret,s=o?.trackChangeId,a=i?.trackChangeId;return typeof s=="string"&&s.length>0&&s===a?s:null}function zO(e){if(!e||typeof e!="object")return!1;const t=e,n=t.anchor,r=t.focus;return typeof n?.blockId!="string"||!n.blockId||typeof r?.blockId!="string"||!r.blockId||!Number.isFinite(n.blockOffset)||!Number.isFinite(r.blockOffset)?!1:n.blockId!==r.blockId||n.blockOffset!==r.blockOffset||Number.isFinite(n.trackedBlockOffset)&&Number.isFinite(r.trackedBlockOffset)&&n.trackedBlockOffset!==r.trackedBlockOffset}var U_=new WeakMap;function $_(e){const t=[],n=i=>{typeof i=="string"&&i.length>0&&!t.includes(i)&&t.push(i)},r=i=>{if(!i||typeof i!="object")return;const s=i,a=s.sourceIds;if(a&&typeof a=="object"&&(n(a.wordIdInsert),n(a.wordIdDelete),Array.isArray(a.wordIdOther)))for(const f of a.wordIdOther)n(f);const l=s.wordRevisionIds;l&&typeof l=="object"&&(n(l.insert),n(l.delete),n(l.format));const u=s.replacement;if(u&&typeof u=="object")for(const f of[u.inserted,u.deleted])f&&typeof f=="object"&&(n(f.id),n(f.wordId));const d=s.move;if(d&&typeof d=="object")for(const f of[d.source,d.destination])f&&typeof f=="object"&&(n(f.id),n(f.wordId))};r(e);const o=e?.change;return o&&o!==e&&r(o),t}function ta(e){const t=U_.get(e);if(t)return t;const n=new Set,r=new Map;for(const i of e){const s=Ur(i);if(s){n.add(s);for(const a of $_(i)){r.has(a)||r.set(a,s);const l=`imported:${a}`;r.has(l)||r.set(l,s)}}}const o={toPublicId(i){if(n.has(i))return i;const s=r.get(i);return s!=null&&n.has(s)?s:null},aliasesFor(i){const s=[i];for(const[a,l]of r)l===i&&!s.includes(a)&&s.push(a);return s}};return U_.set(e,o),o}var H_=new WeakMap,G_=new WeakMap;function Fl(e,t){const n=Qn(t);let r=H_.get(e);r||(r=new Map,H_.set(e,r));const o=r.get(n);if(o)return o;const i=ta(e.filter(s=>Qn(eh(s))===n));return r.set(n,i),i}function W_(e){return!!e&&typeof e=="object"&&e.storyType==="textbox"}function jO(e,t){const n=t.filter(o=>e.some(i=>Ur(i)===o&&eh(i)==null));if(n.length===0)return null;if(n.length===1)return n[0];const r=new Set;for(const o of n){const i=e.find(s=>Ur(s)===o);if(i)for(const s of $_(i)){if(r.has(s))return null;r.add(s)}}return n[0]}function VO(e){const t=G_.get(e);if(t)return t;const n=e.filter(o=>eh(o)!=null),r=n.length===e.length?e:n;return G_.set(e,r),r}function UO(e){const{selectionIds:t,publicIds:n,selection:r,bodyItems:o,allStoryItems:i}=e;if(t.length===0)return null;const s=u=>{for(const d of t){const f=u.toPublicId(d);if(f)return f}return null},a=hs(r),l=Qn(a)===Qn(null);if(i){const u=l?VO(i):i,d=s(Fl(u,a));if(d)return d;const f=n?.find(p=>u.some(g=>Ti(g,p,a)));return f||(l?s(ta(o)):W_(a)?jO(i,t):null)}return l?s(ta(o))??t[0]??null:null}function $O(e,t){const n=e.find(r=>Ur(r)===t||r.importedId===t);return n?n.rootCommentId??n.parentCommentId??Ur(n)??t:null}function HO(e){const t=e.selectionTarget;if(t){const s=t.start,a=t.end,l=typeof s?.blockId=="string"?s.blockId:void 0,u=typeof a?.blockId=="string"?a.blockId:l;if(l)return{startBlockId:l,endBlockId:u??l}}const n=e.target,r=n&&Array.isArray(n.segments)?n.segments:[],o=r[0]?.blockId,i=r[r.length-1]?.blockId;return typeof o=="string"?{startBlockId:o,endBlockId:typeof i=="string"?i:o}:null}function Kr(e){const t=[],n=s=>{typeof s=="string"&&s.length>0&&!t.includes(s)&&t.push(s)},r=e.target,o=r&&Array.isArray(r.segments)?r.segments:[];for(const s of o)n(s?.blockId);const i=e.selectionTarget;return i&&(n(i.start?.blockId),n(i.end?.blockId)),t}var GO=64;function Pc(e){return e.length<=GO}function hs(e){const t=e.target,n=e.selectionTarget,r=n?.start,o=n?.end,i=t?.story??n?.story??r?.story??o?.story;return i&&typeof i=="object"?i:{kind:"story",storyType:"body"}}function _o(e,t){return{kind:"block",nodeType:"paragraph",nodeId:e,...t&&typeof t=="object"?{story:t}:{}}}function Ga(e){return{kind:"block",nodeType:"paragraph",nodeId:e}}function K_(e,t){return{kind:"block",nodeType:"listItem",nodeId:e,...t&&typeof t=="object"?{story:t}:{}}}var q_=720;function na(e){return Math.round(e*20)}function ad(e){return typeof e=="number"&&Number.isFinite(e)}function WO(e){if(!e||typeof e!="object")return null;const t=e.node;if(!t||typeof t!="object")return null;const n=t.kind==="heading"?t.heading??null:t.kind==="paragraph"?t.paragraph??null:null;if(!n)return null;const r=n.resolved,o=n.props,i=r?.indent??o?.indent;if(!i||typeof i!="object")return null;const s=ad(i.left)?na(i.left):ad(i.start)?na(i.start):void 0,a=ad(i.right)?na(i.right):ad(i.end)?na(i.end):void 0,l=ad(i.firstLine)?na(i.firstLine):void 0,u=ad(i.hanging)?na(i.hanging):void 0;return s==null&&a==null&&l==null&&u==null?null:{...s!=null?{left:s}:{},...a!=null?{right:a}:{},...l!=null?{firstLine:l}:{},...u!=null?{hanging:u}:{}}}function z0(e){const t=e.target,n=t&&Array.isArray(t.segments)?t.segments:[],r=t?.story,o=[];for(const i of n){if(!i||typeof i.blockId!="string")continue;const s=i.range;!s||typeof s.start!="number"||typeof s.end!="number"||s.start===s.end||o.push({kind:"text",blockId:i.blockId,range:{start:s.start,end:s.end},...r?{story:r}:{}})}return o}function KO(e){if(!e||typeof e!="object")return[];const t=e,n=t.story,r=[];if(t.kind==="text"&&t.range&&typeof t.blockId=="string"){const o=t.range;return typeof o.start=="number"&&typeof o.end=="number"&&o.start!==o.end&&r.push({kind:"text",blockId:t.blockId,range:{start:Math.min(o.start,o.end),end:Math.max(o.start,o.end)},...n?{story:n}:{}}),r}if(t.kind==="text"&&Array.isArray(t.segments)){for(const o of t.segments){const i=o?.range;typeof o?.blockId=="string"&&typeof i?.start=="number"&&typeof i?.end=="number"&&i.start!==i.end&&r.push({kind:"text",blockId:o.blockId,range:{start:Math.min(i.start,i.end),end:Math.max(i.start,i.end)},...n?{story:n}:{}})}return r}if(t.kind==="selection"){const o=t.start,i=t.end,s=typeof o?.blockId=="string"&&i?.blockId===o.blockId?o.blockId:null;o?.kind==="text"&&i?.kind==="text"&&s&&typeof o.offset=="number"&&typeof i.offset=="number"&&o.offset!==i.offset&&r.push({kind:"text",blockId:s,range:{start:Math.min(o.offset,i.offset),end:Math.max(o.offset,i.offset)},...t.story??o.story?{story:t.story??o.story}:{}})}return r}function rh(e){if(!e||typeof e!="object")return null;const t=e,n=t.story;if(t.kind==="text"&&t.range&&typeof t.blockId=="string"){const r=t.range;if(typeof r.start=="number"&&typeof r.end=="number"&&r.start===r.end)return{kind:"text",blockId:t.blockId,range:{start:r.start,end:r.end},...n?{story:n}:{}}}if(t.kind==="text"&&Array.isArray(t.segments)){const r=t.segments[0],o=r?.range;if(typeof r?.blockId=="string"&&typeof o?.start=="number"&&typeof o?.end=="number"&&o.start===o.end)return{kind:"text",blockId:r.blockId,range:{start:o.start,end:o.end},...n?{story:n}:{}}}if(t.kind==="selection"){const r=t.start,o=t.end,i=typeof r?.blockId=="string"&&o?.blockId===r.blockId?r.blockId:null;if(r?.kind==="text"&&o?.kind==="text"&&i&&typeof r.offset=="number"&&typeof o.offset=="number"&&r.offset===o.offset)return{kind:"text",blockId:i,range:{start:r.offset,end:r.offset},...t.story??r.story?{story:t.story??r.story}:{}}}return null}function $i(e){return rh(e.target)??rh(e.selectionTarget)}function Y_(e){const t=$i(e)?.story;return t?.storyType==="headerFooterPart"||t?.storyType==="headerFooterSlot"}var X_=["fontFamily","fontSize","color","highlight"],qO={undo:"history.undo",redo:"history.redo"},oh=["bold","italic","underline","strikethrough"];function j0(e){return X_.includes(e)}function ld(e){const t=e.target,n=t&&Array.isArray(t.segments)?t.segments:[],r=[],o=(l,u,d)=>{typeof l!="string"||typeof u!="number"||typeof d!="number"||r.push({blockId:l,start:Math.min(u,d),end:Math.max(u,d)})};for(const l of n){const u=l?.range;o(l?.blockId,u?.start,u?.end)}if(r.length>0)return r;const i=e.selectionTarget,s=i?.start,a=i?.end;return!s||!a||s.blockId!==a.blockId||o(s.blockId,s.offset,a.offset),r}function ps(e){const t=e.target,n=e.selectionTarget,r=n?.start,o=n?.end,i=t?.story??n?.story??r?.story??o?.story;return i&&typeof i=="object"?i:void 0}function YO(e){const t=ps(e);if(!t||typeof t!="object")return"body";const n=t;return JSON.stringify({storyType:typeof n.storyType=="string"?n.storyType:"body",refId:typeof n.refId=="string"?n.refId:null,noteId:typeof n.noteId=="string"?n.noteId:null,textboxId:typeof n.textboxId=="string"?n.textboxId:null})}function Wa(e){const t=ld(e);return t.length===0?null:[YO(e),...t.map(n=>`${n.blockId}:${n.start}-${n.end}`)].join("|")}function Z_(e){const t=e.selectionTarget;return!t||typeof t!="object"?null:Mc({selectionTarget:t})}function XO(e,t){if(e==="fontSize"){const r=typeof t=="number"?t:Number(t);return Number.isFinite(r)&&r>0?String(r):null}if(typeof t!="string")return null;const n=t.trim();return n.length===0?null:e==="color"||e==="highlight"?n.toUpperCase():n}function ZO(e,t){return Math.max(e.start,t.start)<Math.min(e.end,t.end)}function QO(e){if(!e)return[];const t=Array.isArray(e.blocks)?e.blocks:[],n=[];for(const r of t){const o=r?.range,i=r?.blockId;typeof i!="string"||typeof o?.start!="number"||typeof o?.end!="number"||n.push({blockId:i,start:Math.min(o.start,o.end),end:Math.max(o.start,o.end)})}return n}function JO(e,t){return e.length!==t.length?!1:e.every((n,r)=>{const o=t[r];return o?.blockId===n.blockId&&o?.start===n.start&&o?.end===n.end})}function Q_(e,t){const n=ld(t);if(n.length===0)return null;const r=e&&Array.isArray(e.items)?e.items:[];if(r.length===0)return null;const o=r.find(i=>JO(n,QO(i)));if(o)return o;if(n.length===1){const i=r.find(s=>{const a=s?.address;return a?.kind==="block"&&a.nodeId===n[0].blockId});if(i)return i}return r[0]??null}function eF(e,t){const n=t==="fontSize"?e?.fontSizePt??e?.fontSize:t==="highlight"?e?.highlight??e?.backgroundColor:e?.[t];if(typeof n=="number")return Number.isFinite(n)?String(n):void 0;if(typeof n!="string")return;const r=n.trim();if(r.length!==0)return t==="color"||t==="highlight"?r.toUpperCase():r}function V0(e){if(typeof e!="string")return;const t=e.split(",")[0]?.trim().replace(/^['"]+|['"]+$/g,"").trim();if(!t)return;const n=t.toLowerCase();if(!(n==="serif"||n==="sans-serif"||n==="monospace"||n==="cursive"||n==="fantasy"))return t}function tF(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return;const t=Math.round(e*.75*2)/2;if(!(t<=0))return String(t)}function nF(e,t){return e==="fontFamily"?t.toLowerCase():e==="color"||e==="highlight"?t.toUpperCase():t}function J_(e,t){if(!e)return{};const n=new Map;for(const i of ld(t)){const s=n.get(i.blockId)??[];s.push({start:i.start,end:i.end}),n.set(i.blockId,s)}if(n.size===0)return{};const r=Array.isArray(e.blocks)?e.blocks:[],o={};for(const i of X_){const s=new Map;let a=!1,l=!1;for(const u of r){const d=typeof u?.blockId=="string"?u.blockId:null;if(!d)continue;const f=n.get(d);if(!f?.length)continue;const p=Array.isArray(u?.runs)?u.runs:[];for(const g of p){const m=g?.range,v=typeof m?.start=="number"?m.start:null,C=typeof m?.end=="number"?m.end:null;if(v==null||C==null||!f.some(b=>ZO(b,{start:v,end:C})))continue;a=!0;const w=eF(g?.styles,i);if(w===void 0){l=!0;continue}const S=nF(i,w);if(s.has(S)||s.set(S,w),s.size>1)break}if(s.size>1)break}a&&!l&&s.size===1&&(o[i]=[...s.values()][0])}return o}function U0(e,t){const n=Kr(e)[0];return n?t==="nodeId"?{kind:"after",nodeId:n}:{kind:"after",target:_o(n)}:{kind:"documentEnd"}}function rn(e,t){const n=e.supported??t!=="unsupported",r=e.enabled??(e.disabled!==void 0?!e.disabled:n);return{enabled:r,disabled:!r,active:e.active??!1,supported:n,value:e.value,source:t,reason:r?void 0:e.reason}}function cd(e){if(!e||typeof e!="object")return null;const t=e,n=t.change,r=n&&typeof n=="object"?n:t;return{...t,id:t.id??r.id,change:r}}function ud(e){const t=e,n=t.change;return n&&typeof n=="object"?n:t}function ra(e){if(kr(e))return!0;if(e===!1)return!1;if(e===!0||e==null||typeof e!="object")return!0;const t=e;return"success"in t||"failure"in t||"effects"in t?e:t.status!=="rejected"}function jm(e){return!!e&&typeof e=="object"&&e.success===!0}function eA(e){if(e.dryRun===!0)return!1;const t=e.receipt;return!(t&&typeof t=="object"&&t.changed===!1||t&&typeof t=="object"&&t.noop===!0||t&&typeof t=="object"&&t.status==="NO_OP")}function mo(e){return!(e===!1||e&&typeof e=="object"&&e.success===!1)}function ih(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function $0(e){const t=[],n=r=>{if(!r||typeof r!="object")return;const o=r;if(Array.isArray(o.runs)&&t.push(o),Array.isArray(o.rows))for(const i of o.rows){const s=i?.cells;if(Array.isArray(s))for(const a of s){const l=a;if(Array.isArray(l?.blocks))for(const u of l.blocks)n(u);l?.paragraph&&n(l.paragraph)}}};if(Array.isArray(e))for(const r of e)n(r);return t}function Dc(e,t){return e.sourceAnchor?.sourceNodeId===t?!0:e.id===t}function Vm(e){return e.trackedChange?.kind==="delete"?0:typeof e.text=="string"?e.text.length:0}function Ri(e){let t=!1,n=null,r=null,o=null;for(const i of e)t=i,!mo(i)&&n===null&&(n=i),jm(i)&&(o=i),i!==!1&&(r=i);return n??o??r??t}function rF(e){const t=e?.anchor,n=t?.start,r=t?.end;return typeof n?.blockId!="string"||typeof r?.blockId!="string"||n.blockId!==r.blockId||typeof n.offset!="number"||typeof r.offset!="number"?null:{kind:"selection",start:{kind:"text",blockId:n.blockId,offset:n.offset},end:{kind:"text",blockId:r.blockId,offset:r.offset}}}function oF(e){return e.startsWith("#")?{kind:"anchor",anchor:e.slice(1)}:{kind:"external",url:e}}function Um(e){return nd(e)?.trackDecision??null}function iF(e){return{found:e.length>0,success:e.length>0,rects:e,rect:e[0]}}function Nl(e){return{found:!1,success:!1,rects:[],reason:e}}function sF(e,t){if(!t||typeof t.getBoundingClientRect!="function"||e.rects.length===0)return e;let n;try{const o=t.getBoundingClientRect();n={left:o.left,top:o.top}}catch{return e}const r=e.rects.map(o=>({...o,left:o.left-n.left,right:o.right-n.left,top:o.top-n.top,bottom:o.bottom-n.top}));return{...e,rects:r,rect:r[0]}}function aF(e){if(!e||typeof e!="object")return!1;const t=e;if(typeof t.blockId!="string"||!t.range||typeof t.range!="object")return!1;const n=t.range;return Number.isInteger(n.start)&&Number.isInteger(n.end)&&n.start>=0&&n.start<=n.end}function tA(e){if(!e||e.kind!=="text"||!Array.isArray(e.segments)||e.segments.length===0)return null;const t=Array.from(e.segments);if(!t.every(aF))return null;const n=t[0],r=t[t.length-1],o=e.story;return{kind:"selection",start:{kind:"text",blockId:n.blockId,offset:n.range.start,...o?{story:o}:{}},end:{kind:"text",blockId:r.blockId,offset:r.range.end,...o?{story:o}:{}},...o?{story:o}:{}}}function lF(e){return e.selectionTarget?e.selectionTarget:tA(e.target)}function dd(e){if(e.empty)return null;if(e.selectionTarget)return e.selectionTarget;const t=tA(e.target);return t&&t.start.kind==="text"&&t.end.kind==="text"&&t.start.blockId!==t.end.blockId?null:t}function H0(e){return!e.inline||typeof e.docRoute!="string"?null:e.docRoute.startsWith("format.")?e.docRoute.slice(7):null}var G0={bold:null,italic:null,underline:null,strike:null,color:null,highlight:null,fontFamily:null,fontSize:null,vertAlign:null,smallCaps:null,caps:null,letterSpacing:null,dstrike:null},cF=Object.fromEntries(Object.entries(G0).filter(([e])=>kO[e]?.tracked===!0));function uF(e,t,n,r){switch(e.kind){case"toggle":{const o=typeof n=="object"&&n!==null&&"value"in n?n.value:n;return typeof o=="boolean"||o===null?{target:t,value:o}:{target:t,value:!r}}case"value-string":{const o=typeof n=="object"&&n!==null&&"value"in n?n.value:n;return o===null?{target:t,value:null}:typeof o!="string"||o.trim()===""?null:{target:t,value:o}}case"value-number":{const o=typeof n=="object"&&n!==null&&"value"in n?n.value:n,i=typeof o=="number"?o:Number(o);return!Number.isFinite(i)||i<=0?null:{target:t,value:i}}case"clear":return{target:t,inline:{...G0}};default:return null}}function dF(e){const t=o=>{if(!o||typeof o!="object")return null;const i=o,s=i.rowIndex,a=i.columnIndex;return typeof s!="number"||!Number.isInteger(s)||typeof a!="number"||!Number.isInteger(a)?null:{rowIndex:s,columnIndex:a}};if(!e)return null;const n=t(e.start),r=t(e.end);return!n||!r?null:{start:n,end:r}}function fF(e,t){const{tableNodeId:n,rowIndex:r,columnIndex:o,cellNodeId:i,mergeRange:s}=t;switch(e){case"insert-row-before":return{nodeId:n,rowIndex:r,position:"above"};case"insert-row-after":return{nodeId:n,rowIndex:r,position:"below"};case"delete-row":return{nodeId:n,rowIndex:r};case"insert-column-before":return{nodeId:n,columnIndex:o,position:"left"};case"insert-column-after":return{nodeId:n,columnIndex:o,position:"right"};case"delete-column":return{nodeId:n,columnIndex:o};case"delete-table":return{nodeId:n};case"merge-cells":{const a=s??{start:{rowIndex:r,columnIndex:o},end:{rowIndex:r,columnIndex:o}};return{nodeId:n,start:a.start,end:a.end}}case"split-cell":return i?{nodeId:i,rows:1,columns:2}:null;case"remove-borders":return{nodeId:n,mode:"applyTo",applyTo:"all",border:null};default:return null}}function hF(e){const t=e.superdoc,n=new Map,r=new Map;let o=null,i=0;const s=[];let a=null,l=0,u=!1,d=Promise.resolve(),f=null,p={mode:"idle",snapshot:null,sourceSelectionKey:null,lastClickAt:0,pointerSelecting:!1,keyboardSelecting:!1},g=0,m=null;const v=new Set;let C={},w="",S=null;const b=()=>{const c=t?.activeEditor;return c&&typeof c=="object"?c:null},k={open:()=>{if(N)return{ok:!1,reason:tt.notReady};const c=b();if(!c)return{ok:!1,reason:tt.notReady};const h=c.contextMenu;if(!h||typeof h!="object"||typeof h.open!="function")return{ok:!1,reason:tt.operationUnavailable};try{const y=h.open();return y&&typeof y=="object"&&y.ok===!1?{ok:!1,reason:Bm(y.reason,tt.operationUnavailable)}:{ok:!0}}catch{return{ok:!1,reason:tt.operationUnavailable}}},close:()=>{if(N)return;const c=b()?.contextMenu;if(!(!c||typeof c!="object"||typeof c.close!="function"))try{c.close()}catch{}},contextAt:gx};let x;const M=()=>{if(x!==void 0)return x;const c=b()?.doc;return c&&typeof c=="object"?c:null},z=()=>{const c=b()?.v2TrackedChanges;return c&&typeof c=="object"?c:null},G=()=>{const c=b();if(c?.editorVersion!==2)return null;const h=c.reviewWindow;return h&&typeof h=="object"?h:null},F=()=>{const c=G();return!c||typeof c.getSnapshot!="function"?null:Lt(()=>c.getSnapshot(),null)},L=()=>typeof G()?.getSnapshot=="function",$=c=>{const h=c?.status;return h==="ready"||h==="stale"?h:"pending"},T=()=>{const c=b()?.host;return c&&typeof c=="object"?c:null},H=()=>{const c=b(),h=c?.doc;if(c?.editorVersion!==2)return h;const y=T(),_=y?Fm.get(t)?.get(y):null;if(!h||!y||!_)return null;const E=(D,V)=>new Proxy(D,{get(ne,le,xe){const je=Reflect.get(ne,le,xe);if(typeof le!="string")return je;const De=V?`${V}.${le}`:le;return typeof je=="function"&&_.supports(De)?(...Ye)=>b()!==c||T()!==y||c.doc!==h?!1:_.run(De,Ye):je&&(typeof je=="object"||typeof je=="function")?E(je,De):je}});return E(h,"")},R=c=>{if(c.storyType!=="headerFooterPart"||typeof c.refId!="string")return null;const h=b(),y=T(),_=h?.pageLayout??y?.pageLayout;if(!_||typeof _!="object")return null;const E=_.getActiveRulerContext,D=y?.resolveHeaderFooterEditTarget;if(typeof E!="function"||typeof D!="function")return null;const V=Lt(()=>E.call(_),null);if(!V||typeof V.pageIndex!="number")return null;for(const ne of["header","footer"]){const le=Lt(()=>D.call(y,{pageIndex:V.pageIndex,kind:ne}),null);if(!(le?.status!=="ready"||le.refId!==c.refId||typeof le.sectionId!="string"||!["default","first","even"].includes(String(le.slotVariant))))return{kind:"story",storyType:"headerFooterSlot",section:{kind:"section",sectionId:le.sectionId},headerFooterKind:ne,variant:le.slotVariant}}return null},U=()=>{const c=T(),h=c?.getPendingInlineFormat;if(typeof h!="function")return null;const y=Lt(()=>h.call(c),null);return y&&typeof y=="object"?y:null},W=c=>{const h=H0(c);if(!h)return null;const y=U();if(!y||!(h in y))return null;const _=y[h];return c.inline?.kind==="toggle"?_===!0:_!=null&&_!==""},ee=c=>{const h=H0(c);if(!h)return;const y=U();if(!y||!(h in y))return;const _=y[h];if(typeof _=="string"&&_!=="")return _;if(typeof _=="number"&&Number.isFinite(_))return String(_)},J=(c,h)=>{const y=T(),_=y?.setPendingInlineFormat;typeof _=="function"&&Lt(()=>_.call(y,c,h),void 0)},Z=c=>{const h=T(),y=h?.clearPendingInlineFormat;typeof y=="function"&&Lt(()=>y.call(h,c),void 0)},Me=new Set(["bold","italic","underline","strikethrough"]),fe=c=>{const h=U();if(!h)return;const y=Array.isArray(c.activeMarks)?c.activeMarks:[];let _=null;for(const E of Object.keys(h)){const D=h[E];let V;if(Me.has(E)){if(D===!1)continue;V=y.includes(E)===(D===!0)}else if(j0(E)){if(D==null)continue;_||(_=ol(c)),V=_[E]===D}else V=!1;V&&Z(E)}},ye=()=>{const c=b()?.editCommands;return c&&typeof c=="object"?c:null},ve=c=>{const h=ye();if(!h||typeof h.getSnapshot!="function")return null;const y=Lt(()=>h.getSnapshot(),null)?.commands?.[c];return y&&typeof y=="object"?y:null},Pe=()=>ve("lists.apply"),Ve=c=>{const h=c?.value?.seed;return h==="bullet"||h==="ordered"?h:null},nt=c=>{const h=qO[c];return h?ve(h):null},ct=()=>{const c=T();if(!c||typeof c.getTableContext!="function")return null;const h=Lt(()=>c.getTableContext(),null);return h&&typeof h=="object"?h:null},ft=()=>{const c=ct();if(!c||c.inTable!==!0)return null;const h=c.table,y=typeof h?.nodeId=="string"&&h.nodeId.length>0?h.nodeId:null;if(!y)return null;const _=c.row,E=c.column,D=c.cell,V=typeof _?.index=="number"&&Number.isInteger(_.index)?_.index:null,ne=typeof E?.index=="number"&&Number.isInteger(E.index)?E.index:null;if(V==null||ne==null)return null;const le=typeof D?.nodeId=="string"&&D.nodeId.length>0?D.nodeId:null,xe=c.cellRange;return{tableNodeId:y,rowIndex:V,columnIndex:ne,cellNodeId:le,mergeRange:dF(xe)}},It=new Map;let Le=null,oe=null,we=0,Q=0,I=0;const re=new Set,j=(c,h)=>c===h?!0:!c||!h?!1:c.id===h.id&&c.paintedEntityId===h.paintedEntityId&&Qn(c.story)===Qn(h.story),X=c=>Array.from(re).some(h=>j(h,c)),K=c=>{const h=T();if(typeof h?.getHandles!="function")return;const y=Lt(()=>h.getHandles(),null),_=y?.review;if(_){if(c){if(typeof _.setActiveReviewTarget!="function")return;const E=y?.layout;Lt(()=>_.setActiveReviewTarget({entityType:"trackedChange",entityId:c.id,...c.paintedEntityId?{paintedEntityId:c.paintedEntityId}:{},origin:"panel",layoutEpoch:typeof E?.generation=="number"?E.generation:0,story:c.story??{kind:"story",storyType:"body"}}),null);return}typeof _.getActiveReviewTarget!="function"||typeof _.clearActiveReviewTarget!="function"||Lt(()=>_.getActiveReviewTarget(),null)?.entityType==="trackedChange"&&Lt(()=>_.clearActiveReviewTarget(),void 0)}},ae=(c,h)=>{oe=c,we+=1,I+=1,h?.invalidateQueuedNavigation!==!1&&(Q+=1)},ke=new Set;let P,N=!1,me=null;const Se=new Map,Re=new Set;let ze=null,Ke=null,ot=!1,mt=null,Ot=0,Mt=null,Kt=null,$e=!1,Qt=null;const Hn=[],qt=()=>{if(ot||N)return;ot=!0;const c=()=>{ot=!1,N||$t("async-read-settled")};typeof queueMicrotask=="function"?queueMicrotask(c):Promise.resolve().then(c)},jn=250,Pn=5e3,$r=c=>{N||mt&&Ot<=c||(mt&&clearTimeout(mt),Ot=c,mt=setTimeout(()=>{mt=null,Ot=0,N||$t()},Math.max(0,c-Date.now())))},Nr=new WeakMap;let _r=0;const Tn=c=>{if(!c)return"none";let h=Nr.get(c);return h==null&&(h=_r+=1,Nr.set(c,h)),`e${h}`};let tr=0;const qn=e.superdoc,Bn=AO(qn),st=()=>{Bn.abortController.abort("review-mutation-started"),Bn.inFlight=null},_t=()=>{Bn.generation+=1,Bn.abortController=new AbortController,Bn.inFlight=null},gt=c=>{const h=Bn.activeMutationTokens;if(typeof c!="string"||c.length===0||h.has(c))return;const y=h.size===0;h.add(c),y&&st()},Xt=c=>{const h=Bn.activeMutationTokens;typeof c!="string"||!h.delete(c)||h.size===0&&_t()},gn=c=>{const h=z(),y=h?.listTrackedChanges;if(typeof y!="function")return b()?.editorVersion===2?Promise.reject(new Error("v2-tracked-changes-bridge-pending")):c();if(Bn.activeMutationTokens.size>0)return Promise.reject(new Error("ui-review-catalog-superseded"));const _=Bn.generation,E=Bn.inFlight;if(E?.generation===_)return E.promise;const D=Bn.abortController.signal,V=xe=>{if(D.aborted||_!==Bn.generation||xe?.reason==="review-hydration-superseded")throw new Error("ui-review-catalog-superseded");return xe},ne=y.call(h,{blocking:!1,signal:D});if(!kr(ne))return V(ne);const le=Promise.resolve(ne).then(V);return Bn.inFlight={generation:_,promise:le},le.then(()=>{Bn.inFlight?.promise===le&&(Bn.inFlight=null)},()=>{Bn.inFlight?.promise===le&&(Bn.inFlight=null)}),le};let Te=null,Ne=new Set,Qe=null,bt=0,Nt=null;const Dt=new WeakSet,kn=new WeakMap,Ht=c=>{if(kn.has(c))return;const h=typeof c.getLocalMutationRevision=="function"?Lt(()=>c.getLocalMutationRevision(),null):null,y=typeof h=="number"?h:0;kn.set(c,y),y>0?Dt.add(c):h===0&&Dt.delete(c)},In=()=>{const c=T();return c?(Ht(c),Dt.has(c)):!1},sn=()=>`${Tn(b())}|m${tr}`,Ao=()=>{Te=null,Ne=new Set},qi=c=>{for(const h of["trackChanges","trackChanges:all"]){const y=Se.get(h);if(!y?.hasSettled||!Array.isArray(y.value))continue;const _=y.value.filter(E=>{const D=Ur(E);return!D||!c.has(D)});_.length!==y.value.length&&Se.set(h,{...y,value:_})}},dn=c=>{const h=()=>{if(!N)for(const D of[...ke])D(P)},y=ih(c)?c:null,_=b()?.documentMutationReadiness,E=()=>{const D=globalThis.requestAnimationFrame;return typeof D!="function"?Promise.resolve():new Promise(V=>{let ne=!1;const le=()=>{ne||(ne=!0,clearTimeout(xe),V())},xe=setTimeout(le,250);D(()=>D(()=>setTimeout(le,0)))})};if(y?.success===!0&&typeof y.txId=="string"&&y.txId.length>0&&typeof _?.whenPainted=="function")try{Promise.resolve(_.whenPainted.call(_,y)).then(E,()=>{}).then(h,h);return}catch{}h()},sr=(c,h)=>{const y=P.trackChanges,_=y.items.filter(V=>{const ne=Ur(V);return!ne||!c.has(ne)});if(_.length===y.items.length)return;oe&&c.has(oe.id)&&ae(null);const E=new Set;for(const V of _){const ne=ud(V),le=V,xe=ne.author??ne.authorEmail??le.author??le.authorEmail;typeof xe=="string"&&E.add(xe)}const D=y.items.length-_.length;P={...P,trackChanges:{...y,items:_,total:Math.max(_.length,y.total-D),activeId:y.activeId&&c.has(y.activeId)?null:y.activeId,authors:[...E]}},dn(h)},ar=c=>{const h=P.trackChanges,y=h.items.length>0||h.total!==0||h.activeId!==null||h.authors.length>0;Qe=sn(),oe!==null&&ae(null),P={...P,trackChanges:{...h,items:[],total:0,activeId:null,authors:[]}},y&&dn(c)},No=(c,h)=>{if(c.size===0)return;const y=sn(),_=Te===y?Ne:new Set,E=new Set([...c].filter(D=>!_.has(D)));E.size!==0&&(Te=y,Ne=new Set([..._,...E]),qi(Ne),sr(E,h))},ln=c=>Te===c&&Ne.size>0?Ne:null,Mn=c=>{const h=sn(),y=ln(h),_=c.map(cd).filter(E=>{if(E==null)return!1;const D=Ur(E);return D!=null&&!y?.has(D)});for(const E of["trackChanges","trackChanges:all"])Se.set(E,{token:h,value:[..._],hasSettled:!0,inflightToken:null})},Jn=()=>`${sn()}|m${Xn()}|s${bt}`,Yr=c=>JSON.stringify({t:c.target??null,s:c.selectionTarget??null}),Yi=["contentControls:inRange:","query:","effInline:"],$c=120,sa=180,Za=()=>{const c=T(),h=c?.getDocumentLoadingSnapshot;if(typeof h!="function")return"unknown";const y=Lt(()=>h.call(c),null)?.sourceStage;return y==="opening"||y==="bootstrap-ready"||y==="source-loading"?"loading":y==="source-complete"||y==="source-failed"||y==="source-cancelled"?"complete":"unknown"},Bo=new Map,Io=new Map,Xi=new Map;let Zo=null;const Xr={comments:0,trackChanges:0,contentControls:0},Ie=c=>{const h=sn();Bo.get(c)!==h&&(Bo.set(c,h),qt())},Ue=()=>{const c=Se.get("comments");return c?.hasSettled?Array.isArray(c.value)&&c.value.length>0:c?.inflightToken!=null},vt=(c,h)=>Bo.get(c)===h,dt=()=>{const c=sn();let h=!1;for(const[y,_]of Io){if(_!==c){Io.delete(y);continue}if(Xi.get(y)===c)continue;const E=Se.get(y);!E?.hasSettled||E.token!==c||E.inflightToken!=null||(Se.set(y,{...E,token:null,inflightToken:null}),Xi.set(y,c),h=!0)}h&&qt()},Vn=c=>{Xr[c]+=1,Ie(c);let h=!1;return()=>{h||(h=!0,Xr[c]=Math.max(0,Xr[c]-1),Xr[c]===0&&Bo.get(c)===sn()&&Bo.delete(c),qt())}},Dn=c=>{Ie("contentControls")},eo=()=>{const c=Se.get("trackChanges");c?.hasSettled||c?.inflightToken!=null||Ie("trackChanges")},to=()=>{const c=Se.get("comments");c?.hasSettled||c?.inflightToken!=null||Ie("comments")},go=6500,Qo=250;let li=0,zo=0,Ir=!1,Jo=null;const Cs=()=>{if(N||Jo)return;const c=()=>{if(Jo=null,N)return;const h=Date.now()-li;if(Vo()||h<go){Jo=setTimeout(c,Qo);return}Ir=!1,$t()};Jo=setTimeout(c,0)};let jo=null,lr=null;const no=()=>{const c=T();if(!c||jo===c)return;lr&&(lr(),lr=null),jo=c;const h=c.subscribeDocumentLoading;if(typeof h!="function"){jo=null,Uo(go);return}try{const y=D=>{const V=D?.sourceStage;(V==="source-complete"||V==="source-failed"||V==="source-cancelled")&&(Zo=sn(),dt(),li=Math.max(li,Date.now()),Cs())},_=h.call(c,y);typeof _=="function"&&(lr=_);const E=c.getDocumentLoadingSnapshot;typeof E=="function"&&y(Lt(()=>E.call(c),null))}catch{jo=null,Uo(go)}},ci=()=>{const c=b()?.host,h=c?.getForegroundMutationState;if(typeof h!="function")return null;const y=Lt(()=>h.call(c),null);return{active:typeof y?.active=="number"?y.active:0,pending:typeof y?.pending=="number"?y.pending:0}},Vo=()=>{const c=ci();return!!(c&&(c.active>0||c.pending>0))},Uo=(c=$c)=>{N||Mt||(Mt=setTimeout(()=>{if(Mt=null,N)return;if(Vo()){Uo();return}if($e&&Date.now()-zo<go){const y=Jn();Se.get("selection")?.token!==y&&(tl(void 0,!0),Se.get("selection")?.token===y&&$t()),Uo(Qo);return}$e=!1;const h=Kt;Kt=null,h===Jn()&&Zl("selection",h,nc,Qi),$t()},c))},Qa=(c,h)=>{if(!ci())return!1;const y=`${c}\0${h}`;return Re.has(y)?!1:(Re.add(y),Uo(sa),!0)},xh=c=>{if(ze==null||c===ze)return Ke?.timer&&clearTimeout(Ke.timer),Ke=null,ze=c,!1;if(Ke?.key===c)return Ke.ready?(Ke=null,ze=c,!1):!0;Ke?.timer&&clearTimeout(Ke.timer);const h={key:c,ready:!1,timer:null};return h.timer=setTimeout(()=>{N||Ke!==h||(h.timer=null,h.ready=!0,$t())},sa),Ke=h,!0},ql=c=>q9(c),ks=()=>{Zi(),$t()};let ui=null,Ss=null,_s=!1,Yl=0,Ja=!1,di=0;const fi=()=>{ui=null,_s=!1,Yl+=1},Hc=()=>{Ss=null,Ja=!1,di+=1},Xl=()=>{const c=b(),h=c?.documentMutationReadiness;if(!c||typeof h?.whenPainted!="function"||(ui={editor:c,readiness:h,afterEpoch:typeof h.getRenderEpoch=="function"?Lt(()=>h.getRenderEpoch.call(h),null):null},_s))return;_s=!0;const y=Yl;(async()=>{for(;!N&&y===Yl;){const E=ui;if(ui=null,!E){_s=!1;return}let D=!1;try{await E.readiness.whenPainted.call(E.readiness,typeof E.afterEpoch=="number"?{afterEpoch:E.afterEpoch}:void 0),D=!0}catch{}if(N||y!==Yl)return;if(b()!==E.editor){fi();return}D&&ks()}})()},Th=()=>{const c=b(),h=c?.documentMutationReadiness;if(!c||typeof h?.whenPainted!="function")return!1;if(Ss={editor:c,readiness:h,afterEpoch:typeof h.getRenderEpoch=="function"?Lt(()=>h.getRenderEpoch.call(h),null):null},Ja)return!0;Ja=!0;const y=di;return(async()=>{for(;!N&&y===di;){const E=Ss;if(Ss=null,!E){Ja=!1;return}let D=!1;try{await E.readiness.whenPainted.call(E.readiness,typeof E.afterEpoch=="number"?{afterEpoch:E.afterEpoch}:void 0),D=!0}catch{}if(N||y!==di)return;if(b()!==E.editor){Hc();return}Ss||(bt+=1,tl(void 0,!0),$t(D?"post-paint-selection":"post-paint-selection-failed"))}})(),!0},As=()=>{Qt&&clearTimeout(Qt),Qt=setTimeout(()=>{Qt=null,N||(Zi(),$e&&!Vo()&&tl(void 0,!0),$t())},500)},Zl=(c,h,y,_)=>{let E;try{E=y()}catch{E=void 0}if(!kr(E)){const ne={token:h,value:_(E),hasSettled:!0,inflightToken:null,failedToken:null,failureCount:0,retryAtMs:0};return Se.set(c,ne),ne}const D=Se.get(c),V=D?.failedToken===h;return Se.set(c,{token:D?.token??null,value:D?.value??null,hasSettled:D?.hasSettled??!1,inflightToken:h,failedToken:V?h:null,failureCount:V?D.failureCount??0:0,retryAtMs:0}),Promise.resolve(E).then(ne=>{const le=Se.get(c);if(!le||le.inflightToken!==h)return;Se.set(c,{token:h,value:_(ne),hasSettled:!0,inflightToken:null,failedToken:null,failureCount:0,retryAtMs:0});const{sink:xe,workerContext:je}=Nm();if(xe){const De=Ha();Hn.push({key:c,settledAtMs:De,commandId:je?.commandId??null,commandKind:je?.commandKind??null}),O0({stage:"superdoc-ui-async-read-settled",atMs:De,key:c,settledAtMs:De,commandId:je?.commandId??null,commandKind:je?.commandKind??null})}qt()},()=>{const ne=Se.get(c);if(!ne||ne.inflightToken!==h)return;const le=ne.failedToken===h?(ne.failureCount??0)+1:1,xe=Math.min(Pn,jn*2**Math.min(le-1,8)),je=Date.now()+xe;Se.set(c,{...ne,inflightToken:null,failedToken:h,failureCount:le,retryAtMs:je}),$r(je)}),null},Eo=(c,h,y,_)=>{const E=Se.get(c);if(E&&E.token===h&&E.hasSettled)return{value:E.value,status:"ready"};if(c==="selection"&&$e&&Date.now()-zo<go)return Uo(Qo),{value:E?.hasSettled?E.value:null,status:E?.hasSettled?"stale":"pending"};if(OO(c)&&!vt(c,h)){if(Za()==="loading")return Ir=!0,no(),E?.hasSettled?{value:E.value,status:"stale"}:{value:null,status:"pending"};if(Ir)return Cs(),E?.hasSettled?{value:E.value,status:"stale"}:{value:null,status:"pending"};if(Date.now()-zo<go)return Ir=!0,Cs(),E?.hasSettled?{value:E.value,status:"stale"}:{value:null,status:"pending"}}if(Vo())return Uo(),E?.hasSettled?{value:E.value,status:"stale"}:{value:null,status:"pending"};if(E?.failedToken===h&&E.inflightToken==null&&(E.retryAtMs??0)>Date.now())return $r(E.retryAtMs),E.hasSettled?{value:E.value,status:"stale"}:{value:null,status:"pending"};if(!E&&c.startsWith("effInline:")&&xh(c))return{value:null,status:"pending"};if(!E&&Qa(c,h))return{value:null,status:"pending"};if(!E||E.inflightToken!==h){const V=Zl(c,h,y,_);if(V)return{value:V.value,status:"ready"}}const D=Se.get(c);return D?.hasSettled?{value:D.value,status:"stale"}:{value:null,status:"pending"}},bd=c=>{for(const h of Se.keys())c(h)&&Se.delete(h)},Ql=c=>{const h=Yr(c),y=Z_(c);return new Set([`contentControls:inRange:${h}`,`query:${h}`,...y?[`effInline:${y}`]:[]])},Gc=c=>{const h=Ql(c);bd(y=>Yi.some(_=>y.startsWith(_))&&!h.has(y));for(const y of Re){const _=y.split("\0",1)[0];Yi.some(E=>_.startsWith(E))&&!h.has(_)&&Re.delete(y)}},Is=()=>{const c=b();c!==Nt&&(fi(),Hc(),Nt=c,Se.clear(),mt&&clearTimeout(mt),mt=null,Ot=0,Ke?.timer&&clearTimeout(Ke.timer),Ke=null,ze=null,S=null,o=null,Kt=null,$e=!1,Re.clear(),Bo.clear(),Io.clear(),Xi.clear(),Zo=null,Ir=!1,lr&&lr(),lr=null,jo=null,Ao(),Qe=null)},Zi=()=>{tr+=1,Io.clear(),Xi.clear(),Zo=null,Ao()},hi=()=>{const c=Qe===sn();Zi(),c&&(Mn([]),Qe=sn()),$t()},Wc=c=>{if(typeof c!="string"||c.length===0)return er("insertText requires a non-empty string.","INVALID_INPUT");if(Xn()==="viewing")return er("The document is read-only.","DOCUMENT_READONLY");const h=M(),y=h?.insert;if(!h||typeof y!="function")return er("insert is unavailable.");const _=h.selection?.current;if(typeof _!="function")return er("selection.current is unavailable.");const E=V=>{const ne=V&&typeof V=="object"?V:null,le=ne?.selectionTarget??ne?.target??null;return!le||typeof le!="object"?er("insertText requires a live selection target.","PRECONDITION_FAILED"):Lt(()=>dc(y.call(h,{type:"text",value:c,target:le}),er("insert failed.")),er("insert failed."))};let D;try{D=_.call(h.selection)}catch{return er("insertText could not resolve the live selection.","PRECONDITION_FAILED")}return kr(D)?Promise.resolve(D).then(E,()=>er("insertText could not resolve the live selection.","PRECONDITION_FAILED")):E(D)},Kc=(c,h)=>({payload:c,state:P,editor:b(),superdoc:t,context:h,ui:me,execute:(y,_)=>Gh(y,_),executeAsync:(y,_)=>zg(y,_),doc:M(),selection:P.selection,documentMode:Xn(),insertText:Wc}),Jl=c=>c==="editing"||c==="suggesting"||c==="viewing"?c:null,Xn=()=>{const c=b(),h=t&&typeof t=="object"?t:null,y=Jl(h?.config?.documentMode),_=Lt(typeof h?.getActiveRuntime=="function"?()=>{const V=h.getActiveRuntime();return typeof V?.getSnapshot=="function"?V.getSnapshot():null}:void 0,null),E=Jl(_?.documentMode),D=Jl(c?.options?.documentMode);return y&&E&&y!==E?y:E??y??D},ec=()=>{const c=t&&typeof t=="object"?t:null,h=c?.interactionConfig?.comments;if(h&&typeof h.readOnly=="boolean")return h.readOnly===!0;const y=c?.config?.modules?.comments;return!!y&&typeof y=="object"&&y.readOnly===!0},wd=()=>{if(Xn()==="viewing")return tt.documentReadonly;const c=(t&&typeof t=="object"?t:null)?.interactionConfig?.trackedChanges;return c&&typeof c.allowDecisions=="boolean"?c.allowDecisions?void 0:tt.trackedChangeDecisionsDisabled:ec()?tt.documentReadonly:void 0},qc=()=>{const c=t&&typeof t=="object"?t:null,h=c?.interactionConfig?.comments;if(h&&typeof h.allowResolve=="boolean")return h.allowResolve===!1;const y=c?.config?.modules?.comments;return!!y&&typeof y=="object"&&y.allowResolve===!1},tc=()=>ec(),aa=()=>wd()!=null,Qi=c=>c&&typeof c=="object"?c:null,la=(c,h)=>{if(!c)return{...LO,status:h};const y=c.target??null,_=typeof c.text=="string"?c.text:"";return{status:h,empty:c.empty===!0,target:y,selectionTarget:c.selectionTarget??null,tableSelection:c.tableSelection??null,activeMarks:Array.isArray(c.activeMarks)?c.activeMarks:[],activeCommentIds:Array.isArray(c.activeCommentIds)?c.activeCommentIds:[],activeChangeIds:Array.isArray(c.activeChangeIds)?c.activeChangeIds:[],quotedText:_}},el=()=>{const c=M()?.selection;return Eo("selection",Jn(),()=>c?.current?c.current({includeText:!0}):void 0,Qi)},Er=()=>{const{value:c,status:h}=el();return la(c,h)},nc=()=>{const c=M()?.selection;return c?.current?c.current({includeText:!0}):void 0},ca=c=>{if(c.empty!==!0)return!1;const h=c.selectionTarget,y=h?.start,_=h?.end;return y?.kind==="text"&&_?.kind==="text"&&typeof y.blockId=="string"&&y.blockId===_.blockId&&typeof y.offset=="number"&&y.offset===_.offset},tl=(c,h=!1)=>{const y=ci();if(zO(c)&&!(y&&y.active>0)){$e=!1,Kt=null,Zl("selection",Jn(),nc,Qi);return}const _=T(),E=_?.readLiveSelectionSyncSnapshot;if(typeof E!="function")return;const D=Qi(Lt(()=>E.call(_),null));if(!D||!ca(D))return;const V=$i(P.selection),ne=rh(D.selectionTarget)??rh(D.target),le=V?.range,xe=ne?.range,je=!!(V&&ne&&V.blockId===ne.blockId&&Qn(V.story)===Qn(ne.story)&&le?.start===xe?.start);$e=!!(y&&y.active>0)||$e&&(h||je);const De=Jn(),Ye=!!(y&&(y.active>0||y.pending>0))||$e&&Date.now()-zo<go;if(Ye)Kt=De,Uo();else if(Kt=null,Zl("selection",De,nc,Qi))return;const Ze=Se.get("selection"),Xe=Array.isArray(D.activeMarks)&&D.activeMarks.length>0?D.activeMarks:Array.isArray(P.selection.activeMarks)?P.selection.activeMarks:[],Ge=Array.isArray(D.activeCommentIds)?D.activeCommentIds:[],rt=BO(c),lt=!!(y&&y.active>0&&V&&ne&&V.blockId===ne.blockId&&Qn(V.story)===Qn(ne.story)&&typeof le?.start=="number"&&typeof xe?.start=="number"&&Math.abs(xe.start-le.start)<=2),We=rt!=null||lt?P.selection.activeChangeIds.filter(Rt=>rt==null||ta(P.trackChanges.items).aliasesFor(Rt).includes(rt)):[],wt=Array.isArray(D.activeChangeIds)&&D.activeChangeIds.length>0?D.activeChangeIds:We;Se.set("selection",{token:De,value:{...D,activeMarks:Xe,activeCommentIds:Ge,activeChangeIds:wt},hasSettled:!0,inflightToken:Ye?null:Ze?.inflightToken??null})},Yc=async(c=0)=>{const h=M()?.selection,y=h?.current,_=Jn();if(typeof y!="function")return Se.set("selection",{token:_,value:null,hasSettled:!0,inflightToken:null}),$t(),P.selection;let E;try{E=y.call(h,{includeText:!0}),kr(E)&&(E=await Promise.resolve(E))}catch{E=null}return N?la(null,"pending"):Jn()!==_?c<1?Yc(c+1):P.selection:(Se.set("selection",{token:_,value:Qi(E),hasSettled:!0,inflightToken:null}),$t(),P.selection)},Xc=()=>{const c=M()?.comments;return Eo("comments",sn(),()=>c?.list?c.list():void 0,h=>h&&Array.isArray(h.items)?h.items:[])},ua=(c="trackChanges")=>{const h=sn(),y=M()?.trackChanges,_=z(),E=typeof _?.listTrackedChanges=="function"?_.listTrackedChanges:null,D=Eo(c,h,()=>E?gn(()=>y?.list?.({in:"all"})):y?.list?y.list({in:"all"}):void 0,V=>{const ne=V&&typeof V=="object"?V:null;if(ne?.complete===!1||ne?.sourceCoverageComplete===!1){if(Io.set(c,h),no(),Zo===h||Za()==="complete"){const le=()=>{N||dt()};typeof queueMicrotask=="function"?queueMicrotask(le):Promise.resolve().then(le)}}else Io.get(c)===h&&Io.delete(c);return ne&&Array.isArray(ne.items)?ne.items:[]});return Io.get(c)===h&&D.status==="ready"?{...D,status:"stale"}:D},Rh=c=>{const h=F(),y=L(),_=y?null:Xc(),E=y&&Array.isArray(h?.commentItems)?h.commentItems:null,D=y?E:_.value,V=y?$(h):_.status,ne=D??[],le=c.activeCommentIds,xe=Se.get("comments"),je=xe?.token===sn()&&xe.hasSettled&&Array.isArray(xe.value)?xe.value:null,De=Xr.comments>0?je:ne;Le&&De&&!De.some(Ze=>Ur(Ze)===Le)&&(Le=null);const Ye=Le??le[0]??null;return{status:Ol(V,c.status),listStatus:V,items:ne,total:ne.length,activeIds:le,activeId:Ye}},Zc=new WeakMap,Ji=c=>{const h=Zc.get(c);if(h)return h;const y=c.map(cd).filter(_=>_!=null);return Zc.set(c,y),y},Qc=new WeakMap,pi=(c,h)=>{const y=Qc.get(c);if(y?.suppressedIds===h)return y.value;const _=h?c.filter(E=>{const D=Ur(E);return!D||!h.has(D)}):c;return Qc.set(c,{suppressedIds:h,value:_}),_},rc=new WeakMap,Jc=c=>{const h=rc.get(c);if(h)return h;const y=new Set;for(const E of c){const D=ud(E),V=E,ne=D.author??D.authorEmail??V.author??V.authorEmail;typeof ne=="string"&&y.add(ne)}const _=[...y];return rc.set(c,_),_},mi=()=>{const c=sn();if(L()){const _=Se.get("trackChanges"),E=_?.token===c&&_.hasSettled&&Array.isArray(_.value)?_.value:F()?.trackedChangeItems;return Array.isArray(E)?Ji(E):null}const{value:h,status:y}=ua("trackChanges:all");return y==="ready"?Ji(h??[]):null},Mh=c=>{const h=sn(),y=ln(h),_=F(),E=L(),D=E?null:ua(),V=E&&Array.isArray(_?.trackedChangeItems)?_.trackedChangeItems:null,ne=E?V:D.value,le=E?$(_):D.status,xe=pi(Ji(ne??[]),y),je=mi(),De=oe;if(De&&!re.has(De)){const Rt=Se.get("trackChanges"),an=Rt?.token===h&&Rt.hasSettled&&Array.isArray(Rt.value)?pi(Ji(Rt.value),y):null,un=Xr.trackChanges>0?an:De.story?je:xe;un&&!un.some(En=>Ti(En,De.id,De.story))&&ae(null)}const Ye=je??xe,Ze=Fl(Ye,hs(c)),Xe=Qe===h?[]:y?c.activeChangeIds.filter(Rt=>!y.has(Rt)):c.activeChangeIds,Ge=Xe.map(Rt=>Ze.toPublicId(Rt)??Rt),rt=oe?.story?Fl(Ye,oe.story):ta(Ye),lt=oe?rt.toPublicId(oe.id)??oe.id:null,We=UO({selectionIds:Xe,publicIds:Ge,selection:c,bodyItems:xe,allStoryItems:je}),wt=lt??We;return{status:Ol(le,c.status),items:xe,total:xe.length,activeId:wt,authors:Jc(xe)}},Cd=(c,h)=>{if(!L())return h;Ie("comments");const y=Xc(),_=y.value??h.items;return{status:Ol(y.status,c.status),listStatus:y.status,items:_,total:_.length,activeIds:c.activeCommentIds,activeId:Le??c.activeCommentIds[0]??null}},eu=(c,h)=>{if(!L())return h;Ie("trackChanges");const y=ua(),_=ln(sn()),E=pi(Ji(y.value??h.items),_),D=oe?.story?Fl(E,oe.story):ta(E),V=oe?D.toPublicId(oe.id)??oe.id:h.activeId;return{status:Ol(y.status,c.status),items:E,total:E.length,activeId:V,authors:Jc(E)}};let kd=null,Sd=[];const oc=(c,h)=>{const y=sn();return h==="ready"?(kd=y,Sd=c,{items:c,status:h}):h==="pending"&&kd===y?{items:Sd,status:"stale"}:{items:c,status:h}},Lh=c=>{const h=M()?.contentControls,{value:y,status:_}=Eo("contentControls",sn(),()=>h?.list?h.list():void 0,De=>De&&Array.isArray(De.items)?De.items:[]),E=y??[],{items:D,status:V}=_d(h,c),ne=new Map(D.map(De=>[De.id,De])),le=new Set(E.map(De=>De.id)),xe=[...E.map(De=>ne.get(De.id)??De),...D.filter(De=>!le.has(De.id))],je=D.map(De=>De.id);return{status:Ol(_,V,c.status),items:xe,total:xe.length,activeId:je[0]??null,activeIds:je}},da=(c,h)=>{if(!c||typeof c.listInRange!="function")return{lockModesById:new Map,rows:[],status:"ready"};const y=HO(h);if(!y)return{lockModesById:new Map,rows:[],status:"ready"};const{value:_,status:E}=Eo(`contentControls:inRange:${Yr(h)}`,sn(),()=>c.listInRange(y),ne=>ne&&Array.isArray(ne.items)?ne.items:[]),D=_??[],V=new Map;for(const ne of D)typeof ne?.id=="string"&&V.set(ne.id,typeof ne.lockMode=="string"?ne.lockMode:"unlocked");return{lockModesById:V,rows:D,status:E}},_d=(c,h)=>{const{rows:y,status:_}=da(c,h),E=h.selectionTarget,D=h.target;let V=E?.start;if(E){if(E.kind!=="selection"||V?.kind!=="text"||typeof V.blockId!="string"||typeof V.offset!="number")return oc([],_)}else{const Ge=D?.kind==="text"&&Array.isArray(D.segments)?D.segments[0]:void 0,rt=Ge?.range;if(typeof Ge?.blockId!="string"||typeof rt?.start!="number")return oc([],_);V={kind:"text",blockId:Ge.blockId,offset:rt.start,story:D?.story}}const ne=(D?.coordinateSpace!=="tracked"&&Array.isArray(D?.segments)?D.segments:[]).find(Ge=>Ge.blockId===V.blockId),le=ne?.range,xe=ne&&typeof ne.blockId=="string"&&typeof le?.start=="number"?{kind:"text",blockId:ne.blockId,offset:le.start,story:D?.story??V.story}:null,je=(E?E.coordinateSpace:D?.coordinateSpace)==="tracked"?"tracked":"visible",De=je==="tracked"?xe:V,Ye=Kr(h),Ze=Ye.indexOf((De??V).blockId),Xe=y.map((Ge,rt)=>({item:Ge,index:rt})).filter(({item:Ge})=>{const rt=Ge.selectionTarget,lt=rt?.coordinateSpace==="tracked"?"tracked":"visible";if(lt==="tracked"&&je!=="tracked")return!1;const We=lt==="tracked"?V:De;if(!We)return!1;const wt=rt?.start,Rt=rt?.end;if(rt?.kind!=="selection"||wt?.kind!=="text"||Rt?.kind!=="text"||typeof wt.blockId!="string"||typeof Rt.blockId!="string"||typeof wt.offset!="number"||typeof Rt.offset!="number"||Qn(rt.story??wt.story??Rt.story)!==Qn(E?.story??We.story))return!1;if(wt.blockId===Rt.blockId){if(We.blockId!==wt.blockId)return!1;const En=Math.min(wt.offset,Rt.offset),io=Math.max(wt.offset,Rt.offset);return En===io?We.offset===En:We.offset>=En&&We.offset<io}if(We.blockId===wt.blockId)return We.offset>=wt.offset;if(We.blockId===Rt.blockId)return We.offset<Rt.offset;if(Ze===-1)return!1;const an=Ye.indexOf(wt.blockId),un=Ye.indexOf(Rt.blockId);return an!==-1&&un!==-1?Ze>Math.min(an,un)&&Ze<Math.max(an,un):an!==-1?Ze>an:un!==-1?Ze<un:!0}).sort((Ge,rt)=>{const lt=Ge.item.selectionTarget,We=rt.item.selectionTarget,wt=lt.start.kind==="text"&<.end.kind==="text"&<.start.blockId===lt.end.blockId,Rt=We.start.kind==="text"&&We.end.kind==="text"&&We.start.blockId===We.end.blockId;if(wt!==Rt)return wt?-1:1;if(Ge.item.kind!==rt.item.kind)return Ge.item.kind==="inline"?-1:1;if(wt&&Rt&<.start.kind==="text"&<.end.kind==="text"&&We.start.kind==="text"&&We.end.kind==="text"){const an=Math.abs(lt.end.offset-lt.start.offset),un=Math.abs(We.end.offset-We.start.offset);if(an!==un)return an-un}return rt.index-Ge.index}).map(({item:Ge})=>Ge);return oc(Xe,_)},Ad=()=>{const c=t?.fonts;return{options:yF(gF(Lt(c?.getDocumentFontOptions?()=>c.getDocumentFontOptions():void 0,[])),vF(Lt(c?.getFontFamilyOptions?()=>c.getFontFamilyOptions():void 0,[]))),sizeOptions:bF}},Id=()=>{const c=Lt(t?.getZoomState?()=>t.getZoomState():void 0,null),h=typeof c?.value=="number"?c.value:100,y=c?.mode;return{mode:y==="manual"||y==="fit-width"?y:y==="fixed"?"manual":null,value:h,min:typeof c?.min=="number"?c.min:10,max:typeof c?.max=="number"?c.max:100}},Ph=()=>Lt(t?.getMeasurementUnit?()=>t.getMeasurementUnit():void 0,"in")==="cm"?"cm":"in",ei=()=>{const c=b(),h=c?c.isDirty:void 0;return{ready:c!=null,mode:Xn(),dirty:c?h===void 0?In():!!h:!1}},nl=c=>{const h=c.quotedText;if(typeof h!="string"||h.length===0)return null;const y=ld(c);if(y.length===0||!Pc(y.map(D=>D.blockId)))return null;const _=c.target,E=y.length===1?_o(y[0].blockId,_?.story):void 0;return{select:{type:"text",pattern:h,mode:"contains",caseSensitive:!0},...E?{within:E}:{},require:"any"}},tu=c=>{const h=M()?.query;if(typeof h?.match!="function")return null;const y=nl(c);if(!y)return null;const{value:_}=Eo(`query:${Yr(c)}`,sn(),()=>h.match(y),E=>E&&typeof E=="object"?E:null);return Q_(_,c)},Ed=c=>{const h=T(),y=new Set(Kr(c));if(y.size===0)return{};const _=h?.readMountedProjectionBlocksByIds,E=h?.readMountedProjectionBlocks;if(typeof _!="function"&&typeof E!="function")return{};const D=Lt(()=>{if(typeof _!="function")return E.call(h);const Ge=ps(c);return Ge?_.call(h,[...y],Ge):_.call(h,[...y])},null);if(!Array.isArray(D))return{};const V=$0(D),ne=Ge=>{const rt={},lt=V0(Ge.fontFamily);lt&&(rt.fontFamily=lt);const We=tF(Ge.fontSize);return We&&(rt.fontSize=We),typeof Ge.color=="string"&&Ge.color.trim()!==""&&(rt.color=Ge.color.trim().toUpperCase()),typeof Ge.highlight=="string"&&Ge.highlight.trim()!==""&&(rt.highlight=Ge.highlight.trim().toUpperCase()),rt},le=$i(c),xe=le&&typeof le.range?.start=="number"?le.range.start:null;if(le&&xe!==null&&y.has(le.blockId)){const Ge=V.find(lt=>Dc(lt,le.blockId)),rt=Ge&&Array.isArray(Ge.runs)?Ge.runs:null;if(rt&&rt.length>0&&rt.every(lt=>lt?.kind==="text"||lt?.kind==="tab")){let lt=0,We=null;for(const wt of rt){const Rt=Vm(wt);if(xe>=lt&&xe<lt+Rt){We=wt;break}lt+=Rt}if(!We){for(let wt=rt.length-1;wt>=0&&!We;wt-=1)rt[wt]?.kind==="text"&&(We=rt[wt]);We??=rt[rt.length-1]??null}return We?ne(We):{}}}const je=ld(c);if(je.length>0){const Ge=new Set,rt=new Set;let lt=!1,We=!0;for(const wt of je){const Rt=V.find(En=>Dc(En,wt.blockId));if(!Rt)return{};const an=Array.isArray(Rt.runs)?Rt.runs:[];if(an.length===0)continue;if(!an.every(En=>En?.kind==="text"||En?.kind==="tab")){We=!1;break}let un=0;for(const En of an){const io=Vm(En),Bi=un,as=un+io;if(Bi<wt.end&&as>wt.start){lt=!0;const wo=ne(En);wo.fontFamily&&Ge.add(wo.fontFamily),wo.fontSize&&rt.add(wo.fontSize)}un=as}}if(We&<){const wt={};return Ge.size===1&&(wt.fontFamily=[...Ge][0]),rt.size===1&&(wt.fontSize=[...rt][0]),wt}}const De=new Set,Ye=new Set;let Ze=!1;for(const Ge of V){if(![...y].some(lt=>Dc(Ge,lt)))continue;const rt=Array.isArray(Ge.runs)?Ge.runs:[];for(const lt of rt){if(lt?.kind!=="text")continue;Ze=!0;const We=ne(lt);We.fontFamily&&De.add(We.fontFamily),We.fontSize&&Ye.add(We.fontSize)}}if(!Ze)return{};const Xe={};return De.size===1&&(Xe.fontFamily=[...De][0]),Ye.size===1&&(Xe.fontSize=[...Ye][0]),Xe},xd=c=>{const h=T(),y=new Set(Kr(c));if(y.size===0)return{};const _=h?.readMountedProjectionBlocksByIds,E=h?.readMountedProjectionBlocks;if(typeof _!="function"&&typeof E!="function")return{};const D=Lt(()=>{if(typeof _!="function")return E.call(h);const Xe=ps(c);return Xe?_.call(h,[...y],Xe):_.call(h,[...y])},null);if(!Array.isArray(D))return{};const V=$0(D),ne=Xe=>({bold:Xe.bold===!0,italic:Xe.italic===!0,underline:Xe.underline!=null,strikethrough:Xe.strike===!0}),le=Xe=>{const Ge={};for(const rt of oh){const lt=Xe[rt];lt.size===1&&(Ge[rt]=[...lt][0])}return Ge},xe=$i(c),je=xe&&typeof xe.range?.start=="number"?xe.range.start:null;if(xe&&je!==null&&y.has(xe.blockId)){const Xe=V.find(rt=>Dc(rt,xe.blockId)),Ge=Xe&&Array.isArray(Xe.runs)?Xe.runs:null;if(Ge&&Ge.length>0&&Ge.every(rt=>rt?.kind==="text"||rt?.kind==="tab")){let rt=0,lt=null;for(const We of Ge){const wt=Vm(We);if(je>=rt&&je<rt+wt){lt=We;break}rt+=wt}if(!lt){for(let We=Ge.length-1;We>=0&&!lt;We-=1)Ge[We]?.kind==="text"&&(lt=Ge[We]);lt??=Ge[Ge.length-1]??null}return lt?ne(lt):{}}}const De=ld(c);if(De.length>0){const Xe={bold:new Set,italic:new Set,underline:new Set,strikethrough:new Set};let Ge=!1,rt=!0;for(const lt of De){const We=V.find(an=>Dc(an,lt.blockId));if(!We)return{};const wt=Array.isArray(We.runs)?We.runs:[];if(wt.length===0)continue;if(!wt.every(an=>an?.kind==="text"||an?.kind==="tab")){rt=!1;break}let Rt=0;for(const an of wt){const un=Vm(an),En=Rt,io=Rt+un;if(En<lt.end&&io>lt.start){Ge=!0;const Bi=ne(an);for(const as of oh)Xe[as].add(Bi[as])}Rt=io}}if(rt&&Ge)return le(Xe)}const Ye={bold:new Set,italic:new Set,underline:new Set,strikethrough:new Set};let Ze=!1;for(const Xe of V){if(![...y].some(rt=>Dc(Xe,rt)))continue;const Ge=Array.isArray(Xe.runs)?Xe.runs:[];for(const rt of Ge){if(rt?.kind!=="text")continue;Ze=!0;const lt=ne(rt);for(const We of oh)Ye[We].add(lt[We])}}return Ze?le(Ye):{}},rl=(c,h)=>{if(h.fontFamily!==void 0&&h.fontSize!==void 0&&h.color!==void 0&&h.highlight!==void 0)return{values:h,effectiveUniformityStatus:"ready"};const y=Ed(c),_={...y.fontFamily!==void 0?{fontFamily:y.fontFamily}:{},...y.fontSize!==void 0?{fontSize:y.fontSize}:{},...y.color!==void 0?{color:y.color}:{},...y.highlight!==void 0?{highlight:y.highlight}:{},...h};if(!c.empty&&(_.fontFamily===void 0||_.fontSize===void 0)){const E=Oh(c);return E.values&&(_.fontFamily===void 0&&E.values.fontFamily!==void 0&&(_.fontFamily=E.values.fontFamily),_.fontSize===void 0&&E.values.fontSize!==void 0&&(_.fontSize=E.values.fontSize)),{values:_,effectiveUniformityStatus:E.status}}return{values:_,effectiveUniformityStatus:"ready"}},Dh=["fontFamily","fontSize","bold","italic","underline","strikethrough"],Td=c=>{const h=c.selectionTarget;if(!h)return{value:null,status:"ready"};const y=Sr(M(),"format.readEffectiveInlineUniformity");if(!y)return{value:null,status:"ready"};const _=Z_(c)??Yr(c);return Eo(`effInline:${_}`,sn(),()=>y({target:h,offsetSpace:"selection",keys:Dh}),E=>E&&typeof E=="object"?E:null)},Oh=c=>{const{value:h,status:y}=Td(c);if(!h||h.success!==!0)return{values:null,status:y};const _=h.values,E=D=>{const V=_?.[D];if(!(!V||V.state!=="uniform"||typeof V.value!="string"))return D==="fontFamily"?V0(V.value):V.value};return{values:{fontFamily:E("fontFamily"),fontSize:E("fontSize")},status:y}},Rd=c=>{const{value:h,status:y}=Td(c);if(!h||h.success!==!0)return{values:null,status:y};const _=h.values,E={};for(const D of oh){const V=_?.[D];V?.state==="uniform"&&(V.value==="true"||V.value==="false")&&(E[D]=V.value==="true")}return{values:E,status:y}},Md=(c,h)=>{const y=c.activeMark;if(!y||!oh.includes(y))return null;const _=y,E=xd(h)[_];if(E!==void 0)return E;const{values:D}=Rd(h),V=D?.[_];return V!==void 0?V:null},Ld=async c=>{const h=c.selectionTarget;if(!h)return null;const y=Sr(M(),"format.readEffectiveInlineUniformity");if(!y)return null;try{const _=await Promise.resolve(y({target:h,offsetSpace:"selection"}));return _&&typeof _=="object"&&_.success===!0?_:null}catch{return null}},Es=(c,h,y)=>{const _=y.values;for(const E of["fontFamily","fontSize"]){if(h[E]!==void 0)continue;const D=_?.[E];D?.state==="uniform"&&typeof D.value=="string"?c[E]=E==="fontFamily"?V0(D.value):D.value:delete c[E]}},fa=c=>rl(c,J_(tu(c),c)),ol=c=>fa(c).values,Fh=async c=>{const h=M()?.query,y=nl(c);if(typeof h?.match!="function"||!y)return ol(c);try{const _=await Promise.resolve(h.match(y)),E=J_(Q_(_&&typeof _=="object"?_:null,c),c),D=rl(c,E);if(D.effectiveUniformityStatus!=="ready"&&(E.fontFamily===void 0||E.fontSize===void 0)){const V=await Ld(c);V&&Es(D.values,E,V)}return D.values}catch{return ol(c)}},ic=async c=>{const h=M();if(h)return typeof h.getNode=="function"?await Promise.resolve(h.getNode(c)):await Promise.resolve(h.getNodeById?.({nodeId:c.nodeId,nodeType:c.nodeType}))},Pd=c=>{const h=M()?.query;if(typeof h?.match!="function")return"ready";const y=nl(c);if(!y)return"ready";const{status:_}=Eo(`query:${Yr(c)}`,sn(),()=>h.match(y),E=>E&&typeof E=="object"?E:null);return _},Dd=c=>{const h=fa(c),y=h.values;if(c.empty)return h;const _=Wa(c);return _?c.status==="ready"&&Pd(c)==="ready"&&h.effectiveUniformityStatus==="ready"?(S={key:_,values:y},h):S&&S.key===_?{...h,values:{...S.values,...y}}:h:h},il=c=>{const h=M(),y=Dd(c),_=y.values;c.status==="ready"&&!c.empty&&Pd(c)==="ready"&&y.effectiveUniformityStatus==="ready"&&(C=_,w=`${Mc(c)}:${sn()}`);const E=h?.contentControls,{lockModesById:D}=da(E,c),V={};for(const ne of al())V[ne]=A(ne,h,c,_,D);return V},es=c=>c?tt.operationUnavailable:b()?tt.documentApiUnavailable:tt.notReady,xs=c=>c==="contentLocked"||c==="sdtContentLocked",xr=c=>{for(const h of c.values())if(xs(h))return tt.contentControlLocked},Od=(c,h,y,_,E)=>{if(!h)return c.scope==="all"?tt.bulkDecisionsDisabled:es(E);if(y)return y;if(c.scope!=="all"&&_.activeChangeIds.length===0)return tt.selectionRequired},ha=c=>{Is();let h;if(L()){const E=mi()?.find(V=>Ur(V)===c);if(E)return ud(E);const D=Se.get("trackChanges");h=D?.hasSettled&&Array.isArray(D.value)?D.value:null}else h=ua("trackChanges:all").value;const y=h?.find(E=>Ur(E)===c),_=cd(y);return _?ud(_):null},nu=(c,h)=>{const y=t.canPerformPermission;if(typeof y!="function"||h.length===0)return;const _=t.config&&typeof t.config=="object"?t.config.user:null;for(const E of h){const D=ha(E)??{id:E},V=NO(D,_),ne=c==="accept"?V?"RESOLVE_OWN":"RESOLVE_OTHER":V?"REJECT_OWN":"REJECT_OTHER";let le;try{le=y.call(t,{permission:ne,trackedChange:D,comment:null})}catch{return}if(le===!1)return tt.permissionDenied}},sc=c=>{const h=T(),y=Lt(typeof h?.getCapabilities=="function"?()=>h.getCapabilities():void 0,null)?.editableSubset?.commands;if(Array.isArray(y))return y.find(_=>_?.command===c||_?.id===c)??null;if(y&&typeof y=="object"){const _=y[c];return _&&typeof _=="object"?_:null}return null},sl=(c,h)=>{if(c.scope!=="all"||typeof h?.[`${c.kind}All`]=="function")return;const y=sc(`trackedChanges.${c.kind}All`);if(!(y&&(y.status==="supported"||y.enabled===!0)))return tt.bulkDecisionsDisabled},ac=c=>c.empty&&$i(c)!=null&&typeof T()?.setPendingInlineFormat=="function",A=(c,h,y,_,E=new Map)=>{if(It.has(c))return rn({supported:!0,enabled:!0,...Lt(It.get(c).getState?()=>It.get(c).getState(Kc(void 0)):void 0,{})},"custom");const D=Xn()==="viewing",V=N_(c);if(V&&typeof ye()?.lists?.apply=="function"){const Ze=Pe(),Xe=typeof Ze?.shippedStatus=="string"?Ze.shippedStatus:null,Ge=Xe!=="not-shipped"&&Xe!=="disabled",rt=Ge&&(typeof Ze?.enabled=="boolean"?Ze.enabled:!0),lt=Ge?Ve(Ze):null;return rn(D?{enabled:!1,active:lt===V,supported:Ge,value:Ze?.value,reason:tt.documentReadonly}:{enabled:rt,active:lt===V,supported:Ge,value:Ze?.value},"builtin")}const ne=Um(c);if(ne){const Ze=h?.trackChanges,Xe=typeof Ze?.decide=="function"||typeof Ze?.[ne.kind]=="function",Ge=typeof Ze?.decide=="function"||typeof Ze?.[`${ne.kind}All`]=="function",rt=ne.scope==="all"?Ge:Xe,lt=sl(ne,Ze)??Od(ne,rt,wd(),y,h)??(ne.scope==="all"?void 0:nu(ne.kind,y.activeChangeIds));return rn({enabled:lt==null,active:!1,supported:rt,reason:lt},"builtin")}if(c==="copy-format")return Xn()==="viewing"?rn({supported:!0,enabled:!1,active:!1},"builtin"):b()?rn({supported:!0,enabled:!0,active:p.mode!=="idle"},"builtin"):rn({supported:!0,enabled:!1,active:!1,reason:tt.notReady},"builtin");const le=nd(c);if(!le)return rn({enabled:!1,active:!1,supported:!1,reason:tt.commandUnsupported},"unsupported");if(le.disposition!=="routed")return rn({enabled:!1,active:!1,supported:!1,reason:le.reason??tt.commandUnsupported},le.disposition==="unsupported"?"unsupported":"builtin");if(le.instanceRoute)return Li(le);if(le.table)return ht(le,h,D);if(le.inline?.kind==="clear"){if(le.mutates&&D)return rn({enabled:!1,active:!1,supported:!0,reason:tt.documentReadonly},"builtin");const Ze=xr(E);if(Ze)return rn({enabled:!1,active:!1,supported:!0,reason:Ze},"builtin");const Xe=Kr(y).length>0||dd(y)!=null;return rn({enabled:Xe,active:!1,supported:!0,reason:Xe?void 0:tt.selectionRequired},"builtin")}const xe=le.docRoute;if(!xe)return rn({enabled:!1,active:!1,supported:!1,reason:tt.commandUnsupported},"unsupported");if(Sr(h,xe)==null)return rn({enabled:!1,active:!1,supported:!1,reason:es(h)},"builtin");const je=nt(c);if(je){const Ze=je.shippedStatus,Xe=Ze!=="not-shipped"&&Ze!=="disabled",Ge=typeof je.enabled=="boolean"?je.enabled:!0,rt=c==="undo"||c==="redo",lt=rt&&je.historyResolved===!1,We=rt&&Xe&&Ge===!1&&je.reason===null&&!lt,wt=je.reason===void 0?void 0:We?tt.historyEmpty:lt?tt.notReady:Bm(je.reason,tt.commandUnsupported);return le.mutates&&D?rn({enabled:!1,active:!1,supported:Xe,reason:tt.documentReadonly},"builtin"):rn({enabled:Xe&&Ge,active:!1,supported:Xe,reason:wt},"builtin")}const De=ie(le,h,y),Ye=se(le,h,y,_);if(le.list?.mode==="indent"||le.list?.mode==="outdent")return gr(le,h,D,y,De,Ye);if(le.list?.mode==="toggle-seed")return Br(le,h,D,y,De,Ye);if(le.mutates&&D)return rn({enabled:!1,active:De,supported:!0,value:Ye,reason:tt.documentReadonly},"builtin");if(le.inline&&!dd(y)){const Ze=xr(E);return rn(Ze?{enabled:!1,active:De,supported:!0,value:Ye,reason:Ze}:ac(y)?{enabled:!0,active:De,supported:!0,value:Ye}:{enabled:!1,active:De,supported:!0,value:Ye,reason:tt.rangeSelectionRequired},"builtin")}if((le.blockParagraph||le.list)&&Kr(y).length===0)return rn({enabled:!1,active:De,supported:!0,value:Ye,reason:tt.selectionRequired},"builtin");if(le.field&&!Y_(y))return rn({enabled:!1,active:De,supported:!0,reason:tt.contextUnavailable},"builtin");if(le.pageNumbers&&Xn()==="suggesting")return rn({enabled:!1,active:De,supported:!0,reason:tt.operationUnavailable},"builtin");if(le.link&&!De&&z0(y).length===0&&!$i(y))return rn({enabled:!1,active:De,supported:!0,reason:tt.rangeSelectionRequired},"builtin");if(le.inline){const Ze=xr(E);if(Ze)return rn({enabled:!1,active:De,supported:!0,value:Ye,reason:Ze},"builtin")}return rn({enabled:!0,active:De,supported:!0,value:Ye},"builtin")};function O(c,h){const y=c.address?.anchor,_=y?.start,E=y?.end,D=typeof _?.blockId=="string"?_.blockId:null,V=typeof E?.blockId=="string"?E.blockId:null;if(!D||!V)return!1;const ne=typeof _?.offset=="number"?_.offset:null,le=typeof E?.offset=="number"?E.offset:null;if(ne==null||le==null)return!1;const xe=h.target,je=xe&&Array.isArray(xe.segments)?xe.segments:[];for(const De of je){const Ye=typeof De?.blockId=="string"?De.blockId:null;if(!Ye)continue;const Ze=De.range,Xe=typeof Ze?.start=="number"?Ze.start:null,Ge=typeof Ze?.end=="number"?Ze.end:null;if(!(Xe==null||Ge==null)){if(D!==V){if(Ye===D&&Ge>ne||Ye===V&&Xe<le)return!0;continue}if(Ye===D){if(Xe===Ge){if(Xe>=ne&&Xe<=le)return!0;continue}if(Math.max(Xe,ne)<Math.min(Ge,le))return!0}}}return!1}const Y=(c,h)=>{const y=c?.hyperlinks;if(!y||typeof y.list!="function")return null;const _=Kr(h);if(!Pc(_))return null;for(const E of _){const D={kind:"block",nodeType:"paragraph",nodeId:E},{value:V}=Eo(`hyperlinks:${E}`,sn(),()=>y.list({within:D}),le=>le&&typeof le=="object"?le:null),ne=(V&&Array.isArray(V.items)?V.items:[]).find(le=>O(le,h));if(ne)return ne}return null},ie=(c,h,y)=>{if(c.link)return Y(h,y)!=null;if(c.list?.mode==="toggle-seed"&&c.list.seed)return Oe(h,y)===c.list.seed;const _=W(c);if(_!==null)return _;const E=r.get(c.id),D=Wa(y);if(D&&E?.selectionSignature===D)return E.active;const V=Md(c,y);return V!==null?V:wF(c,y)},se=(c,h,y,_)=>{if(c.inline&&j0(c.inline.key)){const E=ee(c);if(E!==void 0)return E;const D=_[c.inline.key];if(D!==void 0)return D;const V=Wa(y),ne=V?n.get(c.inline.key):void 0;if(V&&ne?.selectionSignature===V)return ne.value}if(c.id==="linked-style"){const{style:E}=ga(y,Pi().cache);return!E.styleId||E.mixed?void 0:{styleId:E.styleId,styleName:E.styleName}}if(c.id==="text-align")return Gt(h,y);if(c.id==="link")return vo(h,y)??void 0},he=(c,h,y)=>{const _=c?.lists;if(!_)return{value:null,status:"ready"};const E=y.storyType==="body",D=typeof _.getStateInStory=="function"?()=>_.getStateInStory({target:Ga(h),story:y}):E&&typeof _.getState=="function"?()=>_.getState({target:Ga(h)}):null;if(!D)return{value:null,status:"ready"};const{value:V,status:ne}=Eo(`lists:${Qn(y)}:${h}`,sn(),D,le=>le&&typeof le=="object"?le:null);return{value:V?.success===!0?V:null,status:ne}},ue=(c,h,y)=>he(c,h,y).value,de=(c,h,y)=>{const _=ue(c,h,y);return!_||_.isListItem!==!0?null:_.seed==="bullet"||_.seed==="ordered"?_.seed:null},Ae=(c,h,y)=>{const _=he(c,h,y),E=_.value;return{value:E&&typeof E.isListItem=="boolean"?E.isListItem:null,status:_.status}},Oe=(c,h)=>{const y=Kr(h);if(y.length===0||!Pc(y))return null;const _=hs(h),E=de(c,y[0],_);if(E!=="bullet"&&E!=="ordered")return null;for(const D of y.slice(1))if(de(c,D,_)!==E)return null;return E},He=(c,h,y)=>{if(!c)return{value:null,status:"ready",refreshing:!1};const _=Qn(y),E=_==="story:body";if(E&&typeof c.getNodeById!="function")return{value:null,status:"ready",refreshing:!1};if(!E&&typeof c.getNode!="function")return{value:null,status:"ready",refreshing:!1};const D=`node:${_}:${h}`,V=sn(),ne=Eo(D,V,()=>E?c.getNodeById({nodeId:h,nodeType:"paragraph"}):c.getNode(_o(h,y)),xe=>xe&&typeof xe=="object"?xe:null),le=Se.get(D);return{...ne,refreshing:ne.status==="stale"&&le?.inflightToken===V&&le.failedToken!==V}},Fe=c=>c==="left"||c==="center"||c==="right"||c==="justify"?c:void 0,qe=c=>c==="start"||c==="end"||c==="distributed"||c==="numTab"||c==="lowKashida"||c==="mediumKashida"||c==="highKashida"||c==="thaiDistribute",at=(c,h)=>{const y=T(),_=y?.readMountedProjectionBlocksByIds;if(typeof _!="function")return null;const E=ps(c),D=Lt(()=>E?_.call(y,[...h],E):_.call(y,[...h]),null);if(!Array.isArray(D))return new Map;const V=$0(D),ne=new Map;for(const le of h){const xe=V.find(Ze=>Dc(Ze,le));if(!xe)continue;const je=xe.attrs,De=Fe(je?.alignment),Ye=cO(je);ne.set(le,De??(Ye==="rtl"?"right":"left"))}return ne},it=(c,h,y,_)=>{const{value:E,status:D,refreshing:V}=He(c,h,y),ne=_?.get(h);if(D==="pending")return ne?{status:"uniform",value:ne}:{status:"pending"};if(D==="stale"&&!V)return{status:"pending"};if(D==="stale"&&ne)return{status:"uniform",value:ne};if(D==="stale"&&_&&!ne)return{status:"unavailable"};if(!E)return{status:"unavailable"};const le=E.node;if(!le)return{status:"unavailable"};const xe=le.kind;if(xe!=="paragraph"&&xe!=="heading")return{status:"unavailable"};const je=le[xe];if(!je||typeof je!="object")return{status:"unavailable"};const De=je.props?.alignment;if(De==null)return ne?{status:"uniform",value:ne}:{status:"unavailable"};const Ye=Fe(De);return Ye?{status:"uniform",value:Ye}:qe(De)&&ne?{status:"uniform",value:ne}:{status:"unavailable"}},At=(c,h)=>{const y=Kr(h);if(y.length===0||!Pc(y))return{status:"unavailable"};const _=hs(h),E=at(h,y),D=it(c,y[0],_,E);if(D.status!=="uniform")return D;for(const V of y.slice(1)){const ne=it(c,V,_,E);if(ne.status!=="uniform")return ne;if(ne.value!==D.value)return{status:"mixed"}}return D},pt=c=>{const h=Kr(c);return h.length===0?null:`${Qn(hs(c))}:${h.join(",")}`},Gt=(c,h)=>{const y=At(c,h),_=y.status==="uniform"?y.value:void 0,E=o;if(!E)return _;const D=pt(h);return D&&D!==E.selectionSignature?(o=null,_):!D||!E.settled?E.value:y.status!=="pending"?(o=null,_):E.value},bn=(c,h)=>{const y=Fe(h),_=pt(c),E=Kr(c);if(!y||!_||E.length===0)return null;const D=++i;return o={selectionSignature:_,value:y,generation:D,settled:!1,canReconcile:Pc(E)},$t(),D},Tr=(c,h)=>{if(c==null)return;const y=o;if(!(!y||y.generation!==c)){if(!mo(h)){o=null;return}if(!y.canReconcile){o=null;return}y.settled=!0}},Jt=async(c,h,y)=>{const _=c?.lists;if(!_)return null;try{const E=y.storyType==="body",D=typeof _.getStateInStory=="function"?await _.getStateInStory({target:Ga(h),story:y}):E&&typeof _.getState=="function"?await _.getState({target:Ga(h)}):null,V=D&&typeof D=="object"?D:null;return!V||V.success!==!0||typeof V.isListItem!="boolean"?null:V.isListItem}catch{return null}},On=(c,h,y)=>{const _={resolved:!1,seed:null},E=c?.lists;if(!E)return _;const D=y.storyType==="body",V=typeof E.getStateInStory=="function"?()=>E.getStateInStory({target:Ga(h),story:y}):D&&typeof E.getState=="function"?()=>E.getState({target:Ga(h)}):null;if(!V)return _;const ne=le=>{const xe=le&&typeof le=="object"?le:null;return!xe||xe.success!==!0||typeof xe.isListItem!="boolean"?_:{resolved:!0,seed:xe.isListItem===!0&&(xe.seed==="bullet"||xe.seed==="ordered")?xe.seed:null}};try{const le=V();return kr(le)?Promise.resolve(le).then(ne,()=>_):ne(le)}catch{return _}},Sn=async(c,h,y)=>{if(!c)return null;try{const _=!y||y.storyType==="body",E=y&&typeof c.getNode=="function"?await c.getNode(_o(h,y)):_&&typeof c.getNodeById=="function"?await c.getNodeById({nodeId:h,nodeType:"paragraph"}):null;return WO(E&&typeof E=="object"?E:null)}catch{return null}},gr=(c,h,y,_,E,D)=>{if(c.mutates&&y)return rn({enabled:!1,active:E,supported:!0,value:D,reason:tt.documentReadonly},"builtin");const V=Kr(_);if(V.length===0)return rn({enabled:!1,active:E,supported:!0,value:D,reason:tt.selectionRequired},"builtin");const ne=c.docRoute?Sr(h,c.docRoute):null,le=Sr(h,"format.paragraph.setIndentation"),xe=Sr(h,"format.paragraph.clearIndentation"),je=c.list?.mode,De=je==="indent"?le!=null:le!=null||xe!=null,Ye=hs(_);let Ze=null;if(Ye.storyType!=="body"){Ze=[];for(const Xe of V){const{value:Ge,status:rt}=Ae(h,Xe,Ye);if(Ge===null)return rt!=="ready"&&(ne!=null||De)?rn({enabled:!0,active:E,supported:!0,value:D},"builtin"):rn({enabled:!1,active:E,supported:!1,value:D,reason:es(h)},"builtin");Ze.push(Ge)}}if(Ze?.some(Xe=>Xe===!0)){const Xe=je==="indent"?"lists.indentRange":"lists.outdentRange",Ge=Xn()!=="suggesting"&&Ze.every(lt=>lt===!0)&&Sr(h,Xe)!=null,rt=je==="outdent"&&Sr(h,"lists.outdentInStory")!=null;if(!Ge&&!rt)return rn({enabled:!1,active:E,supported:!1,value:D,reason:es(h)},"builtin")}for(const[Xe,Ge]of V.entries()){const rt=Ze?{value:Ze[Xe]??null,status:"ready"}:Ae(h,Ge,Ye),lt=rt.value;if(lt===!0){if(ne!=null)return rn({enabled:!0,active:E,supported:!0,value:D},"builtin");continue}if(lt===!1&&De){if(Ye.storyType!=="body"&&typeof h?.getNode!="function")continue;return rn({enabled:!0,active:E,supported:!0,value:D},"builtin")}if(lt===null)return rt.status!=="ready"&&(ne!=null||De)?rn({enabled:!0,active:E,supported:!0,value:D},"builtin"):rn({enabled:!1,active:E,supported:!1,value:D,reason:es(h)},"builtin")}return rn({enabled:!1,active:E,supported:!1,value:D,reason:es(h)},"builtin")},Br=(c,h,y,_,E,D)=>{if(c.mutates&&y)return rn({enabled:!1,active:E,supported:!0,value:D,reason:tt.documentReadonly},"builtin");const V=Kr(_);if(V.length===0)return rn({enabled:!1,active:E,supported:!0,value:D,reason:tt.selectionRequired},"builtin");const ne=hs(_),le=h?.lists;if(!(typeof le?.getStateInStory=="function"||ne.storyType==="body"&&typeof le?.getState=="function"))return rn({enabled:!1,active:E,supported:!1,value:D,reason:tt.operationUnavailable},"builtin");if(!Pc(V))return rn(ne.storyType==="body"&&Sr(h,"lists.remove")!=null?{enabled:!0,active:E,supported:!0,value:D}:{enabled:!1,active:E,supported:!1,value:D,reason:tt.operationUnavailable},"builtin");const xe=V.map(Ze=>he(h,Ze,ne));if(xe.some(({status:Ze})=>Ze!=="ready"))return rn({enabled:!0,active:E,supported:!0,value:D},"builtin");if(xe.some(({value:Ze})=>Ze===null))return rn({enabled:!1,active:E,supported:!1,value:D,reason:tt.operationUnavailable},"builtin");const je=c.list?.seed,De=xe.every(({value:Ze})=>Ze?.isListItem===!0&&Ze.seed===je);if(ne.storyType==="body")return rn(!De||Sr(h,"lists.remove")!=null?{enabled:!0,active:E,supported:!0,value:D}:{enabled:!1,active:E,supported:!1,value:D,reason:tt.operationUnavailable},"builtin");const Ye=Sr(h,"lists.removeInStory");return rn(De&&Ye?{enabled:!0,active:E,supported:!0,value:D}:{enabled:!1,active:E,supported:!1,value:D,reason:tt.operationUnavailable},"builtin")},vo=(c,h)=>{const y=Y(c,h)?.properties?.href;return typeof y=="string"?y:null},Li=c=>{if(!b())return rn({enabled:!1,active:!1,supported:!1,reason:tt.notReady},"builtin");const h=c.instanceRoute;return typeof t?.[h]!="function"?rn({enabled:!1,active:!1,supported:!1,reason:tt.operationUnavailable},"builtin"):rn({enabled:!0,active:gi(c),supported:!0,value:fn(c)},"builtin")},gi=c=>{const h=t?.config??void 0;return c.valueFrom==="ruler"?!!h?.rulers:c.valueFrom==="formattingMarks"?!!h?.layoutEngineOptions?.showFormattingMarks:!1},ht=(c,h,y)=>{if(y)return rn({enabled:!1,active:!1,supported:!0,reason:tt.documentReadonly},"builtin");const _=ft();return _!=null&&(!c.table.requiresCell||_.cellNodeId!=null)?(c.docRoute?Sr(h,c.docRoute):null)==null?rn({enabled:!1,active:!1,supported:!1,reason:es(h)},"builtin"):rn({enabled:!0,active:!1,supported:!0},"builtin"):rn({enabled:!1,active:!1,supported:!0,reason:tt.tableContextUnavailable},"builtin")},fn=c=>{if(c.valueFrom==="zoom")return Id().value;if(c.valueFrom==="documentMode")return Xn();if(c.valueFrom==="measurementUnit")return Ph();if(c.valueFrom==="ruler"||c.valueFrom==="formattingMarks")return gi(c)},Zr=(c,h)=>c.id==="zoom"?typeof h=="number"&&Number.isFinite(h)&&h>0:c.id==="document-mode"?h==="editing"||h==="suggesting"||h==="viewing":c.id==="measurement-unit"?h==="in"||h==="cm":!0,al=()=>[...new Set([...aO,...It.keys()])],pa="Normal",xo={ready:!1,status:"ready",catalogRevision:null,quickGallery:[],activeParagraphStyleId:null,activeParagraphStyleName:null,mixedSelection:!1,sourceStatus:null,diagnostics:[]},Ts=c=>`styles:catalog:${JSON.stringify(c??{})}`,ma=c=>{const h=M()?.styles;return!h||typeof h.getCatalog!="function"?{value:null,status:"ready"}:Eo(Ts(c),sn(),()=>h.getCatalog(c),y=>y&&typeof y=="object"?y:null)},Pi=()=>{const c=ma({includePreview:!0});if(!c.value)return{cache:null,status:c.status};const h=ma({view:"quickGallery",includePreview:!0}),y=h.value?h.value.items:c.value.styles.filter(E=>E.visibility.quickGallery),_=new Map;for(const E of c.value.styles)_.set(E.id,E);return{cache:{full:c.value,quickGallery:y,byId:_},status:Ol(c.status,h.status)}},ru=(c,h,y)=>{const{value:_,status:E}=He(c,h,y);if(!_)return{ok:!1,styleRef:null,status:E};const D=_.node;if(!D||typeof D!="object")return{ok:!1,styleRef:null,status:E};const V=D.kind,ne=typeof V=="string"?D[V]:void 0,le=ne&&typeof ne=="object"?ne.styleRef:void 0;return{ok:!0,styleRef:typeof le=="string"&&le.length>0?le:null,status:E}},ga=(c,h)=>{const y=[],_=M();if(!_)return y.push({severity:"warning",code:"active-style-unavailable",message:"Active paragraph style is unavailable: the Document API is not reachable."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:y},status:"ready"};const E=Kr(c);if(E.length===0)return y.push({severity:"info",code:"active-style-no-selection",message:"No paragraph block is resolvable from the current selection; active paragraph style is unavailable."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:y},status:"ready"};if(!Pc(E))return y.push({severity:"info",code:"active-style-selection-too-large",message:"Active paragraph style is unavailable for a large multi-paragraph selection."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:y},status:"ready"};const D=h?.full.defaults.paragraphStyleId??(h?pa:null),V=new Set;let ne=0,le=0,xe=0,je="ready";const De=hs(c);for(const Xe of E){const Ge=ru(_,Xe,De);if(je=Ol(je,Ge.status),!Ge.ok){le+=1;continue}if(!Ge.styleRef&&!D){xe+=1;continue}const rt=Ge.styleRef??D;if(!rt){xe+=1;continue}ne+=1,V.add(rt)}if(ne===0){const Xe=xe>0&&le===0;return y.push({severity:"warning",code:Xe?"active-style-default-unavailable":"active-style-read-failed",message:Xe?"Selected paragraphs have no explicit style and the style catalogue is unavailable, so the document default cannot be resolved.":"Could not read the paragraph style of any selected block; active paragraph style is unavailable."}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:y},status:je}}const Ye=le+xe;if(Ye>0)return y.push({severity:"warning",code:"active-style-partial",message:`Active paragraph style resolved from ${ne} of ${ne+Ye} selected blocks; ${Ye} could not be read, so the active style is unavailable.`}),{style:{styleId:null,styleName:null,mixed:!1,diagnostics:y},status:je};if(V.size>1)return{style:{styleId:null,styleName:null,mixed:!0,diagnostics:y},status:je};const Ze=[...V][0];return{style:{styleId:Ze,styleName:h?.byId.get(Ze)?.name??null,mixed:!1,diagnostics:y},status:je}},ll=c=>{if(!b())return xo;const{cache:h,status:y}=Pi(),{style:_,status:E}=ga(c,h);let D;return h?D=_.diagnostics.length===0?h.full.diagnostics:[...h.full.diagnostics,..._.diagnostics]:D=[{severity:"warning",code:"catalog-unavailable",message:"The style catalogue is unavailable: the Document API styles surface is not reachable (e.g. viewing mode or a worker-backed editor)."},..._.diagnostics],{ready:!0,status:Ol(y,E,c.status),catalogRevision:h?.full.revision??null,quickGallery:h?.quickGallery??[],activeParagraphStyleId:_.styleId,activeParagraphStyleName:_.styleName,mixedSelection:_.mixed,sourceStatus:h?.full.sourceStatus??null,diagnostics:D}},Rs=(c="direct")=>{const{sink:h}=Nm(),y=h?Ha():0,_={},E=(xe,je)=>{if(!h)return je();const De=Ha();try{return je()}finally{_[xe]=Ha()-De}},D=E("documentMode",Xn),V=E("selection",Er);V.status==="ready"&&Gc(V),fe(V);const ne=Wa(V);for(const[xe,je]of r)(!ne||je.selectionSignature!==ne||je.settled&&V.status==="ready")&&r.delete(xe);const le={ready:b()!=null,documentMode:D,document:E("document",ei),selection:V,toolbar:{context:D,commands:E("toolbarCommands",()=>il(V)),copyFormatActive:p.mode!=="idle"},comments:E("comments",()=>Rh(V)),trackChanges:E("trackChanges",()=>Mh(V)),contentControls:E("contentControls",()=>Lh(V)),zoom:E("zoom",Id),fonts:E("fonts",Ad),styles:E("styles",()=>ll(V))};if(h){const xe=Ha();O0({stage:"superdoc-ui-compute-state",atMs:xe,reason:c,startedAtMs:y,completedAtMs:xe,durationMs:xe-y,phaseMs:_,asyncReadSettlements:Hn.splice(0)})}return le},cl=c=>{const h=Wa(c);h&&a&&h!==a&&(n.clear(),r.clear()),h&&(a=h)};let ts=null,vi=null,Ms=null,yi=null,bi=null,ns=null,rs=!1;const Fd=()=>{if(N||rs)return;rs=!0;const c=()=>{rs&&(rs=!1,!N&&$t())};typeof queueMicrotask=="function"?queueMicrotask(c):Promise.resolve().then(c)},lc=()=>{const c=ye();if(c!==Ms&&(yi&&(yi(),yi=null),Ms=c,!(!c||typeof c.subscribe!="function")))try{const h=c.subscribe(()=>Fd());typeof h=="function"&&(yi=h)}catch{Ms=null}},cc=()=>{const c=G();if(c!==bi&&(ns&&(ns(),ns=null),bi=c,!(!c||typeof c.subscribe!="function")))try{const h=c.subscribe(()=>$t());typeof h=="function"&&(ns=h)}catch{bi=null}};let Di=null,ti=null,B=null,q=null,Ee=null,be=null;const Je=()=>{const c=b()?.host,h=Lt(c?.getHandles?()=>c.getHandles():void 0,null)?.editing?.selection;return h&&typeof h.subscribe=="function"?h:null},zt=()=>{const c=T(),h=c?.readLiveSelectionSyncSnapshot;if(typeof h!="function")return!1;const y=Qi(Lt(()=>h.call(c),null));if(!y||!ca(y))return!1;const _=la(y,"ready"),E=$i(P.selection),D=$i(_);if(E&&D&&E.blockId===D.blockId&&Qn(E.story)===Qn(D.story))return!1;const V=Ed(_),ne=P.toolbar.commands["font-family"]?.value,le=P.toolbar.commands["font-size"]?.value,xe=typeof ne=="string"&&ne.length>0,je=typeof le=="string"&&le.length>0||typeof le=="number"&&Number.isFinite(le);return xe&&V.fontFamily===void 0||je&&V.fontSize===void 0},Pt=()=>{const c=Je();if(c!==ts&&(vi&&(vi(),vi=null),ts=c,!!c))try{const h=c.subscribe(y=>{Vo()&&zt()&&Th()||(bt+=1,tl(y),$t("host-selection"))});typeof h=="function"&&(vi=h)}catch{ts=null}},on=()=>{const c=b()?.host,h=Lt(c?.getHandles?()=>c.getHandles():void 0,null)?.review;return h&&typeof h.subscribe=="function"?h:null},cn=c=>c?typeof c.getActiveReviewTarget=="function"?Lt(()=>c.getActiveReviewTarget(),null):typeof c.getSnapshot=="function"?Lt(()=>c.getSnapshot(),null)?.activeReviewTarget??null:null:null;let pn=0;const Ln=(c,h)=>{const y=(h&&typeof h=="object"?h:null)?.lastInteractionRejection;if(c==null&&y&&typeof y=="object"&&y.code==="review-target-invalidated"&&y.detail==="not-painted"&&oe)return!1;const _=c&&typeof c=="object"?c:null;let E=null;if(_?.entityType==="trackedChange"&&typeof _.entityId=="string"&&_.entityId.length>0){const D=_.story&&typeof _.story=="object"?_.story:void 0,V=D&&Qn(D)!==Qn(null)?D:void 0,ne=typeof _.paintedEntityId=="string"&&_.paintedEntityId.length>0?_.paintedEntityId:null,le=ne??_.entityId,xe=(()=>{if(V){const Ye=mi(),Ze=Ye?Fl(Ye,V):null;return Ze?.toPublicId(le)??Ze?.toPublicId(_.entityId)??_.entityId}const De=ta(Array.isArray(P?.trackChanges.items)?P.trackChanges.items:[]);return De.toPublicId(le)??De.toPublicId(_.entityId)??_.entityId})(),je=ne??(le!==xe?le:null);E={id:xe,...V?{story:V}:{},...je&&je!==xe?{paintedEntityId:je}:{}}}return c==null&&E==null&&oe!=null&&X(oe)||j(oe,E)?!1:(ae(E),!0)},Hr=()=>{const c=on();if(c===Di)return;if(ti&&(ti(),ti=null),Di=c,!c){Ln(null);return}let h=!0;try{const y=c.subscribe(_=>{const E=_&&typeof _=="object"?_:null,D=E&&Object.prototype.hasOwnProperty.call(E,"activeReviewTarget")?E.activeReviewTarget:cn(c);!Ln(D,_)||h||$t()});typeof y=="function"&&(ti=y),Ln(cn(c))}catch{Di=null}finally{h=!1}},_n=()=>{if(ts||Xn()!=="viewing")return null;const c=b()?.mount?.container,h=(c&&typeof c=="object"&&"ownerDocument"in c?c.ownerDocument??null:null)??globalThis.document??null;return h&&typeof h.addEventListener=="function"?h:null},Rr=()=>{const c=_n();if(c===Ee||(be&&(be(),be=null),Ee=c,!c))return;const h=()=>{bt+=1,$t()};c.addEventListener("selectionchange",h),c.addEventListener("pointerup",h,!0),c.addEventListener("mouseup",h,!0),be=()=>{c.removeEventListener("selectionchange",h),c.removeEventListener("pointerup",h,!0),c.removeEventListener("mouseup",h,!0)}};Is(),Ln(cn(on())),P=Rs("initial"),a=Wa(P.selection);let Ls=()=>{};const yo=()=>{const c=b()?.host,h=c?.events,y=h&&typeof h.subscribe=="function"?h:null;if(y!==B&&(q&&(q(),q=null),B=y,!!y)){c&&(kn.delete(c),Ht(c));try{const _=y.subscribe(E=>{const D=E?.type,V=D==="document:mutated"&&E.hasCommitEvent!==!0;if((V||D==="mutation:committed"&&eA(E)||D==="collaboration:remote-changed"&&Array.isArray(E.changedStoryIds)&&E.changedStoryIds.length>0)&&Ls(),(D==="document:mutated"||D==="mutation:committed"&&eA(E))&&c&&!Dt.has(c)&&(Dt.add(c),$t("document-dirty")),D==="collaboration:document-replaced"&&c&&(Dt.delete(c),kn.delete(c),Ht(c),$t("document-dirty")),D==="review-mutation:started"){gt(E.reviewMutation?.token);return}if(D==="review-mutation:aborted"){Xt(E.reviewMutation?.token),qt();return}if(D==="mutation:rejected"&&E.reviewMutation&&(Xt(E.reviewMutation.token),qt()),D==="mutation:committed"&&E.reviewMutation&&Xt(E.reviewMutation.token),D==="source:complete"||D==="source:signals-complete"){Zo=sn(),dt();return}if((V||D==="mutation:committed"||D==="collaboration:remote-changed")&&(li=Date.now()),V||D==="mutation:committed"||D==="save:completed"||D==="collaboration:remote-changed"){const ne=D==="mutation:committed"?A_(E):null;if(ne?.allResolved){Mn([]),ar(E.receipt);return}ne?.removedIds.size&&No(new Set(ne.removedIds),E.receipt);const le=D==="mutation:committed"&&ql(E)||D==="collaboration:remote-changed"&&Array.isArray(E.changedStoryIds)&&E.changedStoryIds.length>0;if(le&&(zo=Date.now()),D==="mutation:committed"&&le){As();return}if(ne?.removedIds.size&&ne.upsertIds.size===0)return;(V||D==="collaboration:remote-changed"||D==="mutation:committed"&&!le)&&Xl();const xe=D==="collaboration:remote-changed"&&Array.isArray(E.changedPartUris)&&E.changedPartUris.some(De=>typeof De=="string"&&DO.has(De)),je=D==="collaboration:remote-changed"&&Array.isArray(E.changedStoryIds)&&E.changedStoryIds.length>0&&Ue();xe&&!le&&(Ir=!0),Zi(),xe&&!le?Ie("comments"):je&&(Ir=!0,Cs()),$t()}});typeof _=="function"&&(q=_)}catch{B=null}}},$t=(c="unspecified")=>{if(N)return;const{sink:h}=Nm(),y=h?Ha():0;rs=!1,Is(),Pt(),lc(),cc(),Hr(),Rr(),yo();const _=Rs(c);cl(_.selection),P=_;let E=0,D=0;for(const V of[...ke]){if(!h){V(P);continue}const ne=Ha();V(P);const le=Ha()-ne;E+=le,D=Math.max(D,le)}if(h){const V=Ha();O0({stage:"superdoc-ui-recompute",atMs:V,reason:c,startedAtMs:y,completedAtMs:V,durationMs:V-y,listenerCount:ke.size,listenerTotalMs:E,listenerMaxMs:D})}},ul=[],ou=[],Nh=[],Bh=c=>{for(const h of c)try{h()}catch{}},Nd=()=>Bh(ul),Tg=()=>Bh(ou),Rg=()=>Bh(Nh),zh=[];((c,h)=>{if(!(!c||typeof c.on!="function"))for(const y of h){const _=y==="active-editor-change"?()=>{Nd(),Tg(),$t()}:y==="document-replaced"?E=>{const D=E&&typeof E=="object"?E:null,V=D?.editor,ne=D?.host,le=!!V&&V===b(),xe=!!ne&&ne===T();if(!le&&!xe)return;const je=xe?ne:T();je&&(Dt.delete(je),kn.delete(je)),Tg(),Se.clear(),Zi(),$t()}:y==="document-mode-change"?()=>{$t(),Rg()}:()=>$t();try{c.on(y,_),zh.push(()=>{try{typeof c.off=="function"&&c.off(y,_)}catch{}})}catch{}}})(t,xO),Pt(),lc(),cc(),Hr(),Rr(),yo();const Ps=(c,h=fD)=>({get:()=>c(P),subscribe:y=>{let _=c(P);const E=D=>{const V=c(D);h(_,V)||(_=V,y(V))};return ke.add(E),()=>ke.delete(E)}}),Ds=c=>Ps(c),os=c=>{const h=y=>{const _=D=>{try{y(D)}catch{}},E=c.subscribe(_);return _(c.get()),E};return{get:()=>c.get(),getSnapshot:()=>c.get(),observe:h,subscribe:y=>h(_=>y({snapshot:_}))}},jh=(c,h,y)=>{const _=os(c),E=os(h),D=V=>{const ne=Vn(y);$t();const le=E.observe(V);return()=>{le(),ne()}};return{get:_.get,getSnapshot:_.getSnapshot,observe:D,subscribe:V=>D(ne=>V({snapshot:ne}))}};function Vh(c){return c&&typeof c=="object"&&typeof c.id=="string"?String(c.id):null}function nr(c){const h=ps(c);return h&&Qn(h)!==Qn(null)?h:void 0}function Uh(c,h){return{kind:"id",id:c,...h?{story:h}:{}}}function Mg(c){if(c.empty)return null;const h=c.selectionTarget,y=h?.start,_=h?.end;if(h?.kind!=="selection"||y?.kind!=="text"||_?.kind!=="text"||typeof y.blockId!="string"||y.blockId!==_.blockId||!Number.isInteger(y.offset)||!Number.isInteger(_.offset)||y.offset<0||_.offset<0||y.offset===_.offset)return null;const E=Math.min(y.offset,_.offset),D=Math.max(y.offset,_.offset),V=ps(c);return{kind:"range",coordinateSpace:h.coordinateSpace==="tracked"?"tracked":"visible",range:{kind:"text",...V?{story:V}:{},segments:[{blockId:y.blockId,range:{start:E,end:D}}]}}}function Lg(c,h){if(Qn(h)!==Qn(null))return;const y=M()?.trackChanges,_=y?.list;if(typeof _!="function")return;const E=Lt(()=>_.call(y),null);if(kr(E)||!E||typeof E!="object")return;const D=E.items;if(Array.isArray(D))return D.map(cd).find(V=>V!=null&&Ti(V,c,h))}function U1(c,h){const y=$h(c.quotedText);if(!y)return!1;const _=ud(h);return[_.insertedText,_.deletedText,_.excerpt].some(E=>$h(E)===y)}function $h(c){return typeof c=="string"?c.replace(/\s+/g," ").trim():""}function Pg(){const c=P.selection.activeChangeIds[0];if(!c)return"unavailable";const h=ps(P.selection),y=(P.trackChanges.status==="ready"?P.trackChanges.items.find(V=>Ti(V,c,h)):void 0)??Lg(c,h)??mi()?.find(V=>Ti(V,c,h));if(!y)return"unavailable";const _=ud(y),E=_.type,D=_.grouping;return U1(P.selection,y)?"id":E==="replacement"&&D==="replacement-pair"||(E==="insertion"||E==="deletion"||E==="insert"||E==="delete")&&D==="standalone"?"range":"id"}function Dg(c,h,y,_){const E=()=>X1(c,Uh(y,_),y,_);try{const D=X1(c,h,y,_);if(kr(D))return ro(Promise.resolve(D).then(ne=>mo(ra(ne))?ne:E()));const V=ra(D);return ro(mo(V)?D:E())}catch{return!1}}function Og(c){if(typeof c=="string"&&c.length>0)return{target:{kind:"id",id:c},changeId:c};if(c&&typeof c=="object"){const h=c;if(h.target&&typeof h.target=="object"){const _=h.target;return{target:_,changeId:Vh(_),story:_.story}}const y=typeof h.changeId=="string"?h.changeId:h.id;if(typeof y=="string"&&y.length>0)return{target:Uh(y,h.story),changeId:y,story:h.story}}return null}function Fg(c,h){if(c.scope==="all")return{target:{kind:"all"},changeId:null};const y=Og(h);if(y)return y;const _=P.selection.activeChangeIds[0],E=nr(P.selection);return _?{target:Uh(_,E),changeId:_,story:E}:null}function iu(c,h){if(c.scope==="id"&&h==null){if(P.selection.activeChangeIds.length>1)return au(c.kind,{kind:"ids",ids:P.selection.activeChangeIds},null);if(P.selection.activeChangeIds.length===1&&!P.selection.empty&&P.selection.selectionTarget){const _=Pg();if(_==="unavailable")return!1;if(_==="range"){const E=Mg(P.selection),D=nr(P.selection);return E?Dg(c.kind,E,P.selection.activeChangeIds[0],D):!1}if(_==="id"){const E=P.selection.activeChangeIds[0],D=ps(P.selection),V=D&&Qn(D)!==Qn(null)?D:void 0;return Kh(c.kind,V?{id:E,story:V}:E)}}}const y=Fg(c,h);return y?au(c.kind,y.target,y.changeId,y.story):!1}function uc(c,h){const y=ye()?.lists,_=y?.apply,E=T(),D=x!==void 0&&b()?.editorVersion===2&&E?Fm.get(t)?.get(E):null;if(x!==void 0&&b()?.editorVersion===2&&!D||!D&&typeof _!="function")return!1;const{behavior:V,preset:ne,continuity:le}=typeof h=="string"?MO(h):h&&typeof h=="object"?h:{},xe={kind:c,behavior:V??"toggle"};ne!==void 0&&(xe.preset=ne),le!==void 0&&(xe.continuity=le);try{return ro(D?D.runListApply(xe):_.call(y,xe))}catch{return!1}}let $o=Promise.resolve(!1),kt=null,Ut=null,vn=null,vr=Promise.resolve(!1);const Mr=async c=>{if(!jm(c))return c;const h=b()?.documentMutationReadiness,y=h?.whenPainted;if(typeof y!="function")return c;const _=typeof c.txId=="string"?c.txId:void 0;try{await y.call(h,_?{txId:_}:void 0)}catch{}return c},Zn=c=>{if(kr(c)){const y=Promise.resolve(c);return{immediate:!0,committed:y.then(_=>ra(_),()=>!1),settled:y.then(_=>Mr(ra(_)),()=>!1)}}const h=ra(c);return{immediate:h,committed:Promise.resolve(h),settled:Mr(h)}},Oi=()=>{const c=s.shift();if(!c){u=!1,f?.(),f=null;return}try{c.resolve(N?!1:c.mutate())}catch{c.resolve(!1)}},Os=()=>{let c=!1;return()=>{c||(c=!0,Oi())}},Bd=(c,h)=>{if(!u){u=!0,d=new Promise(D=>{f=D});try{return{result:h(),release:Os()}}catch(D){throw u=!1,f?.(),f=null,D}}const y=s.find(D=>D.key===c);if(y)return y.mutate=h,{result:y.result,release:()=>{}};let _;const E=new Promise(D=>{_=D});return s.push({key:c,mutate:h,result:E,resolve:_}),{result:E,release:Os()}},UK=new Set(["create.tableOfContents","headerFooters.pageNumbers.set","headerFooters.pageNumbers.remove"]),$K=c=>er(`Tracked authoring is not supported for ${c}.`),zd=c=>{if(Xn()==="suggesting")return UK.has(c)?$K(c):{changeMode:"tracked"}},HK=()=>Xn()==="suggesting"?cF:G0,bo=(c,h,y)=>{const _=zd(c);return _&&_.success===!1?_:_?h(y,_):h(y)},GK=(c,h,y,_)=>{const E=c.inline;if(!E)return;const D=ra(_);if(D===!1||typeof D=="object"&&D&&D.success===!1)return;if(E.kind==="clear"){n.clear();return}if(E.kind==="toggle"||!j0(E.key))return;const V=Wa(h);if(!V)return;const ne=XO(E.key,y.value);if(ne==null){n.delete(E.key);return}n.set(E.key,{selectionSignature:V,value:ne})},WK=(c,h,y,_)=>!c.inline||c.inline.kind==="toggle"?_:kr(_)?Promise.resolve(_).then(E=>(GK(c,h,y,E),E)):_,KK=(c,h,y,_)=>{if(c.inline?.kind!=="toggle"||!mo(ra(_))||typeof y.value!="boolean"&&y.value!==null)return null;const E=Wa(h);if(!E)return null;const D=++l;return r.set(c.id,{selectionSignature:E,active:y.value===!0,generation:D,settled:!1}),$t(),D},qK=(c,h,y)=>{if(h==null)return;const _=r.get(c.id);if(!(!_||_.generation!==h)){if(!mo(y)){r.delete(c.id);return}_.settled=!0}},Ng=(c,h)=>c.then(y=>(h?.(y),hi(),y),()=>(h?.(!1),hi(),!1)),ro=(c,h)=>{const y=kt;if(kt=null,y)return $o=Ng(y,h),ra(c);if(kr(c))return $o=Ng(Zn(c).settled,h),!0;const _=ra(c);return jm(_)&&typeof b()?.documentMutationReadiness?.whenPainted=="function"?($o=Ng(Mr(_),h),_):(h?.(_),$o=Promise.resolve(_),hi(),_)},YK=(c,h)=>!c||typeof c!="object"?h:c,dc=(c,h=er("Document API operation failed."))=>{if(kr(c))return Promise.resolve(c).then(_=>dc(_,h),()=>h);const y=YK(c,h);return Zi(),jm(y)&&typeof b()?.documentMutationReadiness?.whenPainted=="function"?(Ng(Mr(y)),$t(),y):($t(),y)},XK=(c,h,y,_)=>{const E=[],D=[];for(const V of y){const ne=_(V);if(ne)try{const le=Zn(bo(c,h,ne));E.push(le.immediate),D.push(le.settled)}catch{E.push(!1),D.push(Promise.resolve(!1))}}return kt=D.length?Promise.all(D).then(V=>Ri(V)):null,Ri(E)},ZK=(c,h,y,_)=>{const E=[],D=[];for(const V of y){const ne=_(V);if(ne)try{const le=Zn(bo(c,h,ne));E.push(le.immediate),D.push(le.settled)}catch{E.push(!1),D.push(Promise.resolve(!1))}}return kt=D.length?Promise.all(D).then(V=>Ri(V)):null,Ri(E)},$1=(c,h,y,_=P.selection)=>{const E=zd(c);return E&&E.success===!1?E:_.selectionTarget?h(y,{...E,offsetSpace:"selection"}):E?h(y,E):h(y)},QK=(c,h,y,_)=>{const E=_o(h,_);switch(c.kind){case"alignment":{const D=y;return D!=="left"&&D!=="center"&&D!=="right"&&D!=="justify"?null:{target:E,alignment:D}}case"spacing-line":{const D=typeof y=="number"?y:Number(y);return!Number.isFinite(D)||D<=0?null:{target:E,line:D,lineRule:"auto"}}case"style":if(y&&typeof y=="object"){const D=y.role;if(D&&typeof D=="object")return{target:E,role:D}}return typeof y!="string"||y.trim()===""?null:{target:E,styleId:y};case"direction":{const D=c.fixedValue;return D!=="ltr"&&D!=="rtl"?null:{target:E,direction:D}}default:return null}},JK=(c,h)=>{const y=c.inline,_=H0(c),E=T();if(!y||typeof E?.setPendingInlineFormat!="function")return!1;if(y.kind==="clear")return Z(),!0;if(!_)return!1;let D;if(y.kind==="toggle")D=!ie(c,M(),P.selection);else{const V=h&&typeof h=="object"&&"value"in h?h.value:h;if(y.kind==="value-number"){const ne=typeof V=="number"?V:Number(V);D=Number.isFinite(ne)&&ne>0?ne:null}else D=typeof V=="string"&&V.trim()!==""?V:null;if(D===null)return J(_,null),!0}return J(_,D),!0},eq=()=>{const c=M(),{lockModesById:h}=da(c?.contentControls,P.selection);if(xr(h))return!1;const y=[],_=[],E=Ze=>{const Xe=Zn(Ze);y.push(Xe.immediate),_.push(Xe.settled)},D=(Ze,Xe,Ge)=>{try{E(Ge?Ze(Xe,Ge):Ze(Xe))}catch{y.push(!1),_.push(Promise.resolve(!1))}},V=Pi().cache?.full.defaults.paragraphStyleId??pa,ne=dd(P.selection);if(ne){const Ze=Sr(c,"format.apply");if(Ze)try{E($1("format.apply",Ze,{target:ne,inline:{...HK()}}))}catch{y.push(!1),_.push(Promise.resolve(!1))}}const le=Sr(c,"format.paragraph.resetDirectFormatting"),xe=Sr(c,"styles.paragraph.setStyleRef"),je=ps(P.selection),De=!je||je.storyType==="body",Ye=Sr(c,De?"lists.remove":"lists.removeInStory");for(const Ze of Kr(P.selection)){const Xe=_o(Ze,je);if(le&&D(le,{target:Xe}),Ye)try{const Ge=Ga(Ze),rt=Zn(Ye(De?{target:Ge}:{target:Ge,story:je}));_.push(rt.settled.then(lt=>mo(lt)?lt:!0))}catch{}xe&&D(xe,{target:Xe,styleId:V})}if(!ne&&Xn()!=="suggesting"){const Ze=Sr(c,"format.paragraph.setMarkRunProps");if(Ze)for(const Xe of Kr(P.selection))D(Ze,{target:_o(Xe,je),markRunProps:{bold:!1,italic:!1,strikethrough:!1,doubleStrikethrough:!1,smallCaps:!1,caps:!1,verticalAlign:"baseline"}})}return kt=_.length?Promise.all(_).then(Ze=>Ri(Ze)):null,Ri(y.length?y:[!1])},tq=(c,h,y)=>{const _=Kr(P.selection);if(_.length===0)return!1;const E=ps(P.selection);return XK(c.docRoute,h,_,D=>QK(c.blockParagraph,D,y,E))},nq=(c,h,y)=>{const _=M(),E=Sr(_,"format.paragraph.setIndentation"),D=Sr(_,"format.paragraph.clearIndentation"),V=c.list?.mode,ne=hs(P.selection),le=ps(P.selection),xe=async je=>{const De=await Jt(_,je,ne);if(De===!0)return{kind:"list",routeToCall:c.docRoute,opToCall:h,input:{target:K_(je)}};if(De===null||le&&le.storyType!=="body"&&typeof _?.getNode!="function")return null;const Ye=await Sn(_,je,le),Ze={};if(Ye?.right!=null&&(Ze.right=Ye.right),Ye?.firstLine!=null&&(Ze.firstLine=Ye.firstLine),Ye?.hanging!=null&&(Ze.hanging=Ye.hanging),V==="indent")return E?{kind:"paragraph",routeToCall:"format.paragraph.setIndentation",opToCall:E,input:{target:_o(je,le),left:Math.max(0,Ye?.left??0)+q_,...Ze}}:null;const Xe=Math.max(0,(Ye?.left??0)-q_);return Xe>0&&(Ze.left=Xe),Object.keys(Ze).length===0?D?{kind:"paragraph",routeToCall:"format.paragraph.clearIndentation",opToCall:D,input:{target:_o(je,le)}}:E?{kind:"paragraph",routeToCall:"format.paragraph.setIndentation",opToCall:E,input:{target:_o(je,le),left:0}}:null:E?{kind:"paragraph",routeToCall:"format.paragraph.setIndentation",opToCall:E,input:{target:_o(je,le),...Ze}}:null};return kt=(async()=>{const je=await Promise.all(y.map(Xe=>xe(Xe).catch(()=>null)));if(je.length===y.length&&je.every(Xe=>Xe?.kind==="list")&&Xn()!=="suggesting"){const Xe=V==="indent"?"lists.indentRange":"lists.outdentRange",Ge=Sr(_,Xe);if(Ge)try{return await Zn(bo(Xe,Ge,{paraIds:y,story:ne})).settled}catch{return!1}}const De=ne.storyType!=="body"&&je.some(Xe=>Xe?.kind==="list"),Ye=De&&V==="outdent"?Sr(_,"lists.outdentInStory"):null;if(De&&!Ye)return!1;const Ze=je.map(Xe=>{if(!Xe)return Promise.resolve(!1);try{return Xe.kind==="list"&&Ye?Zn(bo("lists.outdentInStory",Ye,{target:Xe.input.target,story:ne})).settled:Zn(bo(Xe.routeToCall,Xe.opToCall,Xe.input)).settled}catch{return Promise.resolve(!1)}});return Ri(await Promise.all(Ze))})(),!0},rq=(c,h)=>{const y=c.list,_=M(),E=Kr(P.selection);if(E.length===0)return!1;const D=hs(P.selection),V=D.storyType==="body";if(y.mode==="indent"||y.mode==="outdent")return nq(c,h,E);const ne=y.seed,le=De=>{if(De.some(lt=>!lt.resolved))return{immediate:!1,settled:null};const Ye=De.every(lt=>lt.seed===ne);if(!Ye&&!V)return{immediate:!1,settled:null};const Ze=Ye?V?"lists.remove":"lists.removeInStory":c.docRoute,Xe=Ye?Sr(_,Ze):h;if(!Xe)return{immediate:!1,settled:null};const Ge=[],rt=[];return E.forEach((lt,We)=>{if(!Ye&&De[We]?.seed===ne)return;const wt=Ye?{target:Ga(lt),...V?{}:{story:D}}:{target:Ga(lt),seed:ne};try{const Rt=Zn(bo(Ze,Xe,wt));Ge.push(Rt.immediate),rt.push(Rt.settled)}catch{Ge.push(!1),rt.push(Promise.resolve(!1))}}),{immediate:Ri(Ge),settled:rt.length?Promise.all(rt).then(lt=>Ri(lt)):null}},xe=E.map(De=>On(_,De,D));if(xe.some(kr))return kt=Promise.all(xe).then(async De=>{const Ye=le(De);return Ye.settled?await Ye.settled:Ye.immediate}),!0;const je=le(xe);return kt=je.settled,je.immediate};function Hh(c){return c&&typeof c=="object"?c:{}}function oq(c){if(typeof c=="string")return c;const h=Hh(c);if(Object.prototype.hasOwnProperty.call(h,"href"))return h.href;if(Object.prototype.hasOwnProperty.call(h,"value"))return h.value}function iq(c,h){const y=Hh(c).text;return typeof y=="string"&&y.trim()!==""?y:h}function ex(c){const h=Hh(c),y=h.capture&&typeof h.capture=="object"?h.capture:null;return h.target??y?.target??y?.selectionTarget??h.selectionTarget??h.textTarget??null}const sq=c=>{const h=M(),y=h?.hyperlinks;if(!y)return!1;const _=T(),E=typeof _?.getHandles=="function"?_.getHandles():null,D=x?E?.editing?.hyperlinks:y,V=Hh(c),ne=oq(c),le=ex(c),xe=typeof V.text=="string"?V.text:void 0,je=typeof V.currentText=="string"?V.currentText:void 0,De=ih(V.hyperlinkTarget)?V.hyperlinkTarget:null,Ye=ih(V.textTarget)?V.textTarget:null,Ze=Y(h,P.selection),Xe=typeof De?.storyId=="string"&&typeof De?.hyperlinkNodeId=="string";if(Xe&&ne===null){const Ge=y.remove;if(typeof Ge!="function")return!1;try{return bo("hyperlinks.remove",Ge,{storyId:De.storyId,hyperlinkNodeId:De.hyperlinkNodeId,keepText:!0})}catch{return!1}}if(Ze&&ne===null){const Ge=D?.remove;if(typeof Ge!="function")return!1;try{return bo("hyperlinks.remove",Ge,{target:Ze.address,mode:"unwrap"})}catch{return!1}}if((Ze||De)&&typeof ne=="string"&&ne.trim()!==""){const Ge=D?.patch,rt=y.updateTarget;if(!(!Xe&&Ze&&typeof Ge=="function")&&!(Xe&&typeof rt=="function"))return!1;const lt=typeof xe=="string"&&xe!==(Xe?je:Ze?.text??je),We=h?.text?.replace,wt=lt?Xe?Ye:rF(Ze?.address):null,Rt=lt&&!!wt&&typeof We=="function";if(lt&&!Rt)return!1;const an=[],un=[];let En=null,io=null,Bi=null,as=!1;try{if(Xe){if(typeof rt!="function")return!1;const wo=bo("hyperlinks.updateTarget",rt,{storyId:De.storyId,hyperlinkNodeId:De.hyperlinkNodeId,newTarget:oF(ne)});as=kr(wo);const ni=Zn(wo);if(!mo(ni.immediate))return!1;an.push(ni.immediate),un.push(ni.settled),En=ni.immediate,io=ni.committed,Bi=ni.settled}else if(Ze){if(typeof Ge!="function")return!1;const wo=bo("hyperlinks.patch",Ge,{target:Ze.address,patch:{href:ne}});as=kr(wo);const ni=Zn(wo);if(!mo(ni.immediate))return!1;an.push(ni.immediate),un.push(ni.settled),En=ni.immediate,io=ni.committed,Bi=ni.settled}}catch{return!1}if(Rt){const wo=(Ho,ya)=>mo(ya)?Ri([Ho,ya]):mo(Ho)?Qf(Ho,ya):ya,ni=Ho=>{if(!mo(Ho))return Ho;try{const ya=Zn(bo("text.replace",We,{target:wt,text:xe}));return mo(ya.immediate)?Promise.all([Bi??Promise.resolve(Ho),ya.settled]).then(([o2,Zq])=>wo(o2,Zq)):Qf(Ho,ya.immediate)}catch{return Qf(Ho,!1)}};if(as)return kt=(io??Promise.resolve(En??!1)).then(ni),Ri(an);try{const Ho=Zn(bo("text.replace",We,{target:wt,text:xe}));if(!mo(Ho.immediate))return En?Qf(En,Ho.immediate):Ho.immediate;an.push(Ho.immediate),un.push(Ho.settled),kt=Promise.all([Bi??Promise.resolve(En??!1),Ho.settled]).then(([ya,o2])=>wo(ya,o2))}catch{return En?Qf(En,!1):!1}}return!Rt&&un.length>0&&(kt=Promise.all(un).then(wo=>Ri(wo))),Ri(an)}if(typeof ne=="string"&&ne.trim()!==""){const Ge=ne.trim(),rt=D?.wrap,lt=KO(le),We=lt.length>0?lt:z0(P.selection);if(We.length>0){if(typeof rt!="function")return!1;try{return ZK("hyperlinks.wrap",rt,We,un=>({target:un,link:{destination:{href:Ge}}}))}catch{return!1}}const wt=D?.insert,Rt=iq(c,Ge);if(typeof wt!="function"||Rt.trim()==="")return!1;const an=rh(le)??$i(P.selection);if(!an)return!1;try{return bo("hyperlinks.insert",wt,{target:an,text:Rt,link:{destination:{href:Ge}}})}catch{return!1}}return!1},aq=(c,h,y)=>{const _=c.create.kind,E=y&&typeof y=="object"?y:{};if(_==="table"){const V=Number(E.rows??E.rowCount),ne=Number(E.columns??E.cols??E.colCount);if(!Number.isInteger(V)||V<1||!Number.isInteger(ne)||ne<1)return!1;const le=$i(P.selection),xe=le&&typeof le.blockId=="string"?{kind:"inParagraph",target:_o(le.blockId),offset:le.range?.start??0}:U0(P.selection,"nodeId");try{return bo(c.docRoute,h,{rows:V,columns:ne,at:xe})}catch{return!1}}if(_==="image"){const V=E.src??E.value;if(typeof V!="string"||V.trim()==="")return!1;const ne=$i(P.selection),le=hs(P.selection),xe=le.storyType==="body"?null:le;let je;ne&&typeof ne.blockId=="string"?je={kind:"inParagraph",target:_o(ne.blockId,xe),offset:ne.range?.start??0}:(je=U0(P.selection,"target"),xe&&je.kind==="after"&&(je={...je,target:{...je.target,story:xe}}));const De={src:V,at:je};xe&&(De.in=je.kind==="inParagraph"?R(xe)??xe:xe),typeof E.alt=="string"&&(De.alt=E.alt),typeof E.title=="string"&&(De.title=E.title),E.size&&typeof E.size=="object"&&(De.size=E.size);const Ye=T(),Ze=typeof Ye?.getHandles=="function"?Ye.getHandles():null,Xe=x?Ze?.editing?.images:null,Ge=x?Xe?.create:h;if(typeof Ge!="function")return!1;try{return bo(c.docRoute,Ge,De)}catch{return!1}}const D={at:U0(P.selection,"target")};typeof E.instruction=="string"&&(D.instruction=E.instruction),E.config&&typeof E.config=="object"&&(D.config=E.config);try{return bo(c.docRoute,h,D)}catch{return!1}},lq=()=>{if(x===null)return null;const c=T();return c?x!==void 0?(typeof c.getHandles=="function"?c.getHandles():null)?.editing?.fields??null:typeof c.getCodeFieldEditingCommands=="function"?c.getCodeFieldEditingCommands():null:null},cq=c=>{if(P.selection.status==="ready"&&!Y_(P.selection))return!1;const h=zd(c.docRoute);if(h&&h.success===!1)return h;const y={instruction:c.field.instruction};try{const _=lq();return typeof _?.insertAtSelection!="function"?!1:h?_.insertAtSelection(y,h):_.insertAtSelection(y)}catch{return!1}},tx=()=>{if(x===null)return null;const c=T();return c?x!==void 0?(typeof c.getHandles=="function"?c.getHandles():null)?.editing?.pageNumbers??null:typeof c.getCodePageNumberEditingCommands=="function"?c.getCodePageNumberEditingCommands():null:null},uq=(c,h)=>{if(!h)return!1;const y=zd(c.docRoute);if(y&&y.success===!1)return y;const _=c.pageNumbers;try{const E=tx();if(typeof E?.[_]!="function")return!1;const D=E[_];return y?D(h,y):D(h)}catch{return!1}},dq=async()=>{try{const c=tx();return typeof c?.get!="function"?null:await c.get()??null}catch{return null}},nx=()=>{if(x===null)return null;const c=T();return c?x!==void 0?(typeof c.getHandles=="function"?c.getHandles():null)?.editing?.tables??null:typeof c.getCodeTableEditingCommands=="function"?c.getCodeTableEditingCommands():null:null},fq=(c,h)=>{const y=c.table,_=ft();if(!_||y.requiresCell&&!_.cellNodeId)return!1;const E=fF(y.action,_);if(!E)return!1;try{if(y.action==="insert-row-before"||y.action==="insert-row-after"){const D=nx();if(typeof D?.insertRow!="function")return!1;const V=zd(c.docRoute);return V&&V.success===!1?V:V?D.insertRow(E,V):D.insertRow(E)}if(y.action==="insert-column-before"||y.action==="insert-column-after"){const D=nx();if(typeof D?.insertColumn!="function")return!1;const V=zd(c.docRoute);return V&&V.success===!1?V:V?D.insertColumn(E,_.rowIndex,V):D.insertColumn(E,_.rowIndex)}return bo(c.docRoute,h,E)}catch{return!1}},hq=c=>!c||c.disposition!=="routed"?!1:!!(c.inline||c.blockParagraph||c.list||c.link||c.create),pq=c=>{const h=Hh(c);return!!(ex(c)||ih(h.hyperlinkTarget)||ih(h.textTarget))},mq=(c,h,y)=>P.selection.status!=="ready"?!1:Um(c)?.scope==="id"||!h||h.disposition!=="routed"?!0:h.inline?.kind==="clear"?Kr(P.selection).length>0||dd(P.selection)!=null:h.inline?dd(P.selection)!=null||ac(P.selection):h.blockParagraph||h.list?Kr(P.selection).length>0:h.link?pq(y)||z0(P.selection).length>0||$i(P.selection)!=null||ie(h,M(),P.selection):!0,gq=(c,h)=>{const y=Um(c),_=nd(c);return y?.scope==="id"&&Og(h)||y?.scope!=="id"&&!hq(_)?!1:!mq(c,_,h)},vq=(c,h)=>gq(c,h)?Yc().then(()=>{}):null,yq=(c,h,y)=>{if(kt=null,$o=Promise.resolve(!1),N)return!1;const _=It.get(c);if(_)try{const De=_.execute(Kc(h,y));return ro(De)}catch{return!1}const E=N_(c);if(E){if(Xn()==="viewing")return!1;if(typeof ye()?.lists?.apply=="function")return uc(E,h)}const D=Um(c);if(D)return iu(D,h);if(c==="copy-format")return ro(bq());const V=nd(c);if(!V||V.disposition!=="routed")return!1;const ne=V.normalizePayload?V.normalizePayload(h):h;if(V.instanceRoute){if(!b()||!Zr(V,ne))return!1;const De=t?.[V.instanceRoute];if(typeof De!="function")return!1;try{const Ye=V.fixedArg!==void 0?V.fixedArg:ne,Ze=De.call(t,Ye);return ro(Ze)}catch{return!1}}if(V.inline?.kind==="clear")return V.mutates&&Xn()==="viewing"?!1:ro(eq());const le=V.docRoute;if(!le||V.mutates&&Xn()==="viewing")return!1;const xe=M(),je=Sr(xe,le);if(!je)return!1;if(V.inline){const{lockModesById:De}=da(xe?.contentControls,P.selection);if(xr(De))return!1;const Ye=dd(P.selection);if(!Ye)return ac(P.selection)?ro(JK(V,ne)):ro(!1);const Ze=ie(V,xe,P.selection),Xe=uF(V.inline,Ye,ne,Ze);if(!Xe)return!1;let Ge=null;try{const rt=b(),lt=rt?.doc,We=Xn(),wt=()=>b()!==rt||rt?.doc!==lt||Xn()!==We?!1:$1(le,je,Xe),Rt=Wa(P.selection)??Mc(P.selection),an=V.inline.kind==="toggle"?Bd(`${V.id}:${Rt}`,wt):null;Ge=an?.release??null;const un=an?an.result:wt(),En=KK(V,P.selection,Xe,un),io=WK(V,P.selection,Xe,un),Bi=ro(io,as=>{qK(V,En,as),Ge?.(),Ge=null});return V.inline.kind==="toggle"&&(vr=$o),Bi}catch{return Ge?.(),!1}}if(V.blockParagraph){const De=tq(V,je,ne),Ye=V.blockParagraph.kind==="alignment"&&mo(De)?bn(P.selection,ne):null;return ro(De,Ze=>{Tr(Ye,Ze)})}if(V.list){const De=rq(V,je);return ro(De)}if(V.link){const De=sq(ne);return ro(De)}if(V.create){const De=aq(V,je,ne);return ro(De)}if(V.field){if(Ut)return!1;const De=ro(cq(V)),Ye=$o;return Ut=Ye,Ye.finally(()=>{Ut===Ye&&(Ut=null)}),De}if(V.pageNumbers){if(vn)return!1;const De=ro(uq(V,ne)),Ye=$o;return vn=Ye,Ye.finally(()=>{vn===Ye&&(vn=null)}),De}if(V.table){const De=fq(V,je);return ro(De)}try{return ro(V.mutates?bo(le,je,ne):je(ne))}catch{return!1}},H1=(c,h,y,_)=>{const E=Jx(t,"command:started",()=>({commandId:c,selection:P.selection}));let D;const V=x;x=_&&!It.has(c)?H():void 0;try{D=yq(c,h,y)}catch(le){throw Wd(t,"command:settled",()=>({actionId:E,commandId:c,outcome:"threw"})),le}finally{x=V}const ne=le=>Wd(t,"command:settled",()=>({actionId:E,commandId:c,outcome:mo(le)?"succeeded":"rejected",result:le}));if(D===!1)ne(D);else try{$o.then(ne,()=>ne(!1))}catch{}return D},Gh=(c,h,y)=>H1(c,h,y,!1),Bg=()=>{g+=1,m=null,p={mode:"idle",snapshot:null,sourceSelectionKey:null,lastClickAt:p.lastClickAt,pointerSelecting:!1,keyboardSelecting:!1};for(const c of v)c("idle");$t()},bq=async()=>{const c=x??null,h=["bold","italic","underline","strikethrough"].filter(De=>P.toolbar.commands[De]?.active===!0),y=await vr;await d;const _=mo(y)?h:[],E=500,D=Date.now();if(p.mode!=="idle"){if(p.mode==="armed"&&D-p.lastClickAt<E){p={...p,mode:"persistent",lastClickAt:D};for(const De of v)De("persistent");return $t(),!0}return Bg(),!1}const V=D-p.lastClickAt<E,ne=++g;p={...p,lastClickAt:D};const le=await Yc(),xe=`${Mc(le)}:${sn()}`,je=await wq(null,le,xe&&xe===w?C:void 0,_);if(ne!==g)return!0;p={...p,mode:V?"persistent":"armed",snapshot:je,sourceSelectionKey:Mc(le),lastClickAt:D},m=c;for(const De of v)De(p.mode);return $t(),!0},wq=async(c,h,y,_=[])=>{const E=h?.target??c?.target;if(!E||E.kind!=="text")return null;const D=Array.isArray(E.segments)?E.segments:[];if(D.length===0)return null;const V=M();if(!V)return null;const ne=E.story;let le=null;for(const Xe of D){const Ge=(await ic(_o(Xe.blockId,ne)))?.node??null;if(!Ge)continue;const rt=G1(Ge),lt=Array.isArray(rt?.inlines)?rt.inlines:[],We=Cq(lt,Xe.range);le?le=rx(le,We):le=We}const xe=le?j9(le):{},je={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strike"},De=new Set([...h?.activeMarks??(Array.isArray(c?.activeMarks)?c.activeMarks:[]),..._]);for(const[Xe,Ge]of Object.entries(je))De.has(Xe)&&(xe[Ge]=!0);const Ye=y??await Fh(h??la(c,"ready"));if(Ye.fontFamily&&(xe.fontFamily=Ye.fontFamily),Ye.color&&(xe.color=Ye.color),Ye.highlight&&(xe.highlight=Ye.highlight),Ye.fontSize){const Xe=Number.parseFloat(Ye.fontSize);Number.isNaN(Xe)||(xe.fontSize=Xe)}let Ze=null;if(D.length===1){const Xe=D[0],Ge=(await ic(_o(Xe.blockId,ne)))?.node??null;Ge&&G1(Ge)&&(Ze=await kq(Ge,Xe.blockId,V,ne))}return{story:ne??null,inline:xe,paragraph:Ze}},G1=c=>c?c.kind==="paragraph"?c.paragraph??null:c.kind==="heading"?c.heading??null:null:null,Cq=(c,h)=>{const y=V=>{const ne=V.run;return typeof ne?.text=="string"?ne.text:""},_=V=>V.run?.props;if(h.start===h.end){let V=0;for(const ne of c){const le=y(ne),xe=V,je=V+le.length;if(V=je,h.start>=xe&&h.start<=je){const De=_(ne);return De?{...De}:{}}}return{}}let E=0;const D=[];for(const V of c){const ne=y(V),le=E,xe=E+ne.length;if(E=xe,xe<=h.start||le>=h.end)continue;const je=_(V);je&&D.push(je)}return D.length===0?{}:D.length===1?{...D[0]}:rx(D[0],...D.slice(1))},rx=(c,...h)=>{const y={...c};for(const _ of h)for(const E of Object.keys(y)){if(!(E in _)){delete y[E];continue}const D=y[E],V=_[E];(typeof D!=typeof V||JSON.stringify(D)!==JSON.stringify(V))&&delete y[E]}return y},kq=async(c,h,y,_)=>{const E=G1(c),D=E.props??{},V=E.styleRef??null,ne=D.alignment??null,le=D.spacing??null,xe=D.indent??null,je=xe?{...xe.left!=null?{left:xe.left}:{},...xe.right!=null?{right:xe.right}:{},...xe.firstLine!=null?{firstLine:xe.firstLine}:{},...xe.hanging!=null?{hanging:xe.hanging}:{}}:null,De=D.markRunProps??null,Ye=D.numbering?.numId,Ze=typeof Ye=="string"?parseInt(Ye,10):typeof Ye=="number"?Ye:NaN,Xe=D.numbering?.level,Ge=isNaN(Ze)?null:{numId:Ze,...Xe!=null?{level:Xe}:{}};let rt=null;if(Ge&&typeof y.lists?.getState=="function")try{const lt=await y.lists.getState({target:_o(h,_)});lt&&typeof y.lists?.getStyle=="function"&&(rt=await y.lists.getStyle(lt)??null)}catch{}return{styleId:V,alignment:ne,spacing:le,indentation:je,markRunProps:De,numbering:Ge,listStyle:rt}},ox=async()=>{if(p.mode==="idle"||p.pointerSelecting||p.keyboardSelecting)return;const c=M()?.selection,h=async()=>{const V=typeof c?.current=="function"?await Promise.resolve(c.current({includeText:!0})):el().value;return Qi(V)},y=()=>new Promise(V=>setTimeout(V,16)),_=8;let E=null,D="";for(let V=0;V<_;V+=1){if(V>0&&await y(),p.mode==="idle"||p.pointerSelecting||p.keyboardSelecting)return;if(E=await h(),!(!E||E.empty)&&(D=Mc(E),D!==p.sourceSelectionKey))break}if(E&&!E.empty&&D!==p.sourceSelectionKey){await ix(E);return}if(p.snapshot?.paragraph){const V=await h();if(!V||Mc(V)===p.sourceSelectionKey)return;await ix(V)}},ix=async c=>{const h=p.snapshot;if(!h){p.mode==="armed"&&Bg();return}const y=m??M();if(!y)return;const _=la(c,"ready"),{lockModesById:E}=da(y.contentControls,_);if(xr(E)){$t();return}const D=c.target,V=c.selectionTarget;if(c.empty!==!0&&Object.keys(h.inline).length>0){const ne=Sr(y,"format.apply");if(ne&&V)try{if(!mo(ra(await Promise.resolve($1("format.apply",ne,{target:V,inline:h.inline},c))))){$t();return}}catch{$t();return}}if(h.paragraph){const ne=Array.isArray(D?.segments)?D.segments:[],le=D?.story;for(const xe of ne){const je=_o(xe.blockId,le),De=await ic(je),Ye=De?.node??null,Ze=De?.address??null;if(!Ye)continue;const Xe={kind:"block",nodeType:Ze?.nodeType??Ye.kind??"paragraph",nodeId:xe.blockId,...le&&typeof le=="object"?{story:le}:{}},{styleId:Ge,alignment:rt,spacing:lt,indentation:We,markRunProps:wt,numbering:Rt,listStyle:an}=h.paragraph;if(Ge&&await y.styles?.paragraph?.setStyle?.({target:Xe,styleId:Ge}),rt&&await y.format?.paragraph?.setAlignment?.({target:Xe,alignment:rt}),lt){const un=lt,En=un.lineRule??"auto",io=new Set(["auto","exact","atLeast"]).has(En)?En:"auto",Bi={...un.before!=null?{before:Math.round(un.before*20)}:{},...un.after!=null?{after:Math.round(un.after*20)}:{},...un.line!=null?{line:Math.round(io==="auto"?un.line*240:un.line*20),lineRule:io}:{}};await y.format?.paragraph?.setSpacing?.({target:Xe,...Bi})}if(We){const un={...We.left!=null?{left:na(We.left)}:{},...We.right!=null?{right:na(We.right)}:{},...We.firstLine!=null?{firstLine:na(We.firstLine)}:{},...We.hanging!=null?{hanging:na(We.hanging)}:{}};await y.format?.paragraph?.setIndentation?.({target:Xe,...un})}wt&&await y.format?.paragraph?.setMarkRunProps?.({target:Xe,markRunProps:wt}),Rt&&await y.format?.paragraph?.setNumbering?.({target:Xe,...Rt}),an&&((await ic(je))?.address?.nodeType==="listItem"?await y.lists?.applyStyle?.({target:K_(xe.blockId,le),style:an}):Rt&&await y.format?.paragraph?.setNumbering?.({target:Xe,...Rt}))}}p.mode==="armed"&&Bg(),$t()},sx=(c,h,y,_)=>{const E=vq(c,h),D=E?E.then(()=>(H1(c,h,y,_),$o)):(H1(c,h,y,_),$o);return nd(c)?.inline?.kind==="toggle"&&(vr=D),D},zg=(c,h,y)=>sx(c,h,y,!1),Sq=(c,h)=>sx(c,h,void 0,!0),ax=c=>({id:c,getState:()=>P.toolbar.commands[c]??A(c,M(),P.selection,ol(P.selection)),observe:h=>Ps(y=>y.toolbar.commands[c]??{enabled:!1,active:!1,supported:!1,source:"unsupported",reason:tt.commandUnsupported}).subscribe(h),execute:h=>Gh(c,h),executeAsync:h=>zg(c,h)}),_q=c=>{It.set(c.id,c),$t();const h=()=>{It.delete(c.id),$t()};return Object.assign(h,{handle:ax(c.id),unregister:h})},jg=Ds(c=>c.selection),Vg=os(jg),Ug=()=>{const c=T();if(typeof c?.getHandles!="function")return{reason:tt.hostCapabilityUnavailable};let h=null;try{h=c.getHandles()}catch(E){const D=E?.reason;return{reason:D==="host-not-ready"||D==="host-disposed"||D==="editing-mount-required"?tt.notReady:tt.hostCapabilityUnavailable}}const y=h?.editing?.selectionTargets;if(typeof y?.apply=="function")return{helper:y};const _=h?.selection;return typeof _?.apply=="function"?{helper:_}:{reason:tt.hostCapabilityUnavailable}},Aq=()=>{const c=T();if(typeof c?.getHandles!="function")return null;let h=null;try{h=c.getHandles()}catch{return null}const y=h?.editing?.selection?.toSelectionTarget?.()??h?.selection?.toSelectionTarget?.();if(!y||typeof y!="object"||y.kind!=="ok")return null;const _=y.target;return _&&typeof _=="object"?_:null},Iq=c=>{const h=T();if(typeof h?.getHandles=="function")try{const y=h.getHandles()?.editing?.contentControls;typeof y?.activate=="function"&&y.activate({id:c})}catch{}},W1={get:Vg.get,getSnapshot:Vg.getSnapshot,subscribe:Vg.subscribe,observe:Vg.observe,current:()=>el().value,capture:()=>{const c=jg.get();return c.empty||!c.target&&!c.selectionTarget?null:{...c,capturedAt:Date.now()}},restore:c=>{const h=E=>($t(),{...E,success:E.ok});if(!c||typeof c!="object")return h({ok:!1,reason:tt.targetUnresolved});if(!b())return h({ok:!1,reason:tt.notReady});const y=lF(c);if(!y)return h({ok:!1,reason:tt.targetUnresolved});const _=Ug();if(!("helper"in _))return h({ok:!1,reason:_.reason});try{return h(N0(_.helper.apply(y)))}catch{return h({ok:!1,reason:tt.hostCapabilityUnavailable})}},apply:c=>{if(!b())return{ok:!1,reason:tt.notReady};const h=Ug();if(!("helper"in h))return{ok:!1,reason:h.reason};try{const y=h.helper.apply(c);return $t(),N0(y)}catch{return{ok:!1,reason:tt.hostCapabilityUnavailable}}},placeAroundContentControl:async c=>{if(!b())return{ok:!1,reason:tt.notReady};const h=Ug();if(!("helper"in h))return{ok:!1,reason:h.reason};if(typeof h.helper.placeAroundContentControl!="function")return{ok:!1,reason:tt.hostCapabilityUnavailable};try{const y=await h.helper.placeAroundContentControl(c);return $t(),N0(y)}catch{return{ok:!1,reason:tt.targetUnresolved}}},getAnchorRect:c=>{const h=T();if(typeof h?.getSelectionAnchorRect=="function"){const y=Lt(()=>h.getSelectionAnchorRect(c),null);return y&&typeof y=="object"&&(Number(y.width)>0||Number(y.height)>0)?y:null}return null},getRects:c=>{const h=jg.get(),y=h.selectionTarget??h.target;if(h.empty||!y)return[];const _=Jg.getRect({target:y,relativeTo:c?.relativeTo});return _.found?_.rects:[]}},Eq={get ids(){return al()},has:c=>nd(c)!=null||It.has(c),get:c=>ax(c),execute:Gh,executeAsync:zg,register:_q,getContextMenuItems:c=>{const h=[];for(const y of It.values()){const _=y.contextMenu;_&&Lt(_.when?()=>_.when(c):void 0,!0)&&h.push({id:y.id,label:_.label,group:_.group,order:_.order,invoke:()=>Gh(y.id,void 0,c)})}return h.sort((y,_)=>(y.order??0)-(_.order??0)||y.label.localeCompare(_.label))}},K1=os(Ds(c=>c.toolbar)),xq={get:K1.get,getSnapshot:()=>P.toolbar,subscribe:K1.subscribe,observe:K1.observe,execute:Gh,executeAsync:zg},su=async(c,h)=>{if(!b())return{success:!1,ok:!1,reason:tt.notReady};if(!c)return{success:!1,ok:!1,reason:tt.targetUnresolved};const y=T(),_=y?.scrollTargetIntoView;if(typeof _!="function")return{success:!1,ok:!1,reason:tt.hostCapabilityUnavailable};try{const E={target:c,block:h?.block??"center",behavior:h?.behavior??"smooth"},D=await Promise.resolve(h?.shouldContinue?_.call(y,E,h.shouldContinue):_.call(y,E));return D&&typeof D=="object"&&D.success===!1?{success:!1,ok:!1,reason:Bm(D.reason,tt.targetUnresolved)}:{success:!0,ok:!0}}catch{return{success:!1,ok:!1,reason:tt.hostCapabilityUnavailable}}};let q1=0;ou.push(()=>{q1+=1});const Tq={navigateTo:async(c,h)=>{const y=++q1,_=()=>({success:!1,ok:!1,reason:tt.targetUnresolved}),E=typeof c=="string"?{kind:"entity",entityType:"bookmark",name:c}:c;if(!E||E.kind!=="entity"||E.entityType!=="bookmark"||typeof E.name!="string"||E.name.length===0||E.story!==void 0&&(!E.story||E.story.kind!=="story"||E.story.storyType!=="body"))return _();const D=b();if(!D||N)return{success:!1,ok:!1,reason:tt.notReady};const V=M(),ne=V?.bookmarks;if(typeof ne?.list!="function"||typeof ne?.get!="function")return{success:!1,ok:!1,reason:tt.operationUnavailable};const le=Ug();if(!("helper"in le))return{success:!1,ok:!1,reason:le.reason};const xe=T();if(typeof xe?.scrollTargetIntoView!="function")return{success:!1,ok:!1,reason:tt.hostCapabilityUnavailable};const je=Yh();let De=!0;const Ye=()=>De&&!N&&y===q1&&b()===D&&M()===V&&T()===xe&&Yh()===je,Ze=async()=>{try{const rt=await ne.list.call(ne,E.story?{in:E.story}:{});if(!Ye()||(Array.isArray(rt?.items)?rt.items:[]).filter(En=>En?.name===E.name).length!==1)return _();const lt=await ne.get.call(ne,{target:E});if(!Ye())return _();const We=lt?.range?.from,wt=lt?.range?.to,Rt=En=>typeof En?.blockId=="string"&&En.blockId.length>0&&Number.isInteger(En.offset)&&En.offset>=0;if(lt?.name!==E.name||lt?.address?.story&<.address.story.storyType!=="body"||lt?.tableColumn||!Rt(We)||!Rt(wt)||We.blockId===wt.blockId&&We.offset>wt.offset)return _();const an=await su({kind:"text",segments:[{blockId:We.blockId,range:{start:We.offset,end:We.offset}}]},{block:h?.block??"center",behavior:h?.behavior??"instant",shouldContinue:Ye});if(!Ye())return _();if(!an.ok)return an;const un=W1.apply({kind:"selection",start:{kind:"text",blockId:We.blockId,offset:We.offset},end:{kind:"text",blockId:wt.blockId,offset:wt.offset}});return{...un,success:un.ok}}catch{return _()}};let Xe;const Ge=new Promise(rt=>{Xe=setTimeout(()=>{De=!1,rt(_())},15e3)});try{return await Promise.race([Ze(),Ge])}finally{De=!1,clearTimeout(Xe)}}},lx=c=>{if(!c||typeof c!="object")return null;const h=c,y=h.wordRevisionIds&&typeof h.wordRevisionIds=="object"?h.wordRevisionIds:null,_=h.sourceIds&&typeof h.sourceIds=="object"?h.sourceIds:null,E=Array.isArray(_?.wordIdOther)?_.wordIdOther:void 0,D=y?.insert??y?.delete??y?.format??_?.wordIdInsert??_?.wordIdDelete??E?.[0];return typeof D=="string"&&D.length>0?D:null},cx=async(c,h,y,_,E)=>{const D=await su(h,E);if(D.ok)return D;const V=z(),ne=V?.focusTrackedChange;if(typeof ne!="function")return D;const le=y||_?{commentId:c,...y?{trackedChangeStory:y}:{},..._?{importedId:_}:{}}:c;try{const xe=await Promise.resolve(ne.call(V,le));if(xe&&typeof xe=="object"&&xe.ok===!0)return{success:!0,ok:!0}}catch{}return D},$g=async(c,h,y,_)=>{const E=c==="trackChanges"?_?.story:void 0,D=c==="trackChanges"?_?.matchStory??E:void 0,V=We=>{if(!E||!We||typeof We!="object")return We;const wt=We,Rt=wt.address&&typeof wt.address=="object"?wt.address:null;return wt.story||Rt?.story?We:{...wt,story:E}},ne=c==="trackChanges"?z_:Jf,le=y.find(We=>Ti(We,h,D)),xe=le&&typeof le=="object"?le:null,je=c==="trackChanges"&&xe?.type==="move"&&(xe.subtype==="move-to"||xe.subtype==="move-from")?xe.subtype:null,De=je&&typeof xe?.trackedChangeCanonicalId=="string"?xe.trackedChangeCanonicalId:h,Ye=We=>{if(!je)return c==="trackChanges"?z_(We,{preferStableBlock:!0}):ne(We);const wt=Jf(We);if(wt?.kind!=="move")return null;const Rt=je==="move-to"?wt.destination:wt.source;return B0(Rt)?Rt:null},Ze=ne(le),Xe=c!=="trackChanges"||!je&&B0(Jf(le));if(Ze&&Xe)return V(Ze);const Ge=M()?.[c],rt=c==="comments"?{commentId:h}:{id:De,...E?{story:E}:{}},lt=Ge?.get;if(typeof lt!="function")return V(Ze);try{return V(Ye(await Promise.resolve(lt.call(Ge,rt)))??Ze)}catch{return V(Ze)}};function ux(c,h){if(tc())return er("Comments are read-only.","DOCUMENT_READONLY");if(qc())return er("Resolving comments is disabled.","DOCUMENT_READONLY");const y=M()?.comments,_=y?.patch;if(typeof _!="function")return er("comments.patch is unavailable.");const E=er("comments.patch failed.");return Lt(()=>dc(_.call(y,{commentId:c,status:h}),E),E)}const Wh=()=>tc()?er("Comments are read-only.","DOCUMENT_READONLY"):null,Rq=(c,h)=>{const y=h&&typeof h=="object"?h:null;let _=Array.from(c);y?.includeResolved===!1&&(_=_.filter(le=>le.status!=="resolved"));const E=Number(y?.offset),D=Number.isInteger(E)&&E>0?E:0,V=Number(y?.limit),ne=Number.isInteger(V)&&V>=0?D+V:void 0;return _.slice(D,ne)},jd=Ds(c=>c.comments),Hg=jh(jd,Ps(c=>Cd(c.selection,c.comments)),"comments"),Mq={get:Hg.get,getSnapshot:Hg.getSnapshot,subscribe:Hg.subscribe,observe:Hg.observe,list:c=>{to();const h=Xc();return Rq(h.value??jd.get().items,c)},getById:c=>{const h=jd.get().items.find(E=>Ur(E)===c)??null;if(h)return h;const y=M()?.comments,_=Lt(y?.get?()=>y.get({commentId:c}):void 0,null);return kr(_)?null:_},createFromCapture:(c,h)=>{const y=Wh();if(y)return y;const _=M()?.comments,E=_?.create;if(typeof E!="function")return er("comments.create is unavailable.");const D=er("comments.create failed.");return Lt(()=>{const V=c&&typeof c=="object"?c.target??c.selectionTarget:null;return V==null?er("A range selection is required to comment.","NO_SELECTION"):dc(E.call(_,{target:V,text:h.text}),D)},D)},createFromSelection:c=>{const h=Wh();if(h)return h;const y=M()?.comments,_=y?.create;if(typeof _!="function")return er("comments.create is unavailable.");const E=jg.get();let D=E.target??E.selectionTarget;if(E.empty||!D){const ne=Aq();ne&&(D=ne)}if(!D)return er("A range selection is required to comment.","NO_SELECTION");const V=er("comments.create failed.");return Lt(()=>dc(_.call(y,{target:D,text:c.text}),V),V)},reply:(c,h)=>{const y=Wh();if(y)return y;const _=M()?.comments,E=_?.reply??_?.create;if(typeof E!="function")return er("comments.reply is unavailable.");const D=er("comments.reply failed.");return Lt(()=>dc(E===_?.reply?E.call(_,{parentCommentId:c,text:h.text}):E.call(_,{parentCommentId:c,text:h.text}),D),D)},edit:(c,h)=>{const y=Wh();if(y)return y;const _=M()?.comments,E=_?.patch;if(typeof E!="function")return er("comments.patch is unavailable.");const D=er("comments.patch failed.");return Lt(()=>dc(E.call(_,{commentId:c,text:h.text}),D),D)},resolve:c=>ux(c,"resolved"),reopen:c=>ux(c,"active"),delete:c=>{const h=Wh();if(h)return h;const y=M()?.comments,_=y?.delete??y?.remove;if(typeof _!="function")return er("comments.delete is unavailable.");const E=er("comments.delete failed.");return Lt(()=>dc(_.call(y,{commentId:c}),E),E)},setActive:c=>{if(c==null)return Le=null,$t(),!0;if(!b())return!1;const h=jd.get(),y=Se.get("comments"),_=y?.token===sn()&&y.hasSettled&&Array.isArray(y.value)?y.value:null,E=_??h.items;if(!_&&h.listStatus!=="ready")return!1;const D=$O(E,c);return!D||!E.some(V=>Ur(V)===D)?!1:(Le=D,$t(),!0)},scrollTo:async c=>{if(!M())return{success:!1,ok:!1,reason:b()?tt.documentApiUnavailable:tt.notReady};const h=await $g("comments",c,jd.get().items);return h?su(h):{success:!1,ok:!1,reason:tt.targetUnresolved}}},is=Ds(c=>c.trackChanges),Y1=(c,h)=>{eo();const y=(ua().value??is.get().items).map(cd).filter(De=>De!=null&&Ur(De)!==null);if(y.length===0)return null;const _=P.trackChanges.activeId,E=oe?.id===_?oe.story:void 0,D=y.filter(De=>th(De)==null),V=E||D.length===0?y:D;let ne=_?V.findIndex(De=>Ti(De,_,E)):-1;ne===-1&&_&&E&&(ne=V.findIndex(De=>Ti(De,_)));const le=V[ne===-1?c>0?0:V.length-1:(ne+c+V.length)%V.length],xe=Ur(le),je=th(le);return ae(je?{id:xe,story:je}:{id:xe},h),$t(),xe},dx=async c=>{const h=z(),y=h?.listTrackedChanges;if(typeof y=="function")try{await Promise.resolve(y.call(h,{mode:"visible-window",targetIds:[c],refreshReason:"ui-track-change-reveal-restamp",blocking:!0}))}catch{}};let fx=Promise.resolve();const Lq=c=>{const h=Q;return fx.catch(()=>{}).then(()=>Pq(c,h))},Pq=async(c,h)=>{if(Q!==h)return{success:!1};const y=oe,_=Y1(c,{invalidateQueuedNavigation:!1});if(_==null)return{success:!1};const E=oe,D=we,V=()=>Q===h&&oe===E&&we===D,ne=()=>{V()&&(ae(y,{invalidateQueuedNavigation:!1}),$t())};E&&re.add(E);try{const le=await $g("trackChanges",_,is.get().items,E?.story?{story:E.story}:void 0);if(!V())return{success:!1};if(!le)return ne(),{success:!1};const xe=is.get().items.find(De=>Ti(De,_,E?.story))??is.get().items.find(De=>Ur(De)===_),je=lx(xe);pn+=1;try{const De=await cx(_,le,E?.story,je,{behavior:"auto",shouldContinue:V});if(!V())return{success:!1};if(!De.ok&&De.reason!==tt.targetNotVisible)ne(),K(y);else{if(De.ok&&await dx(_),!V())return{success:!1};K(E)}return{success:De.ok}}finally{pn=Math.max(0,pn-1),pn===0&&(V()?Di&&Ln(cn(Di)):K(oe))}}finally{E&&re.delete(E)}},hx=c=>{const h=Lq(c);return fx=h.then(()=>{},()=>{}),h},Gg=jh(is,Ps(c=>eu(c.selection,c.trackChanges)),"trackChanges"),Dq={get:Gg.get,getSnapshot:Gg.getSnapshot,subscribe:Gg.subscribe,observe:Gg.observe,list:()=>{eo();const c=ua().value??is.get().items,h=ln(sn());return c.map(cd).filter(y=>y!=null).filter(y=>{const _=Ur(y);return!_||!h?.has(_)})},accept:c=>Kh("accept",c),acceptAsync:c=>Wg(()=>Kh("accept",c)),reject:c=>Kh("reject",c),rejectAsync:c=>Wg(()=>Kh("reject",c)),acceptAll:()=>au("accept",{kind:"all"},null),acceptAllAsync:()=>Wg(()=>au("accept",{kind:"all"},null)),rejectAll:()=>au("reject",{kind:"all"},null),rejectAllAsync:()=>Wg(()=>au("reject",{kind:"all"},null)),next:()=>Y1(1),previous:()=>Y1(-1),navigateNext:()=>hx(1),navigatePrevious:()=>hx(-1),getAt:c=>{if(!c||typeof c!="object"||typeof c.x!="number"||typeof c.y!="number")return null;const h=e2(c);if(h.length===0)return null;const y=is.get().items;let _;for(const E of h){if(E.type!=="trackedChange")continue;let D;if(E.story){if(_===void 0&&(_=mi()),!_)continue;D=_}else D=y;const V=D.find(ne=>Ti(ne,E.id,E.story));if(V)return E.story?{id:V.id,item:V,story:E.story}:{id:V.id,item:V}}return null},setActive:c=>{if(c==null)return ae(null),K(null),$t(),!0;if(!b())return!1;const h=typeof c=="string"?{id:c}:{id:c.id,story:c.story};if(typeof h.id!="string"||h.id.length===0)return!1;const y=h.id;if(h.story){const _=mi();if(!_)return!1;const E=Fl(_,h.story).toPublicId(h.id)??h.id;if(!_.some(D=>Ti(D,E,h.story)))return!1;h.id=E}else{const _=mi()??is.get().items,E=ta(_).toPublicId(h.id)??h.id,D=_.find(V=>Ur(V)===E);if(!D)return!1;h.id=E,h.story=th(D)}return y!==h.id&&(h.paintedEntityId=y),ae(h),K(h),$t(),!0},scrollTo:async c=>{if(!M())return{success:!1,ok:!1,reason:b()?tt.documentApiUnavailable:tt.notReady};const h=typeof c=="string"?c:c.id,y=typeof c=="string"||!c.story||typeof c.story!="object"?void 0:c.story,_=y?th({address:{story:y}}):void 0;if(typeof h!="string"||h.length===0)return{success:!1,ok:!1,reason:tt.targetUnresolved};Q+=1,I+=1;const E=I,D=y?mi()??is.get().items:is.get().items,V=y?Fl(D,y).toPublicId(h)??h:ta(D).toPublicId(h)??h,ne=y?D.find(Ye=>Ti(Ye,V,y)):D.find(Ye=>Ur(Ye)===V),le=y?_:th(ne),xe=lx(ne),je=oe,De={id:V,...le?{story:le}:{},...V!==h?{paintedEntityId:h}:{}};re.add(De);try{const Ye=await $g("trackChanges",V,D,le||y?{story:le,matchStory:y}:void 0);if(I!==E)return{success:!1,ok:!1};if(!Ye)return{success:!1,ok:!1,reason:tt.targetUnresolved};ae(De);const Ze=I,Xe=oe,Ge=we,rt=()=>I===Ze&&oe===Xe&&we===Ge,lt=()=>{rt()&&(ae(je,{invalidateQueuedNavigation:!1}),$t())};$t(),pn+=1;try{const We=await cx(V,Ye,le,xe,{behavior:"auto",shouldContinue:rt});if(!rt())return{success:!1,ok:!1};if(!We.ok&&We.reason!==tt.targetNotVisible)lt(),K(je);else{if(We.ok&&await dx(V),!rt())return{success:!1,ok:!1};K(De)}return We}finally{pn=Math.max(0,pn-1),pn===0&&(rt()?Di&&Ln(cn(Di)):K(oe))}}finally{re.delete(De)}}},Kh=(c,h)=>{const{id:y,story:_}=typeof h=="string"?{id:h,story:void 0}:h;if(typeof y!="string"||y.length===0)return!1;const E={kind:"id",id:y,..._?{story:_}:{}};return au(c,E,y,_)},Wg=c=>(kt=null,$o=Promise.resolve(!1),N||c()===!1?Promise.resolve(!1):$o),au=(c,h,y,_)=>{try{return ro(X1(c,h,y,_))}catch{return!1}},X1=(c,h,y,_)=>{if(aa())return!1;const E=M()?.trackChanges,D=h.kind==="all"||h.scope==="all",V=h.kind==="range",ne=h.kind==="ids",le=D?[]:ne&&Array.isArray(h.ids)?h.ids.filter(Ye=>typeof Ye=="string"&&Ye.length>0):y?[y]:[];if(le.length>0&&nu(c,le)||sl({kind:c,scope:D?"all":"id"},E))return!1;if(x){const Ye=T(),Ze=Lt(typeof Ye?.getHandles=="function"?()=>Ye.getHandles():void 0,null)?.trackChanges?.decide;return typeof Ze=="function"?Ze({decision:c,target:h}):!1}const xe=D?`${c}All`:c,je=!V&&!ne&&!_&&E&&typeof E[xe]=="function"?E[xe]:null,De=E&&typeof E.decide=="function"?E.decide:null;return!je&&!De?!1:je?je.call(E,y??{}):De.call(E,{decision:c,target:h})},Kg=Ds(c=>c.contentControls),qh=c=>Kg.get().items.find(h=>h?.id===c)??null,qg=jh(Kg,Ps(c=>(Xr.contentControls>0&&Ie("contentControls"),c.contentControls)),"contentControls"),Oq=(c=>{if(c===void 0)return qg.get();const h=nh(c);return h?qh(h):null}),Fq=os(Kg);let Z1=0,Q1=null;const J1=()=>{Z1+=1;const c=Q1??T();Q1=null,Lt(()=>c?.clearContentControlHighlight?.call(c),void 0)};ou.push(J1);const Nq={clearHighlight:J1,highlight:async c=>{const h=nh(c);if(!h)return{success:!1,reason:"invalid-id"};const y=T(),_=b(),E=M()?.contentControls;if(N||!y||typeof y.highlightContentControl!="function"||typeof E?.list!="function")return{success:!1,reason:"not-ready"};const D=++Z1;Q1=y,Lt(()=>y.cancelContentControlHighlightRequest?.call(y),void 0);const V=()=>N||D!==Z1||_!==b();try{const ne=await E.list.call(E);if(V())return{success:!1,reason:"cancelled"};const le=ne?.items?.find(De=>De.id===h);if(!le)return{success:!1,reason:"not-found"};const xe=zm(le);if(!xe||le.isEmpty)return{success:!1,reason:"not-reachable"};const je=await y.highlightContentControl.call(y,h,xe);return V()?{success:!1,reason:"cancelled"}:je?{success:!0}:{success:!1,reason:"not-reachable"}}catch{return{success:!1,reason:V()?"cancelled":"not-reachable"}}},get:(c=>(c!==void 0&&Dn("api"),Oq(c))),getSnapshot:qg.getSnapshot,subscribe:qg.subscribe,observe:qg.observe,observeActivePath:Fq.observe,list:()=>(Dn("api"),Kg.get().items),getById:c=>(Dn("api"),qh(c)),getRect:c=>{const h=nh(c);if(!h)return Nl("unresolved");Dn("panel");const y=qh(h);if(!y)return Nl("unresolved");const _=zm(y);return _?Jg.getRect({target:_}):Nl("unavailable")},scrollIntoView:async c=>{const h=nh(c);if(!h)return{success:!1};Dn("panel");const y=qh(h);if(!y)return{success:!1};const _=zm(y);return _?{success:(await su(_,{block:c.block,behavior:c.behavior})).ok}:{success:!1}},focus:async c=>{const h=nh(c);if(!h)return{success:!1,reason:"invalid-id"};if(!b())return{success:!1,reason:"not-ready"};Dn("panel");const y=qh(h);if(!y)return{success:!1,reason:"not-found"};const _=zm(y);if(!_)return{success:!1,reason:"not-reachable"};if(!(await su(_,{block:c.block,behavior:c.behavior})).ok)return{success:!1,reason:"not-reachable"};const E=FO(_);if(!E)return{success:!1,reason:"not-reachable"};const D=W1.apply(E);return!D.ok&&D.reason!==tt.hostCapabilityUnavailable?{success:!1,reason:"not-reachable"}:(Iq(h),{success:!0})}},Yg=os(Ds(c=>c.fonts)),px={get:Yg.get,getSnapshot:Yg.getSnapshot,subscribe:Yg.subscribe,observe:Yg.observe,getFamilyOptions:()=>P.fonts.options,getSizeOptions:()=>P.fonts.sizeOptions},Xg=os(Ds(c=>c.zoom)),Bq={get:Xg.get,getSnapshot:Xg.getSnapshot,subscribe:Xg.subscribe,observe:Xg.observe,set:c=>{if(typeof t?.setZoom=="function")try{t.setZoom(c),$t()}catch{}},setMode:c=>{if(typeof t?.setZoomMode=="function")try{t.setZoomMode(c),$t()}catch{}}},Zg=os(Ds(c=>c.document)),zq={get:Zg.get,getSnapshot:Zg.getSnapshot,subscribe:Zg.subscribe,observe:Zg.observe,setMode:c=>{if(typeof t?.setDocumentMode=="function")try{t.setDocumentMode(c),$t()}catch{}},export:c=>{if(typeof t?.export=="function")try{return Promise.resolve(t.export(c))}catch{return}},getText:()=>{const c=M(),h=Lt(c?.getText?()=>c.getText({}):void 0,null);return typeof h=="string"?h:h&&typeof h=="object"&&typeof h.text=="string"?h.text:null},replaceDocument:async c=>{const h=e.superdoc;return typeof h.replaceDocument!="function"?{ok:!1,reason:tt.operationUnavailable}:h.replaceDocument(c)},replaceFile:c=>{const h=t?.replaceFile??t?.loadDocument??t?.reload;if(typeof h=="function")try{return Promise.resolve(h.call(t,c))}catch{return}}},mx=()=>{if(typeof HTMLElement>"u")return null;const c=b()?.mount?.container;if(c instanceof HTMLElement)return c;const h=t?.element;return h instanceof HTMLElement?h:null},jq=(c,h)=>{if(typeof c!="number"||typeof h!="number"||!Number.isFinite(c)||!Number.isFinite(h))return[];const y=globalThis.document;if(!y||typeof y.elementFromPoint!="function")return[];const _=mx();if(!_)return[];const E=y.elementFromPoint(c,h);if(!E||!_.contains(E))return[];const D=[E],V=We=>{We&&_.contains(We)&&!D.includes(We)&&D.push(We)},ne=y.elementsFromPoint;if(typeof ne=="function"){let We=[];try{We=ne.call(y,c,h)??[]}catch{We=[]}for(const wt of We)V(wt)}const le=[],xe=We=>{We&&_.contains(We)&&!le.includes(We)&&!D.includes(We)&&le.push(We)},je=We=>{const wt=We.getBoundingClientRect;if(typeof wt!="function")return!1;let Rt;try{Rt=wt.call(We)}catch{return!1}return Rt!=null&&c>=Rt.left&&c<=Rt.right&&h>=Rt.top&&h<=Rt.bottom};for(const We of D){const wt=We.querySelectorAll;if(typeof wt!="function")continue;let Rt;try{Rt=wt.call(We,"[data-track-change-marker]")}catch{continue}for(let an=0;an<Rt.length;an+=1)je(Rt[an])&&xe(Rt[an])}le.reverse();const De=[...le,...D],Ye=P_(De[0],_);for(let We=1;We<De.length;We+=1)for(const wt of P_(De[We],_))Ye.push(wt);if(Ye.length===0)return Ye;const Ze=is.get().items,Xe=ta(Ze);let Ge;const rt=new Set,lt=[];for(const We of Ye){if(We.type!=="trackedChange"){const un=We.type==="contentControl"?j_(We.story):void 0,En=We.type==="contentControl"?W_(un)?un:V_(We.storyKey)??un:void 0,io=`${We.type}:${We.id}:${JSON.stringify(En??null)}`;if(rt.has(io))continue;if(rt.add(io),We.type==="contentControl"){const{storyKey:Bi,story:as,...wo}=We;lt.push(En?{...wo,story:En}:wo)}else lt.push(We);continue}const wt=V_(We.storyKey)??j_(We.story);let Rt;if(wt){if(Ge===void 0&&(Ge=mi()),!Ge||(Rt=Fl(Ge,wt).toPublicId(We.id),!Rt||!Ge.some(un=>Ti(un,Rt,wt))))continue}else if(Rt=Xe.toPublicId(We.id),!Rt)continue;const an=`trackedChange:${Rt}`;rt.has(an)||(rt.add(an),lt.push(wt?{type:"trackedChange",id:Rt,story:wt}:{type:"trackedChange",id:Rt}))}return lt};function e2(c,h){return typeof c=="object"?jq(c?.x,c?.y):null}function gx(c){const h=!!c&&typeof c.x=="number"&&typeof c.y=="number",y=h?{x:c.x,y:c.y}:{x:0,y:0};return{point:y,entities:h?e2(y):[],selection:P.selection,position:null,insideSelection:!1}}const Vd=new Set;let t2=!1;const vx=c=>{const h=T();if(typeof h?.observeGeometry!="function")return;let y=!1;const _=Lt(()=>{const E=h.observeGeometry(()=>c.schedule());return y=!0,E},null);c.detach=typeof _=="function"?_:null,c.boundHost=y?h:null},Qg=c=>{if(c.detach){try{c.detach()}catch{}c.detach=null}c.boundHost=null},yx=()=>{if(t2=!1,!(N||T()))for(const c of Vd)Qg(c)},Vq=()=>{if(!t2){if(t2=!0,typeof queueMicrotask=="function"){queueMicrotask(yx);return}Promise.resolve().then(yx)}},Uq=()=>{const c=T();if(!c){Vq();return}for(const h of Vd)h.boundHost&&h.boundHost===c||(Qg(h),vx(h),h.schedule())};ul.push(Uq);const Jg={getRect:c=>{const h=T(),y=h?.getTargetRects;if(typeof y=="function"){const _=Lt(()=>y.call(h,{target:c.target}),null);return _&&typeof _=="object"?_.success===!0&&Array.isArray(_.rects)?sF(iF(_.rects.filter(E=>E!=null&&typeof E=="object")),c.relativeTo):Nl(typeof _.reason=="string"?_.reason:"unresolved"):Nl("unresolved")}return Nl("unavailable")},observe:c=>{const h=[];let y=0;const _=typeof requestAnimationFrame=="function",E=()=>{if(!_){c();return}y||(y=requestAnimationFrame(()=>{y=0,c()}))},D=Ps(ne=>({ready:ne.ready,selection:ne.selection,zoom:ne.zoom}));h.push(D.subscribe(()=>E()));const V={schedule:E,detach:null,boundHost:null};return vx(V),Vd.add(V),()=>{Vd.delete(V),Qg(V),y&&typeof cancelAnimationFrame=="function"&&cancelAnimationFrame(y);for(const ne of h.splice(0))try{ne()}catch{}}},getHost:()=>mx(),entityAt:e2,contextAt:gx,scrollIntoView:async c=>{const h=c?.target;if(!h)return{success:!1};let y=null;if(h.kind==="entity"){const _=h.entityType==="comment"?"comments":"trackChanges",E=_==="comments"?jd.get().items:is.get().items,D=h.entityType==="trackedChange"&&h.story?{story:h.story}:void 0;y=await $g(_,h.entityId,E,D)}else{const _=h,E=h,D=Array.isArray(_.segments)&&_.segments.length>0?_.segments:E.blockId&&E.range?[{blockId:E.blockId,range:E.range}]:null;if(D){const V=h.story;y={kind:"text",segments:D,...V?{story:V}:{}}}}return y?{success:(await su(y,{block:c.block??"center",behavior:c.behavior??"smooth"})).ok}:{success:!1}}},bx=c=>{const h=(c&&typeof c=="object"?c:null)?.target;return h&&typeof h=="object"?h:null},wx=c=>`metadata:resolve:${c}`,Yh=()=>{const c=T(),h=typeof c?.getLocalMutationRevision=="function"?Lt(()=>c.getLocalMutationRevision(),null):null;return`${sn()}|local:${typeof h=="number"?h:"unknown"}`},$q=c=>{const h=M()?.metadata;if(!h||typeof h.resolve!="function")return null;const{value:y,status:_}=Eo(wx(c),Yh(),()=>h.resolve({id:c}),bx);return _==="ready"?y:null},Hq=async c=>{const h=M()?.metadata;if(!h||typeof h.resolve!="function")return null;try{const y=Yh(),_=await Promise.resolve(h.resolve({id:c}));if(y!==Yh())return null;const E=bx(_);return Se.set(wx(c),{token:y,value:E,hasSettled:!0,inflightToken:null}),E}catch{return null}},Gq={getRect:c=>{const h=M()?.metadata;if(!h||typeof h.resolve!="function")return Nl("unavailable");const y=$q(c.id);return y?Jg.getRect({target:y}):Nl("unresolved")},scrollIntoView:async c=>{const h=await Hq(c.id);return h?{success:(await su(h,{block:c.block,behavior:c.behavior})).ok}:{success:!1}}},Wq={inTable:!1,tableNodeId:null,rowIndex:null,columnIndex:null,cellNodeId:null,rows:null,columns:null},Kq={getContext:()=>{const c=ft();if(!c)return{...Wq};const h=ct()?.table;return{inTable:!0,tableNodeId:c.tableNodeId,rowIndex:c.rowIndex,columnIndex:c.columnIndex,cellNodeId:c.cellNodeId,rows:typeof h?.rows=="number"?h.rows:null,columns:typeof h?.columns=="number"?h.columns:null}},isInTable:()=>ft()!=null},ev={query:"",total:0,activeIndex:-1,open:!1,available:!1,caseSensitive:!1,includeTrackedDeletions:!1,includeDeletedText:!1,regex:!1,canReplace:!1,canReplaceAll:!1,reason:tt.searchUnavailable};let Yt={...ev};const tv=new Set,va=()=>{const c=T()?.search;return c&&typeof c=="object"?c:null},Fi=()=>{const c=ye()?.search;return c&&typeof c=="object"?c:null},Xh=()=>{const c=va();if(c&&typeof c.setSession=="function")return!0;const h=Fi();return!!h&&typeof h.query=="function"&&typeof h.getState=="function"},Ni=()=>{for(const c of[...tv])try{c(Yt)}catch{}},To=c=>{Yt={...Yt,...c};const h=c.includeTrackedDeletions??c.includeDeletedText;return h!==void 0&&(Yt.includeTrackedDeletions=h,Yt.includeDeletedText=h),Ni(),Yt};let Wn=0,Fs=null,ss=null,lu=null,Ud=null;const Zh=()=>{const c=Ud;Ud=null,c&&Lt(()=>c(),null)},Cx=()=>{const c=lu;lu=null,c&&Lt(()=>(c(),null),null)},qq=()=>{ss=null,Wn+=1,Fs=null,dl=!1,Zh(),Cx();const c=Xh();Yt={...ev,available:c,reason:c?void 0:tt.searchUnavailable},Ni()};ou.push(qq),Nh.push(()=>{if(Fs===Wn)return;const c=Yt,h=Ns();(h.canReplace!==c.canReplace||h.canReplaceAll!==c.canReplaceAll||h.available!==c.available||h.reason!==c.reason)&&Ni()});const Yq=c=>{if(!c)return!1;const h=c.queryError;if(h&&typeof h=="object"&&h.code==="invalid-pattern")return!0;const y=c.rejection;return c.status==="rejected"&&!!y&&typeof y=="object"&&y.code==="invalid-pattern"},n2=(c,h=!1,y=h)=>{const _=c&&typeof c=="object"?c:null;if(!_)return null;const E=Array.isArray(_.matches)?_.matches:[],D=typeof _.total=="number"&&Number.isFinite(_.total)?_.total:E.length,V=typeof _.activeMatchIndex=="number"?_.activeMatchIndex:typeof _.activeIndex=="number"?_.activeIndex:-1,ne=_.canReplace===!0||h;return{...typeof _.query=="string"?{query:_.query}:{},total:D,activeIndex:V,canReplace:ne,canReplaceAll:ne&&D>0&&_.truncated!==!0&&(_.canReplace===!0||y),...typeof _.caseSensitive=="boolean"?{caseSensitive:_.caseSensitive}:{},...typeof _.includeDeletedText=="boolean"?{includeDeletedText:_.includeDeletedText}:{},..._.regex===!0?{regex:!0}:{},...Yq(_)?{invalidPattern:!0}:{}}};let dl=!1;const r2=()=>{if(!dl)return;dl=!1;const c=Fi();c&&typeof c.query=="function"&&Lt(()=>c.query({query:""}),null)},Ro=()=>Fs!==Wn&&ve("find.replace")?.enabled===!0,Mo=()=>Fs!==Wn&&ve("find.replaceAll")?.enabled===!0,oo=(c,h=!1,y=h)=>{const _=n2(c,h,y);if(!_){To({total:0,activeIndex:-1,canReplace:!1,canReplaceAll:!1,reason:void 0});return}To({..._.query!==void 0?{query:_.query}:{},total:_.total,activeIndex:_.activeIndex,canReplace:_.canReplace,canReplaceAll:_.canReplaceAll,..._.includeDeletedText!==void 0?{includeDeletedText:_.includeDeletedText}:{},..._.regex!==void 0?{regex:_.regex}:{},reason:_.invalidPattern?tt.searchInvalidPattern:void 0})},Ns=()=>{const c=va();if(c&&typeof c.getState!="function")return Yt={...Yt,available:Xh(),reason:Xh()?void 0:tt.searchUnavailable},Yt;if(!c){const y=Fi();if(y&&typeof y.getState=="function"){const _=n2(Lt(()=>y.getState(),null),Ro(),Mo());if(Fs===Wn)return Yt;if(_)return Yt={...Yt,..._.query!==void 0?{query:_.query}:{},total:_.total,activeIndex:_.activeIndex,canReplace:_.canReplace,canReplaceAll:_.canReplaceAll,available:!0,reason:_.invalidPattern?tt.searchInvalidPattern:void 0,open:Yt.open||!!_.query},Yt}return Yt={...ev,query:Yt.query,caseSensitive:Yt.caseSensitive,includeTrackedDeletions:Yt.includeTrackedDeletions,includeDeletedText:Yt.includeDeletedText},Yt}const h=n2(Lt(()=>c.getState(),null));return h&&(Yt={...Yt,...h.query!==void 0?{query:h.query}:{},total:h.total,activeIndex:h.activeIndex,canReplace:h.canReplace,canReplaceAll:h.canReplaceAll,...h.includeDeletedText!==void 0?{includeDeletedText:h.includeDeletedText}:{},...h.includeDeletedText!==void 0?{includeTrackedDeletions:h.includeDeletedText}:{},...h.regex!==void 0?{regex:h.regex}:{},available:!0,reason:h.invalidPattern?tt.searchInvalidPattern:void 0,open:Yt.open||!!h.query}),Yt},$d=c=>{const h=c&&typeof c=="object"?c:null;if(h?.status==="committed")return{ok:!0};if(h?.status==="rejected"&&h.reason==="read-only")return{ok:!1,reason:tt.documentReadonly};const y=h?.rejection;if(h?.status==="rejected"&&y&&typeof y=="object"&&y.code==="read-only-document")return{ok:!1,reason:tt.documentReadonly};if(h?.status==="rejected"&&h.reason==="truncated")return{ok:!1,reason:tt.searchTruncated};const _=h?.failure;return h?.status==="receipt-failure"&&_&&typeof _=="object"&&_.code==="REVISION_MISMATCH"?{ok:!1,reason:tt.targetUnresolved}:{ok:!1,reason:tt.operationUnavailable}},kx=c=>{const h=Wn;return Ns(),Ni(),kr(c)?Promise.resolve(c).then(y=>(h===Wn&&(Ns(),Ni()),$d(y)),()=>(h===Wn&&To({available:!1,reason:tt.searchUnavailable}),{ok:!1,reason:tt.searchUnavailable})):$d(c)},nv=os({get:()=>Ns(),subscribe:c=>(tv.add(c),()=>tv.delete(c))}),Sx={get:nv.get,getSnapshot:nv.getSnapshot,subscribe:nv.subscribe,observe:nv.observe,open:()=>Xh()?(To({available:!0,open:!0,reason:void 0}),{ok:!0}):(To({available:!1,open:!1,reason:tt.searchUnavailable}),{ok:!1,reason:tt.searchUnavailable}),close:()=>{if(ss=null,Wn+=1,Zh(),lu)Cx();else{const c=va();if(c&&typeof c.clear=="function")Lt(()=>c.clear(),null);else{const h=Fi();h&&typeof h.query=="function"&&Lt(()=>h.query({query:""}),null)}}Yt={...ev,available:Xh(),reason:void 0},Yt.available||(Yt.reason=tt.searchUnavailable),Ni()},find:(c,h)=>{const y=va(),_=!!h?.caseSensitive,E=(h?.includeTrackedDeletions??h?.includeDeletedText)===!0,D=h?.regex===!0;if((!y||typeof y.setSession!="function")&&ss!==null&&ss===Fi()&&Fs!==Wn&&Bs===null&&Yt.open&&Yt.available&&!Yt.reason&&Yt.query===c&&Yt.caseSensitive===_&&Yt.includeDeletedText===E&&Yt.regex===D)return Ns(),Ni(),Yt;ss=null,Bs!==null&&(clearTimeout(Bs),Bs=null);const V=++Wn;if(Zh(),r2(),!y||typeof y.setSession!="function"){const le=Fi();if(le&&typeof le.query=="function"&&typeof le.getState=="function"){Fs=V,To({query:c,caseSensitive:_,includeDeletedText:E,regex:D,total:0,activeIndex:-1,canReplace:!1,canReplaceAll:!1,available:!0,open:!0,reason:void 0}),lu=()=>{le.query({query:""})};const xe=Lt(()=>le.query({query:c,caseSensitive:_,includeDeletedText:E,regex:D}),null);return kr(xe)?(dl=!0,Promise.resolve(xe).then(je=>{V===Wn&&(dl=!1,Fs=null,ss=le,oo(je,Ro(),Mo()))},()=>{V===Wn&&(dl=!1,To({available:!1,reason:tt.searchUnavailable}))}),Yt):(Fs=null,ss=le,oo(xe,Ro(),Mo()),oo(Lt(()=>le.getState(),null),Ro(),Mo()),Yt)}return To({query:c,total:0,activeIndex:-1,available:!1,caseSensitive:_,includeDeletedText:E,regex:D,reason:tt.searchUnavailable})}To({query:c,caseSensitive:_,includeDeletedText:E,regex:D,available:!0,open:!0,reason:void 0}),lu=()=>{typeof y.clear=="function"&&y.clear()};const ne=Lt(()=>y.setSession(c,{caseSensitive:_,includeDeletedText:E,...D?{regex:!0}:{},highlight:!0}),null);if(oo(ne),c.length>0&&Yt.total===0&&Yt.reason!==tt.searchInvalidPattern){const le=Fi();if(le&&typeof le.query=="function"&&typeof le.getState=="function"){const xe=lu;lu=()=>{xe?.(),le.query({query:""})};const je=Lt(()=>le.query({query:c,caseSensitive:_,includeDeletedText:E,regex:D}),null);kr(je)?(dl=!0,Promise.resolve(je).then(De=>{V===Wn&&(dl=!1,oo(De,Ro(),Mo()))},()=>{V===Wn&&(dl=!1,To({available:!1,reason:tt.searchUnavailable}))})):oo(je,Ro(),Mo()),oo(Lt(()=>le.getState(),null),Ro(),Mo())}}return Yt},search:(c,h)=>Sx.find(c,h),next:()=>{const c=va();if(!c||typeof c.next!="function"){const h=Fi();if(!h||typeof h.next!="function"||typeof h.getState!="function")return{ok:!1,reason:tt.searchUnavailable};if(Yt.total===0)return{ok:!1,reason:tt.operationUnavailable};const y=Lt(()=>h.next(),null);if(kr(y)){const _=Wn;Promise.resolve(y).then(E=>{_===Wn&&oo(E,Ro(),Mo())}).catch(()=>{_===Wn&&To({available:!1,reason:tt.searchUnavailable})})}else oo(y,Ro(),Mo());return oo(Lt(()=>h.getState(),null),Ro(),Mo()),{ok:!0}}return Yt.total===0?{ok:!1,reason:tt.operationUnavailable}:(oo(Lt(()=>c.next(),null)),{ok:!0})},previous:()=>{const c=va();if(!c||typeof c.previous!="function"){const h=Fi();if(!h||typeof h.previous!="function"||typeof h.getState!="function")return{ok:!1,reason:tt.searchUnavailable};if(Yt.total===0)return{ok:!1,reason:tt.operationUnavailable};const y=Lt(()=>h.previous(),null);if(kr(y)){const _=Wn;Promise.resolve(y).then(E=>{_===Wn&&oo(E,Ro(),Mo())}).catch(()=>{_===Wn&&To({available:!1,reason:tt.searchUnavailable})})}else oo(y,Ro(),Mo());return oo(Lt(()=>h.getState(),null),Ro(),Mo()),{ok:!0}}return Yt.total===0?{ok:!1,reason:tt.operationUnavailable}:(oo(Lt(()=>c.previous(),null)),{ok:!0})},clear:()=>{ss=null,Wn+=1,Zh(),r2();const c=va();if(c&&typeof c.clear=="function"&&Lt(()=>c.clear(),null),!c||typeof c.clear!="function"){const h=Fi();h&&typeof h.query=="function"&&Lt(()=>h.query({query:""}),null)}To({query:"",total:0,activeIndex:-1,canReplace:!1,canReplaceAll:!1,reason:void 0})},replace:c=>{const h=va();if(!h){const _=Fi();if(!_||typeof _.replace!="function"||typeof _.getState!="function")return{ok:!1,reason:tt.searchUnavailable};if(!Ro())return{ok:!1,reason:tt.operationUnavailable};const E=Lt(()=>_.replace({replacement:typeof c=="string"?c:""}),null);if(kr(E)){const D=Wn;Ns(),Ni();const V=()=>D===Wn;return Promise.resolve(E).then(ne=>(V()&&(oo(ne,Ro(),Mo()),Ns(),Ni()),$d(ne)),()=>(V()&&To({available:!1,reason:tt.searchUnavailable}),{ok:!1,reason:tt.searchUnavailable}))}return Ns(),Ni(),$d(E)}if(typeof h.replaceCurrent!="function")return{ok:!1,reason:tt.operationUnavailable};const y=Lt(()=>h.replaceCurrent(typeof c=="string"?c:""),null);return kx(y)},replaceAll:c=>{const h=va();if(!h){const _=Fi();if(!_||typeof _.replaceAll!="function"||typeof _.getState!="function")return{ok:!1,reason:tt.searchUnavailable};if(!Mo())return{ok:!1,reason:ve("find.replaceAll")?.reason==="search-truncated"?tt.searchTruncated:tt.operationUnavailable};const E=Lt(()=>_.replaceAll({replacement:typeof c=="string"?c:""}),null);if(kr(E)){const D=Wn;Ns(),Ni();const V=()=>D===Wn;return Promise.resolve(E).then(ne=>(V()&&(oo(ne,Ro(),Mo()),Ns(),Ni()),$d(ne)),()=>(V()&&To({available:!1,reason:tt.searchUnavailable}),{ok:!1,reason:tt.searchUnavailable}))}return Ns(),Ni(),$d(E)}if(typeof h.replaceAll!="function")return{ok:!1,reason:tt.operationUnavailable};const y=Lt(()=>h.replaceAll(typeof c=="string"?c:""),null);return kx(y)}};let Bs=null;Ls=()=>{if(ss=null,Bs!==null&&clearTimeout(Bs),!Yt.open||!Yt.query)return;const c=Wn;Bs=setTimeout(()=>{if(Bs=null,N||c!==Wn||!Yt.open||!Yt.query)return;const h={query:Yt.query,caseSensitive:Yt.caseSensitive,includeDeletedText:Yt.includeDeletedText,regex:Yt.regex},y=Fi(),_=va();if(typeof y?.refresh!="function"&&typeof _?.refresh!="function")return;const E=++Wn;if(r2(),typeof y?.refresh=="function"&&typeof y.query=="function"){const V=y;Ud=()=>{V.query({query:""})}}const D=typeof y?.refresh=="function"?Lt(()=>y.refresh(h),null):Lt(()=>_.refresh(),null);kr(D)?(Fs=E,To({canReplace:!1,canReplaceAll:!1}),Promise.resolve(D).then(V=>{E!==Wn||N||(Ud=null,Fs=null,ss=y,oo(V,Ro(),Mo()))},()=>{E!==Wn||N||(Ud=null,To({available:!1,reason:tt.searchUnavailable}))})):D!==null&&(Ud=null,ss=y,oo(D))},120)};const _x=Ds(c=>c.styles),rv=os(_x),Xq={get:rv.get,getSnapshot:rv.getSnapshot,subscribe:rv.subscribe,observe:rv.observe,getCatalog:c=>(Ie(Ts(c)),ma(c).value),getQuickGallery:()=>_x.get().quickGallery,getActiveParagraphStyle:()=>ga(P.selection,Pi().cache).style},ov=B9({getEditor:b,getMode:Xn,getFonts:()=>px.getFamilyOptions(),getContainer:()=>t.element??null,openSurface:typeof t.openSurface=="function"?c=>t.openSurface(c):null});ou.push(ov.close),Nh.push(ov.close);const iv={select:Ps,get state(){return P},selection:W1,commands:Eq,toolbar:xq,comments:Mq,trackChanges:Dq,contentControls:Nq,bookmarks:Tq,fonts:px,zoom:Bq,document:zq,viewport:Jg,metadata:Gq,tables:Kq,search:Sx,contextMenu:k,watermark:ov,styles:Xq,formatPainter:{setPointerSelecting(c){N||(p={...p,pointerSelecting:c})},notifyPointerUp(){N||(p={...p,pointerSelecting:!1},ox())},setKeyboardSelecting(c){N||(p={...p,keyboardSelecting:c})},notifyKeyUp(){N||(p={...p,keyboardSelecting:!1},ox())},cancel(){N||Bg()},onModeChange(c){return N?()=>{}:(v.add(c),()=>v.delete(c))}},createScope:()=>{const c=[];return{select:(h,y)=>{const _=Ps(h,y);return{get:_.get,subscribe:E=>{const D=_.subscribe(E);return c.push(D),D}}},dispose:()=>{for(const h of c.splice(0))h()}}},destroy:()=>{if(!N){ov.destroy(),J1(),N=!0,ss=null,Bs!==null&&clearTimeout(Bs),Bs=null,Zh(),IO(qn,Bn),Mt&&(clearTimeout(Mt),Mt=null),mt&&(clearTimeout(mt),mt=null,Ot=0),Ke?.timer&&(clearTimeout(Ke.timer),Ke.timer=null),Ke=null,Qt&&(clearTimeout(Qt),Qt=null),Jo&&(clearTimeout(Jo),Jo=null),lr&&lr(),lr=null,jo=null;for(const c of Object.keys(Xr))Xr[c]=0;Bo.clear(),Io.clear(),Xi.clear(),Zo=null,Re.clear();for(const c of zh.splice(0))c();vi&&vi(),vi=null,ts=null,yi&&yi(),yi=null,Ms=null,ns&&ns(),ns=null,bi=null,ti&&ti(),ti=null,Di=null,q&&q(),q=null,B=null,be&&be(),be=null,Ee=null;for(const c of Vd)Qg(c);Vd.clear(),ke.clear(),tv.clear(),g+=1,m=null,v.clear(),Wn+=1,It.clear()}}};return me=iv,O_.set(iv,Sq),F_.set(iv,dq),iv}var pF=[{value:"Arial",label:"Arial",previewFamily:"Arial, sans-serif"},{value:"Calibri",label:"Calibri",previewFamily:"Calibri, sans-serif"},{value:"Courier New",label:"Courier New",previewFamily:'"Courier New", monospace'},{value:"Georgia",label:"Georgia",previewFamily:"Georgia, serif"},{value:"Times New Roman",label:"Times New Roman",previewFamily:'"Times New Roman", serif'},{value:"Verdana",label:"Verdana",previewFamily:"Verdana, sans-serif"}];function mF(e){const t=e.trim(),n=t[0];if(n==='"'||n==="'"){const o=t.indexOf(n,1);if(o>0)return t.slice(1,o).trim()}const r=t.indexOf(",");return(r===-1?t:t.slice(0,r)).trim().replace(/^["']|["']$/g,"")}function gF(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||typeof n!="object")continue;const r=n,o=typeof r.logicalFamily=="string"?mF(r.logicalFamily):"";if(!o)continue;const i=typeof r.previewFamily=="string"&&r.previewFamily.trim()?r.previewFamily.trim():o;t.push({value:o,label:o,previewFamily:i})}return t}function vF(e){if(!Array.isArray(e))return[];const t=[];for(const n of e){if(!n||typeof n!="object")continue;const r=n,o=typeof r.value=="string"?r.value.trim():"";if(!o)continue;const i=typeof r.label=="string"&&r.label.trim()?r.label.trim():o,s=typeof r.previewFamily=="string"&&r.previewFamily.trim()?r.previewFamily.trim():o;t.push({value:o,label:i,previewFamily:s})}return t}function yF(e,t=[]){const n=[],r=new Set,o=s=>{const a=String(s.value).trim().toLowerCase();!a||r.has(a)||(r.add(a),n.push(s))};for(const s of e)o(s);const i=t.length?t:pF;for(const s of i)o(s);return n}var bF=[{value:"8",label:"8"},{value:"9",label:"9"},{value:"10",label:"10"},{value:"11",label:"11"},{value:"12",label:"12"},{value:"14",label:"14"},{value:"16",label:"16"},{value:"18",label:"18"},{value:"24",label:"24"},{value:"36",label:"36"}];function wF(e,t){return e.activeMark?t.activeMarks.includes(e.activeMark):!1}var CF=e=>!!e?.trackedChange,kF=e=>e,SF=(e,t,n,r=e)=>!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n)?!1:(Number.isFinite(r)?r:e)<t||e>n,_F=({comment:e,anchorTop:t,anchorBottom:n,viewportTop:r,viewportBottom:o})=>CF(e)&&SF(t,r,o,n),AF=({comment:e,anchorTop:t,anchorBottom:n,cardHeight:r,viewportTop:o,viewportBottom:i})=>!_F({comment:e,anchorTop:t,anchorBottom:n,viewportTop:o,viewportBottom:i})||!Number.isFinite(r)?null:(Number.isFinite(n)?n:t)<o?Math.min(t,o-r-1):t,IF=({id:e,visibleIds:t,activeCommentInstanceId:n})=>e?!!(e==="pending"||n!=null&&String(e)===String(n)||t?.has?.(e)):!1,nA=({previousIds:e,currentIds:t,removedId:n})=>{if(!Array.isArray(e)||!(t instanceof Set)||!n)return null;const r=e.indexOf(n);if(r<0)return null;for(let o=r+1;o<e.length;o+=1){const i=e[o];if(t.has(i))return i}for(let o=r-1;o>=0;o-=1){const i=e[o];if(t.has(i))return i}return null};Ft(),yn();var EF=["data-comment-id","data-comment-instance-id","data-comment-thread-id","data-comment-position-key","data-comment-page-index"],Oc={},xF={__name:"FloatingComments",props:{currentDocument:{type:Object,required:!0},parent:{type:Object,required:!0}},setup(e){const r=new Set(["auto","scroll","hidden","clip"]),o=(Te,Ne,Qe)=>{if(Ne>=0){Te[Ne].top=Te[Ne].anchorTop;let bt=Te[Ne].top+Te[Ne].height+Qe;for(let Dt=Ne+1;Dt<Te.length;Dt++)Te[Dt].top=Math.max(Te[Dt].anchorTop,bt),bt=Te[Dt].top+Te[Dt].height+Qe;bt=Te[Ne].top-Qe;for(let Dt=Ne-1;Dt>=0;Dt--){const kn=bt-Te[Dt].height;Te[Dt].top=Math.min(Te[Dt].anchorTop,kn),bt=Te[Dt].top-Qe}const Nt=Math.min(...Te.map(Dt=>Dt.top));if(Nt<0){const Dt=Math.abs(Nt);for(const kn of Te)kn.top+=Dt}}else for(let bt=1;bt<Te.length;bt++){const Nt=Te[bt-1],Dt=Nt.top+Nt.height+Qe;Te[bt].top<Dt&&(Te[bt].top=Dt)}},i=e,s=Xu(),a=Js(),{clearInstantSidebarAlignment:l}=a,{activeComment:u,activeFloatingCommentInstanceId:d,editorCommentPositions:f,pendingComment:p,editingCommentId:g,instantSidebarAlignmentTargetY:m,instantSidebarAlignmentThreadId:v,instantSidebarAlignmentInstanceId:C}=qs(a),{activeZoom:w}=qs(s),S=_e(()=>{const Te=a.getFloatingCommentInstances;if(!Array.isArray(Te))return[];const Ne=i.currentDocument?.id;return Ne==null?Te:Te.filter(Qe=>a.belongsToDocument(Qe.comment,String(Ne),{allowSingleDocumentMismatch:!0}))}),b=te(null),k=te(0),x=te(0),M=te(!1),z=te(null),G=te(0),F=Te=>{const Ne=p.value?.commentId;return Ne?typeof Te=="object"?Te?.commentId===Ne:Te===Ne||Te==="pending":!1},L=Te=>Te?.commentId??Te?.importedId??null,$=_e(()=>{const Te=new Map,Ne=new Map;for(const Qe of S.value){Qe?.id!=null&&Te.set(String(Qe.id),Qe);const bt=L(Qe?.comment);if(bt==null)continue;const Nt=String(bt),Dt=Ne.get(Nt)??[];Dt.push(Qe),Ne.set(Nt,Dt)}return{byId:Te,byThreadId:Ne}}),T=(Te,Ne=null)=>{if(Te==null)return null;const Qe=String(Te),bt=$.value.byThreadId.get(Qe)??[];if(!bt.length)return null;if(Ne!=null){const Nt=bt.find(Dt=>String(Dt.id)===String(Ne));if(Nt)return Nt.id}return bt.find(Nt=>Nt.isPrimary)?.id??bt[0]?.id??null},H=_e(()=>u.value?T(u.value,d.value):null),R=Te=>{if(typeof Te=="number")return Number.isFinite(Te)?Te:null;if(typeof Te!="string"||Te.trim()==="")return null;const Ne=Number(Te);return Number.isFinite(Ne)?Ne:null},U=te({...Oc}),W=te(new Set),ee=te({});let J=null;const Z=new Set;let Me=null;const fe=()=>{Me==null&&(Me=requestAnimationFrame(()=>{Me=null,G.value+=1}))},ye=Te=>{if(i.currentDocument.type==="application/pdf"){const Ne=(w.value??100)/100,Qe=R(Te?.comment?.selection?.selectionBounds?.top);return Qe==null?null:Qe*Ne}return Te?.positionEntry?.bounds?.top},ve=(Te,Ne)=>{if(i.currentDocument.type==="application/pdf"){const bt=(w.value??100)/100,Nt=R(Te?.comment?.selection?.selectionBounds?.bottom);return Nt!=null?Nt*bt:Ne}const Qe=Te?.positionEntry?.bounds?.bottom;return Number.isFinite(Qe)?Qe:Ne},Pe=_e(()=>{const Te=[];for(const Ne of S.value){const Qe=Ne?.id,bt=L(Ne?.comment),Nt=ye(Ne);if(Qe==null||bt==null||!Number.isFinite(Nt))continue;const Dt=kF(Nt,Ne.comment);Te.push({id:Qe,threadId:bt,instance:Ne,top:Dt,anchorBottom:ve(Ne,Dt)})}return Te}),Ve=()=>{const Te=f.value.pending;if(typeof Te?.bounds?.top=="number"&&!isNaN(Te.bounds.top))return Te.bounds.top;const Ne=i.currentDocument.type==="application/pdf"?(w.value??100)/100:1,Qe=R(p.value?.selection?.selectionBounds?.top);return Qe==null?null:Qe*Ne},nt=Te=>IF({id:Te?.id,visibleIds:W.value,activeCommentInstanceId:H.value,comment:Te?.commentRef}),ct=()=>{const Te=b.value;if(!Te)return null;const Ne=Te.getBoundingClientRect();if(!Number.isFinite(Ne.top)||!Number.isFinite(window.innerHeight))return null;let Qe=0,bt=window.innerHeight;for(let Dt=Te.parentElement;Dt;Dt=Dt.parentElement){const kn=window.getComputedStyle(Dt).overflowY;if(!["auto","scroll","hidden","clip"].includes(kn))continue;const Ht=Dt.getBoundingClientRect();!Number.isFinite(Ht.top)||!Number.isFinite(Ht.bottom)||(Qe=Math.max(Qe,Ht.top),bt=Math.min(bt,Ht.bottom))}if(bt<=Qe)return null;const Nt=i.parent?.getBoundingClientRect?.();if(Nt&&Number.isFinite(Nt.top)&&Number.isFinite(Nt.bottom)){const Dt=Math.max(Qe,Nt.top),kn=Math.min(bt,Nt.bottom);kn>Dt&&(Qe=Dt,bt=kn)}return{top:Qe-Ne.top,bottom:bt-Ne.top}},ft=_e(()=>v.value?T(v.value,C.value):null),It=_e(()=>{G.value;const Te=Pe.value,Ne=p.value&&p.value.fileId===i.currentDocument.id;if(!Te.length&&!S.value.length&&!Ne)return[];const Qe=[],bt=ct()??{top:0,bottom:Math.max(0,i.parent?.clientHeight||window.innerHeight||0)},Nt=bt.top-600,Dt=bt.bottom+600,kn=Ne?"pending":H.value,Ht=new Set,In=({id:dn,threadId:sr,instance:ar,top:No,anchorBottom:ln,hasAnchorGeometry:Mn})=>{const Jn=String(dn);Ht.has(Jn)||(Ht.add(Jn),Qe.push({id:dn,threadId:sr,pageIndex:ar?.pageIndex??null,anchorTop:No,anchorBottom:ln,hasAnchorGeometry:Mn,top:No,height:U.value[dn]||110,commentRef:ar.comment,instanceRef:ar}))};for(const dn of Te){const{id:sr,threadId:ar,instance:No,top:ln,anchorBottom:Mn}=dn,Jn=kn!=null&&String(sr)===String(kn),Yr=g.value!=null&&String(ar)===String(g.value);!Jn&&!Yr&&(Mn<Nt||ln>Dt)||In({id:sr,threadId:ar,instance:No,top:ln,anchorBottom:Mn,hasAnchorGeometry:!0})}const sn=[];if(kn&&kn!=="pending"){const dn=$.value.byId.get(String(kn));dn&&sn.push(dn)}if(g.value!=null){const dn=$.value.byThreadId.get(String(g.value))??[],sr=dn.find(ar=>ar.isPrimary)??dn[0];sr&&sn.push(sr)}for(const dn of sn){const sr=dn.id,ar=L(dn.comment);sr==null||ar==null||Ht.has(String(sr))||In({id:sr,threadId:ar,instance:dn,top:bt.top,anchorBottom:bt.top,hasAnchorGeometry:!1})}if(Ne){const dn=Ve();typeof dn=="number"&&!isNaN(dn)&&Qe.push({id:"pending",anchorTop:dn,anchorBottom:dn,hasAnchorGeometry:!0,top:dn,height:U.value.pending||110,commentRef:p.value})}Qe.sort((dn,sr)=>dn.anchorTop-sr.anchorTop);const Ao=[];for(const dn of Qe){const sr=dn.hasAnchorGeometry?AF({comment:dn.commentRef,anchorTop:dn.anchorTop,anchorBottom:dn.anchorBottom,cardHeight:dn.height,viewportTop:bt.top,viewportBottom:bt.bottom}):null;sr==null?Ao.push(dn):(dn.top=sr,dn.isOffscreenReviewCard=!0)}const qi=kn?Ao.findIndex(dn=>dn.id===kn):-1;return o(Ao,qi,15),Qe}),Le=_e(()=>(G.value,Math.max(0,i.parent?.clientHeight||0,i.parent?.scrollHeight||0))),oe=()=>{J&&J.disconnect(),J=new IntersectionObserver(Te=>{const Ne=new Set(W.value);for(const Qe of Te){const bt=Qe.target.dataset.commentId;bt&&(Qe.isIntersecting?Ne.add(bt):Ne.delete(bt))}W.value=Ne},{rootMargin:"600px 0px 600px 0px"})},we=()=>{if(!J)return;const Te=new Set;for(const Ne of It.value){const Qe=ee.value[Ne.id];Qe&&(Te.add(Qe),Z.has(Qe)||(J.observe(Qe),Z.add(Qe)))}for(const Ne of Z)Te.has(Ne)||(J.unobserve(Ne),Z.delete(Ne))},Q=(Te,Ne)=>{Ne<=0||Ne===U.value[Te]||(Oc[Te]=Ne,U.value={...U.value,[Te]:Ne})},I=Te=>{if(!Te)return;const{elementRef:Ne,commentId:Qe}=Te;Ne&&Ct(()=>{const bt=Ne.value?.getBoundingClientRect();!bt||bt.height<=0||Qe&&Q(Qe,bt.height)})},re=Te=>{const Ne=Te?.id;Ne&&Ct(()=>{const Qe=ee.value[Ne];if(!Qe)return;const bt=Qe.querySelector(".comments-dialog");if(!bt)return;Q(Ne,bt.getBoundingClientRect().height);const Nt=Ne===H.value,Dt=Ne==="pending",kn=!!g.value&&!!u.value&&Te?.threadId!=null&&String(Te.threadId)===String(u.value);!Nt&&!Dt&&!kn||(Qt(It.value.map(Ht=>Ht.id)),jn(()=>It.value.map(Ht=>Ht.id)))})},j=Te=>{!Te&&z.value!=null||(M.value=Te)},X=(Te,Ne,Qe)=>{if(!Number.isFinite(Ne)){Qe?.(!1);return}const bt=ee.value[Te];if(!bt){Qe?.(!1);return}const Nt=bt.getBoundingClientRect().top;x.value+=Ne-Nt,Qe?.(!0)},K=(Te,Ne)=>{if(Ne)ee.value[Te]=Ne,J&&!Z.has(Ne)&&(J.observe(Ne),Z.add(Ne));else{const Qe=ee.value[Te];Qe&&J&&(J.unobserve(Qe),Z.delete(Qe)),delete ee.value[Te]}};let ae=[],ke=null,P=[],N=null,me=!1,Se=0,Re=null,ze=null,Ke=null,ot=null,mt=null;const Ot=new Set,Mt=()=>{Ke=null,ot=null,z.value=null,j(!1)},Kt=Te=>{if(!Ke)return;const Ne=(Te?.target instanceof Element?Te.target:null)?.closest?.("[data-comment-action]"),Qe=Ne?.getAttribute?.("data-comment-action");(Qe==="resolve"||Qe==="reject")&&b.value?.contains?.(Ne)||Mt()},$e=()=>{ae.forEach(clearTimeout),ae=[]},Qt=Te=>{for(const Ne of Te.filter(Boolean)){const Qe=ee.value[Ne];if(!Qe)continue;const bt=Qe.querySelector(".comments-dialog");bt&&Q(Ne,bt.getBoundingClientRect().height)}},Hn=50,qt=350,jn=Te=>{$e();const Ne=typeof Te=="function"?Te:()=>Te;ae.push(setTimeout(()=>Qt(Ne()),Hn)),ae.push(setTimeout(()=>Qt(Ne()),qt))},Pn=()=>{l(),requestAnimationFrame(()=>{j(!1)})},$r=(Te,Ne)=>{!Te||!Number.isFinite(Ne)||(j(!0),Ct(()=>{Qt([Te]),X(Te,Ne,()=>{Pn()})}))},Nr=()=>{N=null,Se+=1,Re!=null&&(cancelAnimationFrame(Re),Re=null),j(!1)},_r=()=>{!Ke&&!N||(Mt(),Nr(),j(!0),x.value=0,mt!=null&&cancelAnimationFrame(mt),mt=requestAnimationFrame(()=>{mt=null,!Ke&&!N&&j(!1)}))},Tn=()=>{_r(),fe()},tr=()=>{const Te=Ne=>{!Ne?.addEventListener||Ot.has(Ne)||(Ne.addEventListener("scroll",Tn,{passive:!0}),Ot.add(Ne))};Te(i.parent);for(let Ne=b.value?.parentElement;Ne;Ne=Ne.parentElement)r.has(window.getComputedStyle(Ne).overflowY)&&Te(Ne);Te(window)},qn=()=>{for(const Te of Ot)Te.removeEventListener?.("scroll",Tn);Ot.clear()},Bn=()=>{if(!N||me)return;me=!0;const Te=Se;Re!=null&&(cancelAnimationFrame(Re),Re=null),j(!0),Ct(()=>{if(me=!1,Te!==Se){Bn();return}const{key:Ne,targetClientY:Qe}=N;Qt([Ne]),X(Ne,Qe,bt=>{if(Te===Se){if(!bt){j(!1);return}Re=requestAnimationFrame(()=>{Re=null,Te===Se&&j(!1)})}})})},st=(Te,Ne)=>{const Qe=nA({previousIds:P,currentIds:Ne,removedId:Te}),bt=(Qe?ee.value[Qe]:null)?.getBoundingClientRect?.().top;return!Qe||!Number.isFinite(bt)?(Nr(),!1):(N={key:Qe,targetClientY:bt},Se+=1,Bn(),!0)},_t=Te=>{const Ne=Te?.target?.closest?.("[data-comment-action]"),Qe=Ne?.getAttribute?.("data-comment-action");if(Qe!=="resolve"&&Qe!=="reject"||(Mt(),Ne.getAttribute?.("aria-disabled")==="true"))return;const bt=Ne.closest?.("[data-comment-id]")?.getAttribute?.("data-comment-id");if(!bt||String(H.value??"")===String(bt))return;const Nt=It.value.filter(Ht=>Ht.commentRef?.trackedChange).map((Ht,In)=>({id:Ht.id,index:In,top:Ht.top})).filter(Ht=>Number.isFinite(Ht.top)).sort((Ht,In)=>Ht.top-In.top||Ht.index-In.index).map(Ht=>Ht.id),Dt=nA({previousIds:Nt,currentIds:new Set(Nt),removedId:bt}),kn=(Dt?ee.value[Dt]:null)?.getBoundingClientRect?.().top;!Dt||!Number.isFinite(kn)||(Ke={removedKey:bt,targetKey:Dt,targetClientY:kn,applied:!1},ot=bt,z.value=Dt,j(!0))};jt(H,(Te,Ne)=>{if($e(),!(Ke!=null&&ot!=null&&[Te,Ne].some(Nt=>Nt!=null&&String(Nt)===String(ot)))){if(ot=null,Te)Mt(),Nr();else if(Ne){const Nt=new Set(It.value.map(Dt=>Dt.id));Nt.has(Ne)?Nr():st(Ne,Nt)}}const Qe=[Te,Ne],bt=Te&&Te===ft.value&&Number.isFinite(m.value);Ct(()=>{if(bt){Qt(Qe);return}jn(Qe)})}),jt([H,ft,m],([Te,Ne,Qe])=>{!Te||!Ne||Te!==Ne||!Number.isFinite(Qe)||$r(Te,Qe)}),jt(g,()=>{$e(),Ct(()=>{jn(()=>It.value.map(Te=>Te.id))})}),jt(u,()=>{if(ke&&clearTimeout(ke),!u.value){if(l(),N){Bn();return}j(!1),x.value=0;return}if(!(F(u.value)?p.value:a.getComment(u.value)))return;const Te=F(u.value)?"pending":H.value;if(Te){if(Te===ft.value&&Number.isFinite(m.value)){j(!0);return}Ct(()=>{ke=setTimeout(()=>{const Qe=ee.value[Te];if(!Qe)return;const bt=i.parent?.getBoundingClientRect?.();if(!bt)return;const Nt=It.value.find(In=>In.id===Te),Dt=Te==="pending"?Ve():Nt?.anchorTop;if(typeof Dt!="number"||isNaN(Dt))return;const kn=Qe.getBoundingClientRect().top,Ht=bt.top+Dt;x.value+=Ht-kn},400)})}}),jt(w,()=>{if(i.currentDocument.type==="application/pdf"){for(const Te in Oc)delete Oc[Te];U.value={},k.value+=1}});let gt=new Set,Xt=null,gn=null;return jt(It,Te=>{const Ne=H.value?Te.find(ln=>ln.id===H.value):null,Qe=typeof Ne?.anchorTop=="number"&&Number.isFinite(Ne.anchorTop)?Ne.anchorTop:null,bt=Qe!=null&&Xt!=null&&Math.abs(Qe-Xt)>1,Nt=typeof Ne?.top=="number"&&Number.isFinite(Ne.top)?Ne.top:null,Dt=Nt!=null&&gn!=null&&Math.abs(Nt-gn)>1;bt&&x.value!==0&&!Number.isFinite(m.value)?(x.value=0,j(!1)):Dt&&x.value!==0&&!Number.isFinite(m.value)&&!N&&(j(!0),x.value+=gn-Nt,ze!=null&&cancelAnimationFrame(ze),ze=requestAnimationFrame(()=>{ze=null,!N&&!Number.isFinite(m.value)&&j(!1)})),Xt=Qe,gn=Nt;const kn=Te.map(ln=>ln.id),Ht=new Set(kn);if(Ke&&!Ke.applied&&!Ht.has(Ke.removedKey)){const{targetKey:ln,targetClientY:Mn}=Ke;Ke.applied=!0,Ht.has(ln)&&Number.isFinite(Mn)?(N={key:ln,targetClientY:Mn},Se+=1,Bn()):Mt()}if(Ke?.applied&&!Ht.has(Ke.targetKey)&&Mt(),N&&!Ht.has(N.key)){const ln=N.key;st(ln,Ht)||(j(!1),x.value=0)}const In=new Set(W.value);let sn=!1,Ao=-1/0,qi=1/0;const dn=b.value;if(dn){const ln=dn.getBoundingClientRect();Ao=-ln.top-600,qi=-ln.top+window.innerHeight+600}const sr=new Map(Te.map(ln=>[ln.id,ln]));for(const ln of Ht)if(!In.has(ln)){const Mn=sr.get(ln);(!Mn||Mn.top>=Ao&&Mn.top<=qi)&&(In.add(ln),sn=!0)}for(const ln of In)Ht.has(ln)||(In.delete(ln),sn=!0);sn&&(W.value=In);for(const ln of gt)Ht.has(ln)||delete Oc[ln];const ar=gt.size!==Ht.size||[...gt].some(ln=>!Ht.has(ln)),No=P.length!==kn.length||P.some((ln,Mn)=>ln!==kn[Mn]);if(ar){const ln={};for(const Mn of Ht)Oc[Mn]&&(ln[Mn]=Oc[Mn]);U.value=ln,Ct(()=>{for(const Mn of Te){const Jn=ee.value[Mn.id];if(!Jn)continue;const Yr=Jn.querySelector(".comments-dialog");Yr&&Q(Mn.id,Yr.getBoundingClientRect().height)}})}N&&(ar||No)&&Bn(),gt=Ht,Ct(()=>{P=kn,we()})}),zn(()=>{oe(),tr(),window.addEventListener("resize",fe,{passive:!0}),document.addEventListener("pointerdown",Kt,!0),Ct(we)}),ur(()=>{$e(),ke&&clearTimeout(ke),Mt(),Nr(),ze!=null&&(cancelAnimationFrame(ze),ze=null),mt!=null&&(cancelAnimationFrame(mt),mt=null),qn(),window.removeEventListener("resize",fe),document.removeEventListener("pointerdown",Kt,!0),Me!=null&&(cancelAnimationFrame(Me),Me=null),J&&(J.disconnect(),J=null,Z.clear())}),(Te,Ne)=>(pe(),Ce("div",{class:"section-wrapper",ref_key:"floatingCommentsContainer",ref:b,onClickCapture:_t,style:An({minHeight:Le.value+"px",transition:M.value?"none":void 0})},[ce("div",{class:"sidebar-container",style:An({transform:`translateY(${x.value}px)`,transition:M.value?"none":void 0})},[(pe(!0),Ce(Bt,null,Rn(It.value,Qe=>(pe(),Ce("div",{key:Qe.id,ref_for:!0,ref:bt=>K(Qe.id,bt),"data-comment-id":Qe.id,"data-comment-instance-id":Qe.id,"data-comment-thread-id":Qe.threadId,"data-comment-position-key":Qe.instanceRef?.positionKey??"","data-comment-page-index":Qe.pageIndex??"",class:Zt([{"is-direct-decision-continuity-target":Qe.id===z.value},"comment-placeholder"]),style:An({top:(Qe.isOffscreenReviewCard?Qe.top-x.value:Qe.top)+"px",height:Qe.height+"px",transition:M.value?"none":void 0})},[nt(Qe)?(pe(),hn(x0,{key:Qe.id+k.value,onReady:I,onResize:bt=>re(Qe),class:"floating-comment",parent:e.parent,comment:Qe.commentRef,"floating-instance-id":Qe.id,"floating-page-index":Qe.pageIndex,"floating-position-entry":Qe.instanceRef?.positionEntry??null,"is-floating-instance-active":Qe.id===H.value},null,8,["onResize","parent","comment","floating-instance-id","floating-page-index","floating-position-entry","is-floating-instance-active"])):ut("",!0)],14,EF))),128))],4)],36))}},TF=mn(xF,[["__scopeId","data-v-8262096d"]]);Ft(),yn();var RF={class:"superdoc__pdf-comments-layer pdf-comments-layer","aria-hidden":"false"},MF=["data-id","data-comment-id","data-page-number","onClick","onKeydown"],LF="pdf",PF="#078383",DF="#B1124B",OF={__name:"PdfCommentsLayer",emits:["anchor-activate"],setup(e,{emit:t}){const n=t,r=Js(),o=Xu(),{activeComment:i}=qs(r),{documents:s,activeZoom:a}=qs(o),{proxy:l}=yr(),u=b=>typeof b=="number"?Number.isFinite(b):typeof b=="string"&&b.trim()!==""?Number.isFinite(Number(b)):!1,d=b=>!!b&&u(b.top)&&u(b.left)&&u(b.right)&&u(b.bottom),f=_e(()=>{const b=Array.isArray(s.value)?s.value:[];return new Set(b.filter(k=>k?.type===Da).map(k=>String(k.id)))}),p=b=>{const k=b?.fileId??b?.documentId??b?.selection?.documentId;return k!=null?String(k):null},g=b=>{const k=b?.commentId??b?.importedId;return k!=null&&String(k)!==""?String(k):null},m=b=>{const k=f.value;if(!k.size)return!1;const x=p(b);return x?k.has(x):k.size===1},v=b=>{const k=Math.min(Number(b.top),Number(b.bottom)),x=Math.max(Number(b.top),Number(b.bottom));return{top:k,left:Math.min(Number(b.left),Number(b.right)),right:Math.max(Number(b.left),Number(b.right)),bottom:x}},C=_e(()=>{const b=r.getFloatingComments;return Array.isArray(b)?b.filter(k=>k?.selection?.source===LF).filter(k=>!k.resolvedTime).filter(k=>g(k)!==null).filter(k=>d(k.selection?.selectionBounds)).filter(k=>m(k)).map(k=>{const x=g(k),M=v(k.selection.selectionBounds);return{commentId:x,page:k.selection?.page??null,isInternal:k.isInternal!==!1,bounds:M}}):[]}),w=b=>{const k=(a.value??100)/100,{top:x,left:M,right:z,bottom:G}=b.bounds,F=i.value===b.commentId,L=(b.isInternal?PF:DF)+(F?"66":"33");return{position:"absolute",top:x*k+"px",left:M*k+"px",width:(z-M)*k+"px",height:(G-x)*k+"px",backgroundColor:L}},S=b=>{r.setActiveComment(l.$superdoc,b.commentId),n("anchor-activate",b.commentId)};return(b,k)=>(pe(),Ce("div",RF,[(pe(!0),Ce(Bt,null,Rn(C.value,x=>(pe(),Ce("div",{key:x.commentId,class:"sd-comment-anchor sd-highlight",role:"button",tabindex:"0","data-id":x.commentId,"data-comment-id":x.commentId,"data-page-number":x.page,style:An(w(x)),onClick:tn(M=>S(x),["stop","prevent"]),onKeydown:[Ko(tn(M=>S(x),["stop","prevent"]),["enter"]),Ko(tn(M=>S(x),["stop","prevent"]),["space"])]},null,44,MF))),128))]))}},FF=mn(OF,[["__scopeId","data-v-b5ad4c58"]]);Ft();var NF=({proxy:e,layers:t,documents:n,modules:r})=>{const o=_e(()=>{const L=r.value?.whiteboard??r.whiteboard;return L===!1||L==null?null:L}),i=e?.$superdoc?.whiteboard,s=Pr([]),a=Qr({}),l=Qr({}),u=te(!1),d=te(0),f=te(0),p=te(1),g=te(o.value?.enabled??!1),m=()=>{if(u.value)return;d.value+=1;const L=f.value||s.value.length;L&&d.value>=L&&(u.value=!0,e?.$superdoc?.emit("whiteboard:ready",{whiteboard:i}))},v=L=>{if(!L)return;const $=n.value?.[0];$&&$.type==="application/pdf"&&C(L)},C=L=>{const{pageIndex:$,width:T,height:H,originalWidth:R,originalHeight:U}=L,W={width:T,height:H,originalWidth:R,originalHeight:U};i?.setPageSize($,W),a[$]=W;const ee=i?.getPage($);ee&&ee.setSize(W),i&&(s.value=i.getPages().sort((J,Z)=>J.pageIndex-Z.pageIndex).map(J=>Gr(J)),f.value=s.value.length),Ct(()=>{G(),m()})},w=L=>{e?.$superdoc?.emit("whiteboard:change",L)},S=L=>{L.forEach($=>{const T=a[$.pageIndex];T&&$.setSize(T)}),s.value=L.map($=>Gr($)),f.value=s.value.length,Ct(()=>G())},b=L=>{g.value=L,e?.$superdoc?.emit("whiteboard:enabled",L)},k=L=>{p.value=L},x=L=>{e?.$superdoc?.emit("whiteboard:tool",L)},M=()=>{const L=n.value?.[0];L&&L.type==="application/pdf"&&z({doc:L})},z=({doc:L})=>{s.value.forEach($=>{const T=`${L.id}-page-${$.pageIndex+1}`,H=document.querySelector(`[data-page-id="${T}"]`);if(!H)return;const R=H.getBoundingClientRect(),U=a[$.pageIndex]||{},W=U.originalWidth??$.size?.originalWidth??R.width,ee=U.originalHeight??$.size?.originalHeight??R.height,J={width:R.width,height:R.height,originalWidth:W,originalHeight:ee};a[$.pageIndex]=J,$.setSize(J)})},G=()=>{const L=t.value?.getBoundingClientRect?.();if(!L)return;const $=n.value?.[0];$&&$.type==="application/pdf"&&F({doc:$,layerBounds:L})},F=({doc:L,layerBounds:$})=>{s.value.forEach(T=>{const H=`${L.id}-page-${T.pageIndex+1}`,R=document.querySelector(`[data-page-id="${H}"]`);if(!R)return;const U=R.getBoundingClientRect();l[T.pageIndex]={top:U.top-$.top,left:U.left-$.left}})};return i&&(i.on("change",w),i.on("setData",S),i.on("enabled",b),i.on("opacity",k),i.on("tool",x)),ur(()=>{i&&(i.off("change",w),i.off("setData",S),i.off("opacity",k),i.off("enabled",b),i.off("tool",x))}),{whiteboard:i,whiteboardModuleConfig:o,whiteboardPages:s,whiteboardPageSizes:a,whiteboardPageOffsets:l,whiteboardEnabled:g,whiteboardOpacity:p,whiteboardReady:u,handleWhiteboardPageReady:v,updateWhiteboardPageSizes:M,updateWhiteboardPageOffsets:G}};Ft(),yn();var BF=["data-page-index"],zF={__name:"WhiteboardPage",props:{whiteboard:{type:Object,required:!0},page:{type:Object,required:!0},pageSize:{type:Object,default:null},pageOffset:{type:Object,default:null},enabled:{type:Boolean,default:!0}},setup(e){const t=e,n=te(null),r=()=>{const u=n.value;!u||!t.page||(t.page.mount(u),t.pageSize&&t.page.resize(t.pageSize.width,t.pageSize.height))},o=u=>{if(!t.page||!u?.dataTransfer||!t.enabled||t.whiteboard.getTool()!=="select")return;u.preventDefault(),u.stopPropagation();const d=n.value;if(!d)return;const f=d.getBoundingClientRect(),p=u.clientX-f.left,g=u.clientY-f.top,m=t.pageSize?.width,v=t.pageSize?.originalWidth??m,C=Number.isFinite(m)&&Number.isFinite(v)&&v?m/v:1;i(u,p,g,C)||s(u,p,g,C)||a(u,p,g)||l(u,p,g)},i=(u,d,f,p)=>{const g=u.dataTransfer.getData("application/sticker");if(!g)return!1;const m=(t.whiteboard.getType("stickers")||[]).find(v=>v.id===g);return m?.src?(t.page.addImage({stickerId:m.id,x:d,y:f,src:m.src,width:Number.isFinite(m.width)?m.width*p:m.width,height:Number.isFinite(m.height)?m.height*p:m.height,type:"sticker"}),!0):!1},s=(u,d,f,p)=>{const g=Array.from(u.dataTransfer.files||[]).find(v=>v.type.startsWith("image/"));if(!g)return!1;const m=new FileReader;return m.onload=()=>{typeof m.result=="string"&&t.page.addImage({x:d,y:f,src:m.result,type:"image"})},m.readAsDataURL(g),!0},a=(u,d,f)=>{const p=u.dataTransfer.getData("application/comment");if(!p)return!1;const g=(t.whiteboard.getType("comments")||[]).find(m=>m.id===p);return g?.text?(t.page.addText({x:d,y:f,content:g.text}),!0):!1},l=(u,d,f)=>{const p=u.dataTransfer.getData("text/plain");return p?(t.page.addText({x:d,y:f,content:p}),!0):!1};return jt(()=>[t.page,t.pageSize?.width,t.pageSize?.height],()=>{Ct(r)}),zn(()=>{r()}),ur(()=>{t.page?.destroy()}),(u,d)=>(pe(),Ce("div",{ref_key:"containerRef",ref:n,class:"whiteboard-page","data-page-index":e.page.pageIndex,onDragover:d[0]||(d[0]=tn(()=>{},["prevent"])),onDrop:tn(o,["prevent"]),style:An({width:(e.pageSize?.width??e.page.size?.width)+"px",height:(e.pageSize?.height??e.page.size?.height)+"px",transform:`translate(${e.pageOffset?.left??0}px, ${e.pageOffset?.top??0}px)`})},null,44,BF))}},jF=mn(zF,[["__scopeId","data-v-c876c9b5"]]);Ft(),yn();var VF={__name:"WhiteboardLayer",props:{whiteboard:{type:Object,required:!0},pages:{type:Array,default:()=>[]},pageSizes:{type:Object,default:()=>({})},pageOffsets:{type:Object,default:()=>({})},enabled:{type:Boolean,default:!0},interactive:{type:Boolean,default:null},opacity:{type:Number,default:1}},setup(e){const t=e,n=_e(()=>t.interactive==null?t.enabled:t.interactive);return(r,o)=>(pe(),Ce("div",{class:"whiteboard-layer","aria-hidden":"true",style:An({opacity:e.opacity,pointerEvents:n.value?"auto":"none"})},[(pe(!0),Ce(Bt,null,Rn(e.pages,i=>(pe(),hn(jF,{key:i.pageIndex,page:i,"page-size":e.pageSizes?.[i.pageIndex],"page-offset":e.pageOffsets?.[i.pageIndex],whiteboard:e.whiteboard,enabled:e.enabled},null,8,["page","page-size","page-offset","whiteboard","enabled"]))),128))],4))}},UF=mn(VF,[["__scopeId","data-v-54546c3d"]]);Ft(),yn();var $F={class:"superdoc-html-viewer"},HF={class:"superdoc-html-viewer__document"},GF=["innerHTML"],WF={__name:"HtmlViewer",props:{fileSource:{type:[File,Blob],required:!0},documentId:{type:String,required:!0}},emits:["ready","selection-change"],setup(e,{emit:t}){const n=e,r=te(""),o=t,i=()=>{const l=window.getSelection();console.debug("selection from html viewer",l),o("selection-change",l)},s=l=>new Promise((u,d)=>{const f=new FileReader;f.onload=p=>{const g=p.target.result;u(g)},f.onerror=p=>d(p),f.readAsText(l)}),a=async()=>{try{const l=await s(n.fileSource);r.value=l,o("ready",n.documentId)}catch(l){o("error",l),console.error("Error loading document",l)}};return zn(()=>{a()}),(l,u)=>(pe(),Ce("div",$F,[ce("div",HF,[ce("div",{class:"superdoc-html-viewer__content",innerHTML:r.value,onMouseup:i},null,40,GF)])]))}},KF=mn(WF,[["__scopeId","data-v-da3494ba"]]),qF=(e,t,n=()=>!0)=>{const r=new Set(t.map(String)),o=new Set;e.forEach(s=>{if(!n(s))return;const a=s.commentId!=null?String(s.commentId):null,l=s.importedId!=null?String(s.importedId):null;!(a&&r.has(a))&&!(l&&r.has(l))||(a&&o.add(a),l&&o.add(l))});let i=!0;for(;i;)i=!1,e.forEach(s=>{if(!n(s))return;const a=s.commentId!=null?String(s.commentId):null,l=s.importedId!=null?String(s.importedId):null,u=s.parentCommentId!=null?String(s.parentCommentId):null,d=Tm(s),f=d!=null?String(d):null,p=a&&o.has(a)||l&&o.has(l),g=u&&o.has(u)||f&&o.has(f);if(!p&&!g)return;const m=o.size;a&&o.add(a),l&&o.add(l),o.size>m&&(i=!0)});return o};Ft();var rA=te(!1);function Hi(){return{isHighContrastMode:rA,setHighContrastMode:t=>{rA.value=t}}}var IX="[data-track-change-id], .superdoc-comment-highlight, .sd-comment-anchor",EX="sidebar",W0=new Set(["auto","sidebar","inline"]),YF=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),K0=(...e)=>e.find(t=>t!==void 0),oA=e=>{if(typeof e=="string")return e.trim()||void 0;if(typeof HTMLElement<"u"&&e instanceof HTMLElement)return e};function XF(e){const t=e;return typeof t?.closest=="function"&&t.closest(".track-change-focused")!=null}function iA(e){if(!e||e===!1||typeof e!="object")return e;const t={...e},n=YF(e.responsive)?e.responsive:{},r=K0(e.layout,e.displayMode),o=oA(K0(n.target,e.compactMeasurementSelector)),i=K0(n.breakpoint,e.compactBreakpointPx),s=e.displayMode;W0.has(s)||delete t.displayMode;const a=oA(e.compactMeasurementSelector);a===void 0?delete t.compactMeasurementSelector:t.compactMeasurementSelector=a;const l=e.compactBreakpointPx;typeof l=="number"&&Number.isFinite(l)&&l>=0||delete t.compactBreakpointPx,delete t.layout,delete t.responsive,W0.has(r)&&(t.layout=r);const u={};return o!==void 0&&(u.target=o),typeof i=="number"&&Number.isFinite(i)&&i>=0&&(u.breakpoint=i),Object.keys(u).length>0&&(t.responsive=u),t}Ft();var sA=".superdoc__document",ZF=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0,QF=e=>e+320+24;function JF({commentsModuleConfig:e,superdocRoot:t,layers:n}){const r=te(0),o=te(!1);let i=null,s=null,a=null,l=[];const u=C=>{if(!(C instanceof HTMLElement)||(typeof window<"u"?window.getComputedStyle(C):null)?.display==="contents")return!1;const w=Number(C.clientWidth??0),S=Number(C.getBoundingClientRect?.().width??0);return Number.isFinite(w)&&w>0||Number.isFinite(S)&&S>0},d=()=>{const C=t.value,w=e.value?.responsive?.target;if(u(w))return w;if(typeof w=="string"&&w.trim().length>0&&typeof document<"u"){let b=null;try{b=document.querySelector(w.trim())}catch{b=null}if(u(b))return b}let S=C?.parentElement??null;for(;S;){if(u(S))return S;S=S.parentElement}return u(C)||C instanceof HTMLElement?C:null},f=()=>{const C=typeof window<"u"?window.ResizeObserver:void 0;if(typeof C>"u")return;const w=d();w!==s&&(i&&(i.disconnect(),i=null),s=w,s&&(i=new C(()=>{v()}),i.observe(s)))},p=()=>{f();const C=Number(s?.clientWidth??0);if(Number.isFinite(C)&&C>0)return C;const w=Number(s?.getBoundingClientRect?.().width??0);return Number.isFinite(w)&&w>0?w:0},g=()=>{const C=typeof window<"u"?window.ResizeObserver:void 0;if(typeof C>"u")return;const w=t.value?.querySelector?.(sA)??null,S=[n.value,w].filter((b,k,x)=>b instanceof HTMLElement&&x.indexOf(b)===k);S.length===l.length&&S.every((b,k)=>b===l[k])||(a&&(a.disconnect(),a=null),l=S,S.length&&(a=new C(()=>{v()}),S.forEach(b=>a.observe(b))))},m=()=>{g();const C=t.value?.querySelector?.(sA),w=n.value,S=Number(C?.clientWidth??C?.getBoundingClientRect?.().width??0);if(Number.isFinite(S)&&S>0)return S;const b=Number(w?.clientWidth??w?.getBoundingClientRect?.().width??0);return Number.isFinite(b)&&b>0?b:816},v=()=>{const C=p(),w=e.value,S=w?.layout??"sidebar";if(S==="sidebar"){r.value=C,o.value=!1;return}if(S==="inline"){r.value=C,o.value=!0;return}if(!(Number.isFinite(C)&&C>0))return;r.value=C;const b=w?.responsive?.breakpoint;if(ZF(b)){o.value=C<b;return}const k=m(),x=QF(k);o.value=C<x};return ur(()=>{i&&(i.disconnect(),i=null),s=null,a&&(a.disconnect(),a=null),l=[]}),{superdocContainerWidth:r,isCompactCommentsMode:o,recalculateCompactCommentsMode:v,ensureCompactMeasurementObserver:f}}Ft();var aA=320,Bl=12,eN=220,tN=16,nN=500,lA=".superdoc-comment-highlight[data-comment-ids]",cA="data-comment-ids",rN=".sd-comment-anchor",q0=(e,t,n)=>Math.min(Math.max(e,t),n),oa=e=>Number(e),ms=e=>Number.isFinite(e),Y0=e=>e?.commentId??e?.importedId??null,uA=e=>String(e||"").split(",").map(t=>t.trim()).filter(Boolean),oN=e=>{const t=e?.value;if(!t)return null;const n=oa(t.ts);if(!ms(n)||Date.now()-n>nN)return null;const r=oa(t.x),o=oa(t.anchorRect?.bottom),i=ms(o)?o:oa(t.y);return!ms(r)||!ms(i)?null:{x:r,y:i}},iN=({rootEl:e,comment:t,pendingComment:n})=>{if(n?.value&&t?.commentId===n.value?.commentId){const a=e.querySelectorAll(lA);for(const l of a)if(uA(l.getAttribute(cA)).includes("pending")&&typeof l.getBoundingClientRect=="function")return l.getBoundingClientRect()}const r=Y0(t);if(!r)return null;const o=String(r),i=e.querySelectorAll(lA);for(const a of i)if(uA(a.getAttribute(cA)).includes(o)&&typeof a.getBoundingClientRect=="function")return a.getBoundingClientRect();const s=e.querySelector(`[data-track-change-id="${o}"]`);return s&&typeof s.getBoundingClientRect=="function"?s.getBoundingClientRect():null},sN=(e,t)=>{const{entry:n}=e(Y0(t)),r=oa(n?.bounds?.bottom);return ms(r)?r:oa(n?.bounds?.top)},aN=({selectionPosition:e,comment:t,pendingComment:n})=>e.value?.source==="pdf"||t?.selection?.source==="pdf"||n.value?.selection?.source==="pdf",lN=({rootEl:e,layersRect:t,comment:n})=>{const r=Y0(n);if(r==null)return NaN;const o=e.querySelector(`${rN}[data-id="${String(r)}"]`);if(!o||typeof o.getBoundingClientRect!="function")return NaN;const i=o.getBoundingClientRect();return oa(i.bottom)-oa(t.top)},cN=({comment:e,pendingComment:t,selectionPosition:n,activeZoom:r})=>{if(!t.value||e?.commentId!==t.value?.commentId)return NaN;const o=oa(n.value?.bottom);if(ms(o))return o*(n.value?.source==="pdf"?(r.value??100)/100:1);const i=oa(n.value?.top);return ms(i)?i*(n.value?.source==="pdf"?(r.value??100)/100:1):NaN},uN=({top:e,left:t})=>({top:`${Math.round(e)}px`,left:`${Math.round(t)}px`,right:"auto"}),dN=({rootRect:e,layersRect:t,anchorBottom:n,anchorClientX:r=NaN})=>{const o=t.top-e.top+n+tN,i=Math.max(Bl,e.height-eN),s=q0(o,Bl,i),a=Math.max(Bl,e.width-aA-Bl);let l;if(ms(r))l=q0(r-e.left+Bl,Bl,a);else{const u=e.width-(t.left-e.left+t.width)+Bl;l=q0(e.width-u-aA,Bl,a)}return{top:s,left:l}};function fN({activeComment:e,pendingComment:t,activeCompactComment:n,showCommentsSidebar:r,selectionPosition:o,activeZoom:i,superdocRoot:s,layers:a,documents:l,resolveCommentPositionEntry:u,clearActiveComment:d,clearPendingComment:f}){const p={top:"12px",right:"12px"},g=te(0),m=te({x:null,y:null,ts:0,anchorRect:null});let v=null,C=null;const w=()=>{m.value={x:null,y:null,ts:0,anchorRect:null}},S=(M,z,G)=>{if(!l.value?.some(L=>L.type==="application/pdf"))return!1;const F=M.querySelector(".superdoc__compact-comment-popover");return!n.value||!F||F.contains(z)||G?!1:(t.value&&f(),d(),w(),!0)},b=M=>{const z=s.value;if(!z||!a.value?.contains(M.target))return;const G=(typeof document.elementsFromPoint=="function"?document.elementsFromPoint(M.clientX,M.clientY):[]).find(L=>L?.nodeType===1&&z.contains(L)&&L.closest("[data-track-change-id], .superdoc-comment-highlight, .sd-comment-anchor"))?.closest("[data-track-change-id], .superdoc-comment-highlight, .sd-comment-anchor")??(M.target?.nodeType===1?M.target.closest("[data-track-change-id], .superdoc-comment-highlight, .sd-comment-anchor"):null);if(S(z,M.target,G)||M.button!==0||M.pointerType!=="mouse")return;const F=G&&typeof G.getBoundingClientRect=="function"?G.getBoundingClientRect():null;F&&(m.value={x:M.clientX,y:F.bottom,ts:Date.now(),anchorRect:{left:F.left,right:F.right,top:F.top,bottom:F.bottom}})},k=_e(()=>{g.value;const M=n.value;if(!M)return p;const z=s.value,G=a.value;if(!z||!G)return p;const F=z.getBoundingClientRect(),L=G.getBoundingClientRect(),$=oN(m),T=$?null:iN({rootEl:z,comment:M,pendingComment:t});let H=NaN,R=NaN;if($?(H=$.y-L.top,R=$.x):T?(H=T.bottom-L.top,R=T.left):H=sN(u,M),!ms(H)&&aN({selectionPosition:o,comment:M,pendingComment:t})&&(H=lN({rootEl:z,layersRect:L,comment:M})),ms(H)||(H=cN({comment:M,pendingComment:t,selectionPosition:o,activeZoom:i})),!ms(H))return p;const U=dN({rootRect:F,layersRect:L,anchorBottom:H,anchorClientX:R});return uN(U)});return jt([e,t,o,i,r,m],()=>{const M=typeof window<"u"?window.requestAnimationFrame:null,z=typeof window<"u"?window.cancelAnimationFrame:null;v!=null&&z?.(v),M&&(v=M(()=>{g.value+=1,v=null}))},{deep:!1}),jt(n,(M,z)=>{if(!z&&M){const G=document.activeElement;G instanceof HTMLElement&&(C=G)}},{deep:!1}),jt(t,(M,z)=>{!z&&M&&w()}),zn(()=>{document.addEventListener("pointerdown",b,!0)}),ur(()=>{document.removeEventListener("pointerdown",b,!0);const M=typeof window<"u"?window.cancelAnimationFrame:null;v!=null&&(M?.(v),v=null),C=null}),{compactCommentPopoverStyle:k,closeCompactCommentPopover:()=>{n.value&&(t.value&&f(),d(),C&&typeof C.focus=="function"&&C.focus(),C=null)},resetClickAnchor:w}}function Yo(...e){const t={};for(const n of e)if(!(typeof n!="object"||n===null))for(const[r,o]of Object.entries(n))o!==void 0&&(t[r]=o);return t}function zl(...e){for(const t of e)if(t!==void 0)return t}function hN(e,t){const n=Yo(e,t),r=Yo(e?.responsive,t?.responsive);return Object.keys(r).length>0?n.responsive=r:delete n.responsive,n}var X0=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function $m(e={}){const t=X0(e.hyperlinks)?e.hyperlinks:{},n=typeof t.onActivate=="function",r=X0(e.ui)?e.ui:{},o=X0(r.linkPopover)?r.linkPopover:{},i=e.hyperlinks===!1,s=e.ui===!1||r.linkPopover===!1,a=[{value:t.onActivate,source:"hyperlinks.onActivate"},{value:o.popoverResolver,source:"compatibility"},{value:e.modules?.links?.popoverResolver,source:"compatibility"}].find(({value:d})=>d!==void 0),l=i||!n&&s,u=!l&&typeof a?.value=="function"?a.value:void 0;return{handler:u,handlerSource:u?a.source:void 0,editableActivationDisabled:l,builtInEditorDisabled:s,interceptsNavigationOnly:i||n}}function pN(e,t){if(!e||typeof e.entityId!="string"||e.entityType!=="comment"&&e.entityType!=="trackedChange")return null;const n=typeof t=="function"?t(e.entityId):null;if(e.entityType==="comment"&&n?.trackedChange)return e.entityId;const r=n?.commentId??n?.importedId??e.entityId;return r!=null?String(r):null}var mN=new Set(["shell","receipt"]),dA=/^[a-zA-Z][a-zA-Z0-9_-]{0,127}$/,gN=/^[a-z][a-z0-9-]*(?::[a-z][a-z0-9-]*)?$/;function fA(e){if(!e||typeof e!="object")return{};const t=e.reason??(e.failureSource==="receipt"?e.failure?.code:void 0);return{...mN.has(e.failureSource)?{failureSource:e.failureSource}:{},...typeof t=="string"&&dA.test(t)?{reason:t}:{},...typeof e.inputKind=="string"&&dA.test(e.inputKind)?{inputKind:e.inputKind}:{},...typeof e.editableCommandKind=="string"&&e.editableCommandKind.length<=128&&gN.test(e.editableCommandKind)?{editableCommandKind:e.editableCommandKind}:{}}}function hA(e){const t=new Map,n=r=>typeof r=="string"&&r.length>0?r:"__default__";return{shouldNotify(r,o){if(!e(o))return!1;const i=n(r);let s=t.get(i);return s||(s=new WeakSet,t.set(i,s)),s.has(o)?!1:(s.add(o),!0)},clear(r){t.delete(n(r))}}}var vN="no-author-configured",yN="author-required",bN="This edit needs an author identity. Set `user.name` in your SuperDoc configuration and reopen the document to make tracked or revision-overlapping edits.";function pA(e){return typeof e=="string"&&e.includes(vN)}function mA(e){if(!e||e.type!=="mutation:rejected")return!1;if(e.failureSource==="receipt"){const t=e.failure;return t?t.code==="PRECONDITION_FAILED"&&pA(t.message):!1}return e.failureSource==="shell"?e.reason==="author-required"?!0:e.reason==="PRECONDITION_FAILED"&&pA(e.message):!1}function wN(){return hA(mA)}function CN(e,t){return t?.schemaVersion!==1||t.decision!=="accept"&&t.decision!=="reject"?null:{documentId:typeof e=="string"?e:null,decision:t.decision,requestedCount:t.requestedCount,successfulCount:t.appliedCount,permissionDeniedCount:t.deniedCount}}var kN=new Set(["keydown","beforeinput","compositionend","cut","paste","drop","pointerup","programmatic"]),SN=new Set(["insert-text","replace-text","delete-backward","delete-forward","plain-text-paste","clipboard-paste","image-delete","image-drop","image-paste","image-move","sdt-move","structural:enter-split-paragraph","structural:enter-insert-paragraph-before","structural:enter-insert-paragraph-after","structural:enter-list-outdent","structural:enter-list-exit","structural:shift-enter-line-break","structural:mod-enter-page-break","structural:backspace-boundary-merge-with-previous","structural:delete-boundary-merge-with-next","structural:list-indent","structural:list-outdent","tab:paragraph-insert-tab","tab:list-indent-range","tab:list-outdent-range","tab:table-append-row"]),_N=new Set(["beforeinput","compositionend","cut","paste","drop"]),AN=new Set(["shell","receipt"]),IN="edit-rejected",EN="This edit couldn’t be completed. Adjust the selection and try again.";function xN(e){return!!(e&&e.type==="mutation:rejected"&&e.origin==="document-surface"&&AN.has(e.failureSource)&&kN.has(e.inputKind)&&(SN.has(e.editableCommandKind)||e.editableCommandKind==null&&_N.has(e.inputKind)))}function TN(e,t){return{error:new Error(EN,{cause:fA(t)}),code:IN,editor:null,...typeof e=="string"&&e.length>0?{documentId:e}:{}}}function RN(){return hA(xN)}var MN=e=>!!(e?.anchor&&e?.focus&&(e.anchor.blockId!==e.focus.blockId||e.anchor.blockOffset!==e.focus.blockOffset)),LN=(e,t)=>{if(!e||e.rangeCount<1||e.isCollapsed||!t)return!1;const n=e.getRangeAt(0);return!t.contains(n.startContainer)&&!t.contains(n.endContainer)},PN=(e,t)=>e!=="editing"&&e!=="suggesting"?!1:MN(t),DN=(e,t)=>e===!0&&t?.source==="document-editor",ON=Lr((()=>{})),FN=Gd({default:()=>IA}),gA,vA,yA,bA,wA,CA,kA,SA,_A,AA,IA,NN=Lr((()=>{Ft(),ON(),yn(),gA=["onKeydown"],vA=["id"],yA={class:"sd-password-prompt__description"},bA={class:"sd-password-prompt__field"},wA=["placeholder","disabled","aria-label"],CA={key:0,class:"sd-password-prompt__error",role:"alert"},kA={class:"sd-password-prompt__actions"},SA=["disabled"],_A=["disabled"],AA={__name:"PasswordPromptSurface",props:{surfaceId:{type:String,default:""},mode:{type:String,default:"dialog"},request:{type:Object,default:()=>({})},resolve:{type:Function,default:()=>{}},close:{type:Function,default:()=>{}},passwordPrompt:{type:Object,required:!0}},setup(e){const t=e,n=te(""),r=te(!1),o=te(t.passwordPrompt.errorCode==="DOCX_PASSWORD_INVALID"),i=te(o.value?t.passwordPrompt.texts.invalidMessage:""),s=_e(()=>o.value?t.passwordPrompt.texts.invalidTitle:t.passwordPrompt.texts.title),a=_e(()=>n.value.length>0&&!r.value);async function l(){if(!a.value)return;r.value=!0,i.value="";const d=await t.passwordPrompt.attemptPassword(n.value);if(d.success){t.resolve({password:n.value});return}r.value=!1,n.value="",d.errorCode==="DOCX_PASSWORD_INVALID"?(o.value=!0,i.value=t.passwordPrompt.texts.invalidMessage):d.errorCode==="timeout"?i.value=t.passwordPrompt.texts.timeoutMessage:i.value=t.passwordPrompt.texts.genericErrorMessage}function u(){t.close("user-cancelled")}return(d,f)=>(pe(),Ce("div",{class:"sd-password-prompt",onKeydown:Ko(tn(l,["prevent"]),["enter"])},[ce("h3",{id:`sd-password-prompt-heading-${e.surfaceId}`,class:"sd-password-prompt__heading"},Et(s.value),9,vA),ce("p",yA,Et(e.passwordPrompt.texts.description),1),ce("div",bA,[ki(ce("input",{"onUpdate:modelValue":f[0]||(f[0]=p=>n.value=p),type:"password",class:"sd-password-prompt__input",placeholder:e.passwordPrompt.texts.placeholder,disabled:r.value,autocomplete:"current-password","aria-label":e.passwordPrompt.texts.inputAriaLabel},null,8,wA),[[Ii,n.value]])]),i.value?(pe(),Ce("p",CA,Et(i.value),1)):ut("",!0),ce("div",kA,[ce("button",{type:"button",class:"sd-password-prompt__btn sd-password-prompt__btn--cancel",disabled:r.value,onClick:u},Et(e.passwordPrompt.texts.cancelLabel),9,SA),ce("button",{type:"button",class:"sd-password-prompt__btn sd-password-prompt__btn--submit",disabled:!a.value,onClick:l},Et(r.value?e.passwordPrompt.texts.busyLabel:e.passwordPrompt.texts.submitLabel),9,_A)])],40,gA))}},IA=mn(AA,[["__scopeId","data-v-ecf7f6fb"]])}));Ft();var BN=["DOCX_PASSWORD_REQUIRED","DOCX_PASSWORD_INVALID"],zN=3e4,Gi={title:"Password Required",invalidTitle:"Incorrect Password",description:"This document is password protected. Enter the password to open it.",placeholder:"Enter password",inputAriaLabel:"Document password",submitLabel:"Open",cancelLabel:"Cancel",busyLabel:"Decrypting…",invalidMessage:"Incorrect password. Please try again.",timeoutMessage:"Timed out while decrypting. Please try again.",genericErrorMessage:"Unable to decrypt this document."};function jN({getSurfaceManager:e,getPasswordPromptConfig:t,onUnhandled:n}){const r=[],o=Pr(null),i=new Map;let s=!1;function a(m,v,C){if(!m||!BN.includes(v)||t()===!1||!e())return!1;const w=i.get(m.id);if(w)return clearTimeout(w.timer),w.resolve({success:!1,errorCode:v}),i.delete(m.id),!0;const S=r.find(b=>b.doc.id===m.id);return S?(S.errorCode=v,S.originalException=C,!0):(o.value?.doc.id===m.id||(r.push({doc:m,errorCode:v,originalException:C}),d()),!0)}function l(m){if(!m)return;const v=i.get(m.id);v&&(clearTimeout(v.timer),v.resolve({success:!0}),i.delete(m.id))}function u(){s=!0;for(const[,m]of i)clearTimeout(m.timer),m.resolve({success:!1,errorCode:"destroyed"});i.clear(),r.length=0,o.value=null}function d(){if(s||o.value||r.length===0)return;const m=r.shift();m&&f(m).catch(v=>{o.value=null,console.error("[SuperDoc] Password prompt error:",v),n?.(m.doc,m.errorCode,m.originalException),d()})}async function f({doc:m,errorCode:v,originalException:C}){const w=e();if(!w||s)return;const S=p(),b=z=>(m.password=z,m.editorMountNonce++,new Promise(G=>{const F=setTimeout(()=>{i.delete(m.id),G({success:!1,errorCode:"timeout"})},zN);i.set(m.id,{resolve:G,timer:F})})),k={documentId:m.id,errorCode:v,texts:S.texts,attemptPassword:b},x=g(S,{documentId:m.id,errorCode:v,texts:S.texts});if(x.suppressed){n?.(m,v,C),d();return}o.value={doc:m,surfaceHandle:null};let M;if(x.component)M=w.open({mode:"dialog",closeOnBackdrop:!1,ariaLabel:S.texts.title,component:Gr(x.component),props:{...x.props,passwordPrompt:k}});else if(x.render){const z=x.render;M=w.open({mode:"dialog",closeOnBackdrop:!1,ariaLabel:S.texts.title,render:G=>z({container:G.container,passwordPrompt:k,resolve:G.resolve,close:G.close,surfaceId:G.surfaceId,mode:G.mode})})}else{const z=(await Promise.resolve().then(()=>(NN(),FN))).default,G=`password-prompt-${m.id}`;M=w.open({id:G,mode:"dialog",closeOnBackdrop:!1,ariaLabelledBy:`sd-password-prompt-heading-${G}`,component:Gr(z),props:{passwordPrompt:k}})}o.value={doc:m,surfaceHandle:M},await M.result,o.value=null,d()}function p(){const m=t();if(m===!1)return{enabled:!1,texts:Gi};const v=typeof m=="object"&&m!==null?m:{};if(v.component!=null&&typeof v.render=="function")throw new Error('modules.surfaces.passwordPrompt cannot provide both "component" and "render". Use one or the other.');return{enabled:!0,texts:{title:v.title??Gi.title,invalidTitle:v.invalidTitle??Gi.invalidTitle,description:v.description??Gi.description,placeholder:v.placeholder??Gi.placeholder,inputAriaLabel:v.inputAriaLabel??Gi.inputAriaLabel,submitLabel:v.submitLabel??Gi.submitLabel,cancelLabel:v.cancelLabel??Gi.cancelLabel,busyLabel:v.busyLabel??Gi.busyLabel,invalidMessage:v.invalidMessage??Gi.invalidMessage,timeoutMessage:v.timeoutMessage??Gi.timeoutMessage,genericErrorMessage:v.genericErrorMessage??Gi.genericErrorMessage},component:v.component,props:v.props,render:v.render,resolver:v.resolver}}function g(m,v){if(typeof m.resolver=="function"){const C=m.resolver(v);if(C!=null&&C.type!=="default"){if(C.type==="none")return{suppressed:!0};if(C.type==="custom")return{component:C.component,props:C.props};if(C.type==="external")return{render:C.render}}}return m.component!=null?{component:m.component,props:m.props}:typeof m.render=="function"?{render:m.render}:{builtin:!0}}return{handleEncryptionError:a,handleEditorReady:l,destroy:u}}function EA(e,{getCurrentSession:t,applySlice:n,onSettled:r}){return()=>{if(e===t())try{n(e.getSnapshot())}catch{}r()}}var VN=Lr((()=>{})),UN=Gd({default:()=>XA}),xA,TA,RA,MA,LA,PA,DA,OA,FA,NA,BA,zA,jA,VA,UA,$A,HA,GA,WA,KA,qA,YA,XA,$N=Lr((()=>{Ft(),VN(),yn(),xA=["onKeydown"],TA={class:"sd-find-replace__row"},RA=["title","aria-label","aria-expanded"],MA=["value","placeholder","aria-label"],LA={key:0,class:"sd-find-replace__count"},PA=["title","aria-label","aria-pressed"],DA=["title","aria-label","aria-pressed"],OA=["title","aria-label","aria-pressed"],FA={class:"sd-find-replace__nav"},NA=["disabled","title","aria-label"],BA=["disabled","title","aria-label"],zA=["title","aria-label"],jA={key:0,class:"sd-find-replace__row"},VA={class:"sd-find-replace__field"},UA=["value","placeholder","aria-label"],$A={class:"sd-find-replace__nav sd-find-replace__nav--actions"},HA=["disabled","title"],GA=["disabled","title"],WA={key:1,class:"sd-find-replace__error",role:"alert"},KA={key:0,class:"sd-find-replace__row-indent","aria-hidden":"true"},qA={class:"sd-find-replace__error-text"},YA={__name:"FindReplaceSurface",props:{surfaceId:{type:String,default:""},mode:{type:String,default:"floating"},request:{type:Object,default:()=>({})},resolve:{type:Function,default:()=>{}},close:{type:Function,default:()=>{}},findReplace:{type:Object,required:!0}},setup(e){const t=e,n=te(null),r=_e(()=>{const v=t.findReplace;return!!(!v.hasMatches?.value||v.replacePending?.value===!0||v.canReplace&&v.canReplace.value===!1)}),o=_e(()=>{if(r.value)return!0;const v=t.findReplace;return!!(v.canReplaceAll&&v.canReplaceAll.value===!1)}),i=_e(()=>t.findReplace.ignoreDiacriticsSupported?.value!==!1),s=_e(()=>t.findReplace.replaceEnabled&&t.findReplace.replaceCanMutate?.value!==!1),a=_e(()=>t.findReplace.regexSupported?.value===!0),l=_e(()=>t.findReplace.searchError?.value??null);function u(v){v.key==="Enter"&&!v.shiftKey?(v.preventDefault(),d()):v.key==="Enter"&&v.shiftKey&&(v.preventDefault(),f())}function d(){t.findReplace.goNext(),m()}function f(){t.findReplace.goPrev(),m()}function p(){t.findReplace.close("user-closed")}function g(v){const C=[];let w=v?.parentElement??null;for(;w;){const b=w.ownerDocument?.defaultView?.getComputedStyle?.(w);if(b){const k=`${b.overflowY} ${b.overflowX}`;(k.includes("auto")||k.includes("scroll"))&&C.push(w)}w=w.parentElement}const S=v?.ownerDocument?.scrollingElement;return S&&!C.includes(S)&&C.push(S),C}function m(){const v=n.value;if(!v)return;const C=g(v).map(w=>({el:w,top:w.scrollTop,left:w.scrollLeft}));v.focus({preventScroll:!0});for(const{el:w,top:S,left:b}of C)w.scrollTop!==S&&(w.scrollTop=S),w.scrollLeft!==b&&(w.scrollLeft=b)}return zn(()=>{t.findReplace.registerFocusFn(m)}),(v,C)=>(pe(),Ce("div",{class:"sd-find-replace",onKeydown:Ko(tn(p,["stop"]),["esc"])},[ce("div",TA,[s.value?(pe(),Ce("button",{key:0,type:"button",class:Zt(["sd-find-replace__btn sd-find-replace__btn--expander",{"sd-find-replace__btn--expander-open":e.findReplace.showReplace.value}]),title:e.findReplace.texts.toggleReplaceLabel,"aria-label":e.findReplace.texts.toggleReplaceAriaLabel,"aria-expanded":e.findReplace.showReplace.value?"true":"false",onClick:C[0]||(C[0]=w=>e.findReplace.showReplace.value=!e.findReplace.showReplace.value)},[...C[14]||(C[14]=[ce("svg",{viewBox:"0 0 16 16",width:"14",height:"14","aria-hidden":"true"},[ce("path",{d:"M6 3.5 10.5 8 6 12.5",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],10,RA)):ut("",!0),ce("div",{class:Zt(["sd-find-replace__field",{"sd-find-replace__field--error":l.value}])},[C[15]||(C[15]=ce("svg",{class:"sd-find-replace__search-icon",viewBox:"0 0 16 16",width:"15",height:"15","aria-hidden":"true"},[ce("path",{d:"M7 1a6 6 0 1 0 3.7 10.7l3.3 3.3 1-1-3.3-3.3A6 6 0 0 0 7 1Zm0 1.5a4.5 4.5 0 1 1 0 9 4.5 4.5 0 0 1 0-9Z",fill:"currentColor"})],-1)),ce("input",{ref_key:"findInputRef",ref:n,value:e.findReplace.findQuery.value,onInput:C[1]||(C[1]=w=>e.findReplace.findQuery.value=w.target.value),type:"text",class:"sd-find-replace__input sd-find-replace__input--search","data-sd-autofocus":"",placeholder:e.findReplace.texts.findPlaceholder,"aria-label":e.findReplace.texts.findAriaLabel,onKeydown:u},null,40,MA),e.findReplace.findQuery.value&&!l.value?(pe(),Ce("span",LA,Et(e.findReplace.matchLabel.value),1)):ut("",!0),ce("button",{type:"button",class:Zt(["sd-find-replace__btn sd-find-replace__btn--toggle",{"sd-find-replace__btn--active":e.findReplace.caseSensitive.value}]),title:e.findReplace.texts.matchCaseAriaLabel,"aria-label":e.findReplace.texts.matchCaseAriaLabel,"aria-pressed":e.findReplace.caseSensitive.value?"true":"false",onMousedown:C[2]||(C[2]=tn(()=>{},["prevent"])),onClick:C[3]||(C[3]=w=>e.findReplace.caseSensitive.value=!e.findReplace.caseSensitive.value)},Et(e.findReplace.texts.matchCaseLabel),43,PA),i.value?(pe(),Ce("button",{key:1,type:"button",class:Zt(["sd-find-replace__btn sd-find-replace__btn--toggle",{"sd-find-replace__btn--active":e.findReplace.ignoreDiacritics.value}]),title:e.findReplace.texts.ignoreDiacriticsAriaLabel,"aria-label":e.findReplace.texts.ignoreDiacriticsAriaLabel,"aria-pressed":e.findReplace.ignoreDiacritics.value?"true":"false",onMousedown:C[4]||(C[4]=tn(()=>{},["prevent"])),onClick:C[5]||(C[5]=w=>e.findReplace.ignoreDiacritics.value=!e.findReplace.ignoreDiacritics.value)},Et(e.findReplace.texts.ignoreDiacriticsLabel),43,DA)):ut("",!0),a.value?(pe(),Ce("button",{key:2,type:"button",class:Zt(["sd-find-replace__btn sd-find-replace__btn--toggle",{"sd-find-replace__btn--active":e.findReplace.regex.value}]),title:e.findReplace.texts.regexAriaLabel,"aria-label":e.findReplace.texts.regexAriaLabel,"aria-pressed":e.findReplace.regex.value?"true":"false",onMousedown:C[6]||(C[6]=tn(()=>{},["prevent"])),onClick:C[7]||(C[7]=w=>e.findReplace.regex.value=!e.findReplace.regex.value)},Et(e.findReplace.texts.regexLabel),43,OA)):ut("",!0)],2),ce("div",FA,[ce("button",{type:"button",class:"sd-find-replace__btn sd-find-replace__btn--icon",disabled:!e.findReplace.hasMatches.value,title:e.findReplace.texts.previousMatchLabel,"aria-label":e.findReplace.texts.previousMatchAriaLabel,onClick:C[8]||(C[8]=w=>f())},[...C[16]||(C[16]=[ce("svg",{viewBox:"0 0 16 16",width:"16",height:"16","aria-hidden":"true"},[ce("path",{d:"M10 3.5 5.5 8 10 12.5",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],8,NA),ce("button",{type:"button",class:"sd-find-replace__btn sd-find-replace__btn--icon",disabled:!e.findReplace.hasMatches.value,title:e.findReplace.texts.nextMatchLabel,"aria-label":e.findReplace.texts.nextMatchAriaLabel,onClick:C[9]||(C[9]=w=>d())},[...C[17]||(C[17]=[ce("svg",{viewBox:"0 0 16 16",width:"16",height:"16","aria-hidden":"true"},[ce("path",{d:"M6 3.5 10.5 8 6 12.5",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],8,BA),C[19]||(C[19]=ce("span",{class:"sd-find-replace__divider","aria-hidden":"true"},null,-1)),ce("button",{type:"button",class:"sd-find-replace__btn sd-find-replace__btn--icon",title:e.findReplace.texts.closeLabel,"aria-label":e.findReplace.texts.closeAriaLabel,onClick:p},[...C[18]||(C[18]=[ce("svg",{viewBox:"0 0 16 16",width:"16",height:"16","aria-hidden":"true"},[ce("path",{d:"m4.5 4.5 7 7m0-7-7 7",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"})],-1)])],8,zA)])]),e.findReplace.showReplace.value&&s.value?(pe(),Ce("div",jA,[C[20]||(C[20]=ce("span",{class:"sd-find-replace__row-indent","aria-hidden":"true"},null,-1)),ce("div",VA,[ce("input",{value:e.findReplace.replaceText.value,onInput:C[10]||(C[10]=w=>e.findReplace.replaceText.value=w.target.value),type:"text",class:"sd-find-replace__input",placeholder:e.findReplace.texts.replacePlaceholder,"aria-label":e.findReplace.texts.replaceAriaLabel,onKeydown:C[11]||(C[11]=Ko(tn(w=>e.findReplace.replaceCurrent(),["prevent"]),["enter"]))},null,40,UA)]),ce("div",$A,[ce("button",{type:"button",class:"sd-find-replace__btn sd-find-replace__btn--action",disabled:r.value,title:e.findReplace.texts.replaceLabel,onClick:C[12]||(C[12]=w=>e.findReplace.replaceCurrent())},Et(e.findReplace.texts.replaceLabel),9,HA),ce("button",{type:"button",class:"sd-find-replace__btn sd-find-replace__btn--action",disabled:o.value,title:e.findReplace.texts.replaceAllLabel,onClick:C[13]||(C[13]=w=>e.findReplace.replaceAll())},Et(e.findReplace.texts.replaceAllLabel),9,GA)])])):ut("",!0),l.value?(pe(),Ce("div",WA,[s.value?(pe(),Ce("span",KA)):ut("",!0),ce("span",qA,Et(l.value),1)])):ut("",!0)],40,xA))}},XA=mn(YA,[["__scopeId","data-v-5dba4c36"]])}));Ft();var mr={findPlaceholder:"Find",findAriaLabel:"Find text",replacePlaceholder:"Replace",replaceAriaLabel:"Replace text",noResultsLabel:"No results",previousMatchLabel:"Previous match (Shift+Enter)",previousMatchAriaLabel:"Previous match",nextMatchLabel:"Next match (Enter)",nextMatchAriaLabel:"Next match",closeLabel:"Close (Escape)",closeAriaLabel:"Close find and replace",replaceLabel:"Replace",replaceAllLabel:"All",toggleReplaceLabel:"Toggle replace",toggleReplaceAriaLabel:"Toggle replace",matchCaseLabel:"Aa",matchCaseAriaLabel:"Match case",regexLabel:".*",regexAriaLabel:"Use regular expression",invalidPatternLabel:"Invalid pattern",ignoreDiacriticsLabel:"ä≡a",ignoreDiacriticsAriaLabel:"Ignore diacritics"};function HN(e){if(!e)return null;const t=e.extensionStorage,n=e.storage,r=t?.Search??n?.Search;if(r?.searchIndex||r?.searchResults)return r;const o=e.extensionStorage??e.storage;if(o)for(const i of Object.keys(o)){const s=o[i];if(s&&typeof s=="object"&&"searchIndex"in s&&"searchResults"in s)return s}return null}function GN({getSurfaceManager:e,getActiveEditor:t,activeEditorRef:n,getFindReplaceConfig:r,getSuperDocUI:o}){let i=null,s=null,a=null,l=!1,u=!1;const d=te(!1);let f=null;const p=te(""),g=te(""),m=te(!1),v=te(!1),C=te(!1),w=te(!1),S=te(0),b=te(-1),k=te(!0),x=te(!0),M=te(!1),z=te(!0),G=te(!1),F=te(null);let L=mr;const $=_e(()=>p.value?S.value===0?L.noResultsLabel:`${b.value+1} of ${S.value}`:""),T=_e(()=>S.value>0),H=_e(()=>T.value&&!M.value&&k.value),R=_e(()=>H.value&&x.value);let U=null,W=null;function ee(P){return typeof P?.commands?.setSearchSession=="function"}function J(){try{const P=(typeof o=="function"?o():null)?.search;return P&&(typeof P.find=="function"||typeof P.search=="function")?P:null}catch{return null}}function Z(P){P&&(S.value=typeof P.total=="number"?P.total:0,b.value=typeof P.activeIndex=="number"?P.activeIndex:-1,k.value=P.canReplace===!0,x.value=typeof P.canReplaceAll=="boolean"?P.canReplaceAll:P.canReplace===!0,F.value=P.reason==="search-invalid-pattern"?L.invalidPatternLabel:null)}function Me(){if(a){fe();return}if(s){if(!p.value){try{s.commands.clearSearchSession()}catch{}S.value=0,b.value=-1;return}try{const P=s.commands.setSearchSession(p.value,{caseSensitive:m.value,ignoreDiacritics:v.value,highlight:!0,searchModel:we().includeDeletedText?"raw":"visible"});S.value=P.matches.length,b.value=P.activeMatchIndex}catch{}}}function fe(){const P=a;if(P){if(!p.value){try{P.clear()}catch{}S.value=0,b.value=-1,F.value=null;return}try{const N={caseSensitive:m.value,regex:C.value},me=we().includeDeletedText===!0;Z(typeof P.find=="function"?P.find(p.value,{...N,includeTrackedDeletions:me}):P.search(p.value,{...N,includeDeletedText:me}))}catch{}}}function ye(){U&&clearTimeout(U),U=setTimeout(Me,150)}jt(p,()=>{d.value&&ye()}),jt(m,()=>{d.value&&Me()}),jt(v,()=>{d.value&&Me()}),jt(C,()=>{d.value&&Me()});let ve=!0;function Pe(){if(T.value){if(a){try{a.next(),Z(a.getSnapshot())}catch{}return}if(s)try{const P=s.commands.nextSearchMatch();b.value=P.activeMatchIndex}catch{}}}function Ve(){if(T.value){if(a){try{a.previous(),Z(a.getSnapshot())}catch{}return}if(s)try{const P=s.commands.previousSearchMatch();b.value=P.activeMatchIndex}catch{}}}function nt(){if(ve&&!M.value&&T.value){if(a){if(!k.value)return;const P=a;M.value=!0;const N=EA(P,{getCurrentSession:()=>a,applySlice:Z,onSettled:()=>{M.value=!1}});let me=null;try{me=P.replace(g.value)}catch{}me&&typeof me.then=="function"?Promise.resolve(me).then(N,N):N();return}if(s)try{const P=s.commands.replaceSearchMatch(g.value);S.value=P.matches.length,b.value=P.activeMatchIndex}catch{}}}function ct(){if(ve&&!M.value&&T.value){if(a){if(!k.value||!x.value)return;const P=a;M.value=!0;const N=EA(P,{getCurrentSession:()=>a,applySlice:Z,onSettled:()=>{M.value=!1}});let me=null;try{me=P.replaceAll(g.value)}catch{}me&&typeof me.then=="function"?Promise.resolve(me).then(N,N):N();return}if(s)try{s.commands.replaceAllSearchMatches(g.value),S.value=0,b.value=-1}catch{}}}function ft(){if(a){try{Z(a.getSnapshot())}catch{}return}const P=HN(s);if(!P)return;const N=P.searchResults,me=Array.isArray(N)?N.length:0,Se=P.activeMatchIndex??-1;me!==S.value&&(S.value=me),Se!==b.value&&(b.value=Se)}function It(){Le(),W=setInterval(ft,200)}function Le(){U&&clearTimeout(U),U=null,W&&clearInterval(W),W=null}function oe(){p.value="",g.value="",m.value=!1,v.value=!1,C.value=!1,F.value=null,w.value=!1,S.value=0,b.value=-1,k.value=!0,x.value=!0,M.value=!1}function we(){const P=typeof r=="function"?r():void 0;if(P===!1||P==null)return{enabled:!1,texts:mr,replaceEnabled:!0};if(P===!0)return{enabled:!0,texts:mr,replaceEnabled:!0};const N=typeof P=="object"?P:{};if(N.component!=null&&typeof N.render=="function")throw new Error('Search configuration cannot provide both "component" and "render". Use one or the other.');return{enabled:!0,texts:{findPlaceholder:N.findPlaceholder??mr.findPlaceholder,findAriaLabel:N.findAriaLabel??mr.findAriaLabel,replacePlaceholder:N.replacePlaceholder??mr.replacePlaceholder,replaceAriaLabel:N.replaceAriaLabel??mr.replaceAriaLabel,noResultsLabel:N.noResultsLabel??mr.noResultsLabel,previousMatchLabel:N.previousMatchLabel??mr.previousMatchLabel,previousMatchAriaLabel:N.previousMatchAriaLabel??mr.previousMatchAriaLabel,nextMatchLabel:N.nextMatchLabel??mr.nextMatchLabel,nextMatchAriaLabel:N.nextMatchAriaLabel??mr.nextMatchAriaLabel,closeLabel:N.closeLabel??mr.closeLabel,closeAriaLabel:N.closeAriaLabel??mr.closeAriaLabel,replaceLabel:N.replaceLabel??mr.replaceLabel,replaceAllLabel:N.replaceAllLabel??mr.replaceAllLabel,toggleReplaceLabel:N.toggleReplaceLabel??mr.toggleReplaceLabel,toggleReplaceAriaLabel:N.toggleReplaceAriaLabel??mr.toggleReplaceAriaLabel,matchCaseLabel:N.matchCaseLabel??mr.matchCaseLabel,matchCaseAriaLabel:N.matchCaseAriaLabel??mr.matchCaseAriaLabel,regexLabel:N.regexLabel??mr.regexLabel,regexAriaLabel:N.regexAriaLabel??mr.regexAriaLabel,invalidPatternLabel:N.invalidPatternLabel??mr.invalidPatternLabel,ignoreDiacriticsLabel:N.ignoreDiacriticsLabel??mr.ignoreDiacriticsLabel,ignoreDiacriticsAriaLabel:N.ignoreDiacriticsAriaLabel??mr.ignoreDiacriticsAriaLabel},replaceEnabled:N.replaceEnabled??!0,includeDeletedText:N.includeDeletedText??!1,component:N.component,props:N.props,render:N.render,resolver:N.resolver,floating:N.floating&&typeof N.floating=="object"?N.floating:void 0}}function Q(P,N){if(typeof P.resolver=="function"){const me=P.resolver(N);if(me!=null&&me.type!=="default"){if(me.type==="none")return{suppressed:!0};if(me.type==="custom")return{component:me.component,props:me.props};if(me.type==="external")return{render:me.render}}}return P.component!=null?{component:P.component,props:P.props}:typeof P.render=="function"?{render:P.render}:{builtin:!0}}function I(P,N){return{findQuery:p,replaceText:g,caseSensitive:m,ignoreDiacritics:v,regex:C,showReplace:w,matchCount:S,activeMatchIndex:b,matchLabel:$,hasMatches:T,canReplace:H,canReplaceAll:R,replaceCanMutate:k,replacePending:M,ignoreDiacriticsSupported:z,regexSupported:G,searchError:F,replaceEnabled:P.replaceEnabled??!0,texts:P.texts,goNext:Pe,goPrev:Ve,replaceCurrent:nt,replaceAll:ct,registerFocusFn:me=>{f=me},close:me=>N(me)}}function re(P){return{get findQuery(){return P.findQuery.value},set findQuery(N){P.findQuery.value=N},get replaceText(){return P.replaceText.value},set replaceText(N){P.replaceText.value=N},get caseSensitive(){return P.caseSensitive.value},set caseSensitive(N){P.caseSensitive.value=N},get ignoreDiacritics(){return P.ignoreDiacritics.value},set ignoreDiacritics(N){P.ignoreDiacritics.value=N},get regex(){return P.regex.value},set regex(N){P.regex.value=N},get regexSupported(){return P.regexSupported.value},get searchError(){return P.searchError.value},get replaceCanMutate(){return P.replaceCanMutate.value},get showReplace(){return P.showReplace.value},set showReplace(N){P.showReplace.value=N},get matchCount(){return P.matchCount.value},get activeMatchIndex(){return P.activeMatchIndex.value},get matchLabel(){return P.matchLabel.value},get hasMatches(){return P.hasMatches.value},get canReplace(){return P.canReplace.value},get canReplaceAll(){return P.canReplaceAll?P.canReplaceAll.value:P.canReplace.value},get replacePending(){return P.replacePending.value},get ignoreDiacriticsSupported(){return P.ignoreDiacriticsSupported.value},replaceEnabled:P.replaceEnabled,texts:P.texts,goNext:P.goNext,goPrev:P.goPrev,replaceCurrent:P.replaceCurrent,replaceAll:P.replaceAll,registerFocusFn:P.registerFocusFn,close:P.close}}function j(P){if(P){if(typeof P?.commands?.clearSearchSession=="function"){try{P.commands.clearSearchSession()}catch{}return}if(a&&P===s)try{a.clear()}catch{}}}function X(){try{if(l||!e()||!t())return!1;if(i&&d.value)return!0;const P=we();if(!P.enabled||Q(P,{texts:P.texts,replaceEnabled:P.replaceEnabled??!0}).suppressed)return!1;if(!ee(t())){const N=J();if(!N)return!1;try{if(N.getSnapshot?.().available!==!0)return!1}catch{return!1}}return!0}catch{return!1}}async function K(){if(l)return;const P=e();if(P){if(i&&d.value){f?.();return}if(!u){u=!0;try{const N=t();if(!N){u=!1;return}const me=we();if(!me.enabled){u=!1;return}const Se=Q(me,{texts:me.texts,replaceEnabled:me.replaceEnabled??!0});if(Se.suppressed){u=!1;return}oe(),L=me.texts,ve=me.replaceEnabled??!0;const Re={placement:"top-right",autoFocus:!0,width:420,...me.floating};if(s&&s!==N&&j(s),s=N,a=ee(N)?null:J(),z.value=!a,G.value=!!a,a)try{Z(a.getSnapshot())}catch{}f=null;let ze=()=>{};const Ke=I(me,Ot=>ze(Ot));let ot;if(Se.component)ot=P.open({mode:"floating",ariaLabel:me.texts.findAriaLabel,closeOnEscape:!0,floating:Re,component:Gr(Se.component),props:{...Se.props,findReplace:Ke}});else if(Se.render){const Ot=Se.render;ot=P.open({mode:"floating",ariaLabel:me.texts.findAriaLabel,closeOnEscape:!0,floating:Re,render:Mt=>Ot({container:Mt.container,findReplace:re(Ke),resolve:Mt.resolve,close:Mt.close,surfaceId:Mt.surfaceId,mode:Mt.mode})})}else{let Ot;try{Ot=(await Promise.resolve().then(()=>($N(),UN))).default}catch{u=!1;return}if(l||i&&d.value){u=!1;return}const Mt=t()||N;s!==Mt&&(j(s),s=Mt,a=ee(Mt)?null:J(),z.value=!a),ot=P.open({mode:"floating",ariaLabel:me.texts.findAriaLabel,component:Gr(Ot),closeOnEscape:!0,floating:Re,props:{findReplace:Ke}})}ze=Ot=>ot.close(Ot??"programmatic"),i=ot,d.value=!0,u=!1,It();const mt=ot.id;ot.result.then(()=>{i?.id===mt?(Le(),j(s),i=null,d.value=!1,f=null):j(N!==s?N:null)})}catch(N){throw u=!1,N}}}}function ae(){i&&i.close("programmatic")}n&&jt(n,(P,N)=>{!d.value||!i||P!==N&&(j(N),ae())});function ke(){l=!0,Le(),ae(),s=null,a=null,f=null}return{open:K,close:ae,isOpen:d,wouldOpen:X,destroy:ke}}var sh=null;function Z0(e){e!=null&&(sh=e)}function WN(e){sh===e&&(sh=null)}function KN(e){return sh===null||sh===e}function qN(e,{focusInside:t,owner:n}){if(e.defaultPrevented)return!1;if(t)return!0;const r=document.activeElement;return(!r||r===document.body||r===document.documentElement)&&KN(n)}var YN=/^(https?|mailto|tel):/i,XN=/^(javascript|data|vbscript):/i,ZN=/^[a-z][a-z0-9+.-]*:/i;function QN(e){if(typeof e!="string")return null;const t=e.trim();return t?t.startsWith("#")?{href:t}:XN.test(t)?null:ZN.test(t)?YN.test(t)?{href:t}:null:{href:t}:null}var JN='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M0 64C0 46.3 14.3 32 32 32l48 0 16 0 128 0c70.7 0 128 57.3 128 128c0 31.3-11.3 60.1-30 82.3c37.1 22.4 62 63.1 62 109.7c0 70.7-57.3 128-128 128L96 480l-16 0-48 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l16 0 0-160L48 96 32 96C14.3 96 0 81.7 0 64zM224 224c35.3 0 64-28.7 64-64s-28.7-64-64-64L112 96l0 128 112 0zM112 288l0 128 144 0c35.3 0 64-28.7 64-64s-28.7-64-64-64l-32 0-112 0z"/></svg>',eB='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M128 64c0-17.7 14.3-32 32-32l192 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-58.7 0L160 416l64 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32s14.3-32 32-32l58.7 0L224 96l-64 0c-17.7 0-32-14.3-32-32z"/></svg>',tB='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M16 64c0-17.7 14.3-32 32-32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-16 0 0 128c0 53 43 96 96 96s96-43 96-96l0-128-16 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-16 0 0 128c0 88.4-71.6 160-160 160s-160-71.6-160-160L64 96 48 96C30.3 96 16 81.7 16 64zM0 448c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32z"/></svg>',ZA='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M40 48C26.7 48 16 58.7 16 72l0 48c0 13.3 10.7 24 24 24l48 0c13.3 0 24-10.7 24-24l0-48c0-13.3-10.7-24-24-24L40 48zM192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L192 64zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zM16 232l0 48c0 13.3 10.7 24 24 24l48 0c13.3 0 24-10.7 24-24l0-48c0-13.3-10.7-24-24-24l-48 0c-13.3 0-24 10.7-24 24zM40 368c-13.3 0-24 10.7-24 24l0 48c0 13.3 10.7 24 24 24l48 0c13.3 0 24-10.7 24-24l0-48c0-13.3-10.7-24-24-24l-48 0z"/></svg>',nB=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc. (bullet shapes modified)--><path fill-rule="evenodd" d="M192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L192 64zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zM64 48 A48 48 0 1 0 64 144 A48 48 0 1 0 64 48 Z M64 68 A28 28 0 1 1 64 124 A28 28 0 1 1 64 68 Z M64 208 A48 48 0 1 0 64 304 A48 48 0 1 0 64 208 Z M64 228 A28 28 0 1 1 64 284 A28 28 0 1 1 64 228 Z M64 368 A48 48 0 1 0 64 464 A48 48 0 1 0 64 368 Z M64 388 A28 28 0 1 1 64 444 A28 28 0 1 1 64 388 Z"/></svg>
|
|
17
17
|
`,rB=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc. (bullet shapes modified)--><path d="M192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L192 64zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zM16 48 L112 48 L112 144 L16 144 Z M16 208 L112 208 L112 304 L16 304 Z M16 368 L112 368 L112 464 L16 464 Z"/></svg>
|
|
18
18
|
`,oB='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M24 56c0-13.3 10.7-24 24-24l32 0c13.3 0 24 10.7 24 24l0 120 16 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l16 0 0-96-8 0C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432l33.2 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-88 0c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z"/></svg>',iB=`<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
19
19
|
<g clip-path="url(#clip0_0_1)">
|
|
@@ -103,10 +103,10 @@ js: import "konva/skia-backend";
|
|
|
103
103
|
`,X4=()=>{if(typeof document>"u")throw new Error(dV)},gs=class Dx{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new Dx(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){const n=this.m;return{x:n[0]*t.x+n[2]*t.y+n[4],y:n[1]*t.x+n[3]*t.y+n[5]}}translate(t,n){return this.m[4]+=this.m[0]*t+this.m[2]*n,this.m[5]+=this.m[1]*t+this.m[3]*n,this}scale(t,n){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=n,this.m[3]*=n,this}rotate(t){const n=Math.cos(t),r=Math.sin(t),o=this.m[0]*n+this.m[2]*r,i=this.m[1]*n+this.m[3]*r,s=this.m[0]*-r+this.m[2]*n,a=this.m[1]*-r+this.m[3]*n;return this.m[0]=o,this.m[1]=i,this.m[2]=s,this.m[3]=a,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,n){const r=this.m[0]+this.m[2]*n,o=this.m[1]+this.m[3]*n,i=this.m[2]+this.m[0]*t,s=this.m[3]+this.m[1]*t;return this.m[0]=r,this.m[1]=o,this.m[2]=i,this.m[3]=s,this}multiply(t){const n=this.m[0]*t.m[0]+this.m[2]*t.m[1],r=this.m[1]*t.m[0]+this.m[3]*t.m[1],o=this.m[0]*t.m[2]+this.m[2]*t.m[3],i=this.m[1]*t.m[2]+this.m[3]*t.m[3],s=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],a=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=n,this.m[1]=r,this.m[2]=o,this.m[3]=i,this.m[4]=s,this.m[5]=a,this}invert(){const t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),n=this.m[3]*t,r=-this.m[1]*t,o=-this.m[2]*t,i=this.m[0]*t,s=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),a=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=n,this.m[1]=r,this.m[2]=o,this.m[3]=i,this.m[4]=s,this.m[5]=a,this}getMatrix(){return this.m}decompose(){const t=this.m[0],n=this.m[1],r=this.m[2],o=this.m[3],i=this.m[4],s=this.m[5],a=t*o-n*r,l={x:i,y:s,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(t!=0||n!=0){const u=Math.sqrt(t*t+n*n);l.rotation=n>0?Math.acos(t/u):-Math.acos(t/u),l.scaleX=u,l.scaleY=a/u,l.skewX=(t*r+n*o)/a,l.skewY=0}else if(r!=0||o!=0){const u=Math.sqrt(r*r+o*o);l.rotation=Math.PI/2-(o>0?Math.acos(-r/u):-Math.acos(r/u)),l.scaleX=a/u,l.scaleY=u,l.skewX=0,l.skewY=(t*r+n*o)/a}return l.rotation=Be._getRotation(l.rotation),l}},fV="[object Array]",hV="[object Number]",pV="[object String]",mV="[object Boolean]",gV=Math.PI/180,vV=180/Math.PI,ch="#",yV="",bV="0",wV="Konva warning: ",Z4="Konva error: ",CV="rgb(",o1={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},kV=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,Jm=[],uh=null,SV=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(e){setTimeout(e,16)},Be={_isElement(e){return!!(e&&e.nodeType==1)},_isFunction(e){return!!(e&&e.constructor&&e.call&&e.apply)},_isPlainObject(e){return!!e&&e.constructor===Object},_isArray(e){return Object.prototype.toString.call(e)===fV},_isNumber(e){return Object.prototype.toString.call(e)===hV&&!isNaN(e)&&isFinite(e)},_isString(e){return Object.prototype.toString.call(e)===pV},_isBoolean(e){return Object.prototype.toString.call(e)===mV},isObject(e){return e instanceof Object},isValidSelector(e){if(typeof e!="string")return!1;const t=e[0];return t==="#"||t==="."||t===t.toUpperCase()},_sign(e){return e===0||e>0?1:-1},requestAnimFrame(e){Jm.push(e),Jm.length===1&&SV(function(){const t=Jm;Jm=[],t.forEach(function(n){n()})})},createCanvasElement(){X4();const e=document.createElement("canvas");try{e.style=e.style||{}}catch{}return e},createImageElement(){return X4(),document.createElement("img")},_isInDocument(e){for(;e=e.parentNode;)if(e==document)return!0;return!1},_urlToImage(e,t){const n=Be.createImageElement();n.onload=function(){t(n)},n.src=e},_rgbToHex(e,t,n){return((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1)},_hexToRgb(e){e=e.replace(ch,yV);const t=parseInt(e,16);return{r:t>>16&255,g:t>>8&255,b:t&255}},getRandomColor(){let e=(Math.random()*16777215<<0).toString(16);for(;e.length<6;)e=bV+e;return ch+e},isCanvasFarblingActive(){if(uh!==null)return uh;if(typeof document>"u")return uh=!1,!1;const e=this.createCanvasElement();e.width=10,e.height=10;const t=e.getContext("2d",{willReadFrequently:!0});t.clearRect(0,0,10,10),t.fillStyle="#282828",t.fillRect(0,0,10,10);const n=t.getImageData(0,0,10,10).data;let r=!1;for(let o=0;o<100;o++)if(n[o*4]!==40||n[o*4+1]!==40||n[o*4+2]!==40||n[o*4+3]!==255){r=!0;break}return uh=r,this.releaseCanvas(e),uh},getHitColor(){const e=this.getRandomColor();return this.isCanvasFarblingActive()?this.getSnappedHexColor(e):e},getHitColorKey(e,t,n){return this.isCanvasFarblingActive()&&(e=Math.round(e/5)*5,t=Math.round(t/5)*5,n=Math.round(n/5)*5),ch+this._rgbToHex(e,t,n)},getSnappedHexColor(e){const t=this._hexToRgb(e);return ch+this._rgbToHex(Math.round(t.r/5)*5,Math.round(t.g/5)*5,Math.round(t.b/5)*5)},getRGB(e){let t;return e in o1?(t=o1[e],{r:t[0],g:t[1],b:t[2]}):e[0]===ch?this._hexToRgb(e.substring(1)):e.substr(0,4)===CV?(t=kV.exec(e.replace(/ /g,"")),{r:parseInt(t[1],10),g:parseInt(t[2],10),b:parseInt(t[3],10)}):{r:0,g:0,b:0}},colorToRGBA(e){return e=e||"black",Be._namedColorToRBA(e)||Be._hex3ColorToRGBA(e)||Be._hex4ColorToRGBA(e)||Be._hex6ColorToRGBA(e)||Be._hex8ColorToRGBA(e)||Be._rgbColorToRGBA(e)||Be._rgbaColorToRGBA(e)||Be._hslColorToRGBA(e)},_namedColorToRBA(e){const t=o1[e.toLowerCase()];return t?{r:t[0],g:t[1],b:t[2],a:1}:null},_rgbColorToRGBA(e){if(e.indexOf("rgb(")===0){e=e.match(/rgb\(([^)]+)\)/)[1];const t=e.split(/ *, */).map(Number);return{r:t[0],g:t[1],b:t[2],a:1}}},_rgbaColorToRGBA(e){if(e.indexOf("rgba(")===0){e=e.match(/rgba\(([^)]+)\)/)[1];const t=e.split(/ *, */).map((n,r)=>n.slice(-1)==="%"?r===3?parseInt(n)/100:parseInt(n)/100*255:Number(n));return{r:t[0],g:t[1],b:t[2],a:t[3]}}},_hex8ColorToRGBA(e){if(e[0]==="#"&&e.length===9)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:parseInt(e.slice(7,9),16)/255}},_hex6ColorToRGBA(e){if(e[0]==="#"&&e.length===7)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:1}},_hex4ColorToRGBA(e){if(e[0]==="#"&&e.length===5)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:parseInt(e[4]+e[4],16)/255}},_hex3ColorToRGBA(e){if(e[0]==="#"&&e.length===4)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:1}},_hslColorToRGBA(e){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(e)){const[t,...n]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e),r=Number(n[0])/360,o=Number(n[1])/100,i=Number(n[2])/100;let s,a,l;if(o===0)return l=i*255,{r:Math.round(l),g:Math.round(l),b:Math.round(l),a:1};i<.5?s=i*(1+o):s=i+o-i*o;const u=2*i-s,d=[0,0,0];for(let f=0;f<3;f++)a=r+1/3*-(f-1),a<0&&a++,a>1&&a--,6*a<1?l=u+(s-u)*6*a:2*a<1?l=s:3*a<2?l=u+(s-u)*(2/3-a)*6:l=u,d[f]=l*255;return{r:Math.round(d[0]),g:Math.round(d[1]),b:Math.round(d[2]),a:1}}},haveIntersection(e,t){return!(t.x>e.x+e.width||t.x+t.width<e.x||t.y>e.y+e.height||t.y+t.height<e.y)},cloneObject(e){const t={};for(const n in e)this._isPlainObject(e[n])?t[n]=this.cloneObject(e[n]):this._isArray(e[n])?t[n]=this.cloneArray(e[n]):t[n]=e[n];return t},cloneArray(e){return e.slice(0)},degToRad(e){return e*gV},radToDeg(e){return e*vV},_degToRad(e){return Be.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),Be.degToRad(e)},_radToDeg(e){return Be.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),Be.radToDeg(e)},_getRotation(e){return xt.angleDeg?Be.radToDeg(e):e},_capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)},throw(e){throw new Error(Z4+e)},error(e){console.error(Z4+e)},warn(e){xt.showWarnings&&console.warn(wV+e)},each(e,t){for(const n in e)t(n,e[n])},_inRange(e,t,n){return t<=e&&e<n},_getProjectionToSegment(e,t,n,r,o,i){let s,a,l;const u=(e-n)*(e-n)+(t-r)*(t-r);if(u==0)s=e,a=t,l=(o-n)*(o-n)+(i-r)*(i-r);else{const d=((o-e)*(n-e)+(i-t)*(r-t))/u;d<0?(s=e,a=t,l=(e-o)*(e-o)+(t-i)*(t-i)):d>1?(s=n,a=r,l=(n-o)*(n-o)+(r-i)*(r-i)):(s=e+d*(n-e),a=t+d*(r-t),l=(s-o)*(s-o)+(a-i)*(a-i))}return[s,a,l]},_getProjectionToLine(e,t,n){const r=Be.cloneObject(e);let o=Number.MAX_VALUE;return t.forEach(function(i,s){if(!n&&s===t.length-1)return;const a=t[(s+1)%t.length],l=Be._getProjectionToSegment(i.x,i.y,a.x,a.y,e.x,e.y),u=l[0],d=l[1],f=l[2];f<o&&(r.x=u,r.y=d,o=f)}),r},_prepareArrayForTween(e,t,n){const r=[],o=[];if(e.length>t.length){const s=t;t=e,e=s}for(let s=0;s<e.length;s+=2)r.push({x:e[s],y:e[s+1]});for(let s=0;s<t.length;s+=2)o.push({x:t[s],y:t[s+1]});const i=[];return o.forEach(function(s){const a=Be._getProjectionToLine(s,r,n);i.push(a.x),i.push(a.y)}),i},_prepareToStringify(e){let t;e.visitedByCircularReferenceRemoval=!0;for(const n in e)if(e.hasOwnProperty(n)&&e[n]&&typeof e[n]=="object"){if(t=Object.getOwnPropertyDescriptor(e,n),e[n].visitedByCircularReferenceRemoval||Be._isElement(e[n]))if(t.configurable)delete e[n];else return null;else if(Be._prepareToStringify(e[n])===null)if(t.configurable)delete e[n];else return null}return delete e.visitedByCircularReferenceRemoval,e},_assign(e,t){for(const n in t)e[n]=t[n];return e},_getFirstPointerId(e){return e.touches?e.changedTouches[0].identifier:e.pointerId||999},releaseCanvas(...e){xt.releaseCanvasOnDestroy&&e.forEach(t=>{t.width=0,t.height=0})},drawRoundedRectPath(e,t,n,r){let o=t<0?t:0,i=n<0?n:0;t=Math.abs(t),n=Math.abs(n);let s=0,a=0,l=0,u=0;typeof r=="number"?s=a=l=u=Math.min(r,t/2,n/2):(s=Math.min(r[0]||0,t/2,n/2),a=Math.min(r[1]||0,t/2,n/2),u=Math.min(r[2]||0,t/2,n/2),l=Math.min(r[3]||0,t/2,n/2)),e.moveTo(o+s,i),e.lineTo(o+t-a,i),e.arc(o+t-a,i+a,a,Math.PI*3/2,0,!1),e.lineTo(o+t,i+n-u),e.arc(o+t-u,i+n-u,u,0,Math.PI/2,!1),e.lineTo(o+l,i+n),e.arc(o+l,i+n-l,l,Math.PI/2,Math.PI,!1),e.lineTo(o,i+s),e.arc(o+s,i+s,s,Math.PI,Math.PI*3/2,!1)},drawRoundedPolygonPath(e,t,n,r,o){r=Math.abs(r);for(let i=0;i<n;i++){const s=t[(i-1+n)%n],a=t[i],l=t[(i+1)%n],u={x:a.x-s.x,y:a.y-s.y},d={x:l.x-a.x,y:l.y-a.y},f=Math.hypot(u.x,u.y),p=Math.hypot(d.x,d.y);let g;typeof o=="number"?g=o:g=i<o.length?o[i]:0,g=r*Math.cos(Math.PI/n)*Math.min(1,g/r*2);const m={x:u.x/f,y:u.y/f},v={x:d.x/p,y:d.y/p},C={x:a.x-m.x*g,y:a.y-m.y*g},w={x:a.x+v.x*g,y:a.y+v.y*g};i===0?e.moveTo(C.x,C.y):e.lineTo(C.x,C.y),e.arcTo(a.x,a.y,w.x,w.y,g)}}};function _V(e){const t=[],n=e.length,r=Be;for(let o=0;o<n;o++){let i=e[o];r._isNumber(i)?i=Math.round(i*1e3)/1e3:r._isString(i)||(i=i+""),t.push(i)}return t}var Q4=",",AV="(",IV=")",EV="([",xV="])",TV=";",RV="()",MV="=",J4=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"],LV=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled","filter"],PV=100,eg=null;function eI(){if(eg!==null)return eg;try{const e=Be.createCanvasElement().getContext("2d");return e?!!e&&"filter"in e:(eg=!1,!1)}catch{return eg=!1,!1}}var tg=class{constructor(e){this.canvas=e,xt.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(e){e.fillEnabled()&&this._fill(e)}_fill(e){}strokeShape(e){e.hasStroke()&&this._stroke(e)}_stroke(e){}fillStrokeShape(e){e.attrs.fillAfterStrokeEnabled?(this.strokeShape(e),this.fillShape(e)):(this.fillShape(e),this.strokeShape(e))}getTrace(e,t){let n=this.traceArr,r=n.length,o="",i,s,a,l;for(i=0;i<r;i++)s=n[i],a=s.method,a?(l=s.args,o+=a,e?o+=RV:Be._isArray(l[0])?o+=EV+l.join(Q4)+xV:(t&&(l=l.map(u=>typeof u=="number"?Math.floor(u):u)),o+=AV+l.join(Q4)+IV)):(o+=s.property,e||(o+=MV+s.val)),o+=TV;return o}clearTrace(){this.traceArr=[]}_trace(e){let t=this.traceArr,n;t.push(e),n=t.length,n>=PV&&t.shift()}reset(){const e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){const t=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,t.getWidth()/t.pixelRatio,t.getHeight()/t.pixelRatio)}_applyLineCap(e){const t=e.attrs.lineCap;t&&this.setAttr("lineCap",t)}_applyOpacity(e){const t=e.getAbsoluteOpacity();t!==1&&this.setAttr("globalAlpha",t)}_applyLineJoin(e){const t=e.attrs.lineJoin;t&&this.setAttr("lineJoin",t)}_applyMiterLimit(e){const t=e.attrs.miterLimit;t!=null&&this.setAttr("miterLimit",t)}setAttr(e,t){this._context[e]=t}arc(e,t,n,r,o,i){this._context.arc(e,t,n,r,o,i)}arcTo(e,t,n,r,o){this._context.arcTo(e,t,n,r,o)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,n,r,o,i){this._context.bezierCurveTo(e,t,n,r,o,i)}clearRect(e,t,n,r){this._context.clearRect(e,t,n,r)}clip(...e){this._context.clip.apply(this._context,e)}closePath(){this._context.closePath()}createImageData(e,t){const n=arguments;if(n.length===2)return this._context.createImageData(e,t);if(n.length===1)return this._context.createImageData(e)}createLinearGradient(e,t,n,r){return this._context.createLinearGradient(e,t,n,r)}createPattern(e,t){return this._context.createPattern(e,t)}createRadialGradient(e,t,n,r,o,i){return this._context.createRadialGradient(e,t,n,r,o,i)}drawImage(e,t,n,r,o,i,s,a,l){const u=arguments,d=this._context;u.length===3?d.drawImage(e,t,n):u.length===5?d.drawImage(e,t,n,r,o):u.length===9&&d.drawImage(e,t,n,r,o,i,s,a,l)}ellipse(e,t,n,r,o,i,s,a){this._context.ellipse(e,t,n,r,o,i,s,a)}isPointInPath(e,t,n,r){return n?this._context.isPointInPath(n,e,t,r):this._context.isPointInPath(e,t,r)}fill(...e){this._context.fill.apply(this._context,e)}fillRect(e,t,n,r){this._context.fillRect(e,t,n,r)}strokeRect(e,t,n,r){this._context.strokeRect(e,t,n,r)}fillText(e,t,n,r){r?this._context.fillText(e,t,n,r):this._context.fillText(e,t,n)}measureText(e){return this._context.measureText(e)}getImageData(e,t,n,r){return this._context.getImageData(e,t,n,r)}lineTo(e,t){this._context.lineTo(e,t)}moveTo(e,t){this._context.moveTo(e,t)}rect(e,t,n,r){this._context.rect(e,t,n,r)}roundRect(e,t,n,r,o){this._context.roundRect(e,t,n,r,o)}putImageData(e,t,n){this._context.putImageData(e,t,n)}quadraticCurveTo(e,t,n,r){this._context.quadraticCurveTo(e,t,n,r)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,t){this._context.scale(e,t)}setLineDash(e){this._context.setLineDash?this._context.setLineDash(e):"mozDash"in this._context?this._context.mozDash=e:"webkitLineDash"in this._context&&(this._context.webkitLineDash=e)}getLineDash(){return this._context.getLineDash()}setTransform(e,t,n,r,o,i){this._context.setTransform(e,t,n,r,o,i)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,t,n,r){this._context.strokeText(e,t,n,r)}transform(e,t,n,r,o,i){this._context.transform(e,t,n,r,o,i)}translate(e,t){this._context.translate(e,t)}_enableTrace(){let e=this,t=J4.length,n=this.setAttr,r,o;const i=function(s){let a=e[s],l;e[s]=function(){return o=_V(Array.prototype.slice.call(arguments,0)),l=a.apply(e,arguments),e._trace({method:s,args:o}),l}};for(r=0;r<t;r++)i(J4[r]);e.setAttr=function(){n.apply(e,arguments);const s=arguments[0];let a=arguments[1];(s==="shadowOffsetX"||s==="shadowOffsetY"||s==="shadowBlur")&&(a=a/this.canvas.getPixelRatio()),e._trace({property:s,val:a})}}_applyGlobalCompositeOperation(e){const t=e.attrs.globalCompositeOperation;!t||t==="source-over"||this.setAttr("globalCompositeOperation",t)}};LV.forEach(function(e){Object.defineProperty(tg.prototype,e,{get(){return this._context[e]},set(t){this._context[e]=t}})});var DV=class extends tg{constructor(e,{willReadFrequently:t=!1}={}){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:t})}_fillColor(e){const t=e.fill();this.setAttr("fillStyle",t),e._fillFunc(this)}_fillPattern(e){this.setAttr("fillStyle",e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){const t=e._getLinearGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fillRadialGradient(e){const t=e._getRadialGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fill(e){const t=e.fill(),n=e.getFillPriority();if(t&&n==="color"){this._fillColor(e);return}const r=e.getFillPatternImage();if(r&&n==="pattern"){this._fillPattern(e);return}const o=e.getFillLinearGradientColorStops();if(o&&n==="linear-gradient"){this._fillLinearGradient(e);return}const i=e.getFillRadialGradientColorStops();if(i&&n==="radial-gradient"){this._fillRadialGradient(e);return}t?this._fillColor(e):r?this._fillPattern(e):o?this._fillLinearGradient(e):i&&this._fillRadialGradient(e)}_strokeLinearGradient(e){const t=e.getStrokeLinearGradientStartPoint(),n=e.getStrokeLinearGradientEndPoint(),r=e.getStrokeLinearGradientColorStops(),o=this.createLinearGradient(t.x,t.y,n.x,n.y);if(r){for(let i=0;i<r.length;i+=2)o.addColorStop(r[i],r[i+1]);this.setAttr("strokeStyle",o)}}_stroke(e){const t=e.dash(),n=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!n){this.save();const r=this.getCanvas().getPixelRatio();this.setTransform(r,0,0,r,0,0)}this._applyLineCap(e),t&&e.dashEnabled()&&(this.setLineDash(t),this.setAttr("lineDashOffset",e.dashOffset())),this.setAttr("lineWidth",e.strokeWidth()),e.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)"),e.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(e):this.setAttr("strokeStyle",e.stroke()),e._strokeFunc(this),n||this.restore()}}_applyShadow(e){var t,n,r;const o=(t=e.getShadowRGBA())!==null&&t!==void 0?t:"black",i=(n=e.getShadowBlur())!==null&&n!==void 0?n:5,s=(r=e.getShadowOffset())!==null&&r!==void 0?r:{x:0,y:0},a=e.getAbsoluteScale(),l=this.canvas.getPixelRatio(),u=a.x*l,d=a.y*l;this.setAttr("shadowColor",o),this.setAttr("shadowBlur",i*Math.min(Math.abs(u),Math.abs(d))),this.setAttr("shadowOffsetX",s.x*u),this.setAttr("shadowOffsetY",s.y*d)}},OV=class extends tg{constructor(e){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:!0})}_fill(e){this.save(),this.setAttr("fillStyle",e.colorKey),e._fillFuncHit(this),this.restore()}strokeShape(e){e.hasHitStroke()&&this._stroke(e)}_stroke(e){if(e.hasHitStroke()){const t=e.getStrokeScaleEnabled();if(!t){this.save();const o=this.getCanvas().getPixelRatio();this.setTransform(o,0,0,o,0,0)}this._applyLineCap(e);const n=e.hitStrokeWidth(),r=n==="auto"?e.strokeWidth():n;this.setAttr("lineWidth",r),this.setAttr("strokeStyle",e.colorKey),e._strokeFuncHit(this),t||this.restore()}}},ng;function FV(){if(ng)return ng;const e=Be.createCanvasElement(),t=e.getContext("2d");return ng=(function(){return(xt._global.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)})(),Be.releaseCanvas(e),ng}var i1=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;const t=(e||{}).pixelRatio||xt.pixelRatio||FV();this.pixelRatio=t,this._canvas=Be.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(e){const t=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/t,this.getHeight()/t)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+"px";const t=this.pixelRatio;this.getContext()._context.scale(t,t)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+"px";const t=this.pixelRatio;this.getContext()._context.scale(t,t)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,t){this.setWidth(e||0),this.setHeight(t||0)}toDataURL(e,t){try{return this._canvas.toDataURL(e,t)}catch{try{return this._canvas.toDataURL()}catch(r){return Be.error("Unable to get data URL. "+r.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}},jl=class extends i1{constructor(e={width:0,height:0,willReadFrequently:!1}){super(e),this.context=new DV(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}},s1=class extends i1{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new OV(this),this.setSize(e.width,e.height)}},$n={get isDragging(){let e=!1;return $n._dragElements.forEach(t=>{t.dragStatus==="dragging"&&(e=!0)}),e},justDragged:!1,get node(){let e;return $n._dragElements.forEach(t=>{e=t.node}),e},_dragElements:new Map,_drag(e){const t=[];$n._dragElements.forEach((n,r)=>{const{node:o}=n,i=o.getStage();i.setPointersPositions(e),n.pointerId===void 0&&(n.pointerId=Be._getFirstPointerId(e));const s=i._changedPointerPositions.find(a=>a.id===n.pointerId);if(s){if(n.dragStatus!=="dragging"){const a=o.dragDistance();if(Math.max(Math.abs(s.x-n.startPointerPos.x),Math.abs(s.y-n.startPointerPos.y))<a||(o.startDrag({evt:e}),!o.isDragging()))return}o._setDragPosition(e,n),t.push(o)}}),t.forEach(n=>{n.getStage()&&n.fire("dragmove",{type:"dragmove",target:n,evt:e},!0)})},_endDragBefore(e){const t=[];$n._dragElements.forEach(n=>{const{node:r}=n,o=r.getStage();if(e&&o.setPointersPositions(e),!o._changedPointerPositions.find(s=>s.id===n.pointerId))return;(n.dragStatus==="dragging"||n.dragStatus==="stopped")&&($n.justDragged=!0,xt._mouseListenClick=!1,xt._touchListenClick=!1,xt._pointerListenClick=!1,n.dragStatus="stopped");const i=n.node.getLayer()||n.node instanceof xt.Stage&&n.node;i&&t.indexOf(i)===-1&&t.push(i)}),t.forEach(n=>{n.draw()})},_endDragAfter(e){$n._dragElements.forEach((t,n)=>{t.dragStatus==="stopped"&&t.node.fire("dragend",{type:"dragend",target:t.node,evt:e},!0),t.dragStatus!=="dragging"&&$n._dragElements.delete(n)})}};xt.isBrowser&&(window.addEventListener("mouseup",$n._endDragBefore,!0),window.addEventListener("touchend",$n._endDragBefore,!0),window.addEventListener("touchcancel",$n._endDragBefore,!0),window.addEventListener("mousemove",$n._drag),window.addEventListener("touchmove",$n._drag),window.addEventListener("mouseup",$n._endDragAfter,!1),window.addEventListener("touchend",$n._endDragAfter,!1),window.addEventListener("touchcancel",$n._endDragAfter,!1));function Vl(e){return Be._isString(e)?'"'+e+'"':Object.prototype.toString.call(e)==="[object Number]"||Be._isBoolean(e)?e:Object.prototype.toString.call(e)}function tI(e){return e>255?255:e<0?0:Math.round(e)}function St(){if(xt.isUnminified)return function(e,t){return Be._isNumber(e)||Be.warn(Vl(e)+' is a not valid value for "'+t+'" attribute. The value should be a number.'),e}}function rg(e){if(xt.isUnminified)return function(t,n){let r=Be._isNumber(t),o=Be._isArray(t)&&t.length==e;return!r&&!o&&Be.warn(Vl(t)+' is a not valid value for "'+n+'" attribute. The value should be a number or Array<number>('+e+")"),t}}function a1(){if(xt.isUnminified)return function(e,t){return Be._isNumber(e)||e==="auto"||Be.warn(Vl(e)+' is a not valid value for "'+t+'" attribute. The value should be a number or "auto".'),e}}function Nc(){if(xt.isUnminified)return function(e,t){return Be._isString(e)||Be.warn(Vl(e)+' is a not valid value for "'+t+'" attribute. The value should be a string.'),e}}function nI(){if(xt.isUnminified)return function(e,t){const n=Be._isString(e),r=Object.prototype.toString.call(e)==="[object CanvasGradient]"||e&&e.addColorStop;return n||r||Be.warn(Vl(e)+' is a not valid value for "'+t+'" attribute. The value should be a string or a native gradient.'),e}}function NV(){if(xt.isUnminified)return function(e,t){const n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&e instanceof n||(Be._isArray(e)?e.forEach(function(r){Be._isNumber(r)||Be.warn('"'+t+'" attribute has non numeric element '+r+". Make sure that all elements are numbers.")}):Be.warn(Vl(e)+' is a not valid value for "'+t+'" attribute. The value should be a array of numbers.')),e}}function vs(){if(xt.isUnminified)return function(e,t){return e===!0||e===!1||Be.warn(Vl(e)+' is a not valid value for "'+t+'" attribute. The value should be a boolean.'),e}}function BV(e){if(xt.isUnminified)return function(t,n){return t==null||Be.isObject(t)||Be.warn(Vl(t)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+e),t}}var dh="get",fh="set",ge={addGetterSetter(e,t,n,r,o){ge.addGetter(e,t,n),ge.addSetter(e,t,r,o),ge.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){const r=dh+Be._capitalize(t);e.prototype[r]=e.prototype[r]||function(){const o=this.attrs[t];return o===void 0?n:o}},addSetter(e,t,n,r){const o=fh+Be._capitalize(t);e.prototype[o]||ge.overWriteSetter(e,t,n,r)},overWriteSetter(e,t,n,r){const o=fh+Be._capitalize(t);e.prototype[o]=function(i){return n&&i!==void 0&&i!==null&&(i=n.call(this,i,t)),this._setAttr(t,i),r&&r.call(this),this}},addComponentsGetterSetter(e,t,n,r,o){const i=n.length,s=Be._capitalize,a=dh+s(t),l=fh+s(t);e.prototype[a]=function(){const d={};for(let f=0;f<i;f++){const p=n[f];d[p]=this.getAttr(t+s(p))}return d};const u=BV(n);e.prototype[l]=function(d){const f=this.attrs[t];r&&(d=r.call(this,d,t)),u&&u.call(this,d,t);for(const p in d)d.hasOwnProperty(p)&&this._setAttr(t+s(p),d[p]);return d||n.forEach(p=>{this._setAttr(t+s(p),void 0)}),this._fireChangeEvent(t,f,d),o&&o.call(this),this},ge.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){const n=Be._capitalize(t),r=fh+n,o=dh+n;e.prototype[t]=function(){return arguments.length?(this[r](arguments[0]),this):this[o]()}},addDeprecatedGetterSetter(e,t,n,r){Be.error("Adding deprecated "+t);const o=dh+Be._capitalize(t),i=t+" property is deprecated and will be removed soon. Look at Konva change log for more information.";e.prototype[o]=function(){Be.error(i);const s=this.attrs[t];return s===void 0?n:s},ge.addSetter(e,t,r,function(){Be.error(i)}),ge.addOverloadedGetterSetter(e,t)},backCompat(e,t){Be.each(t,function(n,r){const o=e.prototype[r],i=dh+Be._capitalize(n),s=fh+Be._capitalize(n);function a(){o.apply(this,arguments),Be.error('"'+n+'" method is deprecated and will be removed soon. Use ""'+r+'" instead.')}e.prototype[n]=a,e.prototype[i]=a,e.prototype[s]=a})},afterSetFilter(){this._filterUpToDate=!1}};function zV(e){const t=/(\w+)\(([^)]+)\)/g;let n;for(;(n=t.exec(e))!==null;){const[,r,o]=n;switch(r){case"blur":{const i=parseFloat(o.replace("px",""));return function(s){this.blurRadius(i*.5);const a=xt.Filters;a&&a.Blur&&a.Blur.call(this,s)}}case"brightness":{const i=o.includes("%")?parseFloat(o)/100:parseFloat(o);return function(s){this.brightness(i);const a=xt.Filters;a&&a.Brightness&&a.Brightness.call(this,s)}}case"contrast":{const i=parseFloat(o);return function(s){const a=100*(Math.sqrt(i)-1);this.contrast(a);const l=xt.Filters;l&&l.Contrast&&l.Contrast.call(this,s)}}case"grayscale":return function(i){const s=xt.Filters;s&&s.Grayscale&&s.Grayscale.call(this,i)};case"sepia":return function(i){const s=xt.Filters;s&&s.Sepia&&s.Sepia.call(this,i)};case"invert":return function(i){const s=xt.Filters;s&&s.Invert&&s.Invert.call(this,i)};default:Be.warn(`CSS filter "${r}" is not supported in fallback mode. Consider using function filters for better compatibility.`);break}}return()=>{}}var og="absoluteOpacity",rI="allEventListeners",Ka="absoluteTransform",oI="absoluteScale",Bc="canvas",jV="Change",VV="children",UV="konva",l1="listening",$V="mouseenter",HV="mouseleave",GV="pointerenter",WV="pointerleave",KV="touchenter",qV="touchleave",iI="set",sI="Shape",ig=" ",aI="stage",Ul="transform",YV="Stage",c1="visible",XV=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(ig),ZV=1,Tt=class Qh{constructor(t){this._id=ZV++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){(t===Ul||t===Ka)&&this._cache.get(t)?this._cache.get(t).dirty=!0:t?this._cache.delete(t):this._cache.clear()}_getCache(t,n){let r=this._cache.get(t);return(r===void 0||(t===Ul||t===Ka)&&r.dirty===!0)&&(r=n.call(this),this._cache.set(t,r)),r}_calculate(t,n,r){if(!this._attachedDepsListeners.get(t)){const o=n.map(i=>i+"Change.konva").join(ig);this.on(o,()=>{this._clearCache(t)}),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,r)}_getCanvasCache(){return this._cache.get(Bc)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===Ka&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(Bc)){const{scene:t,filter:n,hit:r}=this._cache.get(Bc);Be.releaseCanvas(t._canvas,n._canvas,r._canvas),this._cache.delete(Bc)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(t){const n=t||{};let r={};(n.x===void 0||n.y===void 0||n.width===void 0||n.height===void 0)&&(r=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let o=Math.ceil(n.width||r.width),i=Math.ceil(n.height||r.height),s=n.pixelRatio,a=n.x===void 0?Math.floor(r.x):n.x,l=n.y===void 0?Math.floor(r.y):n.y,u=n.offset||0,d=n.drawBorder||!1,f=n.hitCanvasPixelRatio||1;if(!o||!i){Be.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");return}const p=Math.abs(Math.round(r.x)-a)>.5?1:0,g=Math.abs(Math.round(r.y)-l)>.5?1:0;o+=u*2+p,i+=u*2+g,a-=u,l-=u;const m=new jl({pixelRatio:s,width:o,height:i}),v=new jl({pixelRatio:s,width:0,height:0,willReadFrequently:!0}),C=new s1({pixelRatio:f,width:o,height:i}),w=m.getContext(),S=C.getContext(),b=new jl({width:m.width/m.pixelRatio+Math.abs(a),height:m.height/m.pixelRatio+Math.abs(l),pixelRatio:m.pixelRatio}),k=b.getContext();return C.isCache=!0,m.isCache=!0,this._cache.delete(Bc),this._filterUpToDate=!1,n.imageSmoothingEnabled===!1&&(m.getContext()._context.imageSmoothingEnabled=!1,v.getContext()._context.imageSmoothingEnabled=!1),w.save(),S.save(),k.save(),w.translate(-a,-l),S.translate(-a,-l),k.translate(-a,-l),b.x=a,b.y=l,this._isUnderCache=!0,this._clearSelfAndDescendantCache(og),this._clearSelfAndDescendantCache(oI),this.drawScene(m,this,b),this.drawHit(C,this),this._isUnderCache=!1,w.restore(),S.restore(),d&&(w.save(),w.beginPath(),w.rect(0,0,o,i),w.closePath(),w.setAttr("strokeStyle","red"),w.setAttr("lineWidth",5),w.stroke(),w.restore()),Be.releaseCanvas(b._canvas),this._cache.set(Bc,{scene:m,filter:v,hit:C,x:a,y:l}),this._requestDraw(),this}isCached(){return this._cache.has(Bc)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,n){const r=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];let o=1/0,i=1/0,s=-1/0,a=-1/0;const l=this.getAbsoluteTransform(n);return r.forEach(function(u){const d=l.point(u);o===void 0&&(o=s=d.x,i=a=d.y),o=Math.min(o,d.x),i=Math.min(i,d.y),s=Math.max(s,d.x),a=Math.max(a,d.y)}),{x:o,y:i,width:s-o,height:a-i}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const n=this._getCanvasCache();t.translate(n.x,n.y);const r=this._getCachedSceneCanvas(),o=r.pixelRatio;t.drawImage(r._canvas,0,0,r.width/o,r.height/o),t.restore()}_drawCachedHitCanvas(t){const n=this._getCanvasCache(),r=n.hit;t.save(),t.translate(n.x,n.y),t.drawImage(r._canvas,0,0,r.width/r.pixelRatio,r.height/r.pixelRatio),t.restore()}_getCachedSceneCanvas(){let t=this.filters(),n=this._getCanvasCache(),r=n.scene,o=n.filter,i=o.getContext(),s,a,l,u;if(!t||t.length===0)return r;if(this._filterUpToDate)return o;let d=!0;for(let p=0;p<t.length;p++)if(typeof t[p]=="string"&&eI(),typeof t[p]!="string"||!eI()){d=!1;break}const f=r.pixelRatio;if(o.setSize(r.width/r.pixelRatio,r.height/r.pixelRatio),d){const p=t.join(" ");return i.save(),i.setAttr("filter",p),i.drawImage(r._canvas,0,0,r.getWidth()/f,r.getHeight()/f),i.restore(),this._filterUpToDate=!0,o}try{for(s=t.length,i.clear(),i.drawImage(r._canvas,0,0,r.getWidth()/f,r.getHeight()/f),a=i.getImageData(0,0,o.getWidth(),o.getHeight()),l=0;l<s;l++)u=t[l],typeof u=="string"&&(u=zV(u)),u.call(this,a),i.putImageData(a,0,0)}catch(p){Be.error("Unable to apply filter. "+p.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}return this._filterUpToDate=!0,o}on(...t){const n=t[0],r=t[1];if(t[2],this._cache&&this._cache.delete(rI),t.length===3)return this._delegate.apply(this,t);const o=n.split(ig);for(let i=0;i<o.length;i++){const s=o[i].split("."),a=s[0],l=s[1]||"";this.eventListeners[a]||(this.eventListeners[a]=[]),this.eventListeners[a].push({name:l,handler:r})}return this}off(t,n){let r=(t||"").split(ig),o=r.length,i,s,a,l,u,d;if(this._cache&&this._cache.delete(rI),!t)for(s in this.eventListeners)this._off(s);for(i=0;i<o;i++)if(a=r[i],l=a.split("."),u=l[0],d=l[1],u)this.eventListeners[u]&&this._off(u,d,n);else for(s in this.eventListeners)this._off(s,d,n);return this}dispatchEvent(t){const n={target:this,type:t.type,evt:t};return this.fire(t.type,n),this}addEventListener(t,n){return this.on(t,function(r){n.call(this,r.evt)}),this}removeEventListener(t){return this.off(t),this}_delegate(t,n,r){const o=this;return this.on(t,function(i){const s=i.target.findAncestors(n,!0,o);for(let a=0;a<s.length;a++)i=Be.cloneObject(i),i.currentTarget=s[a],r.call(s[a],i)}),this}remove(){return this.isDragging()&&this.stopDrag(),$n._dragElements.delete(this._id),$n._dragElements.forEach((t,n)=>{this.isAncestorOf(t.node)&&$n._dragElements.delete(n)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(Ka),this._clearSelfAndDescendantCache(og),this._clearSelfAndDescendantCache(oI),this._clearSelfAndDescendantCache(aI),this._clearSelfAndDescendantCache(c1),this._clearSelfAndDescendantCache(l1)}_remove(){this._clearCaches();const t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(t){const n="get"+Be._capitalize(t);return Be._isFunction(this[n])?this[n]():this.attrs[t]}getAncestors(){let t=this.getParent(),n=[];for(;t;)n.push(t),t=t.getParent();return n}getAttrs(){return this.attrs||{}}setAttrs(t){return this._batchTransformChanges(()=>{let n,r;if(!t)return this;for(n in t)n!==VV&&(r=iI+Be._capitalize(n),Be._isFunction(this[r])?this[r](t[n]):this._setAttr(n,t[n]))}),this}isListening(){return this._getCache(l1,this._isListening)}_isListening(t){if(!this.listening())return!1;const n=this.getParent();return n&&n!==t&&this!==t?n._isListening(t):!0}isVisible(){return this._getCache(c1,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const n=this.getParent();return n&&n!==t&&this!==t?n._isVisible(t):!0}shouldDrawHit(t,n=!1){if(t)return this._isVisible(t)&&this._isListening(t);const r=this.getLayer();let o=!1;$n._dragElements.forEach(s=>{s.dragStatus==="dragging"&&(s.node.nodeType==="Stage"||s.node.getLayer()===r)&&(o=!0)});const i=!n&&!xt.hitOnDragEnabled&&(o||xt.isTransforming());return this.isListening()&&this.isVisible()&&!i}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t=this.getDepth(),n=this,r=0,o,i,s,a;function l(d){for(o=[],i=d.length,s=0;s<i;s++)a=d[s],r++,a.nodeType!==sI&&(o=o.concat(a.getChildren().slice())),a._id===n._id&&(s=i);o.length>0&&o[0].getDepth()<=t&&l(o)}const u=this.getStage();return n.nodeType!==YV&&u&&l(u.getChildren()),r}getDepth(){let t=0,n=this.parent;for(;n;)t++,n=n.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(Ul),this._clearSelfAndDescendantCache(Ka)),this._needClearTransformCache=!1}setPosition(t){return this._batchTransformChanges(()=>{this.x(t.x),this.y(t.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;const n=t.getPointerPosition();if(!n)return null;const r=this.getAbsoluteTransform().copy();return r.invert(),r.point(n)}getAbsolutePosition(t){let n=!1,r=this.parent;for(;r;){if(r.isCached()){n=!0;break}r=r.parent}n&&!t&&(t=!0);const o=this.getAbsoluteTransform(t).getMatrix(),i=new gs,s=this.offset();return i.m=o.slice(),i.translate(s.x,s.y),i.getTranslation()}setAbsolutePosition(t){const{x:n,y:r,...o}=this._clearTransform();this.attrs.x=n,this.attrs.y=r,this._clearCache(Ul);const i=this._getAbsoluteTransform().copy();return i.invert(),i.translate(t.x,t.y),t={x:this.attrs.x+i.getTranslation().x,y:this.attrs.y+i.getTranslation().y},this._setTransform(o),this.setPosition({x:t.x,y:t.y}),this._clearCache(Ul),this._clearSelfAndDescendantCache(Ka),this}_setTransform(t){let n;for(n in t)this.attrs[n]=t[n]}_clearTransform(){const t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){let n=t.x,r=t.y,o=this.x(),i=this.y();return n!==void 0&&(o+=n),r!==void 0&&(i+=r),this.setPosition({x:o,y:i}),this}_eachAncestorReverse(t,n){let r=[],o=this.getParent(),i,s;if(!(n&&n._id===this._id)){for(r.unshift(this);o&&(!n||o._id!==n._id);)r.unshift(o),o=o.parent;for(i=r.length,s=0;s<i;s++)t(r[s])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return Be.warn("Node has no parent. moveToTop function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1?(this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0):!1}moveUp(){if(!this.parent)return Be.warn("Node has no parent. moveUp function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1?(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0):!1}moveDown(){if(!this.parent)return Be.warn("Node has no parent. moveDown function is ignored."),!1;const t=this.index;return t>0?(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0):!1}moveToBottom(){if(!this.parent)return Be.warn("Node has no parent. moveToBottom function is ignored."),!1;const t=this.index;return t>0?(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0):!1}setZIndex(t){if(!this.parent)return Be.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&Be.warn("Unexpected value "+t+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");const n=this.index;return this.parent.children.splice(n,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(og,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let t=this.opacity();const n=this.getParent();return n&&!n._isUnderCache&&(t*=n.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){let t=this.getAttrs(),n,r,o,i,s;const a={attrs:{},className:this.getClassName()};for(n in t)r=t[n],s=Be.isObject(r)&&!Be._isPlainObject(r)&&!Be._isArray(r),!s&&(o=typeof this[n]=="function"&&this[n],delete t[n],i=o?o.call(this):null,t[n]=r,i!==r&&(a.attrs[n]=r));return Be._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,n,r){const o=[];n&&this._isMatch(t)&&o.push(this);let i=this.parent;for(;i;){if(i===r)return o;i._isMatch(t)&&o.push(i),i=i.parent}return o}isAncestorOf(t){return!1}findAncestor(t,n,r){return this.findAncestors(t,n,r)[0]}_isMatch(t){if(!t)return!1;if(typeof t=="function")return t(this);let n=t.replace(/ /g,"").split(","),r=n.length,o,i;for(o=0;o<r;o++)if(i=n[o],Be.isValidSelector(i)||(Be.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),Be.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),Be.warn("Konva is awesome, right?")),i.charAt(0)==="#"){if(this.id()===i.slice(1))return!0}else if(i.charAt(0)==="."){if(this.hasName(i.slice(1)))return!0}else if(this.className===i||this.nodeType===i)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(aI,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,n={},r){return n.target=n.target||this,r?this._fireAndBubble(t,n):this._fire(t,n),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(Ka,this._getAbsoluteTransform)}_getAbsoluteTransform(t){let n;if(t)return n=new gs,this._eachAncestorReverse(function(r){const o=r.transformsEnabled();o==="all"?n.multiply(r.getTransform()):o==="position"&&n.translate(r.x()-r.offsetX(),r.y()-r.offsetY())},t),n;{n=this._cache.get(Ka)||new gs,this.parent?this.parent.getAbsoluteTransform().copyInto(n):n.reset();const r=this.transformsEnabled();if(r==="all")n.multiply(this.getTransform());else if(r==="position"){const o=this.attrs.x||0,i=this.attrs.y||0,s=this.attrs.offsetX||0,a=this.attrs.offsetY||0;n.translate(o-s,i-a)}return n.dirty=!1,n}}getAbsoluteScale(t){let n=this;for(;n;)n._isUnderCache&&(t=n),n=n.getParent();const r=this.getAbsoluteTransform(t).decompose();return{x:r.scaleX,y:r.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(Ul,this._getTransform)}_getTransform(){var t,n;const r=this._cache.get(Ul)||new gs;r.reset();const o=this.x(),i=this.y(),s=xt.getAngle(this.rotation()),a=(t=this.attrs.scaleX)!==null&&t!==void 0?t:1,l=(n=this.attrs.scaleY)!==null&&n!==void 0?n:1,u=this.attrs.skewX||0,d=this.attrs.skewY||0,f=this.attrs.offsetX||0,p=this.attrs.offsetY||0;return(o!==0||i!==0)&&r.translate(o,i),s!==0&&r.rotate(s),(u!==0||d!==0)&&r.skew(u,d),(a!==1||l!==1)&&r.scale(a,l),(f!==0||p!==0)&&r.translate(-1*f,-1*p),r.dirty=!1,r}clone(t){let n=Be.cloneObject(this.attrs),r,o,i,s,a;for(r in t)n[r]=t[r];const l=new this.constructor(n);for(r in this.eventListeners)for(o=this.eventListeners[r],i=o.length,s=0;s<i;s++)a=o[s],a.name.indexOf(UV)<0&&(l.eventListeners[r]||(l.eventListeners[r]=[]),l.eventListeners[r].push(a));return l}_toKonvaCanvas(t){t=t||{};const n=this.getClientRect(),r=this.getStage(),o=t.x!==void 0?t.x:Math.floor(n.x),i=t.y!==void 0?t.y:Math.floor(n.y),s=t.pixelRatio||1,a=new jl({width:t.width||Math.ceil(n.width)||(r?r.width():0),height:t.height||Math.ceil(n.height)||(r?r.height():0),pixelRatio:s}),l=a.getContext(),u=new jl({width:a.width/a.pixelRatio+Math.abs(o),height:a.height/a.pixelRatio+Math.abs(i),pixelRatio:a.pixelRatio});return t.imageSmoothingEnabled===!1&&(l._context.imageSmoothingEnabled=!1),l.save(),(o||i)&&l.translate(-1*o,-1*i),this.drawScene(a,void 0,u),l.restore(),a}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){t=t||{};const n=t.mimeType||null,r=t.quality||null,o=this._toKonvaCanvas(t).toDataURL(n,r);return t.callback&&t.callback(o),o}toImage(t){return new Promise((n,r)=>{try{const o=t?.callback;o&&delete t.callback,Be._urlToImage(this.toDataURL(t),function(i){n(i),o?.(i)})}catch(o){r(o)}})}toBlob(t){return new Promise((n,r)=>{try{const o=t?.callback;o&&delete t.callback,this.toCanvas(t).toBlob(i=>{n(i),o?.(i)},t?.mimeType,t?.quality)}catch(o){r(o)}})}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return this.attrs.dragDistance!==void 0?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():xt.dragDistance}_off(t,n,r){let o=this.eventListeners[t],i,s,a;for(i=0;i<o.length;i++)if(s=o[i].name,a=o[i].handler,(s!=="konva"||n==="konva")&&(!n||s===n)&&(!r||r===a)){if(o.splice(i,1),o.length===0){delete this.eventListeners[t];break}i--}}_fireChangeEvent(t,n,r){this._fire(t+jV,{oldVal:n,newVal:r})}addName(t){if(!this.hasName(t)){const n=this.name(),r=n?n+" "+t:t;this.name(r)}return this}hasName(t){if(!t)return!1;const n=this.name();return n?(n||"").split(/\s/g).indexOf(t)!==-1:!1}removeName(t){const n=(this.name()||"").split(/\s/g),r=n.indexOf(t);return r!==-1&&(n.splice(r,1),this.name(n.join(" "))),this}setAttr(t,n){const r=this[iI+Be._capitalize(t)];return Be._isFunction(r)?r.call(this,n):this._setAttr(t,n),this}_requestDraw(){if(xt.autoDrawEnabled){const t=this.getLayer()||this.getStage();t?.batchDraw()}}_setAttr(t,n){const r=this.attrs[t];r===n&&!Be.isObject(n)||(n==null?delete this.attrs[t]:this.attrs[t]=n,this._shouldFireChangeEvents&&this._fireChangeEvent(t,r,n),this._requestDraw())}_setComponentAttr(t,n,r){let o;r!==void 0&&(o=this.attrs[t],o||(this.attrs[t]=this.getAttr(t)),this.attrs[t][n]=r,this._fireChangeEvent(t,o,r))}_fireAndBubble(t,n,r){n&&this.nodeType===sI&&(n.target=this);const o=[$V,HV,GV,WV,KV,qV];if(!(o.indexOf(t)!==-1&&(r&&(this===r||this.isAncestorOf&&this.isAncestorOf(r))||this.nodeType==="Stage"&&!r))){this._fire(t,n);const i=o.indexOf(t)!==-1&&r&&r.isAncestorOf&&r.isAncestorOf(this)&&!r.isAncestorOf(this.parent);(n&&!n.cancelBubble||!n)&&this.parent&&this.parent.isListening()&&!i&&(r&&r.parent?this._fireAndBubble.call(this.parent,t,n,r):this._fireAndBubble.call(this.parent,t,n))}}_getProtoListeners(t){var n,r;const{nodeType:o}=this,i=Qh.protoListenerMap.get(o)||{};let s=i?.[t];if(s===void 0){s=[];let a=Object.getPrototypeOf(this);for(;a;){const l=(r=(n=a.eventListeners)===null||n===void 0?void 0:n[t])!==null&&r!==void 0?r:[];s.push(...l),a=Object.getPrototypeOf(a)}i[t]=s,Qh.protoListenerMap.set(o,i)}return s}_fire(t,n){n=n||{},n.currentTarget=this,n.type=t;const r=this._getProtoListeners(t);if(r){const i=r.slice();for(let s=0;s<i.length;s++)i[s].handler.call(this,n)}const o=this.eventListeners[t];if(o){const i=o.slice(),s=i.length;for(let l=0;l<i.length;l++)i[l].handler.call(this,n);const a=this.eventListeners[t];if(a)for(let l=s;l<a.length;l++)a[l].handler.call(this,n)}}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const n=t?t.pointerId:void 0,r=this.getStage(),o=this.getAbsolutePosition();if(!r)return;const i=r._getPointerById(n)||r._changedPointerPositions[0]||o;$n._dragElements.set(this._id,{node:this,startPointerPos:i,offset:{x:i.x-o.x,y:i.y-o.y},dragStatus:"ready",pointerId:n,startEvent:t})}startDrag(t,n=!0){$n._dragElements.has(this._id)||this._createDragElement(t);const r=$n._dragElements.get(this._id);r.dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:r.startEvent&&r.startEvent.evt||t&&t.evt},n)}_setDragPosition(t,n){const r=this.getStage()._getPointerById(n.pointerId);if(!r)return;let o={x:r.x-n.offset.x,y:r.y-n.offset.y};const i=this.dragBoundFunc();if(i!==void 0){const s=i.call(this,o,t);s?o=s:Be.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}(!this._lastPos||this._lastPos.x!==o.x||this._lastPos.y!==o.y)&&(this.setAbsolutePosition(o),this._requestDraw()),this._lastPos=o}stopDrag(t){const n=$n._dragElements.get(this._id);n&&(n.dragStatus="stopped"),$n._endDragBefore(t),$n._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=$n._dragElements.get(this._id);return t?t.dragStatus==="dragging":!1}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(t){if(!(t.evt.button===void 0||xt.dragButtons.indexOf(t.evt.button)>=0)||this.isDragging())return;let n=!1;$n._dragElements.forEach(r=>{this.isAncestorOf(r.node)&&(n=!0)}),n||this._createDragElement(t)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;const t=$n._dragElements.get(this._id),n=t&&t.dragStatus==="dragging",r=t&&t.dragStatus==="ready";n?this.stopDrag():r&&$n._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(t={x:0,y:0}){const n=this.getStage();if(!n)return!1;const r={x:-t.x,y:-t.y,width:n.width()+2*t.x,height:n.height()+2*t.y};return Be.haveIntersection(r,this.getClientRect())}static create(t,n){return Be._isString(t)&&(t=JSON.parse(t)),this._createNode(t,n)}static _createNode(t,n){let r=Qh.prototype.getClassName.call(t),o=t.children,i,s,a;n&&(t.attrs.container=n),xt[r]||(Be.warn('Can not find a node with class name "'+r+'". Fallback to "Shape".'),r="Shape");const l=xt[r];if(i=new l(t.attrs),o)for(s=o.length,a=0;a<s;a++)i.add(Qh._createNode(o[a]));return i}};Tt.protoListenerMap=new Map,Tt.prototype.nodeType="Node",Tt.prototype._attrsAffectingSize=[],Tt.prototype.eventListeners={},Tt.prototype.on(XV,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(Ul),this._clearSelfAndDescendantCache(Ka)}),Tt.prototype.on("visibleChange.konva",function(){this._clearSelfAndDescendantCache(c1)}),Tt.prototype.on("listeningChange.konva",function(){this._clearSelfAndDescendantCache(l1)}),Tt.prototype.on("opacityChange.konva",function(){this._clearSelfAndDescendantCache(og)});var ir=ge.addGetterSetter;ir(Tt,"zIndex"),ir(Tt,"absolutePosition"),ir(Tt,"position"),ir(Tt,"x",0,St()),ir(Tt,"y",0,St()),ir(Tt,"globalCompositeOperation","source-over",Nc()),ir(Tt,"opacity",1,St()),ir(Tt,"name","",Nc()),ir(Tt,"id","",Nc()),ir(Tt,"rotation",0,St()),ge.addComponentsGetterSetter(Tt,"scale",["x","y"]),ir(Tt,"scaleX",1,St()),ir(Tt,"scaleY",1,St()),ge.addComponentsGetterSetter(Tt,"skew",["x","y"]),ir(Tt,"skewX",0,St()),ir(Tt,"skewY",0,St()),ge.addComponentsGetterSetter(Tt,"offset",["x","y"]),ir(Tt,"offsetX",0,St()),ir(Tt,"offsetY",0,St()),ir(Tt,"dragDistance",void 0,St()),ir(Tt,"width",0,St()),ir(Tt,"height",0,St()),ir(Tt,"listening",!0,vs()),ir(Tt,"preventDefault",!0,vs()),ir(Tt,"filters",void 0,function(e){return this._filterUpToDate=!1,e}),ir(Tt,"visible",!0,vs()),ir(Tt,"transformsEnabled","all",Nc()),ir(Tt,"size"),ir(Tt,"dragBoundFunc"),ir(Tt,"draggable",!1,vs()),ge.backCompat(Tt,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});var Mi=class extends Tt{constructor(){super(...arguments),this.children=[]}getChildren(e){const t=this.children||[];return e?t.filter(e):t}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.destroy()}),this.children=[],this._requestDraw(),this}add(...e){if(e.length===0)return this;if(e.length>1){for(let n=0;n<e.length;n++)this.add(e[n]);return this}const t=e[0];return t.getParent()?(t.moveTo(this),this):(this._validateAdd(t),t.index=this.getChildren().length,t.parent=this,t._clearCaches(),this.getChildren().push(t),this._fire("add",{child:t}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(e){return this._generalFind(e,!1)}findOne(e){const t=this._generalFind(e,!0);return t.length>0?t[0]:void 0}_generalFind(e,t){const n=[];return this._descendants(r=>{const o=r._isMatch(e);return o&&n.push(r),!!(o&&t)}),n}_descendants(e){let t=!1;const n=this.getChildren();for(const r of n){if(t=e(r),t)return!0;if(r.hasChildren()&&(t=r._descendants(e),t))return!0}return!1}toObject(){const e=Tt.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach(t=>{e.children.push(t.toObject())}),e}isAncestorOf(e){let t=e.getParent();for(;t;){if(t._id===this._id)return!0;t=t.getParent()}return!1}clone(e){const t=Tt.prototype.clone.call(this,e);return this.getChildren().forEach(function(n){t.add(n.clone())}),t}getAllIntersections(e){const t=[];return this.find("Shape").forEach(n=>{n.isVisible()&&n.intersects(e)&&t.push(n)}),t}_clearSelfAndDescendantCache(e){var t;super._clearSelfAndDescendantCache(e),!this.isCached()&&((t=this.children)===null||t===void 0||t.forEach(function(n){n._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;(e=this.children)===null||e===void 0||e.forEach(function(t,n){t.index=n}),this._requestDraw()}drawScene(e,t,n){const r=this.getLayer(),o=e||r&&r.getCanvas(),i=o&&o.getContext(),s=this._getCanvasCache(),a=s&&s.scene,l=o&&o.isCache;if(!this.isVisible()&&!l)return this;if(a){i.save();const u=this.getAbsoluteTransform(t).getMatrix();i.transform(u[0],u[1],u[2],u[3],u[4],u[5]),this._drawCachedSceneCanvas(i),i.restore()}else this._drawChildren("drawScene",o,t,n);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;const n=this.getLayer(),r=e||n&&n.hitCanvas,o=r&&r.getContext(),i=this._getCanvasCache();if(i&&i.hit){o.save();const s=this.getAbsoluteTransform(t).getMatrix();o.transform(s[0],s[1],s[2],s[3],s[4],s[5]),this._drawCachedHitCanvas(o),o.restore()}else this._drawChildren("drawHit",r,t);return this}_drawChildren(e,t,n,r){var o;const i=t&&t.getContext(),s=this.clipWidth(),a=this.clipHeight(),l=this.clipFunc(),u=typeof s=="number"&&typeof a=="number"||l,d=n===this;if(u){i.save();const p=this.getAbsoluteTransform(n);let g=p.getMatrix();i.transform(g[0],g[1],g[2],g[3],g[4],g[5]),i.beginPath();let m;if(l)m=l.call(this,i,this);else{const v=this.clipX(),C=this.clipY();i.rect(v||0,C||0,s,a)}i.clip.apply(i,m),g=p.copy().invert().getMatrix(),i.transform(g[0],g[1],g[2],g[3],g[4],g[5])}const f=!d&&this.globalCompositeOperation()!=="source-over"&&e==="drawScene";f&&(i.save(),i._applyGlobalCompositeOperation(this)),(o=this.children)===null||o===void 0||o.forEach(function(p){p[e](t,n,r)}),f&&i.restore(),u&&i.restore()}getClientRect(e={}){var t;const n=e.skipTransform,r=e.relativeTo;let o,i,s,a,l={x:1/0,y:1/0,width:0,height:0};const u=this;(t=this.children)===null||t===void 0||t.forEach(function(p){if(!p.visible())return;const g=p.getClientRect({relativeTo:u,skipShadow:e.skipShadow,skipStroke:e.skipStroke});g.width===0&&g.height===0||(o===void 0?(o=g.x,i=g.y,s=g.x+g.width,a=g.y+g.height):(o=Math.min(o,g.x),i=Math.min(i,g.y),s=Math.max(s,g.x+g.width),a=Math.max(a,g.y+g.height)))});const d=this.find("Shape");let f=!1;for(let p=0;p<d.length;p++)if(d[p]._isVisible(this)){f=!0;break}return f&&o!==void 0?l={x:o,y:i,width:s-o,height:a-i}:l={x:0,y:0,width:0,height:0},n?l:this._transformedRect(l,r)}};ge.addComponentsGetterSetter(Mi,"clip",["x","y","width","height"]),ge.addGetterSetter(Mi,"clipX",void 0,St()),ge.addGetterSetter(Mi,"clipY",void 0,St()),ge.addGetterSetter(Mi,"clipWidth",void 0,St()),ge.addGetterSetter(Mi,"clipHeight",void 0,St()),ge.addGetterSetter(Mi,"clipFunc");var hh=new Map,lI=xt._global.PointerEvent!==void 0;function u1(e){return hh.get(e)}function d1(e){return{evt:e,pointerId:e.pointerId}}function cI(e,t){return hh.get(e)===t}function uI(e,t){ph(e),t.getStage()&&(hh.set(e,t),lI&&t._fire("gotpointercapture",d1(new PointerEvent("gotpointercapture"))))}function ph(e,t){const n=hh.get(e);if(!n)return;const r=n.getStage();r&&r.content,hh.delete(e),lI&&n._fire("lostpointercapture",d1(new PointerEvent("lostpointercapture")))}var QV="Stage",JV="string",dI="px",eU="mouseout",fI="mouseleave",hI="mouseover",pI="mouseenter",mI="mousemove",gI="mousedown",vI="mouseup",mh="pointermove",gh="pointerdown",hd="pointerup",vh="pointercancel",tU="lostpointercapture",sg="pointerout",yh="pointerleave",ag="pointerover",lg="pointerenter",f1="contextmenu",yI="touchstart",bI="touchend",wI="touchmove",CI="touchcancel",h1="wheel",nU=5,rU=[[pI,"_pointerenter"],[gI,"_pointerdown"],[mI,"_pointermove"],[vI,"_pointerup"],[fI,"_pointerleave"],[yI,"_pointerdown"],[wI,"_pointermove"],[bI,"_pointerup"],[CI,"_pointercancel"],[hI,"_pointerover"],[h1,"_wheel"],[f1,"_contextmenu"],[gh,"_pointerdown"],[mh,"_pointermove"],[hd,"_pointerup"],[vh,"_pointercancel"],[yh,"_pointerleave"],[tU,"_lostpointercapture"]],p1={mouse:{[sg]:eU,[yh]:fI,[ag]:hI,[lg]:pI,[mh]:mI,[gh]:gI,[hd]:vI,[vh]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[sg]:"touchout",[yh]:"touchleave",[ag]:"touchover",[lg]:"touchenter",[mh]:wI,[gh]:yI,[hd]:bI,[vh]:CI,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[sg]:sg,[yh]:yh,[ag]:ag,[lg]:lg,[mh]:mh,[gh]:gh,[hd]:hd,[vh]:vh,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},bh=e=>e.indexOf("pointer")>=0?"pointer":e.indexOf("touch")>=0?"touch":"mouse",pd=e=>{const t=bh(e);if(t==="pointer")return xt.pointerEventsEnabled&&p1.pointer;if(t==="touch")return p1.touch;if(t==="mouse")return p1.mouse};function kI(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&&Be.warn("Stage does not support clipping. Please use clip for Layers or Groups."),e}var oU="Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);",wh=[],cg=class extends Mi{constructor(e){super(kI(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),wh.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{kI(this.attrs)}),this._checkVisibility()}_validateAdd(e){const t=e.getType()==="Layer",n=e.getType()==="FastLayer";t||n||Be.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const e=this.visible()?"":"none";this.content.style.display=e}setContainer(e){if(typeof e===JV){let t;if(e.charAt(0)==="."){const n=e.slice(1);e=document.getElementsByClassName(n)[0]}else e.charAt(0)!=="#"?t=e:t=e.slice(1),e=document.getElementById(t);if(!e)throw"Can not find container in document with id "+t}return this._setAttr("container",e),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),e.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){const e=this.children,t=e.length;for(let n=0;n<t;n++)e[n].clear();return this}clone(e){return e||(e={}),e.container=typeof document<"u"&&document.createElement("div"),Mi.prototype.clone.call(this,e)}destroy(){super.destroy();const e=this.content;e&&Be._isInDocument(e)&&this.container().removeChild(e);const t=wh.indexOf(this);return t>-1&&wh.splice(t,1),Be.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(Be.warn(oU),null)}_getPointerById(e){return this._pointerPositions.find(t=>t.id===e)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(e){e={...e},e.x=e.x||0,e.y=e.y||0,e.width=e.width||this.width(),e.height=e.height||this.height();const t=new jl({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),n=t.getContext()._context,r=this.children;return(e.x||e.y)&&n.translate(-1*e.x,-1*e.y),r.forEach(function(o){if(!o.isVisible())return;const i=o._toKonvaCanvas(e);n.drawImage(i._canvas,e.x,e.y,i.getWidth()/i.getPixelRatio(),i.getHeight()/i.getPixelRatio())}),t}getIntersection(e){if(!e)return null;const t=this.children,n=t.length-1;for(let r=n;r>=0;r--){const o=t[r].getIntersection(e);if(o)return o}return null}_resizeDOM(){const e=this.width(),t=this.height();this.content&&(this.content.style.width=e+dI,this.content.style.height=t+dI),this.bufferCanvas.setSize(e,t),this.bufferHitCanvas.setSize(e,t),this.children.forEach(n=>{n.setSize({width:e,height:t}),n.draw()})}add(e,...t){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.add(arguments[r]);return this}super.add(e);const n=this.children.length;return n>nU&&Be.warn("The stage has "+n+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),e.setSize({width:this.width(),height:this.height()}),e.draw(),xt.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return cI(e,this)}setPointerCapture(e){uI(e,this)}releaseCapture(e){ph(e,this)}getLayers(){return this.children}_bindContentEvents(){xt.isBrowser&&rU.forEach(([e,t])=>{this.content.addEventListener(e,n=>{this[t](n)},{passive:!1})})}_pointerenter(e){this.setPointersPositions(e);const t=pd(e.type);t&&this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);const t=pd(e.type);t&&this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_getTargetShape(e){let t=this[e+"targetShape"];return t&&!t.getStage()&&(t=null),t}_pointerleave(e){const t=pd(e.type),n=bh(e.type);if(!t)return;this.setPointersPositions(e);const r=this._getTargetShape(n),o=!(xt.isDragging()||xt.isTransforming())||xt.hitOnDragEnabled;r&&o?(r._fireAndBubble(t.pointerout,{evt:e}),r._fireAndBubble(t.pointerleave,{evt:e}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this[n+"targetShape"]=null):o&&(this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(t.pointerout,{evt:e,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(e){const t=pd(e.type),n=bh(e.type);if(!t)return;this.setPointersPositions(e);let r=!1;this._changedPointerPositions.forEach(o=>{const i=this.getIntersection(o);if($n.justDragged=!1,xt["_"+n+"ListenClick"]=!0,!i||!i.isListening()){this[n+"ClickStartShape"]=void 0;return}xt.capturePointerEventsEnabled&&i.setPointerCapture(o.id),this[n+"ClickStartShape"]=i,i._fireAndBubble(t.pointerdown,{evt:e,pointerId:o.id}),r=!0;const s=e.type.indexOf("touch")>=0;i.preventDefault()&&e.cancelable&&s&&e.preventDefault()}),r||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(e){const t=pd(e.type),n=bh(e.type);if(!t)return;const r=e.type.indexOf("touch")>=0||e.pointerType==="touch";if(xt.isDragging()&&$n.node.preventDefault()&&e.cancelable&&r&&e.preventDefault(),this.setPointersPositions(e),!(!(xt.isDragging()||xt.isTransforming())||xt.hitOnDragEnabled))return;const o={};let i=!1;const s=this._getTargetShape(n);this._changedPointerPositions.forEach(a=>{const l=u1(a.id)||this.getIntersection(a),u=a.id,d={evt:e,pointerId:u},f=s!==l;if(f&&s&&(s._fireAndBubble(t.pointerout,{...d},l),s._fireAndBubble(t.pointerleave,{...d},l)),l){if(o[l._id])return;o[l._id]=!0}l&&l.isListening()?(i=!0,f&&(l._fireAndBubble(t.pointerover,{...d},s),l._fireAndBubble(t.pointerenter,{...d},s),this[n+"targetShape"]=l),l._fireAndBubble(t.pointermove,{...d})):s&&(this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:u}),this[n+"targetShape"]=null)}),i||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){const t=pd(e.type),n=bh(e.type);if(!t)return;this.setPointersPositions(e);const r=this[n+"ClickStartShape"],o=this[n+"ClickEndShape"],i={};let s=!1;this._changedPointerPositions.forEach(a=>{const l=u1(a.id)||this.getIntersection(a);if(l){if(l.releaseCapture(a.id),i[l._id])return;i[l._id]=!0}const u=a.id,d={evt:e,pointerId:u};let f=!1;xt["_"+n+"InDblClickWindow"]?(f=!0,clearTimeout(this[n+"DblTimeout"])):$n.justDragged||(xt["_"+n+"InDblClickWindow"]=!0,clearTimeout(this[n+"DblTimeout"])),this[n+"DblTimeout"]=setTimeout(function(){xt["_"+n+"InDblClickWindow"]=!1},xt.dblClickWindow),l&&l.isListening()?(s=!0,this[n+"ClickEndShape"]=l,l._fireAndBubble(t.pointerup,{...d}),xt["_"+n+"ListenClick"]&&r&&r===l&&(l._fireAndBubble(t.pointerclick,{...d}),f&&o&&o===l&&l._fireAndBubble(t.pointerdblclick,{...d}))):(this[n+"ClickEndShape"]=null,s||(this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),s=!0),xt["_"+n+"ListenClick"]&&this._fire(t.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:u}),f&&this._fire(t.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:u}))}),s||this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),xt["_"+n+"ListenClick"]=!1,e.cancelable&&n!=="touch"&&n!=="pointer"&&e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);const t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(f1,{evt:e}):this._fire(f1,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);const t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(h1,{evt:e}):this._fire(h1,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);const t=u1(e.pointerId)||this.getIntersection(this.getPointerPosition());t&&t._fireAndBubble(hd,d1(e)),ph(e.pointerId)}_lostpointercapture(e){ph(e.pointerId)}setPointersPositions(e){const t=this._getContentPosition();let n=null,r=null;e=e||window.event,e.touches!==void 0?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(e.touches,o=>{this._pointerPositions.push({id:o.identifier,x:(o.clientX-t.left)/t.scaleX,y:(o.clientY-t.top)/t.scaleY})}),Array.prototype.forEach.call(e.changedTouches||e.touches,o=>{this._changedPointerPositions.push({id:o.identifier,x:(o.clientX-t.left)/t.scaleX,y:(o.clientY-t.top)/t.scaleY})})):(n=(e.clientX-t.left)/t.scaleX,r=(e.clientY-t.top)/t.scaleY,this.pointerPos={x:n,y:r},this._pointerPositions=[{x:n,y:r,id:Be._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:r,id:Be._getFirstPointerId(e)}])}_setPointerPosition(e){Be.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(e)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};const e=this.content.getBoundingClientRect();return{top:e.top,left:e.left,scaleX:e.width/this.content.clientWidth||1,scaleY:e.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new jl({width:this.width(),height:this.height()}),this.bufferHitCanvas=new s1({pixelRatio:1,width:this.width(),height:this.height()}),!xt.isBrowser)return;const e=this.container();if(!e)throw"Stage has no container. A container is required.";e.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),e.appendChild(this.content),this._resizeDOM()}cache(){return Be.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(e){e.batchDraw()}),this}};cg.prototype.nodeType=QV,Ar(cg),ge.addGetterSetter(cg,"container"),xt.isBrowser&&document.addEventListener("visibilitychange",()=>{wh.forEach(e=>{e.batchDraw()})});var SI="hasShadow",_I="shadowRGBA",AI="patternImage",II="linearGradient",EI="radialGradient",ug;function m1(){return ug||(ug=Be.createCanvasElement().getContext("2d"),ug)}var Ch={};function iU(e){const t=this.attrs.fillRule;t?e.fill(t):e.fill()}function sU(e){e.stroke()}function aU(e){const t=this.attrs.fillRule;t?e.fill(t):e.fill()}function lU(e){e.stroke()}function cU(){this._clearCache(SI)}function uU(){this._clearCache(_I)}function dU(){this._clearCache(AI)}function fU(){this._clearCache(II)}function hU(){this._clearCache(EI)}var yt=class extends Tt{constructor(e){super(e);let t,n=0;for(;t=Be.getHitColor(),!(t&&!(t in Ch));)if(n++,n>=1e4){Be.warn("Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it."),t=Be.getRandomColor();break}this.colorKey=t,Ch[t]=this}getContext(){return Be.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return Be.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(SI,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(AI,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const e=m1().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(e&&e.setTransform){const t=new gs;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(xt.getAngle(this.fillPatternRotation())),t.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),t.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const n=t.getMatrix(),r=typeof DOMMatrix>"u"?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);e.setTransform(r)}return e}}_getLinearGradient(){return this._getCache(II,this.__getLinearGradient)}__getLinearGradient(){const e=this.fillLinearGradientColorStops();if(e){const t=m1(),n=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),o=t.createLinearGradient(n.x,n.y,r.x,r.y);for(let i=0;i<e.length;i+=2)o.addColorStop(e[i],e[i+1]);return o}}_getRadialGradient(){return this._getCache(EI,this.__getRadialGradient)}__getRadialGradient(){const e=this.fillRadialGradientColorStops();if(e){const t=m1(),n=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),o=t.createRadialGradient(n.x,n.y,this.fillRadialGradientStartRadius(),r.x,r.y,this.fillRadialGradientEndRadius());for(let i=0;i<e.length;i+=2)o.addColorStop(e[i],e[i+1]);return o}}getShadowRGBA(){return this._getCache(_I,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const e=Be.colorToRGBA(this.shadowColor());if(e)return"rgba("+e.r+","+e.g+","+e.b+","+e.a*(this.shadowOpacity()||1)+")"}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>this.strokeEnabled()&&this.strokeWidth()&&!!(this.stroke()||this.strokeLinearGradientColorStops()))}hasHitStroke(){const e=this.hitStrokeWidth();return e==="auto"?this.hasStroke():this.strokeEnabled()&&!!e}intersects(e){const t=this.getStage();if(!t)return!1;const n=t.bufferHitCanvas;return n.getContext().clear(),this.drawHit(n,void 0,!0),n.context.getImageData(Math.round(e.x),Math.round(e.y),1,1).data[3]>0}destroy(){return Tt.prototype.destroy.call(this),delete Ch[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e){var t;if(!(!((t=this.attrs.perfectDrawEnabled)!==null&&t!==void 0)||t))return!1;const n=e||this.hasFill(),r=this.hasStroke(),o=this.getAbsoluteOpacity()!==1;if(n&&r&&o)return!0;const i=this.hasShadow(),s=this.shadowForStrokeEnabled();return!!(n&&r&&i&&s)}setStrokeHitEnabled(e){Be.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),e?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){const e=this.size();return{x:this._centroid?-e.width/2:0,y:this._centroid?-e.height/2:0,width:e.width,height:e.height}}getClientRect(e={}){let t=!1,n=this.getParent();for(;n;){if(n.isCached()){t=!0;break}n=n.getParent()}const r=e.skipTransform,o=e.relativeTo||t&&this.getStage()||void 0,i=this.getSelfRect(),s=!e.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,a=i.width+s,l=i.height+s,u=!e.skipShadow&&this.hasShadow(),d=u?this.shadowOffsetX():0,f=u?this.shadowOffsetY():0,p=a+Math.abs(d),g=l+Math.abs(f),m=u&&this.shadowBlur()||0,v={width:p+m*2,height:g+m*2,x:-(s/2+m)+Math.min(d,0)+i.x,y:-(s/2+m)+Math.min(f,0)+i.y};return r?v:this._transformedRect(v,o)}drawScene(e,t,n){const r=this.getLayer(),o=(e||r.getCanvas()).getContext(),i=this._getCanvasCache(),s=this.getSceneFunc(),a=this.hasShadow();let l;const u=t===this;if(!this.isVisible()&&!u)return this;if(i){o.save();const d=this.getAbsoluteTransform(t).getMatrix();return o.transform(d[0],d[1],d[2],d[3],d[4],d[5]),this._drawCachedSceneCanvas(o),o.restore(),this}if(!s)return this;if(o.save(),this._useBufferCanvas()){l=this.getStage();const d=n||l.bufferCanvas,f=d.getContext();n?(f.save(),f.setTransform(1,0,0,1,0,0),f.clearRect(0,0,d.width,d.height),f.restore()):f.clear(),f.save(),f._applyLineJoin(this),f._applyMiterLimit(this);const p=this.getAbsoluteTransform(t).getMatrix();f.transform(p[0],p[1],p[2],p[3],p[4],p[5]),s.call(this,f,this),f.restore();const g=d.pixelRatio;a&&o._applyShadow(this),u||(o._applyOpacity(this),o._applyGlobalCompositeOperation(this)),o.drawImage(d._canvas,d.x||0,d.y||0,d.width/g,d.height/g)}else{if(o._applyLineJoin(this),o._applyMiterLimit(this),!u){const d=this.getAbsoluteTransform(t).getMatrix();o.transform(d[0],d[1],d[2],d[3],d[4],d[5]),o._applyOpacity(this),o._applyGlobalCompositeOperation(this)}a&&o._applyShadow(this),s.call(this,o,this)}return o.restore(),this}drawHit(e,t,n=!1){if(!this.shouldDrawHit(t,n))return this;const r=this.getLayer(),o=e||r.hitCanvas,i=o&&o.getContext(),s=this.hitFunc()||this.sceneFunc(),a=this._getCanvasCache(),l=a&&a.hit;if(this.colorKey||Be.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),l){i.save();const u=this.getAbsoluteTransform(t).getMatrix();return i.transform(u[0],u[1],u[2],u[3],u[4],u[5]),this._drawCachedHitCanvas(i),i.restore(),this}if(!s)return this;if(i.save(),i._applyLineJoin(this),i._applyMiterLimit(this),this!==t){const u=this.getAbsoluteTransform(t).getMatrix();i.transform(u[0],u[1],u[2],u[3],u[4],u[5])}return s.call(this,i,this),i.restore(),this}drawHitFromCache(e=0){const t=this._getCanvasCache(),n=this._getCachedSceneCanvas(),r=t.hit,o=r.getContext(),i=r.getWidth(),s=r.getHeight();o.clear(),o.drawImage(n._canvas,0,0,i,s);try{const a=o.getImageData(0,0,i,s),l=a.data,u=l.length,d=Be._hexToRgb(this.colorKey);for(let f=0;f<u;f+=4)l[f+3]>e?(l[f]=d.r,l[f+1]=d.g,l[f+2]=d.b,l[f+3]=255):l[f+3]=0;o.putImageData(a,0,0)}catch(a){Be.error("Unable to draw hit graph from cached scene canvas. "+a.message)}return this}hasPointerCapture(e){return cI(e,this)}setPointerCapture(e){uI(e,this)}releaseCapture(e){ph(e,this)}};yt.prototype._fillFunc=iU,yt.prototype._strokeFunc=sU,yt.prototype._fillFuncHit=aU,yt.prototype._strokeFuncHit=lU,yt.prototype._centroid=!1,yt.prototype.nodeType="Shape",Ar(yt),yt.prototype.eventListeners={},yt.prototype.on("shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",cU),yt.prototype.on("shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",uU),yt.prototype.on("fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",dU),yt.prototype.on("fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",fU),yt.prototype.on("fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",hU),ge.addGetterSetter(yt,"stroke",void 0,nI()),ge.addGetterSetter(yt,"strokeWidth",2,St()),ge.addGetterSetter(yt,"fillAfterStrokeEnabled",!1),ge.addGetterSetter(yt,"hitStrokeWidth","auto",a1()),ge.addGetterSetter(yt,"strokeHitEnabled",!0,vs()),ge.addGetterSetter(yt,"perfectDrawEnabled",!0,vs()),ge.addGetterSetter(yt,"shadowForStrokeEnabled",!0,vs()),ge.addGetterSetter(yt,"lineJoin"),ge.addGetterSetter(yt,"lineCap"),ge.addGetterSetter(yt,"miterLimit"),ge.addGetterSetter(yt,"sceneFunc"),ge.addGetterSetter(yt,"hitFunc"),ge.addGetterSetter(yt,"dash"),ge.addGetterSetter(yt,"dashOffset",0,St()),ge.addGetterSetter(yt,"shadowColor",void 0,Nc()),ge.addGetterSetter(yt,"shadowBlur",0,St()),ge.addGetterSetter(yt,"shadowOpacity",1,St()),ge.addComponentsGetterSetter(yt,"shadowOffset",["x","y"]),ge.addGetterSetter(yt,"shadowOffsetX",0,St()),ge.addGetterSetter(yt,"shadowOffsetY",0,St()),ge.addGetterSetter(yt,"fillPatternImage"),ge.addGetterSetter(yt,"fill",void 0,nI()),ge.addGetterSetter(yt,"fillPatternX",0,St()),ge.addGetterSetter(yt,"fillPatternY",0,St()),ge.addGetterSetter(yt,"fillLinearGradientColorStops"),ge.addGetterSetter(yt,"strokeLinearGradientColorStops"),ge.addGetterSetter(yt,"fillRadialGradientStartRadius",0),ge.addGetterSetter(yt,"fillRadialGradientEndRadius",0),ge.addGetterSetter(yt,"fillRadialGradientColorStops"),ge.addGetterSetter(yt,"fillPatternRepeat","repeat"),ge.addGetterSetter(yt,"fillEnabled",!0),ge.addGetterSetter(yt,"strokeEnabled",!0),ge.addGetterSetter(yt,"shadowEnabled",!0),ge.addGetterSetter(yt,"dashEnabled",!0),ge.addGetterSetter(yt,"strokeScaleEnabled",!0),ge.addGetterSetter(yt,"fillPriority","color"),ge.addComponentsGetterSetter(yt,"fillPatternOffset",["x","y"]),ge.addGetterSetter(yt,"fillPatternOffsetX",0,St()),ge.addGetterSetter(yt,"fillPatternOffsetY",0,St()),ge.addComponentsGetterSetter(yt,"fillPatternScale",["x","y"]),ge.addGetterSetter(yt,"fillPatternScaleX",1,St()),ge.addGetterSetter(yt,"fillPatternScaleY",1,St()),ge.addComponentsGetterSetter(yt,"fillLinearGradientStartPoint",["x","y"]),ge.addComponentsGetterSetter(yt,"strokeLinearGradientStartPoint",["x","y"]),ge.addGetterSetter(yt,"fillLinearGradientStartPointX",0),ge.addGetterSetter(yt,"strokeLinearGradientStartPointX",0),ge.addGetterSetter(yt,"fillLinearGradientStartPointY",0),ge.addGetterSetter(yt,"strokeLinearGradientStartPointY",0),ge.addComponentsGetterSetter(yt,"fillLinearGradientEndPoint",["x","y"]),ge.addComponentsGetterSetter(yt,"strokeLinearGradientEndPoint",["x","y"]),ge.addGetterSetter(yt,"fillLinearGradientEndPointX",0),ge.addGetterSetter(yt,"strokeLinearGradientEndPointX",0),ge.addGetterSetter(yt,"fillLinearGradientEndPointY",0),ge.addGetterSetter(yt,"strokeLinearGradientEndPointY",0),ge.addComponentsGetterSetter(yt,"fillRadialGradientStartPoint",["x","y"]),ge.addGetterSetter(yt,"fillRadialGradientStartPointX",0),ge.addGetterSetter(yt,"fillRadialGradientStartPointY",0),ge.addComponentsGetterSetter(yt,"fillRadialGradientEndPoint",["x","y"]),ge.addGetterSetter(yt,"fillRadialGradientEndPointX",0),ge.addGetterSetter(yt,"fillRadialGradientEndPointY",0),ge.addGetterSetter(yt,"fillPatternRotation",0),ge.addGetterSetter(yt,"fillRule",void 0,Nc()),ge.backCompat(yt,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});var pU="beforeDraw",mU="draw",xI=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],gU=xI.length,zc=class extends Mi{constructor(e){super(e),this.canvas=new jl,this.hitCanvas=new s1({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);const t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),e<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[e+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){Tt.prototype.moveToTop.call(this);const e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!Tt.prototype.moveUp.call(this))return!1;const e=this.getStage();return!e||!e.content?!1:(e.content.removeChild(this.getNativeCanvasElement()),this.index<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[this.index+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(Tt.prototype.moveDown.call(this)){const e=this.getStage();if(e){const t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(Tt.prototype.moveToBottom.call(this)){const e=this.getStage();if(e){const t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){const e=this.getNativeCanvasElement();return Tt.prototype.remove.call(this),e&&e.parentNode&&Be._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:e,height:t}){return this.canvas.setSize(e,t),this.hitCanvas.setSize(e,t),this._setSmoothEnabled(),this}_validateAdd(e){const t=e.getType();t!=="Group"&&t!=="Shape"&&Be.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(e){return e={...e},e.width=e.width||this.getWidth(),e.height=e.height||this.getHeight(),e.x=e.x!==void 0?e.x:this.x(),e.y=e.y!==void 0?e.y:this.y(),Tt.prototype._toKonvaCanvas.call(this,e)}_checkVisibility(){this.visible()?this.canvas._canvas.style.display="block":this.canvas._canvas.style.display="none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){Be.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){Be.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,Be.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;let t=1,n=!1;for(;;){for(let r=0;r<gU;r++){const o=xI[r],i=this._getIntersection({x:e.x+o.x*t,y:e.y+o.y*t}),s=i.shape;if(s)return s;if(n=!!i.antialiased,!i.antialiased)break}if(n)t+=1;else return null}}_getIntersection(e){const t=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.round(e.x*t),Math.round(e.y*t),1,1).data,r=n[3];if(r===255){const o=Ch[Be.getHitColorKey(n[0],n[1],n[2])];return o?{shape:o}:{antialiased:!0}}else if(r>0)return{antialiased:!0};return{}}drawScene(e,t,n){const r=this.getLayer(),o=e||r&&r.getCanvas();return this._fire(pU,{node:this}),this.clearBeforeDraw()&&o.getContext().clear(),Mi.prototype.drawScene.call(this,o,t,n),this._fire(mU,{node:this}),this}drawHit(e,t){const n=this.getLayer(),r=e||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),Mi.prototype.drawHit.call(this,r,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){Be.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return Be.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;const e=this.parent;this.hitCanvas._canvas.parentNode?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}destroy(){return Be.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};zc.prototype.nodeType="Layer",Ar(zc),ge.addGetterSetter(zc,"imageSmoothingEnabled",!0),ge.addGetterSetter(zc,"clearBeforeDraw",!0),ge.addGetterSetter(zc,"hitGraphEnabled",!0,vs());var g1=class extends zc{constructor(e){super(e),this.listening(!1),Be.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}};g1.prototype.nodeType="FastLayer",Ar(g1);var md=class extends Mi{_validateAdd(e){const t=e.getType();t!=="Group"&&t!=="Shape"&&Be.throw("You may only add groups and shapes to groups.")}};md.prototype.nodeType="Group",Ar(md);var v1=(function(){return Fc.performance&&Fc.performance.now?function(){return Fc.performance.now()}:function(){return new Date().getTime()}})(),gd=class Hd{constructor(t,n){this.id=Hd.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:v1(),frameRate:0},this.func=t,this.setLayers(n)}setLayers(t){let n=[];return t&&(n=Array.isArray(t)?t:[t]),this.layers=n,this}getLayers(){return this.layers}addLayer(t){const n=this.layers,r=n.length;for(let o=0;o<r;o++)if(n[o]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const t=Hd.animations,n=t.length;for(let r=0;r<n;r++)if(t[r].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=v1(),Hd._addAnimation(this),this}stop(){return Hd._removeAnimation(this),this}_updateFrameObject(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const n=t.id,r=this.animations,o=r.length;for(let i=0;i<o;i++)if(r[i].id===n){this.animations.splice(i,1);break}}static _runFrames(){const t={},n=this.animations;for(let r=0;r<n.length;r++){const o=n[r],i=o.layers,s=o.func;o._updateFrameObject(v1());const a=i.length;let l;if(s?l=s.call(o,o.frame)!==!1:l=!0,!!l)for(let u=0;u<a;u++){const d=i[u];d._id!==void 0&&(t[d._id]=d)}}for(const r in t)t.hasOwnProperty(r)&&t[r].batchDraw()}static _animationLoop(){const t=Hd;t.animations.length?(t._runFrames(),Be.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,Be.requestAnimFrame(this._animationLoop))}};gd.animations=[],gd.animIdCounter=0,gd.animRunning=!1;var vU={node:1,duration:1,easing:1,onFinish:1,yoyo:1},yU=1,TI=2,RI=3,MI=["fill","stroke","shadowColor"],bU=0,wU=class{constructor(e,t,n,r,o,i,s){this.prop=e,this.propFunc=t,this.begin=r,this._pos=r,this.duration=i,this._change=0,this.prevPos=0,this.yoyo=s,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=o-this.begin,this.pause()}fire(e){const t=this[e];t&&t()}setTime(e){e>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():e<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=e,this.update())}getTime(){return this._time}setPosition(e){this.prevPos=this._pos,this.propFunc(e),this._pos=e}getPosition(e){return e===void 0&&(e=this._time),this.func(e,this.begin,this._change,this.duration)}play(){this.state=TI,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=RI,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(e){this.pause(),this._time=e,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){const e=this.getTimer()-this._startTime;this.state===TI?this.setTime(e):this.state===RI&&this.setTime(this.duration-e)}pause(){this.state=yU,this.fire("onPause")}getTimer(){return new Date().getTime()}},dg=class zr{constructor(t){const n=this,r=t.node,o=r._id,i=t.easing||kh.Linear,s=!!t.yoyo;let a,l;typeof t.duration>"u"?a=.3:t.duration===0?a=.001:a=t.duration,this.node=r,this._id=bU++;const u=r.getLayer()||(r instanceof xt.Stage?r.getLayers():null);u||Be.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new gd(function(){n.tween.onEnterFrame()},u),this.tween=new wU(l,function(d){n._tweenFunc(d)},i,0,1,a*1e3,s),this._addListeners(),zr.attrs[o]||(zr.attrs[o]={}),zr.attrs[o][this._id]||(zr.attrs[o][this._id]={}),zr.tweens[o]||(zr.tweens[o]={});for(l in t)vU[l]===void 0&&this._addAttr(l,t[l]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,n){const r=this.node,o=r._id;let i,s,a,l,u;const d=zr.tweens[o][t];d&&delete zr.attrs[o][d][t];let f=r.getAttr(t);if(Be._isArray(n))if(i=[],s=Math.max(n.length,f.length),t==="points"&&n.length!==f.length&&(n.length>f.length?(l=f,f=Be._prepareArrayForTween(f,n,r.closed())):(a=n,n=Be._prepareArrayForTween(n,f,r.closed()))),t.indexOf("fill")===0)for(let p=0;p<s;p++)if(p%2===0)i.push(n[p]-f[p]);else{const g=Be.colorToRGBA(f[p]);u=Be.colorToRGBA(n[p]),f[p]=g,i.push({r:u.r-g.r,g:u.g-g.g,b:u.b-g.b,a:u.a-g.a})}else for(let p=0;p<s;p++)i.push(n[p]-f[p]);else MI.indexOf(t)!==-1?(f=Be.colorToRGBA(f),u=Be.colorToRGBA(n),i={r:u.r-f.r,g:u.g-f.g,b:u.b-f.b,a:u.a-f.a}):i=n-f;zr.attrs[o][this._id][t]={start:f,diff:i,end:n,trueEnd:a,trueStart:l},zr.tweens[o][t]=this._id}_tweenFunc(t){const n=this.node,r=zr.attrs[n._id][this._id];let o,i,s,a,l,u,d,f;for(o in r){if(i=r[o],s=i.start,a=i.diff,f=i.end,Be._isArray(s))if(l=[],d=Math.max(s.length,f.length),o.indexOf("fill")===0)for(u=0;u<d;u++)u%2===0?l.push((s[u]||0)+a[u]*t):l.push("rgba("+Math.round(s[u].r+a[u].r*t)+","+Math.round(s[u].g+a[u].g*t)+","+Math.round(s[u].b+a[u].b*t)+","+(s[u].a+a[u].a*t)+")");else for(u=0;u<d;u++)l.push((s[u]||0)+a[u]*t);else MI.indexOf(o)!==-1?l="rgba("+Math.round(s.r+a.r*t)+","+Math.round(s.g+a.g*t)+","+Math.round(s.b+a.b*t)+","+(s.a+a.a*t)+")":l=s+a*t;n.setAttr(o,l)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{const t=this.node,n=zr.attrs[t._id][this._id];n.points&&n.points.trueEnd&&t.setAttr("points",n.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{const t=this.node,n=zr.attrs[t._id][this._id];n.points&&n.points.trueStart&&t.points(n.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(t*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){const t=this.node._id,n=this._id,r=zr.tweens[t];this.pause(),this.anim&&this.anim.stop();for(const o in r)delete zr.tweens[t][o];delete zr.attrs[t][n],zr.tweens[t]&&(Object.keys(zr.tweens[t]).length===0&&delete zr.tweens[t],Object.keys(zr.attrs[t]).length===0&&delete zr.attrs[t])}};dg.attrs={},dg.tweens={},Tt.prototype.to=function(e){const t=e.onFinish;e.node=this,e.onFinish=function(){this.destroy(),t&&t()},new dg(e).play()};var kh={BackEaseIn(e,t,n,r){return n*(e/=r)*e*(2.70158*e-1.70158)+t},BackEaseOut(e,t,n,r){return n*((e=e/r-1)*e*(2.70158*e+1.70158)+1)+t},BackEaseInOut(e,t,n,r){let o=1.70158;return(e/=r/2)<1?n/2*(e*e*(((o*=1.525)+1)*e-o))+t:n/2*((e-=2)*e*(((o*=1.525)+1)*e+o)+2)+t},ElasticEaseIn(e,t,n,r,o,i){let s=0;return e===0?t:(e/=r)===1?t+n:(i||(i=r*.3),!o||o<Math.abs(n)?(o=n,s=i/4):s=i/(2*Math.PI)*Math.asin(n/o),-(o*Math.pow(2,10*(e-=1))*Math.sin((e*r-s)*(2*Math.PI)/i))+t)},ElasticEaseOut(e,t,n,r,o,i){let s=0;return e===0?t:(e/=r)===1?t+n:(i||(i=r*.3),!o||o<Math.abs(n)?(o=n,s=i/4):s=i/(2*Math.PI)*Math.asin(n/o),o*Math.pow(2,-10*e)*Math.sin((e*r-s)*(2*Math.PI)/i)+n+t)},ElasticEaseInOut(e,t,n,r,o,i){let s=0;return e===0?t:(e/=r/2)===2?t+n:(i||(i=r*(.3*1.5)),!o||o<Math.abs(n)?(o=n,s=i/4):s=i/(2*Math.PI)*Math.asin(n/o),e<1?-.5*(o*Math.pow(2,10*(e-=1))*Math.sin((e*r-s)*(2*Math.PI)/i))+t:o*Math.pow(2,-10*(e-=1))*Math.sin((e*r-s)*(2*Math.PI)/i)*.5+n+t)},BounceEaseOut(e,t,n,r){return(e/=r)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t},BounceEaseIn(e,t,n,r){return n-kh.BounceEaseOut(r-e,0,n,r)+t},BounceEaseInOut(e,t,n,r){return e<r/2?kh.BounceEaseIn(e*2,0,n,r)*.5+t:kh.BounceEaseOut(e*2-r,0,n,r)*.5+n*.5+t},EaseIn(e,t,n,r){return n*(e/=r)*e+t},EaseOut(e,t,n,r){return-n*(e/=r)*(e-2)+t},EaseInOut(e,t,n,r){return(e/=r/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t},StrongEaseIn(e,t,n,r){return n*(e/=r)*e*e*e*e+t},StrongEaseOut(e,t,n,r){return n*((e=e/r-1)*e*e*e*e+1)+t},StrongEaseInOut(e,t,n,r){return(e/=r/2)<1?n/2*e*e*e*e*e+t:n/2*((e-=2)*e*e*e*e+2)+t},Linear(e,t,n,r){return n*e/r+t}},LI=Be._assign(xt,{Util:Be,Transform:gs,Node:Tt,Container:Mi,Stage:cg,stages:wh,Layer:zc,FastLayer:g1,Group:md,DD:$n,Shape:yt,shapes:Ch,Animation:gd,Tween:dg,Easings:kh,Context:tg,Canvas:i1}),qa=class extends yt{_sceneFunc(e){const t=xt.getAngle(this.angle()),n=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,t,n),e.arc(0,0,this.innerRadius(),t,0,!n),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){const e=this.innerRadius(),t=this.outerRadius(),n=this.clockwise(),r=xt.getAngle(n?360-this.angle():this.angle()),o=Math.cos(Math.min(r,Math.PI)),i=1,s=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),a=Math.sin(Math.min(r,Math.PI/2)),l=o*(o>0?e:t),u=i*t,d=s*(s>0?e:t),f=a*(a>0?t:e);return{x:l,y:n?-1*f:d,width:u-l,height:f-d}}};qa.prototype._centroid=!0,qa.prototype.className="Arc",qa.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],Ar(qa),ge.addGetterSetter(qa,"innerRadius",0,St()),ge.addGetterSetter(qa,"outerRadius",0,St()),ge.addGetterSetter(qa,"angle",0,St()),ge.addGetterSetter(qa,"clockwise",!1,vs());function y1(e,t,n,r,o,i,s){const a=Math.sqrt(Math.pow(n-e,2)+Math.pow(r-t,2)),l=Math.sqrt(Math.pow(o-n,2)+Math.pow(i-r,2)),u=s*a/(a+l),d=s*l/(a+l);return[n-u*(o-e),r-u*(i-t),n+d*(o-e),r+d*(i-t)]}function PI(e,t){const n=e.length,r=[];for(let o=2;o<n-2;o+=2){const i=y1(e[o-2],e[o-1],e[o],e[o+1],e[o+2],e[o+3],t);isNaN(i[0])||(r.push(i[0]),r.push(i[1]),r.push(e[o]),r.push(e[o+1]),r.push(i[2]),r.push(i[3]))}return r}function CU(e){const t=[[e[0],e[2],e[4],e[6]],[e[1],e[3],e[5],e[7]]],n=[];for(const r of t){const o=-3*r[0]+9*r[1]-9*r[2]+3*r[3];if(o!==0){const i=6*r[0]-12*r[1]+6*r[2],s=-3*r[0]+3*r[1],a=i*i-4*o*s;if(a>=0){const l=Math.sqrt(a);n.push((-i+l)/(2*o)),n.push((-i-l)/(2*o))}}}return n.filter(r=>r>0&&r<1).flatMap(r=>t.map(o=>{const i=1-r;return i*i*i*o[0]+3*i*i*r*o[1]+3*i*r*r*o[2]+r*r*r*o[3]}))}var Ya=class extends yt{constructor(e){super(e),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(e){const t=this.points(),n=t.length,r=this.tension(),o=this.closed(),i=this.bezier();if(!n)return;let s=0;if(e.beginPath(),e.moveTo(t[0],t[1]),r!==0&&n>4){const a=this.getTensionPoints(),l=a.length;for(s=o?0:4,o||e.quadraticCurveTo(a[0],a[1],a[2],a[3]);s<l-2;)e.bezierCurveTo(a[s++],a[s++],a[s++],a[s++],a[s++],a[s++]);o||e.quadraticCurveTo(a[l-2],a[l-1],t[n-2],t[n-1])}else if(i)for(s=2;s<n;)e.bezierCurveTo(t[s++],t[s++],t[s++],t[s++],t[s++],t[s++]);else for(s=2;s<n;s+=2)e.lineTo(t[s],t[s+1]);o?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():PI(this.points(),this.tension())}_getTensionPointsClosed(){const e=this.points(),t=e.length,n=this.tension(),r=y1(e[t-2],e[t-1],e[0],e[1],e[2],e[3],n),o=y1(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],n),i=PI(e,n);return[r[2],r[3]].concat(i).concat([o[0],o[1],e[t-2],e[t-1],o[2],o[3],r[0],r[1],e[0],e[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let e=this.points();if(e.length<4)return{x:e[0]||0,y:e[1]||0,width:0,height:0};this.tension()!==0?e=[e[0],e[1],...this._getTensionPoints(),e[e.length-2],e[e.length-1]]:this.bezier()?e=[e[0],e[1],...CU(this.points()),e[e.length-2],e[e.length-1]]:e=this.points();let t=e[0],n=e[0],r=e[1],o=e[1],i,s;for(let a=0;a<e.length/2;a++)i=e[a*2],s=e[a*2+1],t=Math.min(t,i),n=Math.max(n,i),r=Math.min(r,s),o=Math.max(o,s);return{x:t,y:r,width:n-t,height:o-r}}};Ya.prototype.className="Line",Ya.prototype._attrsAffectingSize=["points","bezier","tension"],Ar(Ya),ge.addGetterSetter(Ya,"closed",!1),ge.addGetterSetter(Ya,"bezier",!1),ge.addGetterSetter(Ya,"tension",0,St()),ge.addGetterSetter(Ya,"points",[],NV());var kU=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],SU=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],_U=[[1],[1,1],[1,2,1],[1,3,3,1]],DI=(e,t,n)=>{let r,o;const s=n/2;r=0;for(let a=0;a<20;a++)o=s*kU[20][a]+s,r+=SU[20][a]*AU(e,t,o);return s*r},OI=(e,t,n)=>{n===void 0&&(n=1);const r=e[0]-2*e[1]+e[2],o=t[0]-2*t[1]+t[2],i=2*e[1]-2*e[0],s=2*t[1]-2*t[0],a=4*(r*r+o*o),l=4*(r*i+o*s),u=i*i+s*s;if(a===0)return n*Math.sqrt(Math.pow(e[2]-e[0],2)+Math.pow(t[2]-t[0],2));const d=l/(2*a),f=u/a,p=n+d,g=f-d*d,m=p*p+g>0?Math.sqrt(p*p+g):0,v=d*d+g>0?Math.sqrt(d*d+g):0,C=d+Math.sqrt(d*d+g)!==0?g*Math.log(Math.abs((p+m)/(d+v))):0;return Math.sqrt(a)/2*(p*m-d*v+C)};function AU(e,t,n){const r=b1(1,n,e),o=b1(1,n,t),i=r*r+o*o;return Math.sqrt(i)}var b1=(e,t,n)=>{const r=n.length-1;let o,i;if(r===0)return 0;if(e===0){i=0;for(let s=0;s<=r;s++)i+=_U[r][s]*Math.pow(1-t,r-s)*Math.pow(t,s)*n[s];return i}else{o=new Array(r);for(let s=0;s<r;s++)o[s]=r*(n[s+1]-n[s]);return b1(e-1,t,o)}},FI=(e,t,n)=>{let r=1,o=e/t,i=(e-n(o))/t,s=0;for(;r>.001;){const a=n(o+i),l=Math.abs(e-a)/t;if(l<r)r=l,o+=i;else{const u=n(o-i),d=Math.abs(e-u)/t;d<r?(r=d,o-=i):i/=2}if(s++,s>500)break}return o},Wi=class wi extends yt{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=wi.parsePathData(this.data()),this.pathLength=wi.getPathLength(this.dataArray)}_sceneFunc(t){const n=this.dataArray;t.beginPath();let r=!1;for(let o=0;o<n.length;o++){const i=n[o].command,s=n[o].points;switch(i){case"L":t.lineTo(s[0],s[1]);break;case"M":t.moveTo(s[0],s[1]);break;case"C":t.bezierCurveTo(s[0],s[1],s[2],s[3],s[4],s[5]);break;case"Q":t.quadraticCurveTo(s[0],s[1],s[2],s[3]);break;case"A":const a=s[0],l=s[1],u=s[2],d=s[3],f=s[4],p=s[5],g=s[6],m=s[7],v=u>d?u:d,C=u>d?1:u/d,w=u>d?d/u:1;t.translate(a,l),t.rotate(g),t.scale(C,w),t.arc(0,0,v,f,f+p,1-m),t.scale(1/C,1/w),t.rotate(-g),t.translate(-a,-l);break;case"z":r=!0,t.closePath();break}}!r&&!this.hasFill()?t.strokeShape(this):t.fillStrokeShape(this)}getSelfRect(){let t=[];this.dataArray.forEach(function(l){if(l.command==="A"){const u=l.points[4],d=l.points[5],f=l.points[4]+d;let p=Math.PI/180;if(Math.abs(u-f)<p&&(p=Math.abs(u-f)),d<0)for(let g=u-p;g>f;g-=p){const m=wi.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],g,0);t.push(m.x,m.y)}else for(let g=u+p;g<f;g+=p){const m=wi.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],g,0);t.push(m.x,m.y)}}else if(l.command==="C")for(let u=0;u<=1;u+=.01){const d=wi.getPointOnCubicBezier(u,l.start.x,l.start.y,l.points[0],l.points[1],l.points[2],l.points[3],l.points[4],l.points[5]);t.push(d.x,d.y)}else t=t.concat(l.points)});let n=t[0],r=t[0],o=t[1],i=t[1],s,a;for(let l=0;l<t.length/2;l++)s=t[l*2],a=t[l*2+1],isNaN(s)||(n=Math.min(n,s),r=Math.max(r,s)),isNaN(a)||(o=Math.min(o,a),i=Math.max(i,a));return{x:n,y:o,width:r-n,height:i-o}}getLength(){return this.pathLength}getPointAtLength(t){return wi.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(t,n,r,o){return Math.sqrt((r-t)*(r-t)+(o-n)*(o-n))}static getPathLength(t){let n=0;for(let r=0;r<t.length;++r)n+=t[r].pathLength;return n}static getPointAtLengthOfDataArray(t,n){let r,o=0,i=n.length;if(!i)return null;for(;o<i&&t>n[o].pathLength;)t-=n[o].pathLength,++o;if(o===i)return r=n[o-1].points.slice(-2),{x:r[0],y:r[1]};if(t<.01)return n[o].command==="M"?(r=n[o].points.slice(0,2),{x:r[0],y:r[1]}):{x:n[o].start.x,y:n[o].start.y};const s=n[o],a=s.points;switch(s.command){case"L":return wi.getPointOnLine(t,s.start.x,s.start.y,a[0],a[1]);case"C":return wi.getPointOnCubicBezier(FI(t,wi.getPathLength(n),v=>DI([s.start.x,a[0],a[2],a[4]],[s.start.y,a[1],a[3],a[5]],v)),s.start.x,s.start.y,a[0],a[1],a[2],a[3],a[4],a[5]);case"Q":return wi.getPointOnQuadraticBezier(FI(t,wi.getPathLength(n),v=>OI([s.start.x,a[0],a[2]],[s.start.y,a[1],a[3]],v)),s.start.x,s.start.y,a[0],a[1],a[2],a[3]);case"A":const l=a[0],u=a[1],d=a[2],f=a[3],p=a[5],g=a[6];let m=a[4];return m+=p*t/s.pathLength,wi.getPointOnEllipticalArc(l,u,d,f,m,g)}return null}static getPointOnLine(t,n,r,o,i,s,a){s=s??n,a=a??r;const l=this.getLineLength(n,r,o,i);if(l<1e-10)return{x:n,y:r};if(o===n)return{x:s,y:a+(i>r?t:-t)};const u=(i-r)/(o-n),d=Math.sqrt(t*t/(1+u*u))*(o<n?-1:1),f=u*d;if(Math.abs(a-r-u*(s-n))<1e-10)return{x:s+d,y:a+f};const p=((s-n)*(o-n)+(a-r)*(i-r))/(l*l),g=n+p*(o-n),m=r+p*(i-r),v=this.getLineLength(s,a,g,m),C=Math.sqrt(t*t-v*v),w=Math.sqrt(C*C/(1+u*u))*(o<n?-1:1),S=u*w;return{x:g+w,y:m+S}}static getPointOnCubicBezier(t,n,r,o,i,s,a,l,u){function d(m){return m*m*m}function f(m){return 3*m*m*(1-m)}function p(m){return 3*m*(1-m)*(1-m)}function g(m){return(1-m)*(1-m)*(1-m)}return{x:l*d(t)+s*f(t)+o*p(t)+n*g(t),y:u*d(t)+a*f(t)+i*p(t)+r*g(t)}}static getPointOnQuadraticBezier(t,n,r,o,i,s,a){function l(f){return f*f}function u(f){return 2*f*(1-f)}function d(f){return(1-f)*(1-f)}return{x:s*l(t)+o*u(t)+n*d(t),y:a*l(t)+i*u(t)+r*d(t)}}static getPointOnEllipticalArc(t,n,r,o,i,s){const a=Math.cos(s),l=Math.sin(s),u={x:r*Math.cos(i),y:o*Math.sin(i)};return{x:t+(u.x*a-u.y*l),y:n+(u.x*l+u.y*a)}}static parsePathData(t){if(!t)return[];let n=t;const r=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];n=n.replace(new RegExp(" ","g"),",");for(let f=0;f<r.length;f++)n=n.replace(new RegExp(r[f],"g"),"|"+r[f]);const o=n.split("|"),i=[],s=[];let a=0,l=0;const u=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let d;for(let f=1;f<o.length;f++){let p=o[f],g=p.charAt(0);for(p=p.slice(1),s.length=0;d=u.exec(p);)s.push(d[0]);let m=[],v=g==="A"||g==="a"?0:-1;for(let C=0,w=s.length;C<w;C++){const S=s[C];if(S==="00"){m.push(0,0),v>=0&&(v+=2,v>=7&&(v-=7));continue}if(v>=0){if(v===3){if(/^[01]{2}\d+(?:\.\d+)?$/.test(S)){m.push(parseInt(S[0],10)),m.push(parseInt(S[1],10)),m.push(parseFloat(S.slice(2))),v+=3,v>=7&&(v-=7);continue}if(S==="11"||S==="10"||S==="01"){m.push(parseInt(S[0],10)),m.push(parseInt(S[1],10)),v+=2,v>=7&&(v-=7);continue}if(S==="0"||S==="1"){m.push(parseInt(S,10)),v+=1,v>=7&&(v-=7);continue}}else if(v===4){if(/^[01]\d+(?:\.\d+)?$/.test(S)){m.push(parseInt(S[0],10)),m.push(parseFloat(S.slice(1))),v+=2,v>=7&&(v-=7);continue}if(S==="0"||S==="1"){m.push(parseInt(S,10)),v+=1,v>=7&&(v-=7);continue}}const b=parseFloat(S);isNaN(b)?m.push(0):m.push(b),v+=1,v>=7&&(v-=7)}else{const b=parseFloat(S);isNaN(b)?m.push(0):m.push(b)}}for(;m.length>0&&!isNaN(m[0]);){let C="",w=[];const S=a,b=l;let k,x,M,z,G,F,L,$,T,H;switch(g){case"l":a+=m.shift(),l+=m.shift(),C="L",w.push(a,l);break;case"L":a=m.shift(),l=m.shift(),w.push(a,l);break;case"m":const R=m.shift(),U=m.shift();if(a+=R,l+=U,C="M",i.length>2&&i[i.length-1].command==="z"){for(let W=i.length-2;W>=0;W--)if(i[W].command==="M"){a=i[W].points[0]+R,l=i[W].points[1]+U;break}}w.push(a,l),g="l";break;case"M":a=m.shift(),l=m.shift(),C="M",w.push(a,l),g="L";break;case"h":a+=m.shift(),C="L",w.push(a,l);break;case"H":a=m.shift(),C="L",w.push(a,l);break;case"v":l+=m.shift(),C="L",w.push(a,l);break;case"V":l=m.shift(),C="L",w.push(a,l);break;case"C":w.push(m.shift(),m.shift(),m.shift(),m.shift()),a=m.shift(),l=m.shift(),w.push(a,l);break;case"c":w.push(a+m.shift(),l+m.shift(),a+m.shift(),l+m.shift()),a+=m.shift(),l+=m.shift(),C="C",w.push(a,l);break;case"S":x=a,M=l,k=i[i.length-1],k.command==="C"&&(x=a+(a-k.points[2]),M=l+(l-k.points[3])),w.push(x,M,m.shift(),m.shift()),a=m.shift(),l=m.shift(),C="C",w.push(a,l);break;case"s":x=a,M=l,k=i[i.length-1],k.command==="C"&&(x=a+(a-k.points[2]),M=l+(l-k.points[3])),w.push(x,M,a+m.shift(),l+m.shift()),a+=m.shift(),l+=m.shift(),C="C",w.push(a,l);break;case"Q":w.push(m.shift(),m.shift()),a=m.shift(),l=m.shift(),w.push(a,l);break;case"q":w.push(a+m.shift(),l+m.shift()),a+=m.shift(),l+=m.shift(),C="Q",w.push(a,l);break;case"T":x=a,M=l,k=i[i.length-1],k.command==="Q"&&(x=a+(a-k.points[0]),M=l+(l-k.points[1])),a=m.shift(),l=m.shift(),C="Q",w.push(x,M,a,l);break;case"t":x=a,M=l,k=i[i.length-1],k.command==="Q"&&(x=a+(a-k.points[0]),M=l+(l-k.points[1])),a+=m.shift(),l+=m.shift(),C="Q",w.push(x,M,a,l);break;case"A":z=m.shift(),G=m.shift(),F=m.shift(),L=m.shift(),$=m.shift(),T=a,H=l,a=m.shift(),l=m.shift(),C="A",w=this.convertEndpointToCenterParameterization(T,H,a,l,L,$,z,G,F);break;case"a":z=m.shift(),G=m.shift(),F=m.shift(),L=m.shift(),$=m.shift(),T=a,H=l,a+=m.shift(),l+=m.shift(),C="A",w=this.convertEndpointToCenterParameterization(T,H,a,l,L,$,z,G,F);break}i.push({command:C||g,points:w,start:{x:S,y:b},pathLength:this.calcLength(S,b,C||g,w)})}(g==="z"||g==="Z")&&i.push({command:"z",points:[],start:void 0,pathLength:0})}return i}static calcLength(t,n,r,o){let i,s,a,l;const u=wi;switch(r){case"L":return u.getLineLength(t,n,o[0],o[1]);case"C":return DI([t,o[0],o[2],o[4]],[n,o[1],o[3],o[5]],1);case"Q":return OI([t,o[0],o[2]],[n,o[1],o[3]],1);case"A":i=0;const d=o[4],f=o[5],p=o[4]+f;let g=Math.PI/180;if(Math.abs(d-p)<g&&(g=Math.abs(d-p)),s=u.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],d,0),f<0)for(l=d-g;l>p;l-=g)a=u.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],l,0),i+=u.getLineLength(s.x,s.y,a.x,a.y),s=a;else for(l=d+g;l<p;l+=g)a=u.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],l,0),i+=u.getLineLength(s.x,s.y,a.x,a.y),s=a;return a=u.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],p,0),i+=u.getLineLength(s.x,s.y,a.x,a.y),i}return 0}static convertEndpointToCenterParameterization(t,n,r,o,i,s,a,l,u){const d=u*(Math.PI/180),f=Math.cos(d)*(t-r)/2+Math.sin(d)*(n-o)/2,p=-1*Math.sin(d)*(t-r)/2+Math.cos(d)*(n-o)/2,g=f*f/(a*a)+p*p/(l*l);g>1&&(a*=Math.sqrt(g),l*=Math.sqrt(g));let m=Math.sqrt((a*a*(l*l)-a*a*(p*p)-l*l*(f*f))/(a*a*(p*p)+l*l*(f*f)));i===s&&(m*=-1),isNaN(m)&&(m=0);const v=m*a*p/l,C=m*-l*f/a,w=(t+r)/2+Math.cos(d)*v-Math.sin(d)*C,S=(n+o)/2+Math.sin(d)*v+Math.cos(d)*C,b=function(L){return Math.sqrt(L[0]*L[0]+L[1]*L[1])},k=function(L,$){return(L[0]*$[0]+L[1]*$[1])/(b(L)*b($))},x=function(L,$){return(L[0]*$[1]<L[1]*$[0]?-1:1)*Math.acos(k(L,$))},M=x([1,0],[(f-v)/a,(p-C)/l]),z=[(f-v)/a,(p-C)/l],G=[(-1*f-v)/a,(-1*p-C)/l];let F=x(z,G);return k(z,G)<=-1&&(F=Math.PI),k(z,G)>=1&&(F=0),s===0&&F>0&&(F=F-2*Math.PI),s===1&&F<0&&(F=F+2*Math.PI),[w,S,a,l,M,F,d,s]}};Wi.prototype.className="Path",Wi.prototype._attrsAffectingSize=["data"],Ar(Wi),ge.addGetterSetter(Wi,"data");var jc=class extends Ya{_sceneFunc(e){super._sceneFunc(e);const t=Math.PI*2,n=this.points();let r=n;const o=this.tension()!==0&&n.length>4;o&&(r=this.getTensionPoints());const i=this.pointerLength(),s=n.length;let a,l;if(o){const f=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],n[s-2],n[s-1]],p=Wi.calcLength(r[r.length-4],r[r.length-3],"C",f),g=Wi.getPointOnQuadraticBezier(Math.min(1,1-i/p),f[0],f[1],f[2],f[3],f[4],f[5]);a=n[s-2]-g.x,l=n[s-1]-g.y}else a=n[s-2]-n[s-4],l=n[s-1]-n[s-3];const u=(Math.atan2(l,a)+t)%t,d=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(n[s-2],n[s-1]),e.rotate(u),e.moveTo(0,0),e.lineTo(-i,d/2),e.lineTo(-i,-d/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(n[0],n[1]),o?(a=(r[0]+r[2])/2-n[0],l=(r[1]+r[3])/2-n[1]):(a=n[2]-n[0],l=n[3]-n[1]),e.rotate((Math.atan2(-l,-a)+t)%t),e.moveTo(0,0),e.lineTo(-i,d/2),e.lineTo(-i,-d/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){const t=this.dashEnabled();t&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),t&&(this.attrs.dashEnabled=!0)}getSelfRect(){const e=super.getSelfRect(),t=this.pointerWidth()/2;return{x:e.x,y:e.y-t,width:e.width,height:e.height+t*2}}};jc.prototype.className="Arrow",Ar(jc),ge.addGetterSetter(jc,"pointerLength",10,St()),ge.addGetterSetter(jc,"pointerWidth",10,St()),ge.addGetterSetter(jc,"pointerAtBeginning",!1),ge.addGetterSetter(jc,"pointerAtEnding",!0);var vd=class extends yt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.attrs.radius||0,0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius()!==e/2&&this.radius(e/2)}setHeight(e){this.radius()!==e/2&&this.radius(e/2)}};vd.prototype._centroid=!0,vd.prototype.className="Circle",vd.prototype._attrsAffectingSize=["radius"],Ar(vd),ge.addGetterSetter(vd,"radius",0,St());var $l=class extends yt{_sceneFunc(e){const t=this.radiusX(),n=this.radiusY();e.beginPath(),e.save(),t!==n&&e.scale(1,n/t),e.arc(0,0,t,0,Math.PI*2,!1),e.restore(),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radiusX()*2}getHeight(){return this.radiusY()*2}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}};$l.prototype.className="Ellipse",$l.prototype._centroid=!0,$l.prototype._attrsAffectingSize=["radiusX","radiusY"],Ar($l),ge.addComponentsGetterSetter($l,"radius",["x","y"]),ge.addGetterSetter($l,"radiusX",0,St()),ge.addGetterSetter($l,"radiusY",0,St());var ys=class Ox extends yt{constructor(t){super(t),this._loadListener=()=>{this._requestDraw()},this.on("imageChange.konva",n=>{this._removeImageLoad(n.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&t.readyState===4||t&&t.addEventListener&&t.addEventListener("load",this._loadListener)}_removeImageLoad(t){t&&t.removeEventListener&&t.removeEventListener("load",this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(){const t=!!this.cornerRadius(),n=this.hasShadow();return t&&n?!0:super._useBufferCanvas(!0)}_sceneFunc(t){const n=this.getWidth(),r=this.getHeight(),o=this.cornerRadius(),i=this.attrs.image;let s;if(i){const a=this.attrs.cropWidth,l=this.attrs.cropHeight;a&&l?s=[i,this.cropX(),this.cropY(),a,l,0,0,n,r]:s=[i,0,0,n,r]}(this.hasFill()||this.hasStroke()||o)&&(t.beginPath(),o?Be.drawRoundedRectPath(t,n,r,o):t.rect(0,0,n,r),t.closePath(),t.fillStrokeShape(this)),i&&(o&&t.clip(),t.drawImage.apply(t,s))}_hitFunc(t){const n=this.width(),r=this.height(),o=this.cornerRadius();t.beginPath(),o?Be.drawRoundedRectPath(t,n,r,o):t.rect(0,0,n,r),t.closePath(),t.fillStrokeShape(this)}getWidth(){var t,n,r;return(r=(t=this.attrs.width)!==null&&t!==void 0?t:(n=this.image())===null||n===void 0?void 0:n.width)!==null&&r!==void 0?r:0}getHeight(){var t,n,r;return(r=(t=this.attrs.height)!==null&&t!==void 0?t:(n=this.image())===null||n===void 0?void 0:n.height)!==null&&r!==void 0?r:0}static fromURL(t,n,r=null){const o=Be.createImageElement();o.onload=function(){n(new Ox({image:o}))},o.onerror=r,o.crossOrigin="Anonymous",o.src=t}};ys.prototype.className="Image",ys.prototype._attrsAffectingSize=["image"],Ar(ys),ge.addGetterSetter(ys,"cornerRadius",0,rg(4)),ge.addGetterSetter(ys,"image"),ge.addComponentsGetterSetter(ys,"crop",["x","y","width","height"]),ge.addGetterSetter(ys,"cropX",0,St()),ge.addGetterSetter(ys,"cropY",0,St()),ge.addGetterSetter(ys,"cropWidth",0,St()),ge.addGetterSetter(ys,"cropHeight",0,St());var NI=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],IU="Change.konva",EU="none",w1="up",C1="right",k1="down",S1="left",xU=NI.length,_1=class extends md{constructor(e){super(e),this.on("add.konva",function(t){this._addListeners(t.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(e){let t=this,n;const r=function(){t._sync()};for(n=0;n<xU;n++)e.on(NI[n]+IU,r)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let e=this.getText(),t=this.getTag(),n,r,o,i,s,a,l;if(e&&t){switch(n=e.width(),r=e.height(),o=t.pointerDirection(),i=t.pointerWidth(),l=t.pointerHeight(),s=0,a=0,o){case w1:s=n/2,a=-1*l;break;case C1:s=n+i,a=r/2;break;case k1:s=n/2,a=r+l;break;case S1:s=-1*i,a=r/2;break}t.setAttrs({x:-1*s,y:-1*a,width:n,height:r}),e.setAttrs({x:-1*s,y:-1*a})}}};_1.prototype.className="Label",Ar(_1);var Vc=class extends yt{_sceneFunc(e){const t=this.width(),n=this.height(),r=this.pointerDirection(),o=this.pointerWidth(),i=this.pointerHeight(),s=this.cornerRadius();let a=0,l=0,u=0,d=0;typeof s=="number"?a=l=u=d=Math.min(s,t/2,n/2):(a=Math.min(s[0]||0,t/2,n/2),l=Math.min(s[1]||0,t/2,n/2),d=Math.min(s[2]||0,t/2,n/2),u=Math.min(s[3]||0,t/2,n/2)),e.beginPath(),e.moveTo(a,0),r===w1&&(e.lineTo((t-o)/2,0),e.lineTo(t/2,-1*i),e.lineTo((t+o)/2,0)),e.lineTo(t-l,0),e.arc(t-l,l,l,Math.PI*3/2,0,!1),r===C1&&(e.lineTo(t,(n-i)/2),e.lineTo(t+o,n/2),e.lineTo(t,(n+i)/2)),e.lineTo(t,n-d),e.arc(t-d,n-d,d,0,Math.PI/2,!1),r===k1&&(e.lineTo((t+o)/2,n),e.lineTo(t/2,n+i),e.lineTo((t-o)/2,n)),e.lineTo(u,n),e.arc(u,n-u,u,Math.PI/2,Math.PI,!1),r===S1&&(e.lineTo(0,(n+i)/2),e.lineTo(-1*o,n/2),e.lineTo(0,(n-i)/2)),e.lineTo(0,a),e.arc(a,a,a,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=0,t=0,n=this.pointerWidth(),r=this.pointerHeight(),o=this.pointerDirection(),i=this.width(),s=this.height();return o===w1?(t-=r,s+=r):o===k1?s+=r:o===S1?(e-=n*1.5,i+=n):o===C1&&(i+=n*1.5),{x:e,y:t,width:i,height:s}}};Vc.prototype.className="Tag",Ar(Vc),ge.addGetterSetter(Vc,"pointerDirection",EU),ge.addGetterSetter(Vc,"pointerWidth",0,St()),ge.addGetterSetter(Vc,"pointerHeight",0,St()),ge.addGetterSetter(Vc,"cornerRadius",0,rg(4));var Sh=class extends yt{_sceneFunc(e){const t=this.cornerRadius(),n=this.width(),r=this.height();e.beginPath(),t?Be.drawRoundedRectPath(e,n,r,t):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}};Sh.prototype.className="Rect",Ar(Sh),ge.addGetterSetter(Sh,"cornerRadius",0,rg(4));var Hl=class extends yt{_sceneFunc(e){const t=this._getPoints(),n=this.radius(),r=this.sides(),o=this.cornerRadius();if(e.beginPath(),o)Be.drawRoundedPolygonPath(e,t,r,n,o);else{e.moveTo(t[0].x,t[0].y);for(let i=1;i<t.length;i++)e.lineTo(t[i].x,t[i].y)}e.closePath(),e.fillStrokeShape(this)}_getPoints(){const e=this.attrs.sides,t=this.attrs.radius||0,n=[];for(let r=0;r<e;r++)n.push({x:t*Math.sin(r*2*Math.PI/e),y:-1*t*Math.cos(r*2*Math.PI/e)});return n}getSelfRect(){const e=this._getPoints();let t=e[0].x,n=e[0].x,r=e[0].y,o=e[0].y;return e.forEach(i=>{t=Math.min(t,i.x),n=Math.max(n,i.x),r=Math.min(r,i.y),o=Math.max(o,i.y)}),{x:t,y:r,width:n-t,height:o-r}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};Hl.prototype.className="RegularPolygon",Hl.prototype._centroid=!0,Hl.prototype._attrsAffectingSize=["radius"],Ar(Hl),ge.addGetterSetter(Hl,"radius",0,St()),ge.addGetterSetter(Hl,"sides",0,St()),ge.addGetterSetter(Hl,"cornerRadius",0,rg(4));var BI=Math.PI*2,Uc=class extends yt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,BI,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),BI,0,!0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};Uc.prototype.className="Ring",Uc.prototype._centroid=!0,Uc.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Ar(Uc),ge.addGetterSetter(Uc,"innerRadius",0,St()),ge.addGetterSetter(Uc,"outerRadius",0,St());var ia=class extends yt{constructor(e){super(e),this._updated=!0,this.anim=new gd(()=>{const t=this._updated;return this._updated=!1,t}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(e){const t=this.animation(),n=this.frameIndex(),r=n*4,o=this.animations()[t],i=this.frameOffsets(),s=o[r+0],a=o[r+1],l=o[r+2],u=o[r+3],d=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,l,u),e.closePath(),e.fillStrokeShape(this)),d)if(i){const f=i[t],p=n*2;e.drawImage(d,s,a,l,u,f[p+0],f[p+1],l,u)}else e.drawImage(d,s,a,l,u,0,0,l,u)}_hitFunc(e){const t=this.animation(),n=this.frameIndex(),r=n*4,o=this.animations()[t],i=this.frameOffsets(),s=o[r+2],a=o[r+3];if(e.beginPath(),i){const l=i[t],u=n*2;e.rect(l[u+0],l[u+1],s,a)}else e.rect(0,0,s,a);e.closePath(),e.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){const e=this;this.interval=setInterval(function(){e._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;const e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){const e=this.frameIndex(),t=this.animation();e<this.animations()[t].length/4-1?this.frameIndex(e+1):this.frameIndex(0)}};ia.prototype.className="Sprite",Ar(ia),ge.addGetterSetter(ia,"animation"),ge.addGetterSetter(ia,"animations"),ge.addGetterSetter(ia,"frameOffsets"),ge.addGetterSetter(ia,"image"),ge.addGetterSetter(ia,"frameIndex",0,St()),ge.addGetterSetter(ia,"frameRate",17,St()),ge.backCompat(ia,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});var Gl=class extends yt{_sceneFunc(e){const t=this.innerRadius(),n=this.outerRadius(),r=this.numPoints();e.beginPath(),e.moveTo(0,0-n);for(let o=1;o<r*2;o++){const i=o%2===0?n:t,s=i*Math.sin(o*Math.PI/r),a=-1*i*Math.cos(o*Math.PI/r);e.lineTo(s,a)}e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};Gl.prototype.className="Star",Gl.prototype._centroid=!0,Gl.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Ar(Gl),ge.addGetterSetter(Gl,"numPoints",5,St()),ge.addGetterSetter(Gl,"innerRadius",0,St()),ge.addGetterSetter(Gl,"outerRadius",0,St());function Wl(e){return[...e].reduce((t,n,r,o)=>{if(/\p{Emoji}/u.test(n)){const i=o[r+1];i&&/\p{Emoji_Modifier}|\u200D/u.test(i)?(t.push(n+i),o[r+1]=""):t.push(n)}else/\p{Regional_Indicator}{2}/u.test(n+(o[r+1]||""))?t.push(n+o[r+1]):r>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(n)?t[t.length-1]+=n:n&&t.push(n);return t},[])}var yd="auto",TU="center",zI="inherit",_h="justify",RU="Change.konva",jI="2d",VI="-",UI="left",MU="text",LU="Text",PU="top",DU="bottom",$I="middle",HI="normal",OU="px ",fg=" ",FU="right",GI="rtl",NU="word",BU="char",WI="none",A1="…",KI=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],zU=KI.length,Ah=null;function jU(){if(Ah!==null)return Ah;Ah=!1;try{const e=document.createElement("canvas");e.width=10,e.height=10;const t=e.getContext(jI);if(t){t.globalAlpha=0,t.shadowColor="black",t.shadowBlur=5,t.shadowOffsetX=5,t.shadowOffsetY=5,t.fillStyle="black",t.font="10px Arial",t.fillText("X",0,10);const n=t.getImageData(0,0,10,10).data;for(let r=3;r<n.length;r+=4)if(n[r]>0){Ah=!0;break}}}catch{}return Ah}function VU(e){return e.split(",").map(t=>{t=t.trim();const n=t.indexOf(" ")>=0,r=t.indexOf('"')>=0||t.indexOf("'")>=0;return n&&!r&&(t=`"${t}"`),t}).join(", ")}var hg;function I1(){return hg||(hg=Be.createCanvasElement().getContext(jI),hg)}function UU(e){e.fillText(this._partialText,this._partialTextX,this._partialTextY)}function $U(e){e.setAttr("miterLimit",2),e.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function HU(e){return e=e||{},!e.fillLinearGradientColorStops&&!e.fillRadialGradientColorStops&&!e.fillPatternImage&&(e.fill=e.fill||"black"),e}var fr=class extends yt{constructor(e){super(HU(e)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t<zU;t++)this.on(KI[t]+RU,this._setTextData);this._setTextData()}_sceneFunc(e){var t,n;const r=this.textArr,o=r.length;if(!this.text())return;let i=this.padding(),s=this.fontSize(),a=this.lineHeight()*s,l=this.verticalAlign(),u=this.direction(),d=0,f=this.align(),p=this.getWidth(),g=this.letterSpacing(),m=this.charRenderFunc(),v=this.fill(),C=this.textDecoration(),w=this.underlineOffset(),S=C.indexOf("underline")!==-1,b=C.indexOf("line-through")!==-1,k;u=u===zI?e.direction:u;let x=a/2,M=$I;if(!xt.legacyTextRendering){const z=this.measureSize("M");M="alphabetic",x=(((t=z.fontBoundingBoxAscent)!==null&&t!==void 0?t:z.actualBoundingBoxAscent)-((n=z.fontBoundingBoxDescent)!==null&&n!==void 0?n:z.actualBoundingBoxDescent))/2+a/2}for(u===GI&&e.setAttr("direction",u),e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",M),e.setAttr("textAlign",UI),l===$I?d=(this.getHeight()-o*a-i*2)/2:l===DU&&(d=this.getHeight()-o*a-i*2),e.translate(i,d+i),k=0;k<o;k++){let z=0,G=0;const F=r[k],L=F.text,$=F.width,T=F.lastInParagraph;if(e.save(),f===FU?z+=p-$-i*2:f===TU&&(z+=(p-$-i*2)/2),S){e.save(),e.beginPath();const R=w??(xt.legacyTextRendering?Math.round(s/2):Math.round(s/4)),U=z,W=x+G+R;e.moveTo(U,W);const ee=f===_h&&!T?p-i*2:$;e.lineTo(U+Math.round(ee),W),e.lineWidth=s/15,e.strokeStyle=this._getLinearGradient()||v,e.stroke(),e.restore()}const H=z;if(u!==GI&&(g!==0||f===_h||m)){const R=L.split(" ").length-1,U=Wl(L);for(let W=0;W<U.length;W++){const ee=U[W];if(ee===" "&&!T&&f===_h&&(z+=(p-i*2-$)/R),this._partialTextX=z,this._partialTextY=x+G,this._partialText=ee,m){e.save();const J=r.slice(0,k).reduce((Z,Me)=>Z+Wl(Me.text).length,0);m({char:ee,index:W+J,x:z,y:x+G,lineIndex:k,column:W,isLastInLine:T,width:this.measureSize(ee).width,context:e})}e.fillStrokeShape(this),m&&e.restore(),z+=this.measureSize(ee).width+g}}else g!==0&&e.setAttr("letterSpacing",`${g}px`),this._partialTextX=z,this._partialTextY=x+G,this._partialText=L,e.fillStrokeShape(this);if(b){e.save(),e.beginPath();const R=xt.legacyTextRendering?0:-Math.round(s/4),U=H;e.moveTo(U,x+G+R);const W=f===_h&&!T?p-i*2:$;e.lineTo(U+Math.round(W),x+G+R),e.lineWidth=s/15,e.strokeStyle=this._getLinearGradient()||v,e.stroke(),e.restore()}e.restore(),o>1&&(x+=a)}}_hitFunc(e){const t=this.getWidth(),n=this.getHeight();e.beginPath(),e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}setText(e){const t=Be._isString(e)?e:e==null?"":e+"";return this._setAttr(MU,t),this}getWidth(){return this.attrs.width===yd||this.attrs.width===void 0?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){return this.attrs.height===yd||this.attrs.height===void 0?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return Be.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(e){var t,n,r,o,i,s,a,l,u,d,f;let p=I1(),g=this.fontSize(),m;p.save(),p.font=this._getContextFont(),m=p.measureText(e),p.restore();const v=g/100;return{actualBoundingBoxAscent:(t=m.actualBoundingBoxAscent)!==null&&t!==void 0?t:71.58203125*v,actualBoundingBoxDescent:(n=m.actualBoundingBoxDescent)!==null&&n!==void 0?n:0,actualBoundingBoxLeft:(r=m.actualBoundingBoxLeft)!==null&&r!==void 0?r:-7.421875*v,actualBoundingBoxRight:(o=m.actualBoundingBoxRight)!==null&&o!==void 0?o:75.732421875*v,alphabeticBaseline:(i=m.alphabeticBaseline)!==null&&i!==void 0?i:0,emHeightAscent:(s=m.emHeightAscent)!==null&&s!==void 0?s:100*v,emHeightDescent:(a=m.emHeightDescent)!==null&&a!==void 0?a:-20*v,fontBoundingBoxAscent:(l=m.fontBoundingBoxAscent)!==null&&l!==void 0?l:91*v,fontBoundingBoxDescent:(u=m.fontBoundingBoxDescent)!==null&&u!==void 0?u:21*v,hangingBaseline:(d=m.hangingBaseline)!==null&&d!==void 0?d:72.80000305175781*v,ideographicBaseline:(f=m.ideographicBaseline)!==null&&f!==void 0?f:-21*v,width:m.width,height:g}}_getContextFont(){return this.fontStyle()+fg+this.fontVariant()+fg+(this.fontSize()+OU)+VU(this.fontFamily())}_addTextLine(e){this.align()===_h&&(e=e.trim());const t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e){const t=this.letterSpacing(),n=e.length;return I1().measureText(e).width+t*n}_setTextData(){let e=this.text().split(`
|
|
104
104
|
`),t=+this.fontSize(),n=0,r=this.lineHeight()*t,o=this.attrs.width,i=this.attrs.height,s=o!==yd&&o!==void 0,a=i!==yd&&i!==void 0,l=this.padding(),u=o-l*2,d=i-l*2,f=0,p=this.wrap(),g=p!==BU&&p!==WI,m=this.ellipsis();this.textArr=[],I1().font=this._getContextFont();const v=m?this._getTextWidth(A1):0;for(let C=0,w=e.length;C<w;++C){let S=e[C],b=this._getTextWidth(S);if(s&&b>u)for(;S.length>0;){let k=0,x=Wl(S).length,M="",z=0;for(;k<x;){const G=k+x>>>1,F=Wl(S).slice(0,G+1).join(""),L=this._getTextWidth(F);(m&&a&&f+r>d?L+v:L)<=u?(k=G+1,M=F,z=L):x=G}if(M){if(g){const G=Wl(S),F=Wl(M),L=G[F.length],$=L===fg||L===VI;let T;if($&&z<=u)T=F.length;else{const H=F.lastIndexOf(fg),R=F.lastIndexOf(VI);T=Math.max(H,R)+1}T>0&&(k=T,M=G.slice(0,k).join(""),z=this._getTextWidth(M))}if(M=M.trimRight(),this._addTextLine(M),n=Math.max(n,z),f+=r,this._shouldHandleEllipsis(f)){this._tryToAddEllipsisToLastLine();break}if(S=Wl(S).slice(k).join("").trimLeft(),S.length>0&&(b=this._getTextWidth(S),b<=u)){this._addTextLine(S),f+=r,n=Math.max(n,b);break}}else break}else this._addTextLine(S),f+=r,n=Math.max(n,b),this._shouldHandleEllipsis(f)&&C<w-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),a&&f+r>d)break}this.textHeight=t,this.textWidth=n}_shouldHandleEllipsis(e){const t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,o=r!==yd&&r!==void 0,i=r-this.padding()*2;return this.wrap()===WI||o&&e+n>i}_tryToAddEllipsisToLastLine(){const e=this.attrs.width,t=e!==yd&&e!==void 0,n=e-this.padding()*2,r=this.ellipsis(),o=this.textArr[this.textArr.length-1];!o||!r||(t&&(this._getTextWidth(o.text+A1)<n||(o.text=o.text.slice(0,o.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(o.text+A1))}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const e=this.textDecoration().indexOf("underline")!==-1||this.textDecoration().indexOf("line-through")!==-1,t=this.hasShadow();return e&&t||t&&this.getAbsoluteOpacity()!==1&&jU()?!0:super._useBufferCanvas()}};fr.prototype._fillFunc=UU,fr.prototype._strokeFunc=$U,fr.prototype.className=LU,fr.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],Ar(fr),ge.overWriteSetter(fr,"width",a1()),ge.overWriteSetter(fr,"height",a1()),ge.addGetterSetter(fr,"direction",zI),ge.addGetterSetter(fr,"fontFamily","Arial"),ge.addGetterSetter(fr,"fontSize",12,St()),ge.addGetterSetter(fr,"fontStyle",HI),ge.addGetterSetter(fr,"fontVariant",HI),ge.addGetterSetter(fr,"padding",0,St()),ge.addGetterSetter(fr,"align",UI),ge.addGetterSetter(fr,"verticalAlign",PU),ge.addGetterSetter(fr,"lineHeight",1,St()),ge.addGetterSetter(fr,"wrap",NU),ge.addGetterSetter(fr,"ellipsis",!1,vs()),ge.addGetterSetter(fr,"letterSpacing",0,St()),ge.addGetterSetter(fr,"text","",Nc()),ge.addGetterSetter(fr,"textDecoration",""),ge.addGetterSetter(fr,"underlineOffset",void 0,St()),ge.addGetterSetter(fr,"charRenderFunc",void 0);var GU="",qI="normal";function YI(e){e.fillText(this.partialText,0,0)}function XI(e){e.strokeText(this.partialText,0,0)}var Jr=class extends yt{constructor(e){super(e),this.dummyCanvas=Be.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute(),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return Wi.getPathLength(this.dataArray)}_getPointAtLength(e){return!this.attrs.data||e>this.pathLength?null:Wi.getPointAtLengthOfDataArray(e,this.dataArray)}_readDataAttribute(){this.dataArray=Wi.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(e){e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",this.textBaseline()),e.setAttr("textAlign","left"),e.save();const t=this.textDecoration(),n=this.fill(),r=this.fontSize(),o=this.glyphInfo,i=t.indexOf("underline")!==-1,s=t.indexOf("line-through")!==-1;i&&e.beginPath();for(let a=0;a<o.length;a++){e.save();const l=o[a].p0;e.translate(l.x,l.y),e.rotate(o[a].rotation),this.partialText=o[a].text,e.fillStrokeShape(this),i&&(a===0&&e.moveTo(0,r/2+1),e.lineTo(o[a].width,r/2+1)),e.restore()}if(i&&(e.strokeStyle=n,e.lineWidth=r/20,e.stroke()),s){e.beginPath();for(let a=0;a<o.length;a++){e.save();const l=o[a].p0;e.translate(l.x,l.y),e.rotate(o[a].rotation),a===0&&e.moveTo(0,0),e.lineTo(o[a].width,0),e.restore()}e.strokeStyle=n,e.lineWidth=r/20,e.stroke()}e.restore()}_hitFunc(e){e.beginPath();const t=this.glyphInfo;if(t.length>=1){const n=t[0].p0;e.moveTo(n.x,n.y)}for(let n=0;n<t.length;n++){const r=t[n].p1;e.lineTo(r.x,r.y)}e.setAttr("lineWidth",this.fontSize()),e.setAttr("strokeStyle",this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return Be.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return fr.prototype.setText.call(this,e)}_getContextFont(){return fr.prototype._getContextFont.call(this)}_getTextSize(e){const t=this.dummyCanvas.getContext("2d");t.save(),t.font=this._getContextFont();const n=t.measureText(e);return t.restore(),{width:n.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const e=Wl(this.text()),t=[];let n=0;for(let p=0;p<e.length;p++)t.push({char:e[p],width:this._getTextSize(e[p]).width}),n+=t[p].width;const{width:r,height:o}=this._getTextSize(this.attrs.text);if(this.textWidth=n,this.textHeight=o,this.glyphInfo=[],!this.attrs.data)return null;const i=this.letterSpacing(),s=this.align(),a=this.kerningFunc(),l=Math.max(0,n-r),u=Math.max(this.textWidth+((this.attrs.text||"").length-1)*i,0);let d=0;s==="center"&&(d=Math.max(0,this.pathLength/2-u/2)),s==="right"&&(d=Math.max(0,this.pathLength-u));let f=d;for(let p=0;p<t.length;p++){const g=this._getPointAtLength(f);if(!g)return;const m=t[p].char;let v=t[p].width+i;if(m===" "&&s==="justify"){const M=this.text().split(" ").length-1;v+=(this.pathLength-u)/M}const C=f+v,w=this._getPointAtLength(C>this.pathLength&&C-this.pathLength<=l?this.pathLength:C);if(!w)return;const S=Wi.getLineLength(g.x,g.y,w.x,w.y);let b=0;if(a)try{b=a(t[p-1].char,m)*this.fontSize()}catch{b=0}g.x+=b,w.x+=b,this.textWidth+=b;const k=Wi.getPointOnLine(b+S/2,g.x,g.y,w.x,w.y),x=Math.atan2(w.y-g.y,w.x-g.x);this.glyphInfo.push({transposeX:k.x,transposeY:k.y,text:e[p],rotation:x,p0:g,p1:w,width:S}),f+=v}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const e=[];this.glyphInfo.forEach(function(l){e.push(l.p0.x),e.push(l.p0.y),e.push(l.p1.x),e.push(l.p1.y)});let t=e[0]||0,n=e[0]||0,r=e[1]||0,o=e[1]||0,i,s;for(let l=0;l<e.length/2;l++)i=e[l*2],s=e[l*2+1],t=Math.min(t,i),n=Math.max(n,i),r=Math.min(r,s),o=Math.max(o,s);const a=this.fontSize();return{x:t-a/2,y:r-a/2,width:n-t+a,height:o-r+a}}destroy(){return Be.releaseCanvas(this.dummyCanvas),super.destroy()}};Jr.prototype._fillFunc=YI,Jr.prototype._strokeFunc=XI,Jr.prototype._fillFuncHit=YI,Jr.prototype._strokeFuncHit=XI,Jr.prototype.className="TextPath",Jr.prototype._attrsAffectingSize=["text","fontSize","data"],Ar(Jr),ge.addGetterSetter(Jr,"data"),ge.addGetterSetter(Jr,"fontFamily","Arial"),ge.addGetterSetter(Jr,"fontSize",12,St()),ge.addGetterSetter(Jr,"fontStyle",qI),ge.addGetterSetter(Jr,"align","left"),ge.addGetterSetter(Jr,"letterSpacing",0,St()),ge.addGetterSetter(Jr,"textBaseline","middle"),ge.addGetterSetter(Jr,"fontVariant",qI),ge.addGetterSetter(Jr,"text",GU),ge.addGetterSetter(Jr,"textDecoration",""),ge.addGetterSetter(Jr,"kerningFunc",void 0);var ZI="tr-konva",WU=["resizeEnabledChange","rotateAnchorOffsetChange","rotateAnchorAngleChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(e=>e+`.${ZI}`).join(" "),QI="nodesRect",KU=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],qU={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},YU="ontouchstart"in xt._global;function XU(e,t,n){if(e==="rotater")return n;t+=Be.degToRad(qU[e]||0);const r=(Be.radToDeg(t)%360+360)%360;return Be._inRange(r,337.5,360)||Be._inRange(r,0,22.5)?"ns-resize":Be._inRange(r,22.5,67.5)?"nesw-resize":Be._inRange(r,67.5,112.5)?"ew-resize":Be._inRange(r,112.5,157.5)?"nwse-resize":Be._inRange(r,157.5,202.5)?"ns-resize":Be._inRange(r,202.5,247.5)?"nesw-resize":Be._inRange(r,247.5,292.5)?"ew-resize":Be._inRange(r,292.5,337.5)?"nwse-resize":(Be.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}var pg=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function ZU(e){return{x:e.x+e.width/2*Math.cos(e.rotation)+e.height/2*Math.sin(-e.rotation),y:e.y+e.height/2*Math.cos(e.rotation)+e.width/2*Math.sin(e.rotation)}}function JI(e,t,n){const r=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),o=n.y+(e.x-n.x)*Math.sin(t)+(e.y-n.y)*Math.cos(t);return{...e,rotation:e.rotation+t,x:r,y:o}}function QU(e,t){return JI(e,t,ZU(e))}function JU(e,t,n){let r=t;for(let o=0;o<e.length;o++){const i=xt.getAngle(e[o]),s=Math.abs(i-t)%(Math.PI*2);Math.min(s,Math.PI*2-s)<n&&(r=i)}return r}var E1=0,Nn=class extends md{constructor(e){super(e),this._movingAnchorName=null,this._transforming=!1,this._elementsCreated=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(WU,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return Be.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return ZI+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();const t=e.filter(n=>n.isAncestorOf(this)?(Be.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1):!0);return this._nodes=e=t,e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(n=>{const r=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()};if(n._attrsAffectingSize.length){const o=n._attrsAffectingSize.map(i=>i+"Change."+this._getEventNamespace()).join(" ");n.on(o,r)}n.on(KU.map(o=>o+`.${this._getEventNamespace()}`).join(" "),r),n.on(`absoluteTransformChange.${this._getEventNamespace()}`,r),this._proxyDrag(n)}),this._resetTransformCache(),this.findOne(".top-left")&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,n=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(".back")&&this.startDrag(n,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,n=>{if(!t)return;const r=e.getAbsolutePosition(),o=r.x-t.x,i=r.y-t.y;this.nodes().forEach(s=>{if(s===e||s.isDragging())return;const a=s.getAbsolutePosition();s.setAbsolutePosition({x:a.x+o,y:a.y+i}),s.startDrag(n)}),t=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(e=>{e.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(QI),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(QI,this.__getNodeRect)}__getNodeShape(e,t=this.rotation(),n){const r=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),o=e.getAbsoluteScale(n),i=e.getAbsolutePosition(n),s=r.x*o.x-e.offsetX()*o.x,a=r.y*o.y-e.offsetY()*o.y,l=(xt.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2);return JI({x:i.x+s*Math.cos(l)+a*Math.sin(-l),y:i.y+a*Math.cos(l)+s*Math.sin(l),width:r.width*o.x,height:r.height*o.y,rotation:l},-xt.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const e=[];this.nodes().map(a=>{const l=a.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),u=[{x:l.x,y:l.y},{x:l.x+l.width,y:l.y},{x:l.x+l.width,y:l.y+l.height},{x:l.x,y:l.y+l.height}],d=a.getAbsoluteTransform();u.forEach(function(f){const p=d.point(f);e.push(p)})});const t=new gs;t.rotate(-xt.getAngle(this.rotation()));let n=1/0,r=1/0,o=-1/0,i=-1/0;e.forEach(function(a){const l=t.point(a);n===void 0&&(n=o=l.x,r=i=l.y),n=Math.min(n,l.x),r=Math.min(r,l.y),o=Math.max(o,l.x),i=Math.max(i,l.y)}),t.invert();const s=t.point({x:n,y:r});return{x:s.x,y:s.y,width:o-n,height:i-r,rotation:xt.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),pg.forEach(e=>{this._createAnchor(e)}),this._createAnchor("rotater"),this._elementsCreated=!0}_createAnchor(e){const t=new Sh({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:YU?10:"auto"}),n=this;t.on("mousedown touchstart",function(r){n._handleMouseDown(r)}),t.on("dragstart",r=>{t.stopDrag(),r.cancelBubble=!0}),t.on("dragend",r=>{r.cancelBubble=!0}),t.on("mouseenter",()=>{const r=XU(e,xt.getAngle(this.rotation()),this.rotateAnchorCursor());t.getStage().content&&(t.getStage().content.style.cursor=r),this._cursorChange=!0}),t.on("mouseout",()=>{t.getStage().content&&(t.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(t)}_createBack(){const e=new yt({name:"back",width:0,height:0,sceneFunc(t,n){const r=n.getParent(),o=r.padding(),i=n.width(),s=n.height();if(t.beginPath(),t.rect(-o,-o,i+o*2,s+o*2),r.rotateEnabled()&&r.rotateLineVisible()){const a=r.rotateAnchorAngle(),l=r.rotateAnchorOffset(),u=Be.degToRad(a),d=Math.sin(u),f=-Math.cos(u),p=i/2,g=s/2;let m=1/0;f<0?m=Math.min(m,-g/f):f>0&&(m=Math.min(m,(s-g)/f)),d<0?m=Math.min(m,-p/d):d>0&&(m=Math.min(m,(i-p)/d));const v=p+d*m,C=g+f*m,w=Be._sign(s),S=v+d*l*w,b=C+f*l*w;t.moveTo(v,C),t.lineTo(S,b)}t.fillStrokeShape(n)},hitFunc:(t,n)=>{if(!this.shouldOverdrawWholeArea())return;const r=this.padding();t.beginPath(),t.rect(-r,-r,n.width()+r*2,n.height()+r*2),t.fillStrokeShape(n)}});this.add(e),this._proxyDrag(e),e.on("dragstart",t=>{t.cancelBubble=!0}),e.on("dragmove",t=>{t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(e){if(this._transforming)return;this._movingAnchorName=e.target.name().split(" ")[0];const t=this._getNodeRect(),n=t.width,r=t.height,o=Math.sqrt(Math.pow(n,2)+Math.pow(r,2));this.sin=Math.abs(r/o),this.cos=Math.abs(n/o),typeof window<"u"&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const i=e.target.getAbsolutePosition(),s=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:s.x-i.x,y:s.y-i.y},E1++,this._fire("transformstart",{evt:e.evt,target:this.getNode()}),this._nodes.forEach(a=>{a._fire("transformstart",{evt:e.evt,target:a})})}_handleMouseMove(e){let t,n,r;const o=this.findOne("."+this._movingAnchorName),i=o.getStage();i.setPointersPositions(e);const s=i.getPointerPosition();let a={x:s.x-this._anchorDragOffset.x,y:s.y-this._anchorDragOffset.y};const l=o.getAbsolutePosition();this.anchorDragBoundFunc()&&(a=this.anchorDragBoundFunc()(l,a,e)),o.setAbsolutePosition(a);const u=o.getAbsolutePosition();if(l.x===u.x&&l.y===u.y)return;if(this._movingAnchorName==="rotater"){const w=this._getNodeRect();t=o.x()-w.width/2,n=-o.y()+w.height/2;const S=xt.getAngle(this.rotateAnchorAngle());let b=Math.atan2(-n,t)+Math.PI/2-S;w.height<0&&(b-=Math.PI);const k=xt.getAngle(this.rotation())+b,x=xt.getAngle(this.rotationSnapTolerance()),M=QU(w,JU(this.rotationSnaps(),k,x)-w.rotation);this._fitNodesInto(M,e);return}const d=this.shiftBehavior();let f;d==="inverted"?f=this.keepRatio()&&!e.shiftKey:d==="none"?f=this.keepRatio():f=this.keepRatio()||e.shiftKey;let p=this.centeredScaling()||e.altKey;if(this._movingAnchorName==="top-left"){if(f){const w=p?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};r=Math.sqrt(Math.pow(w.x-o.x(),2)+Math.pow(w.y-o.y(),2));const S=this.findOne(".top-left").x()>w.x?-1:1,b=this.findOne(".top-left").y()>w.y?-1:1;t=r*this.cos*S,n=r*this.sin*b,this.findOne(".top-left").x(w.x-t),this.findOne(".top-left").y(w.y-n)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(o.y());else if(this._movingAnchorName==="top-right"){if(f){const w=p?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};r=Math.sqrt(Math.pow(o.x()-w.x,2)+Math.pow(w.y-o.y(),2));const S=this.findOne(".top-right").x()<w.x?-1:1,b=this.findOne(".top-right").y()>w.y?-1:1;t=r*this.cos*S,n=r*this.sin*b,this.findOne(".top-right").x(w.x+t),this.findOne(".top-right").y(w.y-n)}var g=o.position();this.findOne(".top-left").y(g.y),this.findOne(".bottom-right").x(g.x)}else if(this._movingAnchorName==="middle-left")this.findOne(".top-left").x(o.x());else if(this._movingAnchorName==="middle-right")this.findOne(".bottom-right").x(o.x());else if(this._movingAnchorName==="bottom-left"){if(f){const w=p?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};r=Math.sqrt(Math.pow(w.x-o.x(),2)+Math.pow(o.y()-w.y,2));const S=w.x<o.x()?-1:1,b=o.y()<w.y?-1:1;t=r*this.cos*S,n=r*this.sin*b,o.x(w.x-t),o.y(w.y+n)}g=o.position(),this.findOne(".top-left").x(g.x),this.findOne(".bottom-right").y(g.y)}else if(this._movingAnchorName==="bottom-center")this.findOne(".bottom-right").y(o.y());else if(this._movingAnchorName==="bottom-right"){if(f){const w=p?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};r=Math.sqrt(Math.pow(o.x()-w.x,2)+Math.pow(o.y()-w.y,2));const S=this.findOne(".bottom-right").x()<w.x?-1:1,b=this.findOne(".bottom-right").y()<w.y?-1:1;t=r*this.cos*S,n=r*this.sin*b,this.findOne(".bottom-right").x(w.x+t),this.findOne(".bottom-right").y(w.y+n)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(p=this.centeredScaling()||e.altKey,p){const w=this.findOne(".top-left"),S=this.findOne(".bottom-right"),b=w.x(),k=w.y(),x=this.getWidth()-S.x(),M=this.getHeight()-S.y();S.move({x:-b,y:-k}),w.move({x,y:M})}const m=this.findOne(".top-left").getAbsolutePosition();t=m.x,n=m.y;const v=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),C=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:t,y:n,width:v,height:C,rotation:xt.getAngle(this.rotation())},e)}_handleMouseUp(e){this._removeEvents(e)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(e){var t;if(this._transforming){this._transforming=!1,typeof window<"u"&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const n=this.getNode();E1--,this._fire("transformend",{evt:e,target:n}),(t=this.getLayer())===null||t===void 0||t.batchDraw(),n&&this._nodes.forEach(r=>{var o;r._fire("transformend",{evt:e,target:r}),(o=r.getLayer())===null||o===void 0||o.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(e,t){const n=this._getNodeRect(),r=1;if(Be._inRange(e.width,-this.padding()*2-r,r)){this.update();return}if(Be._inRange(e.height,-this.padding()*2-r,r)){this.update();return}const o=new gs;if(o.rotate(xt.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const f=o.point({x:-this.padding()*2,y:0});e.x+=f.x,e.y+=f.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=f.x,this._anchorDragOffset.y-=f.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const f=o.point({x:this.padding()*2,y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=f.x,this._anchorDragOffset.y-=f.y,e.width+=this.padding()*2}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const f=o.point({x:0,y:-this.padding()*2});e.x+=f.x,e.y+=f.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=f.x,this._anchorDragOffset.y-=f.y,e.height+=this.padding()*2}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const f=o.point({x:0,y:this.padding()*2});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=f.x,this._anchorDragOffset.y-=f.y,e.height+=this.padding()*2}if(this.boundBoxFunc()){const f=this.boundBoxFunc()(n,e);f?e=f:Be.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const i=1e7,s=new gs;s.translate(n.x,n.y),s.rotate(n.rotation),s.scale(n.width/i,n.height/i);const a=new gs,l=e.width/i,u=e.height/i;this.flipEnabled()===!1?(a.translate(e.x,e.y),a.rotate(e.rotation),a.translate(e.width<0?e.width:0,e.height<0?e.height:0),a.scale(Math.abs(l),Math.abs(u))):(a.translate(e.x,e.y),a.rotate(e.rotation),a.scale(l,u));const d=a.multiply(s.invert());this._nodes.forEach(f=>{var p;if(!f.getStage())return;const g=f.getParent().getAbsoluteTransform(),m=f.getTransform().copy();m.translate(f.offsetX(),f.offsetY());const v=new gs;v.multiply(g.copy().invert()).multiply(d).multiply(g).multiply(m);const C=v.decompose();f.setAttrs(C),(p=f.getLayer())===null||p===void 0||p.batchDraw()}),this.rotation(Be._getRotation(e.rotation)),this._nodes.forEach(f=>{this._fire("transform",{evt:t,target:f}),f._fire("transform",{evt:t,target:f})}),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,t){this.findOne(e).setAttrs(t)}update(){var e;const t=this._getNodeRect();this.rotation(Be._getRotation(t.rotation));const n=t.width,r=t.height,o=this.enabledAnchors(),i=this.resizeEnabled(),s=this.padding(),a=this.anchorSize(),l=this.find("._anchor");l.forEach(x=>{x.setAttrs({width:a,height:a,offsetX:a/2,offsetY:a/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:a/2+s,offsetY:a/2+s,visible:i&&o.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:n/2,y:0,offsetY:a/2+s,visible:i&&o.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:n,y:0,offsetX:a/2-s,offsetY:a/2+s,visible:i&&o.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:a/2+s,visible:i&&o.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:n,y:r/2,offsetX:a/2-s,visible:i&&o.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:a/2+s,offsetY:a/2-s,visible:i&&o.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:n/2,y:r,offsetY:a/2-s,visible:i&&o.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:n,y:r,offsetX:a/2-s,offsetY:a/2-s,visible:i&&o.indexOf("bottom-right")>=0});const u=this.rotateAnchorAngle(),d=this.rotateAnchorOffset(),f=Be.degToRad(u),p=Math.sin(f),g=-Math.cos(f),m=n/2,v=r/2;let C=1/0;g<0?C=Math.min(C,-v/g):g>0&&(C=Math.min(C,(r-v)/g)),p<0?C=Math.min(C,-m/p):p>0&&(C=Math.min(C,(n-m)/p));const w=m+p*C,S=v+g*C,b=Be._sign(r);this._batchChangeChild(".rotater",{x:w+p*d*b,y:S+g*d*b-s*g,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:n,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),draggable:this.nodes().some(x=>x.draggable()),x:0,y:0});const k=this.anchorStyleFunc();k&&l.forEach(x=>{k(x)}),(e=this.getLayer())===null||e===void 0||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const e=this.findOne("."+this._movingAnchorName);e&&e.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),md.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(Be.error("You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead."),this):super.add(...e)}toObject(){return Tt.prototype.toObject.call(this)}clone(e){return Tt.prototype.clone.call(this,e)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};Nn.isTransforming=()=>E1>0;function e$(e){return e instanceof Array||Be.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach(function(t){pg.indexOf(t)===-1&&Be.warn("Unknown anchor name: "+t+". Available names are: "+pg.join(", "))}),e||[]}Nn.prototype.className="Transformer",Ar(Nn),ge.addGetterSetter(Nn,"enabledAnchors",pg,e$),ge.addGetterSetter(Nn,"flipEnabled",!0,vs()),ge.addGetterSetter(Nn,"resizeEnabled",!0),ge.addGetterSetter(Nn,"anchorSize",10,St()),ge.addGetterSetter(Nn,"rotateEnabled",!0),ge.addGetterSetter(Nn,"rotateLineVisible",!0),ge.addGetterSetter(Nn,"rotationSnaps",[]),ge.addGetterSetter(Nn,"rotateAnchorOffset",50,St()),ge.addGetterSetter(Nn,"rotateAnchorAngle",0,St()),ge.addGetterSetter(Nn,"rotateAnchorCursor","crosshair"),ge.addGetterSetter(Nn,"rotationSnapTolerance",5,St()),ge.addGetterSetter(Nn,"borderEnabled",!0),ge.addGetterSetter(Nn,"anchorStroke","rgb(0, 161, 255)"),ge.addGetterSetter(Nn,"anchorStrokeWidth",1,St()),ge.addGetterSetter(Nn,"anchorFill","white"),ge.addGetterSetter(Nn,"anchorCornerRadius",0,St()),ge.addGetterSetter(Nn,"borderStroke","rgb(0, 161, 255)"),ge.addGetterSetter(Nn,"borderStrokeWidth",1,St()),ge.addGetterSetter(Nn,"borderDash"),ge.addGetterSetter(Nn,"keepRatio",!0),ge.addGetterSetter(Nn,"shiftBehavior","default"),ge.addGetterSetter(Nn,"centeredScaling",!1),ge.addGetterSetter(Nn,"ignoreStroke",!1),ge.addGetterSetter(Nn,"padding",0,St()),ge.addGetterSetter(Nn,"nodes"),ge.addGetterSetter(Nn,"node"),ge.addGetterSetter(Nn,"boundBoxFunc"),ge.addGetterSetter(Nn,"anchorDragBoundFunc"),ge.addGetterSetter(Nn,"anchorStyleFunc"),ge.addGetterSetter(Nn,"shouldOverdrawWholeArea",!1),ge.addGetterSetter(Nn,"useSingleNodeRotation",!0),ge.backCompat(Nn,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var Xa=class extends yt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,xt.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};Xa.prototype.className="Wedge",Xa.prototype._centroid=!0,Xa.prototype._attrsAffectingSize=["radius"],Ar(Xa),ge.addGetterSetter(Xa,"radius",0,St()),ge.addGetterSetter(Xa,"angle",0,St()),ge.addGetterSetter(Xa,"clockwise",!1),ge.backCompat(Xa,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});function eE(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var t$=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],n$=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function r$(e,t){const n=e.data,r=e.width,o=e.height;let i,s,a,l,u,d,f,p,g,m,v,C,w,S,b,k,x,M,z,G;const F=t+t+1,L=r-1,$=o-1,T=t+1,H=T*(T+1)/2,R=new eE,U=t$[t],W=n$[t];let ee=null,J=R,Z=null,Me=null;for(let fe=1;fe<F;fe++)J=J.next=new eE,fe===T&&(ee=J);J.next=R,a=s=0;for(let fe=0;fe<o;fe++){C=w=S=b=l=u=d=f=0,p=T*(k=n[s]),g=T*(x=n[s+1]),m=T*(M=n[s+2]),v=T*(z=n[s+3]),l+=H*k,u+=H*x,d+=H*M,f+=H*z,J=R;for(let ye=0;ye<T;ye++)J.r=k,J.g=x,J.b=M,J.a=z,J=J.next;for(let ye=1;ye<T;ye++)i=s+((L<ye?L:ye)<<2),l+=(J.r=k=n[i])*(G=T-ye),u+=(J.g=x=n[i+1])*G,d+=(J.b=M=n[i+2])*G,f+=(J.a=z=n[i+3])*G,C+=k,w+=x,S+=M,b+=z,J=J.next;Z=R,Me=ee;for(let ye=0;ye<r;ye++)n[s+3]=z=f*U>>W,z!==0?(z=255/z,n[s]=(l*U>>W)*z,n[s+1]=(u*U>>W)*z,n[s+2]=(d*U>>W)*z):n[s]=n[s+1]=n[s+2]=0,l-=p,u-=g,d-=m,f-=v,p-=Z.r,g-=Z.g,m-=Z.b,v-=Z.a,i=a+((i=ye+t+1)<L?i:L)<<2,C+=Z.r=n[i],w+=Z.g=n[i+1],S+=Z.b=n[i+2],b+=Z.a=n[i+3],l+=C,u+=w,d+=S,f+=b,Z=Z.next,p+=k=Me.r,g+=x=Me.g,m+=M=Me.b,v+=z=Me.a,C-=k,w-=x,S-=M,b-=z,Me=Me.next,s+=4;a+=r}for(let fe=0;fe<r;fe++){w=S=b=C=u=d=f=l=0,s=fe<<2,p=T*(k=n[s]),g=T*(x=n[s+1]),m=T*(M=n[s+2]),v=T*(z=n[s+3]),l+=H*k,u+=H*x,d+=H*M,f+=H*z,J=R;for(let ve=0;ve<T;ve++)J.r=k,J.g=x,J.b=M,J.a=z,J=J.next;let ye=r;for(let ve=1;ve<=t;ve++)s=ye+fe<<2,l+=(J.r=k=n[s])*(G=T-ve),u+=(J.g=x=n[s+1])*G,d+=(J.b=M=n[s+2])*G,f+=(J.a=z=n[s+3])*G,C+=k,w+=x,S+=M,b+=z,J=J.next,ve<$&&(ye+=r);s=fe,Z=R,Me=ee;for(let ve=0;ve<o;ve++)i=s<<2,n[i+3]=z=f*U>>W,z>0?(z=255/z,n[i]=(l*U>>W)*z,n[i+1]=(u*U>>W)*z,n[i+2]=(d*U>>W)*z):n[i]=n[i+1]=n[i+2]=0,l-=p,u-=g,d-=m,f-=v,p-=Z.r,g-=Z.g,m-=Z.b,v-=Z.a,i=fe+((i=ve+T)<$?i:$)*r<<2,l+=C+=Z.r=n[i],u+=w+=Z.g=n[i+1],d+=S+=Z.b=n[i+2],f+=b+=Z.a=n[i+3],Z=Z.next,p+=k=Me.r,g+=x=Me.g,m+=M=Me.b,v+=z=Me.a,C-=k,w-=x,S-=M,b-=z,Me=Me.next,s+=r}}var o$=function(t){const n=Math.round(this.blurRadius());n>0&&r$(t,n)};ge.addGetterSetter(Tt,"blurRadius",0,St(),ge.afterSetFilter);var i$=function(e){const t=this.brightness()*255,n=e.data,r=n.length;for(let o=0;o<r;o+=4)n[o]+=t,n[o+1]+=t,n[o+2]+=t};ge.addGetterSetter(Tt,"brightness",0,St(),ge.afterSetFilter);var s$=function(e){const t=this.brightness(),n=e.data,r=n.length;for(let o=0;o<r;o+=4)n[o]=Math.min(255,n[o]*t),n[o+1]=Math.min(255,n[o+1]*t),n[o+2]=Math.min(255,n[o+2]*t)},a$=function(e){const t=Math.pow((this.contrast()+100)/100,2),n=e.data,r=n.length;let o=150,i=150,s=150;for(let a=0;a<r;a+=4)o=n[a],i=n[a+1],s=n[a+2],o/=255,o-=.5,o*=t,o+=.5,o*=255,i/=255,i-=.5,i*=t,i+=.5,i*=255,s/=255,s-=.5,s*=t,s+=.5,s*=255,o=o<0?0:o>255?255:o,i=i<0?0:i>255?255:i,s=s<0?0:s>255?255:s,n[a]=o,n[a+1]=i,n[a+2]=s};ge.addGetterSetter(Tt,"contrast",0,St(),ge.afterSetFilter);var l$=function(e){var t,n,r,o,i,s,a,l,u;const d=e.data,f=e.width,p=e.height,g=Math.min(1,Math.max(0,(n=(t=this.embossStrength)===null||t===void 0?void 0:t.call(this))!==null&&n!==void 0?n:.5)),m=Math.min(1,Math.max(0,(o=(r=this.embossWhiteLevel)===null||r===void 0?void 0:r.call(this))!==null&&o!==void 0?o:.5)),v=(a={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[(s=(i=this.embossDirection)===null||i===void 0?void 0:i.call(this))!==null&&s!==void 0?s:"top-left"])!==null&&a!==void 0?a:315,C=!!((u=(l=this.embossBlend)===null||l===void 0?void 0:l.call(this))!==null&&u!==void 0&&u),w=g*10,S=m*255,b=v*Math.PI/180,k=Math.cos(b),x=Math.sin(b),M=128/1020*w,z=new Uint8ClampedArray(d),G=new Float32Array(f*p);for(let H=0,R=0;R<d.length;R+=4,H++)G[H]=.2126*z[R]+.7152*z[R+1]+.0722*z[R+2];const F=[-1,0,1,-2,0,2,-1,0,1],L=[-1,-2,-1,0,0,0,1,2,1],$=[-f-1,-f,-f+1,-1,0,1,f-1,f,f+1],T=H=>H<0?0:H>255?255:H;for(let H=1;H<p-1;H++)for(let R=1;R<f-1;R++){const U=H*f+R;let W=0,ee=0;W+=G[U+$[0]]*F[0],ee+=G[U+$[0]]*L[0],W+=G[U+$[1]]*F[1],ee+=G[U+$[1]]*L[1],W+=G[U+$[2]]*F[2],ee+=G[U+$[2]]*L[2],W+=G[U+$[3]]*F[3],ee+=G[U+$[3]]*L[3],W+=G[U+$[5]]*F[5],ee+=G[U+$[5]]*L[5],W+=G[U+$[6]]*F[6],ee+=G[U+$[6]]*L[6],W+=G[U+$[7]]*F[7],ee+=G[U+$[7]]*L[7],W+=G[U+$[8]]*F[8],ee+=G[U+$[8]]*L[8];const J=T(S+(k*W+x*ee)*M),Z=U*4;if(C){const Me=J-S;d[Z]=T(z[Z]+Me),d[Z+1]=T(z[Z+1]+Me),d[Z+2]=T(z[Z+2]+Me),d[Z+3]=z[Z+3]}else d[Z]=d[Z+1]=d[Z+2]=J,d[Z+3]=z[Z+3]}for(let H=0;H<f;H++){let R=H*4,U=((p-1)*f+H)*4;d[R]=z[R],d[R+1]=z[R+1],d[R+2]=z[R+2],d[R+3]=z[R+3],d[U]=z[U],d[U+1]=z[U+1],d[U+2]=z[U+2],d[U+3]=z[U+3]}for(let H=1;H<p-1;H++){let R=H*f*4,U=(H*f+(f-1))*4;d[R]=z[R],d[R+1]=z[R+1],d[R+2]=z[R+2],d[R+3]=z[R+3],d[U]=z[U],d[U+1]=z[U+1],d[U+2]=z[U+2],d[U+3]=z[U+3]}return e};ge.addGetterSetter(Tt,"embossStrength",.5,St(),ge.afterSetFilter),ge.addGetterSetter(Tt,"embossWhiteLevel",.5,St(),ge.afterSetFilter),ge.addGetterSetter(Tt,"embossDirection","top-left",void 0,ge.afterSetFilter),ge.addGetterSetter(Tt,"embossBlend",!1,void 0,ge.afterSetFilter);function x1(e,t,n,r,o){const i=n-t,s=o-r;if(i===0)return r+s/2;if(s===0)return r;let a=(e-t)/i;return a=s*a+r,a}var c$=function(e){const t=e.data,n=t.length;let r=t[0],o=r,i,s=t[1],a=s,l,u=t[2],d=u,f;const p=this.enhance();if(p===0)return;for(let b=0;b<n;b+=4)i=t[b+0],i<r?r=i:i>o&&(o=i),l=t[b+1],l<s?s=l:l>a&&(a=l),f=t[b+2],f<u?u=f:f>d&&(d=f);o===r&&(o=255,r=0),a===s&&(a=255,s=0),d===u&&(d=255,u=0);let g,m,v,C,w,S;if(p>0)g=o+p*(255-o),m=r-p*(r-0),v=a+p*(255-a),C=s-p*(s-0),w=d+p*(255-d),S=u-p*(u-0);else{const b=(o+r)*.5;g=o+p*(o-b),m=r+p*(r-b);const k=(a+s)*.5;v=a+p*(a-k),C=s+p*(s-k);const x=(d+u)*.5;w=d+p*(d-x),S=u+p*(u-x)}for(let b=0;b<n;b+=4)t[b+0]=x1(t[b+0],r,o,m,g),t[b+1]=x1(t[b+1],s,a,C,v),t[b+2]=x1(t[b+2],u,d,S,w)};ge.addGetterSetter(Tt,"enhance",0,St(),ge.afterSetFilter);var u$=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4){const o=.34*t[r]+.5*t[r+1]+.16*t[r+2];t[r]=o,t[r+1]=o,t[r+2]=o}};ge.addGetterSetter(Tt,"hue",0,St(),ge.afterSetFilter),ge.addGetterSetter(Tt,"saturation",0,St(),ge.afterSetFilter),ge.addGetterSetter(Tt,"luminance",0,St(),ge.afterSetFilter);var d$=function(e){const t=e.data,n=t.length,r=1,o=Math.pow(2,this.saturation()),i=Math.abs(this.hue()+360)%360,s=this.luminance()*127,a=r*o*Math.cos(i*Math.PI/180),l=r*o*Math.sin(i*Math.PI/180),u=.299*r+.701*a+.167*l,d=.587*r-.587*a+.33*l,f=.114*r-.114*a-.497*l,p=.299*r-.299*a-.328*l,g=.587*r+.413*a+.035*l,m=.114*r-.114*a+.293*l,v=.299*r-.3*a+1.25*l,C=.587*r-.586*a-1.05*l,w=.114*r+.886*a-.2*l;let S,b,k,x;for(let M=0;M<n;M+=4)S=t[M+0],b=t[M+1],k=t[M+2],x=t[M+3],t[M+0]=u*S+d*b+f*k+s,t[M+1]=p*S+g*b+m*k+s,t[M+2]=v*S+C*b+w*k+s,t[M+3]=x},f$=function(e){const t=e.data,n=t.length,r=Math.pow(2,this.value()),o=Math.pow(2,this.saturation()),i=Math.abs(this.hue()+360)%360,s=r*o*Math.cos(i*Math.PI/180),a=r*o*Math.sin(i*Math.PI/180),l=.299*r+.701*s+.167*a,u=.587*r-.587*s+.33*a,d=.114*r-.114*s-.497*a,f=.299*r-.299*s-.328*a,p=.587*r+.413*s+.035*a,g=.114*r-.114*s+.293*a,m=.299*r-.3*s+1.25*a,v=.587*r-.586*s-1.05*a,C=.114*r+.886*s-.2*a;for(let w=0;w<n;w+=4){const S=t[w+0],b=t[w+1],k=t[w+2],x=t[w+3];t[w+0]=l*S+u*b+d*k,t[w+1]=f*S+p*b+g*k,t[w+2]=m*S+v*b+C*k,t[w+3]=x}};ge.addGetterSetter(Tt,"hue",0,St(),ge.afterSetFilter),ge.addGetterSetter(Tt,"saturation",0,St(),ge.afterSetFilter),ge.addGetterSetter(Tt,"value",0,St(),ge.afterSetFilter);var h$=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4)t[r]=255-t[r],t[r+1]=255-t[r+1],t[r+2]=255-t[r+2]},p$=function(e,t,n){const r=e.data,o=t.data,i=e.width,s=e.height,a=n.polarCenterX||i/2,l=n.polarCenterY||s/2;let u=Math.sqrt(a*a+l*l),d=i-a,f=s-l;const p=Math.sqrt(d*d+f*f);u=p>u?p:u;const g=s,m=i,v=360/m*Math.PI/180;for(let C=0;C<m;C+=1){const w=Math.sin(C*v),S=Math.cos(C*v);for(let b=0;b<g;b+=1){d=Math.floor(a+u*b/g*S),f=Math.floor(l+u*b/g*w);let k=(f*i+d)*4;const x=r[k+0],M=r[k+1],z=r[k+2],G=r[k+3];k=(C+b*i)*4,o[k+0]=x,o[k+1]=M,o[k+2]=z,o[k+3]=G}}},m$=function(e,t,n){const r=e.data,o=t.data,i=e.width,s=e.height,a=n.polarCenterX||i/2,l=n.polarCenterY||s/2;let u=Math.sqrt(a*a+l*l),d=i-a,f=s-l;const p=Math.sqrt(d*d+f*f);u=p>u?p:u;const g=s,m=i,v=n.polarRotation||0;let C,w;for(d=0;d<i;d+=1)for(f=0;f<s;f+=1){const S=d-a,b=f-l,k=Math.sqrt(S*S+b*b)*g/u;let x=(Math.atan2(b,S)*180/Math.PI+360+v)%360;x=x*m/360,C=Math.floor(x),w=Math.floor(k);let M=(w*i+C)*4;const z=r[M+0],G=r[M+1],F=r[M+2],L=r[M+3];M=(f*i+d)*4,o[M+0]=z,o[M+1]=G,o[M+2]=F,o[M+3]=L}},g$=function(e){const t=e.width,n=e.height;let r,o,i,s,a,l,u,d,f,p,g=Math.round(this.kaleidoscopePower());const m=Math.round(this.kaleidoscopeAngle()),v=Math.floor(t*(m%360)/360);if(g<1)return;const C=Be.createCanvasElement();C.width=t,C.height=n;const w=C.getContext("2d").getImageData(0,0,t,n);Be.releaseCanvas(C),p$(e,w,{polarCenterX:t/2,polarCenterY:n/2});let S=t/Math.pow(2,g);for(;S<=8;)S=S*2,g-=1;S=Math.ceil(S);let b=S,k=0,x=b,M=1;for(v+S>t&&(k=b,x=0,M=-1),o=0;o<n;o+=1)for(r=k;r!==x;r+=M)i=Math.round(r+v)%t,f=(t*o+i)*4,a=w.data[f+0],l=w.data[f+1],u=w.data[f+2],d=w.data[f+3],p=(t*o+r)*4,w.data[p+0]=a,w.data[p+1]=l,w.data[p+2]=u,w.data[p+3]=d;for(o=0;o<n;o+=1)for(b=Math.floor(S),s=0;s<g;s+=1){for(r=0;r<b+1;r+=1)f=(t*o+r)*4,a=w.data[f+0],l=w.data[f+1],u=w.data[f+2],d=w.data[f+3],p=(t*o+b*2-r-1)*4,w.data[p+0]=a,w.data[p+1]=l,w.data[p+2]=u,w.data[p+3]=d;b*=2}m$(w,e,{polarRotation:0})};ge.addGetterSetter(Tt,"kaleidoscopePower",2,St(),ge.afterSetFilter),ge.addGetterSetter(Tt,"kaleidoscopeAngle",0,St(),ge.afterSetFilter);function mg(e,t,n){let r=(n*e.width+t)*4;const o=[];return o.push(e.data[r++],e.data[r++],e.data[r++],e.data[r++]),o}function Ih(e,t){return Math.sqrt(Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)+Math.pow(e[2]-t[2],2))}function v$(e){const t=[0,0,0];for(let n=0;n<e.length;n++)t[0]+=e[n][0],t[1]+=e[n][1],t[2]+=e[n][2];return t[0]/=e.length,t[1]/=e.length,t[2]/=e.length,t}function y$(e,t){const n=mg(e,0,0),r=mg(e,e.width-1,0),o=mg(e,0,e.height-1),i=mg(e,e.width-1,e.height-1),s=t||10;if(Ih(n,r)<s&&Ih(r,i)<s&&Ih(i,o)<s&&Ih(o,n)<s){const a=v$([r,n,i,o]),l=[];for(let u=0;u<e.width*e.height;u++)l[u]=Ih(a,[e.data[u*4],e.data[u*4+1],e.data[u*4+2]])<s?0:255;return l}}function b$(e,t){for(let n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}function w$(e,t,n){const r=[1,1,1,1,0,1,1,1,1],o=Math.round(Math.sqrt(r.length)),i=Math.floor(o/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const u=a*t+l;let d=0;for(let f=0;f<o;f++)for(let p=0;p<o;p++){const g=a+f-i,m=l+p-i;if(g>=0&&g<n&&m>=0&&m<t){const v=g*t+m,C=r[f*o+p];d+=e[v]*C}}s[u]=d===2040?255:0}return s}function C$(e,t,n){const r=[1,1,1,1,1,1,1,1,1],o=Math.round(Math.sqrt(r.length)),i=Math.floor(o/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const u=a*t+l;let d=0;for(let f=0;f<o;f++)for(let p=0;p<o;p++){const g=a+f-i,m=l+p-i;if(g>=0&&g<n&&m>=0&&m<t){const v=g*t+m,C=r[f*o+p];d+=e[v]*C}}s[u]=d>=1020?255:0}return s}function k$(e,t,n){const r=[.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111],o=Math.round(Math.sqrt(r.length)),i=Math.floor(o/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const u=a*t+l;let d=0;for(let f=0;f<o;f++)for(let p=0;p<o;p++){const g=a+f-i,m=l+p-i;if(g>=0&&g<n&&m>=0&&m<t){const v=g*t+m,C=r[f*o+p];d+=e[v]*C}}s[u]=d}return s}var S$=function(e){let t=y$(e,this.threshold());return t&&(t=w$(t,e.width,e.height),t=C$(t,e.width,e.height),t=k$(t,e.width,e.height),b$(e,t)),e};ge.addGetterSetter(Tt,"threshold",0,St(),ge.afterSetFilter);var _$=function(e){const t=this.noise()*255,n=e.data,r=n.length,o=t/2;for(let i=0;i<r;i+=4)n[i+0]+=o-2*o*Math.random(),n[i+1]+=o-2*o*Math.random(),n[i+2]+=o-2*o*Math.random()};ge.addGetterSetter(Tt,"noise",.2,St(),ge.afterSetFilter);var A$=function(e){let t=Math.ceil(this.pixelSize()),n=e.width,r=e.height,o=Math.ceil(n/t),i=Math.ceil(r/t),s=e.data;if(t<=0){Be.error("pixelSize value can not be <= 0");return}for(let a=0;a<o;a+=1)for(let l=0;l<i;l+=1){let u=0,d=0,f=0,p=0;const g=a*t,m=g+t,v=l*t,C=v+t;let w=0;for(let S=g;S<m;S+=1)if(!(S>=n))for(let b=v;b<C;b+=1){if(b>=r)continue;const k=(n*b+S)*4;u+=s[k+0],d+=s[k+1],f+=s[k+2],p+=s[k+3],w+=1}u=u/w,d=d/w,f=f/w,p=p/w;for(let S=g;S<m;S+=1)if(!(S>=n))for(let b=v;b<C;b+=1){if(b>=r)continue;const k=(n*b+S)*4;s[k+0]=u,s[k+1]=d,s[k+2]=f,s[k+3]=p}}};ge.addGetterSetter(Tt,"pixelSize",8,St(),ge.afterSetFilter);var I$=function(e){const t=Math.round(this.levels()*254)+1,n=e.data,r=n.length,o=255/t;for(let i=0;i<r;i+=1)n[i]=Math.floor(n[i]/o)*o};ge.addGetterSetter(Tt,"levels",.5,St(),ge.afterSetFilter);var E$=function(e){const t=e.data,n=t.length,r=this.red(),o=this.green(),i=this.blue();for(let s=0;s<n;s+=4){const a=(.34*t[s]+.5*t[s+1]+.16*t[s+2])/255;t[s]=a*r,t[s+1]=a*o,t[s+2]=a*i,t[s+3]=t[s+3]}};ge.addGetterSetter(Tt,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),ge.addGetterSetter(Tt,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),ge.addGetterSetter(Tt,"blue",0,tI,ge.afterSetFilter);var x$=function(e){const t=e.data,n=t.length,r=this.red(),o=this.green(),i=this.blue(),s=this.alpha();for(let a=0;a<n;a+=4){const l=1-s;t[a]=r*s+t[a]*l,t[a+1]=o*s+t[a+1]*l,t[a+2]=i*s+t[a+2]*l}};ge.addGetterSetter(Tt,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),ge.addGetterSetter(Tt,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),ge.addGetterSetter(Tt,"blue",0,tI,ge.afterSetFilter),ge.addGetterSetter(Tt,"alpha",1,function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e});var T$=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4){const o=t[r+0],i=t[r+1],s=t[r+2];t[r+0]=Math.min(255,o*.393+i*.769+s*.189),t[r+1]=Math.min(255,o*.349+i*.686+s*.168),t[r+2]=Math.min(255,o*.272+i*.534+s*.131)}},R$=function(e){const n=e.data;for(let r=0;r<n.length;r+=4){const o=n[r],i=n[r+1],s=n[r+2];.2126*o+.7152*i+.0722*s>=128&&(n[r]=255-o,n[r+1]=255-i,n[r+2]=255-s)}return e},M$=function(e){const t=this.threshold()*255,n=e.data,r=n.length;for(let o=0;o<r;o+=1)n[o]=n[o]<t?0:255};ge.addGetterSetter(Tt,"threshold",.5,St(),ge.afterSetFilter);var L$=LI.Util._assign(LI,{Arc:qa,Arrow:jc,Circle:vd,Ellipse:$l,Image:ys,Label:_1,Tag:Vc,Line:Ya,Path:Wi,Rect:Sh,RegularPolygon:Hl,Ring:Uc,Sprite:ia,Star:Gl,Text:fr,TextPath:Jr,Transformer:Nn,Wedge:Xa,Filters:{Blur:o$,Brightness:s$,Brighten:i$,Contrast:a$,Emboss:l$,Enhance:c$,Grayscale:u$,HSL:d$,HSV:f$,Invert:h$,Kaleidoscope:g$,Mask:S$,Noise:_$,Pixelate:A$,Posterize:I$,RGB:E$,RGBA:x$,Sepia:T$,Solarize:R$,Threshold:M$}}),P$=L$;Ft();var D$=["dialog","floating"],tE=["top-right","top-left","bottom-right","bottom-left","top-center","bottom-center"];function O$(e){if(!e||typeof e!="object")throw new Error("SurfaceManager: request must be a non-null object.");if(!D$.includes(e.mode))throw new Error(`SurfaceManager: mode must be "dialog" or "floating", got "${e.mode}".`);const t="kind"in e&&e.kind!=null,n="component"in e&&e.component!=null,r="render"in e&&typeof e.render=="function";if(n&&r)throw new Error('SurfaceManager: request cannot provide both "component" and "render". Use one or the other.');if(!t&&!n&&!r)throw new Error('SurfaceManager: request must provide "kind" (intent-based) or "component"/"render" (direct-render).');if(e.mode==="floating"&&e.floating?.placement!=null&&!tE.includes(e.floating.placement))throw new Error(`SurfaceManager: floating.placement must be one of ${tE.join(", ")}, got "${e.floating.placement}".`)}var F$=class{activeDialog=Pr(null);activeFloating=Pr(null);#e=!1;#n=1;#t;constructor({getModuleConfig:e}){this.#t=e}open(e){if(this.#e)return this.#c(e);O$(e);const t=this.#u(e),{component:n,props:r,render:o}=this.#f(t);let i,s=!1;const a=new Promise(g=>{i=m=>s?!1:(s=!0,g(m),!0)});let l;const u=g=>{i({status:"submitted",data:g})&&this.#i(l)},d=g=>{i({status:"closed",reason:g})&&this.#i(l)};l={id:t.id,mode:t.mode,request:t,component:n,props:r,render:o,resolve:u,close:d,settle:g=>i(g),get settled(){return s}};const f=t.mode==="dialog"?"activeDialog":"activeFloating",p=this[f].value;return p&&!p.settled&&p.settle({status:"replaced",replacedBy:t.id}),this[f].value=l,{id:t.id,mode:t.mode,close:g=>this.#o(l,g),result:a}}close(e,t){if(e!=null){const o=this.#a(e);o&&this.#o(o,t);return}const n=this.activeDialog.value;if(n&&!n.settled){this.#o(n,t);return}const r=this.activeFloating.value;r&&!r.settled&&this.#o(r,t)}settleAll(e){for(const t of[this.activeDialog,this.activeFloating]){const n=t.value;n&&!n.settled&&n.settle(e),t.value=null}}destroy(){this.#e=!0,this.settleAll({status:"destroyed"})}#o(e,t){e.settled||(e.settle({status:"closed",reason:t}),this.#i(e))}#i(e){const t=e.mode==="dialog"?this.activeDialog:this.activeFloating;t.value===e&&(t.value=null)}#a(e){return this.activeDialog.value?.id===e?this.activeDialog.value:this.activeFloating.value?.id===e?this.activeFloating.value:null}#u(e){const t=e.id??`surface-${this.#n++}`,n=this.#t()??{},r=e.mode==="dialog"?n.dialog:n.floating,o=e.mode==="dialog"?{maxWidth:r?.maxWidth,...e.dialog}:e.dialog,i=e.mode==="floating"?{placement:r?.placement??"top-right",width:r?.width,maxWidth:r?.maxWidth,maxHeight:r?.maxHeight,autoFocus:r?.autoFocus??!0,closeOnOutsidePointerDown:r?.closeOnOutsidePointerDown??!1,...e.floating}:e.floating;return{...e,id:t,closeOnEscape:e.closeOnEscape??r?.closeOnEscape??!0,closeOnBackdrop:e.mode==="dialog"?e.closeOnBackdrop??r?.closeOnBackdrop??!0:!1,dialog:o,floating:i}}#f(e){if("component"in e&&e.component!=null)return{component:e.component,props:e.props};if("render"in e&&typeof e.render=="function")return{render:e.render};const t=this.#t()?.resolver;if(typeof t=="function"){const n=t(e);if(n!=null){if(n.type==="none")throw new Error(`SurfaceManager: resolver explicitly suppressed surface for kind "${e.kind}".`);if(n.type==="custom")return{component:n.component,props:n.props};if(n.type==="external")return{render:n.render}}}throw new Error(`SurfaceManager: no renderer resolved for kind "${e.kind}". Provide a resolver via surfaces.resolver, or use a direct-render request.`)}#c(e){return{id:e?.id??`surface-${this.#n++}`,mode:e?.mode??"dialog",close:()=>{},result:Promise.resolve({status:"destroyed"})}}},N$="https://docs.superdoc.dev/guides/migration/document-api",nE=new Set;function B$(e,t){nE.has(e)||(nE.add(e),console.warn(t))}var z$={state:"editor.state",view:"editor.view",schema:"editor.schema",commands:"editor.commands",chain:"editor.chain()",can:"editor.can()",dispatch:"editor.dispatch()"},rE=Symbol.for("superdoc:rawEditor"),oE=new WeakMap;function iE(e){return!e||e[rE]?e:new Proxy(e,{get(t,n){if(n===rE)return t;const r=z$[n];r&&B$(`deprecated:${String(n)}`,`[SuperDoc] ${r} is deprecated and will be removed in a future version. Use the Document API (editor.doc) instead. See ${N$}`);const o=Reflect.get(t,n,t);if(typeof o=="function"){let i=oE.get(t);return i||(i=new Map,oE.set(t,i)),i.has(n)||i.set(n,o.bind(t)),i.get(n)}return o}})}var sE=["review","original","final","off"],j$=["original","markup","final"],V$=["paired","independent"],aE=Symbol.for("@superdoc/trackChanges:normalized"),lE=new Set;function T1(e,t){lE.has(e)||(lE.add(e),console.warn(`[SuperDoc] ${e} is deprecated — use ${t} instead.`))}function cE(e,t,n){return typeof e=="boolean"?e:typeof t=="boolean"?t:n}function U$(e,t,n){return typeof e=="string"&&sE.includes(e)?e:typeof t=="string"&&sE.includes(t)?t:n}function $$(e){return typeof e!="string"||!j$.includes(e)?null:e}function H$(e){return e==="markup"?"review":e}function G$(e){return typeof e=="string"&&V$.includes(e)?e:null}function W$(e){return e==="grouped"?"paired":e==="separate"?"independent":null}function K$(e){return e==="paired"?"grouped":"separate"}function bs(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function R1(e){const t=e[aE]===!0,n=bs(e.viewing),r=$$(n?.trackedChanges);bs(e.modules)||(e.modules={});const o=bs(e.trackChanges),i=bs(e.modules.trackChanges),s=bs(e.layoutEngineOptions?.trackedChanges);t||(o&&Object.prototype.hasOwnProperty.call(o,"visible")&&T1("config.trackChanges.visible","config.viewing.trackedChanges"),i&&T1("config.modules.trackChanges","config.trackChanges for behavior and config.viewing.trackedChanges for viewing projection"),s&&T1("config.layoutEngineOptions.trackedChanges","config.viewing.trackedChanges for display and config.trackChanges.enabled for behavior"));const a=r?r==="markup":cE(o?.visible,i?.visible,!1),l=cE(o?.enabled,i?.enabled,typeof s?.enabled=="boolean"?s.enabled:!0),u=W$(o?.replacementMode)??G$(i?.replacements)??"paired",d=bs(o?.authorColors)??bs(i?.authorColors),f=d||void 0,p=bs(o?.semanticColors)??bs(i?.semanticColors),g=p||void 0,m=e.documentMode==="viewing",v=m?a?"review":"original":"review",C=r?m?H$(r):"review":U$(i?.mode,s?.mode,v),w={visible:a,mode:C,enabled:l,replacements:u};return f&&(w.authorColors=f),g&&(w.semanticColors=g),e.modules.trackChanges=w,e.trackChanges={visible:a,enabled:l,replacementMode:K$(u)},f&&(e.trackChanges.authorColors=f),g&&(e.trackChanges.semanticColors=g),bs(e.layoutEngineOptions)||(e.layoutEngineOptions={}),e.layoutEngineOptions.trackedChanges={mode:C,enabled:l},typeof n?.comments=="boolean"&&(bs(e.comments)||(e.comments={}),e.comments.visible=n.comments),Object.defineProperty(e,aE,{value:!0,writable:!0,configurable:!0,enumerable:!1}),w}var M1=Object.freeze({id:null,name:"Default SuperDoc user",email:null});function q$(e){return!e||typeof e!="object"?{...M1}:{...M1,...e}}var gg=Object.freeze({"font-family":"fontFamily","font-size":"fontSize",strikethrough:"strike","highlight-color":"highlight","text-color":"color","table-of-contents":"tableOfContents","page-number":"pageNumber","table-actions":"tableActions","text-align":"textAlign","bullet-list":"list","numbered-list":"numberedlist","indent-decrease":"indentleft","indent-increase":"indentright","line-height":"lineHeight","linked-style":"linkedStyles","measurement-unit":"measurementUnit","formatting-marks":"formattingMarks","copy-format":"copyFormat","clear-formatting":"clearFormatting","document-mode":"documentMode","track-changes-accept-selection":"acceptTrackedChangeBySelection","track-changes-reject-selection":"rejectTrackedChangeOnSelection"}),uE=Object.freeze({toolbar:!0,comments:!0,contextMenu:!0,loading:!0,search:!1,linkPopover:!1,ruler:!1,contentControls:!0}),Y$=Object.freeze(["left","center","right"]),X$=Object.freeze({compact:32,default:80,wide:120}),xX=Object.freeze(Object.keys(uE)),qr=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function dE(e,t){const n=e?.[t];return n===!1?!1:n===void 0?uE[t]:!0}function Z$(e,t){const n=e?.[t];return qr(n)?n:{}}var fE=Object.freeze(["level","readOnly","allowResolve","permissionResolver"]);function Q$(e){if(!fE.some(n=>n in e))return e;const t={...e};for(const n of fE)delete t[n];return t}function hE(e){const t={...e},n=zl(e.sections,e.customItems),r=zl(e.defaultItems,e.includeDefaultItems);return delete t.customItems,delete t.includeDefaultItems,Yo(t,{sections:n,defaultItems:r})}var pE=Object.freeze({findPlaceholder:"findPlaceholder",findAriaLabel:"findAriaLabel",replacePlaceholder:"replacePlaceholder",replaceAriaLabel:"replaceAriaLabel",noResults:"noResultsLabel",previousMatchTitle:"previousMatchLabel",previousMatchAriaLabel:"previousMatchAriaLabel",nextMatchTitle:"nextMatchLabel",nextMatchAriaLabel:"nextMatchAriaLabel",closeTitle:"closeLabel",closeAriaLabel:"closeAriaLabel",replace:"replaceLabel",replaceAll:"replaceAllLabel",toggleReplaceTitle:"toggleReplaceLabel",toggleReplaceAriaLabel:"toggleReplaceAriaLabel",matchCase:"matchCaseLabel",matchCaseAriaLabel:"matchCaseAriaLabel",ignoreDiacritics:"ignoreDiacriticsLabel",ignoreDiacriticsAriaLabel:"ignoreDiacriticsAriaLabel",regex:"regexLabel",regexAriaLabel:"regexAriaLabel",invalidPattern:"invalidPatternLabel"});function J$(e){return qr(e)?Object.fromEntries(Object.entries(e).filter(([t,n])=>pE[t]!==void 0&&n!==void 0).map(([t,n])=>[pE[t],n])):{}}function mE(e){const t={...e};return delete t.strings,delete t.replaceControls,delete t.includeTrackedDeletions,Yo(t,J$(e.strings),{replaceEnabled:zl(e.replaceControls,e.replaceEnabled),includeDeletedText:zl(e.includeTrackedDeletions,e.includeDeletedText)})}var eH=Object.freeze({"text-color":"color","table-of-contents":"tableOfContents","page-number":"pageNumber","align-left":"alignLeft","align-right":"alignRight","align-center":"alignCenter","align-justify":"alignJustify","bullet-list":"bulletList","numbered-list":"numberedList","indent-decrease":"indentLeft","indent-increase":"indentRight","copy-format":"copyFormat","clear-formatting":"clearFormatting","track-changes-accept-selection":"trackChangesAccept","track-changes-reject-selection":"trackChangesReject","document-mode":"documentMode","document-mode-editing":"documentEditingMode","document-mode-suggesting":"documentSuggestingMode","document-mode-viewing":"documentViewingMode","highlight-color":"highlight","linked-style":"paintbrush","table-actions":"tableActions","split-cell":"splitCell","merge-cells":"mergeCells","insert-row-before":"addRowBefore","insert-row-after":"addRowAfter","insert-column-before":"addColumnBefore","insert-column-after":"addColumnAfter","delete-row":"deleteRow","delete-column":"deleteColumn","delete-table":"deleteTable","remove-borders":"deleteBorders","fix-tables":"fixTables","line-height":"lineHeight","formatting-marks":"formattingMarks"}),tH=Object.freeze({"font-family":"fontFamily","font-size":"fontSize","highlight-color":"highlight","text-color":"color","table-of-contents":"tableOfContents","page-number":"pageNumber","table-actions":"tableActions","insert-row-before":"addRowBefore","insert-row-after":"addRowAfter","insert-column-before":"addColumnBefore","insert-column-after":"addColumnAfter","delete-row":"deleteRow","delete-column":"deleteColumn","delete-table":"deleteTable","remove-borders":"removeBorders","merge-cells":"mergeCells","split-cell":"splitCell","fix-tables":"fixTables","text-align":"textAlign","bullet-list":"bulletList","numbered-list":"numberedList","indent-decrease":"indentLeft","indent-increase":"indentRight","measurement-unit":"measurementUnit","track-changes-accept-selection":"trackChangesAccept","track-changes-reject-selection":"trackChangesReject","clear-formatting":"clearFormatting","copy-format":"copyFormat","line-height":"lineHeight","linked-style-label":"formatText","formatting-marks":"formattingMarks","document-mode-editing":"documentEditingMode","document-mode-suggesting":"documentSuggestingMode","document-mode-viewing":"documentViewingMode","document-mode-editing-description":"documentEditingModeDescription","document-mode-suggesting-description":"documentSuggestingModeDescription","document-mode-viewing-description":"documentViewingModeDescription","linked-style":"linkedStyles"});function vg(e,t){return t[e]??e}function L1(e,t){if(!qr(e))return;const n=Object.entries(e),r=n.filter(([i])=>t[i]===void 0),o=n.filter(([i])=>t[i]!==void 0);return Object.fromEntries([...r,...o].map(([i,s])=>[vg(i,t),s]))}function gE(e){return Array.isArray(e)?e.map(t=>vg(t,gg)):e}function vE(e){return qr(e)?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,gE(n)])):e}function nH(e,t){if(!qr(e)||!Array.isArray(t))return e;const n={...e};for(const r of t){if(!qr(r))continue;const o=r.region??"center";n[o]===void 0&&(n[o]=[])}return n}var rH=Object.freeze({watermark:"center","page-number":"center","formatting-marks":"right","table-of-contents":"center"});function oH(e,t){if(!qr(e)||!Array.isArray(t))return e;const n=Object.fromEntries(Object.entries(e).map(([o,i])=>[o,Array.isArray(i)?[...i]:i])),r=new Set(Object.values(n).flatMap(o=>Array.isArray(o)?o:[]).map(o=>vg(o,gg)));for(const o of t){const i=vg(o,gg);if(r.has(i))continue;const s=rH[o];s&&(Array.isArray(n[s])||(n[s]=[]),n[s].push(o),r.add(i))}return n}function yE(e,t){return nH(oH(e,t.includeItems),t.customItems)}function iH(e){return Array.isArray(e)?e.map(t=>{if(!qr(t))return t;const{value:n,label:r,previewFamily:o}=t;return{key:n,value:n,label:r,...o?{props:{style:{fontFamily:o}}}:{}}}):e}function sH(e){return Array.isArray(e)?e.map(t=>{if(!qr(t)||typeof t.id!="string")return t;const n=t.size??"default",r=t.type==="separator"?void 0:X$[n],o={...t,name:t.id,group:t.region,isNarrow:n==="compact",isWide:n==="wide",...r?{layoutWidth:r,style:{...t.style,width:`${r-2}px`}}:{}};return t.label&&(o.defaultLabel===void 0&&(o.defaultLabel=t.label),o.attributes={...t.attributes,ariaLabel:t.attributes?.ariaLabel??t.label}),t.type==="dropdown"&&Array.isArray(t.options)&&(o.options=t.options.map(i=>qr(i)?{...i,key:i.value??i.id,value:i.value??i.id}:i),o.dropdownValueKey="value"),typeof t.onSelect=="function"&&(o.command=({item:i,argument:s,payload:a,...l})=>t.onSelect({...l,value:s})),delete o.id,delete o.region,delete o.size,delete o.onSelect,o}):e}function aH(e){const t={...e},n=zl(e.items,qr(e.groups)?e.groups:void 0),r=qr(e.items)&&Object.keys(e.items).length===0?{center:[]}:n,o=yE(r,e),i=o===void 0?e.groups:vE(o),s=L1(e.icons,eH),a=Yo(L1(e.texts,{}),L1(e.strings,tH)),l=Array.isArray(e.includeItems)?new Set(e.includeItems):null,u=qr(r)?new Set(Object.values(r).flatMap(d=>Array.isArray(d)?d:[])):new Set;return delete t.items,delete t.includeItems,delete t.overflow,delete t.responsiveTo,delete t.fontOptions,delete t.customItems,delete t.strings,Yo(t,{groups:i,excludeItems:gE(e.excludeItems),icons:s,texts:a,hideButtons:e.overflow===void 0?e.hideButtons:e.overflow==="menu",responsiveToContainer:e.responsiveTo===void 0?e.responsiveToContainer:e.responsiveTo==="container",fonts:e.fontOptions===void 0?e.fonts:iH(e.fontOptions),customButtons:e.customItems===void 0?e.customButtons:sH(e.customItems),showFormattingMarksButton:l===null&&!u.has("formatting-marks")?e.showFormattingMarksButton:u.has("formatting-marks")||l?.has("formatting-marks"),showTableOfContentsButton:l===null&&!u.has("table-of-contents")?e.showTableOfContentsButton:u.has("table-of-contents")||l?.has("table-of-contents"),showWatermarkButton:u.has("watermark")||l?.has("watermark")||!1,showPageNumberButton:u.has("page-number")||l?.has("page-number")||!1})}function bE(e={}){const t=e.ui,n=t===!1,r=qr(t)?t:void 0,o=H=>!n&&dE(r,H),i=H=>n?!1:r?.[H]===void 0?void 0:dE(r,H),s=H=>n?{}:Z$(r,H),a=n||i("ruler")===!1,l=n||i("linkPopover")===!1,u=l?void 0:zl(s("linkPopover").popoverResolver,e.modules?.links?.popoverResolver),d=i("contentControls")??(!n&&e.modules?.contentControls?.chrome!=="none"),f=e.modules?.contentControls?.chrome==="none"?void 0:e.modules?.contentControls?.chrome,p=s("toolbar"),g=aH(p),m=qr(p.items),v=e.modules?.toolbar,C=qr(v)?v:{},w=e.modules?.contextMenu??e.modules?.slashMenu,S=qr(w)?w:{},b=e.modules?.surfaces?.findReplace,k=mE(qr(b)?b:{}),x=qr(C.groups)?vE(yE(C.groups,p)):C.groups,M=[g.groups,x],z=M.find(qr),G=M.find(Array.isArray),F=m?Object.keys(g.groups??{}):zl(G,C.toolbarGroups,e.toolbarGroups),L=Array.isArray(F)?F:null,$=(H,R)=>Object.prototype.hasOwnProperty.call(H,R),T=z&&L?Object.fromEntries([...L.filter(H=>$(z,H)),...Object.keys(z).filter(H=>!Y$.includes(H))].map(H=>[H,z[H]])):z;return{enabled:!n,toolbar:{enabled:o("toolbar"),container:n?null:zl(g.container,C.selector,e.toolbar)??null,options:n?{}:{...Yo(C,g),groups:T,toolbarGroups:F,icons:Yo(e.toolbarIcons,C.icons,g.icons),texts:Yo(e.toolbarTexts,C.texts,g.texts)}},comments:{enabled:i("comments")??(!n&&e.modules?.comments!==!1),options:n?{}:iA(Q$(s("comments")))},contextMenu:{enabled:i("contextMenu")??(!n&&e.disableContextMenu!==!0),suppressed:n||i("contextMenu")===!1,options:n?{}:Yo(hE(S),hE(s("contextMenu")))},loading:{enabled:o("loading")},search:{enabled:i("search")??(!n&&!!e.modules?.surfaces?.findReplace),options:n?{}:Yo(k,mE(s("search")))},linkPopover:{enabled:typeof u=="function",suppressed:l,options:Yo(s("linkPopover"),{popoverResolver:u})},ruler:{enabled:i("ruler")??(!n&&!!e.rulers),suppressed:a,container:a?null:s("ruler").container??e.rulerContainer??null},contentControls:{enabled:d,options:d?Yo({chrome:f},s("contentControls")):{chrome:"none"}}}}var yg=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),lH=e=>e==="read"||e==="write"||e==="resolve";function wE(e={}){const t=yg(e.interaction)?e.interaction:{},n=yg(t.comments)?t.comments:{},r=yg(t.trackedChanges)?t.trackedChanges:{},o=yg(e.modules?.comments)?e.modules.comments:{},i=(n.readOnly??o.readOnly??!1)===!0,s=(n.allowResolve??o.allowResolve??!0)!==!1,a=lH(n.level),l=a?n.level:i?"read":s?"resolve":"write",u=r.allowDecisions;return{comments:{level:l,readOnly:a?l==="read":i,allowResolve:a?l==="resolve":s},trackedChanges:{allowDecisions:typeof u=="boolean"?u:!i}}}var CE=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function kE(e={}){const t=CE(e.surfaces)?e.surfaces:{},n=CE(e.modules?.surfaces)?e.modules.surfaces:{},r=t.resolver===void 0?n.resolver:t.resolver;return{resolver:typeof r=="function"?r:null,dialog:Yo(n.dialog,t.dialog),floating:Yo(n.floating,t.floating)}}var cH="https://docs.superdoc.dev/editor/fonts/";function uH(e){return e==="localhost"||e.endsWith(".localhost")||e==="0.0.0.0"||e==="::1"||e==="[::1]"||e.startsWith("127.")}function dH(e,t,n=typeof window>"u"?"":window.location.hostname){if(!uH(n)||!Array.isArray(e))return;const r=[...new Set(e.map(s=>s.trim()).filter(Boolean))].filter(s=>!t.has(s));if(r.length===0)return;for(const s of r)t.add(s);const o=r.length===1?"font":"fonts",i=r.map(s=>`"${s}"`).join(", ");console.warn(`[SuperDoc] Missing document ${o}: ${i}. The browser is using fallback fonts, which can change line and page breaks. Configure document fonts: ${cH}`)}var fH=class{#e=new Map;#n=new Map;#t=null;#o=new Set;register(e){if(this.#e.has(e.id))throw new Error(`EditorRuntimeRegistry: duplicate runtime id "${e.id}"`);const t=e.root,n=t?this.#n.get(t):void 0;if(n!==void 0&&n!==e.id)throw new Error(`EditorRuntimeRegistry: root element already registered to runtime "${n}"`);this.#e.set(e.id,e),t&&this.#n.set(t,e.id)}unregister(e){const t=this.#e.get(e);return t?(this.#e.delete(e),t.root&&this.#n.delete(t.root),this.#t===e&&(this.#t=null,this.#i({previousRuntimeId:e,nextRuntimeId:null,reason:"active-runtime-unregistered",legacyEditorProjection:null})),!0):!1}get(e){return this.#e.get(e)??null}getAll(){return Array.from(this.#e.values())}getAllByDocumentId(e){const t=[];for(const n of this.#e.values())n.documentId===e&&t.push(n);return t}getActive(){return this.#t===null?null:this.#e.get(this.#t)}getActiveId(){return this.#t}setActive(e,t){if(e!==null&&!this.#e.has(e))throw new Error(`EditorRuntimeRegistry: cannot activate unknown runtime "${e}"`);if(e===this.#t)return;const n=this.#t;this.#t=e;let r=null;e!==null&&(r=this.#e.get(e).getLegacyEditorProjection?.()??null),this.#i({previousRuntimeId:n,nextRuntimeId:e,reason:t,legacyEditorProjection:r})}resolveFromEventTarget(e){const t=e instanceof Element?e:e instanceof Node?e.parentElement:null;if(!t)return null;const n=t.closest(`[${Ym}]`);if(!n)return null;const r=n.getAttribute(Ym),o=r?this.get(r):null;return o&&o.root===n?o:null}subscribe(e){return this.#o.add(e),()=>{this.#o.delete(e)}}clear(){this.#e.clear(),this.#n.clear(),this.#t=null,this.#o.clear()}#i(e){for(const t of Array.from(this.#o))try{t(e)}catch{}}},hH=["table-add-row-before","table-add-row-after","table-delete-row","table-add-column-before","table-add-column-after","table-delete-column","table-delete","table-merge-cells","table-split-cell","table-remove-borders"],SE=[{name:"bold",commandId:"bold",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"italic",commandId:"italic",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"underline",commandId:"underline",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"strike",commandId:"strikethrough",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"clearFormatting",commandId:"clear-formatting",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"copyFormat",commandId:"copy-format",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"fontFamily",commandId:"font-family",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"fontSize",commandId:"font-size",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"color",commandId:"text-color",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"highlight",commandId:"highlight-color",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"textAlign",commandId:"text-align",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"list",commandId:"bullet-list",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"numberedlist",commandId:"numbered-list",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"indentleft",commandId:"indent-decrease",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"indentright",commandId:"indent-increase",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"lineHeight",commandId:"line-height",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"linkedStyles",commandId:"linked-style",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"link",commandId:"link",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"image",commandId:"image",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"watermark",commandId:null,instanceMethod:"ui.watermark.open",disposition:"host-routed",group:"center",note:"opens the shared Watermark dialog through superdoc.ui.watermark.open; the workflow owns scope, edit permissions, and apply"},{name:"pageNumber",commandId:"page-numbers-apply",instanceMethod:null,disposition:"controller-routed",group:"center",note:"opens the Page number popover: adds or changes the caret section numbers (position, first page, style, start) through page-numbers-apply, removes them through page-numbers-remove, or inserts at a header/footer cursor through page-number-insert"},{name:"table",commandId:"table-insert",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"tableActions",commandId:null,instanceMethod:null,disposition:"shell-owned",group:"center",memberCommandIds:hH,note:"table editing dropdown is shell chrome; its member commands are controller-routed through the shared table-context facade (ui.tables / host.getTableContext()) and fail closed with table-context-unavailable when the caret is not in a table"},{name:"undo",commandId:"undo",instanceMethod:null,disposition:"controller-routed",group:"left"},{name:"redo",commandId:"redo",instanceMethod:null,disposition:"controller-routed",group:"left"},{name:"search",commandId:null,instanceMethod:null,disposition:"shell-owned",group:"right",note:"built-in search button; opens the shared find/replace surface (the same one Cmd/Ctrl+F opens) by emitting a `search:open` event on the SuperDoc instance, which the shell handles. The surface reads/drives the controller search surface (ui.search), backed by the single V2 host search session (host.search) which owns query, navigation, reveal, and replace. Find/navigation are always available when the host exposes search; replace/replaceAll mutate through the host session and fail closed (document-readonly) in viewing/read-only mode. If a runtime cannot expose search, the surface fails closed with search-unavailable"},{name:"zoom",commandId:"zoom",instanceMethod:null,disposition:"controller-routed",group:"right"},{name:"measurementUnit",commandId:"measurement-unit",instanceMethod:null,disposition:"controller-routed",group:"right"},{name:"ruler",commandId:null,instanceMethod:"toggleRuler",disposition:"host-routed",group:"right",note:"built-in shell toggles ruler visibility through the public SuperDoc.toggleRuler() instance method; the controller also routes the ruler command through it so custom UIs drive the same chrome (active state from config.rulers)"},{name:"formattingMarks",commandId:null,instanceMethod:"toggleFormattingMarks",disposition:"host-routed",group:"right",note:"built-in shell toggles nonprinting marks through the public SuperDoc.toggleFormattingMarks()/setShowFormattingMarks() instance methods (not a controller command)"},{name:"documentMode",commandId:"document-mode",instanceMethod:null,disposition:"controller-routed",group:"right"},{name:"acceptTrackedChangeBySelection",commandId:"track-changes-accept-selection",instanceMethod:null,disposition:"controller-routed",group:"right"},{name:"rejectTrackedChangeOnSelection",commandId:"track-changes-reject-selection",instanceMethod:null,disposition:"controller-routed",group:"right"},{name:"customButtons",commandId:null,instanceMethod:null,disposition:"shell-owned",group:"center",note:"consumer-defined buttons the rendered shell owns; their execution context surface is phase 2"}],_E=new Map(SE.map(e=>[e.name,e])),pH=SE.map(e=>e.name);function P1(e){return _E.get(e)??null}function mH(e){const t=_E.get(e);return t?.disposition==="controller-routed"?t.commandId:null}var gH=(e,t)=>{let n=e.replace(/[^0-9.]/g,"");return n=parseFloat(n),isNaN(n)&&(n=t),n=parseFloat(n),n},vH=(e,t,n)=>{let r,o,i,s=0;n||(n={});const a=()=>{s=n.leading===!1?0:Date.now(),r=null,i=e(...o),r||(o=null)},l=(...u)=>{const d=Date.now();!s&&n.leading===!1&&(s=d);const f=t-(d-s);return o=u,f<=0||f>t?(r&&(clearTimeout(r),r=null),s=d,i=e(...u),r||(o=null)):!r&&n.trailing!==!1&&(r=setTimeout(a,f)),i};return l.cancel=function(){clearTimeout(r),s=0,r=o=null},l};Ft(),yn();var yH={class:"sd-toolbar-icon"},bH=["innerHTML"],wH={__name:"ToolbarButtonIcon",props:{name:{type:String,required:!0},color:{type:String,default:null},icon:{type:String,default:null}},setup(e){const t=e,n=_e(()=>{if(t.name==="color")return{backgroundColor:t.color||"#111111"};if(t.name==="highlight")return{backgroundColor:t.color||"#D6D6D6"}}),r=_e(()=>["color","highlight"].includes(t.name));return(o,i)=>(pe(),Ce("div",yH,[ce("div",{class:Zt(["sd-toolbar-icon__icon",[`sd-toolbar-icon__icon--${t.name}`]]),innerHTML:e.icon},null,10,bH),r.value?(pe(),Ce("div",{key:0,class:"color-bar",style:An(n.value)},null,4)):ut("",!0)]))}},AE=mn(wH,[["__scopeId","data-v-65ecd5b1"]]);Ft(),yn();var CH=["role","aria-label","aria-disabled"],kH=["data-item"],SH=["data-item"],_H={key:1,class:"sd-button-label"},AH=["data-item","aria-label"],IH=["innerHTML"],EH={key:2},xH=["onKeydown","id"],TH=["placeholder","onKeydown","id","data-item"],RH=["data-item","innerHTML"],MH={"aria-live":"polite",class:"sd-visually-hidden"},LH={__name:"ToolbarButton",props:{iconColor:{type:String,default:null},active:{type:Boolean,default:!1},isNarrow:{type:Boolean,default:!1},isWide:{type:Boolean,default:!1},toolbarItem:{type:Object,required:!0},defaultLabel:{type:String,default:null},isOverflowItem:{type:Boolean,default:!1},allowEnterPropagation:{type:Boolean,default:!1}},emits:["buttonClick","textSubmit","mainClick"],setup(e,{emit:t}){const n=t,{proxy:r}=yr(),o=e,{name:i,active:s,icon:a,label:l,hideLabel:u,iconColor:d,hasCaret:f,splitButton:p,disabled:g,expand:m,inlineTextInputVisible:v,hasInlineTextInput:C,minWidth:w,style:S,attributes:b}=o.toolbarItem,k=_e(()=>!!p?.value&&!!f?.value),x=_e(()=>i?.value??""),M=te(""),z=te(null),{isHighContrastMode:G}=Hi();jt(()=>l?.value,Pe=>{document.activeElement!==z.value&&(M.value=Pe==null?"":String(Pe))},{immediate:!0});const F=()=>{C&&Ct(()=>{z.value?.focus(),z.value?.select()}),n("buttonClick")},L=Pe=>{g?.value||(Pe?.stopPropagation(),n("mainClick"))},$=()=>{k.value||F()},T=Pe=>{if(k.value){L(Pe);return}F()},H=Pe=>{Pe.preventDefault(),o.allowEnterPropagation||Pe.stopPropagation(),T(Pe)},R=Pe=>{const Ve=o.toolbarItem?.nestedOptions?.value??[],nt=Pe.trim();if(!nt)return"";const ct=Ve.find(ft=>typeof ft?.label=="string"&&ft.label.toLowerCase()===nt.toLowerCase());return ct?.label?ct.label:Ve.find(ft=>typeof ft?.label=="string"&&ft.label.toLowerCase().startsWith(nt.toLowerCase()))?.label??nt},U=()=>{const Pe=String(M.value??"").trim();let Ve=Pe;if(x.value==="fontSize"){const nt=Number.parseFloat(Pe);Ve=Pe.match(/^\d+(\.5)?$/)?Pe:Number.isFinite(nt)?Math.floor(nt).toString():""}else x.value==="fontFamily"&&(Ve=R(Pe));return Ve?(n("textSubmit",Ve),M.value=Ve,!0):!1},W=Pe=>{const Ve=Pe?.currentTarget;Ve instanceof HTMLInputElement&&(Ve.focus({preventScroll:!0}),Ve.select())},ee=Pe=>{requestAnimationFrame(()=>{const Ve=document.getElementById(`inlineTextInput-${Pe}`);Ve instanceof HTMLInputElement&&(Ve.focus({preventScroll:!0}),Ve.select())})},J=()=>{const Pe=document.querySelector('[role="textbox"][aria-label*="SuperDoc body"], .ProseMirror');return Pe instanceof HTMLElement?(Pe.focus({preventScroll:!0}),!0):!1},Z=()=>{const Pe=r?.$toolbar?.pendingSelectionCapture,Ve=()=>{Pe&&typeof r?.$toolbar?.ui?.selection?.restore=="function"&&r.$toolbar.ui.selection.restore(Pe)};if(J()){Ve();return}typeof r?.$toolbar?.superdoc?.focus=="function"&&(r.$toolbar.superdoc.focus(),Ve())},Me=()=>{U()&&Z()},fe=Pe=>{if(U(),Pe.shiftKey){x.value==="fontSize"&&(Pe.preventDefault(),Ct(()=>ee("fontFamily")));return}if(Pe.preventDefault(),x.value==="fontFamily"){Ct(()=>ee("fontSize"));return}x.value==="fontSize"&&Ct(Z)},ye=_e(()=>S.value?S.value:{minWidth:o.minWidth}),ve=_e(()=>m?.value?dr.dropdownCaretUp:dr.dropdownCaretDown);return(Pe,Ve)=>(pe(),Ce("div",{class:Zt(["sd-toolbar-item",et(b).className]),style:An(ye.value),role:e.isOverflowItem?"menuitem":"button","aria-label":et(b).ariaLabel,"aria-disabled":et(g)?"true":void 0,"data-sd-part":"toolbar-item",onClick:$,onKeydown:Ve[9]||(Ve[9]=Ko(nt=>H(nt),["enter"])),tabindex:"0"},[ce("div",{class:Zt(["sd-toolbar-button",{"sd-active":et(s),"sd-disabled":et(g),narrow:e.isNarrow,wide:e.isWide,split:k.value,"has-inline-text-input":et(C),"high-contrast":et(G)}]),"data-item":`btn-${et(i)||""}`},[k.value?(pe(),Ce("div",{key:0,class:"sd-toolbar-button__main","data-item":`btn-${et(i)||""}-main`,onClick:Ve[0]||(Ve[0]=nt=>L(nt))},[et(a)?(pe(),hn(AE,{key:0,color:et(d),class:"sd-toolbar-icon",icon:et(a),name:et(i)},null,8,["color","icon","name"])):ut("",!0),et(l)&&!et(u)&&!et(v)?(pe(),Ce("div",_H,Et(et(l)),1)):ut("",!0)],8,SH)):ut("",!0),k.value?(pe(),Ce("div",{key:1,class:"sd-toolbar-button__caret","data-item":`btn-${et(i)||""}-caret`,"aria-label":`${et(b).ariaLabel} options`,role:"button"},[ce("div",{class:"sd-dropdown-caret",innerHTML:ve.value,style:An({opacity:et(g)?.6:1})},null,12,IH)],8,AH)):(pe(),Ce(Bt,{key:2},[et(a)?(pe(),hn(AE,{key:0,color:et(d),class:"sd-toolbar-icon",icon:et(a),name:et(i)},null,8,["color","icon","name"])):ut("",!0),et(l)&&!et(u)&&(!et(v)||x.value==="fontFamily")?(pe(),Ce("div",{key:1,class:Zt(["sd-button-label",{"sd-visually-hidden":et(v)&&x.value==="fontFamily"}])},Et(et(l)),3)):ut("",!0),et(v)?(pe(),Ce("span",EH,[et(i)==="fontSize"?ki((pe(),Ce("input",{key:0,"onUpdate:modelValue":Ve[1]||(Ve[1]=nt=>M.value=nt),onKeydown:[Ko(tn(Me,["stop","prevent"]),["enter"]),Ve[2]||(Ve[2]=Ko(nt=>fe(nt),["tab"]))],onClick:Ve[3]||(Ve[3]=tn(nt=>W(nt),["stop"])),onFocus:Ve[4]||(Ve[4]=nt=>W(nt)),type:"text",class:Zt(["button-text-input button-text-input--font-size",{"high-contrast":et(G)}]),id:"inlineTextInput-"+et(i),autocomplete:"off",ref_key:"inlineInput",ref:z},null,42,xH)),[[Ii,M.value]]):ki((pe(),Ce("input",{key:1,"onUpdate:modelValue":Ve[5]||(Ve[5]=nt=>M.value=nt),placeholder:et(l),onKeydown:[Ko(tn(Me,["stop","prevent"]),["enter"]),Ve[6]||(Ve[6]=Ko(nt=>fe(nt),["tab"]))],onClick:Ve[7]||(Ve[7]=tn(nt=>W(nt),["stop"])),onFocus:Ve[8]||(Ve[8]=nt=>W(nt)),type:"text",class:Zt(["button-text-input",{"button-text-input--font-family":x.value==="fontFamily","high-contrast":et(G)}]),id:"inlineTextInput-"+et(i),"data-item":x.value==="fontFamily"?`btn-${et(i)}-input`:void 0,autocomplete:"off",ref_key:"inlineInput",ref:z},null,42,TH)),[[Ii,M.value]])])):ut("",!0),et(f)?(pe(),Ce("div",{key:3,class:"sd-dropdown-caret","data-item":`btn-${et(i)||""}-toggle`,innerHTML:ve.value,style:An({opacity:et(g)?.6:1})},null,12,RH)):ut("",!0)],64)),ce("div",MH,Et(`${et(b).ariaLabel} ${et(s)?"selected":"unset"}`),1)],10,kH)],46,CH))}},D1=mn(LH,[["__scopeId","data-v-96796456"]]);Ft(),yn();var PH={class:"toolbar-separator",role:"separator","aria-label":"Toolbar separator"},DH={__name:"ToolbarSeparator",props:{active:{type:Boolean,default:!1}},emits:["command"],setup(e,{emit:t}){const{isHighContrastMode:n}=Hi(),r=()=>n.value?"#000":"var(--sd-ui-border, #dbdbdb)";return(o,i)=>(pe(),Ce("div",PH,[ce("div",{class:"separator-inner",style:An({backgroundColor:r()})},null,4)]))}},OH=mn(DH,[["__scopeId","data-v-cb82253a"]]);Ft(),yn();var FH={class:"toolbar-dropdown"},NH=["onClick"],BH={key:0,class:"toolbar-dropdown-option__icon"},zH={class:"toolbar-dropdown-option__label"},bg='button, [href], input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])',jH={__name:"ToolbarDropdown",props:{options:{type:Array,default:()=>[]},show:{type:Boolean,required:!0},placement:{type:String,default:"bottom-start"},disabled:{type:Boolean,default:!1},contentStyle:{type:Object,default:()=>({})},menuProps:{type:Function,default:null},nodeProps:{type:Function,default:null},closeOnEscape:{type:Boolean,default:!0},hasOpenChild:{type:Boolean,default:!1}},emits:["update:show","select"],setup(e,{expose:t,emit:n}){const r=e,o=n,i=Mw(),s=te(null),a=te(null),l=te({top:"0px",left:"0px",maxHeight:"none"}),u=te([]),d=te(-1),f=_e(()=>!!r.show),p=te(document.fullscreenElement),g=_e(()=>f.value&&p.value?p.value:document.body),m=_e(()=>r.options.some(oe=>oe?.type==="render")),v=_e(()=>!!i.menu),C=_e(()=>typeof r.menuProps!="function"?{}:r.menuProps()||{}),w=_e(()=>{const{class:oe,style:we,...Q}=C.value;return Q}),S=_e(()=>["toolbar-dropdown-menu",C.value.class,{"toolbar-dropdown-menu--render-only":v.value||r.options.length>0&&r.options.every(oe=>oe&&oe.type==="render")}]),b=_e(()=>{const oe=C.value.style||{};return{...r.contentStyle,...oe}}),k=_e(()=>({...b.value,position:"fixed",top:l.value.top,left:l.value.left,maxHeight:l.value.maxHeight,zIndex:2e3})),x=oe=>{o("update:show",oe)},M=()=>{f.value&&x(!1)},z=()=>{if(!s.value)return;const oe=s.value.getBoundingClientRect(),we=a.value,Q=we?.offsetWidth??0,I=we?.scrollHeight??we?.offsetHeight??0,re=window.innerWidth||document.documentElement.clientWidth||0,j=window.innerHeight||document.documentElement.clientHeight||0,X=8,K=4,ae=oe.bottom+K,ke=oe.top-K,P=Math.max(0,j-ae-X),N=Math.max(0,ke-X),me=P<I&&N>P,Se=me?N:P,Re=me?Math.max(X,ke-(I?Math.min(I,Se):Se)):ae;let ze=oe.left;r.placement==="bottom-end"&&(ze=oe.right-Q);const Ke=Math.max(X,re-Q-X);ze=Math.min(Math.max(X,ze),Ke),l.value={top:`${Re}px`,left:`${ze}px`,maxHeight:`${Se}px`}},G=async()=>{p.value=document.fullscreenElement,f.value&&(await Ct(),z())},F=()=>{r.disabled||x(!f.value)},L=oe=>typeof r.nodeProps!="function"?{}:r.nodeProps(oe)||{},$=oe=>{oe?.disabled||oe?.type!=="render"&&(o("select",oe?.key,oe),M())},T=oe=>oe?.type==="render",H=oe=>!oe?.disabled&&oe?.type!=="render",R=oe=>typeof oe?.icon=="function"||!!oe?.icon,U=oe=>typeof oe?.icon=="function"?oe.icon(oe):oe?.icon||null,W=oe=>oe?typeof oe=="string"?oe.split(/\s+/).includes("sd-selected"):Array.isArray(oe)?oe.some(W):typeof oe=="object"?!!oe["sd-selected"]:!1:!1,ee=oe=>W(oe?.props?.class)||W(oe?.class),J=()=>r.options.map((oe,we)=>H(oe)?we:-1).filter(oe=>oe>=0),Z=()=>{const oe=r.options.findIndex(we=>H(we)&&ee(we));return oe>=0?oe:J()[0]??-1},Me=(oe,we)=>{if(!oe){delete u.value[we];return}u.value[we]=oe},fe=()=>{u.value.forEach((we,Q)=>{we&&we.setAttribute("tabindex",Q===d.value?"0":"-1")});const oe=u.value[d.value];oe&&typeof oe.focus=="function"&&(oe.focus(),oe.scrollIntoView?.({block:"nearest",inline:"nearest"}))},ye=oe=>{const we=J();if(!we.length){d.value=-1;return}const Q=we.indexOf(d.value);if(Q<0){d.value=oe>0?we[0]:we[we.length-1];return}const I=(Q+oe+we.length)%we.length;d.value=we[I]},ve=()=>{let oe=r.options[d.value];if(!H(oe)){const we=J()[0];oe=we===void 0?null:r.options[we]}oe&&$(oe)},Pe=vl({name:"ToolbarDropdownRenderOption",props:{option:{type:Object,required:!0}},setup(oe){return()=>typeof oe.option.render!="function"?null:oe.option.render()}}),Ve=vl({name:"ToolbarDropdownOptionIcon",props:{option:{type:Object,required:!0}},setup(oe){return()=>{const we=U(oe.option);return typeof we=="string"?Dr("span",{innerHTML:we}):we}}}),nt=oe=>{if(!f.value)return;const we=oe.target;if(!(we instanceof Element))return;const Q=s.value?.contains(we),I=a.value?.contains(we);Q||I||r.hasOpenChild&&we.closest('[data-sd-part="dropdown-menu"]')||M()},ct=te(null),ft=()=>{const oe=s.value,we=document.activeElement;if(oe&&we instanceof HTMLElement&&oe.contains(we)){ct.value=we;return}ct.value=oe?.matches?.(bg)?oe:oe?.querySelector(bg)},It=()=>{const oe=ct.value;if(oe instanceof HTMLElement&&document.contains(oe)){oe.focus();return}const we=s.value;if(!we)return;const Q=we.matches?.(bg)?we:we.querySelector(bg);if(Q instanceof HTMLElement){Q.focus();return}we.setAttribute("tabindex","-1"),we.focus()};t({focusTrigger:It});const Le=oe=>{if(!f.value)return;const{key:we}=oe;if(["Escape","ArrowDown","ArrowUp","Enter"].includes(we)){if(we==="Escape"){if(!r.closeOnEscape)return;oe.preventDefault(),M(),Ct(()=>{requestAnimationFrame(It)});return}if(!(m.value||v.value)){if(oe.preventDefault(),we==="ArrowDown"){ye(1),fe();return}if(we==="ArrowUp"){ye(-1),fe();return}we==="Enter"&&ve()}}};return jt(f,async oe=>{if(!oe){d.value=-1,u.value=[];return}ft(),await Ct(),z(),!(m.value||v.value)&&(d.value=Z(),await Ct(),fe())},{immediate:!0}),jt(f,oe=>{oe?(document.addEventListener("pointerdown",nt,!0),document.addEventListener("keydown",Le,!0),window.addEventListener("resize",z),window.addEventListener("scroll",z,!0)):(document.removeEventListener("pointerdown",nt,!0),document.removeEventListener("keydown",Le,!0),window.removeEventListener("resize",z),window.removeEventListener("scroll",z,!0))},{immediate:!0}),zn(()=>{document.addEventListener("fullscreenchange",G)}),ur(()=>{document.removeEventListener("fullscreenchange",G),document.removeEventListener("pointerdown",nt,!0),document.removeEventListener("keydown",Le,!0),window.removeEventListener("resize",z),window.removeEventListener("scroll",z,!0)}),(oe,we)=>(pe(),Ce("div",FH,[ce("div",{ref_key:"triggerRef",ref:s,class:"toolbar-dropdown-trigger","data-sd-part":"dropdown-trigger",onClick:F},[Cu(oe.$slots,"trigger",{},void 0,!0)],512),(pe(),hn(wl,{to:g.value},[en(Up,{name:"fade-in-scale-up-transition"},{default:ao(()=>[f.value?(pe(),Ce("div",$s({key:0,ref_key:"menuRef",ref:a,"data-sd-part":"dropdown-menu",class:S.value,style:k.value},w.value),[v.value?Cu(oe.$slots,"menu",{key:0},void 0,!0):ut("",!0),(pe(!0),Ce(Bt,null,Rn(v.value?[]:e.options,(Q,I)=>(pe(),Ce("div",$s({key:Q.key,ref_for:!0,ref:re=>Me(re,I),class:["toolbar-dropdown-option",[Q.class,Q.props?.class,{"sd-disabled":Q.disabled,"sd-render":T(Q)}]],tabindex:"-1",onClick:re=>$(Q)},{ref_for:!0},{...Q.props,...L(Q)}),[T(Q)?(pe(),hn(et(Pe),{key:0,option:Q},null,8,["option"])):(pe(),Ce(Bt,{key:1},[R(Q)?(pe(),Ce("span",BH,[en(et(Ve),{option:Q},null,8,["option"])])):ut("",!0),ce("span",zH,Et(Q.label),1)],64))],16,NH))),128))],16)):ut("",!0)]),_:3})],8,["to"]))]))}},IE=mn(jH,[["__scopeId","data-v-fa3f6b69"]]),EE=e=>{const t=e?.target;t instanceof Element&&(t.closest('input, textarea, [contenteditable="true"]')||e.preventDefault())},Kl=(e,t=null)=>{if(typeof t?.focus=="function"){t.focus();return}const n=e?.superdoc?.focus??e?.activeEditor?.focus;if(typeof n=="function"){n.call(e?.superdoc??e?.activeEditor,{preventScroll:!0});return}const r=document.querySelector('[role="textbox"][aria-label*="SuperDoc body"], .ProseMirror');r instanceof HTMLElement&&r.focus({preventScroll:!0})};Ft(),yn();var VH={__name:"OverflowMenu",props:{toolbarItem:{type:Object,required:!0},overflowItems:{type:Array,required:!0},uiFontFamily:{type:String,default:"Arial, Helvetica, sans-serif"}},emits:["buttonClick","close","command"],setup(e,{emit:t}){const n=t,r=e,o=te(null),i=_e(()=>r.toolbarItem.expand.value),s=_e(()=>r.overflowItems.some(d=>d.type==="dropdown"&&et(d.expand))),a=_e(()=>({...r.toolbarItem,active:i.value})),l=d=>{if(d!==i.value){if(d){n("buttonClick",r.toolbarItem);return}n("close")}},u=({item:d,argument:f,option:p})=>{d.name.value==="watermark"&&(n("close"),o.value?.focusTrigger()),n("command",{item:d,argument:f,option:p})};return(d,f)=>(pe(),hn(IE,{ref_key:"dropdown",ref:o,class:"overflow-menu","close-on-escape":!s.value,"has-open-child":s.value,"content-style":{width:"200px",padding:"4px 8px",fontFamily:r.uiFontFamily},options:[],placement:"bottom-end",show:i.value,"onUpdate:show":l,"menu-props":()=>({role:"group",class:["overflow-menu_items","sd-toolbar-overflow-menu"]})},{trigger:ao(()=>[en(D1,{"toolbar-item":a.value,"allow-enter-propagation":!0},null,8,["toolbar-item"])]),menu:ao(()=>[en(kg,{class:"superdoc-toolbar-overflow","toolbar-items":e.overflowItems,"ui-font-family":r.uiFontFamily,"from-overflow":"",onMousedown:et(EE),onCommand:u},null,8,["toolbar-items","ui-font-family","onMousedown"])]),_:1},8,["close-on-escape","has-open-child","content-style","show"]))}},UH=mn(VH,[["__scopeId","data-v-1227fcf9"]]),xE=e=>String(e??"").trim().toLowerCase(),wg=(e,t)=>{const n=xE(e);if(!n)return-1;for(let r=0;r<t.length;r+=1)if(xE(t[r]).startsWith(n))return r;return-1},$H=(e,t,{autocomplete:n=!0}={})=>{const r=String(e??""),o=wg(r,t),i=o>=0?String(t[o]??""):"";return n&&o>=0&&i.length>r.length?{matchIndex:o,display:i,selectionStart:r.length,selectionEnd:i.length}:{matchIndex:o,display:r,selectionStart:r.length,selectionEnd:r.length}},HH=e=>{let t=String(e??"").trim();for(;t.length>=2&&(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"));)t=t.slice(1,-1).trim();return t},GH=e=>e<=31||e===127,WH=e=>e===32||e===160||e===65279,KH=e=>Array.from(String(e)).filter(t=>!GH(t.charCodeAt(0))).join(""),qH=e=>{let t="",n=!1;for(const r of String(e)){if(WH(r.charCodeAt(0))){n=t.length>0;continue}n&&(t+=" "),n=!1,t+=r}return t},YH=e=>{const t=String(e??"").split(",")[0]??"",n=KH(t);return qH(HH(n)).trim()},XH=1,ZH=1638,QH=e=>{const t=String(e??"").replace(/[^0-9.-]/g,""),n=Number.parseFloat(t);if(!Number.isFinite(n))return"";const r=Math.round(n*2)/2;return r<XH?"":String(Math.min(r,ZH))};Ft(),yn();var JH=["data-item"],eG=["id","value","disabled","aria-label","aria-expanded","aria-controls","aria-activedescendant","data-item"],tG=["data-item","aria-label","disabled"],nG=["innerHTML"],rG=["id","aria-label"],oG=["id","aria-selected","aria-label","onMousedown","onMouseenter"],iG={class:"toolbar-dropdown-option__label"},sG={class:"sd-button-label sd-font-combobox__legacy-label","aria-hidden":"true"},aG={__name:"ToolbarComboBox",props:{item:{type:Object,required:!0},uiFontFamily:{type:String,default:"Arial, Helvetica, sans-serif"},showPreview:{type:Boolean,default:!1},normalizeValue:{type:Function,default:e=>String(e??"").trim()}},emits:["command","item-clicked","tab-out","editor-handoff"],setup(e,{emit:t}){const n=e,r=t,{isHighContrastMode:o}=Hi(),i=te(null),s=te(null),a=te(null),l=te([]),u=te(!1),d=te(!1),f=te(-1),p=te(""),g=te(""),m=te(!1),v=te({top:"0px",left:"0px",minWidth:"0px",maxHeight:"none"}),C=_e(()=>n.item.nestedOptions?.value??[]),w=_e(()=>C.value.map(P=>String(P?.label??""))),S=_e(()=>String(n.item.label?.value??"")),b=_e(()=>!!n.item.disabled?.value),k=_e(()=>String(n.item.name?.value??"")),x=_e(()=>n.item.attributes?.value?.ariaLabel??"Font family"),M=_e(()=>u.value?g.value:S.value),z=_e(()=>`sd-${k.value||"combobox"}-listbox-${n.item.id?.value??"default"}`),G=P=>`${z.value}-option-${P}`,F=_e(()=>d.value&&f.value>=0?G(f.value):void 0),L=_e(()=>d.value?dr.dropdownCaretUp:dr.dropdownCaretDown),$=P=>{const N=String(P??"").trim().toLowerCase();return C.value.find(me=>String(me?.label??"").trim().toLowerCase()===N)?.props?.style?.fontFamily||P||n.uiFontFamily},T=_e(()=>n.showPreview?{fontFamily:$(u.value?g.value:S.value)}:{fontFamily:n.uiFontFamily}),H=()=>{const P=n.item.selectedValue?.value;if(P){const N=C.value.findIndex(me=>me?.key===P);if(N>=0)return N}return w.value.findIndex(N=>N.toLowerCase()===S.value.toLowerCase())},R=(P,N)=>{const me=i.value;if(!(!me||typeof me.setSelectionRange!="function"))try{me.setSelectionRange(P,N)}catch{}},U=()=>{l.value[f.value]?.scrollIntoView?.({block:"nearest",inline:"nearest"})},W=()=>{l.value[f.value]?.focus?.()},ee=()=>{const P=s.value;if(!P)return;const N=P.getBoundingClientRect(),me=a.value,Se=me?.scrollHeight??me?.offsetHeight??0,Re=window.innerHeight||document.documentElement.clientHeight||0,ze=window.innerWidth||document.documentElement.clientWidth||0,Ke=8,ot=4,mt=N.bottom+ot,Ot=N.top-ot,Mt=Math.max(0,Re-mt-Ke),Kt=Math.max(0,Ot-Ke),$e=Mt<Se&&Kt>Mt,Qt=$e?Kt:Mt,Hn=$e?Math.max(Ke,Ot-(Se?Math.min(Se,Qt):Qt)):mt,qt=Math.min(Math.max(Ke,N.left),Math.max(Ke,ze-N.width-Ke));v.value={top:`${Hn}px`,left:`${qt}px`,minWidth:`${N.width}px`,maxHeight:`${Qt}px`}},J=_e(()=>({position:"fixed",top:v.value.top,left:v.value.left,minWidth:v.value.minWidth,maxHeight:v.value.maxHeight,fontFamily:n.uiFontFamily,zIndex:2e3})),Z=P=>{n.item.expand&&typeof n.item.expand=="object"&&"value"in n.item.expand&&(n.item.expand.value=P)},Me=(P,{focusInput:N=!1,focusOption:me=!1}={})=>{if(b.value||!C.value.length){Z(!1);return}d.value=!0,Z(!0),f.value=P??-1,N&&(u.value=!0,g.value=S.value,i.value?.focus()),Ct(()=>{ee(),U(),me&&W()})},fe=({syncItem:P=!0}={})=>{d.value=!1,f.value=-1,P&&Z(!1)},ye=()=>{fe(),u.value=!1,p.value="",g.value=S.value},ve=()=>{b.value||(d.value||r("item-clicked"),u.value=!0,p.value="",g.value=S.value,Ct(()=>R(0,g.value.length)))},Pe=P=>{if(b.value)return;const N=document.activeElement===i.value;if(r("item-clicked"),u.value=!0,N||(p.value="",g.value=S.value,P.preventDefault(),i.value?.focus({preventScroll:!0}),R(0,S.value.length)),!d.value){const me=H();Me(me>=0?me:0)}},Ve=P=>{const N=P.relatedTarget;N instanceof Node&&s.value?.contains(N)||N instanceof Node&&a.value?.contains(N)||ye()},nt=P=>{if(m.value)return;const N=P.target,me=N.value,Se=typeof N.selectionStart=="number"?N.selectionStart:me.length,Re=typeof N.selectionEnd=="number"?N.selectionEnd:Se,ze=typeof P.inputType=="string"&&P.inputType.startsWith("delete"),Ke=Se===me.length&&Re===me.length;p.value=me;const ot=$H(me,w.value,{autocomplete:!ze&&Ke});g.value=ot.display,N.value=ot.display,ot.display===me&&!Ke?R(Se,Re):R(ot.selectionStart,ot.selectionEnd),d.value&&(f.value=ot.matchIndex,Ct(U))},ct=P=>{m.value=!1,nt(P)},ft=P=>{if(!C.value.length)return;const N=C.value.length,me=f.value<0?P>0?-1:0:f.value;f.value=(me+P+N)%N,Ct(U)},It=(P,N)=>{r("item-clicked"),r("command",{item:n.item,argument:P,option:N}),N&&(n.item.selectedValue.value=N.key)},Le=P=>{P&&(It(P.value??P.label,P),u.value=!1,p.value="",g.value=P.label,fe())},oe=()=>{if(d.value&&f.value>=0)return Le(C.value[f.value]),!0;const P=wg(p.value,w.value);if(P>=0)return Le(C.value[P]),!0;const N=n.normalizeValue(p.value);return N?(It(N,null),u.value=!1,p.value="",g.value=N,fe(),!0):!1},we=P=>{if(!(P.isComposing||m.value||P.keyCode===229)&&!(P.ctrlKey||P.metaKey||P.altKey))switch(P.key){case"ArrowDown":if(P.preventDefault(),d.value)W();else{const N=wg(p.value,w.value),me=N>=0?N:H();Me(me>=0?me:0,{focusOption:!0})}break;case"ArrowUp":if(P.preventDefault(),d.value)W();else{const N=wg(p.value,w.value),me=N>=0?N:H();Me(me>=0?me:C.value.length-1,{focusOption:!0})}break;case"Enter":P.preventDefault(),oe()&&r("editor-handoff"),i.value?.blur();break;case"Tab":P.preventDefault(),oe(),fe(),i.value?.blur(),r("tab-out",P);break;case"Escape":P.preventDefault(),ye(),Ct(()=>i.value?.focus());break;default:break}},Q=P=>{if(P.preventDefault(),!b.value)if(r("item-clicked"),d.value)fe(),i.value?.focus();else{const N=H();Me(N>=0?N:0,{focusOption:!0})}},I=(P,N)=>{P.preventDefault(),Le(N),r("editor-handoff"),i.value?.blur()},re=P=>{f.value=P},j=P=>{if(!(P.ctrlKey||P.metaKey||P.altKey))switch(P.key){case"ArrowDown":P.preventDefault(),ft(1),W();break;case"ArrowUp":P.preventDefault(),ft(-1),W();break;case"Enter":P.preventDefault(),f.value>=0&&(Le(C.value[f.value]),r("editor-handoff"));break;case"Escape":P.preventDefault(),ye(),Ct(()=>i.value?.focus());break;case"Tab":P.preventDefault(),f.value>=0?Le(C.value[f.value]):fe(),r("tab-out",{shiftKey:P.shiftKey,target:i.value});break;default:break}},X=P=>{if(!d.value)return;const N=P.target;N instanceof Element&&(s.value?.contains(N)||a.value?.contains(N)||ye())};jt(d,P=>{P?(document.addEventListener("pointerdown",X,!0),window.addEventListener("resize",ee),window.addEventListener("scroll",ee,!0)):(document.removeEventListener("pointerdown",X,!0),window.removeEventListener("resize",ee),window.removeEventListener("scroll",ee,!0),l.value=[])},{immediate:!0}),ur(()=>{document.removeEventListener("pointerdown",X,!0),window.removeEventListener("resize",ee),window.removeEventListener("scroll",ee,!0)});const K=(P,N)=>{if(!P){delete l.value[N];return}l.value[N]=P},ae=P=>P===f.value,ke=P=>P?.key&&P.key===n.item.selectedValue?.value;return jt(S,P=>{u.value||(g.value=P)}),jt(()=>!!n.item.expand?.value,P=>{if(P&&!d.value){const N=H();Me(N>=0?N:0,{focusInput:!0});return}!P&&d.value&&fe({syncItem:!1})}),(P,N)=>(pe(),Ce("div",{ref_key:"rootRef",ref:s,class:Zt(["sd-font-combobox sd-toolbar-split-field",{"sd-disabled":b.value,"high-contrast":et(o)}]),style:An(n.item.style?.value),"data-item":`btn-${k.value}`},[ce("span",{class:"sd-font-combobox__field sd-toolbar-split-field__main",onMousedown:Pe},[ce("input",{ref_key:"inputRef",ref:i,id:`inlineTextInput-${k.value}`,class:"button-text-input sd-font-combobox__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:"false",value:M.value,style:An(T.value),disabled:b.value,"aria-label":x.value,"aria-expanded":d.value?"true":"false","aria-controls":z.value,"aria-activedescendant":F.value,"aria-haspopup":"listbox","aria-autocomplete":"both","data-item":`btn-${k.value}-input`,onFocus:ve,onBlur:Ve,onInput:nt,onKeydown:we,onCompositionstart:N[0]||(N[0]=me=>m.value=!0),onCompositionend:ct},null,44,eG)],32),ce("button",{type:"button",class:"sd-font-combobox__caret sd-toolbar-split-field__caret","data-item":`btn-${k.value}-toggle`,tabindex:"-1","aria-label":`${x.value} options`,disabled:b.value,onMousedown:Q},[ce("span",{class:"sd-dropdown-caret",innerHTML:L.value},null,8,nG)],40,tG),(pe(),hn(wl,{to:"body"},[d.value?(pe(),Ce("div",{key:0,ref_key:"popupRef",ref:a,role:"listbox","data-sd-part":"dropdown-menu",id:z.value,"aria-label":x.value,class:Zt(["sd-font-combobox__listbox",{"high-contrast":et(o)}]),style:An(J.value)},[(pe(!0),Ce(Bt,null,Rn(C.value,(me,Se)=>(pe(),Ce("div",$s({key:me.key,ref_for:!0,ref:Re=>K(Re,Se),id:G(Se),role:"option",tabindex:"-1",class:["toolbar-dropdown-option sd-font-combobox__option",{"sd-active":ae(Se),"sd-selected":ke(me)}],"aria-selected":ke(me)?"true":"false","aria-label":`${x.value} - ${me.label}`},{ref_for:!0},me.props,{onMousedown:Re=>I(Re,me),onMouseenter:Re=>re(Se),onKeydown:j}),[ce("span",iG,Et(me.label),1)],16,oG))),128))],14,rG)):ut("",!0)])),ce("span",sG,Et(S.value),1)],14,JH))}},TE=mn(aG,[["__scopeId","data-v-e288ef9f"]]);Ft();var lG={__name:"FontFamilyCombobox",props:{item:{type:Object,required:!0},uiFontFamily:{type:String,default:"Arial, Helvetica, sans-serif"}},emits:["command","item-clicked","tab-out","editor-handoff"],setup(e,{emit:t}){const n=e,r=t;return(o,i)=>(pe(),hn(TE,{item:n.item,"ui-font-family":n.uiFontFamily,"show-preview":!0,"normalize-value":et(YH),onCommand:i[0]||(i[0]=s=>r("command",s)),onItemClicked:i[1]||(i[1]=s=>r("item-clicked")),onTabOut:i[2]||(i[2]=s=>r("tab-out",s)),onEditorHandoff:i[3]||(i[3]=s=>r("editor-handoff"))},null,8,["item","ui-font-family","normalize-value"]))}};Ft();var cG={__name:"FontSizeCombobox",props:{item:{type:Object,required:!0},uiFontFamily:{type:String,default:"Arial, Helvetica, sans-serif"}},emits:["command","item-clicked","tab-out","editor-handoff"],setup(e,{emit:t}){const n=e,r=t;return(o,i)=>(pe(),hn(TE,{item:n.item,"ui-font-family":n.uiFontFamily,"show-preview":!1,"normalize-value":et(QH),onCommand:i[0]||(i[0]=s=>r("command",s)),onItemClicked:i[1]||(i[1]=s=>r("item-clicked")),onTabOut:i[2]||(i[2]=s=>r("tab-out",s)),onEditorHandoff:i[3]||(i[3]=s=>r("editor-handoff"))},null,8,["item","ui-font-family","normalize-value"]))}};Ft(),yn();var uG=["data-placement"],dG=2500,fG=Object.assign({inheritAttrs:!1},{__name:"SdTooltip",props:{trigger:{type:String,default:"hover"},delay:{type:Number,default:100},duration:{type:Number,default:100},disabled:{type:Boolean,default:!1},contentStyle:{type:Object,default:()=>({})}},setup(e){const t=e,n=Lw(),r=te(!1),o=te(null),i=te(null),s=te({top:"0px",left:"0px"}),a=te("top");let l=null,u=null,d=null;const f=_e(()=>["sd-tooltip-content",n.class]),p=_e(()=>({...t.contentStyle,...n.style||{},position:"fixed",top:s.value.top,left:s.value.left,zIndex:2100})),g=()=>{l&&(window.clearTimeout(l),l=null)},m=()=>{u&&(window.clearTimeout(u),u=null)},v=()=>{d&&(window.clearTimeout(d),d=null)},C=()=>{v(),d=window.setTimeout(()=>{d=null,k()},dG)},w=(T,H)=>{const R=window.getComputedStyle(T),U=parseFloat(R[H]);return Number.isFinite(U)?R.boxSizing==="border-box"?U:(H==="width"?["paddingLeft","paddingRight","borderLeftWidth","borderRightWidth"]:["paddingTop","paddingBottom","borderTopWidth","borderBottomWidth"]).reduce((W,ee)=>W+(parseFloat(R[ee])||0),U):H==="width"?T.offsetWidth:T.offsetHeight},S=()=>{if(!o.value||!i.value)return;const T=o.value.getBoundingClientRect(),H=w(i.value,"width"),R=w(i.value,"height"),U=window.innerWidth||document.documentElement.clientWidth||0,W=document.documentElement.clientHeight||window.innerHeight||0,ee=8,J=10;let Z=T.left+T.width/2-H/2;Z=Math.max(ee,Math.min(Z,U-H-ee));const Me=T.top-R-J,fe=T.bottom+J,ye=Me>=ee,ve=fe+R<=W-ee,Pe=T.top-J,Ve=W-T.bottom-J;ye?a.value="top":ve?a.value="bottom":a.value=Pe>=Ve?"top":"bottom";const nt=a.value==="top"?Me:fe,ct=Math.min(ee,Math.max(0,W-R)),ft=Math.max(ct,W-R-ee);s.value={top:`${Math.max(ct,Math.min(nt,ft))}px`,left:`${Z}px`}},b=async()=>{t.disabled||(g(),m(),!r.value&&(r.value=!0,C(),await Ct(),S()))},k=()=>{m(),g(),v(),r.value&&(r.value=!1)},x=()=>{if(g(),m(),!r.value){if(t.delay===0){b();return}u=window.setTimeout(()=>{u=null,b()},t.delay)}},M=()=>{if(m(),g(),!!r.value){if(t.duration===0){k();return}l=window.setTimeout(()=>{l=null,k()},t.duration)}},z=()=>{t.trigger==="hover"&&x()},G=()=>{t.trigger==="hover"&&M()},F=()=>{m(),g()},L=()=>{M()},$=T=>{T.key==="Escape"&&k()};return jt(()=>t.disabled,T=>{T&&k()}),jt(r,T=>{T?(window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),document.addEventListener("keydown",$,!0)):(window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0),document.removeEventListener("keydown",$,!0))}),ur(()=>{m(),g(),v(),window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0),document.removeEventListener("keydown",$,!0)}),(T,H)=>(pe(),Ce(Bt,null,[ce("span",{ref_key:"triggerRef",ref:o,class:"sd-tooltip-trigger",onMouseenter:z,onMouseleave:G,onFocusin:z,onFocusout:G},[Cu(T.$slots,"trigger",{},void 0,!0)],544),(pe(),hn(wl,{to:"body"},[en(Up,{name:"fade-in-scale-up-transition"},{default:ao(()=>[r.value&&!e.disabled?(pe(),Ce("div",{key:0,ref_key:"contentRef",ref:i,class:Zt(f.value),style:An(p.value),"data-placement":a.value,onMouseenter:F,onMouseleave:L},[H[0]||(H[0]=ce("span",{class:"sd-tooltip-arrow","aria-hidden":"true"},null,-1)),Cu(T.$slots,"default",{},void 0,!0)],46,uG)):ut("",!0)]),_:3})]))],64))}}),Cg=mn(fG,[["__scopeId","data-v-88d296cd"]]);Ft(),yn();var hG=["onKeydown","tabindex","data-item-id"],pG={key:0},mG={key:0},gG={key:0},vG={key:0},yG={key:0},bG={__name:"ButtonGroup",props:{toolbarItems:{type:Array,required:!0},overflowItems:{type:Array,default:()=>[]},uiFontFamily:{type:String,default:"Arial, Helvetica, sans-serif"},position:{type:String,default:"left"},fromOverflow:{type:Boolean,default:!1},compactSideGroups:{type:Boolean,default:!1}},emits:["command","item-clicked","dropdown-update-show"],setup(e,{emit:t}){const n=t,{proxy:r}=yr(),o=te([]),i=te(null),s=e,a=te(null),{isHighContrastMode:l}=Hi(),u=window.matchMedia("(max-width: 768px)").matches,d=_e(()=>s.position==="left"?{minWidth:s.compactSideGroups?"auto":"120px",justifyContent:"flex-start"}:s.position==="right"?{minWidth:s.compactSideGroups?"auto":"120px",justifyContent:"flex-end"}:{flexGrow:u?0:1,justifyContent:"center"}),f=Le=>Le.type==="button",p=Le=>Le.type==="dropdown",g=Le=>Le.type==="dropdown"&&Le.name?.value==="fontFamily",m=Le=>Le.type==="dropdown"&&Le.name?.value==="fontSize",v=Le=>Le.type==="separator",C=Le=>Le.type==="overflow",w=Le=>!!Le.nestedOptions?.value?.length,S=Le=>{if(!Le)return!1;const oe=Le.expand;return typeof oe=="object"&&oe!==null&&"value"in oe?!!oe.value:!!oe},b=(Le,oe)=>{Le?.expand&&(Le.expand.value=oe)},k=(Le,oe=void 0)=>{if(Le.disabled.value)return;if(C(Le)){const Q=!S(Le);Q&&z(),b(Le,Q),a.value=Q?Le:null,n("item-clicked");return}if(p(Le))return;a.value&&p(a.value)&&S(a.value)&&z(),n("item-clicked");const we=oe!==void 0?oe:Le.argument?.value;n("command",we===void 0?{item:Le}:{item:Le,argument:we})},x=(Le,oe)=>{Le.disabled.value||(a.value=null,n("command",{item:Le,argument:oe}))},M=Le=>{if(Le.disabled.value)return;z();const oe=Le.splitButtonCommand,we=Le.command,Q=oe||we;if(!Q)return;const I={...Le,command:Q};n("item-clicked"),n("command",{item:I})},z=()=>{const Le=r?.$toolbar?.toolbarItems||[],oe=r?.$toolbar?.overflowItems||[],we=[...Le,...oe];(we.length?we:s.toolbarItems).forEach(Q=>{const I=C(Q)&&!s.fromOverflow;(p(Q)||I)&&b(Q,!1)}),a.value=null},G=(Le,oe)=>{z();const we=Le.dropdownValueKey.value?oe[Le.dropdownValueKey.value]:oe.label;n("command",{item:Le,argument:we,option:oe}),Le.selectedValue.value=oe.key,Le.restoreEditorFocus&&Kl(r?.$toolbar)},F=Le=>{n("command",Le)},L=()=>{z(),n("item-clicked")},$=()=>{const Le=document.querySelector('[role="textbox"][aria-label*="SuperDoc body"], .ProseMirror');return Le instanceof HTMLElement?(Le.focus({preventScroll:!0}),!0):!1},T=()=>{const Le=r?.$toolbar?.pendingSelectionCapture,oe=()=>{Le&&typeof r?.$toolbar?.ui?.selection?.restore=="function"&&r.$toolbar.ui.selection.restore(Le)};if($()){oe();return}typeof r?.$toolbar?.superdoc?.focus=="function"&&(r.$toolbar.superdoc.focus(),oe())},H=Le=>!(Le instanceof HTMLElement)||Le.classList.contains("sd-disabled")?null:Le.querySelector("input:not([disabled]), textarea:not([disabled]), select:not([disabled])")||Le.querySelector('button:not([disabled]), [role="button"]:not(.sd-disabled), [tabindex]:not([tabindex="-1"])'),R=(Le,oe)=>{const we=Le?.target?.closest?.(".sd-toolbar-item-ctn");if(!(we instanceof HTMLElement))return!1;let Q=oe>0?we.nextElementSibling:we.previousElementSibling;for(;Q;){const I=H(Q);if(I instanceof HTMLElement)return we.setAttribute("tabindex","-1"),Q.setAttribute("tabindex","0"),I.focus(),!0;Q=oe>0?Q.nextElementSibling:Q.previousElementSibling}return!1},U=Le=>{z();const oe=Le?.shiftKey?-1:1;R(Le,oe)||T()},W=Le=>{if(z(),Le?.shiftKey){R(Le,-1)||T();return}T()},ee=()=>{T()},J=Le=>Le.nestedOptions?.value?.length?Le.nestedOptions.value.map(oe=>{const we=oe?.type!=="render"&&Le.selectedValue.value===oe.key;return{...oe,props:{...oe.props,class:we?"sd-selected":""}}}):[],Z=(Le,oe)=>({role:"menuitem","aria-label":`${oe.attributes.value.ariaLabel} - ${Le.label}`}),Me=Le=>{const oe=Le.target,we=Le.target.closest(".sd-toolbar-item-ctn").nextElementSibling;we&&(oe.setAttribute("tabindex","-1"),we.setAttribute("tabindex","0"),we.focus())},fe=Le=>{const oe=Le.target,we=Le.target.closest(".sd-toolbar-item-ctn").previousElementSibling;we&&(oe.setAttribute("tabindex","-1"),we.setAttribute("tabindex","0"),we.focus())},ye=Le=>{const oe=Le.target.closest(".button-group").nextElementSibling;if(oe)oe.setAttribute("tabindex","0"),oe.focus();else{const we=document.querySelector(".ProseMirror");we&&we.focus()}},ve=Le=>{const oe=Le.target.closest(".button-group").previousElementSibling;oe&&(oe.setAttribute("tabindex","0"),oe.focus())},Pe=Le=>{if(!Le.disabled.value){if(p(Le)){ct(!S(Le),Le);return}k(Le)}},Ve=(Le,oe)=>{const we=Le.target.nodeName==="INPUT"||Le.target.nodeName==="TEXTAREA",Q=oe.name.value==="fontSize"||oe.name.value==="fontFamily";if(!(we&&Q)&&["Enter"," ","Spacebar","Escape","ArrowRight","ArrowLeft","Tab"].includes(Le.key))switch(Le.preventDefault(),Le.key){case"Enter":case" ":case"Spacebar":Pe(oe);break;case"Escape":z();break;case"ArrowRight":z(),Me(Le);break;case"ArrowLeft":z(),fe(Le);break;case"Tab":Le.shiftKey?ve(Le):ye(Le);break;default:break}},nt=Le=>{const oe=o.value.find(we=>!we.classList.contains("sd-disabled"));oe&&(oe.setAttribute("tabindex","0"),oe.focus())},ct=(Le,oe)=>{if(n("item-clicked"),!Le){z(),n("dropdown-update-show",!1);return}z(),a.value=oe,b(oe,!0),n("dropdown-update-show",!0)},ft=Le=>{if(!a.value)return;const oe=Le.target;oe instanceof Element&&(oe.closest('[data-sd-part="dropdown-menu"]')||i.value?.contains(oe)||z())};return jt(()=>S(a.value),Le=>{Le?document.addEventListener("pointerdown",ft,!0):document.removeEventListener("pointerdown",ft,!0)},{immediate:!0}),ur(()=>{document.removeEventListener("pointerdown",ft,!0)}),(Le,oe)=>(pe(),Ce("div",{style:An(d.value),class:"button-group",role:"group",onFocus:nt,ref_key:"buttonGroupRef",ref:i},[(pe(!0),Ce(Bt,null,Rn(e.toolbarItems,(we,Q)=>(pe(),Ce("div",{key:we.id.value,class:Zt([{narrow:we.isNarrow.value,wide:we.isWide.value,"sd-disabled":we.disabled.value},"sd-toolbar-item-ctn"]),onKeydown:I=>Ve(I,we),ref_for:!0,ref_key:"toolbarItemRefs",ref:o,tabindex:Q===0?0:-1,"data-item-id":we.id.value},[v(we)?(pe(),hn(OH,{key:0,style:{width:"20px"}})):ut("",!0),g(we)&&w(we)?(pe(),hn(Cg,{key:1,trigger:"hover",disabled:!we.tooltip?.value,"content-style":{fontFamily:s.uiFontFamily}},{trigger:ao(()=>[en(lG,{item:we,"ui-font-family":s.uiFontFamily,class:"sd-toolbar-button sd-editor-toolbar-dropdown",onCommand:F,onItemClicked:L,onTabOut:oe[0]||(oe[0]=I=>U(I)),onEditorHandoff:ee},null,8,["item","ui-font-family"])]),default:ao(()=>[ce("div",null,[Si(Et(we.tooltip)+" ",1),we.disabled.value?(pe(),Ce("span",pG,"(disabled)")):ut("",!0)])]),_:2},1032,["disabled","content-style"])):m(we)&&w(we)?(pe(),hn(Cg,{key:2,trigger:"hover",disabled:!we.tooltip?.value,"content-style":{fontFamily:s.uiFontFamily}},{trigger:ao(()=>[en(cG,{item:we,"ui-font-family":s.uiFontFamily,class:"sd-toolbar-button sd-editor-toolbar-dropdown",onCommand:F,onItemClicked:L,onTabOut:oe[1]||(oe[1]=I=>W(I)),onEditorHandoff:ee},null,8,["item","ui-font-family"])]),default:ao(()=>[ce("div",null,[Si(Et(we.tooltip)+" ",1),we.disabled.value?(pe(),Ce("span",mG,"(disabled)")):ut("",!0)])]),_:2},1032,["disabled","content-style"])):p(we)&&we.nestedOptions?.value?.length?(pe(),hn(IE,{key:3,options:J(we),disabled:we.disabled.value,show:S(we),"content-style":{fontFamily:s.uiFontFamily},placement:"bottom-start",class:"sd-toolbar-button sd-editor-toolbar-dropdown",onSelect:(I,re)=>G(we,re),"onUpdate:show":I=>ct(I,we),style:An(we.dropdownStyles.value),"menu-props":()=>({role:"menu",style:{fontFamily:s.uiFontFamily},class:["sd-toolbar-dropdown-menu",{"high-contrast":et(l)}]}),"node-props":I=>Z(I,we)},{trigger:ao(()=>[en(Cg,{trigger:"hover",disabled:!we.tooltip?.value,"content-style":{fontFamily:s.uiFontFamily}},{trigger:ao(()=>[en(D1,{"toolbar-item":we,disabled:we.disabled.value,"allow-enter-propagation":!0,onTextSubmit:I=>x(we,I),onMainClick:I=>M(we)},null,8,["toolbar-item","disabled","onTextSubmit","onMainClick"])]),default:ao(()=>[ce("div",null,[Si(Et(we.tooltip)+" ",1),we.disabled.value?(pe(),Ce("span",gG,"(disabled)")):ut("",!0)])]),_:2},1032,["disabled","content-style"])]),_:2},1032,["options","disabled","show","content-style","onSelect","onUpdate:show","style","menu-props","node-props"])):f(we)?(pe(),hn(Cg,{key:4,trigger:"hover",class:"sd-editor-toolbar-tooltip","content-style":{fontFamily:s.uiFontFamily}},{trigger:ao(()=>[en(D1,{"toolbar-item":we,"is-overflow-item":e.fromOverflow,onTextSubmit:I=>x(we,I),onButtonClick:I=>k(we)},null,8,["toolbar-item","is-overflow-item","onTextSubmit","onButtonClick"])]),default:ao(()=>[we.tooltip?(pe(),Ce("div",vG,[Si(Et(we.tooltip)+" ",1),we.disabled.value?(pe(),Ce("span",yG,"(disabled)")):ut("",!0)])):ut("",!0)]),_:2},1032,["content-style"])):ut("",!0),C(we)&&e.overflowItems.length?(pe(),hn(UH,{key:5,"toolbar-item":we,"ui-font-family":s.uiFontFamily,onButtonClick:I=>k(we),"overflow-items":e.overflowItems,onClose:z,onCommand:oe[2]||(oe[2]=I=>n("command",I))},null,8,["toolbar-item","ui-font-family","onButtonClick","overflow-items"])):ut("",!0)],42,hG))),128))],36))}},kg=mn(bG,[["__scopeId","data-v-8d7a9de1"]]),wG=[["Arial","sans-serif"],["Arial Black","sans-serif"],["Arial Narrow","sans-serif"],["Baskerville Old Face","serif"],["Bookman Old Style","serif"],["Brush Script MT","cursive"],["Calibri","sans-serif"],["Century","serif"],["Century Gothic","sans-serif"],["Comic Sans MS","sans-serif"],["Cooper Black","serif"],["Courier New","monospace"],["Garamond","serif"],["Georgia","serif"],["Gill Sans MT Condensed","sans-serif"],["Helvetica","sans-serif"],["Lucida Console","monospace"],["Segoe UI","sans-serif"],["Tahoma","sans-serif"],["Times New Roman","serif"],["Trebuchet MS","sans-serif"],["Verdana","sans-serif"]],CG=wG.map(([e,t])=>({label:e,key:e,props:{style:{fontFamily:`${e}, ${t}`},"data-item":"btn-fontFamily-option"}}));function kG(e){if(e?.length)return e.map(t=>({label:t.label,key:t.value,props:{style:{fontFamily:t.previewFamily||t.label},"data-item":"btn-fontFamily-option"}}))}var SG=[{label:"8",key:"8pt",props:{"data-item":"btn-fontSize-option"}},{label:"9",key:"9pt",props:{"data-item":"btn-fontSize-option"}},{label:"10",key:"10pt",props:{"data-item":"btn-fontSize-option"}},{label:"11",key:"11pt",props:{"data-item":"btn-fontSize-option"}},{label:"12",key:"12pt",props:{"data-item":"btn-fontSize-option"}},{label:"14",key:"14pt",props:{"data-item":"btn-fontSize-option"}},{label:"18",key:"18pt",props:{"data-item":"btn-fontSize-option"}},{label:"24",key:"24pt",props:{"data-item":"btn-fontSize-option"}},{label:"30",key:"30pt",props:{"data-item":"btn-fontSize-option"}},{label:"36",key:"36pt",props:{"data-item":"btn-fontSize-option"}},{label:"48",key:"48pt",props:{"data-item":"btn-fontSize-option"}},{label:"60",key:"60pt",props:{"data-item":"btn-fontSize-option"}},{label:"72",key:"72pt",props:{"data-item":"btn-fontSize-option"}},{label:"96",key:"96pt",props:{"data-item":"btn-fontSize-option"}}],Eh={sm:768,md:1024,lg:1280,xl:1410},O1={undo:"undo",redo:"redo",bold:"bold",italic:"italic",underline:"underline",strike:"strikethrough",acceptTrackedChangeBySelection:"track-changes-accept-selection",rejectTrackedChangeOnSelection:"track-changes-reject-selection",ruler:"ruler",formattingMarks:"formatting-marks",zoom:"zoom",measurementUnit:"measurement-unit",documentMode:"document-mode",link:"link",fontFamily:"font-family",fontSize:"font-size",list:"bullet-list",numberedlist:"numbered-list",table:"table-insert",image:"image",tableOfContents:"table-of-contents-insert",color:"text-color",highlight:"highlight-color",textAlign:"text-align",lineHeight:"line-height",linkedStyles:"linked-style",indentleft:"indent-decrease",indentright:"indent-increase",directionLtr:"direction-ltr",directionRtl:"direction-rtl",clearFormatting:"clear-formatting",copyFormat:"copy-format"},RE={addRowBefore:"table-add-row-before",addRowAfter:"table-add-row-after",deleteRow:"table-delete-row",addColumnBefore:"table-add-column-before",addColumnAfter:"table-add-column-after",deleteColumn:"table-delete-column",deleteTable:"table-delete",deleteCellAndTableBorders:"table-remove-borders",mergeCells:"table-merge-cells",splitCell:"table-split-cell",fixTables:"table-fix"},ME=Object.values(RE),TX=[...new Set([...Object.values(O1),...ME])],_G=new Set(["link"]),RX=new Set(Object.keys(O1).filter(e=>!_G.has(e)));Ft(),yn();var AG="Arial, Helvetica, sans-serif",IG={__name:"Toolbar",emits:["command","toggle","select"],setup(e,{emit:t}){const{proxy:n}=yr();let r=te(1);const o=te(null),i=te(0),s=te(!1);let a=null,l=null,u=n.$toolbar.getAvailableWidth();const d=_e(()=>{const $=n?.$toolbar?.config?.uiDisplayFallbackFont;return typeof $=="string"&&$.trim()?$.trim():AG}),f=n.$toolbar.config?.toolbarGroups?.includes("left"),p=n.$toolbar.config?.toolbarGroups?.includes("right"),g=$=>(i.value,n.$toolbar.getToolbarItemByGroup($)),m=()=>{s.value=n.$toolbar.getAvailableWidth()<=Eh.lg},v=()=>{const $=o.value,T=$?.ownerDocument,H=T?.activeElement;if(!$?.contains(H))return null;const R=H.closest('[data-sd-part="toolbar-item"]')??H.querySelector('[data-sd-part="toolbar-item"]');if(!R||H!==R&&!H.contains(R))return null;const U=R.querySelector("[data-item]")?.getAttribute("data-item");return U?()=>{const W=o.value;if(!W?.isConnected||H.isConnected||T.activeElement!==T.body)return;const ee=[...W.querySelectorAll("[data-item]")];for(const J of[U,"btn-overflow"]){const Z=ee.find(Me=>Me.getAttribute("data-item")===J)?.closest('[data-sd-part="toolbar-item"]');if(Z&&Z.getAttribute("aria-disabled")!=="true"){Z.focus({preventScroll:!0});return}}}:null},C=async $=>{r.value+=1,await Ct(),$?.()},S=vH(async()=>{const $=n.$toolbar.getAvailableWidth();if($===u)return;u=$;const T=v();await n.$toolbar.onToolbarResize(),m(),await C(T)},300),b=()=>{const $=v();u=n.$toolbar.getAvailableWidth(),m(),C($)},k=()=>{i.value+=1};function x(){S.cancel(),window.removeEventListener("resize",S),n.$toolbar.off?.("toolbar-items-changed",b),n.$toolbar.off?.("toolbar-state-change",k),a?.disconnect(),a=null}function M(){x(),window.addEventListener("resize",S),n.$toolbar.on?.("toolbar-items-changed",b),n.$toolbar.on?.("toolbar-state-change",k),typeof ResizeObserver<"u"&&n.$toolbar.config?.responsiveToContainer&&n.$toolbar.toolbarContainer&&(a=new ResizeObserver(()=>{S()}),a.observe(n.$toolbar.toolbarContainer)),m()}zn(M),$v(M),Hv(x),ur(x);const z=()=>{if(!n.$toolbar.activeEditor){l=null,n.$toolbar.pendingSelectionCapture=null;return}l=n.$toolbar.ui?.selection?.capture?.()??null,n.$toolbar.pendingSelectionCapture=l},G=({item:$,argument:T,option:H})=>{F(),n.$toolbar.emitCommand({item:$,argument:T,option:H})},F=()=>{const $=n.$toolbar.activeEditor;if(!$)return;const T=n.$toolbar.pendingSelectionCapture??l;if(T&&typeof n.$toolbar.ui?.selection?.restore=="function"){n.$toolbar.ui.selection.restore(T);return}$.commands?.restoreSelection?.()},L=$=>{z(),EE($)};return($,T)=>(pe(),Ce("div",{class:"superdoc-toolbar",ref_key:"toolbarRoot",ref:o,key:et(r),role:"toolbar","aria-label":"Toolbar","data-sd-part":"toolbar","data-editor-ui-surface":"",onMousedown:L},[et(f)?(pe(),hn(kg,{key:0,tabindex:"0","toolbar-items":g("left"),"overflow-items":et(n).$toolbar.overflowItems,"compact-side-groups":s.value,"ui-font-family":d.value,position:"left",onCommand:G,class:"superdoc-toolbar-group-side"},null,8,["toolbar-items","overflow-items","compact-side-groups","ui-font-family"])):ut("",!0),en(kg,{tabindex:"0","toolbar-items":g("center"),"overflow-items":et(n).$toolbar.overflowItems,"compact-side-groups":s.value,"ui-font-family":d.value,position:"center",onCommand:G},null,8,["toolbar-items","overflow-items","compact-side-groups","ui-font-family"]),et(p)?(pe(),hn(kg,{key:1,tabindex:"0","toolbar-items":g("right"),"overflow-items":et(n).$toolbar.overflowItems,"compact-side-groups":s.value,"ui-font-family":d.value,position:"right",onCommand:G,class:"superdoc-toolbar-group-side"},null,8,["toolbar-items","overflow-items","compact-side-groups","ui-font-family"])):ut("",!0)],32))}},EG=mn(IG,[["__scopeId","data-v-0d00bc5b"]]),xG=e=>{if(!e)return e;const t=e.props?.style?.fontFamily??e.label??e.key;return{...e,props:{...e.props,style:{...e.props?.style,fontFamily:t},"data-item":e.props?.["data-item"]??"btn-fontFamily-option"}}};Ft();var xn=e=>{if(!["button","options","separator","dropdown","overflow"].includes(e.type))throw new Error("Invalid toolbar item type - "+e.type);if(e.type==="button"&&!e.defaultLabel&&!e.icon)throw new Error(`Toolbar button item needs either "icon" or "defaultLabel" - ${e.name}. "label" is the live label and is not a substitute for "defaultLabel".`);if(!e.name)throw new Error("Invalid toolbar item name - "+e.name);const t=te(fl()),n=e.type,r=te(e.name),o=e.command,i=e.noArgumentCommand,s=te(e.icon),a=te(e.group||"center"),l=te(e.allowWithoutEditor),u=te(e.attributes||{}),d=!!e.disabled,f=te(e.disabled),p=te(!1),g=te(!1),m=te(e.style),v=te(e.isNarrow),C=te(e.isWide),w=te(e.minWidth),S=te(e.layoutWidth),b=te(e.suppressActiveHighlight||!1),k=te(e.argument),x=te(null),M=te(null),z=te(e.iconColor),G=te(e.hasCaret),F=te(!!e.splitButton),L=e.splitButtonCommand,$=!!e.restoreEditorFocus,T=te(e.dropdownStyles),H=te(e.tooltip),R=te(e.tooltipVisible),U=te(e.tooltipTimeout),W=te(e.defaultLabel),ee=te(e.label),J=te(e.hideLabel),Z=te(e.inlineTextInputVisible),Me=te(e.hasInlineTextInput),fe=te(e.markName),ye=te(e.labelAttr),ve=te(e.selectedValue),Pe=te(e.dropdownValueKey),Ve=te(e.inputRef||null),nt=te([]);if(e.options){if(!Array.isArray(e.options))throw new Error("Invalid toolbar item options - "+e.options);let re=0;for(let j=0;j<e.options.length;j+=1){const X=e.options[j];(!X||typeof X!="object")&&(re+=1)}if(re)throw new Error(`Toolbar item options must all be objects - ${e.name}. ${re} row(s) are not, so this item is skipped.`);nt.value?.push(...e.options)}const ct=(re={},...j)=>{oe(re,...j),!b.value&&(p.value=!0)},ft=()=>{we(),p.value=!1},It=re=>{f.value=re},Le=()=>{f.value=d},oe=e.onActivate||(()=>null),we=e.onDeactivate||(()=>null),Q=()=>{const re={};return Object.keys(I).forEach(j=>{I[j].value!==void 0&&(re[j]=I[j].value)}),re},I={id:t,name:r,type:n,command:o,noArgumentCommand:i,icon:s,tooltip:H,group:a,attributes:u,disabled:f,active:p,expand:g,nestedOptions:nt,style:m,isNarrow:v,isWide:C,minWidth:w,layoutWidth:S,argument:k,parentItem:M,iconColor:z,hasCaret:G,splitButton:F,splitButtonCommand:L,dropdownStyles:T,tooltipVisible:R,tooltipTimeout:U,defaultLabel:W,label:ee,hideLabel:J,inlineTextInputVisible:Z,hasInlineTextInput:Me,restoreEditorFocus:$,markName:fe,labelAttr:ye,childItem:x,allowWithoutEditor:l,dropdownValueKey:Pe,selectedValue:ve,inputRef:Ve};return{...I,initiallyDisabled:d,unref:Q,activate:ct,deactivate:ft,setDisabled:It,resetDisabled:Le,onActivate:oe,onDeactivate:we}};Ft(),yn();var TG=["onClick","innerHTML","aria-label","onKeydown"],RG={__name:"AlignmentButtons",emits:["select"],setup(e,{emit:t}){const{isHighContrastMode:n}=Hi(),r=t,o=te([]),i=[{key:"left",ariaLabel:"Align left",icon:dr.alignLeft},{key:"center",ariaLabel:"Align center",icon:dr.alignCenter},{key:"right",ariaLabel:"Align right",icon:dr.alignRight},{key:"justify",ariaLabel:"Justify",icon:dr.alignJustify}],s=d=>{r("select",d)},a=d=>{if(d===o.value.length-1)return;const f=o.value[d+1];f&&(f.setAttribute("tabindex","0"),f.focus())},l=d=>{if(d===0)return;const f=o.value[d-1];f&&(f.setAttribute("tabindex","0"),f.focus())},u=(d,f)=>{switch(d.key){case"ArrowLeft":l(f);break;case"ArrowRight":a(f);break;case"Enter":s(i[f].key);break;default:break}};return zn(()=>{const d=o.value[0];d&&(d.setAttribute("tabindex","0"),d.focus())}),(d,f)=>(pe(),Ce("div",{class:Zt(["alignment-buttons",{"high-contrast":et(n)}])},[(pe(),Ce(Bt,null,Rn(i,(p,g)=>ce("div",{key:p.key,class:"sd-button-icon",onClick:m=>s(p.key),innerHTML:p.icon,"data-item":"btn-textAlign-option",role:"menuitem","aria-label":p.ariaLabel,ref_for:!0,ref_key:"alignmentButtonsRefs",ref:o,onKeydown:tn(m=>u(m,g),["prevent"])},null,40,TG)),64))],2))}},MG=mn(RG,[["__scopeId","data-v-13e5f7a4"]]);Ft(),yn();var LG=["onClick","innerHTML","aria-label","onKeydown"],PG={__name:"StyleButtonsList",props:{buttons:{type:Array,required:!0},selectedStyle:{type:String,default:null},iconSize:{type:Number,default:25}},emits:["select"],setup(e,{emit:t}){const{isHighContrastMode:n}=Hi(),r=t,o=e,i=te([]),s=_e(()=>({width:`${o.iconSize}px`,height:`${o.iconSize}px`})),a=f=>{r("select",f)},l=f=>{if(f===i.value.length-1)return;const p=i.value[f+1];p&&(p.setAttribute("tabindex","0"),p.focus())},u=f=>{if(f===0)return;const p=i.value[f-1];p&&(p.setAttribute("tabindex","0"),p.focus())},d=(f,p)=>{switch(f.key){case"ArrowLeft":u(p);break;case"ArrowRight":l(p);break;case"Enter":a(o.buttons[p].key);break;default:break}};return zn(()=>{const f=i.value[0];f&&(f.setAttribute("tabindex","0"),f.focus())}),(f,p)=>(pe(),Ce("div",{class:Zt(["style-buttons-list",{"high-contrast":et(n)}])},[(pe(!0),Ce(Bt,null,Rn(o.buttons,(g,m)=>(pe(),Ce("div",{key:g.key,class:Zt(["sd-button-icon",{"sd-selected":o.selectedStyle===g.key}]),style:An(s.value),onClick:v=>a(g.key),innerHTML:g.icon,role:"menuitem","aria-label":g.ariaLabel,ref_for:!0,ref_key:"buttonRefs",ref:i,onKeydown:tn(v=>d(v,m),["prevent"])},null,46,LG))),128))],2))}},LE=mn(PG,[["__scopeId","data-v-44f37ff6"]]),DG=[{key:"disc",icon:dr.bulletListDisc,ariaLabel:"Opaque circle"},{key:"circle",icon:dr.bulletListCircle,ariaLabel:"Outline circle"},{key:"square",icon:dr.bulletListSquare,ariaLabel:"Opaque square"}],OG=[{key:"decimal",icon:dr.numberedListDecimal,ariaLabel:"1. 2. 3."},{key:"decimal-paren",icon:dr.numberedListDecimalParen,ariaLabel:"1) 2) 3)"},{key:"upper-roman",icon:dr.numberedListUpperRoman,ariaLabel:"I. II. III."},{key:"lower-roman",icon:dr.numberedListLowerRoman,ariaLabel:"i. ii. iii."},{key:"upper-alpha",icon:dr.numberedListUpperAlpha,ariaLabel:"A. B. C."},{key:"upper-alpha-paren",icon:dr.numberedListUpperAlphaParen,ariaLabel:"A) B) C)"},{key:"lower-alpha",icon:dr.numberedListLowerAlpha,ariaLabel:"a. b. c."},{key:"lower-alpha-paren",icon:dr.numberedListLowerAlphaParen,ariaLabel:"a) b) c)"}];Ft(),yn();var FG=["onClick","onKeydown"],NG={class:"document-mode-column icon-column"},BG=["innerHTML"],zG={class:"document-mode-column text-column"},jG={class:"document-mode-type"},VG={class:"document-mode-description"},UG={__name:"DocumentMode",props:{options:{type:Array}},emits:["select"],setup(e,{emit:t}){const n=t,r=te([]),{isHighContrastMode:o}=Hi(),i=e,s=d=>{n("select",d)},a=d=>{if(d===r.value.length-1)return;const f=r.value[d+1];f&&(f.setAttribute("tabindex","0"),f.focus())},l=d=>{if(d===0)return;const f=r.value[d-1];f&&(f.setAttribute("tabindex","0"),f.focus())},u=(d,f)=>{switch(d.key){case"ArrowDown":a(f);break;case"ArrowUp":l(f);break;case"Enter":s(i.options[f]);break;default:break}};return zn(()=>{r.value[0].setAttribute("tabindex","0"),r.value[0].focus()}),(d,f)=>(pe(),Ce("div",{class:Zt(["document-mode",{"high-contrast":et(o)}])},[(pe(!0),Ce(Bt,null,Rn(e.options,(p,g)=>(pe(),Ce("div",{class:Zt(["sd-option-item",{"sd-disabled":p.disabled}]),onClick:m=>s(p),"data-item":"btn-documentMode-option",role:"menuitem",ref_for:!0,ref_key:"documentModeRefs",ref:r,onKeydown:tn(m=>u(m,g),["prevent"])},[ce("div",NG,[ce("div",{class:"icon-column__icon",innerHTML:p.icon},null,8,BG)]),ce("div",zG,[ce("div",jG,Et(p.label),1),ce("div",VG,Et(p.description),1)])],42,FG))),256))],2))}},$G=mn(UG,[["__scopeId","data-v-bee14d7a"]]);Ft(),yn();var HG={class:"linked-style-buttons","data-editor-ui-surface":""},GG=["onClick","onKeydown","aria-label"],WG={__name:"LinkedStyle",props:{styles:{type:Array,default:()=>[]},selectedOption:{type:String,default:null}},emits:["select"],setup(e,{emit:t}){const n=t,r=te([]),o=e,i=p=>{n("select",p)},s=p=>{if(p===r.value.length-1)return;const g=r.value[p+1];g.setAttribute("tabindex","0"),g.focus()},a=p=>{if(p===0)return;const g=r.value[p-1];g.setAttribute("tabindex","0"),g.focus()},l=(p,g,m)=>{switch(p.key){case"ArrowDown":s(g);break;case"ArrowUp":a(g);break;case"Enter":p.preventDefault(),i(m);break;default:break}},u=p=>p?.name??p?.id??"",d=p=>{const g=p?.preview?.css;return g&&typeof g=="object"?g:void 0},f=()=>{r.value[0]&&(r.value[0].setAttribute("tabindex","0"),r.value[0].focus())};return zn(f),jt(()=>o.styles.length,async(p,g)=>{p===0||g!==0||(await Ct(),f())}),(p,g)=>(pe(),Ce("div",HG,[(pe(!0),Ce(Bt,null,Rn(o.styles,(m,v)=>(pe(),Ce("div",{key:m.id??v,class:Zt(["style-item",{selected:e.selectedOption===m.id}]),onClick:C=>i(m),onKeydown:C=>l(C,v,m),"aria-label":`Linked style - ${m.id??u(m)}`,ref_for:!0,ref_key:"styleRefs",ref:r},[ce("div",{class:"style-name","data-item":"btn-linkedStyles-option",style:An(d(m))},Et(u(m)),5)],42,GG))),128))]))}},KG=mn(WG,[["__scopeId","data-v-74c8924b"]]);Ft(),yn();var qG=["placeholder"],YG={class:"sd-ai-writer__footer"},XG={key:0,class:"sd-ai-writer__error",role:"alert"},ZG=["disabled"],QG="https://sd-dev-express-gateway-i6xtm.ondigitalocean.app/insights",JG="You are an expert copywriter and you are immersed in a document editor. Only write what is asked for.",eW={__name:"AIWriter",props:{selectedText:{type:String,default:""},target:{type:Object,default:null},doc:{type:Object,default:null},apiKey:{type:String,default:""},endpoint:{type:String,default:""},restoreSelection:{type:Function,default:null},handleClose:{type:Function,required:!0}},setup(e){const t=e,n=te(""),r=te(!1),o=te(""),i=te(null),s=_e(()=>t.selectedText?"Insert prompt to update text":"Insert prompt to generate text"),a=_e(()=>n.value.trim().length>0&&!r.value);zn(()=>{Ct(()=>{i.value?.focus()})});function l(m){if(typeof m=="string")return m;if(!m||typeof m!="object")return"";const v=m.custom_prompt;if(Array.isArray(v)){const C=v[0];if(C&&typeof C.value=="string")return C.value}return v&&typeof v=="object"&&typeof v.value=="string"?v.value:typeof m.value=="string"?m.value:typeof m.text=="string"?m.text:""}async function u(m){const v={"Content-Type":"application/json"};t.apiKey&&(v["x-api-key"]=t.apiKey);const C=t.selectedText.trim(),w=C?`Rewrite the following text: "${C}" using these instructions: ${m}`:`Generate text based on the following prompt: ${m}`,S=await fetch(t.endpoint||QG,{method:"POST",headers:v,body:JSON.stringify({stream:!1,context:JG,insights:[{type:"custom_prompt",name:C?"text_rewrite":"text_generation",message:w,format:[{value:""}]}]})});if(!S.ok){const k=await S.text().catch(()=>"");throw new Error(k||`AI request failed with ${S.status}`)}const b=l((S.headers.get("content-type")||"").includes("application/json")?await S.json():await S.text()).trim();if(!b)throw new Error("AI returned no text.");return b}function d(m){return!m||typeof m!="object"?!0:!(m.success===!1||m.ok===!1)}function f(m){const v=t.doc;if(!v)throw new Error("Document API is unavailable.");t.restoreSelection?.();let C=null,w=!1;if(t.selectedText&&t.target&&typeof v.replace=="function"?(C=v.replace({target:t.target,text:m}),w=!0):t.target&&typeof v.insert=="function"?(C=v.insert({target:t.target,value:m,type:"text"}),w=!0):typeof v.insert=="function"&&(C=v.insert({value:m,type:"text"}),w=!0),!w)throw new Error("Document text insertion is unavailable.");if(!d(C))throw new Error("Unable to insert generated text.")}async function p(){if(a.value){o.value="",r.value=!0;try{f(await u(n.value.trim())),t.handleClose()}catch(m){o.value=m instanceof Error?m.message:String(m)}finally{r.value=!1}}}function g(m){m.key!=="Enter"||m.shiftKey||(m.preventDefault(),p())}return(m,v)=>(pe(),Ce("form",{class:"sd-ai-writer","data-item":"ai-writer",onSubmit:tn(p,["prevent"])},[ki(ce("textarea",{ref_key:"textareaRef",ref:i,"onUpdate:modelValue":v[0]||(v[0]=C=>n.value=C),class:"sd-ai-writer__input",placeholder:s.value,rows:"4",onKeydown:g},null,40,qG),[[Ii,n.value]]),ce("div",YG,[o.value?(pe(),Ce("p",XG,Et(o.value),1)):ut("",!0),ce("button",{class:"sd-ai-writer__submit",type:"submit",disabled:!a.value},Et(r.value?"Generating":"Generate"),9,ZG)])],32))}},tW=mn(eW,[["__scopeId","data-v-67f6c6f7"]]);Ft(),yn();var nW=["aria-label","onClick","onKeydown"],rW=["innerHTML"],oW=["innerHTML"],Sg=7,iW={__name:"IconGridRow",props:{icons:{type:Array,required:!0},activeColor:{type:Object,required:!1}},emits:["select","clickoutside"],setup(e,{emit:t}){const n=t,r=e,o=_e(()=>m=>r.activeColor.value?r.activeColor.value.toUpperCase()===m.value:!1),i=(m,v)=>v===5||["#FFFFFF","#FAFF09"].includes(m)?{color:"#000"}:{color:"#FFF"},s=m=>{n("select",m.value)},a=te([]),l=te([]);zn(()=>{if(!r.icons.every(v=>Array.isArray(v)))throw new Error("icon props must be 2d array");const m=l.value[0];m&&(m.setAttribute("tabindex","0"),m.focus({preventScroll:!0}))});const u=(m,v)=>{const C=Sg*m+v+1,w=l.value[C];w&&(w.setAttribute("tabindex","0"),w.focus({preventScroll:!0}))},d=(m,v)=>{const C=Sg*m+v-1,w=l.value[C];w&&(w.setAttribute("tabindex","0"),w.focus({preventScroll:!0}))},f=(m,v)=>{const C=v+Sg*(m+1),w=l.value[C];w&&(w.setAttribute("tabindex","0"),w.focus({preventScroll:!0}))},p=(m,v)=>{const C=v+Sg*(m-1),w=l.value[C];w&&(w.setAttribute("tabindex","0"),w.focus({preventScroll:!0}))},g=(m,v,C,w)=>{switch(m.key){case"ArrowRight":u(v,C);break;case"ArrowLeft":d(v,C);break;case"ArrowDown":f(v,C);break;case"ArrowUp":p(v,C);break;case"Enter":s(w);break;case"Escape":n("clickoutside");break;default:break}};return(m,v)=>(pe(!0),Ce(Bt,null,Rn(e.icons,(C,w)=>(pe(),Ce("div",{class:"sd-option-row",key:w,role:"group",ref_for:!0,ref_key:"rowRefs",ref:a},[(pe(!0),Ce(Bt,null,Rn(C,(S,b)=>(pe(),Ce("div",{class:"sd-option",key:b,"aria-label":S.label,role:"menuitem",ref_for:!0,ref_key:"iconRefs",ref:l,onClick:tn(k=>s(S),["stop","prevent"]),onKeydown:tn(k=>g(k,w,b,S),["prevent"])},[ce("div",{class:"sd-option__icon",innerHTML:S.icon,style:An(S.style)},null,12,rW),o.value(S)?(pe(),Ce("div",{key:0,class:"sd-option__check",innerHTML:et(dr).colorOptionCheck,style:An(i(S.value,b))},null,12,oW)):ut("",!0)],40,nW))),128))]))),128))}},PE=mn(iW,[["__scopeId","data-v-05eb02fc"]]),sW=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M320 512c53.2 0 101.4-21.6 136.1-56.6l-298.3-235C140 257.1 128 292.3 128 320c0 106 86 192 192 192zM505.2 370.7c4.4-16.2 6.8-33.1 6.8-50.7c0-91.2-130.2-262.3-166.6-308.3C339.4 4.2 330.5 0 320.9 0l-1.8 0c-9.6 0-18.5 4.2-24.5 11.7C277.8 33 240.7 81.3 205.8 136L38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L505.2 370.7zM224 336c0 44.2 35.8 80 80 80c8.8 0 16 7.2 16 16s-7.2 16-16 16c-61.9 0-112-50.1-112-112c0-8.8 7.2-16 16-16s16 7.2 16 16z"/></svg>
|
|
105
105
|
`;Ft(),yn();var aW={class:"options-grid-wrap"},lW=["innerHTML"],cW={class:"option-grid-ctn"},uW={__name:"IconGrid",props:{icons:{type:Array,required:!0},customIcons:{type:Array,required:!1},activeColor:{type:Object,required:!1},hasNoneIcon:{type:Boolean,required:!1}},emits:["select","clickoutside"],setup(e,{emit:t}){const n=t,r=o=>{n("select",o)};return(o,i)=>(pe(),Ce("div",aW,[e.hasNoneIcon?(pe(),Ce("div",{key:0,class:"none-option",role:"menuitem","aria-label":"Clear color selection",onClick:i[0]||(i[0]=s=>r("none"))},[ce("span",{innerHTML:et(sW),class:"none-icon"},null,8,lW),i[1]||(i[1]=Si(" None ",-1))])):ut("",!0),ce("div",cW,[en(PE,{icons:e.icons,"active-color":e.activeColor,onSelect:r},null,8,["icons","active-color"]),e.customIcons.flat().length?(pe(),Ce(Bt,{key:0},[i[2]||(i[2]=ce("span",{class:"option-grid-ctn__subtitle"},"Custom colors",-1)),en(PE,{icons:e.customIcons,"active-color":e.activeColor,onSelect:r},null,8,["icons","active-color"])],64)):ut("",!0)])]))}},dW=mn(uW,[["__scopeId","data-v-52b0283a"]]);Ft();var fW=e=>{e.expand.value=!1},Wt=(e,t=null)=>({label:t,icon:dr.colorOption,value:e,style:{color:e,boxShadow:"0 0 5px 1px rgba(0, 0, 0, 0.1)",borderRadius:"50%"}}),F1=(e,t,n=[],r=!1)=>{const o=i=>{t.iconColor.value=i,e.emitCommand({item:t,argument:i}),fW(t),Kl(e)};return Dr("div",{},[Dr(dW,{icons:hW,customIcons:n,activeColor:t.iconColor,hasNoneIcon:r,onSelect:o})])},hW=[[Wt("#111111","black"),Wt("#333333","dark gray"),Wt("#5C5C5C","medium gray"),Wt("#858585","light gray"),Wt("#ADADAD","very light gray"),Wt("#D6D6D6","transparent gray"),Wt("#FFFFFF","white")],[Wt("#860028","dark red"),Wt("#D2003F","red"),Wt("#DB3365","coral red"),Wt("#E4668C","light red"),Wt("#ED99B2","pale pink"),Wt("#F6CCD9","transparent pink"),Wt("#FF004D","bright pink")],[Wt("#83015E","dark purple"),Wt("#CD0194","purple"),Wt("#D734A9","orchid"),Wt("#E167BF","light purple"),Wt("#EB99D4","lavender"),Wt("#F5CCEA","transparent pink"),Wt("#FF00A8","neon pink")],[Wt("#8E220A","maroon"),Wt("#DD340F","red-orange"),Wt("#E45C3F","burnt orange"),Wt("#EB856F","peach"),Wt("#F1AE9F","pale peach"),Wt("#F8D6CF","transparent peach"),Wt("#FF7A00","orange")],[Wt("#947D02","olive"),Wt("#E7C302","mustard yellow"),Wt("#ECCF35","yellow"),Wt("#F1DB67","light yellow"),Wt("#F5E79A","very pale yellow"),Wt("#FAF3CC","transparent yellow"),Wt("#FAFF09","neon yellow")],[Wt("#055432","forest green"),Wt("#07834F","green"),Wt("#399C72","medium green"),Wt("#6AB595","light green"),Wt("#9CCDB9","mint"),Wt("#CDE6DC","transparent mint"),Wt("#05F38F","bright teal")],[Wt("#063E7E","navy blue"),Wt("#0A60C5","blue"),Wt("#3B80D1","sky blue"),Wt("#6CA0DC","cornflower blue"),Wt("#9DBFE8","light blue"),Wt("#CEDFF3","very light blue"),Wt("#21c8ce","cyan")],[Wt("#3E027A","deep purple"),Wt("#6103BF","indigo"),Wt("#8136CC","violet"),Wt("#A068D9","lavender pink"),Wt("#C09AE6","light lilac"),Wt("#DFCDF2","transparent lilac"),Wt("#A91DFF","neon purple")]];Ft(),yn();var pW=["data-cols","data-rows","onKeydown","onClick"],mW=["aria-valuetext"],_g=5,gW={__name:"TableGrid",emits:["select","clickoutside"],setup(e,{emit:t}){const n=t,r=te(0),o=te(0),{isHighContrastMode:i}=Hi(),s=te([]),a=f=>{let p=f.target;if(p.dataset.grid)return;let g=[...p.parentElement.querySelectorAll("[data-item]")],m=parseInt(p.dataset.cols,10),v=parseInt(p.dataset.rows,10);l(g,m,v)},l=(f,p,g)=>{o.value=p,r.value=g;for(let m=0;m<f.length;m++){let v=f[m],C=parseInt(v.dataset.cols,10),w=parseInt(v.dataset.rows,10);C<=p&&w<=g?v.classList.add("sd-selected"):v.classList.remove("sd-selected")}},u=({cols:f,rows:p})=>{n("select",{cols:f,rows:p})},d=(f,p,g)=>{let m=p-1,v=g-1;switch(f.key){case"ArrowRight":{if(m>=4)return;const C=v*_g;s.value[C+m+1].setAttribute("tabindex","0"),s.value[C+m+1].focus(),l(s.value,p+1,g);break}case"ArrowLeft":{if(m<=0)return;const C=v*_g;s.value[C+m-1].setAttribute("tabindex","0"),s.value[C+m-1].focus(),l(s.value,p-1,g);break}case"ArrowDown":{if(v>=4)return;const C=(v+1)*_g;s.value[C+m].setAttribute("tabindex","0"),s.value[C+m].focus(),l(s.value,p,g+1);break}case"ArrowUp":{if(v<=0)return;const C=(v-1)*_g;s.value[C+m].setAttribute("tabindex","0"),s.value[C+m].focus(),l(s.value,p,g-1);break}case"Enter":u({cols:p,rows:g});break;default:break}};return zn(()=>{s.value[0].setAttribute("tabindex","0"),s.value[0].focus(),l(s.value,1,1)}),(f,p)=>(pe(),Ce("div",{class:Zt(["toolbar-table-grid-wrapper",{"high-contrast":et(i)}])},[ce("div",{class:"toolbar-table-grid",onMouseover:a,"data-grid":"true"},[(pe(),Ce(Bt,null,Rn(5,g=>(pe(),Ce(Bt,{key:g},[(pe(),Ce(Bt,null,Rn(5,m=>ce("div",{class:"toolbar-table-grid__item",key:`${g}_${m}`,"data-cols":m,"data-rows":g,"data-item":"true",ref_for:!0,ref_key:"tableGridItems",ref:s,onKeydown:tn(v=>d(v,m,g),["prevent"]),onClick:tn(v=>u({cols:m,rows:g}),["stop","prevent"])},null,40,pW)),64))],64))),64))],32),ce("div",{class:"toolbar-table-grid-value","aria-valuetext":`${r.value} x ${o.value}`},Et(r.value)+" x "+Et(o.value),9,mW)],2))}},vW=mn(gW,[["__scopeId","data-v-b87d6ca2"]]);Ft(),yn();var yW={class:"toolbar-table-actions"},bW=["onClick","data-item","ariaLabel"],wW={class:"toolbar-table-actions__icon"},CW=["innerHTML"],kW={class:"toolbar-table-actions__label"},SW={__name:"TableActions",props:{options:{type:Array}},emits:["select"],setup(e,{emit:t}){const n=t,r=o=>{n("select",{command:o.command})};return(o,i)=>(pe(),Ce("div",yW,[(pe(!0),Ce(Bt,null,Rn(e.options,s=>(pe(),Ce("div",{class:Zt(["toolbar-table-actions__item",{"toolbar-table-actions__item--border":s.bottomBorder}]),onClick:a=>r(s),"data-item":s.props?.["data-item"]||"",ariaLabel:s.props?.ariaLabel,role:"menuitem"},[ce("div",wW,[ce("div",{class:"toolbar-table-actions__icon-wrapper",innerHTML:s.icon},null,8,CW)]),ce("div",kW,Et(s.label),1)],10,bW))),256))]))}},_W=mn(SW,[["__scopeId","data-v-0cdad084"]]);Ft(),yn();var AW=["aria-busy"],IW=["aria-disabled"],EW={class:"sd-page-number-menu__row-label","aria-hidden":"true"},xW=["aria-checked","aria-label","title","tabindex","data-position","data-alignment","onClick"],TW={class:"sd-page-number-menu__page",viewBox:"0 0 36 46","aria-hidden":"true",focusable:"false"},RW=["x","y"],MW={class:"sd-page-number-menu__check"},LW=["disabled"],PW={class:"sd-page-number-menu__format"},DW={class:"sd-page-number-menu__field"},OW=["disabled"],FW=["value"],NW={class:"sd-page-number-menu__start"},BW={class:"sd-page-number-menu__check"},zW=["disabled"],jW=["disabled","onKeydown"],VW={key:0,class:"sd-page-number-menu__error",role:"alert"},UW={key:1,class:"sd-page-number-menu__note",role:"status"},$W={class:"sd-page-number-menu__actions"},HW=["disabled"],GW=["disabled"],WW=["disabled"],KW={class:"sd-page-number-menu__cursor-text"},qW={__name:"PageNumberMenu",props:{pageNumbersState:{type:Object,default:null},atCursorState:{type:Object,default:null},suggesting:{type:Boolean,default:!1},inHeaderFooter:{type:Boolean,default:!1},loadCurrent:{type:Function,default:null},applyPageNumbers:{type:Function,required:!0},removePageNumbers:{type:Function,required:!0},insertAtCursor:{type:Function,required:!0},close:{type:Function,required:!0},initialChoice:{type:Object,default:null}},setup(e){const t=e,n=[{value:"top",label:"Top of page",kind:"header"},{value:"bottom",label:"Bottom of page",kind:"footer"}],r=[{value:"left",label:"left"},{value:"center",label:"center"},{value:"right",label:"right"}],o=n.flatMap(oe=>r.map(we=>({position:oe.value,alignment:we.value,label:`${oe.label}, ${we.label}`}))),i=[{value:"decimal",label:"1, 2, 3"},{value:"lowerLetter",label:"a, b, c"},{value:"upperLetter",label:"A, B, C"},{value:"lowerRoman",label:"i, ii, iii"},{value:"upperRoman",label:"I, II, III"},{value:"numberInDash",label:"- 1 -, - 2 -"}],s=[{value:"hebrew1",label:"א, ב, ג"},{value:"hebrew2",label:"א, ב, ג (alphabet)"}],a={left:6,center:14,right:22},l={top:4,bottom:37},{isHighContrastMode:u}=Hi(),d=t.initialChoice??{},f=te(d.position==="top"?"top":"bottom"),p=te(r.some(oe=>oe.value===d.alignment)?d.alignment:"right"),g=te(d.showOnFirstPage!==!1),m=te("decimal"),v=te(!1),C=te(1),w=te(null),S=te(typeof t.loadCurrent=="function");let b=Promise.resolve();const k=te(!1),x=te(!1),M=te(""),z=te([]),G=_e(()=>t.pageNumbersState?.enabled===!0),F=_e(()=>t.atCursorState?.enabled===!0),L=_e(()=>(w.value?.placements?.length??0)>0),$=_e(()=>s.some(oe=>oe.value===m.value)?[...i,...s]:i),T=_e(()=>o.findIndex(oe=>oe.position===f.value&&oe.alignment===p.value)),H=_e(()=>{if(T.value>=0)return T.value;const oe=n.findIndex(we=>we.value===f.value);return Math.max(0,oe)*r.length}),R=_e(()=>L.value?"Apply":"Add page numbers"),U=_e(()=>G.value?"":t.suggesting?"Page numbers can’t be changed as a suggestion. Switch to Editing to change them.":"Page numbers can’t be changed right now."),W=_e(()=>F.value?"In the header or footer you’re editing":t.inHeaderFooter?"Place the cursor without selecting text":"Click into a header or footer first"),ee=_e(()=>{const oe=typeof navigator>"u"?"":navigator.platform||navigator.userAgent||"";return/Mac|iPhone|iPad/i.test(oe)?"⌥⇧⌘P":"Ctrl+Alt+Shift+P"});function J(oe){return oe.position===f.value&&oe.alignment===p.value}function Z(){k.value=!0,M.value=""}function Me(oe,{focus:we=!1}={}){f.value=oe.position,p.value=oe.alignment,Z(),we&&Ct(()=>z.value[o.indexOf(oe)]?.focus())}function fe(oe){const we=H.value,Q=Math.floor(we/r.length),I=we%r.length,re={ArrowLeft:[Q,Math.max(0,I-1)],ArrowRight:[Q,Math.min(r.length-1,I+1)],ArrowUp:[Math.max(0,Q-1),I],ArrowDown:[Math.min(n.length-1,Q+1),I],Home:[Q,0],End:[Q,r.length-1]}[oe.key];return re?(oe.preventDefault(),Me(o[re[0]*r.length+re[1]],{focus:!0}),!0):!1}function ye(oe){fe(oe)||(oe.key==="Enter"?(oe.preventDefault(),ft()):oe.key===" "&&oe.preventDefault())}function ve(oe){if(w.value=oe&&Array.isArray(oe.placements)?oe:null,!w.value||k.value)return;const we=w.value.placements.find(Q=>Q.kind==="footer"&&Q.alignment)??w.value.placements.find(Q=>Q.alignment)??w.value.placements[0];we&&(f.value=we.kind==="header"?"top":"bottom",p.value=we.alignment??null,g.value=w.value.showOnFirstPage!==!1),m.value=w.value.format??"decimal",v.value=typeof w.value.start=="number",C.value=typeof w.value.start=="number"?w.value.start:1,Ct(()=>z.value[H.value]?.focus({preventScroll:!0}))}function Pe(){const oe=w.value,we=f.value==="top"?"header":"footer",Q=oe?.placements?.find(j=>j.kind===we)??null,I={position:f.value};p.value&&(!Q||Q.alignment!==p.value)&&(I.alignment=p.value),(!L.value||g.value!==(oe?.showOnFirstPage!==!1))&&(I.showOnFirstPage=g.value),m.value!==(oe?.format??"decimal")&&(I.format=m.value);const re=v.value?Ve():null;return re!==(oe?.start??null)&&(I.start=re),I}function Ve(){const oe=Math.floor(Number(C.value));return Number.isFinite(oe)&&oe>=0?oe:1}function nt(oe,we){const Q=oe?.failure?.details;return Q?.reason==="page-number-has-content"?`A page number shares its line with other text. Edit the ${Q.kind==="header"?"header":"footer"} directly to change it.`:Q?.reason==="page-number-exists"?"This section already has page numbers.":we==="remove"?"Page numbers couldn’t be removed. Try again.":L.value?"Page numbers couldn’t be changed. Try again.":"Page numbers couldn’t be added. Try again."}async function ct(oe,we){if(!(!G.value||x.value)){x.value=!0,M.value="";try{await b;const{execute:Q,outcome:I}=we(),re=await Q();if(re===!0||re?.success===!0){t.close(I);return}M.value=nt(re,oe)}catch{M.value=nt(null,oe)}finally{x.value=!1}}}function ft(){return ct("apply",()=>{const oe=Pe();return{execute:()=>t.applyPageNumbers(oe),outcome:{action:"apply",choice:{position:f.value,alignment:p.value,showOnFirstPage:g.value}}}})}function It(){return ct("remove",()=>({execute:()=>t.removePageNumbers(),outcome:{action:"remove",kinds:(w.value?.placements??[]).map(oe=>oe.kind)}}))}function Le(){if(!F.value||x.value)return;x.value=!0;let oe;try{oe=t.insertAtCursor()}catch{oe=void 0}t.close({action:"cursor"}),Promise.resolve(oe).catch(()=>{})}return zn(()=>{Ct(()=>z.value[H.value]?.focus({preventScroll:!0})),typeof t.loadCurrent=="function"&&(b=Promise.resolve().then(()=>t.loadCurrent()).then(ve,()=>ve(null)).finally(()=>{S.value=!1}))}),(oe,we)=>(pe(),Ce("div",{class:Zt(["sd-page-number-menu",{"high-contrast":et(u)}]),role:"group","aria-labelledby":"sd-page-number-menu-title","aria-busy":S.value||void 0,"data-sd-page-number-menu":""},[we[9]||(we[9]=ce("div",{id:"sd-page-number-menu-title",class:"sd-page-number-menu__title"},"Page numbers",-1)),ce("div",{class:"sd-page-number-menu__grid",role:"radiogroup","aria-label":"Position","aria-disabled":!G.value||void 0},[(pe(),Ce(Bt,null,Rn(n,(Q,I)=>(pe(),Ce(Bt,{key:Q.value},[ce("div",EW,Et(Q.label),1),(pe(!0),Ce(Bt,null,Rn(et(o).slice(I*3,I*3+3),re=>(pe(),Ce("button",{key:`${re.position}-${re.alignment}`,ref_for:!0,ref:j=>z.value[et(o).indexOf(re)]=j,type:"button",role:"radio",class:Zt(["sd-page-number-menu__tile",{"is-selected":J(re)}]),"aria-checked":J(re),"aria-label":re.label,title:re.label,tabindex:et(o).indexOf(re)===H.value?0:-1,"data-position":re.position,"data-alignment":re.alignment,onClick:j=>Me(re),onDblclick:ft,onKeydown:ye},[(pe(),Ce("svg",TW,[we[4]||(we[4]=rC('<rect class="sd-page-number-menu__sheet" x="0.75" y="0.75" width="34.5" height="44.5" rx="2.5" data-v-30327fd0></rect><rect class="sd-page-number-menu__line" x="7" y="14" width="22" height="2" rx="1" data-v-30327fd0></rect><rect class="sd-page-number-menu__line" x="7" y="19" width="18" height="2" rx="1" data-v-30327fd0></rect><rect class="sd-page-number-menu__line" x="7" y="24" width="22" height="2" rx="1" data-v-30327fd0></rect><rect class="sd-page-number-menu__line" x="7" y="29" width="14" height="2" rx="1" data-v-30327fd0></rect>',5)),ce("rect",{class:"sd-page-number-menu__chip",x:a[re.alignment],y:l[re.position],width:"8",height:"5",rx:"1.5"},null,8,RW)]))],42,xW))),128))],64))),64))],8,IW),ce("label",MW,[ki(ce("input",{"onUpdate:modelValue":we[0]||(we[0]=Q=>g.value=Q),type:"checkbox",disabled:!G.value,"data-sd-page-number-first-page":"",onChange:Z},null,40,LW),[[Pu,g.value]]),we[5]||(we[5]=ce("span",null,"Show on first page",-1))]),ce("div",PW,[ce("label",DW,[we[6]||(we[6]=ce("span",null,"Format",-1)),ki(ce("select",{"onUpdate:modelValue":we[1]||(we[1]=Q=>m.value=Q),disabled:!G.value,"data-sd-page-number-format":"",onChange:Z},[(pe(!0),Ce(Bt,null,Rn($.value,Q=>(pe(),Ce("option",{key:Q.value,value:Q.value},Et(Q.label),9,FW))),128))],40,OW),[[Wp,m.value]])]),ce("div",NW,[ce("label",BW,[ki(ce("input",{"onUpdate:modelValue":we[2]||(we[2]=Q=>v.value=Q),type:"checkbox",disabled:!G.value,"data-sd-page-number-restart":"",onChange:Z},null,40,zW),[[Pu,v.value]]),we[7]||(we[7]=ce("span",null,"Start at",-1))]),ki(ce("input",{"onUpdate:modelValue":we[3]||(we[3]=Q=>C.value=Q),type:"number",min:"0",step:"1",inputmode:"numeric","aria-label":"First page number",disabled:!G.value||!v.value,"data-sd-page-number-start":"",onInput:Z,onKeydown:Ko(tn(ft,["prevent"]),["enter"])},null,40,jW),[[Ii,C.value,void 0,{number:!0}]])])]),M.value?(pe(),Ce("p",VW,Et(M.value),1)):U.value?(pe(),Ce("p",UW,Et(U.value),1)):ut("",!0),ce("div",$W,[L.value?(pe(),Ce("button",{key:0,type:"button",class:"sd-page-number-menu__remove",disabled:!G.value||x.value,"aria-label":"Remove page numbers","data-sd-page-number-remove":"",onClick:It}," Remove ",8,HW)):ut("",!0),ce("button",{type:"button",class:"sd-page-number-menu__add",disabled:!G.value||x.value,"data-sd-page-number-add":"",onClick:ft},Et(R.value),9,GW)]),we[10]||(we[10]=ce("div",{class:"sd-page-number-menu__divider",role:"separator"},null,-1)),ce("button",{type:"button",class:"sd-page-number-menu__cursor",disabled:!F.value||x.value,"data-sd-page-number-at-cursor":"",onClick:Le},[ce("span",KW,[we[8]||(we[8]=ce("span",null,"Insert at cursor",-1)),ce("small",null,Et(W.value),1)]),ce("kbd",null,Et(ee.value),1)],8,WW)],10,AW))}},YW=mn(qW,[["__scopeId","data-v-30327fd0"]]),N1="sd-page-number-flash",XW=1400,DE=e=>new Promise(t=>{typeof e?.requestAnimationFrame=="function"?e.requestAnimationFrame(()=>t()):setTimeout(t,16)});async function OE(e,t){const n=e?.ownerDocument?.defaultView;if(!e||!n)return;await DE(n),await DE(n);const r=n.innerHeight,o=[...e.querySelectorAll(`[data-sd-headerfooter-kind="${t}"]`)].filter(i=>{const s=i.getBoundingClientRect();return s.height>0&&s.bottom>0&&s.top<r});for(const i of o)i.classList.remove(N1),i.classList.add(N1),n.setTimeout(()=>i.classList.remove(N1),XW)}var ZW=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"/></svg>
|
|
106
|
-
`;Ft();var Ki=e=>{e.expand.value=!1},B1=(e,t)=>{const n=e.layoutWidth?.value;return Number.isFinite(n)&&n>0?n:e.type==="separator"?t.get("separator"):t.get(e.name.value)||t.get("default")},QW=e=>{const t=[];for(const n of e){if(n.type==="separator"){const r=t[t.length-1];if(!r||r.type==="separator")continue}t.push(n)}for(;t.length&&t[t.length-1].type==="separator";)t.pop();return t},FE=e=>{const t=new Map;for(const r of e){const o=r.group?.value||"center";t.has(o)||t.set(o,[]),t.get(o).push(r)}const n=new Set;for(const r of t.values())for(const o of QW(r))n.add(o);return e.filter(r=>n.has(r))},JW=e=>{const t=e.find(o=>o.type==="overflow"),n=e.filter(o=>o!==t),r=new Set(FE(n));return e.filter(o=>o===t||r.has(o))};function z1(e,t){const n={...e};return t?n.href=t:delete n.href,n}function NE(e){const t=Array.isArray(e?.segments)?e.segments:[];if(e?.kind!=="text"||!t.length)return null;const n=t[0],r=t[t.length-1];if(!n?.blockId||!r?.blockId||!n.range||!r.range)return null;const o=e.story;return{kind:"selection",start:{kind:"text",blockId:n.blockId,offset:n.range.start??0,...o?{story:o}:{}},end:{kind:"text",blockId:r.blockId,offset:r.range.end??0,...o?{story:o}:{}},...o?{story:o}:{}}}function eK(e){return typeof e?.quotedText=="string"?e.quotedText:typeof e?.text=="string"?e.text:""}function j1(e){return e.ui?.selection?.get?.()??e.ui?.selection?.current?.()??null}function tK(e){return!!(e.config?.superdoc?.config?.modules?.ai||e.superdoc?.config?.modules?.ai)}function nK(e){return e.config?.superdoc?.config?.modules?.ai??e.superdoc?.config?.modules?.ai??{}}var rK=({superToolbar:e,toolbarIcons:t,toolbarTexts:n,toolbarFonts:r,hideButtons:o,availableWidth:i,role:s,isDev:a=!1,configuredItemNames:l,configuredItemOrder:u,excludedItemNames:d,additionalItems:f=[]}={})=>{const p=xn({type:"button",name:"bold",command:"toggleBold",icon:t.bold,tooltip:n.bold,attributes:{ariaLabel:"Bold"}}),g=(r??CG).map(xG),m=xn({type:"dropdown",name:"fontFamily",tooltip:n.fontFamily,command:"setFontFamily",defaultLabel:"Arial",label:"Arial",markName:"textStyle",labelAttr:"fontFamily",hasCaret:!0,hasInlineTextInput:!0,inlineTextInputVisible:!0,isWide:!0,style:{width:"116px"},suppressActiveHighlight:!0,attributes:{ariaLabel:"Font family"},options:g,onActivate:({fontFamily:st}={},_t=!1)=>{if(_t){m.label.value="",m.selectedValue.value="";return}if(!st)return;st=st.split(",")[0];const gt=Te=>Te.value??Te.label,Xt=g.find(Te=>gt(Te)===m.defaultLabel.value),gn=g.find(Te=>gt(Te)===st);gn?(m.label.value=gn.label,m.selectedValue.value=gn.key):Xt?(m.label.value=st,m.selectedValue.value=Xt.key):(m.label.value=st,m.selectedValue.value="")},onDeactivate:()=>{const st=g.find(_t=>(_t.value??_t.label)===m.defaultLabel.value);m.label.value=st?.label??m.defaultLabel.value,m.selectedValue.value=st?.key??""}}),v=xn({type:"dropdown",name:"ai",dropdownStyles:{padding:0,outline:"none"},tooltip:n.ai,icon:t.ai,hideLabel:!0,hasCaret:!1,isWide:!0,suppressActiveHighlight:!0,attributes:{ariaLabel:"AI"},options:[{type:"render",key:"ai",render:()=>C(v)}]});function C(st){const _t=j1(e),gt=_t?.selectionTarget??NE(_t?.target),Xt=_t?.empty?"":eK(_t),gn=nK(e),Te=()=>Ki(st),Ne=()=>{const Qe=e.pendingSelectionCapture;Qe&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(Qe)};return Dr("div",{},[Dr(tW,{handleClose:Te,selectedText:Xt,target:gt,doc:e.superdoc?.activeEditor?.doc??null,apiKey:gn?.apiKey||e.config?.aiApiKey||"",endpoint:gn?.endpoint||e.config?.aiEndpoint||"",restoreSelection:Ne})])}const w=SG,S=xn({type:"dropdown",name:"fontSize",defaultLabel:"12",label:"12",style:{width:"56px"},markName:"textStyle",labelAttr:"fontSize",tooltip:n.fontSize,hasCaret:!0,hasInlineTextInput:!0,inlineTextInputVisible:!0,suppressActiveHighlight:!0,isWide:!0,command:"setFontSize",attributes:{ariaLabel:"Font size"},options:w,onActivate:({fontSize:st},_t=!1)=>{if(_t){S.label.value="",S.selectedValue.value="";return}const gt=w.find(Ne=>Ne.label===String(S.defaultLabel.value));if(!st){S.label.value=S.defaultLabel.value,gt?S.selectedValue.value=gt.key:S.selectedValue.value="";return}let Xt=gH(st,12);Xt<8&&(Xt=8),Xt>96&&(Xt=96);let gn=String(Xt);const Te=w.find(Ne=>Ne.label===gn||Ne.key===gn);Te?S.selectedValue.value=Te.key:S.selectedValue.value="",S.label.value=gn},onDeactivate:()=>{S.label.value=S.defaultLabel.value;const st=w.find(_t=>_t.label===String(S.defaultLabel.value));st?S.selectedValue.value=st.key:S.selectedValue.value=""}}),b=()=>xn({type:"separator",name:"separator",isNarrow:!0}),k=xn({type:"button",name:"italic",command:"toggleItalic",icon:t.italic,active:!1,tooltip:n.italic,attributes:{ariaLabel:"Italic"}}),x=xn({type:"button",name:"underline",command:"toggleUnderline",icon:t.underline,active:!1,tooltip:n.underline,attributes:{ariaLabel:"Underline"}}),M=xn({type:"button",name:"strike",command:"toggleStrike",icon:t.strikethrough,active:!1,tooltip:n.strikethrough,attributes:{ariaLabel:"Strikethrough"}}),z=xn({type:"dropdown",name:"highlight",icon:t.highlight,hideLabel:!0,markName:"highlight",labelAttr:"color",active:!1,tooltip:n.highlight,command:"setHighlight",noArgumentCommand:"unsetHighlight",suppressActiveHighlight:!0,attributes:{ariaLabel:"Highlight"},options:[{key:"color",type:"render",render:()=>F1(e,z,[],!0)}],onActivate:({color:st})=>{z.iconColor.value=st||""},onDeactivate:()=>z.iconColor.value=""}),G=xn({type:"dropdown",name:"color",icon:t.color,hideLabel:!0,markName:"textStyle",labelAttr:"color",active:!1,tooltip:n.color,command:"setColor",suppressActiveHighlight:!0,attributes:{ariaLabel:"Color"},options:[{key:"color",type:"render",render:()=>F1(e,G)}],onActivate:({color:st})=>{G.iconColor.value=st},onDeactivate:()=>G.iconColor.value="#000"}),F=xn({type:"button",name:"search",allowWithoutEditor:!0,active:!1,icon:t.search,tooltip:n.search,group:"right",attributes:{ariaLabel:"Search"}}),L=xn({type:"dropdown",name:"link",markName:"link",icon:t.link,active:!1,tooltip:n.link,attributes:{ariaLabel:"Link dropdown"},options:[{type:"render",key:"linkDropdown",render:()=>$(L)}],onActivate:({href:st})=>{L.attributes.value=z1(L.attributes.value,st)},onDeactivate:()=>{L.attributes.value=z1(L.attributes.value,null),L.expand.value=!1}});function $(st){const _t=j1(e),gt=_t?.selectionTarget??NE(_t?.target),Xt=()=>{const gn=e.pendingSelectionCapture;gn&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(gn)};return Dr("div",{},[Dr(t4,{ui:e.ui,linkItem:st,textTarget:gt,restoreSelection:Xt,closePopover:()=>{Ki(st),Kl(e)},goToAnchor:()=>{Ki(st);const gn=st.attributes.value?.href;if(!gn)return;const Te=gn.slice(1),Ne=(e.ui?.viewport?.getHost?.()??null)?.querySelector?.(`a[name='${Te}']`);Ne&&n4(Ne)}})])}const T=xn({type:"options",name:"linkInput",command:"toggleLink",active:!1});L.childItem=T,T.parentItem=L;const H=xn({type:"button",name:"image",command:"startImageUpload",icon:t.image,active:!1,tooltip:n.image,disabled:!1,attributes:{ariaLabel:"Image"}}),R=xn({type:"button",name:"tableOfContents",command:"insertTableOfContents",icon:t.tableOfContents,active:!1,tooltip:n.tableOfContents,disabled:!1,attributes:{ariaLabel:"Table of contents"}}),U=xn({type:"button",name:"watermark",icon:t.watermark,tooltip:n.watermark,allowWithoutEditor:!0,disabled:!0,attributes:{ariaLabel:n.watermark}}),W=xn({type:"dropdown",name:"pageNumber",icon:t.pageNumber,hideLabel:!0,tooltip:n.pageNumber,disabled:!0,suppressActiveHighlight:!0,attributes:{ariaLabel:n.pageNumber},options:[{key:"pageNumber",type:"render",label:"Page number options",render:()=>J(W)}]});let ee=null;function J(st){const _t=e.ui,gt=Ne=>_t?.commands?.get?.(Ne)?.getState?.()??null,Xt=()=>{Ki(st),Le.expand.value&&Ki(Le),Kl(e)},gn=j1(e),Te=gn?.selectionTarget?.story??gn?.selectionTarget?.start?.story??gn?.target?.story??null;return Dr(YW,{pageNumbersState:gt("page-numbers-apply"),atCursorState:gt("page-number-insert"),inHeaderFooter:Te?.storyType==="headerFooterPart"||Te?.storyType==="headerFooterSlot",suggesting:_t?.document?.getSnapshot?.()?.mode==="suggesting",initialChoice:ee,loadCurrent:()=>_t?_O(_t):Promise.resolve(null),applyPageNumbers:Ne=>id(_t,"page-numbers-apply",Ne),removePageNumbers:()=>id(_t,"page-numbers-remove"),insertAtCursor:()=>id(_t,"page-number-insert"),close:Ne=>{Xt();const Qe=_t?.viewport?.getHost?.();if(Ne?.action==="apply")ee=Ne.choice,OE(Qe,Ne.choice.position==="top"?"header":"footer");else if(Ne?.action==="remove")for(const bt of new Set(Ne.kinds))OE(Qe,bt)}})}const Z=xn({type:"dropdown",name:"table",icon:t.table,hideLabel:!0,labelAttr:"table",active:!1,tooltip:n.table,command:"insertTable",suppressActiveHighlight:!0,attributes:{ariaLabel:"Table"},options:[{key:"table",type:"render",render:()=>Me(Z)}]});function Me(st){return Dr("div",{},[Dr(vW,{onSelect:gt=>{e.emitCommand({item:st,argument:gt}),Ki(st),Kl(e)}})])}const fe=xn({type:"dropdown",name:"tableActions",command:"executeTableCommand",tooltip:n.tableActions,icon:t.tableActions,hideLabel:!0,disabled:!0,attributes:{ariaLabel:"Table actions"},options:[{type:"render",render:()=>ve(fe)}]}),ye=[{label:n.addRowBefore,command:"addRowBefore",icon:t.addRowBefore,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add row before"}},{label:n.addRowAfter,command:"addRowAfter",icon:t.addRowAfter,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add row after"}},{label:n.addColumnBefore,command:"addColumnBefore",icon:t.addColumnBefore,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add column before"}},{label:n.addColumnAfter,command:"addColumnAfter",icon:t.addColumnAfter,bottomBorder:!0,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add column after"}},{label:n.deleteRow,command:"deleteRow",icon:t.deleteRow,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete row"}},{label:n.deleteColumn,command:"deleteColumn",icon:t.deleteColumn,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete column"}},{label:n.deleteTable,command:"deleteTable",icon:t.deleteTable,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete table"}},{label:n.removeBorders,command:"deleteCellAndTableBorders",icon:t.deleteBorders,bottomBorder:!0,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete cell and table borders"}},{label:n.mergeCells,command:"mergeCells",icon:t.mergeCells,props:{"data-item":"btn-tableActions-option",ariaLabel:"Merge cells"}},{label:n.splitCell,command:"splitCell",icon:t.splitCell,props:{"data-item":"btn-tableActions-option",ariaLabel:"Split cells"}},{label:n.fixTables,command:"fixTables",icon:t.fixTables,props:{"data-item":"btn-tableActions-option",ariaLabel:"Fix tables"}}];function ve(st){return Dr(_W,{options:ye,onSelect:_t=>{Ki(st);const{command:gt}=_t;e.emitCommand({item:st,argument:{command:gt}}),Kl(e)}})}const Pe=xn({type:"dropdown",name:"textAlign",tooltip:n.textAlign,icon:t.alignLeft,command:"setTextAlign",hasCaret:!0,markName:"textAlign",labelAttr:"textAlign",suppressActiveHighlight:!0,attributes:{ariaLabel:"Text align"},options:[{type:"render",render:()=>Dr("div",{},[Dr(MG,{onSelect:_t=>{Ki(Pe);const gt={...Pe,command:"setTextAlign"};gt.command="setTextAlign",e.emitCommand({item:gt,argument:_t}),Ve(Pe,_t),Kl(e)}})]),key:"alignment"}],onActivate:({textAlign:st})=>{Ve(Pe,st)},onDeactivate:()=>{Ve(Pe,"left")}}),Ve=(st,_t)=>{let gt=_t==="both"?"justify":_t,Xt={left:t.alignLeft,right:t.alignRight,center:t.alignCenter,justify:t.alignJustify},gn=Xt[gt]??Xt.left;st.icon.value=gn},nt=xn({type:"dropdown",name:"list",command:"toggleBulletListStyle",splitButton:!0,splitButtonCommand:"toggleBulletList",icon:t.bulletList,hasCaret:!0,tooltip:n.bulletList,restoreEditorFocus:!0,attributes:{ariaLabel:"Bullet list"},options:[{type:"render",key:"bullet-style-buttons",render:()=>{const st=_t=>{Ki(nt);const gt={...nt,command:"toggleBulletListStyle"};e.emitCommand({item:gt,argument:_t})};return Dr(LE,{buttons:DG,iconSize:25,selectedStyle:nt.selectedValue.value,onSelect:st})}}]}),ct=xn({type:"dropdown",name:"numberedlist",command:"toggleOrderedListStyle",splitButton:!0,splitButtonCommand:"toggleOrderedList",icon:t.numberedList,hasCaret:!0,tooltip:n.numberedList,restoreEditorFocus:!0,attributes:{ariaLabel:"Numbered list"},options:[{type:"render",key:"numbered-style-buttons",render:()=>{const st=_t=>{Ki(ct);const gt={...ct,command:"toggleOrderedListStyle"};e.emitCommand({item:gt,argument:_t})};return Dr(LE,{buttons:OG,iconSize:30,selectedStyle:ct.selectedValue.value,onSelect:st})}}]}),ft=xn({type:"button",name:"indentleft",command:"decreaseTextIndent",icon:t.indentLeft,active:!1,tooltip:n.indentLeft,disabled:!1,attributes:{ariaLabel:"Left indent"}}),It=xn({type:"button",name:"indentright",command:"increaseTextIndent",icon:t.indentRight,active:!1,tooltip:n.indentRight,disabled:!1,attributes:{ariaLabel:"Right indent"}}),Le=xn({type:"overflow",name:"overflow",command:null,icon:t.overflow,active:!1,disabled:!1,attributes:{ariaLabel:"Overflow items"}}),oe=xn({type:"dropdown",name:"zoom",allowWithoutEditor:!0,tooltip:n.zoom,defaultLabel:"100%",label:"100%",hasCaret:!0,command:"setZoom",isWide:!0,style:{width:"71px",minWidth:"71px"},inlineTextInputVisible:!1,hasInlineTextInput:!0,attributes:{ariaLabel:"Zoom"},options:[{label:"50%",key:.5,props:{"data-item":"btn-zoom-option"}},{label:"75%",key:.75,props:{"data-item":"btn-zoom-option"}},{label:"90%",key:.9,props:{"data-item":"btn-zoom-option"}},{label:"100%",key:1,props:{"data-item":"btn-zoom-option"}},{label:"125%",key:1.25,props:{"data-item":"btn-zoom-option"}},{label:"150%",key:1.5,props:{"data-item":"btn-zoom-option"}},{label:"200%",key:2,props:{"data-item":"btn-zoom-option"}}],onActivate:({zoom:st})=>{st&&(oe.label.value=st)}}),we=xn({type:"dropdown",name:"measurementUnit",allowWithoutEditor:!0,tooltip:n.measurementUnit,defaultLabel:"in",label:"in",hasCaret:!0,command:"setMeasurementUnit",group:"right",style:{width:"52px",minWidth:"52px"},inlineTextInputVisible:!1,hasInlineTextInput:!1,attributes:{ariaLabel:"Measurement unit"},options:[{label:"Inches",key:"in",props:{"data-item":"btn-measurement-unit-option"}},{label:"Centimeters",key:"cm",props:{"data-item":"btn-measurement-unit-option"}}],onActivate:({measurementUnit:st})=>{st&&(we.label.value=st)}}),Q=xn({type:"button",name:"undo",disabled:!0,tooltip:n.undo,command:"undo",icon:t.undo,group:"left",attributes:{ariaLabel:"Undo"}}),I=xn({type:"button",disabled:!0,name:"redo",tooltip:n.redo,command:"redo",icon:t.redo,group:"left",attributes:{ariaLabel:"Redo"}}),re=xn({type:"button",disabled:!1,name:"acceptTrackedChangeBySelection",tooltip:n.trackChangesAccept,command:"acceptTrackedChangeFromToolbar",icon:t.trackChangesAccept,group:"left",attributes:{ariaLabel:"Accept tracked changes"}}),j=xn({type:"button",disabled:!1,name:"rejectTrackedChangeOnSelection",tooltip:n.trackChangesReject,command:"rejectTrackedChangeFromToolbar",icon:t.trackChangesReject,group:"left",attributes:{ariaLabel:"Reject tracked changes"}}),X=xn({type:"button",name:"clearFormatting",command:"clearFormat",tooltip:n.clearFormatting,icon:t.clearFormatting,attributes:{ariaLabel:"Clear formatting"}}),K=xn({type:"button",name:"copyFormat",tooltip:n.copyFormat,icon:t.copyFormat,command:"copyFormat",active:!1,attributes:{ariaLabel:"Copy formatting"}}),ae=(st,_t)=>st==="editor"?_t:st==="suggester"?_t.filter(gt=>gt.value==="suggesting"):_t.filter(gt=>gt.value==="viewing"),ke=st=>st==="editor"?"Editing":st==="suggester"?"Suggesting":"Viewing",P=xn({type:"dropdown",name:"documentMode",command:"setDocumentMode",allowWithoutEditor:!0,icon:t.documentMode,defaultLabel:ke(s),label:ke(s),hasCaret:s==="editor",isWide:!0,style:{display:"flex",justifyContent:"flex-end"},inlineTextInputVisible:!1,hasInlineTextInput:!1,group:"right",disabled:s!=="editor",attributes:{dropdownPosition:"right",className:"sd-toolbar-item--doc-mode",ariaLabel:"Document mode"},options:[{type:"render",render:()=>me(P)}]}),N=[{label:n.documentEditingMode,value:"editing",icon:t.documentEditingMode,description:n.documentEditingModeDescription},{label:n.documentSuggestingMode,value:"suggesting",icon:t.documentSuggestingMode,description:n.documentSuggestingModeDescription},{label:n.documentViewingMode,value:"viewing",icon:t.documentViewingMode,description:n.documentViewingModeDescription}];function me(st){return Dr($G,{options:ae(s,N),onSelect:_t=>{const gt=e.superdoc?.activeEditor??e.activeEditor;Ki(st);const{label:Xt,icon:gn,value:Te}=_t;P.label.value=Xt,P.icon.value=gn,e.emitCommand({item:P,argument:Te}),Kl(e,gt)}})}const Se=new Map([["separator",20],["zoom",71],["measurementUnit",52],["fontFamily",118],["fontSize",57],["textAlign",40],["linkedStyles",142],["documentMode",47],["default",32]]),Re=["search","ruler","undo","overflow","documentMode"],ze=xn({type:"button",name:"ruler",command:"toggleRuler",allowWithoutEditor:!0,icon:t.ruler,active:!1,tooltip:n.ruler,attributes:{ariaLabel:"Ruler"}}),Ke=xn({type:"button",name:"formattingMarks",command:"toggleFormattingMarks",allowWithoutEditor:!0,icon:t.formattingMarks,active:!1,tooltip:n.formattingMarks,attributes:{ariaLabel:"Formatting marks"}}),ot=xn({type:"dropdown",name:"linkedStyles",command:"setLinkedStyle",tooltip:n.linkedStyles,icon:t.paintbrush,defaultLabel:n.formatText,label:n.formatText,hasCaret:!0,isWide:!0,style:{width:"140px"},suppressActiveHighlight:!0,disabled:!1,attributes:{className:"sd-toolbar-item--linked-styles",ariaLabel:"Linked styles"},options:[{type:"render",key:"linkedStyle",render:()=>{const st=gt=>{Ki(ot);const Xt=typeof gt=="string"?gt:gt?.id??null;if(!Xt)return;const gn={...ot,command:"setLinkedStyle"};e.emitCommand({item:gn,argument:Xt})},_t=e.getActiveLinkedStyleId?.()??null;return Dr("div",{},[Dr(KG,{styles:e.getLinkedStyleOptions?.()??[],onSelect:st,selectedOption:_t})])}}],onActivate:({styleId:st,styleName:_t})=>{const gt=_t||st;ot.label.value=st&&st!=="Normal"?String(gt):n.formatText,ot.disabled.value=!1},onDeactivate:()=>{ot.disabled.value=!0,ot.label.value=n.formatText}}),mt=(st,_t)=>{if(_t.value==st)return Dr("div",{innerHTML:ZW,class:"dropdown-select-icon"})},Ot=xn({type:"dropdown",name:"lineHeight",tooltip:n.lineHeight,icon:t.lineHeight,hasCaret:!1,hasInlineTextInput:!1,hideLabel:!0,inlineTextInputVisible:!1,suppressActiveHighlight:!0,restoreEditorFocus:!0,isWide:!1,command:"setLineHeight",dropdownValueKey:"key",selectedValue:"1",attributes:{ariaLabel:"Line height"},options:[1,1.15,1.5,2,2.5,3].map(st=>({label:st.toFixed(2),key:st,icon:()=>mt(st,Ot.selectedValue),props:{"data-item":"btn-lineHeight-option"}}))}),Mt=20,Kt=32,$e=["linkedStyles","clearFormatting","copyFormat","formattingMarks"],Qt=["zoom","fontFamily","fontSize","redo"],Hn=i<=Eh.lg,qt=e.config?.showFormattingMarksButton===!0,jn=e.config?.showTableOfContentsButton===!0;Hn&&(P.attributes.value={...P.attributes.value,className:`${P.attributes.value.className} sd-toolbar-item--doc-mode-compact`}),Hn&&(ot.attributes.value={...ot.attributes.value,className:`${ot.attributes.value.className} sd-toolbar-item--linked-styles-compact`});let Pn=[Q,I,re,j,F,oe,m,b(),S,b(),p,k,x,M,G,z,b(),L,H,...jn?[R]:[],...e.config?.showWatermarkButton||l?.has("watermark")?[U]:[],...e.config?.showPageNumberButton||l?.has("pageNumber")?[W]:[],Z,fe,b(),Pe,nt,ct,ft,It,Ot,b(),ot,b(),ze,we,...qt?[Ke]:[],K,X,...tK(e)?[v]:[],Le,P,...f];if(i<=Eh.md&&o&&(Pn=Pn.filter(st=>st.type!=="separator")),e.config.mode!=="docx"){const st=Pn.findIndex(gt=>gt.name.value==="linkedStyles");Pn.splice(st-1,2);const _t=["ruler","zoom","undo","redo"];Pn=Pn.filter(gt=>!_t.includes(gt.name.value))}const $r=[];a||(s==="viewer"&&$r.push(re,j),Pn=Pn.filter(st=>!$r.includes(st))),l&&(Pn=Pn.filter(st=>st.name.value==="overflow"||st.isCustomToolbarItem||l.has(st.name.value))),d?.size&&(Pn=Pn.filter(st=>!d.has(st.name.value))),Pn=JW(Pn);const Nr=st=>Re.includes(st.name.value),_r=Pn.find(st=>st.name.value==="overflow"),Tn=Pn.filter(st=>st!==_r);if(u){const st=new Map(u.map((gt,Xt)=>[gt,Xt])),_t=gt=>st.get(gt.name.value)??Number.MAX_SAFE_INTEGER;Tn.sort((gt,Xt)=>_t(gt)-_t(Xt))}const tr=st=>{const _t=[],gt=[],Xt=Tn.filter(Nr).reduce((Te,Ne)=>Te+B1(Ne,Se),0);let gn=Kt+Xt+(st&&_r?B1(_r,Se):0);return Tn.forEach((Te,Ne)=>{const Qe=B1(Te,Se);if(Te.type==="separator"&&Tn[Ne-1]?.name.value==="linkedStyles"&&_t.includes(Tn[Ne-1])){_t.push(Te);return}if(i<Eh.xl+Mt&&$e.includes(Te.name.value)&&o){_t.push(Te);return}if(i<Eh.sm&&Qt.includes(Te.name.value)&&o){_t.push(Te);return}if(Nr(Te)){gt.push(Te);return}gn+Qe<=i||!o?(gt.push(Te),gn+=Qe):_t.push(Te)}),{visibleItems:gt,overflowItems:_t}};let{visibleItems:qn,overflowItems:Bn}=tr(!1);if(o&&_r&&Bn.some(st=>st.type!=="separator")){({visibleItems:qn,overflowItems:Bn}=tr(!0));const st=Pn.indexOf(_r),_t=qn.findIndex(gt=>Pn.indexOf(gt)>st);_t===-1?qn.push(_r):qn.splice(_t,0,_r)}return qn=FE(qn),{defaultItems:qn,overflowItems:Bn.filter(st=>st.type!=="separator")}},BE={bold:"Bold",fontFamily:"Font family",ai:"AI text generation",fontSize:"Font size",italic:"Italic",underline:"Underline",highlight:"Highlight color",strikethrough:"Strikethrough",color:"Text color",search:"Search",link:"Link",image:"Image",tableOfContents:"Table of contents",watermark:"Watermark",pageNumber:"Page number",table:"Insert table",tableActions:"Table options",addRowBefore:"Insert row above",addRowAfter:"Insert row below",addColumnBefore:"Insert column left",addColumnAfter:"Insert column right",deleteRow:"Delete row",deleteColumn:"Delete column",deleteTable:"Delete table",removeBorders:"Remove borders",mergeCells:"Merge cells",splitCell:"Split cell",fixTables:"Fix tables",textAlign:"Alignment",bulletList:"Bullet list",numberedList:"Numbered list",indentLeft:"Left indent",indentRight:"Right indent",directionLtr:"Left-to-right",directionRtl:"Right-to-left",zoom:"Zoom",measurementUnit:"Measurement unit",undo:"Undo",redo:"Redo",trackChanges:"Track Changes",trackChangesAccept:"Accept changes under selection",trackChangesReject:"Reject changes under selection",trackChangesOriginal:"Toggle Show Original",trackChangesFinal:"Toggle Show Final",clearFormatting:"Clear formatting",copyFormat:"Format painter",lineHeight:"Line height",formatText:"Format text",ruler:"Show or hide ruler",formattingMarks:"Show or hide formatting marks",pageBreak:"Insert page break",documentEditingMode:"Editing",documentSuggestingMode:"Suggesting",documentViewingMode:"Viewing",documentEditingModeDescription:"Edit document directly",documentSuggestingModeDescription:"Edits become suggestions",documentViewingModeDescription:"View clean version of document only",linkedStyles:"Linked styles"},oK=e=>e?typeof e!="string"?e instanceof HTMLElement?e:null:e.startsWith("#")||e.startsWith(".")?document.querySelector(e):document.getElementById(e):null;Ft();function zE(e){return mH(e)??O1[e]??null}function Ag(e,t,n,r={}){if(!e?.commands||!t||typeof e.commands.has=="function"&&!e.commands.has(t))return!1;const o=typeof e.commands.executeAsync=="function"?e.commands.executeAsync:e.commands.execute;if(typeof o!="function")return!1;const i=r.firstParty?id(e,t,n):n===void 0?o.call(e.commands,t):o.call(e.commands,t,n),s=a=>{!r.reportUnhandled||a!==!1||r.onError?.(new Error(`[superdoc toolbar] Command "${t}" did not run. Check that it is enabled and has the required input.`))};return i&&typeof i.then=="function"?Promise.resolve(i).then(a=>{s(a),r.onSettled?.()},a=>{r.onError?.(a),r.onSettled?.()}):(s(i),r.onSettled?.()),!0}var iK=["page-numbers-apply","page-number-insert"],sK=new Set(["bold","italic","underline","strike","color","highlight","link","clearFormatting","textAlign","list","numberedlist","indentleft","indentright","lineHeight","linkedStyles"]),aK=new Set(["list","numberedlist"]);function lK(e,t){if(e==="fontFamily"||e==="fontSize"||aK.has(e)&&t?.disabled&&t?.supported!==!1&&t?.reason==null)return!0;if(!sK.has(e))return!1;const n=t?.reason;return n==="range-selection-required"||n==="selection-required"}function jE(e){return!!e?.closest?.("[data-editor-ui-surface], .toolbar-dropdown-menu, .sd-toolbar-dropdown-menu, .sd-tooltip-content")}function cK(e){return["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key)}var uK=new Set([...pH,...Object.keys(gg),"ai","overflow","tableOfContents"]),dK=class extends av.default{config={selector:null,toolbarGroups:["left","center","right"],role:"editor",icons:{...dr},texts:{...BE},fonts:null,hideButtons:!0,responsiveToContainer:!1,mode:"docx",excludeItems:[],toolbarButtonsExclude:[],groups:null,customButtons:[],showFormattingMarksButton:!1,showTableOfContentsButton:!1,showWatermarkButton:!1,showPageNumberButton:!1};toolbarItems=[];overflowItems=[];#e=null;#n=null;isDev=!1;role="editor";superdoc;toolbarContainer=null;toolbar=null;_detachFontsChanged=null;_linkedStyleOptions=Pr([]);constructor(e={}){if(super(),this.config={...this.config,...e},this.toolbarItems=[],this.overflowItems=[],this.isDev=e.isDev||!1,this.superdoc=e.superdoc,this.role=e.role||"editor",this.toolbarContainer=null,this.config.icons={...dr,...e.icons},this.config.texts={...BE,...e.texts},this.config.hideButtons=e.hideButtons??!0,this.config.responsiveToContainer=e.responsiveToContainer??!1,this.activeEditor=e.editor??this.superdoc?.activeEditor??null,this.ui=null,this.snapshot=null,this._unsubscribeController=null,this._detachFormatPainterModeChange=null,this._customCommandRegs=new Map,this._reportedInvalidCustomItems=new Set,this._lastFontOptionsSignature="",!this.config.selector&&this.config.element&&(this.config.selector=this.config.element),this.toolbarContainer=oK(this.config.selector),this.toolbarContainer){const t=(this.config?.uiDisplayFallbackFont||"").toString().trim()||"Arial, Helvetica, sans-serif";this.toolbarContainer.style.setProperty("--sd-ui-font-family",t)}try{if(this.#t(),this.#u(),this.#c(),this.#i(),this._lastFontOptionsSignature=this.#r(),!this.toolbarContainer){this.updateToolbarState();return}this.app=Ac(EG),this.app.directive("click-outside",cb),this.app.config.globalProperties.$toolbar=this,this.toolbar=this.app.mount(this.toolbarContainer),this.updateToolbarState()}catch(t){try{this.destroy()}catch{}throw t}}#t(){this.ui=this.superdoc?.ui??null,this.ui&&(this.snapshot=this.ui.toolbar.getSnapshot(),this._unsubscribeController=this.ui.toolbar.subscribe(()=>{this.snapshot=this.ui.toolbar.getSnapshot(),this.getToolbarItemByName("linkedStyles")?.expand.value&&this.#m(),this.updateToolbarState()}),this._detachFormatPainterModeChange=this.ui.formatPainter.onModeChange(e=>{e==="armed"||e==="persistent"?this.#w():this.#y()}))}#o(){this._unsubscribeController?.(),this._unsubscribeController=null,this._detachFormatPainterModeChange?.(),this._detachFormatPainterModeChange=null,this.#y();for(const e of this._customCommandRegs.values())try{e.unregister?.()}catch{}this._customCommandRegs.clear(),this.ui=null,this.snapshot=null}#i(){if(!this.superdoc||typeof this.superdoc.on!="function"||typeof this.superdoc.off!="function")return;const e=()=>{const t=this.#r();t!==this._lastFontOptionsSignature&&(this._lastFontOptionsSignature=t,this.#p()),this.updateToolbarState()};this.superdoc.on("fonts-changed",e),this._detachFontsChanged=()=>{this.superdoc?.off?.("fonts-changed",e)}}#a(){this._detachFontsChanged?.(),this._detachFontsChanged=null}#u(){if(Array.isArray(this.config.groups)){this.config.toolbarGroups=this.config.groups,this.config.groups=null;return}this.config.groups&&!Array.isArray(this.config.groups)&&Object.keys(this.config.groups).length&&(this.config.toolbarGroups=Object.keys(this.config.groups))}getAvailableWidth(){const e=document.documentElement.clientWidth,t=this.toolbarContainer?.offsetWidth??0;return this.config.responsiveToContainer?t:e}#f(e){return e||kG(this.superdoc?.fonts?.getFontFamilyOptions?.()??[])}#c(){const e=this.getAvailableWidth(),t=new Map(this.#s().filter(C=>C.isCustomToolbarItem&&C.type==="dropdown").map(C=>[C.name.value,C.selectedValue.value])),n=this.config.groups&&!Array.isArray(this.config.groups)&&Object.keys(this.config.groups).length>0,r=n?new Set(Object.values(this.config.groups).flatMap(C=>C)):null,o=new Set([...this.config.excludeItems??[],...this.config.toolbarButtonsExclude??[]]),i=this.config.customButtons||[],s=new Set(uK),a=i.map((C,w)=>{try{if(C?.name&&s.has(C.name))throw new Error(`Toolbar item name "${C.name}" is already taken by another item, so this entry is skipped.`);const S=this.#d(C);return t.has(S.name.value)&&(S.selectedValue.value=t.get(S.name.value)),s.add(S.name?.value),S}catch(S){const b=`${C?.name??`<unnamed@${w}>`}::${S?.message??String(S)}`;return this._reportedInvalidCustomItems.has(b)||(this._reportedInvalidCustomItems.add(b),this.#v(S,C?.name??null)),null}}).filter(Boolean),l=n?new Set(Object.keys(this.config.groups)):null,u=l?a.filter(C=>l.has(C.group?.value||"center")):a;let d=null;if(n){const C=Object.values(this.config.groups).flatMap(S=>S),w=a.filter(S=>l.has(S.group?.value||"center")).map(S=>S.name.value);d=[...new Set([...C,...w])]}const{defaultItems:f,overflowItems:p}=rK({superToolbar:this,toolbarIcons:this.config.icons,toolbarTexts:this.config.texts,toolbarFonts:this.#f(this.config.fonts),hideButtons:this.config.hideButtons,availableWidth:e,role:this.role,isDev:this.isDev,configuredItemNames:r,configuredItemOrder:d,excludedItemNames:o,additionalItems:u});n||(d=[...f.map(C=>C.name.value),...p.map(C=>C.name.value)]);const g=p.filter(C=>d.includes(C.name.value)&&!o.has(C.name.value)),m=g.length?[...d,"overflow"]:d,v=f.filter(C=>m.includes(C.name.value)).filter(C=>!o.has(C.name.value));if(n){const C=new Map(d.map((x,M)=>[x,M])),w=x=>C.get(x.name.value)??Number.MAX_SAFE_INTEGER,S=v.find(x=>x.name.value==="overflow"),b=new Map(v.map((x,M)=>[x,M])),k=v.filter(x=>x!==S);if(k.sort((x,M)=>w(x)-w(M)),S){const x=b.get(S),M=k.findIndex(z=>b.get(z)>x);M===-1?k.push(S):k.splice(M,0,S)}v.splice(0,v.length,...k),g.sort((x,M)=>w(x)-w(M))}if(n)for(const[C,w]of Object.entries(this.config.groups))for(const S of v)w.includes(S.name.value)&&(S.group.value=C);this.toolbarItems=v,this.overflowItems=g}#d(e){const t=xn({...e});t.isCustomToolbarItem=!0;const n=e.command;if(typeof n=="function"&&this.ui?.commands?.register){const r=`__builtin_toolbar__${e.name}`;if(!this._customCommandRegs.has(r)){const o=this.ui.commands.register({id:r,execute:i=>{const s=i?.payload&&typeof i.payload=="object"?i.payload:{};try{const a=n({...i,item:t,argument:s.argument,option:s.option});return a&&typeof a.then=="function"?Promise.resolve(a).catch(l=>(this.#v(l,e.name),!1)):a}catch(a){return this.#v(a,e.name),!1}}});this._customCommandRegs.set(r,o)}}return t}#p(){this.#c(),this.emit("toolbar-items-changed")}#r(){if(this.config.fonts)return"custom-fonts";const e=this.superdoc?.fonts?.getFontFamilyOptions?.()??[];return JSON.stringify(e.map(t=>[t.label,t.value,t.previewFamily]))}getToolbarItemByGroup(e){return this.toolbarItems.filter(t=>(t.group?.value||"center")===e)}getToolbarItemByName(e){return this.#s().find(t=>t.name.value===e)}#s(){return[...this.toolbarItems,...this.overflowItems]}getLinkedStyleOptions(){return this.#m(),this._linkedStyleOptions.value}#m(){this.ui?.styles?.getCatalog?.({includePreview:!0});const e=this.ui?.styles?.getCatalog?.({view:"quickGallery",includePreview:!0})?.items??this.ui?.styles?.getQuickGallery?.()??[];e!==this._linkedStyleOptions.value&&(this._linkedStyleOptions.value=e)}getActiveLinkedStyleId(){return this.ui?.styles?.getActiveParagraphStyle?.()?.styleId??null}setActiveEditor(e){this.activeEditor=e;const t=this.#r();t!==this._lastFontOptionsSignature&&(this._lastFontOptionsSignature=t,this.#p()),this.ui&&(this.snapshot=this.ui.toolbar.getSnapshot()),this.updateToolbarState()}onToolbarResize=()=>{this.#c(),this.updateToolbarState()};#_(e){return e==="ruler"?!!this.superdoc?.config?.rulers:e==="formattingMarks"?!!this.superdoc?.config?.layoutEngineOptions?.showFormattingMarks:!1}#k(e){return e==="watermark"?this.ui?.document?.getSnapshot?.().ready===!0&&typeof this.ui?.watermark?.open=="function":e==="ruler"?typeof this.superdoc?.toggleRuler=="function":e==="formattingMarks"?typeof this.superdoc?.toggleFormattingMarks=="function"||typeof this.superdoc?.setShowFormattingMarks=="function":!1}#g(){const e=this.getToolbarItemByName("documentMode");if(!e)return;const t=(this.snapshot?.commands?.["document-mode"]?.value||"editing").toLowerCase(),n=this.config.texts||{},r=this.config.icons||{},o={editing:{label:n.documentEditingMode||"Editing",icon:r.documentEditingMode||r.documentMode},suggesting:{label:n.documentSuggestingMode||"Suggesting",icon:r.documentSuggestingMode||r.documentMode},viewing:{label:n.documentViewingMode||"Viewing",icon:r.documentViewingMode||r.documentMode}},i=o[t]||o.editing;e.label?.value!==void 0&&(e.label.value=i.label),e.defaultLabel?.value!==void 0&&(e.defaultLabel.value=i.label),e.icon?.value!==void 0&&i.icon&&(e.icon.value=i.icon)}#b(){const e=this.toolbarItems.find(n=>n.name.value==="highlight");if(!e)return;const t={key:"color",type:"render",render:()=>F1(this,e,[],!0)};e.nestedOptions.value=[t]}#A(e){return!!e?.active&&e?.value==null}#x(e){return!!e&&e.disabled===!1&&e.value==null}#I(e){const t=e.name.value;if(e.isCustomToolbarItem&&typeof e.command=="string"){const i=this.snapshot?.commands?.[e.command];return e.setDisabled(e.initiallyDisabled||!i||!!i.disabled),i?.active?e.activate():e.deactivate(),!0}if(t==="tableActions"){const i=ME.map(s=>this.snapshot?.commands?.[s]).some(s=>s&&!s.disabled);return e.setDisabled(!i),!0}if(t==="search")return e.setDisabled(this.superdoc?.uiConfig?.search?.enabled!==!0),!0;if(t==="pageNumber"){const i=iK.map(a=>this.snapshot?.commands?.[a]),s=this.ui?.document?.getSnapshot?.()?.mode==="suggesting";return e.setDisabled(!s&&!i.some(a=>a&&!a.disabled)),!0}if(P1(t)?.disposition==="host-routed")return e.setDisabled(!this.#k(t)),this.#_(t)?e.activate():e.deactivate(),!0;const n=zE(t);if(!n)return!1;const r=this.snapshot?.commands?.[n];lK(t,r)?e.setDisabled(!1):e.setDisabled(!!r?.disabled);const o={textAlign:()=>{r?.value?e.activate({textAlign:r.value}):e.deactivate()},lineHeight:()=>{e.selectedValue.value=r?.value!=null?r.value:""},zoom:()=>{if(r?.value!=null){const i=typeof r.value=="number"?`${r.value}%`:String(r.value);e.onActivate({zoom:i})}},measurementUnit:()=>{r?.value!=null&&e.onActivate({measurementUnit:String(r.value)})},documentMode:()=>{this.#g()},link:()=>{e.active.value=!!r?.active,e.attributes.value=z1(e.attributes.value,r?.value??null)},fontFamily:()=>{if(r?.value!=null){e.activate({fontFamily:r.value});return}if(this.#x(r)){e.activate({},!0);return}e.deactivate()},fontSize:()=>{if(r?.value!=null){e.activate({fontSize:r.value});return}if(this.#A(r)){e.activate({},!0);return}e.deactivate()},color:()=>{r?.value!=null?e.activate({color:r.value}):e.deactivate()},highlight:()=>{r?.value!=null?e.activate({color:r.value}):e.deactivate()},linkedStyles:()=>{const i=r?.value,s=typeof i=="string"?i:i?.styleId,a=i&&typeof i=="object"?i.styleName:null;s?e.activate({styleId:s,styleName:a}):e.label.value=this.config.texts?.formatText||"Format text"},list:()=>{r?.active?(e.activate(),e.selectedValue.value=r.value):(e.deactivate(),e.selectedValue.value=null)},numberedlist:()=>{r?.active?(e.activate(),e.selectedValue.value=r.value):(e.deactivate(),e.selectedValue.value=null)},default:()=>{r?.active?e.activate():e.deactivate()}};return(o[t]??o.default)(),!0}updateToolbarState(){this.#g(),this.#b();const e=this.snapshot?.commands?.["document-mode"]?.value||"editing";!(this.snapshot&&(this.superdoc?.activeEditor??this.activeEditor))||e==="viewing"?(this.#F(),this.#s().forEach(n=>{const r=n.isCustomToolbarItem&&typeof n.command=="string";(n.allowWithoutEditor?.value||r)&&this.#I(n)})):this.#s().forEach(n=>{n.resetDisabled(),this.#I(n)}),this.getToolbarItemByName("overflow")?.setDisabled(!this.overflowItems.some(n=>n.type!=="separator"&&!n.disabled.value));const t=this.getToolbarItemByName("copyFormat");t&&(this.snapshot?.copyFormatActive?t.activate():t.deactivate()),this.emit("toolbar-state-change")}#F(){this.#s().forEach(e=>{const{allowWithoutEditor:t}=e;t?.value||e.setDisabled(!0)})}#T(e,t){const n=this.superdoc;if(e==="watermark"){if(!this.#k(e))return!1;const r=this.ui.watermark.open();if(!r.ok)throw new Error(`[superdoc toolbar] Watermark dialog unavailable: ${r.reason}`);return!0}if(e==="ruler")return typeof n?.toggleRuler=="function"?(n.toggleRuler(),!0):!1;if(e==="formattingMarks"){if(typeof t=="boolean"&&typeof n?.setShowFormattingMarks=="function")return n.setShowFormattingMarks(t),!0;if(typeof n?.toggleFormattingMarks=="function")return n.toggleFormattingMarks(),!0}return!1}#P(e,t){const n=e?.name?.value;if(!n)return!1;const r={firstParty:!0,onSettled:()=>this.updateToolbarState(),onError:i=>this.#v(i,n)};if(n==="image"&&t==null)return this.#D();if(n==="tableActions"){const i=RE[t?.command];return i?Ag(this.ui,i,void 0,r):!1}if(P1(n)?.disposition==="unsupported")return!0;const o=zE(n);return o?Ag(this.ui,o,t,r):!1}#D(){return this.snapshot?.commands?.image?.disabled||(this.#e||(this.#e=vD({ownerDocument:this.toolbarContainer?.ownerDocument??document,onPick:async e=>{const t=await mD(e,this.superdoc?.config?.handleImageUpload);Ag(this.ui,"image",{src:t},{firstParty:!0,onSettled:()=>this.updateToolbarState(),onError:n=>this.#v(n,"image")})},onError:e=>this.#v(e,"image")})),this.#e.open()),!0}#w(){if(this.#n)return;const e=this.superdoc?.activeEditor?.container??document,t=i=>{jE(i.target)||this.ui.formatPainter.setPointerSelecting(!0)},n=i=>{this.ui.formatPainter.setPointerSelecting(!1),!jE(i.target)&&this.ui.formatPainter.notifyPointerUp()},r=i=>{if(i.key==="Escape"){this.ui.formatPainter.cancel();return}cK(i)&&this.ui.formatPainter.setKeyboardSelecting(!0)},o=()=>{this.ui.formatPainter.setKeyboardSelecting(!1),this.ui.formatPainter.notifyKeyUp()};e.addEventListener("pointerdown",t),e.addEventListener("pointerup",n),e.addEventListener("keydown",r),e.addEventListener("keyup",o),this.#n=()=>{e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",n),e.removeEventListener("keydown",r),e.removeEventListener("keyup",o)}}#y(){this.#n&&(this.#n(),this.#n=null)}#v(e,t){const n={error:e instanceof Error?e:new Error(String(e)),originalError:e,itemName:t??null,editor:this.superdoc?.activeEditor??this.activeEditor??null},r={...n};this.emit("exception",n),this.superdoc?.emit?.("exception",r)}emitCommand({item:e,argument:t,option:n}){const r=e?.name?.value,{command:o}=e,i=t!=null;if(!(e?.type==="dropdown"&&!i&&(o==="setFontFamily"||o==="setFontSize"))){if(r==="search"){this.superdoc?.emit?.("search:open");return}try{if(P1(r)?.disposition==="host-routed"){this.#T(r,t),this.updateToolbarState();return}if(typeof o=="function"){const s=`__builtin_toolbar__${r}`;if(this._customCommandRegs.has(s)&&this.ui?.commands?.execute)this.ui.commands.execute(s,{argument:t,option:n});else{const a=o({item:e,argument:t,option:n,ui:this.ui,superdoc:this.superdoc});a&&typeof a.then=="function"&&Promise.resolve(a).catch(l=>this.#v(l,r))}this.updateToolbarState();return}if(e?.isCustomToolbarItem&&typeof o=="string"){if(!Ag(this.ui,o,t,{onSettled:()=>this.updateToolbarState(),onError:s=>this.#v(s,r),reportUnhandled:!0}))throw new Error(`[superdoc toolbar] Command not handled: ${String(o)}`);this.updateToolbarState();return}if(!this.#P(e,t)&&o)throw new Error(`[superdoc toolbar] Command not handled: ${String(o)}`);this.updateToolbarState()}catch(s){this.#v(s,r)}}}destroy(){this.#y(),this.#e?.destroy(),this.#e=null,this.#a(),this.#o(),this.app?.unmount(),this.app=null,this.toolbar=null}};function fK(e){return new dK(e)}Ft();var hK=['[data-sdt-type="structuredContent"][data-sdt-id]','[data-sdt-type="structuredContent"][data-sdt-container-id]','[data-sdt-container-type="structuredContent"][data-sdt-container-id]'].join(", "),pK=800,VE=typeof Blob=="function"?Object.getOwnPropertyDescriptor(Blob.prototype,"size")?.get:void 0,UE=e=>{if(!VE)return!1;try{return VE.call(e),!0}catch{return!1}};function mK(e){return e.key==="Alt"||e.key==="Control"||e.key==="Meta"||e.key==="Shift"||(e.ctrlKey||e.metaKey)&&e.shiftKey&&!e.altKey&&(e.code==="Digit8"||e.key==="8"||e.key==="*")?!0:(e.ctrlKey||e.metaKey)&&["b","c","f","i","s","u"].includes(e.key.toLowerCase())}var gK=Object.freeze(["#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F","#BB8FCE","#85C1E2","#F1948A","#82E0AA","#F8C471","#AED6F1","#D7BDE2","#A3E4D7","#F0B27A","#AEB6BF","#E74C3C","#2ECC71","#3498DB","#E67E22","#1ABC9C","#9B59B6","#34495E","#F39C12"]),vK=["original","markup","final"],yK=["review","original","final","off"];function $E(e){return vK.includes(e)}function bK(e){return e==="markup"?"review":e}function HE(e){return yK.includes(e)}function wK(e){const t=e.modules?.trackChanges?.mode;if(HE(t))return t;const n=e.layoutEngineOptions?.trackedChanges?.mode;return HE(n)?n:null}function Ig(e,t){const n=e.viewing,r=$E(n?.trackedChanges)?n.trackedChanges:null,o=r?bK(r):t||(e.trackChanges?.visible===!0?"review":"original");return{comments:typeof n?.comments=="boolean"?n.comments:e.comments?.visible===!0,renderMode:o,trackChangesVisible:r?r==="markup":e.trackChanges?.visible===!0}}async function CK(e,t){const n=new n6.default;return e.forEach((r,o)=>{n.file(t[o],r)}),n.generateAsync({type:"blob",compression:"DEFLATE"})}function V1(e){return!!(e&&(e.synced===!0||e.isSynced===!0))}function GE(e){try{e.synced=!0}catch{}try{e.isSynced=!0}catch{}}function kK(e,t){if(!e)return()=>{};if(V1(e))return t(),()=>{};const n=typeof e.on=="function"?e.on.bind(e):null,r=typeof e.off=="function"?e.off.bind(e):null;if(!n)return t(),()=>{};let o=!1;const i=()=>{o||(o=!0,r?.("synced",a),r?.("sync",l))},s=()=>{o||(i(),t())},a=()=>{GE(e),s()},l=u=>{u!==!1&&(u===!0||V1(e))&&(GE(e),s())};return n("synced",a),n("sync",l),V1(e)&&s(),i}function SK(e,t){const n=e.composedPath();if(!n.includes(t))return null;const r=n.find(a=>a instanceof HTMLElement&&a.matches(hK));if(!r)return null;const o=n.some(a=>a instanceof HTMLElement&&a.classList.contains(Zp.BLOCK_SDT_LABEL)),i=r.getAttribute("data-sdt-container-id")?.trim()||null,s=r.getAttribute("data-sdt-id")?.trim()||null;return o?i??s:s??i}function _K(e){if(!e||typeof e!="object")return[];const t=e.items;return Array.isArray(t)?t:[]}function WE(e){if(!e||typeof e.id!="string"||e.kind!=="inline"&&e.kind!=="block"||typeof e.controlType!="string")return null;const t=e.properties?.tag,n=e.properties?.alias;return{id:e.id,controlType:e.controlType,scope:e.kind,...typeof t=="string"&&t?{tag:t}:{},...typeof n=="string"&&n?{alias:n}:{}}}function KE(e){const t=e.selectionTarget??e.target;if(!t)return null;try{return JSON.stringify(t)}catch{return null}}function AK(e,t){switch(e.state){case"failed":return"failed";case"degraded":return e.detail==="reconnecting"?"reconnecting":"lost";case"synced":return t?"recovered":"initial";default:return t?"reconnecting":"initial"}}function Xo(e){return!!(e&&typeof e=="object"&&e.editorVersion===2)}function qE(e){return typeof e=="string"&&e.length>0?e:null}function YE(e){return e?Xo(e)?qE(e.documentId??e.options?.documentId??null):qE(typeof e.getDocumentId=="function"?e.getDocumentId():e.options?.documentId):null}function IK(e){if(!e||Xo(e))return null;const t=e;return t.documentRenderer??t.presentationEditor??null}function ws(e){if(!e)return null;if(Xo(e))return e.fonts??null;const t=IK(e);return t?{getReport:()=>t.getFontReport?.()??[],getMissingFonts:()=>t.getMissingFonts?.()??[],getDocumentFonts:()=>[...new Set((t.getFontReport?.()??[]).map(n=>n.logicalFamily))],getDocumentFontOptions:()=>t.getDocumentFontOptions?.()??[],getFontFamilyOptions:()=>t.getFontFamilyOptions?.()??[],getLastFontsChangedPayload:()=>t.getLastFontsChangedPayload?.()??null,map:n=>t.mapFonts(n),unmap:n=>t.unmapFonts(n),add:n=>t.addFonts(Array.isArray(n)?n:[n]),preload:n=>t.preloadFonts(n)}:null}var Eg=class extends av.default{static{this.allowedTypes=[br,Da,Du]}#e;#n;#t;#o;#i;#a;#u;#f;#c;#d;#p;#r;#s;#m;#_;#k;#g;#b;#A;#x;#I;#F;#T;#P;#D;#w;#y;get uiConfig(){return this.#y}#v;get interactionConfig(){return this.#v}#N;get surfacesConfig(){return this.#N}#E;#h;#R;#M;#L;constructor(e){if(super(),this.#e=!1,this.#t=!1,this.#o=null,this.#i=null,this.#a=null,this.#u=null,this.#f=null,this.#c=null,this.#d=!1,this.#p=null,this.#r=null,this.#s=null,this.#m=null,this.#_=!1,this.#k=!1,this.#g=null,this.#b=null,this.#A=!1,this.#x=null,this.#I=null,this.#F=n=>{this.listenerCount("content-control:active-change")>0&&(this.#A||(this.#x=n.pointerId),this.#A=!0,this.#g="pointer",this.#b=null)},this.#T=n=>{n.pointerId===this.#x&&(this.#A=!1,this.#x=null,this.#g??="pointer",this.#g==="pointer"&&(this.#b=Date.now()+pK))},this.#P=n=>{this.listenerCount("content-control:active-change")>0&&!mK(n)&&(this.#g="keyboard",this.#b=null)},this.#D=n=>{this.#X(n)},this.#w=null,this.#y=bE({}),this.#v=wE({}),this.#N=kE({}),this.version="0.0.0",this.users=[],this.whiteboard=null,this.colors=[],this.readyEditors=0,this.#h=new fH,this.#R=null,this.#M=!1,this.#L=null,this.config={selector:"#superdoc",documentMode:"editing",allowSelectionInViewMode:!1,role:"editor",documents:[],editorExtensions:[],colors:[],users:[],user:{...M1},layoutEngineOptions:{},modules:{},licenseKey:void 0,telemetry:{enabled:!0},title:"SuperDoc",conversations:[],isInternal:!1,comments:{visible:!1},toolbarGroups:["left","center","right"],toolbarIcons:{},toolbarTexts:{},uiDisplayFallbackFont:"Arial, Helvetica, sans-serif",isDev:!1,disablePiniaDevtools:!1,onEditorBeforeCreate:()=>null,onEditorCreate:()=>null,onEditorDestroy:()=>null,onSourceComplete:()=>null,onSourceSignalsComplete:()=>null,onContentError:()=>null,onReady:()=>null,onCommentsUpdate:()=>null,onContentControlActiveChange:()=>null,onContentControlClick:()=>null,onAwarenessUpdate:()=>null,onLocked:()=>null,onPdfDocumentReady:()=>null,onSidebarToggle:()=>null,onCollaborationReady:()=>null,onEditorUpdate:()=>null,onCommentsListChange:()=>null,onException:()=>null,onListDefinitionsChange:()=>null,onPaginationUpdate:()=>null,onTransaction:()=>null,disableContextMenu:!1,viewOptions:{layout:"print"},useLayoutEngine:!0},this.#ne=new WeakSet,this.#re=new WeakMap,this.#oe=null,this.#K=null,this.#j=null,!e.selector)throw new Error("SuperDoc: selector is required");const t=typeof e.selector=="string"?document.querySelector(e.selector):e.selector;if(!(t instanceof HTMLElement))throw new Error("SuperDoc: selector must be a valid CSS selector string or DOM element");this.#n=Qx(this,e,()=>this.version,t),this.#E=new F$({getModuleConfig:()=>this.#N}),this.#s=t,t.addEventListener("pointerdown",this.#F,!0),t.ownerDocument.addEventListener("pointerup",this.#T,!0),t.ownerDocument.addEventListener("pointercancel",this.#T,!0),t.addEventListener("keydown",this.#P,!0),t.addEventListener("click",this.#D,!0),this.#l("content-control:active-change",e.onContentControlActiveChange),this.#S(e,t),this.#k=!0,this.listenerCount("content-control:active-change")>0&&this.ui}async#X(e){const t=this.#s;if(!t)return;const n=SK(e,t),r=this.activeEditor?.doc?.contentControls?.list;if(!(!n||typeof r!="function"))try{const o=await r();if(this.#e)return;const i=WE(_K(o).find(s=>s.id===n));i&&this.emit("content-control:click",{target:i,source:"pointer"})}catch{return}}async#S(e,t){this.#L=wK(e),this.config={...this.config,...e,modules:{...this.config.modules,...e.modules},layoutEngineOptions:{...this.config.layoutEngineOptions,...e.layoutEngineOptions}},typeof this.config.viewing?.comments=="boolean"&&(this.config.comments={...this.config.comments,visible:this.config.viewing.comments}),!this.config.comments||typeof this.config.comments!="object"?this.config.comments={visible:!1}:typeof this.config.comments.visible!="boolean"&&(this.config.comments.visible=!1),R1(this.config),this.config.documents=this.config.documents||[],this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};const n=this.config.viewOptions?.layout==="web",r=this.config.layoutEngineOptions?.flowMode==="semantic";if(!n&&r&&(console.warn("[SuperDoc] flowMode 'semantic' is only valid with web layout. Coercing to 'paginated'."),this.config.layoutEngineOptions.flowMode="paginated"),this.editorVersion=2,this.#Ue(),this.config.user=q$(this.config.user),this.config.layoutEngineOptions.virtualization||(this.config.layoutEngineOptions.virtualization={enabled:!0,window:5,overscan:1}),this.config.modules=this.config.modules||{},Object.prototype.hasOwnProperty.call(this.config.modules,"comments")||(this.config.modules.comments={}),this.config.modules.comments=iA(this.config.modules.comments),this.#y=bE(this.config),this.#v=wE(this.config),this.#N=kE(this.config),this.config.disableContextMenu=!this.#y.contextMenu.enabled,this.config.rulers=this.#y.ruler.enabled,this.#y.comments.enabled?this.config.modules.comments===!1&&(this.config.modules.comments={}):this.config.modules.comments=!1,this.#y.comments.enabled){this.config.modules.comments===!0&&(this.config.modules.comments={});const i=this.config.modules.comments;i&&(i.readOnly=this.#v.comments.readOnly,i.allowResolve=this.#v.comments.allowResolve)}if(this.config.colors=u6(this.config.colors),this.userColorMap=new Map,this.colorIndex=0,this.version="2.22.0-next.3",this.#ie("🦋 [superdoc] Using SuperDoc version:",this.version),this.superdocId=e.superdocId||fl(),this.colors=this.config.colors??[],this.#Z(),await RM(),this.#e)return;if(await this.#ee(this.config.modules),this.#e){this.#we();return}this.user=this.config.user,this.users=this.config.users||[],this.socket=null,this.isDev=this.config.isDev||!1,this.activeEditor=null,this.comments=[],this.#R||(this.#R=this.#h.subscribe(i=>{this.#He(i.nextRuntimeId,i.legacyEditorProjection)})),this.isLocked=this.config.isLocked||!1,this.lockedBy=this.config.lockedBy||null;const o=document.createElement("div");o.style.display="contents",t.appendChild(o),this.#r=o,this.#J(),this.#V(),this.#Ge(),this.#O()}#O(){if(this.#Q(),this.readyEditors=0,!this.app)throw new Error("SuperDoc: #startRuntime called before #initVueApp populated this.app");this.app.mount(this.#r)}#V(){const e=this.config.modules?.whiteboard,t=e!==!1&&(e?.enabled??!1);this.whiteboard=new lV({Renderer:P$,superdoc:this,enabled:t}),this.emit("whiteboard:init",{whiteboard:this.whiteboard})}get requiredNumberOfEditors(){return this.#C("requiredNumberOfEditors").documents.filter(e=>e.type===br).length}get ui(){return this.#w||(this.#w=hF({superdoc:this}),this.#e&&this.#w.destroy()),this.#U(),this.#w}get diagnostics(){return this.#n}emit(e,...t){return(e==="exception"||e==="document-replaced"||e==="ready"||e==="active-editor-change"||e==="collaboration-ready"||e==="collaboration-connection-change"||e==="locked")&&Wd(this,e,()=>t[0]),super.emit(e,...t)}on(e,t,n){return super.on(e,t,n),e==="content-control:active-change"&&this.#k&&this.ui,this}addListener(e,t,n){return super.addListener(e,t,n),e==="content-control:active-change"&&this.#k&&this.ui,this}once(e,t,n){return super.once(e,t,n),e==="content-control:active-change"&&this.#k&&this.ui,this}removeListener(e,t,n,r){return super.removeListener(e,t,n,r),this.#B(),this}off(e,t,n,r){return super.off(e,t,n,r),this.#B(),this}removeAllListeners(e){return super.removeAllListeners(e),this.#B(),this}#B(){this.listenerCount("content-control:active-change")>0||(this.#m?.(),this.#m=null,this.#I=null,this.#g=null,this.#b=null,this.#A=!1,this.#x=null)}#U(){if(this.#m||this.#_||!this.#w||this.#e||this.listenerCount("content-control:active-change")===0)return;let e=null,t=[],n=null,r=null,o=!0;this.#_=!0;try{n=this.#w.selection.observe(s=>{if(o){o=!1;return}if(s.status!=="ready")return;const a=KE(s);if(!a)return;this.#g==="pointer"&&this.#b!==null&&Date.now()>this.#b&&(this.#g=null,this.#b=null);const l=this.#g??(this.#A?"pointer":null),u=this.activeEditor;(l||this.#I?.editor!==u||this.#I.key!==a)&&(this.#I={editor:u,key:a,source:l??"keyboard"}),this.#g=null,this.#b=null}),r=this.#w.contentControls.observeActivePath(s=>{const a=this.activeEditor,l=s.activeIds.map(v=>WE(s.items.find(C=>C.id===v)));if(l.some(v=>v===null))return;const u=l,d=a===e,f=u.length===t.length&&u.every((v,C)=>v.id===t[C]?.id);if(d&&f)return;if(u.length===0&&t.length===0){e=a;return}const p=d?t[0]??null:null;e=a,t=u;const g=KE(this.#w.selection.getSnapshot()),m=this.#I;this.emit("content-control:active-change",{active:u[0]??null,previous:p,activePath:u,source:g&&m?.editor===a&&m.key===g?m.source:"keyboard"})});const i=()=>{n?.(),r?.()};this.#e||this.listenerCount("content-control:active-change")===0?i():this.#m=i}catch(i){throw n?.(),r?.(),i}finally{this.#_=!1}}get state(){return{documents:this.#C("state").documents.map(e=>xl(e.data)?{...e,data:vb(e.data,e.type||"application/vnd.openxmlformats-officedocument.wordprocessingml.document")}:e),users:this.users}}getDocumentRuntimeForDocument(e){return typeof e!="string"||e.length===0?null:(this.superdocStore?.documents??[]).find(t=>t?.getEditor?.()?.options?.documentId===e)?.getDocumentRuntime?.()??null}getComment(e){return typeof e!="string"||e.length===0?null:this.commentsStore?.getComment?.(e)??null}get element(){return typeof this.config.selector=="string"?document.querySelector(this.config.selector):this.config.selector}#Z(){const e=this.config.document,t=!!e&&typeof e=="object"&&(xl(e)||typeof Blob=="function"&&e instanceof Blob||Object.keys(e).length>0),n=typeof e=="string"&&e.length>0,r=this.config.documents&&this.config.documents?.length;if((t||n)&&r&&console.warn("🦋 [superdoc] You can only provide one of document or documents"),t){const o=bb(e);this.config.documents=[{id:fl(),...o}]}else n&&(this.config.documents=[{id:fl(),type:br,url:this.config.document,name:"document.docx"}]);Array.isArray(this.config.documents)&&this.config.documents.length>0&&(this.config.documents=this.config.documents.map(o=>{const i=bb(o);if(!i||typeof i!="object")return i;const s=typeof i=="object"&&"id"in i&&i.id||o&&typeof o=="object"&&"id"in o&&o.id;return{...i,id:s||fl()}}))}#Q(){const{app:e,pinia:t,superdocStore:n,commentsStore:r,highContrastModeStore:o}=Yj({disablePiniaDevtools:!!this.config.disablePiniaDevtools});this.app=e,this.pinia=t,this.app.config.globalProperties.$config=this.config,this.app.config.globalProperties.$documentMode=this.config.documentMode,this.app.config.globalProperties.$superdoc=this,this.app.provide("surfaceManager",this.#E),this.superdocStore=n,this.commentsStore=r,this.highContrastModeStore=o,typeof this.superdocStore.setExceptionHandler=="function"&&this.superdocStore.setExceptionHandler(s=>this.emit("exception",s)),this.superdocStore.init(this.config);const i=this.config.modules.comments;this.commentsStore.init(i||{}),this.isCollaborative&&mM(this),this.#le()}#l(e,t){t&&this.on(e,t)}#J(){this.#l("editorBeforeCreate",this.config.onEditorBeforeCreate),this.#l("editorCreate",this.config.onEditorCreate),this.#l("editorDestroy",this.config.onEditorDestroy),this.#l("source:complete",this.config.onSourceComplete),this.#l("source:signals-complete",this.config.onSourceSignalsComplete),this.#l("ready",this.config.onReady),this.#l("comments-update",this.config.onCommentsUpdate),this.#l("content-control:click",this.config.onContentControlClick),this.#l("awareness-update",this.config.onAwarenessUpdate),this.#l("locked",this.config.onLocked),this.#l("pdf:document-ready",this.config.onPdfDocumentReady),this.#l("sidebar-toggle",this.config.onSidebarToggle),this.#l("collaboration-ready",this.config.onCollaborationReady),this.#l("collaboration-connection-change",this.config.onCollaborationConnectionChange),this.on("collaboration-ready",e=>this.#ke(e?.editor??null)),this.#l("editor-update",this.config.onEditorUpdate),this.#l("tracked-changes:bulk-decision",this.config.onTrackedChangesBulkDecision),this.on("content-error",this.onContentError),this.#l("exception",this.config.onException),this.#l("list-definitions-change",this.config.onListDefinitionsChange),this.#l("pagination-update",this.config.onPaginationUpdate),this.#l("fonts-resolved",this.config.onFontsResolved),this.#l("fonts-changed",this.config.onFontsChanged),this.#l("zoomChange",this.config.onZoomChange),this.#l("viewport-change",this.config.onViewportChange),this.#l("page-margins-change",this.config.onPageMarginsChange)}async#ee({collaboration:e}={}){return e?(this.isCollaborative=!1,this.config.documents.length===0&&(this.config.documents=[{id:fl(),type:br,name:"document.docx"}]),this.config.v2CollaborationPreflightFailure={code:"collaboration-v1-config-unsupported",message:"SuperDoc v2 cannot use modules.collaboration because it is the SuperDoc v1 collaboration API. SuperDoc did not attach the provider or change the document. Configure Document.v2Collaboration with a v2 room instead."},this.config.documents):this.config.documents}#ce(e,t){this.isCollaborative=!0,this._commentsCollabInitialized=!1,this.ydoc=Gr(e),this.provider=Gr(t),this.#Ee();const n=this.config;this._cleanupAwareness=uM(t,this,n.user),n.documents.forEach(r=>{r.ydoc=e,r.provider=t,r.role=this.config.role})}#Ce(){this.#p=null,this.#te(),typeof this._cleanupAwareness=="function"&&(this._cleanupAwareness(),this._cleanupAwareness=null),this.isCollaborative=!1,this._commentsCollabInitialized=!1,this.ydoc=void 0,this.provider=void 0;const e=this.config;delete e.modules.collaboration,e.documents.forEach(t=>{delete t.ydoc,delete t.provider})}#te(){if(this.#a){try{this.#a()}catch{}this.#a=null}if(this.#u){try{this.#u()}catch{}this.#u=null}if(this.#f){try{this.#f()}catch{}this.#f=null}}#ke(e){this.#te(),Xo(e)&&(this.#_e(e),this.#Ae(e),this.#Se(e))}#Se(e){const t=e.connection;if(!t||typeof t.subscribe!="function")return;const{documentId:n}=t;this.#c?.documentId!==n&&(this.#c=null,this.#d=!1);const r=o=>{if(this.#e)return;const i=this.#c;if(i&&i.state===o.state&&i.detail===(o.detail??null))return;const s={documentId:n,state:o.state,previousState:i?.state??null,kind:AK(o,this.#d),detail:o.detail??null,superdoc:this};this.#c=s,o.state==="synced"&&(this.#d=!0),this.emit("collaboration-connection-change",s)};try{const o=t.getSnapshot?.();o&&r(o),this.#f=t.subscribe(r)}catch(o){console.warn("[SuperDoc] v2 connection bridge failed to subscribe",o)}}getCollaborationConnectionState(){return this.#c}#_e(e){const t=e.presence;if(!t||typeof t.subscribe!="function")return;const n=oV(()=>this.user),r=o=>{if(this.#e)return;const i=n.next(o);this.emit("awareness-update",{...i,superdoc:this})};try{const o=t.getSnapshot?.();o&&r(o),this.#a=t.subscribe(r)}catch(o){console.warn("[SuperDoc] v2 awareness bridge failed to subscribe",o)}}#Ae(e){const t=e.lock;if(!t||typeof t.subscribe!="function")return;const n=r=>{this.#e||this.#$(!!r.isLocked,this.#ue(r.lockedBy??null))};try{if(this.#p&&typeof t.setLocked=="function"){const o=this.#p;t.setLocked(o.isLocked,o.isLocked?o.lockedBy:null),this.#p=null}const r=t.getSnapshot?.();r&&n(r),this.#u=t.subscribe(n)}catch(r){console.warn("[SuperDoc] v2 lock bridge failed to subscribe",r)}}#ue(e){return!e||typeof e!="object"||Array.isArray(e)?null:{...e}}#Ie(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}#$(e,t){this.isLocked===e&&this.#Ie(this.lockedBy,t)||(this.isLocked=e,this.lockedBy=t,this.#ie("🦋 [superdoc] Locking superdoc:",e,t,`
|
|
106
|
+
`;Ft();var Ki=e=>{e.expand.value=!1},B1=(e,t)=>{const n=e.layoutWidth?.value;return Number.isFinite(n)&&n>0?n:e.type==="separator"?t.get("separator"):t.get(e.name.value)||t.get("default")},QW=e=>{const t=[];for(const n of e){if(n.type==="separator"){const r=t[t.length-1];if(!r||r.type==="separator")continue}t.push(n)}for(;t.length&&t[t.length-1].type==="separator";)t.pop();return t},FE=e=>{const t=new Map;for(const r of e){const o=r.group?.value||"center";t.has(o)||t.set(o,[]),t.get(o).push(r)}const n=new Set;for(const r of t.values())for(const o of QW(r))n.add(o);return e.filter(r=>n.has(r))},JW=e=>{const t=e.find(o=>o.type==="overflow"),n=e.filter(o=>o!==t),r=new Set(FE(n));return e.filter(o=>o===t||r.has(o))};function z1(e,t){const n={...e};return t?n.href=t:delete n.href,n}function NE(e){const t=Array.isArray(e?.segments)?e.segments:[];if(e?.kind!=="text"||!t.length)return null;const n=t[0],r=t[t.length-1];if(!n?.blockId||!r?.blockId||!n.range||!r.range)return null;const o=e.story;return{kind:"selection",start:{kind:"text",blockId:n.blockId,offset:n.range.start??0,...o?{story:o}:{}},end:{kind:"text",blockId:r.blockId,offset:r.range.end??0,...o?{story:o}:{}},...o?{story:o}:{}}}function eK(e){return typeof e?.quotedText=="string"?e.quotedText:typeof e?.text=="string"?e.text:""}function j1(e){return e.ui?.selection?.get?.()??e.ui?.selection?.current?.()??null}function tK(e){return!!(e.config?.superdoc?.config?.modules?.ai||e.superdoc?.config?.modules?.ai)}function nK(e){return e.config?.superdoc?.config?.modules?.ai??e.superdoc?.config?.modules?.ai??{}}var rK=({superToolbar:e,toolbarIcons:t,toolbarTexts:n,toolbarFonts:r,hideButtons:o,availableWidth:i,role:s,isDev:a=!1,configuredItemNames:l,configuredItemOrder:u,excludedItemNames:d,additionalItems:f=[]}={})=>{const p=xn({type:"button",name:"bold",command:"toggleBold",icon:t.bold,tooltip:n.bold,attributes:{ariaLabel:"Bold"}}),g=(r??CG).map(xG),m=xn({type:"dropdown",name:"fontFamily",tooltip:n.fontFamily,command:"setFontFamily",defaultLabel:"Arial",label:"Arial",markName:"textStyle",labelAttr:"fontFamily",hasCaret:!0,hasInlineTextInput:!0,inlineTextInputVisible:!0,isWide:!0,style:{width:"116px"},suppressActiveHighlight:!0,attributes:{ariaLabel:"Font family"},options:g,onActivate:({fontFamily:st}={},_t=!1)=>{if(_t){m.label.value="",m.selectedValue.value="";return}if(!st)return;st=st.split(",")[0];const gt=Te=>Te.value??Te.label,Xt=g.find(Te=>gt(Te)===m.defaultLabel.value),gn=g.find(Te=>gt(Te)===st);gn?(m.label.value=gn.label,m.selectedValue.value=gn.key):Xt?(m.label.value=st,m.selectedValue.value=Xt.key):(m.label.value=st,m.selectedValue.value="")},onDeactivate:()=>{const st=g.find(_t=>(_t.value??_t.label)===m.defaultLabel.value);m.label.value=st?.label??m.defaultLabel.value,m.selectedValue.value=st?.key??""}}),v=xn({type:"dropdown",name:"ai",dropdownStyles:{padding:0,outline:"none"},tooltip:n.ai,icon:t.ai,hideLabel:!0,hasCaret:!1,isWide:!0,suppressActiveHighlight:!0,attributes:{ariaLabel:"AI"},options:[{type:"render",key:"ai",render:()=>C(v)}]});function C(st){const _t=j1(e),gt=_t?.selectionTarget??NE(_t?.target),Xt=_t?.empty?"":eK(_t),gn=nK(e),Te=()=>Ki(st),Ne=()=>{const Qe=e.pendingSelectionCapture;Qe&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(Qe)};return Dr("div",{},[Dr(tW,{handleClose:Te,selectedText:Xt,target:gt,doc:e.superdoc?.activeEditor?.doc??null,apiKey:gn?.apiKey||e.config?.aiApiKey||"",endpoint:gn?.endpoint||e.config?.aiEndpoint||"",restoreSelection:Ne})])}const w=SG,S=xn({type:"dropdown",name:"fontSize",defaultLabel:"12",label:"12",style:{width:"56px"},markName:"textStyle",labelAttr:"fontSize",tooltip:n.fontSize,hasCaret:!0,hasInlineTextInput:!0,inlineTextInputVisible:!0,suppressActiveHighlight:!0,isWide:!0,command:"setFontSize",attributes:{ariaLabel:"Font size"},options:w,onActivate:({fontSize:st},_t=!1)=>{if(_t){S.label.value="",S.selectedValue.value="";return}const gt=w.find(Ne=>Ne.label===String(S.defaultLabel.value));if(!st){S.label.value=S.defaultLabel.value,gt?S.selectedValue.value=gt.key:S.selectedValue.value="";return}let Xt=gH(st,12);Xt<8&&(Xt=8),Xt>96&&(Xt=96);let gn=String(Xt);const Te=w.find(Ne=>Ne.label===gn||Ne.key===gn);Te?S.selectedValue.value=Te.key:S.selectedValue.value="",S.label.value=gn},onDeactivate:()=>{S.label.value=S.defaultLabel.value;const st=w.find(_t=>_t.label===String(S.defaultLabel.value));st?S.selectedValue.value=st.key:S.selectedValue.value=""}}),b=()=>xn({type:"separator",name:"separator",isNarrow:!0}),k=xn({type:"button",name:"italic",command:"toggleItalic",icon:t.italic,active:!1,tooltip:n.italic,attributes:{ariaLabel:"Italic"}}),x=xn({type:"button",name:"underline",command:"toggleUnderline",icon:t.underline,active:!1,tooltip:n.underline,attributes:{ariaLabel:"Underline"}}),M=xn({type:"button",name:"strike",command:"toggleStrike",icon:t.strikethrough,active:!1,tooltip:n.strikethrough,attributes:{ariaLabel:"Strikethrough"}}),z=xn({type:"dropdown",name:"highlight",icon:t.highlight,hideLabel:!0,markName:"highlight",labelAttr:"color",active:!1,tooltip:n.highlight,command:"setHighlight",noArgumentCommand:"unsetHighlight",suppressActiveHighlight:!0,attributes:{ariaLabel:"Highlight"},options:[{key:"color",type:"render",render:()=>F1(e,z,[],!0)}],onActivate:({color:st})=>{z.iconColor.value=st||""},onDeactivate:()=>z.iconColor.value=""}),G=xn({type:"dropdown",name:"color",icon:t.color,hideLabel:!0,markName:"textStyle",labelAttr:"color",active:!1,tooltip:n.color,command:"setColor",suppressActiveHighlight:!0,attributes:{ariaLabel:"Color"},options:[{key:"color",type:"render",render:()=>F1(e,G)}],onActivate:({color:st})=>{G.iconColor.value=st},onDeactivate:()=>G.iconColor.value="#000"}),F=xn({type:"button",name:"search",allowWithoutEditor:!0,active:!1,icon:t.search,tooltip:n.search,group:"right",attributes:{ariaLabel:"Search"}}),L=xn({type:"dropdown",name:"link",markName:"link",icon:t.link,active:!1,tooltip:n.link,attributes:{ariaLabel:"Link dropdown"},options:[{type:"render",key:"linkDropdown",render:()=>$(L)}],onActivate:({href:st})=>{L.attributes.value=z1(L.attributes.value,st)},onDeactivate:()=>{L.attributes.value=z1(L.attributes.value,null),L.expand.value=!1}});function $(st){const _t=j1(e),gt=_t?.selectionTarget??NE(_t?.target),Xt=()=>{const gn=e.pendingSelectionCapture;gn&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(gn)};return Dr("div",{},[Dr(t4,{ui:e.ui,linkItem:st,textTarget:gt,restoreSelection:Xt,closePopover:()=>{Ki(st),Kl(e)},goToAnchor:()=>{Ki(st);const gn=st.attributes.value?.href;if(!gn)return;const Te=gn.slice(1),Ne=(e.ui?.viewport?.getHost?.()??null)?.querySelector?.(`a[name='${Te}']`);Ne&&n4(Ne)}})])}const T=xn({type:"options",name:"linkInput",command:"toggleLink",active:!1});L.childItem=T,T.parentItem=L;const H=xn({type:"button",name:"image",command:"startImageUpload",icon:t.image,active:!1,tooltip:n.image,disabled:!1,attributes:{ariaLabel:"Image"}}),R=xn({type:"button",name:"tableOfContents",command:"insertTableOfContents",icon:t.tableOfContents,active:!1,tooltip:n.tableOfContents,disabled:!1,attributes:{ariaLabel:"Table of contents"}}),U=xn({type:"button",name:"watermark",icon:t.watermark,tooltip:n.watermark,allowWithoutEditor:!0,disabled:!0,attributes:{ariaLabel:n.watermark}}),W=xn({type:"dropdown",name:"pageNumber",icon:t.pageNumber,hideLabel:!0,tooltip:n.pageNumber,disabled:!0,suppressActiveHighlight:!0,attributes:{ariaLabel:n.pageNumber},options:[{key:"pageNumber",type:"render",label:"Page number options",render:()=>J(W)}]});let ee=null;function J(st){const _t=e.ui,gt=Ne=>_t?.commands?.get?.(Ne)?.getState?.()??null,Xt=()=>{Ki(st),Le.expand.value&&Ki(Le),Kl(e)},gn=j1(e),Te=gn?.selectionTarget?.story??gn?.selectionTarget?.start?.story??gn?.target?.story??null;return Dr(YW,{pageNumbersState:gt("page-numbers-apply"),atCursorState:gt("page-number-insert"),inHeaderFooter:Te?.storyType==="headerFooterPart"||Te?.storyType==="headerFooterSlot",suggesting:_t?.document?.getSnapshot?.()?.mode==="suggesting",initialChoice:ee,loadCurrent:()=>_t?_O(_t):Promise.resolve(null),applyPageNumbers:Ne=>id(_t,"page-numbers-apply",Ne),removePageNumbers:()=>id(_t,"page-numbers-remove"),insertAtCursor:()=>id(_t,"page-number-insert"),close:Ne=>{Xt();const Qe=_t?.viewport?.getHost?.();if(Ne?.action==="apply")ee=Ne.choice,OE(Qe,Ne.choice.position==="top"?"header":"footer");else if(Ne?.action==="remove")for(const bt of new Set(Ne.kinds))OE(Qe,bt)}})}const Z=xn({type:"dropdown",name:"table",icon:t.table,hideLabel:!0,labelAttr:"table",active:!1,tooltip:n.table,command:"insertTable",suppressActiveHighlight:!0,attributes:{ariaLabel:"Table"},options:[{key:"table",type:"render",render:()=>Me(Z)}]});function Me(st){return Dr("div",{},[Dr(vW,{onSelect:gt=>{e.emitCommand({item:st,argument:gt}),Ki(st),Kl(e)}})])}const fe=xn({type:"dropdown",name:"tableActions",command:"executeTableCommand",tooltip:n.tableActions,icon:t.tableActions,hideLabel:!0,disabled:!0,attributes:{ariaLabel:"Table actions"},options:[{type:"render",render:()=>ve(fe)}]}),ye=[{label:n.addRowBefore,command:"addRowBefore",icon:t.addRowBefore,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add row before"}},{label:n.addRowAfter,command:"addRowAfter",icon:t.addRowAfter,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add row after"}},{label:n.addColumnBefore,command:"addColumnBefore",icon:t.addColumnBefore,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add column before"}},{label:n.addColumnAfter,command:"addColumnAfter",icon:t.addColumnAfter,bottomBorder:!0,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add column after"}},{label:n.deleteRow,command:"deleteRow",icon:t.deleteRow,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete row"}},{label:n.deleteColumn,command:"deleteColumn",icon:t.deleteColumn,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete column"}},{label:n.deleteTable,command:"deleteTable",icon:t.deleteTable,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete table"}},{label:n.removeBorders,command:"deleteCellAndTableBorders",icon:t.deleteBorders,bottomBorder:!0,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete cell and table borders"}},{label:n.mergeCells,command:"mergeCells",icon:t.mergeCells,props:{"data-item":"btn-tableActions-option",ariaLabel:"Merge cells"}},{label:n.splitCell,command:"splitCell",icon:t.splitCell,props:{"data-item":"btn-tableActions-option",ariaLabel:"Split cells"}},{label:n.fixTables,command:"fixTables",icon:t.fixTables,props:{"data-item":"btn-tableActions-option",ariaLabel:"Fix tables"}}];function ve(st){return Dr(_W,{options:ye,onSelect:_t=>{Ki(st);const{command:gt}=_t;e.emitCommand({item:st,argument:{command:gt}}),Kl(e)}})}const Pe=xn({type:"dropdown",name:"textAlign",tooltip:n.textAlign,icon:t.alignLeft,command:"setTextAlign",hasCaret:!0,markName:"textAlign",labelAttr:"textAlign",suppressActiveHighlight:!0,attributes:{ariaLabel:"Text align"},options:[{type:"render",render:()=>Dr("div",{},[Dr(MG,{onSelect:_t=>{Ki(Pe);const gt={...Pe,command:"setTextAlign"};gt.command="setTextAlign",e.emitCommand({item:gt,argument:_t}),Ve(Pe,_t),Kl(e)}})]),key:"alignment"}],onActivate:({textAlign:st})=>{Ve(Pe,st)},onDeactivate:()=>{Ve(Pe,"left")}}),Ve=(st,_t)=>{let gt=_t==="both"?"justify":_t,Xt={left:t.alignLeft,right:t.alignRight,center:t.alignCenter,justify:t.alignJustify},gn=Xt[gt]??Xt.left;st.icon.value=gn},nt=xn({type:"dropdown",name:"list",command:"toggleBulletListStyle",splitButton:!0,splitButtonCommand:"toggleBulletList",icon:t.bulletList,hasCaret:!0,tooltip:n.bulletList,restoreEditorFocus:!0,attributes:{ariaLabel:"Bullet list"},options:[{type:"render",key:"bullet-style-buttons",render:()=>{const st=_t=>{Ki(nt);const gt={...nt,command:"toggleBulletListStyle"};e.emitCommand({item:gt,argument:_t})};return Dr(LE,{buttons:DG,iconSize:25,selectedStyle:nt.selectedValue.value,onSelect:st})}}]}),ct=xn({type:"dropdown",name:"numberedlist",command:"toggleOrderedListStyle",splitButton:!0,splitButtonCommand:"toggleOrderedList",icon:t.numberedList,hasCaret:!0,tooltip:n.numberedList,restoreEditorFocus:!0,attributes:{ariaLabel:"Numbered list"},options:[{type:"render",key:"numbered-style-buttons",render:()=>{const st=_t=>{Ki(ct);const gt={...ct,command:"toggleOrderedListStyle"};e.emitCommand({item:gt,argument:_t})};return Dr(LE,{buttons:OG,iconSize:30,selectedStyle:ct.selectedValue.value,onSelect:st})}}]}),ft=xn({type:"button",name:"indentleft",command:"decreaseTextIndent",icon:t.indentLeft,active:!1,tooltip:n.indentLeft,disabled:!1,attributes:{ariaLabel:"Left indent"}}),It=xn({type:"button",name:"indentright",command:"increaseTextIndent",icon:t.indentRight,active:!1,tooltip:n.indentRight,disabled:!1,attributes:{ariaLabel:"Right indent"}}),Le=xn({type:"overflow",name:"overflow",command:null,icon:t.overflow,active:!1,disabled:!1,attributes:{ariaLabel:"Overflow items"}}),oe=xn({type:"dropdown",name:"zoom",allowWithoutEditor:!0,tooltip:n.zoom,defaultLabel:"100%",label:"100%",hasCaret:!0,command:"setZoom",isWide:!0,style:{width:"71px",minWidth:"71px"},inlineTextInputVisible:!1,hasInlineTextInput:!0,attributes:{ariaLabel:"Zoom"},options:[{label:"50%",key:.5,props:{"data-item":"btn-zoom-option"}},{label:"75%",key:.75,props:{"data-item":"btn-zoom-option"}},{label:"90%",key:.9,props:{"data-item":"btn-zoom-option"}},{label:"100%",key:1,props:{"data-item":"btn-zoom-option"}},{label:"125%",key:1.25,props:{"data-item":"btn-zoom-option"}},{label:"150%",key:1.5,props:{"data-item":"btn-zoom-option"}},{label:"200%",key:2,props:{"data-item":"btn-zoom-option"}}],onActivate:({zoom:st})=>{st&&(oe.label.value=st)}}),we=xn({type:"dropdown",name:"measurementUnit",allowWithoutEditor:!0,tooltip:n.measurementUnit,defaultLabel:"in",label:"in",hasCaret:!0,command:"setMeasurementUnit",group:"right",style:{width:"52px",minWidth:"52px"},inlineTextInputVisible:!1,hasInlineTextInput:!1,attributes:{ariaLabel:"Measurement unit"},options:[{label:"Inches",key:"in",props:{"data-item":"btn-measurement-unit-option"}},{label:"Centimeters",key:"cm",props:{"data-item":"btn-measurement-unit-option"}}],onActivate:({measurementUnit:st})=>{st&&(we.label.value=st)}}),Q=xn({type:"button",name:"undo",disabled:!0,tooltip:n.undo,command:"undo",icon:t.undo,group:"left",attributes:{ariaLabel:"Undo"}}),I=xn({type:"button",disabled:!0,name:"redo",tooltip:n.redo,command:"redo",icon:t.redo,group:"left",attributes:{ariaLabel:"Redo"}}),re=xn({type:"button",disabled:!1,name:"acceptTrackedChangeBySelection",tooltip:n.trackChangesAccept,command:"acceptTrackedChangeFromToolbar",icon:t.trackChangesAccept,group:"left",attributes:{ariaLabel:"Accept tracked changes"}}),j=xn({type:"button",disabled:!1,name:"rejectTrackedChangeOnSelection",tooltip:n.trackChangesReject,command:"rejectTrackedChangeFromToolbar",icon:t.trackChangesReject,group:"left",attributes:{ariaLabel:"Reject tracked changes"}}),X=xn({type:"button",name:"clearFormatting",command:"clearFormat",tooltip:n.clearFormatting,icon:t.clearFormatting,attributes:{ariaLabel:"Clear formatting"}}),K=xn({type:"button",name:"copyFormat",tooltip:n.copyFormat,icon:t.copyFormat,command:"copyFormat",active:!1,attributes:{ariaLabel:"Copy formatting"}}),ae=(st,_t)=>st==="editor"?_t:st==="suggester"?_t.filter(gt=>gt.value==="suggesting"):_t.filter(gt=>gt.value==="viewing"),ke=st=>st==="editor"?"Editing":st==="suggester"?"Suggesting":"Viewing",P=xn({type:"dropdown",name:"documentMode",command:"setDocumentMode",allowWithoutEditor:!0,icon:t.documentMode,defaultLabel:ke(s),label:ke(s),hasCaret:s==="editor",isWide:!0,style:{display:"flex",justifyContent:"flex-end"},inlineTextInputVisible:!1,hasInlineTextInput:!1,group:"right",disabled:s!=="editor",attributes:{dropdownPosition:"right",className:"sd-toolbar-item--doc-mode",ariaLabel:"Document mode"},options:[{type:"render",render:()=>me(P)}]}),N=[{label:n.documentEditingMode,value:"editing",icon:t.documentEditingMode,description:n.documentEditingModeDescription},{label:n.documentSuggestingMode,value:"suggesting",icon:t.documentSuggestingMode,description:n.documentSuggestingModeDescription},{label:n.documentViewingMode,value:"viewing",icon:t.documentViewingMode,description:n.documentViewingModeDescription}];function me(st){return Dr($G,{options:ae(s,N),onSelect:_t=>{const gt=e.superdoc?.activeEditor??e.activeEditor;Ki(st);const{label:Xt,icon:gn,value:Te}=_t;P.label.value=Xt,P.icon.value=gn,e.emitCommand({item:P,argument:Te}),Kl(e,gt)}})}const Se=new Map([["separator",20],["zoom",71],["measurementUnit",52],["fontFamily",118],["fontSize",57],["textAlign",40],["linkedStyles",142],["documentMode",47],["default",32]]),Re=["search","ruler","undo","overflow","documentMode"],ze=xn({type:"button",name:"ruler",command:"toggleRuler",allowWithoutEditor:!0,icon:t.ruler,active:!1,tooltip:n.ruler,attributes:{ariaLabel:"Ruler"}}),Ke=xn({type:"button",name:"formattingMarks",command:"toggleFormattingMarks",allowWithoutEditor:!0,icon:t.formattingMarks,active:!1,tooltip:n.formattingMarks,attributes:{ariaLabel:"Formatting marks"}}),ot=xn({type:"dropdown",name:"linkedStyles",command:"setLinkedStyle",tooltip:n.linkedStyles,icon:t.paintbrush,defaultLabel:n.formatText,label:n.formatText,hasCaret:!0,isWide:!0,style:{width:"140px"},suppressActiveHighlight:!0,disabled:!1,attributes:{className:"sd-toolbar-item--linked-styles",ariaLabel:"Linked styles"},options:[{type:"render",key:"linkedStyle",render:()=>{const st=gt=>{Ki(ot);const Xt=typeof gt=="string"?gt:gt?.id??null;if(!Xt)return;const gn={...ot,command:"setLinkedStyle"};e.emitCommand({item:gn,argument:Xt})},_t=e.getActiveLinkedStyleId?.()??null;return Dr("div",{},[Dr(KG,{styles:e.getLinkedStyleOptions?.()??[],onSelect:st,selectedOption:_t})])}}],onActivate:({styleId:st,styleName:_t})=>{const gt=_t||st;ot.label.value=st&&st!=="Normal"?String(gt):n.formatText,ot.disabled.value=!1},onDeactivate:()=>{ot.disabled.value=!0,ot.label.value=n.formatText}}),mt=(st,_t)=>{if(_t.value==st)return Dr("div",{innerHTML:ZW,class:"dropdown-select-icon"})},Ot=xn({type:"dropdown",name:"lineHeight",tooltip:n.lineHeight,icon:t.lineHeight,hasCaret:!1,hasInlineTextInput:!1,hideLabel:!0,inlineTextInputVisible:!1,suppressActiveHighlight:!0,restoreEditorFocus:!0,isWide:!1,command:"setLineHeight",dropdownValueKey:"key",selectedValue:"1",attributes:{ariaLabel:"Line height"},options:[1,1.15,1.5,2,2.5,3].map(st=>({label:st.toFixed(2),key:st,icon:()=>mt(st,Ot.selectedValue),props:{"data-item":"btn-lineHeight-option"}}))}),Mt=20,Kt=32,$e=["linkedStyles","clearFormatting","copyFormat","formattingMarks"],Qt=["zoom","fontFamily","fontSize","redo"],Hn=i<=Eh.lg,qt=e.config?.showFormattingMarksButton===!0,jn=e.config?.showTableOfContentsButton===!0;Hn&&(P.attributes.value={...P.attributes.value,className:`${P.attributes.value.className} sd-toolbar-item--doc-mode-compact`}),Hn&&(ot.attributes.value={...ot.attributes.value,className:`${ot.attributes.value.className} sd-toolbar-item--linked-styles-compact`});let Pn=[Q,I,re,j,F,oe,m,b(),S,b(),p,k,x,M,G,z,b(),L,H,...jn?[R]:[],...e.config?.showWatermarkButton||l?.has("watermark")?[U]:[],...e.config?.showPageNumberButton||l?.has("pageNumber")?[W]:[],Z,fe,b(),Pe,nt,ct,ft,It,Ot,b(),ot,b(),ze,we,...qt?[Ke]:[],K,X,...tK(e)?[v]:[],Le,P,...f];if(i<=Eh.md&&o&&(Pn=Pn.filter(st=>st.type!=="separator")),e.config.mode!=="docx"){const st=Pn.findIndex(gt=>gt.name.value==="linkedStyles");Pn.splice(st-1,2);const _t=["ruler","zoom","undo","redo"];Pn=Pn.filter(gt=>!_t.includes(gt.name.value))}const $r=[];a||(s==="viewer"&&$r.push(re,j),Pn=Pn.filter(st=>!$r.includes(st))),l&&(Pn=Pn.filter(st=>st.name.value==="overflow"||st.isCustomToolbarItem||l.has(st.name.value))),d?.size&&(Pn=Pn.filter(st=>!d.has(st.name.value))),Pn=JW(Pn);const Nr=st=>Re.includes(st.name.value),_r=Pn.find(st=>st.name.value==="overflow"),Tn=Pn.filter(st=>st!==_r);if(u){const st=new Map(u.map((gt,Xt)=>[gt,Xt])),_t=gt=>st.get(gt.name.value)??Number.MAX_SAFE_INTEGER;Tn.sort((gt,Xt)=>_t(gt)-_t(Xt))}const tr=st=>{const _t=[],gt=[],Xt=Tn.filter(Nr).reduce((Te,Ne)=>Te+B1(Ne,Se),0);let gn=Kt+Xt+(st&&_r?B1(_r,Se):0);return Tn.forEach((Te,Ne)=>{const Qe=B1(Te,Se);if(Te.type==="separator"&&Tn[Ne-1]?.name.value==="linkedStyles"&&_t.includes(Tn[Ne-1])){_t.push(Te);return}if(i<Eh.xl+Mt&&$e.includes(Te.name.value)&&o){_t.push(Te);return}if(i<Eh.sm&&Qt.includes(Te.name.value)&&o){_t.push(Te);return}if(Nr(Te)){gt.push(Te);return}gn+Qe<=i||!o?(gt.push(Te),gn+=Qe):_t.push(Te)}),{visibleItems:gt,overflowItems:_t}};let{visibleItems:qn,overflowItems:Bn}=tr(!1);if(o&&_r&&Bn.some(st=>st.type!=="separator")){({visibleItems:qn,overflowItems:Bn}=tr(!0));const st=Pn.indexOf(_r),_t=qn.findIndex(gt=>Pn.indexOf(gt)>st);_t===-1?qn.push(_r):qn.splice(_t,0,_r)}return qn=FE(qn),{defaultItems:qn,overflowItems:Bn.filter(st=>st.type!=="separator")}},BE={bold:"Bold",fontFamily:"Font family",ai:"AI text generation",fontSize:"Font size",italic:"Italic",underline:"Underline",highlight:"Highlight color",strikethrough:"Strikethrough",color:"Text color",search:"Search",link:"Link",image:"Image",tableOfContents:"Table of contents",watermark:"Watermark",pageNumber:"Page number",table:"Insert table",tableActions:"Table options",addRowBefore:"Insert row above",addRowAfter:"Insert row below",addColumnBefore:"Insert column left",addColumnAfter:"Insert column right",deleteRow:"Delete row",deleteColumn:"Delete column",deleteTable:"Delete table",removeBorders:"Remove borders",mergeCells:"Merge cells",splitCell:"Split cell",fixTables:"Fix tables",textAlign:"Alignment",bulletList:"Bullet list",numberedList:"Numbered list",indentLeft:"Left indent",indentRight:"Right indent",directionLtr:"Left-to-right",directionRtl:"Right-to-left",zoom:"Zoom",measurementUnit:"Measurement unit",undo:"Undo",redo:"Redo",trackChanges:"Track Changes",trackChangesAccept:"Accept changes under selection",trackChangesReject:"Reject changes under selection",trackChangesOriginal:"Toggle Show Original",trackChangesFinal:"Toggle Show Final",clearFormatting:"Clear formatting",copyFormat:"Format painter",lineHeight:"Line height",formatText:"Format text",ruler:"Show or hide ruler",formattingMarks:"Show or hide formatting marks",pageBreak:"Insert page break",documentEditingMode:"Editing",documentSuggestingMode:"Suggesting",documentViewingMode:"Viewing",documentEditingModeDescription:"Edit document directly",documentSuggestingModeDescription:"Edits become suggestions",documentViewingModeDescription:"View clean version of document only",linkedStyles:"Linked styles"},oK=e=>e?typeof e!="string"?e instanceof HTMLElement?e:null:e.startsWith("#")||e.startsWith(".")?document.querySelector(e):document.getElementById(e):null;Ft();function zE(e){return mH(e)??O1[e]??null}function Ag(e,t,n,r={}){if(!e?.commands||!t||typeof e.commands.has=="function"&&!e.commands.has(t))return!1;const o=typeof e.commands.executeAsync=="function"?e.commands.executeAsync:e.commands.execute;if(typeof o!="function")return!1;const i=r.firstParty?id(e,t,n):n===void 0?o.call(e.commands,t):o.call(e.commands,t,n),s=a=>{!r.reportUnhandled||a!==!1||r.onError?.(new Error(`[superdoc toolbar] Command "${t}" did not run. Check that it is enabled and has the required input.`))};return i&&typeof i.then=="function"?Promise.resolve(i).then(a=>{s(a),r.onSettled?.()},a=>{r.onError?.(a),r.onSettled?.()}):(s(i),r.onSettled?.()),!0}var iK=["page-numbers-apply","page-number-insert"],sK=new Set(["bold","italic","underline","strike","color","highlight","link","clearFormatting","textAlign","list","numberedlist","indentleft","indentright","lineHeight","linkedStyles"]),aK=new Set(["list","numberedlist"]);function lK(e,t){if(e==="fontFamily"||e==="fontSize"||aK.has(e)&&t?.disabled&&t?.supported!==!1&&t?.reason==null)return!0;if(!sK.has(e))return!1;const n=t?.reason;return n==="range-selection-required"||n==="selection-required"}function jE(e){return!!e?.closest?.("[data-editor-ui-surface], .toolbar-dropdown-menu, .sd-toolbar-dropdown-menu, .sd-tooltip-content")}function cK(e){return["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key)}var uK=new Set([...pH,...Object.keys(gg),"ai","overflow","tableOfContents"]),dK=class extends av.default{config={selector:null,toolbarGroups:["left","center","right"],role:"editor",icons:{...dr},texts:{...BE},fonts:null,hideButtons:!0,responsiveToContainer:!1,mode:"docx",excludeItems:[],toolbarButtonsExclude:[],groups:null,customButtons:[],showFormattingMarksButton:!1,showTableOfContentsButton:!1,showWatermarkButton:!1,showPageNumberButton:!1};toolbarItems=[];overflowItems=[];#e=null;#n=null;isDev=!1;role="editor";superdoc;toolbarContainer=null;toolbar=null;_detachFontsChanged=null;_linkedStyleOptions=Pr([]);constructor(e={}){if(super(),this.config={...this.config,...e},this.toolbarItems=[],this.overflowItems=[],this.isDev=e.isDev||!1,this.superdoc=e.superdoc,this.role=e.role||"editor",this.toolbarContainer=null,this.config.icons={...dr,...e.icons},this.config.texts={...BE,...e.texts},this.config.hideButtons=e.hideButtons??!0,this.config.responsiveToContainer=e.responsiveToContainer??!1,this.activeEditor=e.editor??this.superdoc?.activeEditor??null,this.ui=null,this.snapshot=null,this._unsubscribeController=null,this._detachFormatPainterModeChange=null,this._customCommandRegs=new Map,this._reportedInvalidCustomItems=new Set,this._lastFontOptionsSignature="",!this.config.selector&&this.config.element&&(this.config.selector=this.config.element),this.toolbarContainer=oK(this.config.selector),this.toolbarContainer){const t=(this.config?.uiDisplayFallbackFont||"").toString().trim()||"Arial, Helvetica, sans-serif";this.toolbarContainer.style.setProperty("--sd-ui-font-family",t)}try{if(this.#t(),this.#u(),this.#c(),this.#i(),this._lastFontOptionsSignature=this.#r(),!this.toolbarContainer){this.updateToolbarState();return}this.app=Ac(EG),this.app.directive("click-outside",cb),this.app.config.globalProperties.$toolbar=this,this.toolbar=this.app.mount(this.toolbarContainer),this.updateToolbarState()}catch(t){try{this.destroy()}catch{}throw t}}#t(){this.ui=this.superdoc?.ui??null,this.ui&&(this.snapshot=this.ui.toolbar.getSnapshot(),this._unsubscribeController=this.ui.toolbar.subscribe(()=>{this.snapshot=this.ui.toolbar.getSnapshot(),this.getToolbarItemByName("linkedStyles")?.expand.value&&this.#m(),this.updateToolbarState()}),this._detachFormatPainterModeChange=this.ui.formatPainter.onModeChange(e=>{e==="armed"||e==="persistent"?this.#w():this.#y()}))}#o(){this._unsubscribeController?.(),this._unsubscribeController=null,this._detachFormatPainterModeChange?.(),this._detachFormatPainterModeChange=null,this.#y();for(const e of this._customCommandRegs.values())try{e.unregister?.()}catch{}this._customCommandRegs.clear(),this.ui=null,this.snapshot=null}#i(){if(!this.superdoc||typeof this.superdoc.on!="function"||typeof this.superdoc.off!="function")return;const e=()=>{const t=this.#r();t!==this._lastFontOptionsSignature&&(this._lastFontOptionsSignature=t,this.#p()),this.updateToolbarState()};this.superdoc.on("fonts-changed",e),this._detachFontsChanged=()=>{this.superdoc?.off?.("fonts-changed",e)}}#a(){this._detachFontsChanged?.(),this._detachFontsChanged=null}#u(){if(Array.isArray(this.config.groups)){this.config.toolbarGroups=this.config.groups,this.config.groups=null;return}this.config.groups&&!Array.isArray(this.config.groups)&&Object.keys(this.config.groups).length&&(this.config.toolbarGroups=Object.keys(this.config.groups))}getAvailableWidth(){const e=document.documentElement.clientWidth,t=this.toolbarContainer?.offsetWidth??0;return this.config.responsiveToContainer?t:e}#f(e){return e||kG(this.superdoc?.fonts?.getFontFamilyOptions?.()??[])}#c(){const e=this.getAvailableWidth(),t=new Map(this.#s().filter(C=>C.isCustomToolbarItem&&C.type==="dropdown").map(C=>[C.name.value,C.selectedValue.value])),n=this.config.groups&&!Array.isArray(this.config.groups)&&Object.keys(this.config.groups).length>0,r=n?new Set(Object.values(this.config.groups).flatMap(C=>C)):null,o=new Set([...this.config.excludeItems??[],...this.config.toolbarButtonsExclude??[]]),i=this.config.customButtons||[],s=new Set(uK),a=i.map((C,w)=>{try{if(C?.name&&s.has(C.name))throw new Error(`Toolbar item name "${C.name}" is already taken by another item, so this entry is skipped.`);const S=this.#d(C);return t.has(S.name.value)&&(S.selectedValue.value=t.get(S.name.value)),s.add(S.name?.value),S}catch(S){const b=`${C?.name??`<unnamed@${w}>`}::${S?.message??String(S)}`;return this._reportedInvalidCustomItems.has(b)||(this._reportedInvalidCustomItems.add(b),this.#v(S,C?.name??null)),null}}).filter(Boolean),l=n?new Set(Object.keys(this.config.groups)):null,u=l?a.filter(C=>l.has(C.group?.value||"center")):a;let d=null;if(n){const C=Object.values(this.config.groups).flatMap(S=>S),w=a.filter(S=>l.has(S.group?.value||"center")).map(S=>S.name.value);d=[...new Set([...C,...w])]}const{defaultItems:f,overflowItems:p}=rK({superToolbar:this,toolbarIcons:this.config.icons,toolbarTexts:this.config.texts,toolbarFonts:this.#f(this.config.fonts),hideButtons:this.config.hideButtons,availableWidth:e,role:this.role,isDev:this.isDev,configuredItemNames:r,configuredItemOrder:d,excludedItemNames:o,additionalItems:u});n||(d=[...f.map(C=>C.name.value),...p.map(C=>C.name.value)]);const g=p.filter(C=>d.includes(C.name.value)&&!o.has(C.name.value)),m=g.length?[...d,"overflow"]:d,v=f.filter(C=>m.includes(C.name.value)).filter(C=>!o.has(C.name.value));if(n){const C=new Map(d.map((x,M)=>[x,M])),w=x=>C.get(x.name.value)??Number.MAX_SAFE_INTEGER,S=v.find(x=>x.name.value==="overflow"),b=new Map(v.map((x,M)=>[x,M])),k=v.filter(x=>x!==S);if(k.sort((x,M)=>w(x)-w(M)),S){const x=b.get(S),M=k.findIndex(z=>b.get(z)>x);M===-1?k.push(S):k.splice(M,0,S)}v.splice(0,v.length,...k),g.sort((x,M)=>w(x)-w(M))}if(n)for(const[C,w]of Object.entries(this.config.groups))for(const S of v)w.includes(S.name.value)&&(S.group.value=C);this.toolbarItems=v,this.overflowItems=g}#d(e){const t=xn({...e});t.isCustomToolbarItem=!0;const n=e.command;if(typeof n=="function"&&this.ui?.commands?.register){const r=`__builtin_toolbar__${e.name}`;if(!this._customCommandRegs.has(r)){const o=this.ui.commands.register({id:r,execute:i=>{const s=i?.payload&&typeof i.payload=="object"?i.payload:{};try{const a=n({...i,item:t,argument:s.argument,option:s.option});return a&&typeof a.then=="function"?Promise.resolve(a).catch(l=>(this.#v(l,e.name),!1)):a}catch(a){return this.#v(a,e.name),!1}}});this._customCommandRegs.set(r,o)}}return t}#p(){this.#c(),this.emit("toolbar-items-changed")}#r(){if(this.config.fonts)return"custom-fonts";const e=this.superdoc?.fonts?.getFontFamilyOptions?.()??[];return JSON.stringify(e.map(t=>[t.label,t.value,t.previewFamily]))}getToolbarItemByGroup(e){return this.toolbarItems.filter(t=>(t.group?.value||"center")===e)}getToolbarItemByName(e){return this.#s().find(t=>t.name.value===e)}#s(){return[...this.toolbarItems,...this.overflowItems]}getLinkedStyleOptions(){return this.#m(),this._linkedStyleOptions.value}#m(){this.ui?.styles?.getCatalog?.({includePreview:!0});const e=this.ui?.styles?.getCatalog?.({view:"quickGallery",includePreview:!0})?.items??this.ui?.styles?.getQuickGallery?.()??[];e!==this._linkedStyleOptions.value&&(this._linkedStyleOptions.value=e)}getActiveLinkedStyleId(){return this.ui?.styles?.getActiveParagraphStyle?.()?.styleId??null}setActiveEditor(e){this.activeEditor=e;const t=this.#r();t!==this._lastFontOptionsSignature&&(this._lastFontOptionsSignature=t,this.#p()),this.ui&&(this.snapshot=this.ui.toolbar.getSnapshot()),this.updateToolbarState()}onToolbarResize=()=>{this.#c(),this.updateToolbarState()};#_(e){return e==="ruler"?!!this.superdoc?.config?.rulers:e==="formattingMarks"?!!this.superdoc?.config?.layoutEngineOptions?.showFormattingMarks:!1}#k(e){return e==="watermark"?this.ui?.document?.getSnapshot?.().ready===!0&&typeof this.ui?.watermark?.open=="function":e==="ruler"?typeof this.superdoc?.toggleRuler=="function":e==="formattingMarks"?typeof this.superdoc?.toggleFormattingMarks=="function"||typeof this.superdoc?.setShowFormattingMarks=="function":!1}#g(){const e=this.getToolbarItemByName("documentMode");if(!e)return;const t=(this.snapshot?.commands?.["document-mode"]?.value||"editing").toLowerCase(),n=this.config.texts||{},r=this.config.icons||{},o={editing:{label:n.documentEditingMode||"Editing",icon:r.documentEditingMode||r.documentMode},suggesting:{label:n.documentSuggestingMode||"Suggesting",icon:r.documentSuggestingMode||r.documentMode},viewing:{label:n.documentViewingMode||"Viewing",icon:r.documentViewingMode||r.documentMode}},i=o[t]||o.editing;e.label?.value!==void 0&&(e.label.value=i.label),e.defaultLabel?.value!==void 0&&(e.defaultLabel.value=i.label),e.icon?.value!==void 0&&i.icon&&(e.icon.value=i.icon)}#b(){const e=this.toolbarItems.find(n=>n.name.value==="highlight");if(!e)return;const t={key:"color",type:"render",render:()=>F1(this,e,[],!0)};e.nestedOptions.value=[t]}#A(e){return!!e?.active&&e?.value==null}#x(e){return!!e&&e.disabled===!1&&e.value==null}#I(e){const t=e.name.value;if(e.isCustomToolbarItem&&typeof e.command=="string"){const i=this.snapshot?.commands?.[e.command];return e.setDisabled(e.initiallyDisabled||!i||!!i.disabled),i?.active?e.activate():e.deactivate(),!0}if(t==="tableActions"){const i=ME.map(s=>this.snapshot?.commands?.[s]).some(s=>s&&!s.disabled);return e.setDisabled(!i),!0}if(t==="search")return e.setDisabled(this.superdoc?.uiConfig?.search?.enabled!==!0),!0;if(t==="pageNumber"){const i=iK.map(a=>this.snapshot?.commands?.[a]),s=this.ui?.document?.getSnapshot?.()?.mode==="suggesting";return e.setDisabled(!s&&!i.some(a=>a&&!a.disabled)),!0}if(P1(t)?.disposition==="host-routed")return e.setDisabled(!this.#k(t)),this.#_(t)?e.activate():e.deactivate(),!0;const n=zE(t);if(!n)return!1;const r=this.snapshot?.commands?.[n];lK(t,r)?e.setDisabled(!1):e.setDisabled(!!r?.disabled);const o={textAlign:()=>{r?.value?e.activate({textAlign:r.value}):e.deactivate()},lineHeight:()=>{e.selectedValue.value=r?.value!=null?r.value:""},zoom:()=>{if(r?.value!=null){const i=typeof r.value=="number"?`${r.value}%`:String(r.value);e.onActivate({zoom:i})}},measurementUnit:()=>{r?.value!=null&&e.onActivate({measurementUnit:String(r.value)})},documentMode:()=>{this.#g()},link:()=>{e.active.value=!!r?.active,e.attributes.value=z1(e.attributes.value,r?.value??null)},fontFamily:()=>{if(r?.value!=null){e.activate({fontFamily:r.value});return}if(this.#x(r)){e.activate({},!0);return}e.deactivate()},fontSize:()=>{if(r?.value!=null){e.activate({fontSize:r.value});return}if(this.#A(r)){e.activate({},!0);return}e.deactivate()},color:()=>{r?.value!=null?e.activate({color:r.value}):e.deactivate()},highlight:()=>{r?.value!=null?e.activate({color:r.value}):e.deactivate()},linkedStyles:()=>{const i=r?.value,s=typeof i=="string"?i:i?.styleId,a=i&&typeof i=="object"?i.styleName:null;s?e.activate({styleId:s,styleName:a}):e.label.value=this.config.texts?.formatText||"Format text"},list:()=>{r?.active?(e.activate(),e.selectedValue.value=r.value):(e.deactivate(),e.selectedValue.value=null)},numberedlist:()=>{r?.active?(e.activate(),e.selectedValue.value=r.value):(e.deactivate(),e.selectedValue.value=null)},default:()=>{r?.active?e.activate():e.deactivate()}};return(o[t]??o.default)(),!0}updateToolbarState(){this.#g(),this.#b();const e=this.snapshot?.commands?.["document-mode"]?.value||"editing";!(this.snapshot&&(this.superdoc?.activeEditor??this.activeEditor))||e==="viewing"?(this.#F(),this.#s().forEach(n=>{const r=n.isCustomToolbarItem&&typeof n.command=="string";(n.allowWithoutEditor?.value||r)&&this.#I(n)})):this.#s().forEach(n=>{n.resetDisabled(),this.#I(n)}),this.getToolbarItemByName("overflow")?.setDisabled(!this.overflowItems.some(n=>n.type!=="separator"&&!n.disabled.value));const t=this.getToolbarItemByName("copyFormat");t&&(this.snapshot?.copyFormatActive?t.activate():t.deactivate()),this.emit("toolbar-state-change")}#F(){this.#s().forEach(e=>{const{allowWithoutEditor:t}=e;t?.value||e.setDisabled(!0)})}#T(e,t){const n=this.superdoc;if(e==="watermark"){if(!this.#k(e))return!1;const r=this.ui.watermark.open();if(!r.ok)throw new Error(`[superdoc toolbar] Watermark dialog unavailable: ${r.reason}`);return!0}if(e==="ruler")return typeof n?.toggleRuler=="function"?(n.toggleRuler(),!0):!1;if(e==="formattingMarks"){if(typeof t=="boolean"&&typeof n?.setShowFormattingMarks=="function")return n.setShowFormattingMarks(t),!0;if(typeof n?.toggleFormattingMarks=="function")return n.toggleFormattingMarks(),!0}return!1}#P(e,t){const n=e?.name?.value;if(!n)return!1;const r={firstParty:!0,onSettled:()=>this.updateToolbarState(),onError:i=>this.#v(i,n)};if(n==="image"&&t==null)return this.#D();if(n==="tableActions"){const i=RE[t?.command];return i?Ag(this.ui,i,void 0,r):!1}if(P1(n)?.disposition==="unsupported")return!0;const o=zE(n);return o?Ag(this.ui,o,t,r):!1}#D(){return this.snapshot?.commands?.image?.disabled||(this.#e||(this.#e=vD({ownerDocument:this.toolbarContainer?.ownerDocument??document,onPick:async e=>{const t=await mD(e,this.superdoc?.config?.handleImageUpload);Ag(this.ui,"image",{src:t},{firstParty:!0,onSettled:()=>this.updateToolbarState(),onError:n=>this.#v(n,"image")})},onError:e=>this.#v(e,"image")})),this.#e.open()),!0}#w(){if(this.#n)return;const e=this.superdoc?.activeEditor?.container??document,t=i=>{jE(i.target)||this.ui.formatPainter.setPointerSelecting(!0)},n=i=>{this.ui.formatPainter.setPointerSelecting(!1),!jE(i.target)&&this.ui.formatPainter.notifyPointerUp()},r=i=>{if(i.key==="Escape"){this.ui.formatPainter.cancel();return}cK(i)&&this.ui.formatPainter.setKeyboardSelecting(!0)},o=()=>{this.ui.formatPainter.setKeyboardSelecting(!1),this.ui.formatPainter.notifyKeyUp()};e.addEventListener("pointerdown",t),e.addEventListener("pointerup",n),e.addEventListener("keydown",r),e.addEventListener("keyup",o),this.#n=()=>{e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",n),e.removeEventListener("keydown",r),e.removeEventListener("keyup",o)}}#y(){this.#n&&(this.#n(),this.#n=null)}#v(e,t){const n={error:e instanceof Error?e:new Error(String(e)),originalError:e,itemName:t??null,editor:this.superdoc?.activeEditor??this.activeEditor??null},r={...n};this.emit("exception",n),this.superdoc?.emit?.("exception",r)}emitCommand({item:e,argument:t,option:n}){const r=e?.name?.value,{command:o}=e,i=t!=null;if(!(e?.type==="dropdown"&&!i&&(o==="setFontFamily"||o==="setFontSize"))){if(r==="search"){this.superdoc?.emit?.("search:open");return}try{if(P1(r)?.disposition==="host-routed"){this.#T(r,t),this.updateToolbarState();return}if(typeof o=="function"){const s=`__builtin_toolbar__${r}`;if(this._customCommandRegs.has(s)&&this.ui?.commands?.execute)this.ui.commands.execute(s,{argument:t,option:n});else{const a=o({item:e,argument:t,option:n,ui:this.ui,superdoc:this.superdoc});a&&typeof a.then=="function"&&Promise.resolve(a).catch(l=>this.#v(l,r))}this.updateToolbarState();return}if(e?.isCustomToolbarItem&&typeof o=="string"){if(!Ag(this.ui,o,t,{onSettled:()=>this.updateToolbarState(),onError:s=>this.#v(s,r),reportUnhandled:!0}))throw new Error(`[superdoc toolbar] Command not handled: ${String(o)}`);this.updateToolbarState();return}if(!this.#P(e,t)&&o)throw new Error(`[superdoc toolbar] Command not handled: ${String(o)}`);this.updateToolbarState()}catch(s){this.#v(s,r)}}}destroy(){this.#y(),this.#e?.destroy(),this.#e=null,this.#a(),this.#o(),this.app?.unmount(),this.app=null,this.toolbar=null}};function fK(e){return new dK(e)}Ft();var hK=['[data-sdt-type="structuredContent"][data-sdt-id]','[data-sdt-type="structuredContent"][data-sdt-container-id]','[data-sdt-container-type="structuredContent"][data-sdt-container-id]'].join(", "),pK=800,VE=typeof Blob=="function"?Object.getOwnPropertyDescriptor(Blob.prototype,"size")?.get:void 0,UE=e=>{if(!VE)return!1;try{return VE.call(e),!0}catch{return!1}};function mK(e){return e.key==="Alt"||e.key==="Control"||e.key==="Meta"||e.key==="Shift"||(e.ctrlKey||e.metaKey)&&e.shiftKey&&!e.altKey&&(e.code==="Digit8"||e.key==="8"||e.key==="*")?!0:(e.ctrlKey||e.metaKey)&&["b","c","f","i","s","u"].includes(e.key.toLowerCase())}var gK=Object.freeze(["#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F","#BB8FCE","#85C1E2","#F1948A","#82E0AA","#F8C471","#AED6F1","#D7BDE2","#A3E4D7","#F0B27A","#AEB6BF","#E74C3C","#2ECC71","#3498DB","#E67E22","#1ABC9C","#9B59B6","#34495E","#F39C12"]),vK=["original","markup","final"],yK=["review","original","final","off"];function $E(e){return vK.includes(e)}function bK(e){return e==="markup"?"review":e}function HE(e){return yK.includes(e)}function wK(e){const t=e.modules?.trackChanges?.mode;if(HE(t))return t;const n=e.layoutEngineOptions?.trackedChanges?.mode;return HE(n)?n:null}function Ig(e,t){const n=e.viewing,r=$E(n?.trackedChanges)?n.trackedChanges:null,o=r?bK(r):t||(e.trackChanges?.visible===!0?"review":"original");return{comments:typeof n?.comments=="boolean"?n.comments:e.comments?.visible===!0,renderMode:o,trackChangesVisible:r?r==="markup":e.trackChanges?.visible===!0}}async function CK(e,t){const n=new n6.default;return e.forEach((r,o)=>{n.file(t[o],r)}),n.generateAsync({type:"blob",compression:"DEFLATE"})}function V1(e){return!!(e&&(e.synced===!0||e.isSynced===!0))}function GE(e){try{e.synced=!0}catch{}try{e.isSynced=!0}catch{}}function kK(e,t){if(!e)return()=>{};if(V1(e))return t(),()=>{};const n=typeof e.on=="function"?e.on.bind(e):null,r=typeof e.off=="function"?e.off.bind(e):null;if(!n)return t(),()=>{};let o=!1;const i=()=>{o||(o=!0,r?.("synced",a),r?.("sync",l))},s=()=>{o||(i(),t())},a=()=>{GE(e),s()},l=u=>{u!==!1&&(u===!0||V1(e))&&(GE(e),s())};return n("synced",a),n("sync",l),V1(e)&&s(),i}function SK(e,t){const n=e.composedPath();if(!n.includes(t))return null;const r=n.find(a=>a instanceof HTMLElement&&a.matches(hK));if(!r)return null;const o=n.some(a=>a instanceof HTMLElement&&a.classList.contains(Zp.BLOCK_SDT_LABEL)),i=r.getAttribute("data-sdt-container-id")?.trim()||null,s=r.getAttribute("data-sdt-id")?.trim()||null;return o?i??s:s??i}function _K(e){if(!e||typeof e!="object")return[];const t=e.items;return Array.isArray(t)?t:[]}function WE(e){if(!e||typeof e.id!="string"||e.kind!=="inline"&&e.kind!=="block"||typeof e.controlType!="string")return null;const t=e.properties?.tag,n=e.properties?.alias;return{id:e.id,controlType:e.controlType,scope:e.kind,...typeof t=="string"&&t?{tag:t}:{},...typeof n=="string"&&n?{alias:n}:{}}}function KE(e){const t=e.selectionTarget??e.target;if(!t)return null;try{return JSON.stringify(t)}catch{return null}}function AK(e,t){switch(e.state){case"failed":return"failed";case"degraded":return e.detail==="reconnecting"?"reconnecting":"lost";case"synced":return t?"recovered":"initial";default:return t?"reconnecting":"initial"}}function Xo(e){return!!(e&&typeof e=="object"&&e.editorVersion===2)}function qE(e){return typeof e=="string"&&e.length>0?e:null}function YE(e){return e?Xo(e)?qE(e.documentId??e.options?.documentId??null):qE(typeof e.getDocumentId=="function"?e.getDocumentId():e.options?.documentId):null}function IK(e){if(!e||Xo(e))return null;const t=e;return t.documentRenderer??t.presentationEditor??null}function ws(e){if(!e)return null;if(Xo(e))return e.fonts??null;const t=IK(e);return t?{getReport:()=>t.getFontReport?.()??[],getMissingFonts:()=>t.getMissingFonts?.()??[],getDocumentFonts:()=>[...new Set((t.getFontReport?.()??[]).map(n=>n.logicalFamily))],getDocumentFontOptions:()=>t.getDocumentFontOptions?.()??[],getFontFamilyOptions:()=>t.getFontFamilyOptions?.()??[],getLastFontsChangedPayload:()=>t.getLastFontsChangedPayload?.()??null,map:n=>t.mapFonts(n),unmap:n=>t.unmapFonts(n),add:n=>t.addFonts(Array.isArray(n)?n:[n]),preload:n=>t.preloadFonts(n)}:null}var Eg=class extends av.default{static{this.allowedTypes=[br,Da,Du]}#e;#n;#t;#o;#i;#a;#u;#f;#c;#d;#p;#r;#s;#m;#_;#k;#g;#b;#A;#x;#I;#F;#T;#P;#D;#w;#y;get uiConfig(){return this.#y}#v;get interactionConfig(){return this.#v}#N;get surfacesConfig(){return this.#N}#E;#h;#R;#M;#L;constructor(e){if(super(),this.#e=!1,this.#t=!1,this.#o=null,this.#i=null,this.#a=null,this.#u=null,this.#f=null,this.#c=null,this.#d=!1,this.#p=null,this.#r=null,this.#s=null,this.#m=null,this.#_=!1,this.#k=!1,this.#g=null,this.#b=null,this.#A=!1,this.#x=null,this.#I=null,this.#F=n=>{this.listenerCount("content-control:active-change")>0&&(this.#A||(this.#x=n.pointerId),this.#A=!0,this.#g="pointer",this.#b=null)},this.#T=n=>{n.pointerId===this.#x&&(this.#A=!1,this.#x=null,this.#g??="pointer",this.#g==="pointer"&&(this.#b=Date.now()+pK))},this.#P=n=>{this.listenerCount("content-control:active-change")>0&&!mK(n)&&(this.#g="keyboard",this.#b=null)},this.#D=n=>{this.#X(n)},this.#w=null,this.#y=bE({}),this.#v=wE({}),this.#N=kE({}),this.version="0.0.0",this.users=[],this.whiteboard=null,this.colors=[],this.readyEditors=0,this.#h=new fH,this.#R=null,this.#M=!1,this.#L=null,this.config={selector:"#superdoc",documentMode:"editing",allowSelectionInViewMode:!1,role:"editor",documents:[],editorExtensions:[],colors:[],users:[],user:{...M1},layoutEngineOptions:{},modules:{},licenseKey:void 0,telemetry:{enabled:!0},title:"SuperDoc",conversations:[],isInternal:!1,comments:{visible:!1},toolbarGroups:["left","center","right"],toolbarIcons:{},toolbarTexts:{},uiDisplayFallbackFont:"Arial, Helvetica, sans-serif",isDev:!1,disablePiniaDevtools:!1,onEditorBeforeCreate:()=>null,onEditorCreate:()=>null,onEditorDestroy:()=>null,onSourceComplete:()=>null,onSourceSignalsComplete:()=>null,onContentError:()=>null,onReady:()=>null,onCommentsUpdate:()=>null,onContentControlActiveChange:()=>null,onContentControlClick:()=>null,onAwarenessUpdate:()=>null,onLocked:()=>null,onPdfDocumentReady:()=>null,onSidebarToggle:()=>null,onCollaborationReady:()=>null,onEditorUpdate:()=>null,onCommentsListChange:()=>null,onException:()=>null,onListDefinitionsChange:()=>null,onPaginationUpdate:()=>null,onTransaction:()=>null,disableContextMenu:!1,viewOptions:{layout:"print"},useLayoutEngine:!0},this.#ne=new WeakSet,this.#re=new WeakMap,this.#oe=null,this.#K=null,this.#j=null,!e.selector)throw new Error("SuperDoc: selector is required");const t=typeof e.selector=="string"?document.querySelector(e.selector):e.selector;if(!(t instanceof HTMLElement))throw new Error("SuperDoc: selector must be a valid CSS selector string or DOM element");this.#n=Qx(this,e,()=>this.version,t),this.#E=new F$({getModuleConfig:()=>this.#N}),this.#s=t,t.addEventListener("pointerdown",this.#F,!0),t.ownerDocument.addEventListener("pointerup",this.#T,!0),t.ownerDocument.addEventListener("pointercancel",this.#T,!0),t.addEventListener("keydown",this.#P,!0),t.addEventListener("click",this.#D,!0),this.#l("content-control:active-change",e.onContentControlActiveChange),this.#S(e,t),this.#k=!0,this.listenerCount("content-control:active-change")>0&&this.ui}async#X(e){const t=this.#s;if(!t)return;const n=SK(e,t),r=this.activeEditor?.doc?.contentControls?.list;if(!(!n||typeof r!="function"))try{const o=await r();if(this.#e)return;const i=WE(_K(o).find(s=>s.id===n));i&&this.emit("content-control:click",{target:i,source:"pointer"})}catch{return}}async#S(e,t){this.#L=wK(e),this.config={...this.config,...e,modules:{...this.config.modules,...e.modules},layoutEngineOptions:{...this.config.layoutEngineOptions,...e.layoutEngineOptions}},typeof this.config.viewing?.comments=="boolean"&&(this.config.comments={...this.config.comments,visible:this.config.viewing.comments}),!this.config.comments||typeof this.config.comments!="object"?this.config.comments={visible:!1}:typeof this.config.comments.visible!="boolean"&&(this.config.comments.visible=!1),R1(this.config),this.config.documents=this.config.documents||[],this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};const n=this.config.viewOptions?.layout==="web",r=this.config.layoutEngineOptions?.flowMode==="semantic";if(!n&&r&&(console.warn("[SuperDoc] flowMode 'semantic' is only valid with web layout. Coercing to 'paginated'."),this.config.layoutEngineOptions.flowMode="paginated"),this.editorVersion=2,this.#Ue(),this.config.user=q$(this.config.user),this.config.layoutEngineOptions.virtualization||(this.config.layoutEngineOptions.virtualization={enabled:!0,window:5,overscan:1}),this.config.modules=this.config.modules||{},Object.prototype.hasOwnProperty.call(this.config.modules,"comments")||(this.config.modules.comments={}),this.config.modules.comments=iA(this.config.modules.comments),this.#y=bE(this.config),this.#v=wE(this.config),this.#N=kE(this.config),this.config.disableContextMenu=!this.#y.contextMenu.enabled,this.config.rulers=this.#y.ruler.enabled,this.#y.comments.enabled?this.config.modules.comments===!1&&(this.config.modules.comments={}):this.config.modules.comments=!1,this.#y.comments.enabled){this.config.modules.comments===!0&&(this.config.modules.comments={});const i=this.config.modules.comments;i&&(i.readOnly=this.#v.comments.readOnly,i.allowResolve=this.#v.comments.allowResolve)}if(this.config.colors=u6(this.config.colors),this.userColorMap=new Map,this.colorIndex=0,this.version="2.22.0-next.4",this.#ie("🦋 [superdoc] Using SuperDoc version:",this.version),this.superdocId=e.superdocId||fl(),this.colors=this.config.colors??[],this.#Z(),await RM(),this.#e)return;if(await this.#ee(this.config.modules),this.#e){this.#we();return}this.user=this.config.user,this.users=this.config.users||[],this.socket=null,this.isDev=this.config.isDev||!1,this.activeEditor=null,this.comments=[],this.#R||(this.#R=this.#h.subscribe(i=>{this.#He(i.nextRuntimeId,i.legacyEditorProjection)})),this.isLocked=this.config.isLocked||!1,this.lockedBy=this.config.lockedBy||null;const o=document.createElement("div");o.style.display="contents",t.appendChild(o),this.#r=o,this.#J(),this.#V(),this.#Ge(),this.#O()}#O(){if(this.#Q(),this.readyEditors=0,!this.app)throw new Error("SuperDoc: #startRuntime called before #initVueApp populated this.app");this.app.mount(this.#r)}#V(){const e=this.config.modules?.whiteboard,t=e!==!1&&(e?.enabled??!1);this.whiteboard=new lV({Renderer:P$,superdoc:this,enabled:t}),this.emit("whiteboard:init",{whiteboard:this.whiteboard})}get requiredNumberOfEditors(){return this.#C("requiredNumberOfEditors").documents.filter(e=>e.type===br).length}get ui(){return this.#w||(this.#w=hF({superdoc:this}),this.#e&&this.#w.destroy()),this.#U(),this.#w}get diagnostics(){return this.#n}emit(e,...t){return(e==="exception"||e==="document-replaced"||e==="ready"||e==="active-editor-change"||e==="collaboration-ready"||e==="collaboration-connection-change"||e==="locked")&&Wd(this,e,()=>t[0]),super.emit(e,...t)}on(e,t,n){return super.on(e,t,n),e==="content-control:active-change"&&this.#k&&this.ui,this}addListener(e,t,n){return super.addListener(e,t,n),e==="content-control:active-change"&&this.#k&&this.ui,this}once(e,t,n){return super.once(e,t,n),e==="content-control:active-change"&&this.#k&&this.ui,this}removeListener(e,t,n,r){return super.removeListener(e,t,n,r),this.#B(),this}off(e,t,n,r){return super.off(e,t,n,r),this.#B(),this}removeAllListeners(e){return super.removeAllListeners(e),this.#B(),this}#B(){this.listenerCount("content-control:active-change")>0||(this.#m?.(),this.#m=null,this.#I=null,this.#g=null,this.#b=null,this.#A=!1,this.#x=null)}#U(){if(this.#m||this.#_||!this.#w||this.#e||this.listenerCount("content-control:active-change")===0)return;let e=null,t=[],n=null,r=null,o=!0;this.#_=!0;try{n=this.#w.selection.observe(s=>{if(o){o=!1;return}if(s.status!=="ready")return;const a=KE(s);if(!a)return;this.#g==="pointer"&&this.#b!==null&&Date.now()>this.#b&&(this.#g=null,this.#b=null);const l=this.#g??(this.#A?"pointer":null),u=this.activeEditor;(l||this.#I?.editor!==u||this.#I.key!==a)&&(this.#I={editor:u,key:a,source:l??"keyboard"}),this.#g=null,this.#b=null}),r=this.#w.contentControls.observeActivePath(s=>{const a=this.activeEditor,l=s.activeIds.map(v=>WE(s.items.find(C=>C.id===v)));if(l.some(v=>v===null))return;const u=l,d=a===e,f=u.length===t.length&&u.every((v,C)=>v.id===t[C]?.id);if(d&&f)return;if(u.length===0&&t.length===0){e=a;return}const p=d?t[0]??null:null;e=a,t=u;const g=KE(this.#w.selection.getSnapshot()),m=this.#I;this.emit("content-control:active-change",{active:u[0]??null,previous:p,activePath:u,source:g&&m?.editor===a&&m.key===g?m.source:"keyboard"})});const i=()=>{n?.(),r?.()};this.#e||this.listenerCount("content-control:active-change")===0?i():this.#m=i}catch(i){throw n?.(),r?.(),i}finally{this.#_=!1}}get state(){return{documents:this.#C("state").documents.map(e=>xl(e.data)?{...e,data:vb(e.data,e.type||"application/vnd.openxmlformats-officedocument.wordprocessingml.document")}:e),users:this.users}}getDocumentRuntimeForDocument(e){return typeof e!="string"||e.length===0?null:(this.superdocStore?.documents??[]).find(t=>t?.getEditor?.()?.options?.documentId===e)?.getDocumentRuntime?.()??null}getComment(e){return typeof e!="string"||e.length===0?null:this.commentsStore?.getComment?.(e)??null}get element(){return typeof this.config.selector=="string"?document.querySelector(this.config.selector):this.config.selector}#Z(){const e=this.config.document,t=!!e&&typeof e=="object"&&(xl(e)||typeof Blob=="function"&&e instanceof Blob||Object.keys(e).length>0),n=typeof e=="string"&&e.length>0,r=this.config.documents&&this.config.documents?.length;if((t||n)&&r&&console.warn("🦋 [superdoc] You can only provide one of document or documents"),t){const o=bb(e);this.config.documents=[{id:fl(),...o}]}else n&&(this.config.documents=[{id:fl(),type:br,url:this.config.document,name:"document.docx"}]);Array.isArray(this.config.documents)&&this.config.documents.length>0&&(this.config.documents=this.config.documents.map(o=>{const i=bb(o);if(!i||typeof i!="object")return i;const s=typeof i=="object"&&"id"in i&&i.id||o&&typeof o=="object"&&"id"in o&&o.id;return{...i,id:s||fl()}}))}#Q(){const{app:e,pinia:t,superdocStore:n,commentsStore:r,highContrastModeStore:o}=Yj({disablePiniaDevtools:!!this.config.disablePiniaDevtools});this.app=e,this.pinia=t,this.app.config.globalProperties.$config=this.config,this.app.config.globalProperties.$documentMode=this.config.documentMode,this.app.config.globalProperties.$superdoc=this,this.app.provide("surfaceManager",this.#E),this.superdocStore=n,this.commentsStore=r,this.highContrastModeStore=o,typeof this.superdocStore.setExceptionHandler=="function"&&this.superdocStore.setExceptionHandler(s=>this.emit("exception",s)),this.superdocStore.init(this.config);const i=this.config.modules.comments;this.commentsStore.init(i||{}),this.isCollaborative&&mM(this),this.#le()}#l(e,t){t&&this.on(e,t)}#J(){this.#l("editorBeforeCreate",this.config.onEditorBeforeCreate),this.#l("editorCreate",this.config.onEditorCreate),this.#l("editorDestroy",this.config.onEditorDestroy),this.#l("source:complete",this.config.onSourceComplete),this.#l("source:signals-complete",this.config.onSourceSignalsComplete),this.#l("ready",this.config.onReady),this.#l("comments-update",this.config.onCommentsUpdate),this.#l("content-control:click",this.config.onContentControlClick),this.#l("awareness-update",this.config.onAwarenessUpdate),this.#l("locked",this.config.onLocked),this.#l("pdf:document-ready",this.config.onPdfDocumentReady),this.#l("sidebar-toggle",this.config.onSidebarToggle),this.#l("collaboration-ready",this.config.onCollaborationReady),this.#l("collaboration-connection-change",this.config.onCollaborationConnectionChange),this.on("collaboration-ready",e=>this.#ke(e?.editor??null)),this.#l("editor-update",this.config.onEditorUpdate),this.#l("tracked-changes:bulk-decision",this.config.onTrackedChangesBulkDecision),this.on("content-error",this.onContentError),this.#l("exception",this.config.onException),this.#l("list-definitions-change",this.config.onListDefinitionsChange),this.#l("pagination-update",this.config.onPaginationUpdate),this.#l("fonts-resolved",this.config.onFontsResolved),this.#l("fonts-changed",this.config.onFontsChanged),this.#l("zoomChange",this.config.onZoomChange),this.#l("viewport-change",this.config.onViewportChange),this.#l("page-margins-change",this.config.onPageMarginsChange)}async#ee({collaboration:e}={}){return e?(this.isCollaborative=!1,this.config.documents.length===0&&(this.config.documents=[{id:fl(),type:br,name:"document.docx"}]),this.config.v2CollaborationPreflightFailure={code:"collaboration-v1-config-unsupported",message:"SuperDoc v2 cannot use modules.collaboration because it is the SuperDoc v1 collaboration API. SuperDoc did not attach the provider or change the document. Configure Document.v2Collaboration with a v2 room instead."},this.config.documents):this.config.documents}#ce(e,t){this.isCollaborative=!0,this._commentsCollabInitialized=!1,this.ydoc=Gr(e),this.provider=Gr(t),this.#Ee();const n=this.config;this._cleanupAwareness=uM(t,this,n.user),n.documents.forEach(r=>{r.ydoc=e,r.provider=t,r.role=this.config.role})}#Ce(){this.#p=null,this.#te(),typeof this._cleanupAwareness=="function"&&(this._cleanupAwareness(),this._cleanupAwareness=null),this.isCollaborative=!1,this._commentsCollabInitialized=!1,this.ydoc=void 0,this.provider=void 0;const e=this.config;delete e.modules.collaboration,e.documents.forEach(t=>{delete t.ydoc,delete t.provider})}#te(){if(this.#a){try{this.#a()}catch{}this.#a=null}if(this.#u){try{this.#u()}catch{}this.#u=null}if(this.#f){try{this.#f()}catch{}this.#f=null}}#ke(e){this.#te(),Xo(e)&&(this.#_e(e),this.#Ae(e),this.#Se(e))}#Se(e){const t=e.connection;if(!t||typeof t.subscribe!="function")return;const{documentId:n}=t;this.#c?.documentId!==n&&(this.#c=null,this.#d=!1);const r=o=>{if(this.#e)return;const i=this.#c;if(i&&i.state===o.state&&i.detail===(o.detail??null))return;const s={documentId:n,state:o.state,previousState:i?.state??null,kind:AK(o,this.#d),detail:o.detail??null,superdoc:this};this.#c=s,o.state==="synced"&&(this.#d=!0),this.emit("collaboration-connection-change",s)};try{const o=t.getSnapshot?.();o&&r(o),this.#f=t.subscribe(r)}catch(o){console.warn("[SuperDoc] v2 connection bridge failed to subscribe",o)}}getCollaborationConnectionState(){return this.#c}#_e(e){const t=e.presence;if(!t||typeof t.subscribe!="function")return;const n=oV(()=>this.user),r=o=>{if(this.#e)return;const i=n.next(o);this.emit("awareness-update",{...i,superdoc:this})};try{const o=t.getSnapshot?.();o&&r(o),this.#a=t.subscribe(r)}catch(o){console.warn("[SuperDoc] v2 awareness bridge failed to subscribe",o)}}#Ae(e){const t=e.lock;if(!t||typeof t.subscribe!="function")return;const n=r=>{this.#e||this.#$(!!r.isLocked,this.#ue(r.lockedBy??null))};try{if(this.#p&&typeof t.setLocked=="function"){const o=this.#p;t.setLocked(o.isLocked,o.isLocked?o.lockedBy:null),this.#p=null}const r=t.getSnapshot?.();r&&n(r),this.#u=t.subscribe(n)}catch(r){console.warn("[SuperDoc] v2 lock bridge failed to subscribe",r)}}#ue(e){return!e||typeof e!="object"||Array.isArray(e)?null:{...e}}#Ie(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}#$(e,t){this.isLocked===e&&this.#Ie(this.lockedBy,t)||(this.isLocked=e,this.lockedBy=t,this.#ie("🦋 [superdoc] Locking superdoc:",e,t,`
|
|
107
107
|
|
|
108
108
|
|
|
109
109
|
`),this.emit("locked",{isLocked:e,lockedBy:t}))}#Ee(){const e=this.config.user;if(!e||e.color)return;const t=this.colors.length>0?this.colors:gK,n=e.id||e.email||e.name||"";let r=5381;for(let o=0;o<n.length;o++)r=(r<<5)+r^n.charCodeAt(o);e.color=t[Math.abs(r)%t.length]}async upgradeToCollaboration(e){if(this.#o){const{target:r}=this.#he(e);if(this.#xe(r,this.#o.target))return this.#o.promise;throw Object.assign(new Error("SuperDoc: a different collaboration target is already upgrading"),{code:"collaboration-upgrade-target-conflict"})}const{target:t}=this.#Be(e);this.#t=!0;const n=(async()=>{try{const r=await this.#Ne(),o=this.#Re(),i=this.#Te();this.#Le();try{this.#p=i;const s=await this.#Oe(t,r);this.#Fe(s,t),this.#p=null;const a=this.activeEditor?.options?.documentId,l=s.configDoc.v2Collaboration?.documentId;if(typeof a!="string"||a!==s.configDoc.id||typeof l!="string"||l!==t.documentId)throw new Error("SuperDoc: collaboration upgrade did not attach the expected room and document");return{roomId:l,documentId:a}}catch(s){throw this.#Me(o),s}}finally{this.#i=null,this.#t=!1,this.#o=null}})();return this.#o={target:t,promise:n},n}#xe(e,t){if(e.token!==t.token)return!1;const n=new WeakMap,r=(o,i)=>{if(Object.is(o,i))return!0;if(!o||!i||typeof o!="object"||typeof i!="object"||Object.getPrototypeOf(o)!==Object.getPrototypeOf(i))return!1;if(n.has(o))return n.get(o)===i;if(n.set(o,i),o instanceof Date&&i instanceof Date)return o.getTime()===i.getTime();if(o instanceof RegExp&&i instanceof RegExp)return o.source===i.source&&o.flags===i.flags;if(o instanceof ArrayBuffer&&i instanceof ArrayBuffer)return r(Array.from(new Uint8Array(o)),Array.from(new Uint8Array(i)));if(ArrayBuffer.isView(o)&&ArrayBuffer.isView(i))return o.constructor===i.constructor&&r(Array.from(new Uint8Array(o.buffer,o.byteOffset,o.byteLength)),Array.from(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)));if(o instanceof Map&&i instanceof Map)return o.size===i.size&&r(Array.from(o.entries()),Array.from(i.entries()));if(o instanceof Set&&i instanceof Set)return o.size===i.size&&r(Array.from(o.values()),Array.from(i.values()));if(Array.isArray(o)&&Array.isArray(i))return o.length===i.length&&o.every((l,u)=>r(l,i[u]));if(Object.getPrototypeOf(o)!==Object.prototype&&Object.getPrototypeOf(o)!==null)return!1;const s=Object.keys(o).sort(),a=Object.keys(i).sort();return s.length===a.length&&s.every((l,u)=>l===a[u]&&r(o[l],i[l]))};return r({...e,token:void 0},{...t,token:void 0})}#Te(){return{isLocked:this.isLocked,lockedBy:this.lockedBy?{...this.lockedBy}:null}}#Re(){const e=this.config.documents.find(r=>r.type===br),t=this.superdocStore?.documents.find(r=>r.id===e.id)??null,n=t?Cn(t):null;return{isCollaborative:this.isCollaborative,configV2Collaboration:e.v2Collaboration??null,configData:e.data,storeDoc:t,storeV2Collaboration:this.#De(n),storeData:t?.data}}#Me(e){this.#p=null;const t=this.config.documents.find(n=>n.type===br);t.v2Collaboration=e.configV2Collaboration,t.data=e.configData,this.isCollaborative=e.isCollaborative,e.storeDoc&&(e.storeDoc.data=e.storeData,this.#G(e.storeDoc,e.storeV2Collaboration))}#Le(){if(this.#e)throw new Error("SuperDoc: instance was destroyed during upgrade")}#C(e){if(!this.superdocStore)throw new Error(`SuperDoc: ${e} requires the instance to be ready; wait for the "ready" event before calling.`);return this.superdocStore}#Ke(e){if(!this.commentsStore)throw new Error(`SuperDoc: ${e} requires the instance to be ready; wait for the "ready" event before calling.`);return this.commentsStore}#H(e){if(!this.superdocStore)throw new Error(`SuperDoc: ${e} requires the instance to be ready; wait for the "ready" event before calling.`)}#Pe(e,t){const n=this.superdocStore?.documents;if(Array.isArray(n))for(const r of n){const o=Cn(r);o.ydoc&&typeof o.ydoc=="object"&&"value"in o.ydoc&&(o.ydoc.value=e),o.provider&&typeof o.provider=="object"&&"value"in o.provider&&(o.provider.value=t)}}#De(e){if(!e)return null;const t=e.v2Collaboration;return t&&typeof t=="object"&&"value"in t?t.value:t??null}#G(e,t){const n=Cn(e).v2Collaboration;if(n&&typeof n=="object"&&"value"in n){n.value=t;return}e.v2Collaboration=t}#de(e){const t=e.syncTimeoutMs===void 0?{}:{syncTimeoutMs:e.syncTimeoutMs};return e.providerFamily==="extension"?{providerType:"extension",adapterId:e.adapterId,documentId:e.documentId,roomMode:e.roomMode,...t,...e.providerOptions!==void 0?{providerOptions:e.providerOptions}:{},...e.token?{token:e.token}:{}}:e.providerFamily==="liveblocks"?{providerType:"liveblocks",documentId:e.documentId,roomMode:e.roomMode,...t,...e.publicApiKey?{publicApiKey:e.publicApiKey}:{},...e.authEndpoint?{authEndpoint:e.authEndpoint}:{}}:e.providerFamily==="hocuspocus"?{providerType:"hocuspocus",documentId:e.documentId,roomMode:e.roomMode,...t,...e.serverUrl?{serverUrl:e.serverUrl}:{},...e.params?{params:e.params}:{},...e.token?{token:e.token}:{}}:{providerType:"y-websocket",documentId:e.documentId,roomMode:e.roomMode,...t,...e.serverUrl?{serverUrl:e.serverUrl}:{},...e.params?{params:e.params}:{}}}async#Oe(e,t){const n=this.config.documents.find(s=>s.type===br),r=this.#C("upgradeToCollaboration").documents.find(s=>s.id===n.id);if(!r)throw new Error("SuperDoc: source document store entry is not available for upgrade");const o=r.getEditor?.();if(!Xo(o)||typeof o.upgradeToCollaboration!="function")throw new Error("SuperDoc: live v2 editor cannot attach collaboration in place");const i=this.#de({...e,roomMode:"create"});return n.v2Collaboration=i,this.#G(r,i),this.isCollaborative=!0,await o.upgradeToCollaboration(t,i),n.data=t,r.data=t,{configDoc:n,storeDoc:r}}#Fe(e,t){const n=this.#de({...t,roomMode:"join"});e.configDoc.v2Collaboration=n,this.#G(e.storeDoc,n)}async#Ne(){const e=this.activeEditor;if(Xo(e)&&typeof e.save=="function"){const r=await e.save();return this.#z(r)}const t=this.config.documents.find(r=>r.type===br),n=(this.superdocStore?.documents.find(r=>r.id===t.id)??null)?.data??t.data;if(n instanceof Blob)return n;if(xl(n))return this.#z(n);throw new Error("SuperDoc: upgradeToCollaboration() requires a live v2 editor save or DOCX Blob source")}#z(e){if(e instanceof Blob)return e;if(xl(e))return vb(e,br);throw new Error("SuperDoc: active v2 editor returned an unsupported DOCX save payload")}#fe(e,t){const n=YE(e),r=(n?this.config.documents.find(a=>a.id===n):null)??this.config.documents.find(a=>a.type==="application/vnd.openxmlformats-officedocument.wordprocessingml.document");if(!r)return;const o=this.#z(t),i=r.v2Collaboration&&typeof r.v2Collaboration=="object"&&r.v2Collaboration.roomMode==="create"?{...r.v2Collaboration,roomMode:"join"}:null;r.data=o,r.fieldContext={},i&&(r.v2Collaboration=i);const s=this.superdocStore?.documents.find(a=>a.id===r.id)??null;s&&(s.data=o,s.fieldContext={},i&&this.#G(s,i))}#qe(){const e=this.superdocStore?.documents;if(!e?.length)throw new Error("SuperDoc: no store documents available for upgrade");const t=e[0].getDocumentRuntime?.()||e[0].getEditor?.();if(!t?.attachCollaboration)throw new Error("SuperDoc: editor does not support attachCollaboration");return t}#Ye(){this.#Ce(),this.#Pe(null,null)}#Xe(e){const n=e.editor??e;return n.options?.collaborationIsReady?Promise.resolve():new Promise(r=>{let o=!1;const i=()=>{o||(o=!0,clearTimeout(s),typeof n.off=="function"&&n.off("collaborationReady",a))},s=setTimeout(()=>{i(),console.warn("[SuperDoc] collaborationReady did not fire within 10 s after collaboration attach. Continuing — collaboration is active but cursor/presence setup may be delayed."),r(void 0)},1e4),a=()=>{i(),r(void 0)};this.#i=()=>{i(),r(void 0)},typeof n.on=="function"?n.on("collaborationReady",a):(i(),r(void 0))})}#Ze(e){return new Promise((n,r)=>{let o,i=!1,s=()=>{};const a=()=>{i=!0,clearTimeout(o),s()};s=kK(e,()=>{i||(a(),n())}),i||(o=setTimeout(()=>{a(),r(new Error("SuperDoc: collaboration provider did not sync within 10000 ms. The provider exposes on/off but never emitted sync(true) or synced."))},1e4)),this.#i=()=>{i||(a(),r(new Error("SuperDoc: instance was destroyed during upgrade")))}})}#Be(e){if(this.#e)throw new Error("SuperDoc: cannot upgrade a destroyed instance");if(this.#t)throw new Error("SuperDoc: upgrade already in progress");if(this.isCollaborative)throw new Error("SuperDoc: instance is already collaborative");const t=this.config,n=t.documents.filter(o=>o.type===br);if(n.length===0)throw new Error("SuperDoc: no DOCX document found for upgrade");if(n.length>1)throw new Error("SuperDoc: upgradeToCollaboration() only supports a single DOCX document");if(t.documents.length!==n.length)throw new Error("SuperDoc: upgradeToCollaboration() only supports single-DOCX instances");if(!Xo(this.#je()))throw new Error("SuperDoc: upgradeToCollaboration() requires a ready v2 DOCX editor");const r=n[0].id;if(typeof r!="string"||r.length===0)throw new Error("SuperDoc: source document is missing its mounted document identity");return this.#he(e)}#he(e){const t=this.config,n=t.documents.find(a=>a.type===br),r=t.modules?.collaboration,o=e.ydoc||e.provider?{ydoc:e.ydoc,provider:e.provider}:r?{...r}:null,i=e.v2Collaboration??this.#ze(n.v2Collaboration)??r?.v2Collaboration??r?.v2??null,s=Xk({collaboration:e.collaboration,v2Collaboration:i,legacyCollaboration:o,documentType:br,documentCount:t.documents.length,...typeof window<"u"?{authEndpointBaseUrl:window.location.href}:{}});if(!s.ok)throw new Error(`SuperDoc: upgradeToCollaboration() ${s.reason}: ${s.message}`);return{target:{...s.target,roomMode:"create"}}}#ze(e){return e&&typeof e=="object"&&"value"in e?e.value:e}#je(){const e=this.config.documents.find(n=>n.type===br),t=this.#C("upgradeToCollaboration").documents.find(n=>n.id===e.id)?.getEditor?.();if(!t)throw new Error("SuperDoc: source editor not yet created — wait for the ready event before upgrading");return t}addSharedUser(e){this.#H("addSharedUser");const t=Ou({actor:e});t&&this.users.some(n=>Ou({actor:n})===t)||this.users.push(e)}removeSharedUser(e){this.#H("removeSharedUser");const t=typeof e=="string"?ab(e):"",n=typeof e=="string"?`email:${t}`:Ou({actor:e});this.users=this.users.filter(r=>{const o=Ou({actor:r});return n?o!==n:t?ab(r.email)!==t:!0})}onContentError({error:e,editor:t}){const n=t.options?.documentId,r=this.#C("onContentError").documents.find(a=>a.id===n),o=typeof r?.id=="string"?r.id:typeof n=="string"?n:"",i=r?.data,s=UE(i)?i:xl(i)?this.#z(i):i==null?i:void 0;this.config.onContentError?.({error:e,editor:t,documentId:o,file:s})}broadcastPdfDocumentReady(){this.emit("pdf:document-ready")}broadcastReady(){this.readyEditors===this.requiredNumberOfEditors&&this.emit("ready",{superdoc:this})}broadcastEditorBeforeCreate(e){this.emit("editorBeforeCreate",{editor:iE(e)})}broadcastEditorCreate(e){this.readyEditors++,this.broadcastReady(),this.#Ve(e),this.emit("editorCreate",{editor:iE(e)})}broadcastSourceComplete(){this.emit("source:complete")}broadcastSourceSignalsComplete(){this.emit("source:signals-complete")}#ne;#re;#Ve(e){if(!e||typeof e.on!="function"||this.#ne.has(e))return;this.#ne.add(e),e.on("fonts-changed",n=>{this.#pe(e)&&this.#W(e,n)});const t=(e.documentRenderer??e.presentationEditor)?.getLastFontsChangedPayload?.();t&&this.#pe(e)&&this.#W(e,t)}#pe(e){return!this.activeEditor||e===this.activeEditor}#oe;#W(e,t){if(this.#oe=t,e.editorVersion===2){let n=this.#re.get(e);n||(n=new Set,this.#re.set(e,n)),dH(t.missingFonts,n)}this.emit("fonts-changed",t)}broadcastEditorDestroy(){this.emit("editorDestroy")}broadcastSidebarToggle(e){this.emit("sidebar-toggle",e)}#Ue(){Array.isArray(this.config.editorExtensions)&&this.config.editorExtensions.length>0&&console.warn("[SuperDoc] `editorExtensions` is ignored by superdoc@2. Use `extensions` with `defineSuperDocExtension`. ProseMirror APIs such as `Node.create`, `Mark.create`, `addPmPlugins`, and custom schemas do not run in v2."),this.config.modules.ai&&console.warn("[SuperDoc] `modules.ai` is deprecated and will be removed in v3. Use `ui.toolbar.customItems` for the action, make the model request in your application, and apply the result with `doc.insert()` or `doc.replace()`.")}#ie(...e){(console.debug?console.debug:console.log)("🦋 🦸♀️ [superdoc]",...e)}#K;get fonts(){return this.#K||(this.#K={getReport:()=>ws(this.activeEditor)?.getReport()??[],getMissingFonts:()=>ws(this.activeEditor)?.getMissingFonts()??[],getDocumentFontOptions:()=>ws(this.activeEditor)?.getDocumentFontOptions()??[],getFontFamilyOptions:()=>ws(this.activeEditor)?.getFontFamilyOptions()??[],getDocumentFonts:()=>ws(this.activeEditor)?.getDocumentFonts()??[],onReport:e=>{const t=this.activeEditor,n=t?ws(t)?.getLastFontsChangedPayload?.()??null:this.#oe??null;return n&&e(n),this.on("fonts-changed",e),()=>this.off("fonts-changed",e)},map:e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new TypeError("superdoc.fonts.map requires a mapping object, for example { Aptos: 'Carlito' }");const t=ws(this.activeEditor);if(!t)throw new Error("superdoc.fonts.map requires an active editor");t.map(e)},unmap:e=>{const t=ws(this.activeEditor);if(!t)throw new Error("superdoc.fonts.unmap requires an active editor");t.unmap(e)},add:e=>{const t=ws(this.activeEditor);if(!t)throw new Error("superdoc.fonts.add requires an active editor");t.add(e)},preload:e=>{const t=ws(this.activeEditor);if(!t)throw new Error("superdoc.fonts.preload requires an active editor");return t.preload(e)}}),this.#K}#q(){const e=this.activeEditor!==null;this.#me(),this.activeEditor=null,this.toolbar?.setActiveEditor?this.toolbar.setActiveEditor(null):this.toolbar&&(this.toolbar.activeEditor=null),e&&this.emit("active-editor-change")}#j;#me(){if(this.#j){try{this.#j()}catch{}this.#j=null}}#$e(e){this.#me();const t=ws(e);if(!e||!t?.onChanged)return;const n=t.getLastFontsChangedPayload?.();n&&this.#W(e,n),this.#j=t.onChanged(r=>this.#W(e,r))}#He(e,t){this.#M=!0;try{if(e===null){this.#q();return}this.#h.get(e)?.kind==="v2"&&Xo(t)?this.#ge(t):this.#q()}finally{this.#M=!1}}#ge(e){if(Xo(e)){!this.#M&&this.#h.getActive()&&this.#h.setActive(null,"set-active-v2-facade");const t=this.activeEditor;this.activeEditor=e,this.#$e(e),this.toolbar?.setActiveEditor?.(e),t!==this.activeEditor&&this.emit("active-editor-change");return}this.#q()}setActiveEditor(e){this.#ge(e)}getV2FeatureMatrix(){return[{feature:"source.docx-bytes",status:"supported",reason:"SuperDoc normalizes File/Blob/ArrayBuffer/Uint8Array DOCX inputs for the separate DOCX Engine dependency"},{feature:"source.url",status:"supported",reason:"shell-owned source normalization resolves URL-backed DOCX inputs before opening the injected v2 editor"},{feature:"source.blank",status:"supported",reason:"shell-owned blank-document seeding resolves to DOCX bytes before mounting the injected v2 editor"},{feature:"execution.browser-worker",status:"supported",reason:"the shipped public v2 shell opens DOCX documents through the browser-worker path by default when collaboration is not active"},{feature:"distribution.cdn-iife",status:"supported",reason:"the CDN/IIFE distribution ships the public bundle plus the emitted v2 browser-worker asset and opens DOCX documents through the worker-backed v2 runtime"},{feature:"docx.open-render",status:"supported",reason:"superdoc@2 opens and renders DOCX documents through its DOCX Engine dependency"},{feature:"docx.review-handles",status:"supported",reason:"Comment/tracked-change list + decide via v2 host handles"},{feature:"shell.toolbar",status:"supported",reason:"new SuperDoc({ toolbar }) mounts the rendered built-in toolbar shell and the superdoc.toolbar handle, both backed by the V2 command controller and the internal compatibility catalog. Explicit item-level limits stay fail-closed in the shared command matrix (for example search replace and copyFormat)."},{feature:"shell.rich-formatting",status:"supported",reason:"Rich inline, paragraph, and list formatting route through the V2 command controller and public Document API (format.* / styles.* / lists.*): bold, italic, underline, strikethrough, font family/size, text/highlight color, alignment, line spacing, linked styles, bullet/numbered lists, indent, and clear formatting."},{feature:"shell.comments-sidebar",status:"supported",reason:"ui-phase3-002: v2 comments adapter routes create/reply/edit/resolve/delete through V2EditorHost.dispatch"},{feature:"shell.comments-sidebar.reopen",status:"supported",reason:'ui-phase3-002: v2 comments sidebar reopens resolved threads through the v2 comments adapter (activeEditor.doc.comments.patch({ status: "active" }))'},{feature:"shell.tracked-change-sidebar",status:"supported",reason:"SD-3722: v2 tracked-change adapter lists and decides exact body, header/footer-part, and note targets"},{feature:"shell.tracked-change-sidebar.bulk",status:"supported",reason:"SD-4039/SD-4040: the shipped v2 command posture exposes all-story Accept All and Reject All through the canonical doc.trackChanges.decide({ target: { kind: 'all' } }) mutation"},{feature:"shell.tracked-change-sidebar.non-body",status:"supported",reason:"SD-3722: public v2 shell hydrates and targets header/footer-part and note tracked changes"},{feature:"shell.comments-sidebar.persistence",status:"supported",reason:"ui-phase3-004: comment create/reply/edit/resolve/delete persist through SuperDoc.export() → re-mount via the v2 host save bridge"},{feature:"shell.tracked-change-sidebar.persistence",status:"supported",reason:"ui-phase3-004: tracked-change accept/reject persist through SuperDoc.export() → re-mount via the v2 host save bridge"},{feature:"shell.comments-sidebar.author-required",status:"supported",reason:"ui-phase3-004: v2 comments adapter surfaces commentCommandsReason=author-required from the host capability matrix; write controls disable and forced dispatch reports ok:false"},{feature:"shell.find-replace",status:"supported",reason:"Ctrl/Cmd+F opens the SuperDoc find/replace surface in v2; find/navigation/replace/replaceAll route through the single host search session (host.search) via ui.search, with replace failing closed in viewing/read-only mode"},{feature:"shell.ai-writer",status:"supported",reason:"built-in toolbar renders the modules.ai-gated AI writer and applies generated text through the public Document API facade"},{feature:"shell.collaboration",status:"supported",reason:"v2 single-doc collaboration (hocuspocus, y-websocket, liveblocks, and registered provider extensions) is wired through document.collaboration, including collaboration-ready, awareness-update, and locked event bridges; external { ydoc, provider } instances remain unsupported"},{feature:"shell.context-menu",status:"supported",reason:"v2 renders the built-in right-click and slash context menu, forwards ui.contextMenu custom items, and honors ui.contextMenu: false for application-owned replacements"},{feature:"shell.page-metrics",status:"supported",reason:"ui-phase4-001: v2 page metrics snapshot (editorVersion: 2, documentId, renderEpoch, layoutGeneration, zoom, pages[], capabilities) available via superdoc.activeEditor.pageMetrics.{ getSnapshot, subscribe, setZoom, scrollToPage, revealBodyTarget, pageIndexForBodyTarget }"},{feature:"shell.zoom",status:"supported",reason:"ui-phase4-001: SuperDoc.setZoom routes to V2EditorHost.setZoom in v2 mode; single CSS-transform wrapper applies scale to the painted document, page metrics viewport coords scale with the same zoom value"},{feature:"shell.ruler-page-margins",status:"supported",reason:"ui-phase4-002: v2 ruler renders against the V2PageMetricsSnapshot and dispatches margin drags through a narrow v2 page-layout bridge (`activeEditor.pageLayout.setMargins(...)`) backed by `doc.sections.setPageMargins(...)`. The v2 page metrics snapshot now reports `capabilities.marginEdit = { supported: true }`"},{feature:"shell.custom-extensions",status:"supported",reason:"superdoc@2 supports customer extensions through `extensions` + `defineSuperDocExtension`; command execution and diagnostics are exposed through the narrow `activeEditor.extensions` facet. Legacy ProseMirror `editorExtensions` are ignored in v2."},{feature:"pdf.viewer",status:"supported",reason:"editorVersion ignored for PDF documents"},{feature:"html.viewer",status:"supported",reason:"editorVersion ignored for HTML documents"}]}get v2(){return this.editorVersion!==2?null:{version:2,featureMatrix:this.getV2FeatureMatrix()}}registerEditorRuntime(e){this.#h.register(e)}unregisterEditorRuntime(e){return this.#h.unregister(e)}getActiveRuntime(){return this.#h.getActive()}setActiveRuntime(e,t){this.#h.setActive(e,t)}resolveRuntimeFromEventTarget(e){return this.#h.resolveFromEventTarget(e)}activateRuntimeFromEventTarget(e,t){const n=this.#h.resolveFromEventTarget(e);return n?(this.#h.setActive(n.id,t),!0):!1}toggleRuler(){const e=this.#C("toggleRuler");this.config.rulers=!this.config.rulers,e.documents.forEach(t=>{t.rulers=this.config.rulers}),this.toolbar?.updateToolbarState?.()}canPerformPermission({permission:e,role:t=this.config.role,isInternal:n=this.config.isInternal,comment:r=null,trackedChange:o=null}={}){if(!e)return!1;let i=r??o?.comment??null;const s=o?.commentId||o?.id;if(!i&&s&&this.commentsStore?.getComment){const a=this.commentsStore.getComment(s),l=a?.getValues;i=typeof l=="function"?l.call(a):a}return $a(e,t,n,{superdoc:this,currentUser:this.config.user,comment:i??null,trackedChange:o??null})}#Ge(){const e=this.config.modules?.toolbar,t=e&&typeof e=="object"?e:{},n=this.#y.toolbar;this.toolbarElement=n.container??void 0;const r=this.config.ui,o=typeof r=="object"&&r!==null&&r.toolbar!==void 0;if(!(n.enabled&&(n.container||e===!0||e!=null&&typeof e=="object"||o))){this.toolbar=null;return}try{this.toolbar=fK({...t,...n.options,selector:this.toolbarElement,superdoc:this,editor:this.activeEditor,role:this.config.role,isDev:this.isDev,documentMode:this.config.documentMode,groups:n.options.groups,toolbarGroups:n.options.toolbarGroups,icons:n.options.icons,texts:n.options.texts,uiDisplayFallbackFont:this.config.uiDisplayFallbackFont})}catch(i){console.warn("[SuperDoc] built-in toolbar mount failed",i),this.toolbar=null}}addCommentsList(e){!this.config?.modules?.comments||this.config.role==="viewer"||(this.commentsList?.close(),e&&(this.config.modules.comments.element=e),this.commentsList=new iD(this.config.modules?.comments,this),this.config.onCommentsListChange&&this.config.onCommentsListChange({isRendered:!0}),this.emit("comments-list-change",{isRendered:!0}))}removeCommentsList(){this.commentsList&&(this.commentsList.close(),this.commentsList=null,this.config.onCommentsListChange&&this.config.onCommentsListChange({isRendered:!1}),this.emit("comments-list-change",{isRendered:!1}))}scrollToComment(e,t={}){if(!this.config?.modules?.comments||!e||typeof e!="string")return!1;const n=this.element||document,r=globalThis.CSS?.escape?globalThis.CSS.escape(e):e.replace(/"/g,'\\"'),o=n.querySelector(`[data-comment-ids*="${r}"]`);if(!o)return!1;const{behavior:i="smooth",block:s="start"}=t??{};return o.scrollIntoView({behavior:i,block:s}),this.commentsStore?.setActiveComment?.(this,e),!0}async navigateTo(e){const t=this.superdocStore?.documents;if(!t?.length)return!1;const n=t[0].getDocumentRuntime?.();return n?.navigateTo?n.navigateTo(e):!1}async scrollToElement(e){const t=this.superdocStore?.documents;if(!t?.length)return!1;const n=t[0].getDocumentRuntime?.();return n?.scrollToElement?n.scrollToElement(e):!1}setDisableContextMenu(e=!0){if(!e&&this.#y.contextMenu.suppressed)return;const t=!!e;this.config.disableContextMenu!==t&&(this.config.disableContextMenu=t,this.superdocStore?.documents?.forEach(n=>{const r=n.getDocumentRuntime?.();r?.setContextMenuDisabled&&r.setContextMenuDisabled(t);const o=n.getEditor?.();o?.setOptions&&o.setOptions({disableContextMenu:t})}))}setShowBookmarks(e=!0){const t=!!e,n=this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};n.showBookmarks!==t&&(n.showBookmarks=t,this.superdocStore?.documents?.forEach(r=>{r.getDocumentRuntime?.()?.setShowBookmarks?.(t)}))}setShowFormattingMarks(e=!0){const t=!!e,n=this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};n.showFormattingMarks!==t&&(n.showFormattingMarks=t,this.superdocStore?.documents?.forEach(r=>{r.getDocumentRuntime?.()?.setShowFormattingMarks?.(t)}),this.emit("formatting-marks-change",{showFormattingMarks:t,superdoc:this}),this.toolbar?.updateToolbarState?.())}toggleFormattingMarks(){const e=!!this.config.layoutEngineOptions?.showFormattingMarks;this.setShowFormattingMarks(!e)}setDocumentMode(e){if(!e)return;this.#H("setDocumentMode");const t=e.toLowerCase(),n=this.config.role==="viewer"?"viewing":this.config.role==="suggester"&&t==="editing"?"suggesting":t;this.config.documentMode=n,R1(this.config),this.#le();const r={viewing:()=>this.#ae(),editing:()=>this.#We(),suggesting:()=>this.#ye()};r[n]&&(r[n](),this.emit("document-mode-change",{documentMode:n}))}#se(e,t){const n=typeof e.id=="string"&&e.id.length>0?e.id:null;if(n){const i=this.#h.getAllByDocumentId(n);if(i.length>0){for(const s of i)s.setDocumentMode(t);return}}const r=typeof e.getDocumentRuntime=="function"?e.getDocumentRuntime():null;if(typeof r?.setDocumentMode=="function"){r.setDocumentMode(t);return}const o=typeof e.getEditor=="function"?e.getEditor():null;o&&typeof o.setDocumentMode=="function"&&o.setDocumentMode(t)}setTrackedChangesPreferences(e){typeof e?.enabled=="boolean"&&(this.config.trackChanges={...this.config.trackChanges,enabled:e.enabled},this.config.modules.trackChanges={...this.config.modules.trackChanges,enabled:e.enabled}),this.#Y(e)}#ve(){return typeof this.config.trackChanges?.enabled=="boolean"?this.config.trackChanges.enabled:typeof this.config.modules?.trackChanges?.enabled=="boolean"?this.config.modules.trackChanges.enabled:!0}#Y(e){const t=e&&Object.keys(e).length?{...e}:void 0;this.config.layoutEngineOptions||(this.config.layoutEngineOptions={}),this.config.layoutEngineOptions.trackedChanges=t,this.superdocStore?.documents?.forEach(n=>{let r=!1;const o=typeof n.id=="string"&&n.id.length>0?n.id:null;if(o)for(const s of this.#h.getAllByDocumentId(o))s.setTrackedChangesRenderOptions(t),r=!0;if(r)return;const i=typeof n.getDocumentRuntime=="function"?n.getDocumentRuntime():null;i?.setTrackedChangesOverrides&&i.setTrackedChangesOverrides(t)})}setViewingOptions(e){if(!e||typeof e!="object")return;this.#H("setViewingOptions");const t=Ig(this.config,this.#L),n={...this.config.viewing},r=typeof e.comments=="boolean",o=$E(e.trackedChanges);if(!(!r&&!o)&&(r&&(n.comments=e.comments),o&&(n.trackedChanges=e.trackedChanges),this.config.viewing=n,typeof n.comments=="boolean"&&(this.config.comments={...this.config.comments,visible:n.comments}),o&&R1(this.config),this.#le(),this.config.documentMode==="viewing")){const i=Ig(this.config,this.#L),s=t.comments||t.trackChangesVisible,a=i.comments||i.trackChangesVisible;this.#ae({updateTrackedChangesProjection:o,updateCommentVisibility:s!==a})}}#We(){if(this.config.role!=="editor")return this.#ye();const e=this.#C("setDocumentMode");if(e.documents.length>0){const t=e.documents[0]?.getEditor();t&&this.setActiveEditor(t)}this.#Y({mode:"review",enabled:this.#ve()}),e.documents.forEach(t=>{t.restoreComments?.(),this.#se(t,"editing")})}#ye(){if(!["editor","suggester"].includes(this.config.role??""))return this.#ae();const e=this.#C("setDocumentMode");if(e.documents.length>0){const t=e.documents[0]?.getEditor();t&&this.setActiveEditor(t)}this.#Y({mode:"review",enabled:this.#ve()}),e.documents.forEach(t=>{t.restoreComments?.(),this.#se(t,"suggesting")})}#ae(e={}){const t=this.#C("setDocumentMode");this.toolbar?.setActiveEditor?this.toolbar.setActiveEditor(null):this.toolbar&&(this.toolbar.activeEditor=null);const n=Ig(this.config,this.#L),r=n.comments,o=n.trackChangesVisible;e.updateTrackedChangesProjection!==!1&&this.#Y({mode:n.renderMode,enabled:this.config.modules.trackChanges?.enabled??!0}),e.updateCommentVisibility!==!1&&!r&&!o&&this.commentsStore?.clearEditorCommentPositions?.(),t.documents.forEach(i=>{e.updateCommentVisibility!==!1&&(r||o?i.restoreComments?.():i.removeComments?.()),this.#se(i,"viewing")})}#le(){const e=Ig(this.config,this.#L),t=e.comments,n=e.trackChangesVisible,r=this.config.documentMode==="viewing",o=t||n;this.commentsStore?.setViewingVisibility&&this.commentsStore.setViewingVisibility({documentMode:this.config.documentMode,commentsVisible:t,trackChangesVisible:n});const i=this.superdocStore?.documents;Array.isArray(i)&&i.length>0&&i.forEach(s=>{const a=typeof s.getDocumentRuntime=="function"?s.getDocumentRuntime():null;a?.setViewingCommentOptions&&a.setViewingCommentOptions({emitCommentPositionsInViewing:r&&o,enableCommentsInViewing:r&&t})})}search(e){const t=this.activeEditor?.commands,n=t?.search;if(typeof n=="function")return n.call(t,e,{searchModel:"visible"})}goToSearchResult(e){const t=this.activeEditor?.commands,n=t?.goToSearchResult;if(typeof n=="function")return!!n.call(t,e)}getZoom(){return this.superdocStore?.activeZoom??100}setZoom(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0){console.warn("[SuperDoc] setZoom expects a positive number representing percentage");return}if(!this.superdocStore){console.warn("[SuperDoc] setZoom called before initialization; use config.zoom.initial for the starting zoom");return}this.superdocStore.activeZoom=e,this.superdocStore.zoomMode="manual",this.emit("zoomChange",{zoom:e,mode:"manual"})}setZoomMode(e){if(e!=="manual"&&e!=="fit-width"){console.warn("[SuperDoc] setZoomMode expects 'manual' or 'fit-width'");return}if(!this.superdocStore){console.warn("[SuperDoc] setZoomMode called before initialization; use config.zoom.mode for the starting mode");return}if(this.superdocStore.zoomMode!==e){if(this.superdocStore.zoomMode=e,e==="fit-width"){const t=this.superdocStore.viewportMetrics;if(t){const n=g_(t.availableWidth,t.documentWidth,M0(this.config.zoom?.fitWidth));n!==null&&(this.superdocStore.activeZoom=n)}}this.emit("zoomChange",{zoom:this.getZoom(),mode:e})}}getZoomState(){const e=M0(this.config.zoom?.fitWidth);return{mode:this.superdocStore?.zoomMode??"manual",value:this.superdocStore?.activeZoom??100,fitZoom:this.superdocStore?.viewportMetrics?.fitZoom??null,min:e.min,max:e.max}}getViewportMetrics(){return this.superdocStore?.viewportMetrics??null}getMeasurementUnit(){return this.superdocStore?.measurementUnit??"in"}setMeasurementUnit(e){if(e!=="in"&&e!=="cm"){console.warn("[SuperDoc] setMeasurementUnit expects 'in' or 'cm'");return}if(!this.superdocStore){console.warn("[SuperDoc] setMeasurementUnit called before initialization; use config.measurementUnit for the starting unit");return}this.superdocStore.measurementUnit!==e&&(this.superdocStore.measurementUnit=e,this.emit("measurement-unit-change",{unit:e}))}setLocked(e=!0){const t=this.activeEditor;if(Xo(t)&&typeof t.lock?.setLocked=="function"){t.lock.setLocked(e,e?{...this.user}:null);const n=t.lock.getSnapshot?.();n&&this.#$(!!n.isLocked,this.#ue(n.lockedBy??null));return}this.config.documents.forEach(n=>{const r=n.ydoc;if(!r)return;const o=r.getMap("meta");r.transact(()=>{o.set("locked",e),e?o.set("lockedBy",this.user):o.delete("lockedBy")})}),this.#$(e,e?this.user:null)}getHTML(e={}){const t=[];return this.#C("getHTML").documents.forEach(n=>{const r=n.getEditor?.();r&&t.push(r)}),t.map(n=>n.getHTML(e))}lockSuperdoc(e=!1,t=null){this.#$(e,t)}async export({exportType:e=["docx"],commentsType:t="external",exportedName:n,additionalFiles:r=[],additionalFileNames:o=[],isFinalDoc:i=!1,triggerDownload:s=!0,fieldsHighlightColor:a=null}={}){if(!Array.isArray(e)||e.length!==1||e[0]!=="docx")throw new TypeError('SuperDoc.export() only supports exportType: ["docx"].');const l=K4(n||this.config.title),u=await this.exportEditorsToDOCX({commentsType:t,isFinalDoc:i,fieldsHighlightColor:a}),d=[...r],f=[...o];if(e.includes("docx")&&u.forEach(g=>{d.push(g),f.push(`${l}.docx`)}),d.length===1)return s?W4(d[0],l,e[0]):d[0];const p=await CK(d,f);return s?W4(p,l,"zip"):p}async replaceFile(e){return(await this.#be(e)).raw}async replaceDocument(e){const{raw:t,confirmed:n}=await this.#be(e);if(n)return{ok:!0};const r={ok:!1};return t&&typeof t=="object"&&("reason"in t&&typeof t.reason=="string"&&(r.reason=t.reason),"detail"in t&&typeof t.detail=="string"&&(r.detail=t.detail)),r}async#be(e){const t=this.activeEditor;if(Xo(t)&&typeof t.replaceFile=="function"){const r=await t.replaceFile(e),o=r&&typeof r=="object"?r.state:null,i=o===null||o==="review-ready"||o==="editing-ready";return i&&(this.#fe(t,e),this.emit("document-replaced",{editor:t,host:t?.host})),{raw:r,confirmed:i}}const n=t&&!Xo(t)?t.replaceFile:null;if(typeof n=="function"){const r=await n.call(t,e),o=r&&typeof r=="object"?r.state:void 0,i=o==null||o==="review-ready"||o==="editing-ready";return i&&(this.#fe(t,e),this.emit("document-replaced",{editor:t,host:t?.host})),{raw:r,confirmed:i}}throw new Error("SuperDoc: replaceFile is unavailable for the active editor")}async exportEditorsToDOCX({commentsType:e,isFinalDoc:t,fieldsHighlightColor:n}={}){const r=this.config?.modules?.comments!==!1;let o,i=!1;const s=()=>(i||(i=!0,e==="clean"?o=[]:r&&this.commentsStore&&typeof this.commentsStore.translateCommentsForExport=="function"&&(o=this.commentsStore.translateCommentsForExport(),Array.isArray(o)||(o=[]))),o),a=new WeakSet,l=u=>{"editor"in u&&u.error&&typeof u.error=="object"&&a.add(u.error)};this.on("exception",l);try{const u=this.#C("exportEditorsToDOCX").documents.map(async d=>{if(!d||d.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document")return null;const f=typeof d.getEditor=="function"?d.getEditor():null,p=()=>UE(d.data)?d.data.type&&d.data.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document"?null:d.data:xl(d.data)?this.#z(d.data):null;if(!f||typeof f.exportDocx!="function")return p();const g=f.editorVersion===2;try{const m=await f.exportDocx(g?{isFinalDoc:t,commentsType:e,fieldsHighlightColor:n}:{isFinalDoc:t,comments:s(),commentsType:e,fieldsHighlightColor:n});if(m)return m}catch(m){if((!m||typeof m!="object"||!a.has(m))&&(this.emit("exception",{error:m,document:d}),this.emit("exception",ij(m,{documentId:d.id,editor:null}))),g)throw m}return p()});return(await Promise.all(u)).filter(d=>d!=null)}finally{this.off("exception",l)}}async save(){const e=this.#C("save").documents;await Promise.all(e.map(async t=>{if(t.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document")return;const n=t.getEditor?.();if(!Xo(n)||typeof n.save!="function")throw new Error(`SuperDoc: save is unavailable for document "${t.id}"`);await n.save()}))}#we(){this.#p=null,this.#te(),typeof this._cleanupAwareness=="function"&&(this._cleanupAwareness(),this._cleanupAwareness=null);const e=this.config;e.socket?.cancelWebsocketRetry?.(),e.socket?.disconnect(),e.socket?.destroy(),this.ydoc?.destroy(),this.provider?.disconnect?.(),this.provider?.destroy?.()}openSurface(e){return this.#E.open(e)}closeSurface(e){this.#E.close(e)}async removeDocument(e){const t=typeof e=="string"?e:String(e??"");if(!t)return!1;const n=this.#C("removeDocument"),r=this.activeEditor,o=YE(r);for(const i of this.#h.getAllByDocumentId(t))this.#h.unregister(i.id);return o===t&&r!==null&&this.#q(),n.removeDocument(t)?(await Ct(),!0):!1}destroy(){eT(this),this.#e=!0,this.#s?.removeEventListener("click",this.#D,!0),this.#s?.removeEventListener("pointerdown",this.#F,!0),this.#s?.ownerDocument.removeEventListener("pointerup",this.#T,!0),this.#s?.ownerDocument.removeEventListener("pointercancel",this.#T,!0),this.#s?.removeEventListener("keydown",this.#P,!0),this.#s=null,this.#m?.(),this.#m=null,this.#i&&(this.#i(),this.#i=null),this.#E&&this.#E.destroy(),this.toolbar?.destroy?.(),this.commentsList?.close(),this.commentsList=null,this.app&&(this.#ie("[superdoc] Unmounting app"),this.superdocStore?.reset(),this.app.unmount(),this.removeAllListeners(),delete this.app.config.globalProperties.$config,delete this.app.config.globalProperties.$superdoc),this.#w?.destroy(),this.#we(),this.#R?.(),this.#R=null,this.#h.clear(),this.#r&&(this.#r.remove(),this.#r=null)}focus(e={}){const t=this.getActiveRuntime();if(t?.getCapabilities().lifecycle.canFocus){t.focus(e).catch(n=>{console.warn("[SuperDoc] active editor runtime focus failed",n)});return}this.activeEditor?Xo(this.activeEditor)?this.activeEditor.focus?.(e):this.activeEditor.focus?.():this.#C("focus").documents.find(n=>{const r=n.getEditor?.();return r?(Xo(r)?r.focus?.(e):r.focus?.(),!0):!1})}setHighContrastMode(e){this.activeEditor&&(this.activeEditor.setHighContrastMode?.(e),this.highContrastModeStore?.setHighContrastMode(e))}};Ft();var XE="__SUPERDOC_V2_BROWSER_RUNTIME__";function EK(e=globalThis){const t=e[XE];return t&&typeof t=="object"?t:null}function xK(e={},t=globalThis){const n=EK(t)??{},r={...n,...e,vue:e.vue??n.vue??J5};return t[XE]=r,r}xK();var TK={action:"--sd-ui-action",actionHover:"--sd-ui-action-hover",actionText:"--sd-ui-action-text",bg:"--sd-ui-bg",hoverBg:"--sd-ui-hover-bg",activeBg:"--sd-ui-active-bg",disabledBg:"--sd-ui-disabled-bg",text:"--sd-ui-text",textMuted:"--sd-ui-text-muted",textDisabled:"--sd-ui-text-disabled",border:"--sd-ui-border"},RK=0;function ZE(e){const{name:t,font:n,radius:r,shadow:o,colors:i,vars:s}=e,a=`sd-theme-${(t?t.replace(/[^a-zA-Z0-9-_]/g,"-"):null)||`custom-${++RK}`}`,l=[];if(i)for(const[u,d]of Object.entries(i)){if(d==null)continue;const f=TK[u];f&&l.push(` ${f}: ${d};`)}if(n!=null&&l.push(` --sd-ui-font-family: ${n};`),r!=null&&l.push(` --sd-ui-radius: ${r};`),o!=null&&l.push(` --sd-ui-shadow: ${o};`),s)for(const[u,d]of Object.entries(s))d!=null&&l.push(` ${u}: ${d};`);return{className:a,css:l.length>0?`.${a} {
|
|
110
110
|
${l.join(`
|
|
111
111
|
`)}
|
|
112
|
-
}`:""}}function MK(e,t){if(typeof document>"u"||!t)return;let n=document.querySelector(`[data-sd-theme="${e}"]`);n||(n=document.createElement("style"),n.setAttribute("data-sd-theme",e),document.head.appendChild(n)),n.textContent=t}function LK(e){const{className:t,css:n}=ZE(e);return MK(t,n),t}function PK(e){return ZE(e)}function DK(e){if(!e||typeof e!="object")throw new Error("defineSuperDocExtension requires an extension object.");if(typeof e.id!="string"||e.id.length===0)throw new Error("defineSuperDocExtension requires a non-empty string `id`.");if(typeof e.activate!="function")throw new Error(`defineSuperDocExtension("${e.id}") requires an \`activate(ctx)\` function.`);if(e.storage!==void 0&&typeof e.storage!="function")throw new Error(`defineSuperDocExtension("${e.id}") \`storage\` must be a function returning the initial storage object.`);return e}var OK=Gd({BlankDOCX:()=>GS,DOCX:()=>br,HTML:()=>Du,PDF:()=>Da,SuperDoc:()=>Eg,buildTheme:()=>PK,compareVersions:()=>a6,createTheme:()=>LK,defineSuperDocExtension:()=>DK,getFileObject:()=>lb}),FK="SUPERDOC_ENGINE_CDN_BASE_URL",QE=Symbol.for("superdoc.docx-engine.cdn-load-state"),xg="superdocDocxEngineStatus";function NK(e,t,n=null){const r=e?.[FK],o=typeof r=="string"&&r.trim()?r:n;if(typeof o=="string"&&o.trim())return BK(o);if(!t)throw new Error("SuperDoc: the CDN build is missing its exact DOCX Engine version");return`https://cdn.jsdelivr.net/npm/@superdoc/docx-engine@${t}`}function BK(e){const t=e.trim().replace(/\/+$/,""),n=t.match(/^([a-z][a-z\d+.-]*):/iu)?.[1]?.toLowerCase();if(n&&n!=="http"&&n!=="https")throw new TypeError(`SuperDoc: unsupported DOCX Engine CDN URL scheme ${n}:`);return t}function zK({engineVersion:e,buildBaseUrl:t}){xM(()=>{const n=NK(globalThis,e,t),r=globalThis[QE],o=r instanceof Map?r:new Map;if(globalThis[QE]=o,!o.has(n)){const i=Promise.all([import(`${n}/dist-cdn/docx-engine.es.js`),jK(`${n}/dist-cdn/style.css`)]).then(([s])=>s);o.set(n,i),i.catch(()=>{o.get(n)===i&&o.delete(n)})}return o.get(n)})}function jK(e){if(typeof document>"u")return Promise.resolve();const t=new URL(e,document.baseURI).href,n=Array.from(document.querySelectorAll('link[rel~="stylesheet"]')).find(o=>o.href===t);if(n?.sheet||n?.dataset[xg]==="loaded")return Promise.resolve();const r=n?.dataset[xg]==="loading";return n&&!r&&n.remove(),new Promise((o,i)=>{const s=r?n:document.createElement("link");let a=!1,l;const u=(g,m)=>{a||(a=!0,l?.disconnect(),s.dataset[xg]=g,m())},d=()=>u("loaded",o),f=()=>u("error",()=>i(new Error(`SuperDoc: failed to load DOCX Engine styles from ${t}`))),p=()=>{s.isConnected||u("error",()=>i(new Error(`SuperDoc: DOCX Engine stylesheet was removed while loading from ${t}`)))};s.addEventListener("load",d,{once:!0}),s.addEventListener("error",f,{once:!0}),typeof globalThis.MutationObserver=="function"&&(l=new globalThis.MutationObserver(p),l.observe(document.head,{childList:!0})),r||(s.rel="stylesheet",s.href=t,s.dataset.superdocDocxEngine="true",s.dataset[xg]="loading",document.head.appendChild(s))})}zK({engineVersion:"0.21.0-next.
|
|
112
|
+
}`:""}}function MK(e,t){if(typeof document>"u"||!t)return;let n=document.querySelector(`[data-sd-theme="${e}"]`);n||(n=document.createElement("style"),n.setAttribute("data-sd-theme",e),document.head.appendChild(n)),n.textContent=t}function LK(e){const{className:t,css:n}=ZE(e);return MK(t,n),t}function PK(e){return ZE(e)}function DK(e){if(!e||typeof e!="object")throw new Error("defineSuperDocExtension requires an extension object.");if(typeof e.id!="string"||e.id.length===0)throw new Error("defineSuperDocExtension requires a non-empty string `id`.");if(typeof e.activate!="function")throw new Error(`defineSuperDocExtension("${e.id}") requires an \`activate(ctx)\` function.`);if(e.storage!==void 0&&typeof e.storage!="function")throw new Error(`defineSuperDocExtension("${e.id}") \`storage\` must be a function returning the initial storage object.`);return e}var OK=Gd({BlankDOCX:()=>GS,DOCX:()=>br,HTML:()=>Du,PDF:()=>Da,SuperDoc:()=>Eg,buildTheme:()=>PK,compareVersions:()=>a6,createTheme:()=>LK,defineSuperDocExtension:()=>DK,getFileObject:()=>lb}),FK="SUPERDOC_ENGINE_CDN_BASE_URL",QE=Symbol.for("superdoc.docx-engine.cdn-load-state"),xg="superdocDocxEngineStatus";function NK(e,t,n=null){const r=e?.[FK],o=typeof r=="string"&&r.trim()?r:n;if(typeof o=="string"&&o.trim())return BK(o);if(!t)throw new Error("SuperDoc: the CDN build is missing its exact DOCX Engine version");return`https://cdn.jsdelivr.net/npm/@superdoc/docx-engine@${t}`}function BK(e){const t=e.trim().replace(/\/+$/,""),n=t.match(/^([a-z][a-z\d+.-]*):/iu)?.[1]?.toLowerCase();if(n&&n!=="http"&&n!=="https")throw new TypeError(`SuperDoc: unsupported DOCX Engine CDN URL scheme ${n}:`);return t}function zK({engineVersion:e,buildBaseUrl:t}){xM(()=>{const n=NK(globalThis,e,t),r=globalThis[QE],o=r instanceof Map?r:new Map;if(globalThis[QE]=o,!o.has(n)){const i=Promise.all([import(`${n}/dist-cdn/docx-engine.es.js`),jK(`${n}/dist-cdn/style.css`)]).then(([s])=>s);o.set(n,i),i.catch(()=>{o.get(n)===i&&o.delete(n)})}return o.get(n)})}function jK(e){if(typeof document>"u")return Promise.resolve();const t=new URL(e,document.baseURI).href,n=Array.from(document.querySelectorAll('link[rel~="stylesheet"]')).find(o=>o.href===t);if(n?.sheet||n?.dataset[xg]==="loaded")return Promise.resolve();const r=n?.dataset[xg]==="loading";return n&&!r&&n.remove(),new Promise((o,i)=>{const s=r?n:document.createElement("link");let a=!1,l;const u=(g,m)=>{a||(a=!0,l?.disconnect(),s.dataset[xg]=g,m())},d=()=>u("loaded",o),f=()=>u("error",()=>i(new Error(`SuperDoc: failed to load DOCX Engine styles from ${t}`))),p=()=>{s.isConnected||u("error",()=>i(new Error(`SuperDoc: DOCX Engine stylesheet was removed while loading from ${t}`)))};s.addEventListener("load",d,{once:!0}),s.addEventListener("error",f,{once:!0}),typeof globalThis.MutationObserver=="function"&&(l=new globalThis.MutationObserver(p),l.observe(document.head,{childList:!0})),r||(s.rel="stylesheet",s.href=t,s.dataset.superdocDocxEngine="true",s.dataset[xg]="loading",document.head.appendChild(s))})}zK({engineVersion:"0.21.0-next.4",buildBaseUrl:null});for(const[e,t]of Object.entries(OK))e==="SuperDoc"||e==="default"||Object.prototype.hasOwnProperty.call(Eg,e)||(Eg[e]=t);var VK=Eg;return VK})();
|