@docx-editor.dev/editor-api 2.27.0 → 2.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import {createServerAutomationHost,createAutomationPaginationProvider}from'@docx-editor.dev/core/automation';function me(o){return createAutomationPaginationProvider(o)}var ge=Object.freeze({PropertyNotLoaded:"the property has not been loaded. Call load(...) and await context.sync() before reading it.",ValueNotLoaded:"the result has not been filled in yet. Await context.sync() before reading it.",InvalidObjectPath:"the object cannot be addressed. Await context.sync() after creating an object with an edit. Keep proxies within their run, or use context.trackedObjects.add(...) before the run ends.",ObjectInUse:"the object still belongs to a run that has not finished. Await that run before passing the object to another one.",InvalidArgument:"the argument is not one this API accepts.",ResourceLimitExceeded:"the document exceeds a supported resource limit.",ItemNotFound:"the collection has no such item.",NotSupported:"the operation or argument is outside this document or host\u2019s supported capabilities.",NotImplemented:"this version does not implement that yet.",ConflictingChanges:"these operations cannot share one atomic batch. Split them across separate context.sync() calls.",InvalidRequestContext:"the request context has finished. Start another run to continue.",RuntimeDisposed:"the runtime has been disposed.",StaleDocument:"the document changed after this context read it, so nothing was applied.",DocumentUnavailable:"the document is not available right now.",GeneralException:"the document could not complete the request."}),v=class extends Error{code;limit;target;expectedRevision;actualRevision;constructor(t){let e=t.target?`${ge[t.code]} (${t.target})`:ge[t.code];super(e),this.name="DocxEditorError",this.code=t.code,t.limit!==void 0&&(this.limit=t.limit),t.target!==void 0&&(this.target=t.target),t.expectedRevision!==void 0&&(this.expectedRevision=t.expectedRevision),t.actualRevision!==void 0&&(this.actualRevision=t.actualRevision);}};function $e(o){return o instanceof v?true:typeof o=="object"&&o!==null&&o.name==="DocxEditorError"&&typeof o.code=="string"}function i(o){throw new v(o)}var tt=Symbol("docx-editor.runtime.internals"),Nt=Symbol("docx-editor.runtime.release"),qt=Symbol("docx-editor.runtime.rebind");function et(o){return o[tt]}var He=new Set(["select","expand","top","skip"]),Me=/^[A-Za-z][A-Za-z0-9]*$/;function fe(o,t){if(o===void 0)return [];let e=typeof o=="string"?o.split(",").map(r=>r.trim()):Array.isArray(o)?o.map(r=>typeof r=="string"?r.trim():r):i({code:"InvalidArgument",target:t}),n=[];for(let r of e)(typeof r!="string"||!Me.test(r))&&i({code:"InvalidArgument",target:t}),n.includes(r)||n.push(r);return n.length===0&&i({code:"InvalidArgument",target:t}),n}function be(o,t){return (typeof o!="number"||!Number.isInteger(o)||o<0)&&i({code:"InvalidArgument",target:t}),o}function Fe(o,t){o===void 0||Array.isArray(o)&&o.length===0||i({code:"InvalidArgument",target:t});}function ye(o,t){if(o===void 0)return {select:[]};if(typeof o=="string"||Array.isArray(o))return {select:fe(o,t)};(typeof o!="object"||o===null)&&i({code:"InvalidArgument",target:t});let e=o;for(let n of Object.keys(e))He.has(n)||i({code:"InvalidArgument",target:`${t}.${n}`});return Fe(e.expand,`${t}.expand`),{select:fe(e.select,`${t}.select`),...e.top===void 0?{}:{top:be(e.top,`${t}.top`)},...e.skip===void 0?{}:{skip:be(e.skip,`${t}.skip`)}}}var M=class{#t;#e;#n;#o;#s=new Map;#a=false;constructor(t,e,n={}){this.#t=t,this.#e=t[tt],this.#n=e,this.#o=n.nullable===true,this.#e.register(this);}get context(){return this.#t}get isNullObject(){return this.#n.isReleased&&i({code:"InvalidObjectPath",target:this.#n.label}),this.#o?(this.#n.isPending&&i({code:"PropertyNotLoaded",target:`${this.#n.label}.isNullObject`}),this.#n.isNull):false}load(t){this.#a=true;try{return this.requireUsablePath(),this.onLoad(ye(t,this.#n.label)),this}finally{this.#a=false;}}get path(){return this.#n}get internals(){return this.#e}handle(){return this.#n.handle()}requireAddressable(){this.#n.isAddressable||i({code:"InvalidObjectPath",target:this.#n.label}),this.#e.assertUsable(this.#n.label);}requireUsablePath(){(this.#n.isReleased||this.#n.isNull&&!(this.#a&&this.#o))&&i({code:"InvalidObjectPath",target:this.#n.label}),this.#e.assertUsable(this.#n.label);}enqueue(t){this.requireUsablePath(),this.#e.queue.push({...t,dependencies:[...t.dependencies??[],this.#n],...this.#a&&this.#o&&t.sort==="read"?{nullableLoad:this.#n}:{}});}loadedProperty(t){return this.#n.isReleased&&!this.#s.has(t)&&i({code:"InvalidObjectPath",target:this.#n.label}),this.#s.has(t)||i({code:"PropertyNotLoaded",target:`${this.#n.label}.${t}`}),this.#s.get(t)}hasLoadedProperty(t){return this.#s.has(t)}setLoadedProperty(t,e){this.#s.set(t,e);}[Nt](){this.#n.release();}[qt](t){this.#t=t,this.#e=t[tt];}};var Dt=class o{#t=false;#e;#n;constructor(t){this.#n=t;}get value(){return this.#t||i({code:"ValueNotLoaded",target:this.#n}),this.#e}get isLoaded(){return this.#t}static create(t){let e=new o(t);return {result:e,fill(n){e.#t=true,e.#e=n;}}}};function xe(o){return Dt.create(o)}function j(o){return new v({code:"GeneralException",target:o})}function R(o,t){if(o.kind!=="text")throw j(t);return o.text}function u(o,t){if(o.kind!=="handle")throw j(t);return o.handle}function C(o,t){if(o.kind!=="handles")throw j(t);return o.handles}function O(o,t){if(o.kind!=="span")throw j(t);return o.span}function Bt(o,t){if(o.kind!=="spans")throw j(t);return o.spans}function Xt(o,t){if(o.kind!=="font")throw j(t);return o.font}function Kt(o,t){if(o.kind!=="paragraphFormat")throw j(t);return o.format}function Pt(o,t){if(o.kind!=="style")throw j(t);return o.name}function $t(o,t){if(o.kind!=="number")throw j(t);return o.value}function nt(o,t){if(o.kind!=="flag")throw j(t);return o.value}function Zt(o,t){if(o.kind!=="pageSetup")throw j(t);return o.setup}function m(o,t){if(o.kind!=="applied")throw j(t)}var c=class o{label;#t;#e;constructor(t,e,n=null){this.label=t,this.#t=e,this.#e=n;}static of(t,e){return new o(t,{status:"resolved",address:{kind:"handle",handle:e}})}static ofSpan(t,e){return new o(t,{status:"resolved",address:{kind:"span",span:e}})}static pending(t){return new o(t,{status:"pending"})}static derived(t,e){return new o(t,{status:"pending"},e)}get state(){return this.#e?this.#e.state:this.#t}get isAddressable(){return this.state.status==="resolved"}get isPending(){return this.state.status==="pending"}get isNull(){return this.state.status==="null"}get isReleased(){return this.state.status==="released"}address(){let t=this.state;if(t.status==="resolved")return t.address;i({code:"InvalidObjectPath",target:this.label});}handle(){let t=this.address();return t.kind!=="handle"&&i({code:"InvalidObjectPath",target:this.label}),t.handle}span(){let t=this.address();return t.kind!=="span"&&i({code:"InvalidObjectPath",target:this.label}),t.span}resolveTo(t){this.#n({kind:"handle",handle:t});}resolveToSpan(t){this.#n({kind:"span",span:t});}resolveNull(){this.#t.status!=="released"&&(this.#t={status:"null"});}release(){this.#e||(this.#t={status:"released"});}#n(t){this.#t.status!=="released"&&(this.#t={status:"resolved",address:t});}};function Ce(o){let t=[],e=false,n=false;for(let r of o)t.push(r.plan()),r.sort==="write"?n=true:e=true;return {operations:t,hasRead:e,hasWrite:n}}var Ve=Object.freeze({"stale-revision":"StaleDocument","invalid-handle":"InvalidObjectPath","invalid-offset":"InvalidArgument","unsupported-capability":"NotSupported",disposed:"RuntimeDisposed","transaction-refused":"GeneralException","unknown-operation":"NotSupported","unsupported-content":"InvalidArgument","unsupported-revision":"NotImplemented","ambiguous-document":"GeneralException","conflicting-operations":"ConflictingChanges","document-unavailable":"DocumentUnavailable"});function Ht(o,t={}){let e=Ve[o.code]??"GeneralException",n=e==="StaleDocument";return new v({code:e,...t.target===void 0?{}:{target:t.target},...n&&t.expectedRevision!==void 0?{expectedRevision:t.expectedRevision}:{},...n&&t.actualRevision!==void 0?{actualRevision:t.actualRevision}:{}})}function Yt(o,t,e){for(let n=0;n<o.results.length;n+=1){let r=o.results[n];if(r?.status!=="error")continue;let s=t[n]?.label;return Ht(r.error,{...s===void 0?{}:{target:s},...e===void 0?{}:{expectedRevision:e},actualRevision:o.revision})}return new v({code:"GeneralException"})}function Jt(o,t){if(t.results.length!==o.length)throw new v({code:"GeneralException"});for(let e=0;e<o.length;e+=1){let n=t.results[e],r=o[e];if(n.status!=="ok")throw new v({code:"GeneralException",target:r.label});r.settle(n.value);}}var Mt=class{#t=[];get size(){return this.#t.length}get pending(){return this.#t}push(t){this.#t.push(t);}take(){let t=this.#t;this.#t=[];for(let e of t)e.capture?.();return t}clear(){for(let t of this.#t)t.dispose?.();this.#t=[];}};function Ae(o,t){if(Array.isArray(o)){for(let e of o)t(e);return}t(o);}var Rt=class{#t;#e;constructor(t,e){this.#t=t,this.#e=e;}add(t){this.#t.assertUsable(),Ae(t,e=>{this.#n(e),this.#t.track(e);});}remove(t){this.#t.assertUsable(),Ae(t,e=>{this.#n(e),this.#t.untrack(e);});}#n(t){this.#e(t)||i({code:"InvalidObjectPath"});}};var Ot=class o{#t;#e=new Mt;#n=new Set;#o=new Set;#s;#a;#i;#r=false;#d=null;#c=false;constructor(t){this.#t=t,this.#s={host:t.host,capabilities:t.capabilities,...t.author===void 0?{}:{author:t.author},revisionTextView:t.revisionTextView,queue:this.#e,session:t.id,roots:()=>t.roots(),assertUsable:e=>{this.#t.assertLive(e),this.#r&&i({code:"InvalidRequestContext",...e===void 0?{}:{target:e}});},isFinished:()=>this.#r,readRevision:()=>this.#d,register:e=>{this.#n.add(e);},track:e=>{this.#o.add(e);},untrack:e=>{this.#o.delete(e);},isTracked:e=>this.#o.has(e),disown:e=>{this.#n.delete(e),this.#o.delete(e);}},this.#a=new Rt(this.#s,e=>this.#n.has(e));}get document(){return this.#s.assertUsable("document"),this.#i??=this.#t.openDocument(this),this.#i}get capabilities(){return this.#t.capabilities}get trackedObjects(){return this.#a}async sync(){this.#s.assertUsable(),this.#c&&i({code:"InvalidRequestContext"});let t=this.#e.take();if(t.length!==0){this.#c=true;try{let e=t.filter(a=>!a.nullableLoad?.isNull),n=t.some(a=>a.sort==="write"),r,s=a=>a.dependencies?.some(d=>!d.isAddressable)??false;for(;e.some(s);){r??=n&&this.#d!==null?this.#d:this.#t.host.revision();let a=e.filter(h=>h.sort==="read"&&!s(h));a.length===0&&i({code:"InvalidObjectPath",target:e.find(s)?.label}),await this.#h(a,r);let d=new Set(a);e=e.filter(h=>!d.has(h)&&!h.nullableLoad?.isNull);}if(e.length){let a=r??(n&&this.#d!==null?this.#d:void 0);await this.#h(e,a);}}finally{for(let e of t)e.dispose?.();this.#c=false;}}}async#h(t,e){let n=Ce(t),r={operations:n.operations,...e===void 0?{}:{expectedRevision:e}};if(this.#t.host.prepare){let a={...r,expectedRevision:r.expectedRevision??this.#t.host.revision()};await this.#t.host.prepare(a);let d=this.#t.host.execute(a);if(!d.ok)throw Yt(d,t,a.expectedRevision);Jt(t,d),this.#d=d.revision;return}let s=this.#t.host.execute(r);if(!s.ok)throw Yt(s,t,e);Jt(t,s),(n.hasRead||n.hasWrite)&&(this.#d=s.revision);}get[tt](){return this.#s}static begin(t){let e=new o(t);return {context:e,adopt(n){for(let r of n)e.#p(r);},finish(){e.#l();}}}#p(t){let e=t.context;if(e===this)return;let n=e[tt];if(n.session!==this.#t.id)throw new v({code:"InvalidObjectPath"});if(!n.isFinished())throw new v({code:"ObjectInUse"});if(!n.isTracked(t))throw new v({code:"InvalidObjectPath"});let r=n.readRevision();n.disown(t),t[qt](this),this.#n.add(t),this.#o.add(t),r!==null&&this.#u(r);}#u(t){this.#d=this.#d===null?t:Math.min(this.#d,t);}#l(){if(!this.#r){this.#r=true,this.#e.clear();for(let t of this.#n)this.#o.has(t)||t[Nt]();this.#n.clear();}}};function kt(o,t,e){if(o.select.length===0)return t;for(let n of o.select)t.includes(n)||i({code:"InvalidArgument",target:`${e}.${n}`});return o.select}var p=class extends M{revisionTextView(){return et(this.context).revisionTextView}loadTextInto(t,e){let n=`${this.path.label}.${t}`;this.enqueue({sort:"read",label:n,plan:e,settle:r=>{this.setLoadedProperty(t,R(r,n));}});}command(t,e,n){let r=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:r,plan:e,settle:s=>m(s,r),...n?{capture:n,dispose:n}:{}});}commandDiscarding(t,e){let n=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:n,plan:e,settle:()=>{}});}commandAnswering(t,e,n,r){this.enqueue({sort:"write",label:t,plan:e,settle:n,...r?{capture:r,dispose:r}:{}});}read(t,e,n){this.enqueue({sort:"read",label:t,plan:e,settle:n});}selection(t,e){return kt(t,e,this.path.label)}onLoad(t){this.selection(t,[]);}};var We=["author","title","subject","keywords","comments","category","lastAuthor"],lt=class o extends p{#t;static of(t,e){return new o(t,c.derived("document.properties",e))}constructor(t,e){super(t,e);}get lastAuthor(){return this.loadedProperty("lastAuthor")}get author(){return this.loadedProperty("author")}set author(t){this.#e("author",t);}get title(){return this.loadedProperty("title")}set title(t){this.#e("title",t);}get subject(){return this.loadedProperty("subject")}set subject(t){this.#e("subject",t);}get keywords(){return this.loadedProperty("keywords")}set keywords(t){this.#e("keywords",t);}get comments(){return this.loadedProperty("comments")}set comments(t){this.#e("comments",t);}get category(){return this.loadedProperty("category")}set category(t){this.#e("category",t);}onLoad(t){for(let e of this.selection(t,We))this.read(`${this.path.label}.${e}`,()=>({op:"getDocumentProperty",name:e}),n=>this.setLoadedProperty(e,R(n,this.path.label)));}#e(t,e){if(this.requireUsablePath(),(typeof e!="string"||e.length>4096)&&i({code:"InvalidArgument",target:`${this.path.label}.${t}`}),this.#t){this.#t[t]=e;return}let n={[t]:e};this.#t=n,this.commandAnswering(this.path.label,()=>({op:"setDocumentProperties",values:n}),r=>{m(r,this.path.label);},()=>{this.#t===n&&(this.#t=void 0);});}};function k(o,t){let e=o.address();return t==="span"?(e.kind!=="span"&&i({code:"InvalidObjectPath",target:o.label}),{start:e.span.start,end:e.span.end}):(e.kind!=="handle"&&i({code:"InvalidObjectPath",target:o.label}),t==="body"?{body:e.handle}:{paragraph:e.handle})}function ct(o,t){return (typeof o!="string"||o.trim().length===0||o.length>255)&&i({code:"InvalidArgument",target:t}),o}var T=class extends M{#t;#e=[];constructor(t,e){super(t,e);}get items(){return this.loadedProperty("items")}fill(t,e){this.setLoadedProperty("items",this.#o(t,e,0,void 0)),this.#t={value:t,label:e};let n=this.#e.splice(0,this.#e.length);for(let r of n)this.#n(r,t);}onLoad(t){kt(t,["items"],this.path.label);let e=this.path.isPending?void 0:this.listing();if(e===null)return;let n=`${this.path.label}.items`,r=t.skip??0,s=t.top;this.enqueue({sort:"read",label:n,plan:()=>{let a=e??this.listing();return a||i({code:"InvalidObjectPath",target:this.path.label}),a},settle:a=>{this.setLoadedProperty("items",this.#o(a,n,r,s));}});}edge(t,e,n){let r=`${this.path.label}.${e}()`,s=this.promised(r,n),a=this.path.isPending?void 0:this.listing();if(a===null){let d={edge:t,target:r,nullable:n,item:s};return this.#t?this.#n(d,this.#t.value):this.#e.push(d),s}return this.enqueue({sort:"read",label:r,plan:()=>{let d=a??this.listing();return d||i({code:"InvalidObjectPath",target:this.path.label}),d},settle:d=>{this.#n({edge:t,target:r,nullable:n,item:s},d);}}),s}#n(t,e){let{edge:n,target:r,nullable:s,item:a}=t,d=this.size(e,r);if(d===0){s||i({code:"ItemNotFound",target:r}),a.hydrateNull();return}let h=this.addressAt(e,r,n==="first"?0:d-1);h||i({code:"ItemNotFound",target:r}),a.hydrateAddress(h);}#o(t,e,n,r){let s=this.size(t,e),a=r===void 0?s:Math.min(s,n+r),d=[];for(let h=n;h<a;h+=1){let P=this.addressAt(t,e,h);P&&d.push(this.itemAt(`${e}[${String(h)}]`,P));}return d}},A=class extends T{size(t,e){return C(t,e).length}addressAt(t,e,n){let r=C(t,e)[n];return r?{kind:"handle",handle:r}:void 0}};var Ft=(a=>(a.unsupported="Unsupported",a.textBox="TextBox",a.geometricShape="GeometricShape",a.group="Group",a.picture="Picture",a.canvas="Canvas",a))(Ft||{}),Ue=["id","name","type"],ve=new Set(Object.values(Ft)),ht=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get id(){return this.loadedProperty("id")}get name(){return this.loadedProperty("name")}get type(){return this.loadedProperty("type")}get body(){if(this.#t)return this.#t;let t=`${this.path.label}.body`,e=I.promisedStory(this.context,t);return this.read(t,()=>({op:"getShapeBody",shape:this.#e()}),n=>{e.hydrateAddress({kind:"handle",handle:u(n,t)});}),this.#t=e,e}onLoad(t){let e=this.selection(t,Ue);e.length&&this.read(this.path.label,()=>({op:"getShape",shape:this.#e()}),n=>{(n.kind!=="shape"||!ve.has(n.shape.type))&&i({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.shape[r]);});}#e(){return this.requireAddressable(),this.path.handle()}},F=class o extends T{#t;#e;static of(t,e,n,r,s){return new o(t,c.derived(e,n),r,s)}constructor(t,e,n,r){super(t,e),this.#t=n,this.#e=r;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getByTypes(t){let e=`${this.path.label}.getByTypes`;(!Array.isArray(t)||t.some(r=>!ve.has(r)))&&i({code:"InvalidArgument",target:e});let n=this.#e?this.#e.filter(r=>t.includes(r)):[...t];return o.of(this.context,e,this.path,this.#t,n)}listing(){let t=k(this.path,this.#t);return this.#e?{op:"getShapes",span:t,types:this.#e}:{op:"getShapes",span:t}}size(t,e){return C(t,e).length}addressAt(t,e,n){let r=C(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return ht.at(this.context,t,e)}promised(t,e){return ht.promised(this.context,t,e)}};function Ge(o){return o==="endnote"?"Endnote":"Footnote"}var pt=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get type(){return this.loadedProperty("type")}get text(){return this.loadedProperty("text")}get body(){if(this.#t)return this.#t;let t=`${this.path.label}.body`,e=I.promisedStory(this.context,t);return this.read(t,()=>({op:"getNoteBody",note:this.#e()}),n=>{e.hydrateAddress({kind:"handle",handle:u(n,t)});}),this.#t=e,e}delete(){this.command("delete",()=>({op:"deleteNote",note:this.#e()}));}getNext(){let t=`${this.path.label}.getNext`,e=o.promised(this.context,t,false),n=this.internals.roots().document,r=`${t}.type`,s="footnote",a=c.pending(r);return this.read(r,()=>({op:"getNoteKind",note:this.#e()}),d=>{s=R(d,r)==="endnote"?"endnote":"footnote",a.resolveTo(this.#e());}),this.enqueue({sort:"read",label:t,dependencies:[a],plan:()=>({op:"getNotes",document:n,noteKind:s}),settle:d=>{let h=C(d,t),P=h.findIndex(at=>at.ref===this.#e().ref),J=P<0?void 0:h[P+1];J||i({code:"ItemNotFound",target:t}),e.hydrateAddress({kind:"handle",handle:J});}}),e}onLoad(t){let e=this.selection(t,["text","type"]);if(e.includes("text")&&this.loadTextInto("text",()=>({op:"getNoteText",note:this.#e(),projection:this.revisionTextView()})),e.includes("type")){let n=`${this.path.label}.type`;this.read(n,()=>({op:"getNoteKind",note:this.#e()}),r=>{this.setLoadedProperty("type",Ge(R(r,n)));});}}#e(){return this.requireAddressable(),this.path.handle()}},N=class o extends A{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return pt.at(this.context,t,e)}promised(t,e){return pt.promised(this.context,t,e)}};var V=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get code(){return this.loadedProperty("code")}set code(t){if(this.requireUsablePath(),(typeof t!="string"||t.length===0)&&i({code:"InvalidArgument",target:`${this.path.label}.code`}),this.#t){this.#t.code=t;return}let e={code:t};this.#t=e,this.commandAnswering(this.path.label,()=>({op:"setFieldCode",field:this.#n(),code:e.code}),n=>m(n,this.path.label),()=>{this.#t===e&&(this.#t=void 0);});}delete(){this.#e("deleteField");}updateResult(){this.#e("updateFieldResult");}#e(t){this.requireUsablePath(),this.commandAnswering(this.path.label,()=>({op:t,field:this.#n()}),e=>m(e,this.path.label));}onLoad(t){this.selection(t,["code"]).length!==0&&this.read(this.path.label,()=>({op:"getField",field:this.#n()}),e=>{e.kind!=="field"&&i({code:"GeneralException",target:this.path.label}),this.setLoadedProperty("code",e.field.code);});}#n(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&i({code:"InvalidObjectPath",target:this.path.label}),t.handle}},W=class o extends T{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getLastOrNullObject(){return this.edge("last","getLastOrNullObject",true)}listing(){return {op:"getFields",span:k(this.path,this.#t)}}size(t,e){return C(t,e).length}addressAt(t,e,n){let r=C(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return V.at(this.context,t,e)}promised(t,e){return V.promised(this.context,t,e)}};var ze=["width","height","lockAspectRatio","altTextDescription"],U=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get width(){return this.loadedProperty("width")}set width(t){this.#e("width",t);}get height(){return this.loadedProperty("height")}set height(t){this.#e("height",t);}get lockAspectRatio(){return this.loadedProperty("lockAspectRatio")}set lockAspectRatio(t){typeof t!="boolean"&&i({code:"InvalidArgument",target:`${this.path.label}.lockAspectRatio`}),this.#n({lockAspectRatio:t});}get altTextDescription(){return this.loadedProperty("altTextDescription")}set altTextDescription(t){typeof t!="string"&&i({code:"InvalidArgument",target:`${this.path.label}.altTextDescription`}),this.#n({altTextDescription:t});}delete(){let t=`${this.path.label}.delete`;this.commandAnswering(t,()=>({op:"deleteInlinePicture",picture:this.#o()}),e=>m(e,t));}onLoad(t){let e=this.selection(t,ze);e.length&&this.read(this.path.label,()=>({op:"getInlinePicture",picture:this.#o()}),n=>{n.kind!=="inlinePicture"&&i({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.picture[r]);});}#e(t,e){(typeof e!="number"||!Number.isFinite(e)||e<=0)&&i({code:"InvalidArgument",target:`${this.path.label}.${t}`}),this.#n({[t]:e});}#n(t){if(this.requireUsablePath(),this.#t){Object.assign(this.#t,t);return}let e=t;this.#t=e,this.commandAnswering(this.path.label,()=>({op:"setInlinePicture",picture:this.#o(),properties:e}),n=>m(n,this.path.label),()=>{this.#t===e&&(this.#t=void 0);});}#o(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&i({code:"InvalidObjectPath",target:this.path.label}),t.handle}},G=class o extends T{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getLastOrNullObject(){return this.edge("last","getLastOrNullObject",true)}listing(){return {op:"getInlinePictures",span:k(this.path,this.#t)}}size(t,e){return C(t,e).length}addressAt(t,e,n){let r=C(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return U.at(this.context,t,e)}promised(t,e){return U.promised(this.context,t,e)}};function q(o,t,e=0){return (!Number.isInteger(o)||o<e)&&i({code:"InvalidArgument",target:t}),o}function Vt(o,t){return (!Array.isArray(o)||o.some(e=>!Array.isArray(e)||e.some(n=>typeof n!="string")))&&i({code:"InvalidArgument",target:t}),o.map(e=>[...e])}function Pe(o,t){return o!=="Start"&&o!=="End"&&i({code:"InvalidArgument",target:t}),o==="Start"?"start":"end"}var z=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n=false){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get values(){return this.loadedProperty("values")}set values(t){let e=Vt(t,`${this.path.label}.values`);this.command("values",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"values",values:e}}));}get style(){return this.loadedProperty("style")}set style(t){typeof t!="string"&&i({code:"InvalidArgument",target:`${this.path.label}.style`}),this.command("style",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"properties",styleId:t}}));}get headerRowCount(){return this.loadedProperty("headerRowCount")}set headerRowCount(t){q(t,`${this.path.label}.headerRowCount`),this.command("headerRowCount",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"properties",headerRowCount:t}}));}get rowCount(){return this.loadedProperty("rowCount")}get columnCount(){return this.loadedProperty("columnCount")}get rows(){return this.#t??=rt.of(this.context,`${this.path.label}.rows`,this.path,()=>({op:"getTableRows",table:this.path.handle()}))}getCell(t,e){let n=`${this.path.label}.getCell`;q(t,n),q(e,n);let r=ot.promised(this.context,n);return this.read(n,()=>({op:"getTableCell",table:this.path.handle(),rowIndex:t,cellIndex:e}),s=>r.hydrateAddress({kind:"handle",handle:u(s,n)})),r}addRows(t,e,n){let r=`${this.path.label}.addRows`,s=Pe(t,r);q(e,r,1);let a=n===void 0?void 0:Vt(n,r),d=rt.of(this.context,r,this.path,()=>null);return this.commandAnswering(r,()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"addRows",location:s,count:e,...a?{values:a}:{}}}),h=>d.fill(h,r)),d}addColumns(t,e,n){let r=`${this.path.label}.addColumns`,s=Pe(t,r);q(e,r,1);let a=n===void 0?void 0:Vt(n,r);this.command("addColumns",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"addColumns",location:s,count:e,...a?{values:a}:{}}}));}deleteRows(t,e){e===void 0&&(e=1),q(t,this.path.label),q(e,this.path.label,1),this.command("deleteRows",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"deleteRows",index:t,count:e}}));}deleteColumns(t,e){e===void 0&&(e=1),q(t,this.path.label),q(e,this.path.label,1),this.command("deleteColumns",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"deleteColumns",index:t,count:e}}));}delete(){this.command("delete",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"delete"}}));}onLoad(t){let e=this.selection(t,["values","style","headerRowCount","rowCount","columnCount"]);this.read(this.path.label,()=>({op:"getTable",table:this.path.handle()}),n=>{n.kind!=="table"&&i({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.table[r]);});}},ut=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n=false){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}insertRows(t,e,n){let r=`${this.path.label}.insertRows`;t!=="Before"&&t!=="After"&&i({code:"InvalidArgument",target:r}),q(e,r,1);let s=n===void 0?void 0:Vt(n,r),a=rt.of(this.context,r,this.path,()=>null);return this.commandAnswering(r,()=>({op:"insertTableRows",row:this.path.handle(),location:t==="Before"?"before":"after",count:e,...s?{values:s}:{}}),d=>a.fill(d,r)),a}get cells(){return this.#t??=It.of(this.context,`${this.path.label}.cells`,this.path,()=>({op:"getTableCells",row:this.path.handle()}))}},ot=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n=false){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get body(){if(this.#t)return this.#t;let t=`${this.path.label}.body`,e=I.promisedStory(this.context,t);return this.read(t,()=>({op:"getTableCellBody",cell:this.path.handle()}),n=>e.hydrateAddress({kind:"handle",handle:u(n,t)})),this.#t=e,e}get value(){return this.loadedProperty("value")}set value(t){typeof t!="string"&&i({code:"InvalidArgument",target:`${this.path.label}.value`}),this.command("value",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{value:t}}));}get columnWidth(){return this.loadedProperty("columnWidth")}set columnWidth(t){(typeof t!="number"||!Number.isFinite(t)||t<=0)&&i({code:"InvalidArgument",target:`${this.path.label}.columnWidth`}),this.command("columnWidth",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{columnWidth:t}}));}get shadingColor(){return this.loadedProperty("shadingColor")}set shadingColor(t){typeof t!="string"&&i({code:"InvalidArgument",target:`${this.path.label}.shadingColor`}),this.command("shadingColor",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{shadingColor:t}}));}get verticalAlignment(){return this.loadedProperty("verticalAlignment")}set verticalAlignment(t){t!=="Top"&&t!=="Center"&&t!=="Bottom"&&i({code:"InvalidArgument",target:`${this.path.label}.verticalAlignment`}),this.command("verticalAlignment",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{verticalAlignment:t}}));}onLoad(t){let e=this.selection(t,["value","columnWidth","shadingColor","verticalAlignment"]);this.read(this.path.label,()=>({op:"getTableCellProperties",cell:this.path.handle()}),n=>{n.kind!=="tableCell"&&i({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.cell[r]);});}},Q=class o extends A{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}static over(t,e,n,r){return o.of(t,e,n,()=>({op:"getTables",scope:r()}))}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return z.at(this.context,t,e)}promised(t,e){return z.promised(this.context,t,e)}},rt=class o extends A{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return ut.at(this.context,t,e)}promised(t,e){return ut.promised(this.context,t,e)}},It=class o extends A{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return ot.at(this.context,t,e)}promised(t,e){return ot.promised(this.context,t,e)}};var _t=(s=>(s.replace="Replace",s.start="Start",s.end="End",s.before="Before",s.after="After",s))(_t||{}),te=(a=>(a.mixed="Mixed",a.unknown="Unknown",a.left="Left",a.centered="Centered",a.right="Right",a.justified="Justified",a))(te||{}),ee=(e=>(e.portrait="Portrait",e.landscape="Landscape",e))(ee||{}),ne=(n=>(n.off="Off",n.trackAll="TrackAll",n.trackMineOnly="TrackMineOnly",n))(ne||{}),oe=(r=>(r.mixed="Mixed",r.top="Top",r.center="Center",r.bottom="Bottom",r))(oe||{}),re=(d=>(d.line="Line",d.page="Page",d.next="Next",d.sectionNext="SectionNext",d.sectionContinuous="SectionContinuous",d.sectionEven="SectionEven",d.sectionOdd="SectionOdd",d))(re||{}),ie=(y=>(y.unknown="Unknown",y.richText="RichText",y.plainText="PlainText",y.picture="Picture",y.buildingBlockGallery="BuildingBlockGallery",y.checkBox="CheckBox",y.comboBox="ComboBox",y.datePicker="DatePicker",y.dropDownList="DropDownList",y.group="Group",y.repeatingSection="RepeatingSection",y.plainTextInline="PlainTextInline",y.plainTextParagraph="PlainTextParagraph",y.richTextInline="RichTextInline",y.richTextParagraphs="RichTextParagraphs",y.richTextTable="RichTextTable",y.richTextTableCell="RichTextTableCell",y.richTextTableRow="RichTextTableRow",y))(ie||{}),se=(x=>(x.all="All",x.atMentions="AtMentions",x.commentReactions="CommentReactions",x.comments="Comments",x.contentType="ContentType",x.documentIntelligence="DocumentIntelligence",x.documentManagementPolicy="DocumentManagementPolicy",x.documentProperties="DocumentProperties",x.documentServerProperties="DocumentServerProperties",x.documentTasks="DocumentTasks",x.documentWorkspace="DocumentWorkspace",x.emailHeader="EmailHeader",x.inkAnnotations="InkAnnotations",x.removePersonalInformation="RemovePersonalInformation",x.revisions="Revisions",x.routingSlip="RoutingSlip",x.sendForReview="SendForReview",x.taskpaneWebExtensions="TaskpaneWebExtensions",x.template="Template",x.versions="Versions",x))(se||{});var Qe=["Replace","Start","End"],Xe=["Start","End"],Ke=["Replace","Start","End"],Ze=["Before","After"],Ye=["Replace","Start","End","Before","After"],Je=["Select","Start","End"];function mt(o,t,e){return (typeof o!="string"||!t.includes(o))&&i({code:"InvalidArgument",target:e}),o}var Re=(o,t)=>mt(o,Qe,t),Oe=(o,t)=>mt(o,Xe,t),ke=(o,t)=>mt(o,Ke,t),Ie=(o,t)=>mt(o,Ze,t),St=(o,t)=>mt(o,Ye,t),Wt=(o,t)=>o===void 0?"Select":mt(o,Je,t);function S(o,t){return typeof o!="string"&&i({code:"InvalidArgument",target:t}),/[\r\n\f\u2028\u2029]/.test(o)&&i({code:"InvalidArgument",target:t}),o}var _e=8,de=(d=>(d.custom="Custom",d.solid="Solid",d.hollow="Hollow",d.square="Square",d.diamonds="Diamonds",d.arrow="Arrow",d.checkmark="Checkmark",d))(de||{}),le=(a=>(a.none="None",a.arabic="Arabic",a.upperRoman="UpperRoman",a.lowerRoman="LowerRoman",a.upperLetter="UpperLetter",a.lowerLetter="LowerLetter",a))(le||{}),E=class o extends p{#t;#e=new Map;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get id(){return this.loadedProperty("id")}get paragraphs(){return this.#t??=L.overListing(this.context,`${this.path.label}.paragraphs`,this.path,()=>({op:"getListParagraphs",list:this.#o()})),this.#t}getLevelParagraphs(t){let e=`${this.path.label}.getLevelParagraphs`,n=ae(t,e);return L.overListing(this.context,e,this.path,()=>({op:"getListParagraphs",list:this.#o(),level:n}))}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=S(t,n);e!=="Start"&&e!=="End"&&e!=="Before"&&e!=="After"&&i({code:"InvalidArgument",target:n});let s=w.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertListParagraph",list:this.#o(),where:e==="Start"||e==="Before"?"start":"end",text:r}),a=>{s.hydrateAddress({kind:"handle",handle:u(a,n)});}),s}setLevelBullet(t,e,n,r){this.#n(t,{bullet:e,...n===void 0?{}:{charCode:n},...r===void 0?{}:{fontName:r}});}setLevelNumbering(t,e,n){this.#n(t,{numbering:e,...n===void 0?{}:{formatString:[...n]}});}setLevelStartingNumber(t,e){this.#n(t,{startingNumber:e});}setLevelIndents(t,e,n){this.#n(t,{textIndent:e,bulletNumberPictureIndent:n});}#n(t,e){let n=`${this.path.label}.levelFormat`,r=ae(t,n);this.requireUsablePath();let s=this.#e.get(r);if(s){Object.assign(s,e),"bullet"in e&&(delete s.numbering,delete s.formatString),"numbering"in e&&(delete s.bullet,delete s.charCode,delete s.fontName);return}let a={...e};this.#e.set(r,a),this.commandAnswering(n,()=>({op:"setListLevelFormat",list:this.#o(),level:r,format:a}),d=>{m(d,n);},()=>{this.#e.get(r)===a&&this.#e.delete(r);});}onLoad(t){if(!this.selection(t,["id"]).includes("id"))return;let e=`${this.path.label}.id`;this.read(e,()=>({op:"getListId",list:this.#o()}),n=>{this.setLoadedProperty("id",$t(n,e));});}#o(){return this.requireAddressable(),this.path.handle()}},gt=class o extends A{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getById(t){let e=`${this.path.label}.getById`,n=tn(t,e),r=this.#t,s=E.promised(this.context,e,false);return this.enqueue({sort:"read",label:e,plan:()=>({op:"getListById",body:r,id:n}),settle:a=>{s.hydrateAddress({kind:"handle",handle:u(a,e)});}}),s}listing(){return {op:"getLists",body:this.#t}}itemAt(t,e){return E.at(this.context,t,e)}promised(t,e){return E.promised(this.context,t,e)}},ft=class o extends p{static of(t,e,n){return new o(t,c.derived(e,n))}constructor(t,e){super(t,e);}get level(){return this.loadedProperty("level")}set level(t){let e=`${this.path.label}.level`,n=ae(t,e);this.commandAnswering(e,()=>({op:"setListLevel",paragraph:this.#t(),level:n}),r=>{m(r,e);});}onLoad(t){if(!this.selection(t,["level"]).includes("level"))return;let e=`${this.path.label}.level`;this.read(e,()=>({op:"getListLevel",paragraph:this.#t()}),n=>{this.setLoadedProperty("level",$t(n,e));});}#t(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&i({code:"InvalidObjectPath",target:this.path.label}),t.handle}};function ae(o,t){return (!Number.isInteger(o)||o<0||o>_e)&&i({code:"InvalidArgument",target:t}),o}function tn(o,t){return (!Number.isInteger(o)||o<=0)&&i({code:"InvalidArgument",target:t}),o}var ce=(f=>(f.mixed="Mixed",f.none="None",f.hidden="Hidden",f.dotLine="DotLine",f.single="Single",f.word="Word",f.double="Double",f.thick="Thick",f.dotted="Dotted",f.dottedHeavy="DottedHeavy",f.dashLine="DashLine",f.dashLineHeavy="DashLineHeavy",f.dashLineLong="DashLineLong",f.dashLineLongHeavy="DashLineLongHeavy",f.dotDashLine="DotDashLine",f.dotDashLineHeavy="DotDashLineHeavy",f.twoDotDashLine="TwoDotDashLine",f.twoDotDashLineHeavy="TwoDotDashLineHeavy",f.wave="Wave",f.waveHeavy="WaveHeavy",f.waveDouble="WaveDouble",f))(ce||{}),en=["bold","italic","color","name","size","underline","strikeThrough","highlightColor","subscript","superscript"],D=class o extends p{#t;#e;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}get bold(){return this.loadedProperty("bold")}set bold(t){this.#n("bold",Lt(t,`${this.path.label}.bold`));}get italic(){return this.loadedProperty("italic")}set italic(t){this.#n("italic",Lt(t,`${this.path.label}.italic`));}get color(){return this.loadedProperty("color")}set color(t){this.#n("color",Ut(t,`${this.path.label}.color`));}get name(){return this.loadedProperty("name")}set name(t){this.#n("name",Ut(t,`${this.path.label}.name`));}get size(){return this.loadedProperty("size")}set size(t){this.#n("size",nn(t,`${this.path.label}.size`));}get underline(){return this.loadedProperty("underline")}set underline(t){this.#n("underline",Ut(t,`${this.path.label}.underline`));}get highlightColor(){return this.loadedProperty("highlightColor")}set highlightColor(t){this.#n("highlightColor",t===null?null:Ut(t,`${this.path.label}.highlightColor`));}get strikeThrough(){return this.loadedProperty("strikeThrough")}set strikeThrough(t){this.#n("strikeThrough",Lt(t,`${this.path.label}.strikeThrough`));}get subscript(){return this.loadedProperty("subscript")}set subscript(t){this.#n("subscript",Lt(t,`${this.path.label}.subscript`));}get superscript(){return this.loadedProperty("superscript")}set superscript(t){this.#n("superscript",Lt(t,`${this.path.label}.superscript`));}onLoad(t){let e=this.selection(t,en);if(e.length===0)return;let n=`${this.path.label}.font`;this.read(n,()=>({op:"getFont",span:this.#o()}),r=>{let s=Xt(r,n);for(let a of e)this.setLoadedProperty(a,s[a]);});}#n(t,e){if(this.requireUsablePath(),this.#e){this.#e[t]=e,t==="subscript"&&e===true&&(this.#e.superscript=false),t==="superscript"&&e===true&&(this.#e.subscript=false);return}let n={[t]:e};t==="subscript"&&e===true&&(n.superscript=false),t==="superscript"&&e===true&&(n.subscript=false),this.#e=n;let r=`${this.path.label}.${t}`;this.commandAnswering(this.path.label,()=>({op:"setFont",span:this.#o(),font:n}),s=>{m(s,r);},()=>{this.#e===n&&(this.#e=void 0);});}#o(){return this.requireAddressable(),k(this.path,this.#t)}};function Lt(o,t){return typeof o!="boolean"&&i({code:"InvalidArgument",target:t}),o}function nn(o,t){return (typeof o!="number"||!Number.isFinite(o))&&i({code:"InvalidArgument",target:t}),o}function Ut(o,t){return (typeof o!="string"||o.length===0)&&i({code:"InvalidArgument",target:t}),o}var on=16,w=class o extends p{#t;#e;#n;#o;#s;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get text(){return this.loadedProperty("text")}get uniqueLocalId(){return this.loadedProperty("uniqueLocalId")}get style(){return this.loadedProperty("style")}set style(t){this.#a("style",ct(t,`${this.path.label}.style`));}get shapes(){return this.#e??=F.of(this.context,`${this.path.label}.shapes`,this.path,"paragraph"),this.#e}get font(){return this.#t??=D.of(this.context,`${this.path.label}.font`,this.path,"paragraph"),this.#t}get alignment(){return this.loadedProperty("alignment")}set alignment(t){this.#a("alignment",sn(t,`${this.path.label}.alignment`));}get firstLineIndent(){return this.loadedProperty("firstLineIndent")}set firstLineIndent(t){this.#a("firstLineIndent",bt(t,`${this.path.label}.firstLineIndent`));}get leftIndent(){return this.loadedProperty("leftIndent")}set leftIndent(t){this.#a("leftIndent",bt(t,`${this.path.label}.leftIndent`));}get rightIndent(){return this.loadedProperty("rightIndent")}set rightIndent(t){this.#a("rightIndent",bt(t,`${this.path.label}.rightIndent`));}get lineSpacing(){return this.loadedProperty("lineSpacing")}set lineSpacing(t){this.#a("lineSpacing",bt(t,`${this.path.label}.lineSpacing`));}get spaceBefore(){return this.loadedProperty("spaceBefore")}set spaceBefore(t){this.#a("spaceBefore",bt(t,`${this.path.label}.spaceBefore`));}get spaceAfter(){return this.loadedProperty("spaceAfter")}set spaceAfter(t){this.#a("spaceAfter",bt(t,`${this.path.label}.spaceAfter`));}get list(){return this.#n??=this.#i(`${this.path.label}.list`),this.#n}getRange(t="Whole"){let e=`${this.path.label}.getRange`;["Whole","Content","Start","End","Before","After"].includes(t)||i({code:"InvalidArgument",target:e});let n=b.promised(this.context,e,false);return this.read(e,()=>({op:"getRange",span:{paragraph:this.#r()},location:t}),r=>{n.hydrateAddress({kind:"span",span:O(r,e)});}),n}startNewList(){let t=`${this.path.label}.startNewList`,e=E.promised(this.context,t,false);return this.commandAnswering(t,()=>({op:"startNewList",paragraph:this.#r()}),n=>{e.hydrateAddress({kind:"handle",handle:u(n,t)});}),e}attachToList(t,e){let n=`${this.path.label}.attachToList`;(!Number.isSafeInteger(t)||t<=0||!Number.isInteger(e)||e<0||e>8)&&i({code:"InvalidArgument",target:n});let r=E.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"attachToList",paragraph:this.#r(),listId:t,level:e}),s=>{r.hydrateAddress({kind:"handle",handle:u(s,n)});}),r}detachFromList(){let t=`${this.path.label}.detachFromList`;this.commandAnswering(t,()=>({op:"detachFromList",paragraph:this.#r()}),e=>{m(e,t);});}get listItem(){return this.#o??=ft.of(this.context,`${this.path.label}.listItem`,this.path),this.#o}clear(){this.commandDiscarding("clear",()=>({op:"replaceSpan",span:{paragraph:this.#r()},text:""}));}delete(){this.command("delete",()=>({op:"deleteParagraph",paragraph:this.#r()}));}insertText(t,e){let n=`${this.path.label}.insertText`,r=S(t,n),s=ke(e,n),a=b.promised(this.context,n,false);return this.commandAnswering(n,()=>s==="Replace"?{op:"replaceSpan",span:{paragraph:this.#r()},text:r}:{op:"insertText",at:{paragraph:this.#r(),at:s==="Start"?"start":"end"},text:r},d=>{a.hydrateAddress({kind:"span",span:O(d,n)});}),a}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=S(t,n),s=Ie(e,n),a=o.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertParagraph",anchor:{paragraph:this.#r()},where:s==="Before"?"before":"after",text:r}),d=>{d.kind!=="handle"&&i({code:"GeneralException",target:n}),a.hydrateAddress({kind:"handle",handle:d.handle});}),a}split(t,e,n){let r=`${this.path.label}.split`,s=an(t,r),a=Le(e,`${r}.trimDelimiters`),d=Le(n,`${r}.trimSpacing`),h=B.answered(this.context,r,this.path);return this.commandAnswering(r,()=>({op:"splitParagraph",paragraph:this.#r(),delimiters:s,...a?{trimDelimiters:true}:{},...d?{trimSpacing:true}:{}}),P=>{h.fill(P,r);}),h}onLoad(t){let e=this.selection(t,["text","uniqueLocalId",...Se]);e.includes("text")&&this.loadTextInto("text",()=>({op:"getText",target:this.#r(),projection:this.revisionTextView()})),e.includes("uniqueLocalId")&&this.loadTextInto("uniqueLocalId",()=>({op:"getParagraphId",paragraph:this.#r()}));let n=Se.filter(s=>e.includes(s));if(n.length===0)return;let r=`${this.path.label}.paragraphFormat`;this.read(r,()=>({op:"getParagraphFormat",paragraph:{paragraph:this.#r()}}),s=>{let a=Kt(s,r);for(let d of n)this.setLoadedProperty(d,a[d]);});}#a(t,e){if(this.requireUsablePath(),this.#s){this.#s[t]=e;return}let n={[t]:e};this.#s=n;let r=`${this.path.label}.${t}`;this.commandAnswering(`${this.path.label}.paragraphFormat`,()=>({op:"setParagraphFormat",paragraph:{paragraph:this.#r()},format:n}),s=>{m(s,r);},()=>{this.#s===n&&(this.#s=void 0);});}#i(t){let e=E.promised(this.context,t,false);return this.read(t,()=>({op:"getParagraphList",paragraph:this.#r()}),n=>{e.hydrateAddress({kind:"handle",handle:u(n,t)});}),e}#r(){return this.requireAddressable(),this.path.handle()}},Se=["style","alignment","firstLineIndent","leftIndent","rightIndent","lineSpacing","spaceBefore","spaceAfter"],rn=["Left","Centered","Right","Justified"];function sn(o,t){return rn.includes(o)||i({code:"InvalidArgument",target:t}),o}function bt(o,t){return (typeof o!="number"||!Number.isFinite(o))&&i({code:"InvalidArgument",target:t}),o}function an(o,t){(!Array.isArray(o)||o.length===0||o.length>on)&&i({code:"InvalidArgument",target:t});for(let e of o)(typeof e!="string"||e.length===0)&&i({code:"InvalidArgument",target:t});return [...o]}function Le(o,t){return o!==void 0&&typeof o!="boolean"&&i({code:"InvalidArgument",target:t}),o===true}var L=class o extends T{#t;static of(t,e,n){return new o(t,c.derived(e,n),null)}static overListing(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getLastOrNullObject(){return this.edge("last","getLastOrNullObject",true)}listing(){if(this.#t)return this.#t();let t=this.path.address();return t.kind==="handle"?{op:"getParagraphs",body:t.handle}:{op:"getSpanParagraphs",span:t.span}}size(t,e){return C(t,e).length}addressAt(t,e,n){let r=C(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return w.at(this.context,t,e)}promised(t,e){return w.promised(this.context,t,e)}},B=class o extends T{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}static answered(t,e,n){return new o(t,c.derived(e,n),null)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t?this.#t():null}size(t,e){return Bt(t,e).length}addressAt(t,e,n){let r=Bt(t,e)[n];return r?{kind:"span",span:r}:void 0}itemAt(t,e){return b.at(this.context,t,e)}promised(t,e){return b.promised(this.context,t,e)}};var je=4096,$=class o extends p{#t;#e=new Map;#n;#o;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get id(){return this.loadedProperty("id")}get tag(){return this.loadedProperty("tag")}set tag(t){this.#a("tag",{tag:he(t,`${this.path.label}.tag`)});}get title(){return this.loadedProperty("title")}set title(t){this.#a("title",{title:he(t,`${this.path.label}.title`)});}get subtype(){return this.loadedProperty("subtype")}get isBound(){return this.loadedProperty("isBound")}get cannotDelete(){let t=this.loadedProperty("lock");return t==="sdtLocked"||t==="sdtContentLocked"}set cannotDelete(t){this.#i("cannotDelete",t);}get cannotEdit(){let t=this.loadedProperty("lock");return t==="contentLocked"||t==="sdtContentLocked"}set cannotEdit(t){this.#i("cannotEdit",t);}get placeholderShown(){return this.loadedProperty("placeholderShown")}get temporary(){return this.loadedProperty("temporary")}get text(){return this.loadedProperty("text")}get paragraphs(){return this.#n??=L.overListing(this.context,`${this.path.label}.paragraphs`,this.path,()=>({op:"getContentControlParagraphs",contentControl:this.#r()})),this.#n}get contentControls(){return this.#o??=H.of(this.context,`${this.path.label}.contentControls`,this.path,{contentControl:this.#r()}),this.#o}getRange(t){let e=`${this.path.label}.getRange`,n=dn(t??"Whole",e),r=this.#e.get(n);if(r)return r;let s=this.#s(e,n);return this.#e.set(n,s),s}setValue(t){let e=`${this.path.label}.setValue`,n=ln(t,e);this.command("setValue",()=>({op:"setContentControlValue",contentControl:this.#r(),value:n}));}insertText(t,e){let n=`${this.path.label}.insertText`,r=S(t,n),s=e==="Replace"?"replace":e==="Start"?"start":e==="End"?"end":i({code:"InvalidArgument",target:n}),a=b.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertContentControlText",contentControl:this.#r(),text:r,at:s}),d=>{a.hydrateAddress({kind:"span",span:O(d,n)});}),a}delete(t){let e=`${this.path.label}.delete`;typeof t!="boolean"&&i({code:"InvalidArgument",target:e}),this.command("delete",()=>({op:"deleteContentControl",contentControl:this.#r(),keepContent:t}));}onLoad(t){let e=this.selection(t,["id","tag","title","subtype","isBound","text","cannotDelete","cannotEdit","placeholderShown","temporary"]);if(e.includes("id")&&this.loadTextInto("id",()=>({op:"getContentControlFileId",contentControl:this.#r()})),e.includes("tag")&&this.loadTextInto("tag",()=>({op:"getContentControlTag",contentControl:this.#r()})),e.includes("title")&&this.loadTextInto("title",()=>({op:"getContentControlTitle",contentControl:this.#r()})),e.includes("subtype")&&this.loadTextInto("subtype",()=>({op:"getContentControlSubtype",contentControl:this.#r()})),e.includes("isBound")){let r=`${this.path.label}.isBound`;this.read(r,()=>({op:"getContentControlIsBound",contentControl:this.#r()}),s=>{this.setLoadedProperty("isBound",nt(s,r));});}if(e.includes("text")&&this.loadTextInto("text",()=>({op:"getContentControlText",contentControl:this.#r(),projection:this.revisionTextView()})),e.includes("cannotDelete")||e.includes("cannotEdit")){let r=`${this.path.label}.lock`;this.read(r,()=>({op:"getContentControlLock",contentControl:this.#r()}),s=>{this.setLoadedProperty("lock",R(s,r));});}if(e.includes("placeholderShown")){let r=`${this.path.label}.placeholderShown`;this.read(r,()=>({op:"getContentControlPlaceholderShown",contentControl:this.#r()}),s=>{this.setLoadedProperty("placeholderShown",nt(s,r));});}if(!e.includes("temporary"))return;let n=`${this.path.label}.temporary`;this.read(n,()=>({op:"getContentControlTemporary",contentControl:this.#r()}),r=>{this.setLoadedProperty("temporary",nt(r,n));});}#s(t,e){let n=b.promised(this.context,t,false);return this.read(t,()=>({op:"getContentControlRange",contentControl:this.#r(),location:e}),r=>{n.hydrateAddress({kind:"span",span:O(r,t)});}),n}#a(t,e){this.command(t,()=>({op:"setContentControlProperties",contentControl:this.#r(),...e}));}#i(t,e){let n=`${this.path.label}.${t}`;if(typeof e!="boolean"&&i({code:"InvalidArgument",target:n}),this.requireUsablePath(),this.#t){this.#t[t]=e;return}let r={[t]:e};this.#t=r,this.command(t,()=>({op:"setContentControlProperties",contentControl:this.#r(),...r}),()=>{this.#t===r&&(this.#t=void 0);});}#r(){return this.requireAddressable(),this.path.handle()}},H=class o extends A{#t;#e;static of(t,e,n,r){return new o(t,c.derived(e,n),r,()=>({op:"getContentControls",scope:r}))}constructor(t,e,n,r){super(t,e),this.#t=n,this.#e=r;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getById(t){let e=`${this.path.label}.getById`;Number.isInteger(t)||i({code:"InvalidArgument",target:e});let n=this.#t,r=$.promised(this.context,e,false);return this.enqueue({sort:"read",label:e,plan:()=>({op:"getContentControlById",scope:n,id:t}),settle:s=>{r.hydrateAddress({kind:"handle",handle:u(s,e)});}}),r}getByTag(t){let e=`${this.path.label}.getByTag`,n=we(t,e),r=this.#t;return new o(this.context,c.derived(e,this.path),r,()=>({op:"getContentControlsByTag",scope:r,tag:n}))}getByTitle(t){let e=`${this.path.label}.getByTitle`,n=we(t,e),r=this.#t;return new o(this.context,c.derived(e,this.path),r,()=>({op:"getContentControlsByTitle",scope:r,title:n}))}listing(){return this.#e()}itemAt(t,e){return $.at(this.context,t,e)}promised(t,e){return $.promised(this.context,t,e)}};function he(o,t){return (typeof o!="string"||o.length>je)&&i({code:"InvalidArgument",target:t}),o}function we(o,t){let e=he(o,t);return e.length===0&&i({code:"InvalidArgument",target:t}),e}function dn(o,t){switch(o){case "Whole":return "whole";case "Content":return "content";case "Start":return "start";case "End":return "end";case "Before":return "before";case "After":return "after";default:return i({code:"InvalidArgument",target:t})}}function ln(o,t){(typeof o!="object"||o===null)&&i({code:"InvalidArgument",target:t});let e=o;if(e.kind==="text"||e.kind==="listItem"){let n=e.kind==="text"?e.text:e.value;return (typeof n!="string"||n.length>je)&&i({code:"InvalidArgument",target:t}),e.kind==="text"?{kind:"text",text:n}:{kind:"listItem",value:n}}if(e.kind==="checkbox")return typeof e.checked!="boolean"&&i({code:"InvalidArgument",target:t}),{kind:"checkbox",checked:e.checked};if(e.kind==="date")return (typeof e.iso!="string"||e.iso.length>64)&&i({code:"InvalidArgument",target:t}),{kind:"date",iso:e.iso};i({code:"InvalidArgument",target:t});}function cn(o,t){return t<1||t>12?0:t===2?o%4===0&&o%100!==0||o%400===0?29:28:t===4||t===6||t===9||t===11?30:31}function Te(o){if(o.length===0)return null;let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?(Z|[+-]\d{2}:\d{2})$/.exec(o.trim());if(!t)return null;let e=Number(t[1]),n=Number(t[2]),r=Number(t[3]),s=cn(e,n);if(e===0||s===0||r<1||r>s)return null;let a=Number(t[4]),d=Number(t[5]),h=Number(t[6]);if(a>23||d>59||h>59)return null;let P=t[7],J=P===void 0?0:Number(P.padEnd(3,"0").slice(0,3));if(Number.isNaN(J))return null;let at=`${t[1]}-${t[2]}-${t[3]}T${t[4]}:${t[5]}:${t[6]}.${String(J).padStart(3,"0")}Z`,Tt=Date.parse(at);if(Number.isNaN(Tt))return null;let g=t[8];if(g==="Z")return new Date(Tt);let _=Number(g.slice(1,3)),dt=Number(g.slice(4,6));if(dt>59||_>14||_===14&&dt!==0)return null;let Qt=g[0]==="+"?1:-1,Et=new Date(Tt-Qt*(_*36e5+dt*6e4));return Number.isNaN(Et.getTime())?null:Et}var Gt=class extends p{hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get authorName(){return this.loadedProperty("authorName")}get creationDate(){return this.loadedProperty("creationDate")}get id(){return this.loadedProperty("id")}get text(){return this.loadedProperty("text")}delete(){this.command("delete",()=>({op:"deleteComment",comment:this.commentHandle()}));}loadCommentFields(t,e){let n=this.selection(t,["authorName","creationDate","id","text",...e]);if(n.includes("authorName")&&this.loadTextInto("authorName",()=>({op:"getCommentAuthor",comment:this.commentHandle()})),n.includes("text")&&this.loadTextInto("text",()=>({op:"getCommentText",comment:this.commentHandle()})),n.includes("id")&&this.loadTextInto("id",()=>({op:"getCommentId",comment:this.commentHandle()})),n.includes("creationDate")){let s=`${this.path.label}.creationDate`;this.read(s,()=>({op:"getCommentDate",comment:this.commentHandle()}),a=>{this.setLoadedProperty("creationDate",Te(R(a,s)));});}if(!n.includes("resolved"))return;let r=`${this.path.label}.resolved`;this.read(r,()=>({op:"getCommentResolved",comment:this.commentHandle()}),s=>{this.setLoadedProperty("resolved",nt(s,r));});}commentHandle(){return this.requireAddressable(),this.path.handle()}},st=class o extends Gt{static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}onLoad(t){this.loadCommentFields(t,[]);}},wt=class o extends A{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return st.at(this.context,t,e)}promised(t,e){return st.promised(this.context,t,e)}},X=class o extends Gt{#t;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}get resolved(){return this.loadedProperty("resolved")}set resolved(t){let e=`${this.path.label}.resolved`;typeof t!="boolean"&&i({code:"InvalidArgument",target:e}),this.commandAnswering(e,()=>({op:"setCommentResolved",comment:this.commentHandle(),resolved:t}),n=>{m(n,e);});}get replies(){return this.#t??=wt.of(this.context,`${this.path.label}.replies`,this.path,()=>({op:"getCommentReplies",comment:this.commentHandle()})),this.#t}getRange(){let t=`${this.path.label}.getRange`,e=b.promised(this.context,t,false);return this.read(t,()=>({op:"getCommentRange",comment:this.commentHandle()}),n=>{e.hydrateAddress({kind:"span",span:O(n,t)});}),e}reply(t){let e=`${this.path.label}.reply`;(typeof t!="string"||t.length===0)&&i({code:"InvalidArgument",target:e});let n=this.internals.author;(typeof n!="string"||n.trim().length===0)&&i({code:"NotSupported",target:e});let r=st.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"replyToComment",comment:this.commentHandle(),text:t,author:n}),s=>{r.hydrateAddress({kind:"handle",handle:u(s,e)});}),r}onLoad(t){this.loadCommentFields(t,["resolved"]);}},K=class o extends A{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return X.at(this.context,t,e)}promised(t,e){return X.promised(this.context,t,e)}},it=class o extends p{static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get author(){return this.loadedProperty("author")}get date(){return this.loadedProperty("date")}get type(){return this.loadedProperty("type")}get range(){let t=`${this.path.label}.range`,e=b.promised(this.context,t,false);return this.read(t,()=>({op:"getRevisionRange",revision:this.#t()}),n=>{e.hydrateAddress({kind:"span",span:O(n,t)});}),e}accept(){this.command("accept",()=>({op:"acceptRevision",revision:this.#t()}));}reject(){this.command("reject",()=>({op:"rejectRevision",revision:this.#t()}));}onLoad(t){let e=this.selection(t,["author","date","type"]);if(e.includes("author")&&this.loadTextInto("author",()=>({op:"getRevisionAuthor",revision:this.#t()})),e.includes("type")&&this.loadTextInto("type",()=>({op:"getRevisionType",revision:this.#t()})),!e.includes("date"))return;let n=`${this.path.label}.date`;this.read(n,()=>({op:"getRevisionDate",revision:this.#t()}),r=>{this.setLoadedProperty("date",Te(R(r,n)));});}static batchHandle(t,e){return (!(t instanceof o)||t.context!==e)&&i({code:"InvalidArgument",target:"RevisionCollection.resolve"}),t.#t()}#t(){return this.requireAddressable(),this.path.handle()}},Z=class o extends A{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}acceptAll(){let t=this.#t;this.commandOn("acceptAll",()=>({op:"acceptAllRevisions",body:t}));}rejectAll(){let t=this.#t;this.commandOn("rejectAll",()=>({op:"rejectAllRevisions",body:t}));}resolve(t,e){let n=`${this.path.label}.resolve`;(!["accept","reject"].includes(t)||e!==void 0&&!Array.isArray(e))&&i({code:"InvalidArgument",target:n});let r=e===void 0?void 0:[...e],{result:s,fill:a}=xe(n);return this.enqueue({sort:"write",label:n,plan:()=>({op:"resolveRevisionBatch",body:this.#t,action:t,...r===void 0?{}:{revisions:r.map(d=>it.batchHandle(d,this.context))}}),settle:d=>{d.kind!=="revisionBatch"&&i({code:"GeneralException",target:n}),a(d.result);}}),s}listing(){return {op:"getRevisions",body:this.#t}}itemAt(t,e){return it.at(this.context,t,e)}promised(t,e){return it.promised(this.context,t,e)}commandOn(t,e){let n=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:n,plan:e,settle:r=>{m(r,n);}});}};var hn=new Set(["matchCase","matchWholeWord","ignorePunct","ignoreSpace","matchWildcards"]);function zt(o,t){if(o===void 0)return;typeof o!="object"&&i({code:"InvalidArgument",target:t});for(let[n,r]of Object.entries(o))hn.has(n)||i({code:"InvalidArgument",target:`${t}.${n}`}),r!==void 0&&typeof r!="boolean"&&i({code:"InvalidArgument",target:`${t}.${n}`});let e={...o.matchCase===void 0?{}:{matchCase:o.matchCase},...o.matchWholeWord===void 0?{}:{matchWholeWord:o.matchWholeWord},...o.ignorePunct===void 0?{}:{ignorePunct:o.ignorePunct},...o.ignoreSpace===void 0?{}:{ignoreSpace:o.ignoreSpace},...o.matchWildcards===void 0?{}:{matchWildcards:o.matchWildcards}};return Object.keys(e).length===0?void 0:e}var b=class o extends p{#t;#e;#n;#o;#s;#a;static at(t,e,n){return n.kind!=="span"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.ofSpan(e,n.span),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="span"?this.path.resolveToSpan(t.span):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get text(){return this.loadedProperty("text")}get font(){return this.#s??=D.of(this.context,`${this.path.label}.font`,this.path,"span"),this.#s}get paragraphs(){return this.#o??=L.of(this.context,`${this.path.label}.paragraphs`,this.path),this.#o}get style(){return this.loadedProperty("style")}set style(t){let e=`${this.path.label}.style`,n=ct(t,e);this.requireAddressable(),this.command("style",()=>({op:"setStyle",span:k(this.path,"span"),name:n}));}get hyperlink(){return this.loadedProperty("hyperlink")}set hyperlink(t){let e=`${this.path.label}.hyperlink`;(typeof t!="string"||t.length>2048)&&i({code:"InvalidArgument",target:e}),this.requireUsablePath(),this.command("hyperlink",()=>({op:"setHyperlink",span:this.#i(),target:t}));}get bookmarks(){let t=this.#i();return this.#a??=Y.of(this.context,`${this.path.label}.bookmarks`,this.path,()=>({op:"getBookmarks",scope:{start:t.start,end:t.end}})),this.#a}search(t,e){let n=`${this.path.label}.search`;typeof t!="string"&&i({code:"InvalidArgument",target:n});let r=zt(e,n),s=this.#i();return B.of(this.context,n,this.path,()=>({op:"search",scope:s,text:t,options:{...r??{},projection:this.revisionTextView()}}))}insertText(t,e){let n=`${this.path.label}.insertText`,r=S(t,n),s=St(e,n);this.requireUsablePath();let a=o.promised(this.context,n,false);return this.commandAnswering(n,()=>{let d=this.#i();return s==="Replace"?{op:"replaceSpan",span:d,text:r}:{op:"insertText",at:s==="Start"||s==="Before"?d.start:d.end,text:r}},d=>{a.hydrateAddress({kind:"span",span:O(d,n)});}),a}delete(){this.requireUsablePath(),this.commandDiscarding("delete",()=>({op:"replaceSpan",span:this.#i(),text:""}));}clear(){let t=this.#i();this.commandDiscarding("clear",()=>({op:"replaceSpan",span:t,text:""}));}insertComment(t){let e=`${this.path.label}.insertComment`;(typeof t!="string"||t.length===0)&&i({code:"InvalidArgument",target:e});let n=this.internals.author;(typeof n!="string"||n.trim().length===0)&&i({code:"NotSupported",target:e});let r=X.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"insertComment",span:this.#i(),text:t,author:n}),s=>{s.kind!=="handle"&&i({code:"GeneralException",target:e}),r.hydrateAddress(s);}),r}insertContentControl(t){let e=`${this.path.label}.insertContentControl`,n=t??"RichText";n!=="RichText"&&n!=="PlainText"&&n!=="DatePicker"&&i({code:"NotSupported",target:e});let r=$.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"insertContentControl",span:this.#i(),subtype:n==="DatePicker"?"date":n==="PlainText"?"plainText":"richText",returnHandle:true}),s=>{s.kind!=="handle"&&i({code:"GeneralException",target:e}),r.hydrateAddress(s);}),r}get tables(){return this.requireUsablePath(),this.#t??=Q.over(this.context,`${this.path.label}.tables`,this.path,()=>k(this.path,"span"))}get fields(){return this.requireUsablePath(),this.#e??=W.of(this.context,`${this.path.label}.fields`,this.path,"span")}insertField(t,e,n,r){let s=`${this.path.label}.insertField`;(e!==void 0&&typeof e!="string"||n!==void 0&&typeof n!="string"||r!==void 0&&typeof r!="boolean")&&i({code:"InvalidArgument",target:s});let a=St(t,s);this.requireUsablePath();let d=V.promised(this.context,s,false);return this.commandAnswering(s,()=>({op:"insertField",span:this.#i(),location:a,...e===void 0?{}:{fieldType:e},...n===void 0?{}:{text:n},...r===void 0?{}:{removeFormatting:r}}),h=>d.hydrateAddress({kind:"handle",handle:u(h,s)})),d}get inlinePictures(){return this.requireUsablePath(),this.#n??=G.of(this.context,`${this.path.label}.inlinePictures`,this.path,"span")}insertInlinePictureFromBase64(t,e){let n=`${this.path.label}.insertInlinePictureFromBase64`;(typeof t!="string"||t.length===0)&&i({code:"InvalidArgument",target:n});let r=St(e,n);this.requireUsablePath();let s=U.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertInlinePicture",span:this.#i(),base64:t,location:r}),a=>{s.hydrateAddress({kind:"handle",handle:u(a,n)});}),s}insertBreak(t,e){let n=`${this.path.label}.insertBreak`;e!=="Before"&&e!=="After"&&i({code:"InvalidArgument",target:n});let r=e;this.requireUsablePath(),this.commandAnswering(n,()=>({op:"insertBreak",span:this.#i(),breakType:t,location:r}),s=>m(s,n));}insertTable(t,e,n,r){let s=`${this.path.label}.insertTable`;(!Number.isInteger(t)||!Number.isInteger(e)||t<1||e<1||!["Before","After"].includes(n))&&i({code:"InvalidArgument",target:s}),r!==void 0&&(!Array.isArray(r)||r.some(h=>!Array.isArray(h)||h.some(P=>typeof P!="string")))&&i({code:"InvalidArgument",target:s});let a=r?.map(h=>[...h]),d=z.promised(this.context,s);return this.commandAnswering(s,()=>({op:"insertTable",span:k(this.path,"span"),location:n,rowCount:t,columnCount:e,...a?{values:a}:{}}),h=>{h.kind!=="handle"&&i({code:"GeneralException",target:s}),d.hydrateAddress({kind:"handle",handle:h.handle});}),d}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=S(t,n),s=St(e,n);s!=="Before"&&s!=="After"&&i({code:"InvalidArgument",target:n});let a=this.#i(),d=s==="Before"?a.start.paragraph:a.end.paragraph,h=w.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertParagraph",anchor:{paragraph:d},where:s==="Before"?"before":"after",text:r}),P=>{P.kind!=="handle"&&i({code:"GeneralException",target:n}),h.hydrateAddress({kind:"handle",handle:P.handle});}),h}select(t){let e=`${this.path.label}.select`,n=Wt(t,e);this.requireAddressable(),this.internals.capabilities.selection||i({code:"NotSupported",target:e});let r=this.#i();this.command("select",()=>({op:"selectSpan",span:r,mode:n==="Select"?"select":n==="Start"?"start":"end"}));}onLoad(t){let e=this.selection(t,["text","style","hyperlink"]);if(e.includes("hyperlink")&&this.loadTextInto("hyperlink",()=>({op:"getHyperlink",span:this.#i()})),e.includes("text")){let r=`${this.path.label}.text`;this.read(r,()=>({op:"getSpanText",span:this.#i(),projection:this.revisionTextView()}),s=>{this.setLoadedProperty("text",R(s,r));});}if(!e.includes("style"))return;let n=`${this.path.label}.style`;this.requireUsablePath(),this.read(n,()=>({op:"getStyle",span:k(this.path,"span")}),r=>{this.setLoadedProperty("style",Pt(r,n));});}#i(){return this.requireAddressable(),this.path.span()}};var yt=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get name(){return this.loadedProperty("name")}get range(){return this.#t??=this.#e(`${this.path.label}.range`),this.#t}select(t){let e=`${this.path.label}.select`,n=Wt(t,e);this.requireUsablePath(),this.internals.capabilities.selection||i({code:"NotSupported",target:e}),this.command("select",()=>({op:"selectBookmark",bookmark:this.#n(),mode:n==="Select"?"select":n==="Start"?"start":"end"}));}onLoad(t){if(!this.selection(t,["name"]).includes("name"))return;let e=`${this.path.label}.name`;this.read(e,()=>({op:"getBookmarkName",bookmark:this.#n()}),n=>{this.setLoadedProperty("name",R(n,e));});}#e(t){let e=b.promised(this.context,t,false);return this.read(t,()=>({op:"getBookmarkRange",bookmark:this.#n()}),n=>{e.hydrateAddress({kind:"span",span:O(n,t)});}),e}#n(){return this.requireAddressable(),this.path.handle()}},Y=class o extends A{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}listing(){return this.#t()}itemAt(t,e){return yt.at(this.context,t,e)}promised(t,e){return yt.promised(this.context,t,e)}};var I=class o extends p{#t;#e;get footnotes(){return this.#t??=N.of(this.context,`${this.path.label}.footnotes`,this.path,()=>({op:"getNotes",document:this.internals.roots().document,scope:this.#l(),noteKind:"footnote"}))}get endnotes(){return this.#e??=N.of(this.context,`${this.path.label}.endnotes`,this.path,()=>({op:"getNotes",document:this.internals.roots().document,scope:this.#l(),noteKind:"endnote"}))}#n;#o;#s;#a;#i;#r;#d;#c;#h;#p;static main(t,e){return new o(t,c.of(e,et(t).roots().body))}static promisedStory(t,e){return new o(t,c.pending(e))}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}constructor(t,e){super(t,e);}get text(){return this.loadedProperty("text")}get paragraphs(){return this.#i??=this.paragraphsUnder(`${this.path.label}.paragraphs`),this.#i}get bookmarks(){let t=this.#l();return this.#r??=Y.of(this.context,`${this.path.label}.bookmarks`,this.path,()=>({op:"getBookmarks",scope:{body:t}})),this.#r}get font(){return this.#d??=D.of(this.context,`${this.path.label}.font`,this.path,"body"),this.#d}paragraphsUnder(t){return L.of(this.context,t,this.path)}get style(){return this.loadedProperty("style")}set style(t){let e=`${this.path.label}.style`,n=ct(t,e);this.requireAddressable(),this.command("style",()=>({op:"setStyle",span:k(this.path,"body"),name:n}));}get lists(){return this.#c??=gt.of(this.context,`${this.path.label}.lists`,this.path,this.#l()),this.#c}get contentControls(){return this.#h??=H.of(this.context,`${this.path.label}.contentControls`,this.path,{body:this.#l()}),this.#h}getComments(){let t=`${this.path.label}.getComments`,e=this.#l();return K.of(this.context,t,this.path,()=>({op:"getComments",scope:{body:e}}))}get revisions(){return this.#p??=Z.of(this.context,`${this.path.label}.revisions`,this.path,this.#l()),this.#p}getRange(t="Whole"){let e=`${this.path.label}.getRange`;this.requireUsablePath();let n=b.promised(this.context,e,false);return this.read(e,()=>({op:"getRange",span:{body:this.path.handle()},location:t}),r=>{n.hydrateAddress({kind:"span",span:O(r,e)});}),n}search(t,e){let n=`${this.path.label}.search`;typeof t!="string"&&i({code:"InvalidArgument",target:n});let r=zt(e,n),s=this.#l();return B.of(this.context,n,this.path,()=>({op:"search",scope:{body:s},text:t,options:{...r??{},projection:this.revisionTextView()}}))}clear(){let t=this.#l();this.commandDiscarding("clear",()=>({op:"replaceSpan",span:{body:t},text:""}));}insertText(t,e){let n=`${this.path.label}.insertText`,r=S(t,n),s=Re(e,n);this.requireUsablePath();let a=b.promised(this.context,n,false);return this.commandAnswering(n,()=>s==="Replace"?{op:"replaceSpan",span:{body:this.#l()},text:r}:{op:"insertText",at:{body:this.#l(),at:s==="Start"?"start":"end"},text:r},d=>{a.hydrateAddress({kind:"span",span:O(d,n)});}),a}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=S(t,n),s=Oe(e,n),a=this.#l(),d=w.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertParagraph",anchor:{body:a,at:s==="Start"?"first":"last"},where:s==="Start"?"before":"after",text:r}),h=>{h.kind!=="handle"&&i({code:"GeneralException",target:n}),d.hydrateAddress({kind:"handle",handle:h.handle});}),d}onLoad(t){let e=this.selection(t,["text","style"]);e.includes("text")&&this.loadTextInto("text",()=>({op:"getText",target:this.#l(),projection:this.revisionTextView()})),e.includes("style")&&this.#u();}#u(){let t=`${this.path.label}.style`;this.requireUsablePath(),this.read(t,()=>({op:"getStyle",span:k(this.path,"body")}),e=>{this.setLoadedProperty("style",Pt(e,t));});}get fields(){return this.requireUsablePath(),this.#o??=W.of(this.context,`${this.path.label}.fields`,this.path,"body")}get inlinePictures(){return this.requireUsablePath(),this.#s??=G.of(this.context,`${this.path.label}.inlinePictures`,this.path,"body")}get shapes(){return this.requireUsablePath(),this.#a??=F.of(this.context,`${this.path.label}.shapes`,this.path,"body")}get tables(){return this.requireUsablePath(),this.#n??=Q.over(this.context,`${this.path.label}.tables`,this.path,()=>({body:this.#l()}))}#l(){return this.requireAddressable(),this.path.handle()}};var pn=Object.freeze({Primary:"default",FirstPage:"first",EvenPages:"even"}),un=["pageWidth","pageHeight","orientation","topMargin","rightMargin","bottomMargin","leftMargin"],jt=class o extends p{#t;static of(t,e,n){return new o(t,c.derived(e,n))}constructor(t,e){super(t,e);}get pageWidth(){return this.loadedProperty("pageWidth")}set pageWidth(t){this.#e("pageWidth",xt(t,`${this.path.label}.pageWidth`));}get pageHeight(){return this.loadedProperty("pageHeight")}set pageHeight(t){this.#e("pageHeight",xt(t,`${this.path.label}.pageHeight`));}get orientation(){return this.loadedProperty("orientation")}set orientation(t){let e=`${this.path.label}.orientation`;t!=="Portrait"&&t!=="Landscape"&&i({code:"InvalidArgument",target:e}),this.#e("orientation",t==="Portrait"?"portrait":"landscape");}get topMargin(){return this.loadedProperty("topMargin")}set topMargin(t){this.#e("topMargin",xt(t,`${this.path.label}.topMargin`));}get bottomMargin(){return this.loadedProperty("bottomMargin")}set bottomMargin(t){this.#e("bottomMargin",xt(t,`${this.path.label}.bottomMargin`));}get leftMargin(){return this.loadedProperty("leftMargin")}set leftMargin(t){this.#e("leftMargin",xt(t,`${this.path.label}.leftMargin`));}get rightMargin(){return this.loadedProperty("rightMargin")}set rightMargin(t){this.#e("rightMargin",xt(t,`${this.path.label}.rightMargin`));}onLoad(t){let e=this.selection(t,un);if(e.length===0)return;let n=`${this.path.label}.pageSetup`;this.read(n,()=>({op:"getPageSetup",section:this.#n()}),r=>{let s=Zt(r,n);for(let a of e)this.setLoadedProperty(a,a==="orientation"?s.orientation==="landscape"?"Landscape":"Portrait":s[a]);});}#e(t,e){if(this.requireUsablePath(),this.#t){this.#t[t]=e;return}let n={[t]:e};this.#t=n;let r=`${this.path.label}.${t}`;this.commandAnswering(`${this.path.label}.pageSetup`,()=>({op:"setPageSetup",section:this.#n(),setup:n}),s=>{m(s,r);},()=>{this.#t===n&&(this.#t=void 0);});}#n(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&i({code:"InvalidObjectPath",target:this.path.label}),t.handle}},Ct=class o extends p{#t;#e;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get body(){return this.#e??=I.main(this.context,`${this.path.label}.body`),this.#e}get pageSetup(){return this.#t??=jt.of(this.context,`${this.path.label}.pageSetup`,this.path),this.#t}getHeader(t){return this.#n("header",t,"getHeader")}getFooter(t){return this.#n("footer",t,"getFooter")}getNext(){let t=`${this.path.label}.getNext`,e=o.promised(this.context,t,false),n=this.internals.roots().document;return this.read(t,()=>({op:"getSections",document:n}),r=>{let s=C(r,t),a=s.findIndex(h=>h.ref===this.#o().ref),d=a<0?void 0:s[a+1];d||i({code:"ItemNotFound",target:t}),e.hydrateAddress({kind:"handle",handle:d});}),e}onLoad(t){this.selection(t,[]);}#n(t,e,n){let r=`${this.path.label}.${n}`,s=pn[e];s===void 0&&i({code:"InvalidArgument",target:r});let a=I.promisedStory(this.context,r);return this.read(r,()=>({op:"getFurniture",section:this.#o(),kind:t,variant:s}),d=>{a.hydrateAddress({kind:"handle",handle:u(d,r)});}),a}#o(){return this.requireAddressable(),this.path.handle()}},At=class o extends A{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return Ct.at(this.context,t,e)}promised(t,e){return Ct.promised(this.context,t,e)}};function xt(o,t){return (typeof o!="number"||!Number.isFinite(o)||o<0)&&i({code:"InvalidArgument",target:t}),o}var vt=class o extends p{#t;#e;#n;#o;#s;#a;#i;#r;#d;static open(t){return new o(t)}constructor(t){super(t,c.of("document",et(t).roots().document));}get changeTrackingMode(){return this.loadedProperty("changeTrackingMode")}set changeTrackingMode(t){["Off","TrackAll","TrackMineOnly"].includes(t)||i({code:"InvalidArgument",target:"document.changeTrackingMode"});let e=this.internals.author;this.commandAnswering("document.changeTrackingMode",()=>({op:"setChangeTrackingMode",mode:t,...e===void 0?{}:{author:e}}),()=>this.setLoadedProperty("changeTrackingMode",t));}get body(){return this.#e??=I.main(this.context,"document.body"),this.#e}removeDocumentInformation(t){this.command(`${this.path.label}.removeDocumentInformation`,()=>({op:"removeDocumentInformation",removeDocInfoType:t}));}get properties(){return this.#t??=lt.of(this.context,this.path),this.#t}get paragraphs(){return this.#n??=this.body.paragraphsUnder("document.paragraphs"),this.#n}get sections(){let t=this.path.handle();return this.#o??=At.of(this.context,"document.sections",this.path,()=>({op:"getSections",document:t})),this.#o}get contentControls(){return this.#i??=H.of(this.context,"document.contentControls",this.path,{body:this.internals.roots().body}),this.#i}get comments(){return this.#s??=K.of(this.context,"document.comments",this.path,()=>({op:"getComments",scope:{body:this.internals.roots().body}})),this.#s}get revisions(){return this.#a??=Z.of(this.context,"document.revisions",this.path,this.internals.roots().body),this.#a}get footnotes(){let t=this.path.handle();return this.#r??=N.of(this.context,"document.footnotes",this.path,()=>({op:"getNotes",document:t,noteKind:"footnote"})),this.#r}get endnotes(){let t=this.path.handle();return this.#d??=N.of(this.context,"document.endnotes",this.path,()=>({op:"getNotes",document:t,noteKind:"endnote"})),this.#d}onLoad(t){if(t.select.length===0)return;this.selection(t,["changeTrackingMode"]).includes("changeTrackingMode")&&this.loadTextInto("changeTrackingMode",()=>({op:"getChangeTrackingMode"}));}};function Ne(o){let t=o.host,e=Object.freeze({...t.capabilities,save:o.save&&t.capabilities.save}),n=typeof o.author=="string"&&o.author.trim().length>0?o.author:void 0,r=o.revisionTextView??"allMarkup";r!=="allMarkup"&&r!=="original"&&i({code:"InvalidArgument",target:"revisionTextView"});let s=false,a=null,d=g=>{s&&i({code:"RuntimeDisposed",...g===void 0?{}:{target:g}});},h=()=>{if(a)return a;d("document");let g=Ee(t.execute({operations:[{op:"getDocument"}]}),"document"),_=Ee(t.execute({operations:[{op:"getBody",document:g}]}),"document.body");return a={document:g,body:_},a},P={host:t,capabilities:e,...n===void 0?{}:{author:n},revisionTextView:r,id:{},roots:h,assertLive:d,openDocument:g=>vt.open(g)};try{h();}catch{a=null;}async function J(g,_){d();let dt=typeof g=="function"?g:_,Qt=typeof g=="function"?[]:Array.isArray(g)?g:[g];typeof dt!="function"&&i({code:"InvalidArgument",target:"run"});let{context:Et,adopt:y,finish:De}=Ot.begin(P);try{return y(Qt),await dt(Et)}finally{De();}}let at={capabilities:e,run:J,dispose(){s||(s=true,a=null,t.dispose());}};return o.save?{...at,async save(){d("save"),e.save||i({code:"NotSupported",target:"save"});let g=t.save();if(!g.ok)throw Ht(g.error,{target:"save"});return g.bytes}}:at}function Ee(o,t){let e=o.results[0];if(e?.status==="error")throw Ht(e.error,{target:t});if(e?.status!=="ok")throw new v({code:"GeneralException",target:t});return u(e.value,t)}function gn(o){if(o){for(let t of o)if(t.collaboration)return t.collaboration}}function fn(o){let t=[o?.zip?.maxEntries,o?.zip?.maxTotalBytes,o?.xml?.maxBytes,o?.xml?.maxElements,o?.maxXmlParts,o?.maxRelationships],e=o?.zip?.maxRatio;(t.some(n=>n!==void 0&&(!Number.isInteger(n)||n<0))||e!==void 0&&(!Number.isFinite(e)||e<0))&&i({code:"InvalidArgument",target:"createServer"});}async function pe(o,t={}){fn(t.limits);let e=gn(t.modules),n=createServerAutomationHost(o,{...t.pagination?{pagination:me(t.pagination)}:{},...t.limits===void 0?{}:{limits:t.limits},...e===void 0?{}:{collaborationModel:e}});if(!n.ok){let r={"too-many-entries":"zip.maxEntries","too-large":"xml.maxBytes","too-many-elements":"xml.maxElements","too-deep":"xml.maxDepth","too-many-xml-parts":"maxXmlParts","too-many-relationships":"maxRelationships"},s=n.limit??r[n.reason];i({code:s===void 0?"InvalidArgument":"ResourceLimitExceeded",target:"createServer",...s===void 0?{}:{limit:s}});}return Ne({host:n.host,save:true,...t.author===void 0?{}:{author:t.author},...t.revisionTextView===void 0?{}:{revisionTextView:t.revisionTextView}})}function qe(o,t,e={}){return pe(o,{...e,modules:[...e.modules??[],{id:"collaboration",collaboration:{session:t}}]})}var ue=(l=>(l.addin="Addin",l.addressBlock="AddressBlock",l.advance="Advance",l.ask="Ask",l.author="Author",l.autoText="AutoText",l.autoTextList="AutoTextList",l.barCode="BarCode",l.bibliography="Bibliography",l.bidiOutline="BidiOutline",l.citation="Citation",l.comments="Comments",l.compare="Compare",l.createDate="CreateDate",l.data="Data",l.database="Database",l.date="Date",l.displayBarcode="DisplayBarcode",l.docProperty="DocProperty",l.docVariable="DocVariable",l.editTime="EditTime",l.embedded="Embedded",l.empty="Empty",l.eq="EQ",l.expression="Expression",l.fileName="FileName",l.fileSize="FileSize",l.fillIn="FillIn",l.formCheckbox="FormCheckbox",l.formDropdown="FormDropdown",l.formText="FormText",l.gotoButton="GotoButton",l.greetingLine="GreetingLine",l.hyperlink="Hyperlink",l.if="If",l.import="Import",l.include="Include",l.includePicture="IncludePicture",l.includeText="IncludeText",l.index="Index",l.info="Info",l.keywords="Keywords",l.lastSavedBy="LastSavedBy",l.link="Link",l.listNum="ListNum",l.macroButton="MacroButton",l.mergeBarcode="MergeBarcode",l.mergeField="MergeField",l.mergeRec="MergeRec",l.mergeSeq="MergeSeq",l.next="Next",l.nextIf="NextIf",l.noteRef="NoteRef",l.numChars="NumChars",l.numPages="NumPages",l.numWords="NumWords",l.ocx="OCX",l.others="Others",l.page="Page",l.pageRef="PageRef",l.print="Print",l.printDate="PrintDate",l.private="Private",l.quote="Quote",l.rd="RD",l.ref="Ref",l.revNum="RevNum",l.saveDate="SaveDate",l.section="Section",l.sectionPages="SectionPages",l.seq="Seq",l.set="Set",l.shape="Shape",l.skipIf="SkipIf",l.styleRef="StyleRef",l.subject="Subject",l.subscriber="Subscriber",l.symbol="Symbol",l.ta="TA",l.tc="TC",l.template="Template",l.time="Time",l.title="Title",l.toa="TOA",l.toc="TOC",l.undefined="Undefined",l.userAddress="UserAddress",l.userInitials="UserInitials",l.userName="UserName",l.xe="XE",l))(ue||{});var ps=Object.freeze({createServer:pe,createCollaborative:qe});export{te as Alignment,I as Body,yt as Bookmark,Y as BookmarkCollection,re as BreakType,ne as ChangeTrackingMode,M as ClientObject,Dt as ClientResult,X as Comment,K as CommentCollection,st as CommentReply,wt as CommentReplyCollection,$ as ContentControl,H as ContentControlCollection,ie as ContentControlType,vt as Document,lt as DocumentProperties,ps as DocxEditor,v as DocxEditorError,V as Field,W as FieldCollection,ue as FieldType,D as Font,U as InlinePicture,G as InlinePictureCollection,_t as InsertLocation,E as List,de as ListBullet,gt as ListCollection,ft as ListItem,le as ListNumbering,pt as NoteItem,N as NoteItemCollection,ee as PageOrientation,jt as PageSetup,w as Paragraph,L as ParagraphCollection,b as Range,B as RangeCollection,se as RemoveDocInfoType,Ot as RequestContext,it as Revision,Z as RevisionCollection,Ct as Section,At as SectionCollection,ht as Shape,F as ShapeCollection,Ft as ShapeType,z as Table,ot as TableCell,It as TableCellCollection,Q as TableCollection,ut as TableRow,rt as TableRowCollection,Rt as TrackedObjects,ce as UnderlineType,oe as VerticalAlignment,$e as isDocxEditorError};
1
+ import {createServerAutomationHost,createAutomationPaginationProvider}from'@docx-editor.dev/core/automation';function ge(o){return createAutomationPaginationProvider(o)}var fe=Object.freeze({PropertyNotLoaded:"the property has not been loaded. Call load(...) and await context.sync() before reading it.",ValueNotLoaded:"the result has not been filled in yet. Await context.sync() before reading it.",InvalidObjectPath:"the object cannot be addressed. Await context.sync() after creating an object with an edit. Keep proxies within their run, or use context.trackedObjects.add(...) before the run ends.",ObjectInUse:"the object still belongs to a run that has not finished. Await that run before passing the object to another one.",InvalidArgument:"the argument is not one this API accepts.",ResourceLimitExceeded:"the document exceeds a supported resource limit.",ItemNotFound:"the collection has no such item.",NotSupported:"the operation or argument is outside this document or host\u2019s supported capabilities.",NotImplemented:"this version does not implement that yet.",ConflictingChanges:"these operations cannot share one atomic batch. Split them across separate context.sync() calls.",InvalidRequestContext:"the request context has finished. Start another run to continue.",RuntimeDisposed:"the runtime has been disposed.",StaleDocument:"the document or a range changed after this context read it, so nothing was applied. The change can come from another writer or from an earlier sync of this context.",DocumentUnavailable:"the document is not available right now.",GeneralException:"the document could not complete the request."}),R=class extends Error{code;limit;target;expectedRevision;actualRevision;constructor(t){let e=t.target?`${fe[t.code]} (${t.target})`:fe[t.code];super(e),this.name="DocxEditorError",this.code=t.code,t.limit!==void 0&&(this.limit=t.limit),t.target!==void 0&&(this.target=t.target),t.expectedRevision!==void 0&&(this.expectedRevision=t.expectedRevision),t.actualRevision!==void 0&&(this.actualRevision=t.actualRevision);}};function Be(o){return o instanceof R?true:typeof o=="object"&&o!==null&&o.name==="DocxEditorError"&&typeof o.code=="string"}function i(o){throw new R(o)}var nt=Symbol("docx-editor.runtime.internals"),Nt=Symbol("docx-editor.runtime.release"),qt=Symbol("docx-editor.runtime.rebind");function ot(o){return o[nt]}var He=new Set(["select","expand","top","skip"]),Me=/^[A-Za-z][A-Za-z0-9]*$/;function be(o,t){if(o===void 0)return [];let e=typeof o=="string"?o.split(",").map(r=>r.trim()):Array.isArray(o)?o.map(r=>typeof r=="string"?r.trim():r):i({code:"InvalidArgument",target:t}),n=[];for(let r of e)(typeof r!="string"||!Me.test(r))&&i({code:"InvalidArgument",target:t}),n.includes(r)||n.push(r);return n.length===0&&i({code:"InvalidArgument",target:t}),n}function ye(o,t){return (typeof o!="number"||!Number.isInteger(o)||o<0)&&i({code:"InvalidArgument",target:t}),o}function Fe(o,t){o===void 0||Array.isArray(o)&&o.length===0||i({code:"InvalidArgument",target:t});}function xe(o,t){if(o===void 0)return {select:[]};if(typeof o=="string"||Array.isArray(o))return {select:be(o,t)};(typeof o!="object"||o===null)&&i({code:"InvalidArgument",target:t});let e=o;for(let n of Object.keys(e))He.has(n)||i({code:"InvalidArgument",target:`${t}.${n}`});return Fe(e.expand,`${t}.expand`),{select:be(e.select,`${t}.select`),...e.top===void 0?{}:{top:ye(e.top,`${t}.top`)},...e.skip===void 0?{}:{skip:ye(e.skip,`${t}.skip`)}}}var W=class{#t;#e;#n;#o;#a=new Map;#s=false;constructor(t,e,n={}){this.#t=t,this.#e=t[nt],this.#n=e,this.#o=n.nullable===true,this.#e.register(this);}get context(){return this.#t}get isNullObject(){return this.#n.isReleased&&i({code:"InvalidObjectPath",target:this.#n.label}),this.#o?(this.#n.isPending&&i({code:"PropertyNotLoaded",target:`${this.#n.label}.isNullObject`}),this.#n.isNull):false}load(t){this.#s=true;try{return this.requireUsablePath(),this.onLoad(xe(t,this.#n.label)),this}finally{this.#s=false;}}get path(){return this.#n}get internals(){return this.#e}handle(){return this.#n.handle()}requireAddressable(){this.#n.isAddressable||i({code:"InvalidObjectPath",target:this.#n.label}),this.#e.assertUsable(this.#n.label);}requireUsablePath(){(this.#n.isReleased||this.#n.isNull&&!(this.#s&&this.#o))&&i({code:"InvalidObjectPath",target:this.#n.label}),this.#e.assertUsable(this.#n.label);}enqueue(t){this.requireUsablePath(),this.#e.queue.push({...t,dependencies:[...t.dependencies??[],this.#n],...this.#s&&this.#o&&t.sort==="read"?{nullableLoad:this.#n}:{}});}loadedProperty(t){return this.#n.isReleased&&!this.#a.has(t)&&i({code:"InvalidObjectPath",target:this.#n.label}),this.#a.has(t)||i({code:"PropertyNotLoaded",target:`${this.#n.label}.${t}`}),this.#a.get(t)}hasLoadedProperty(t){return this.#a.has(t)}setLoadedProperty(t,e){this.#a.set(t,e);}[Nt](){this.#n.release();}[qt](t){this.#t=t,this.#e=t[nt];}};var Dt=class o{#t=false;#e;#n;constructor(t){this.#n=t;}get value(){return this.#t||i({code:"ValueNotLoaded",target:this.#n}),this.#e}get isLoaded(){return this.#t}static create(t){let e=new o(t);return {result:e,fill(n){e.#t=true,e.#e=n;}}}};function Xt(o){return Dt.create(o)}function T(o){return new R({code:"GeneralException",target:o})}function P(o,t){if(o.kind!=="text")throw T(t);return o.text}function u(o,t){if(o.kind!=="handle")throw T(t);return o.handle}function v(o,t){if(o.kind!=="handles")throw T(t);return o.handles}function O(o,t){if(o.kind!=="span")throw T(t);return o.span}function $t(o,t){if(o.kind!=="spans")throw T(t);return o.spans}function Kt(o,t){if(o.kind!=="font")throw T(t);return o.font}function Zt(o,t){if(o.kind!=="paragraphFormat")throw T(t);return o.format}function Rt(o,t){if(o.kind!=="style")throw T(t);return o.name}function Bt(o,t){if(o.kind!=="number")throw T(t);return o.value}function rt(o,t){if(o.kind!=="flag")throw T(t);return o.value}function Yt(o,t){if(o.kind!=="pageSetup")throw T(t);return o.setup}function m(o,t){if(o.kind!=="applied")throw T(t)}var c=class o{label;#t;#e;constructor(t,e,n=null){this.label=t,this.#t=e,this.#e=n;}static of(t,e){return new o(t,{status:"resolved",address:{kind:"handle",handle:e}})}static ofSpan(t,e){return new o(t,{status:"resolved",address:{kind:"span",span:e}})}static pending(t){return new o(t,{status:"pending"})}static derived(t,e){return new o(t,{status:"pending"},e)}get state(){return this.#e?this.#e.state:this.#t}get isAddressable(){return this.state.status==="resolved"}get isPending(){return this.state.status==="pending"}get isNull(){return this.state.status==="null"}get isReleased(){return this.state.status==="released"}address(){let t=this.state;if(t.status==="resolved")return t.address;i({code:"InvalidObjectPath",target:this.label});}handle(){let t=this.address();return t.kind!=="handle"&&i({code:"InvalidObjectPath",target:this.label}),t.handle}span(){let t=this.address();return t.kind!=="span"&&i({code:"InvalidObjectPath",target:this.label}),t.span}resolveTo(t){this.#n({kind:"handle",handle:t});}resolveToSpan(t){this.#n({kind:"span",span:t});}resolveNull(){this.#t.status!=="released"&&(this.#t={status:"null"});}release(){this.#e||(this.#t={status:"released"});}#n(t){this.#t.status!=="released"&&(this.#t={status:"resolved",address:t});}};function Ae(o){let t=[],e=false,n=false;for(let r of o)t.push(r.plan()),r.sort==="write"?n=true:e=true;return {operations:t,hasRead:e,hasWrite:n}}var Ve=Object.freeze({"stale-revision":"StaleDocument","invalid-handle":"InvalidObjectPath","invalid-offset":"InvalidArgument","unsupported-capability":"NotSupported",disposed:"RuntimeDisposed","transaction-refused":"GeneralException","unknown-operation":"NotSupported","unsupported-content":"InvalidArgument","unsupported-revision":"NotImplemented","ambiguous-document":"GeneralException","conflicting-operations":"ConflictingChanges","document-unavailable":"DocumentUnavailable"});function Ht(o,t={}){let e=Ve[o.code]??"GeneralException",n=e==="StaleDocument";return new R({code:e,...t.target===void 0?{}:{target:t.target},...n&&t.expectedRevision!==void 0?{expectedRevision:t.expectedRevision}:{},...n&&t.actualRevision!==void 0?{actualRevision:t.actualRevision}:{}})}function Jt(o,t,e){for(let n=0;n<o.results.length;n+=1){let r=o.results[n];if(r?.status!=="error")continue;let s=t[n]?.label;return Ht(r.error,{...s===void 0?{}:{target:s},...e===void 0?{}:{expectedRevision:e},actualRevision:o.revision})}return new R({code:"GeneralException"})}function _t(o,t){if(t.results.length!==o.length)throw new R({code:"GeneralException"});for(let e=0;e<o.length;e+=1){let n=t.results[e],r=o[e];if(n.status!=="ok")throw new R({code:"GeneralException",target:r.label});r.settle(n.value);}}var Mt=class{#t=[];get size(){return this.#t.length}get pending(){return this.#t}push(t){this.#t.push(t);}take(){let t=this.#t;this.#t=[];for(let e of t)e.capture?.();return t}clear(){for(let t of this.#t)t.dispose?.();this.#t=[];}};function ve(o,t){if(Array.isArray(o)){for(let e of o)t(e);return}t(o);}var Pt=class{#t;#e;constructor(t,e){this.#t=t,this.#e=e;}add(t){this.#t.assertUsable(),ve(t,e=>{this.#n(e),this.#t.track(e);});}remove(t){this.#t.assertUsable(),ve(t,e=>{this.#n(e),this.#t.untrack(e);});}#n(t){this.#e(t)||i({code:"InvalidObjectPath"});}};var Ot=class o{#t;#e=new Mt;#n=new Set;#o=new Set;#a;#s;#i;#r=false;#d=null;#c=false;constructor(t){this.#t=t,this.#a={host:t.host,capabilities:t.capabilities,...t.author===void 0?{}:{author:t.author},revisionTextView:t.revisionTextView,queue:this.#e,session:t.id,roots:()=>t.roots(),assertUsable:e=>{this.#t.assertLive(e),this.#r&&i({code:"InvalidRequestContext",...e===void 0?{}:{target:e}});},isFinished:()=>this.#r,readRevision:()=>this.#d,register:e=>{this.#n.add(e);},track:e=>{this.#o.add(e);},untrack:e=>{this.#o.delete(e);},isTracked:e=>this.#o.has(e),disown:e=>{this.#n.delete(e),this.#o.delete(e);}},this.#s=new Pt(this.#a,e=>this.#n.has(e));}get document(){return this.#a.assertUsable("document"),this.#i??=this.#t.openDocument(this),this.#i}get capabilities(){return this.#t.capabilities}get trackedObjects(){return this.#s}async sync(){this.#a.assertUsable(),this.#c&&i({code:"InvalidRequestContext"});let t=this.#e.take();if(t.length!==0){this.#c=true;try{let e=t.filter(d=>!d.nullableLoad?.isNull),n=t.some(d=>d.sort==="write"),r,s=n&&this.#d!==null?this.#d:void 0,a=d=>d.dependencies?.some(h=>!h.isAddressable)??false;for(;e.some(a);){r??=n&&this.#d!==null?this.#d:this.#t.host.revision();let d=e.filter(g=>g.sort==="read"&&!a(g));d.length===0&&i({code:"InvalidObjectPath",target:e.find(a)?.label}),await this.#h(d,r,s);let h=new Set(d);e=e.filter(g=>!h.has(g)&&!g.nullableLoad?.isNull);}if(e.length){let d=r??(n&&this.#d!==null?this.#d:void 0);await this.#h(e,d,s);}}finally{for(let e of t)e.dispose?.();this.#c=false;}}}async#h(t,e,n){let r=Ae(t),s={operations:r.operations,...e===void 0?{}:{expectedRevision:e}};if(this.#t.host.prepare){let d={...s,expectedRevision:s.expectedRevision??this.#t.host.revision()};await this.#t.host.prepare(d);let h=this.#t.host.execute(d);if(!h.ok)throw Jt(h,t,n);_t(t,h),this.#d=h.revision;return}let a=this.#t.host.execute(s);if(!a.ok)throw Jt(a,t,n);_t(t,a),(r.hasRead||r.hasWrite)&&(this.#d=a.revision);}get[nt](){return this.#a}static begin(t){let e=new o(t);return {context:e,adopt(n){for(let r of n)e.#p(r);},finish(){e.#l();}}}#p(t){let e=t.context;if(e===this)return;let n=e[nt];if(n.session!==this.#t.id)throw new R({code:"InvalidObjectPath"});if(!n.isFinished())throw new R({code:"ObjectInUse"});if(!n.isTracked(t))throw new R({code:"InvalidObjectPath"});let r=n.readRevision();n.disown(t),t[qt](this),this.#n.add(t),this.#o.add(t),r!==null&&this.#u(r);}#u(t){this.#d=this.#d===null?t:Math.min(this.#d,t);}#l(){if(!this.#r){this.#r=true,this.#e.clear();for(let t of this.#n)this.#o.has(t)||t[Nt]();this.#n.clear();}}};function kt(o,t,e){if(o.select.length===0)return t;for(let n of o.select)t.includes(n)||i({code:"InvalidArgument",target:`${e}.${n}`});return o.select}var p=class extends W{revisionTextView(){return ot(this.context).revisionTextView}loadTextInto(t,e){let n=`${this.path.label}.${t}`;this.enqueue({sort:"read",label:n,plan:e,settle:r=>{this.setLoadedProperty(t,P(r,n));}});}command(t,e,n){let r=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:r,plan:e,settle:s=>m(s,r),...n?{capture:n,dispose:n}:{}});}commandDiscarding(t,e){let n=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:n,plan:e,settle:()=>{}});}commandAnswering(t,e,n,r){this.enqueue({sort:"write",label:t,plan:e,settle:n,...r?{capture:r,dispose:r}:{}});}read(t,e,n){this.enqueue({sort:"read",label:t,plan:e,settle:n});}selection(t,e){return kt(t,e,this.path.label)}onLoad(t){this.selection(t,[]);}};var We=["author","title","subject","keywords","comments","category","lastAuthor"],lt=class o extends p{#t;static of(t,e){return new o(t,c.derived("document.properties",e))}constructor(t,e){super(t,e);}get lastAuthor(){return this.loadedProperty("lastAuthor")}get author(){return this.loadedProperty("author")}set author(t){this.#e("author",t);}get title(){return this.loadedProperty("title")}set title(t){this.#e("title",t);}get subject(){return this.loadedProperty("subject")}set subject(t){this.#e("subject",t);}get keywords(){return this.loadedProperty("keywords")}set keywords(t){this.#e("keywords",t);}get comments(){return this.loadedProperty("comments")}set comments(t){this.#e("comments",t);}get category(){return this.loadedProperty("category")}set category(t){this.#e("category",t);}onLoad(t){for(let e of this.selection(t,We))this.read(`${this.path.label}.${e}`,()=>({op:"getDocumentProperty",name:e}),n=>this.setLoadedProperty(e,P(n,this.path.label)));}#e(t,e){if(this.requireUsablePath(),(typeof e!="string"||e.length>4096)&&i({code:"InvalidArgument",target:`${this.path.label}.${t}`}),this.#t){this.#t[t]=e;return}let n={[t]:e};this.#t=n,this.commandAnswering(this.path.label,()=>({op:"setDocumentProperties",values:n}),r=>{m(r,this.path.label);},()=>{this.#t===n&&(this.#t=void 0);});}};function I(o,t){let e=o.address();return t==="span"?(e.kind!=="span"&&i({code:"InvalidObjectPath",target:o.label}),{start:e.span.start,end:e.span.end}):(e.kind!=="handle"&&i({code:"InvalidObjectPath",target:o.label}),t==="body"?{body:e.handle}:{paragraph:e.handle})}function ct(o,t){return (typeof o!="string"||o.trim().length===0||o.length>255)&&i({code:"InvalidArgument",target:t}),o}var E=class extends W{#t;#e=[];constructor(t,e){super(t,e);}get items(){return this.loadedProperty("items")}fill(t,e){this.setLoadedProperty("items",this.#o(t,e,0,void 0)),this.#t={value:t,label:e};let n=this.#e.splice(0,this.#e.length);for(let r of n)this.#n(r,t);}onLoad(t){kt(t,["items"],this.path.label);let e=this.path.isPending?void 0:this.listing();if(e===null)return;let n=`${this.path.label}.items`,r=t.skip??0,s=t.top;this.enqueue({sort:"read",label:n,plan:()=>{let a=e??this.listing();return a||i({code:"InvalidObjectPath",target:this.path.label}),a},settle:a=>{this.setLoadedProperty("items",this.#o(a,n,r,s));}});}edge(t,e,n){let r=`${this.path.label}.${e}()`,s=this.promised(r,n),a=this.path.isPending?void 0:this.listing();if(a===null){let d={edge:t,target:r,nullable:n,item:s};return this.#t?this.#n(d,this.#t.value):this.#e.push(d),s}return this.enqueue({sort:"read",label:r,plan:()=>{let d=a??this.listing();return d||i({code:"InvalidObjectPath",target:this.path.label}),d},settle:d=>{this.#n({edge:t,target:r,nullable:n,item:s},d);}}),s}#n(t,e){let{edge:n,target:r,nullable:s,item:a}=t,d=this.size(e,r);if(d===0){s||i({code:"ItemNotFound",target:r}),a.hydrateNull();return}let h=this.addressAt(e,r,n==="first"?0:d-1);h||i({code:"ItemNotFound",target:r}),a.hydrateAddress(h);}#o(t,e,n,r){let s=this.size(t,e),a=r===void 0?s:Math.min(s,n+r),d=[];for(let h=n;h<a;h+=1){let g=this.addressAt(t,e,h);g&&d.push(this.itemAt(`${e}[${String(h)}]`,g));}return d}},C=class extends E{size(t,e){return v(t,e).length}addressAt(t,e,n){let r=v(t,e)[n];return r?{kind:"handle",handle:r}:void 0}};var Ft=(a=>(a.unsupported="Unsupported",a.textBox="TextBox",a.geometricShape="GeometricShape",a.group="Group",a.picture="Picture",a.canvas="Canvas",a))(Ft||{}),Ue=["id","name","type"],Ce=new Set(Object.values(Ft)),ht=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get id(){return this.loadedProperty("id")}get name(){return this.loadedProperty("name")}get type(){return this.loadedProperty("type")}get body(){if(this.#t)return this.#t;let t=`${this.path.label}.body`,e=S.promisedStory(this.context,t);return this.read(t,()=>({op:"getShapeBody",shape:this.#e()}),n=>{e.hydrateAddress({kind:"handle",handle:u(n,t)});}),this.#t=e,e}onLoad(t){let e=this.selection(t,Ue);e.length&&this.read(this.path.label,()=>({op:"getShape",shape:this.#e()}),n=>{(n.kind!=="shape"||!Ce.has(n.shape.type))&&i({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.shape[r]);});}#e(){return this.requireAddressable(),this.path.handle()}},U=class o extends E{#t;#e;static of(t,e,n,r,s){return new o(t,c.derived(e,n),r,s)}constructor(t,e,n,r){super(t,e),this.#t=n,this.#e=r;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getByTypes(t){let e=`${this.path.label}.getByTypes`;(!Array.isArray(t)||t.some(r=>!Ce.has(r)))&&i({code:"InvalidArgument",target:e});let n=this.#e?this.#e.filter(r=>t.includes(r)):[...t];return o.of(this.context,e,this.path,this.#t,n)}listing(){let t=I(this.path,this.#t);return this.#e?{op:"getShapes",span:t,types:this.#e}:{op:"getShapes",span:t}}size(t,e){return v(t,e).length}addressAt(t,e,n){let r=v(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return ht.at(this.context,t,e)}promised(t,e){return ht.promised(this.context,t,e)}};function Ge(o){return o==="endnote"?"Endnote":"Footnote"}var pt=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get type(){return this.loadedProperty("type")}get text(){return this.loadedProperty("text")}get body(){if(this.#t)return this.#t;let t=`${this.path.label}.body`,e=S.promisedStory(this.context,t);return this.read(t,()=>({op:"getNoteBody",note:this.#e()}),n=>{e.hydrateAddress({kind:"handle",handle:u(n,t)});}),this.#t=e,e}delete(){this.command("delete",()=>({op:"deleteNote",note:this.#e()}));}getNext(){let t=`${this.path.label}.getNext`,e=o.promised(this.context,t,false),n=this.internals.roots().document,r=`${t}.type`,s="footnote",a=c.pending(r);return this.read(r,()=>({op:"getNoteKind",note:this.#e()}),d=>{s=P(d,r)==="endnote"?"endnote":"footnote",a.resolveTo(this.#e());}),this.enqueue({sort:"read",label:t,dependencies:[a],plan:()=>({op:"getNotes",document:n,noteKind:s}),settle:d=>{let h=v(d,t),g=h.findIndex(k=>k.ref===this.#e().ref),H=g<0?void 0:h[g+1];H||i({code:"ItemNotFound",target:t}),e.hydrateAddress({kind:"handle",handle:H});}}),e}onLoad(t){let e=this.selection(t,["text","type"]);if(e.includes("text")&&this.loadTextInto("text",()=>({op:"getNoteText",note:this.#e(),projection:this.revisionTextView()})),e.includes("type")){let n=`${this.path.label}.type`;this.read(n,()=>({op:"getNoteKind",note:this.#e()}),r=>{this.setLoadedProperty("type",Ge(P(r,n)));});}}#e(){return this.requireAddressable(),this.path.handle()}},q=class o extends C{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return pt.at(this.context,t,e)}promised(t,e){return pt.promised(this.context,t,e)}};var G=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get code(){return this.loadedProperty("code")}set code(t){if(this.requireUsablePath(),(typeof t!="string"||t.length===0)&&i({code:"InvalidArgument",target:`${this.path.label}.code`}),this.#t){this.#t.code=t;return}let e={code:t};this.#t=e,this.commandAnswering(this.path.label,()=>({op:"setFieldCode",field:this.#n(),code:e.code}),n=>m(n,this.path.label),()=>{this.#t===e&&(this.#t=void 0);});}delete(){this.#e("deleteField");}updateResult(){this.#e("updateFieldResult");}#e(t){this.requireUsablePath(),this.commandAnswering(this.path.label,()=>({op:t,field:this.#n()}),e=>m(e,this.path.label));}onLoad(t){this.selection(t,["code"]).length!==0&&this.read(this.path.label,()=>({op:"getField",field:this.#n()}),e=>{e.kind!=="field"&&i({code:"GeneralException",target:this.path.label}),this.setLoadedProperty("code",e.field.code);});}#n(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&i({code:"InvalidObjectPath",target:this.path.label}),t.handle}},z=class o extends E{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getLastOrNullObject(){return this.edge("last","getLastOrNullObject",true)}listing(){return {op:"getFields",span:I(this.path,this.#t)}}size(t,e){return v(t,e).length}addressAt(t,e,n){let r=v(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return G.at(this.context,t,e)}promised(t,e){return G.promised(this.context,t,e)}};var ze=["width","height","lockAspectRatio","altTextDescription"],Q=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get width(){return this.loadedProperty("width")}set width(t){this.#e("width",t);}get height(){return this.loadedProperty("height")}set height(t){this.#e("height",t);}get lockAspectRatio(){return this.loadedProperty("lockAspectRatio")}set lockAspectRatio(t){typeof t!="boolean"&&i({code:"InvalidArgument",target:`${this.path.label}.lockAspectRatio`}),this.#n({lockAspectRatio:t});}get altTextDescription(){return this.loadedProperty("altTextDescription")}set altTextDescription(t){typeof t!="string"&&i({code:"InvalidArgument",target:`${this.path.label}.altTextDescription`}),this.#n({altTextDescription:t});}delete(){let t=`${this.path.label}.delete`;this.commandAnswering(t,()=>({op:"deleteInlinePicture",picture:this.#o()}),e=>m(e,t));}onLoad(t){let e=this.selection(t,ze);e.length&&this.read(this.path.label,()=>({op:"getInlinePicture",picture:this.#o()}),n=>{n.kind!=="inlinePicture"&&i({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.picture[r]);});}#e(t,e){(typeof e!="number"||!Number.isFinite(e)||e<=0)&&i({code:"InvalidArgument",target:`${this.path.label}.${t}`}),this.#n({[t]:e});}#n(t){if(this.requireUsablePath(),this.#t){Object.assign(this.#t,t);return}let e=t;this.#t=e,this.commandAnswering(this.path.label,()=>({op:"setInlinePicture",picture:this.#o(),properties:e}),n=>m(n,this.path.label),()=>{this.#t===e&&(this.#t=void 0);});}#o(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&i({code:"InvalidObjectPath",target:this.path.label}),t.handle}},X=class o extends E{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getLastOrNullObject(){return this.edge("last","getLastOrNullObject",true)}listing(){return {op:"getInlinePictures",span:I(this.path,this.#t)}}size(t,e){return v(t,e).length}addressAt(t,e,n){let r=v(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return Q.at(this.context,t,e)}promised(t,e){return Q.promised(this.context,t,e)}};function D(o,t,e=0){return (!Number.isInteger(o)||o<e)&&i({code:"InvalidArgument",target:t}),o}function Vt(o,t){return (!Array.isArray(o)||o.some(e=>!Array.isArray(e)||e.some(n=>typeof n!="string")))&&i({code:"InvalidArgument",target:t}),o.map(e=>[...e])}function Re(o,t){return o!=="Start"&&o!=="End"&&i({code:"InvalidArgument",target:t}),o==="Start"?"start":"end"}var K=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n=false){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get values(){return this.loadedProperty("values")}set values(t){let e=Vt(t,`${this.path.label}.values`);this.command("values",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"values",values:e}}));}get style(){return this.loadedProperty("style")}set style(t){typeof t!="string"&&i({code:"InvalidArgument",target:`${this.path.label}.style`}),this.command("style",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"properties",styleId:t}}));}get headerRowCount(){return this.loadedProperty("headerRowCount")}set headerRowCount(t){D(t,`${this.path.label}.headerRowCount`),this.command("headerRowCount",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"properties",headerRowCount:t}}));}get rowCount(){return this.loadedProperty("rowCount")}get columnCount(){return this.loadedProperty("columnCount")}get rows(){return this.#t??=st.of(this.context,`${this.path.label}.rows`,this.path,()=>({op:"getTableRows",table:this.path.handle()}))}getCell(t,e){let n=`${this.path.label}.getCell`;D(t,n),D(e,n);let r=it.promised(this.context,n);return this.read(n,()=>({op:"getTableCell",table:this.path.handle(),rowIndex:t,cellIndex:e}),s=>r.hydrateAddress({kind:"handle",handle:u(s,n)})),r}addRows(t,e,n){let r=`${this.path.label}.addRows`,s=Re(t,r);D(e,r,1);let a=n===void 0?void 0:Vt(n,r),d=st.of(this.context,r,this.path,()=>null);return this.commandAnswering(r,()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"addRows",location:s,count:e,...a?{values:a}:{}}}),h=>d.fill(h,r)),d}addColumns(t,e,n){let r=`${this.path.label}.addColumns`,s=Re(t,r);D(e,r,1);let a=n===void 0?void 0:Vt(n,r);this.command("addColumns",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"addColumns",location:s,count:e,...a?{values:a}:{}}}));}deleteRows(t,e){e===void 0&&(e=1),D(t,this.path.label),D(e,this.path.label,1),this.command("deleteRows",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"deleteRows",index:t,count:e}}));}deleteColumns(t,e){e===void 0&&(e=1),D(t,this.path.label),D(e,this.path.label,1),this.command("deleteColumns",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"deleteColumns",index:t,count:e}}));}delete(){this.command("delete",()=>({op:"updateTable",table:this.path.handle(),mutation:{kind:"delete"}}));}onLoad(t){let e=this.selection(t,["values","style","headerRowCount","rowCount","columnCount"]);this.read(this.path.label,()=>({op:"getTable",table:this.path.handle()}),n=>{n.kind!=="table"&&i({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.table[r]);});}},ut=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n=false){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}insertRows(t,e,n){let r=`${this.path.label}.insertRows`;t!=="Before"&&t!=="After"&&i({code:"InvalidArgument",target:r}),D(e,r,1);let s=n===void 0?void 0:Vt(n,r),a=st.of(this.context,r,this.path,()=>null);return this.commandAnswering(r,()=>({op:"insertTableRows",row:this.path.handle(),location:t==="Before"?"before":"after",count:e,...s?{values:s}:{}}),d=>a.fill(d,r)),a}get cells(){return this.#t??=It.of(this.context,`${this.path.label}.cells`,this.path,()=>({op:"getTableCells",row:this.path.handle()}))}},it=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n=false){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get body(){if(this.#t)return this.#t;let t=`${this.path.label}.body`,e=S.promisedStory(this.context,t);return this.read(t,()=>({op:"getTableCellBody",cell:this.path.handle()}),n=>e.hydrateAddress({kind:"handle",handle:u(n,t)})),this.#t=e,e}get value(){return this.loadedProperty("value")}set value(t){typeof t!="string"&&i({code:"InvalidArgument",target:`${this.path.label}.value`}),this.command("value",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{value:t}}));}get columnWidth(){return this.loadedProperty("columnWidth")}set columnWidth(t){(typeof t!="number"||!Number.isFinite(t)||t<=0)&&i({code:"InvalidArgument",target:`${this.path.label}.columnWidth`}),this.command("columnWidth",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{columnWidth:t}}));}get shadingColor(){return this.loadedProperty("shadingColor")}set shadingColor(t){typeof t!="string"&&i({code:"InvalidArgument",target:`${this.path.label}.shadingColor`}),this.command("shadingColor",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{shadingColor:t}}));}get verticalAlignment(){return this.loadedProperty("verticalAlignment")}set verticalAlignment(t){t!=="Top"&&t!=="Center"&&t!=="Bottom"&&i({code:"InvalidArgument",target:`${this.path.label}.verticalAlignment`}),this.command("verticalAlignment",()=>({op:"updateTableCell",cell:this.path.handle(),properties:{verticalAlignment:t}}));}onLoad(t){let e=this.selection(t,["value","columnWidth","shadingColor","verticalAlignment"]);this.read(this.path.label,()=>({op:"getTableCellProperties",cell:this.path.handle()}),n=>{n.kind!=="tableCell"&&i({code:"GeneralException",target:this.path.label});for(let r of e)this.setLoadedProperty(r,n.cell[r]);});}},Z=class o extends C{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}static over(t,e,n,r){return o.of(t,e,n,()=>({op:"getTables",scope:r()}))}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return K.at(this.context,t,e)}promised(t,e){return K.promised(this.context,t,e)}},st=class o extends C{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return ut.at(this.context,t,e)}promised(t,e){return ut.promised(this.context,t,e)}},It=class o extends C{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t()}itemAt(t,e){return it.at(this.context,t,e)}promised(t,e){return it.promised(this.context,t,e)}};var te=(s=>(s.replace="Replace",s.start="Start",s.end="End",s.before="Before",s.after="After",s))(te||{}),ee=(a=>(a.mixed="Mixed",a.unknown="Unknown",a.left="Left",a.centered="Centered",a.right="Right",a.justified="Justified",a))(ee||{}),ne=(e=>(e.portrait="Portrait",e.landscape="Landscape",e))(ne||{}),oe=(n=>(n.off="Off",n.trackAll="TrackAll",n.trackMineOnly="TrackMineOnly",n))(oe||{}),re=(r=>(r.mixed="Mixed",r.top="Top",r.center="Center",r.bottom="Bottom",r))(re||{}),ie=(d=>(d.line="Line",d.page="Page",d.next="Next",d.sectionNext="SectionNext",d.sectionContinuous="SectionContinuous",d.sectionEven="SectionEven",d.sectionOdd="SectionOdd",d))(ie||{}),se=(x=>(x.unknown="Unknown",x.richText="RichText",x.plainText="PlainText",x.picture="Picture",x.buildingBlockGallery="BuildingBlockGallery",x.checkBox="CheckBox",x.comboBox="ComboBox",x.datePicker="DatePicker",x.dropDownList="DropDownList",x.group="Group",x.repeatingSection="RepeatingSection",x.plainTextInline="PlainTextInline",x.plainTextParagraph="PlainTextParagraph",x.richTextInline="RichTextInline",x.richTextParagraphs="RichTextParagraphs",x.richTextTable="RichTextTable",x.richTextTableCell="RichTextTableCell",x.richTextTableRow="RichTextTableRow",x))(se||{}),ae=(A=>(A.all="All",A.atMentions="AtMentions",A.commentReactions="CommentReactions",A.comments="Comments",A.contentType="ContentType",A.documentIntelligence="DocumentIntelligence",A.documentManagementPolicy="DocumentManagementPolicy",A.documentProperties="DocumentProperties",A.documentServerProperties="DocumentServerProperties",A.documentTasks="DocumentTasks",A.documentWorkspace="DocumentWorkspace",A.emailHeader="EmailHeader",A.inkAnnotations="InkAnnotations",A.removePersonalInformation="RemovePersonalInformation",A.revisions="Revisions",A.routingSlip="RoutingSlip",A.sendForReview="SendForReview",A.taskpaneWebExtensions="TaskpaneWebExtensions",A.template="Template",A.versions="Versions",A))(ae||{});var Qe=["Replace","Start","End"],Xe=["Start","End"],Ke=["Replace","Start","End"],Ze=["Before","After"],Ye=["Replace","Start","End","Before","After"],Je=["Select","Start","End"];function mt(o,t,e){return (typeof o!="string"||!t.includes(o))&&i({code:"InvalidArgument",target:e}),o}var Pe=(o,t)=>mt(o,Qe,t),Oe=(o,t)=>mt(o,Xe,t),ke=(o,t)=>mt(o,Ke,t),Ie=(o,t)=>mt(o,Ze,t),St=(o,t)=>mt(o,Ye,t),Wt=(o,t)=>o===void 0?"Select":mt(o,Je,t);function L(o,t){return typeof o!="string"&&i({code:"InvalidArgument",target:t}),/[\r\n\f\u2028\u2029]/.test(o)&&i({code:"InvalidArgument",target:t}),o}var _e=8,le=(d=>(d.custom="Custom",d.solid="Solid",d.hollow="Hollow",d.square="Square",d.diamonds="Diamonds",d.arrow="Arrow",d.checkmark="Checkmark",d))(le||{}),ce=(a=>(a.none="None",a.arabic="Arabic",a.upperRoman="UpperRoman",a.lowerRoman="LowerRoman",a.upperLetter="UpperLetter",a.lowerLetter="LowerLetter",a))(ce||{}),N=class o extends p{#t;#e=new Map;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get id(){return this.loadedProperty("id")}get paragraphs(){return this.#t??=w.overListing(this.context,`${this.path.label}.paragraphs`,this.path,()=>({op:"getListParagraphs",list:this.#o()})),this.#t}getLevelParagraphs(t){let e=`${this.path.label}.getLevelParagraphs`,n=de(t,e);return w.overListing(this.context,e,this.path,()=>({op:"getListParagraphs",list:this.#o(),level:n}))}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=L(t,n);e!=="Start"&&e!=="End"&&e!=="Before"&&e!=="After"&&i({code:"InvalidArgument",target:n});let s=j.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertListParagraph",list:this.#o(),where:e==="Start"||e==="Before"?"start":"end",text:r}),a=>{s.hydrateAddress({kind:"handle",handle:u(a,n)});}),s}setLevelBullet(t,e,n,r){this.#n(t,{bullet:e,...n===void 0?{}:{charCode:n},...r===void 0?{}:{fontName:r}});}setLevelNumbering(t,e,n){this.#n(t,{numbering:e,...n===void 0?{}:{formatString:[...n]}});}setLevelStartingNumber(t,e){this.#n(t,{startingNumber:e});}setLevelIndents(t,e,n){this.#n(t,{textIndent:e,bulletNumberPictureIndent:n});}#n(t,e){let n=`${this.path.label}.levelFormat`,r=de(t,n);this.requireUsablePath();let s=this.#e.get(r);if(s){Object.assign(s,e),"bullet"in e&&(delete s.numbering,delete s.formatString),"numbering"in e&&(delete s.bullet,delete s.charCode,delete s.fontName);return}let a={...e};this.#e.set(r,a),this.commandAnswering(n,()=>({op:"setListLevelFormat",list:this.#o(),level:r,format:a}),d=>{m(d,n);},()=>{this.#e.get(r)===a&&this.#e.delete(r);});}onLoad(t){if(!this.selection(t,["id"]).includes("id"))return;let e=`${this.path.label}.id`;this.read(e,()=>({op:"getListId",list:this.#o()}),n=>{this.setLoadedProperty("id",Bt(n,e));});}#o(){return this.requireAddressable(),this.path.handle()}},gt=class o extends C{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getById(t){let e=`${this.path.label}.getById`,n=tn(t,e),r=this.#t,s=N.promised(this.context,e,false);return this.enqueue({sort:"read",label:e,plan:()=>({op:"getListById",body:r,id:n}),settle:a=>{s.hydrateAddress({kind:"handle",handle:u(a,e)});}}),s}listing(){return {op:"getLists",body:this.#t}}itemAt(t,e){return N.at(this.context,t,e)}promised(t,e){return N.promised(this.context,t,e)}},ft=class o extends p{static of(t,e,n){return new o(t,c.derived(e,n))}constructor(t,e){super(t,e);}get level(){return this.loadedProperty("level")}set level(t){let e=`${this.path.label}.level`,n=de(t,e);this.commandAnswering(e,()=>({op:"setListLevel",paragraph:this.#t(),level:n}),r=>{m(r,e);});}onLoad(t){if(!this.selection(t,["level"]).includes("level"))return;let e=`${this.path.label}.level`;this.read(e,()=>({op:"getListLevel",paragraph:this.#t()}),n=>{this.setLoadedProperty("level",Bt(n,e));});}#t(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&i({code:"InvalidObjectPath",target:this.path.label}),t.handle}};function de(o,t){return (!Number.isInteger(o)||o<0||o>_e)&&i({code:"InvalidArgument",target:t}),o}function tn(o,t){return (!Number.isInteger(o)||o<=0)&&i({code:"InvalidArgument",target:t}),o}var he=(b=>(b.mixed="Mixed",b.none="None",b.hidden="Hidden",b.dotLine="DotLine",b.single="Single",b.word="Word",b.double="Double",b.thick="Thick",b.dotted="Dotted",b.dottedHeavy="DottedHeavy",b.dashLine="DashLine",b.dashLineHeavy="DashLineHeavy",b.dashLineLong="DashLineLong",b.dashLineLongHeavy="DashLineLongHeavy",b.dotDashLine="DotDashLine",b.dotDashLineHeavy="DotDashLineHeavy",b.twoDotDashLine="TwoDotDashLine",b.twoDotDashLineHeavy="TwoDotDashLineHeavy",b.wave="Wave",b.waveHeavy="WaveHeavy",b.waveDouble="WaveDouble",b))(he||{}),en=["bold","italic","color","name","size","underline","strikeThrough","highlightColor","subscript","superscript"],$=class o extends p{#t;#e;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}get bold(){return this.loadedProperty("bold")}set bold(t){this.#n("bold",Lt(t,`${this.path.label}.bold`));}get italic(){return this.loadedProperty("italic")}set italic(t){this.#n("italic",Lt(t,`${this.path.label}.italic`));}get color(){return this.loadedProperty("color")}set color(t){this.#n("color",Ut(t,`${this.path.label}.color`));}get name(){return this.loadedProperty("name")}set name(t){this.#n("name",Ut(t,`${this.path.label}.name`));}get size(){return this.loadedProperty("size")}set size(t){this.#n("size",nn(t,`${this.path.label}.size`));}get underline(){return this.loadedProperty("underline")}set underline(t){this.#n("underline",Ut(t,`${this.path.label}.underline`));}get highlightColor(){return this.loadedProperty("highlightColor")}set highlightColor(t){this.#n("highlightColor",t===null?null:Ut(t,`${this.path.label}.highlightColor`));}get strikeThrough(){return this.loadedProperty("strikeThrough")}set strikeThrough(t){this.#n("strikeThrough",Lt(t,`${this.path.label}.strikeThrough`));}get subscript(){return this.loadedProperty("subscript")}set subscript(t){this.#n("subscript",Lt(t,`${this.path.label}.subscript`));}get superscript(){return this.loadedProperty("superscript")}set superscript(t){this.#n("superscript",Lt(t,`${this.path.label}.superscript`));}onLoad(t){let e=this.selection(t,en);if(e.length===0)return;let n=`${this.path.label}.font`;this.read(n,()=>({op:"getFont",span:this.#o()}),r=>{let s=Kt(r,n);for(let a of e)this.setLoadedProperty(a,s[a]);});}#n(t,e){if(this.requireUsablePath(),this.#e){this.#e[t]=e,t==="subscript"&&e===true&&(this.#e.superscript=false),t==="superscript"&&e===true&&(this.#e.subscript=false);return}let n={[t]:e};t==="subscript"&&e===true&&(n.superscript=false),t==="superscript"&&e===true&&(n.subscript=false),this.#e=n;let r=`${this.path.label}.${t}`;this.commandAnswering(this.path.label,()=>({op:"setFont",span:this.#o(),font:n}),s=>{m(s,r);},()=>{this.#e===n&&(this.#e=void 0);});}#o(){return this.requireAddressable(),I(this.path,this.#t)}};function Lt(o,t){return typeof o!="boolean"&&i({code:"InvalidArgument",target:t}),o}function nn(o,t){return (typeof o!="number"||!Number.isFinite(o))&&i({code:"InvalidArgument",target:t}),o}function Ut(o,t){return (typeof o!="string"||o.length===0)&&i({code:"InvalidArgument",target:t}),o}var on=16,j=class o extends p{#t;#e;#n;#o;#a;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get text(){return this.loadedProperty("text")}get uniqueLocalId(){return this.loadedProperty("uniqueLocalId")}get style(){return this.loadedProperty("style")}set style(t){this.#s("style",ct(t,`${this.path.label}.style`));}get shapes(){return this.#e??=U.of(this.context,`${this.path.label}.shapes`,this.path,"paragraph"),this.#e}get font(){return this.#t??=$.of(this.context,`${this.path.label}.font`,this.path,"paragraph"),this.#t}get alignment(){return this.loadedProperty("alignment")}set alignment(t){this.#s("alignment",sn(t,`${this.path.label}.alignment`));}get readingOrder(){return this.loadedProperty("readingOrder")}set readingOrder(t){this.#s("readingOrder",an(t,`${this.path.label}.readingOrder`));}get firstLineIndent(){return this.loadedProperty("firstLineIndent")}set firstLineIndent(t){this.#s("firstLineIndent",bt(t,`${this.path.label}.firstLineIndent`));}get leftIndent(){return this.loadedProperty("leftIndent")}set leftIndent(t){this.#s("leftIndent",bt(t,`${this.path.label}.leftIndent`));}get rightIndent(){return this.loadedProperty("rightIndent")}set rightIndent(t){this.#s("rightIndent",bt(t,`${this.path.label}.rightIndent`));}get lineSpacing(){return this.loadedProperty("lineSpacing")}set lineSpacing(t){this.#s("lineSpacing",bt(t,`${this.path.label}.lineSpacing`));}get spaceBefore(){return this.loadedProperty("spaceBefore")}set spaceBefore(t){this.#s("spaceBefore",bt(t,`${this.path.label}.spaceBefore`));}get spaceAfter(){return this.loadedProperty("spaceAfter")}set spaceAfter(t){this.#s("spaceAfter",bt(t,`${this.path.label}.spaceAfter`));}get list(){return this.#n??=this.#i(`${this.path.label}.list`),this.#n}getRange(t="Whole"){let e=`${this.path.label}.getRange`;["Whole","Content","Start","End","Before","After"].includes(t)||i({code:"InvalidArgument",target:e});let n=y.promised(this.context,e,false);return this.read(e,()=>({op:"getRange",span:{paragraph:this.#r()},location:t}),r=>{n.hydrateAddress({kind:"span",span:O(r,e)});}),n}startNewList(){let t=`${this.path.label}.startNewList`,e=N.promised(this.context,t,false);return this.commandAnswering(t,()=>({op:"startNewList",paragraph:this.#r()}),n=>{e.hydrateAddress({kind:"handle",handle:u(n,t)});}),e}attachToList(t,e){let n=`${this.path.label}.attachToList`;(!Number.isSafeInteger(t)||t<=0||!Number.isInteger(e)||e<0||e>8)&&i({code:"InvalidArgument",target:n});let r=N.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"attachToList",paragraph:this.#r(),listId:t,level:e}),s=>{r.hydrateAddress({kind:"handle",handle:u(s,n)});}),r}detachFromList(){let t=`${this.path.label}.detachFromList`;this.commandAnswering(t,()=>({op:"detachFromList",paragraph:this.#r()}),e=>{m(e,t);});}get listItem(){return this.#o??=ft.of(this.context,`${this.path.label}.listItem`,this.path),this.#o}clear(){this.commandDiscarding("clear",()=>({op:"replaceSpan",span:{paragraph:this.#r()},text:""}));}delete(){let t=`${this.path.label}.delete`;this.commandAnswering(t,()=>({op:"deleteParagraph",paragraph:this.#r()}),e=>{e.kind!=="applied"&&e.kind!=="span"&&i({code:"GeneralException",target:t});});}insertText(t,e){let n=`${this.path.label}.insertText`,r=L(t,n),s=ke(e,n),a=y.promised(this.context,n,false);return this.commandAnswering(n,()=>s==="Replace"?{op:"replaceSpan",span:{paragraph:this.#r()},text:r}:{op:"insertText",at:{paragraph:this.#r(),at:s==="Start"?"start":"end"},text:r},d=>{a.hydrateAddress({kind:"span",span:O(d,n)});}),a}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=L(t,n),s=Ie(e,n),a=o.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertParagraph",anchor:{paragraph:this.#r()},where:s==="Before"?"before":"after",text:r}),d=>{d.kind!=="handle"&&i({code:"GeneralException",target:n}),a.hydrateAddress({kind:"handle",handle:d.handle});}),a}split(t,e,n){let r=`${this.path.label}.split`,s=dn(t,r),a=Le(e,`${r}.trimDelimiters`),d=Le(n,`${r}.trimSpacing`),h=B.answered(this.context,r,this.path);return this.commandAnswering(r,()=>({op:"splitParagraph",paragraph:this.#r(),delimiters:s,...a?{trimDelimiters:true}:{},...d?{trimSpacing:true}:{}}),g=>{h.fill(g,r);}),h}onLoad(t){let e=this.selection(t,["text","uniqueLocalId",...Se]);e.includes("text")&&this.loadTextInto("text",()=>({op:"getText",target:this.#r(),projection:this.revisionTextView()})),e.includes("uniqueLocalId")&&this.loadTextInto("uniqueLocalId",()=>({op:"getParagraphId",paragraph:this.#r()}));let n=Se.filter(s=>e.includes(s));if(n.length===0)return;let r=`${this.path.label}.paragraphFormat`;this.read(r,()=>({op:"getParagraphFormat",paragraph:{paragraph:this.#r()}}),s=>{let a=Zt(s,r);for(let d of n)this.setLoadedProperty(d,a[d]);});}#s(t,e){if(this.requireUsablePath(),this.#a){this.#a[t]=e;return}let n={[t]:e};this.#a=n;let r=`${this.path.label}.${t}`;this.commandAnswering(`${this.path.label}.paragraphFormat`,()=>({op:"setParagraphFormat",paragraph:{paragraph:this.#r()},format:n}),s=>{m(s,r);},()=>{this.#a===n&&(this.#a=void 0);});}#i(t){let e=N.promised(this.context,t,false);return this.read(t,()=>({op:"getParagraphList",paragraph:this.#r()}),n=>{e.hydrateAddress({kind:"handle",handle:u(n,t)});}),e}#r(){return this.requireAddressable(),this.path.handle()}},Se=["style","alignment","firstLineIndent","leftIndent","rightIndent","lineSpacing","spaceBefore","spaceAfter","readingOrder"],rn=["Left","Centered","Right","Justified"];function sn(o,t){return rn.includes(o)||i({code:"InvalidArgument",target:t}),o}function an(o,t){return o!=="LeftToRight"&&o!=="RightToLeft"&&i({code:"InvalidArgument",target:t}),o}function bt(o,t){return (typeof o!="number"||!Number.isFinite(o))&&i({code:"InvalidArgument",target:t}),o}function dn(o,t){(!Array.isArray(o)||o.length===0||o.length>on)&&i({code:"InvalidArgument",target:t});for(let e of o)(typeof e!="string"||e.length===0)&&i({code:"InvalidArgument",target:t});return [...o]}function Le(o,t){return o!==void 0&&typeof o!="boolean"&&i({code:"InvalidArgument",target:t}),o===true}var w=class o extends E{#t;static of(t,e,n){return new o(t,c.derived(e,n),null)}static overListing(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getLastOrNullObject(){return this.edge("last","getLastOrNullObject",true)}listing(){if(this.#t)return this.#t();let t=this.path.address();return t.kind==="handle"?{op:"getParagraphs",body:t.handle}:{op:"getSpanParagraphs",span:t.span}}size(t,e){return v(t,e).length}addressAt(t,e,n){let r=v(t,e)[n];return r?{kind:"handle",handle:r}:void 0}itemAt(t,e){return j.at(this.context,t,e)}promised(t,e){return j.promised(this.context,t,e)}},B=class o extends E{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}static answered(t,e,n){return new o(t,c.derived(e,n),null)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}getLast(){return this.edge("last","getLast",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}listing(){return this.#t?this.#t():null}size(t,e){return $t(t,e).length}addressAt(t,e,n){let r=$t(t,e)[n];return r?{kind:"span",span:r}:void 0}itemAt(t,e){return y.at(this.context,t,e)}promised(t,e){return y.promised(this.context,t,e)}};var je=4096,M=class o extends p{#t;#e=new Map;#n;#o;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get id(){return this.loadedProperty("id")}get tag(){return this.loadedProperty("tag")}set tag(t){this.#s("tag",{tag:pe(t,`${this.path.label}.tag`)});}get title(){return this.loadedProperty("title")}set title(t){this.#s("title",{title:pe(t,`${this.path.label}.title`)});}get subtype(){return this.loadedProperty("subtype")}get isBound(){return this.loadedProperty("isBound")}get cannotDelete(){let t=this.loadedProperty("lock");return t==="sdtLocked"||t==="sdtContentLocked"}set cannotDelete(t){this.#i("cannotDelete",t);}get cannotEdit(){let t=this.loadedProperty("lock");return t==="contentLocked"||t==="sdtContentLocked"}set cannotEdit(t){this.#i("cannotEdit",t);}get placeholderShown(){return this.loadedProperty("placeholderShown")}get temporary(){return this.loadedProperty("temporary")}get text(){return this.loadedProperty("text")}get paragraphs(){return this.#n??=w.overListing(this.context,`${this.path.label}.paragraphs`,this.path,()=>({op:"getContentControlParagraphs",contentControl:this.#r()})),this.#n}get contentControls(){return this.#o??=F.of(this.context,`${this.path.label}.contentControls`,this.path,{contentControl:this.#r()}),this.#o}getRange(t){let e=`${this.path.label}.getRange`,n=ln(t??"Whole",e),r=this.#e.get(n);if(r)return r;let s=this.#a(e,n);return this.#e.set(n,s),s}setValue(t){let e=`${this.path.label}.setValue`,n=cn(t,e);this.command("setValue",()=>({op:"setContentControlValue",contentControl:this.#r(),value:n}));}insertText(t,e){let n=`${this.path.label}.insertText`,r=L(t,n),s=e==="Replace"?"replace":e==="Start"?"start":e==="End"?"end":i({code:"InvalidArgument",target:n}),a=y.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertContentControlText",contentControl:this.#r(),text:r,at:s}),d=>{a.hydrateAddress({kind:"span",span:O(d,n)});}),a}delete(t){let e=`${this.path.label}.delete`;typeof t!="boolean"&&i({code:"InvalidArgument",target:e}),this.command("delete",()=>({op:"deleteContentControl",contentControl:this.#r(),keepContent:t}));}onLoad(t){let e=this.selection(t,["id","tag","title","subtype","isBound","text","cannotDelete","cannotEdit","placeholderShown","temporary"]);if(e.includes("id")&&this.loadTextInto("id",()=>({op:"getContentControlFileId",contentControl:this.#r()})),e.includes("tag")&&this.loadTextInto("tag",()=>({op:"getContentControlTag",contentControl:this.#r()})),e.includes("title")&&this.loadTextInto("title",()=>({op:"getContentControlTitle",contentControl:this.#r()})),e.includes("subtype")&&this.loadTextInto("subtype",()=>({op:"getContentControlSubtype",contentControl:this.#r()})),e.includes("isBound")){let r=`${this.path.label}.isBound`;this.read(r,()=>({op:"getContentControlIsBound",contentControl:this.#r()}),s=>{this.setLoadedProperty("isBound",rt(s,r));});}if(e.includes("text")&&this.loadTextInto("text",()=>({op:"getContentControlText",contentControl:this.#r(),projection:this.revisionTextView()})),e.includes("cannotDelete")||e.includes("cannotEdit")){let r=`${this.path.label}.lock`;this.read(r,()=>({op:"getContentControlLock",contentControl:this.#r()}),s=>{this.setLoadedProperty("lock",P(s,r));});}if(e.includes("placeholderShown")){let r=`${this.path.label}.placeholderShown`;this.read(r,()=>({op:"getContentControlPlaceholderShown",contentControl:this.#r()}),s=>{this.setLoadedProperty("placeholderShown",rt(s,r));});}if(!e.includes("temporary"))return;let n=`${this.path.label}.temporary`;this.read(n,()=>({op:"getContentControlTemporary",contentControl:this.#r()}),r=>{this.setLoadedProperty("temporary",rt(r,n));});}#a(t,e){let n=y.promised(this.context,t,false);return this.read(t,()=>({op:"getContentControlRange",contentControl:this.#r(),location:e}),r=>{n.hydrateAddress({kind:"span",span:O(r,t)});}),n}#s(t,e){this.command(t,()=>({op:"setContentControlProperties",contentControl:this.#r(),...e}));}#i(t,e){let n=`${this.path.label}.${t}`;if(typeof e!="boolean"&&i({code:"InvalidArgument",target:n}),this.requireUsablePath(),this.#t){this.#t[t]=e;return}let r={[t]:e};this.#t=r,this.command(t,()=>({op:"setContentControlProperties",contentControl:this.#r(),...r}),()=>{this.#t===r&&(this.#t=void 0);});}#r(){return this.requireAddressable(),this.path.handle()}},F=class o extends C{#t;#e;static of(t,e,n,r){return new o(t,c.derived(e,n),r,()=>({op:"getContentControls",scope:r}))}constructor(t,e,n,r){super(t,e),this.#t=n,this.#e=r;}getFirst(){return this.edge("first","getFirst",false)}getFirstOrNullObject(){return this.edge("first","getFirstOrNullObject",true)}getById(t){let e=`${this.path.label}.getById`;Number.isInteger(t)||i({code:"InvalidArgument",target:e});let n=this.#t,r=M.promised(this.context,e,false);return this.enqueue({sort:"read",label:e,plan:()=>({op:"getContentControlById",scope:n,id:t}),settle:s=>{r.hydrateAddress({kind:"handle",handle:u(s,e)});}}),r}getByTag(t){let e=`${this.path.label}.getByTag`,n=we(t,e),r=this.#t;return new o(this.context,c.derived(e,this.path),r,()=>({op:"getContentControlsByTag",scope:r,tag:n}))}getByTitle(t){let e=`${this.path.label}.getByTitle`,n=we(t,e),r=this.#t;return new o(this.context,c.derived(e,this.path),r,()=>({op:"getContentControlsByTitle",scope:r,title:n}))}listing(){return this.#e()}itemAt(t,e){return M.at(this.context,t,e)}promised(t,e){return M.promised(this.context,t,e)}};function pe(o,t){return (typeof o!="string"||o.length>je)&&i({code:"InvalidArgument",target:t}),o}function we(o,t){let e=pe(o,t);return e.length===0&&i({code:"InvalidArgument",target:t}),e}function ln(o,t){switch(o){case "Whole":return "whole";case "Content":return "content";case "Start":return "start";case "End":return "end";case "Before":return "before";case "After":return "after";default:return i({code:"InvalidArgument",target:t})}}function cn(o,t){(typeof o!="object"||o===null)&&i({code:"InvalidArgument",target:t});let e=o;if(e.kind==="text"||e.kind==="listItem"){let n=e.kind==="text"?e.text:e.value;return (typeof n!="string"||n.length>je)&&i({code:"InvalidArgument",target:t}),e.kind==="text"?{kind:"text",text:n}:{kind:"listItem",value:n}}if(e.kind==="checkbox")return typeof e.checked!="boolean"&&i({code:"InvalidArgument",target:t}),{kind:"checkbox",checked:e.checked};if(e.kind==="date")return (typeof e.iso!="string"||e.iso.length>64)&&i({code:"InvalidArgument",target:t}),{kind:"date",iso:e.iso};i({code:"InvalidArgument",target:t});}function hn(o,t){return t<1||t>12?0:t===2?o%4===0&&o%100!==0||o%400===0?29:28:t===4||t===6||t===9||t===11?30:31}function Te(o){if(o.length===0)return null;let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,9}))?(Z|[+-]\d{2}:\d{2})$/.exec(o.trim());if(!t)return null;let e=Number(t[1]),n=Number(t[2]),r=Number(t[3]),s=hn(e,n);if(e===0||s===0||r<1||r>s)return null;let a=Number(t[4]),d=Number(t[5]),h=Number(t[6]);if(a>23||d>59||h>59)return null;let g=t[7],H=g===void 0?0:Number(g.padEnd(3,"0").slice(0,3));if(Number.isNaN(H))return null;let k=`${t[1]}-${t[2]}-${t[3]}T${t[4]}:${t[5]}:${t[6]}.${String(H).padStart(3,"0")}Z`,Tt=Date.parse(k);if(Number.isNaN(Tt))return null;let f=t[8];if(f==="Z")return new Date(Tt);let et=Number(f.slice(1,3)),dt=Number(f.slice(4,6));if(dt>59||et>14||et===14&&dt!==0)return null;let Qt=f[0]==="+"?1:-1,Et=new Date(Tt-Qt*(et*36e5+dt*6e4));return Number.isNaN(Et.getTime())?null:Et}var Gt=class extends p{hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get authorName(){return this.loadedProperty("authorName")}get creationDate(){return this.loadedProperty("creationDate")}get id(){return this.loadedProperty("id")}get text(){return this.loadedProperty("text")}delete(){this.command("delete",()=>({op:"deleteComment",comment:this.commentHandle()}));}loadCommentFields(t,e){let n=this.selection(t,["authorName","creationDate","id","text",...e]);if(n.includes("authorName")&&this.loadTextInto("authorName",()=>({op:"getCommentAuthor",comment:this.commentHandle()})),n.includes("text")&&this.loadTextInto("text",()=>({op:"getCommentText",comment:this.commentHandle()})),n.includes("id")&&this.loadTextInto("id",()=>({op:"getCommentId",comment:this.commentHandle()})),n.includes("creationDate")){let s=`${this.path.label}.creationDate`;this.read(s,()=>({op:"getCommentDate",comment:this.commentHandle()}),a=>{this.setLoadedProperty("creationDate",Te(P(a,s)));});}if(!n.includes("resolved"))return;let r=`${this.path.label}.resolved`;this.read(r,()=>({op:"getCommentResolved",comment:this.commentHandle()}),s=>{this.setLoadedProperty("resolved",rt(s,r));});}commentHandle(){return this.requireAddressable(),this.path.handle()}},at=class o extends Gt{static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}onLoad(t){this.loadCommentFields(t,[]);}},wt=class o extends C{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return at.at(this.context,t,e)}promised(t,e){return at.promised(this.context,t,e)}},Y=class o extends Gt{#t;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}get resolved(){return this.loadedProperty("resolved")}set resolved(t){let e=`${this.path.label}.resolved`;typeof t!="boolean"&&i({code:"InvalidArgument",target:e}),this.commandAnswering(e,()=>({op:"setCommentResolved",comment:this.commentHandle(),resolved:t}),n=>{m(n,e);});}get replies(){return this.#t??=wt.of(this.context,`${this.path.label}.replies`,this.path,()=>({op:"getCommentReplies",comment:this.commentHandle()})),this.#t}getRange(){let t=`${this.path.label}.getRange`,e=y.promised(this.context,t,false);return this.read(t,()=>({op:"getCommentRange",comment:this.commentHandle()}),n=>{e.hydrateAddress({kind:"span",span:O(n,t)});}),e}reply(t){let e=`${this.path.label}.reply`;(typeof t!="string"||t.length===0)&&i({code:"InvalidArgument",target:e});let n=this.internals.author;(typeof n!="string"||n.trim().length===0)&&i({code:"NotSupported",target:e});let r=at.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"replyToComment",comment:this.commentHandle(),text:t,author:n}),s=>{r.hydrateAddress({kind:"handle",handle:u(s,e)});}),r}onLoad(t){this.loadCommentFields(t,["resolved"]);}},J=class o extends C{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return Y.at(this.context,t,e)}promised(t,e){return Y.promised(this.context,t,e)}},V=class o extends p{static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get author(){return this.loadedProperty("author")}get date(){return this.loadedProperty("date")}get type(){return this.loadedProperty("type")}get range(){let t=`${this.path.label}.range`,e=y.promised(this.context,t,false);return this.read(t,()=>({op:"getRevisionRange",revision:this.#t()}),n=>{e.hydrateAddress({kind:"span",span:O(n,t)});}),e}accept(){this.command("accept",()=>({op:"acceptRevision",revision:this.#t()}));}reject(){this.command("reject",()=>({op:"rejectRevision",revision:this.#t()}));}onLoad(t){let e=this.selection(t,["author","date","type"]);if(e.includes("author")&&this.loadTextInto("author",()=>({op:"getRevisionAuthor",revision:this.#t()})),e.includes("type")&&this.loadTextInto("type",()=>({op:"getRevisionType",revision:this.#t()})),!e.includes("date"))return;let n=`${this.path.label}.date`;this.read(n,()=>({op:"getRevisionDate",revision:this.#t()}),r=>{this.setLoadedProperty("date",Te(P(r,n)));});}static batchHandle(t,e,n="RevisionCollection.resolve"){return (!(t instanceof o)||t.context!==e)&&i({code:"InvalidArgument",target:n}),t.#t()}#t(){return this.requireAddressable(),this.path.handle()}},_=class o extends C{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}acceptAll(){let t=this.#t;this.commandOn("acceptAll",()=>({op:"acceptAllRevisions",body:t}));}rejectAll(){let t=this.#t;this.commandOn("rejectAll",()=>({op:"rejectAllRevisions",body:t}));}resolve(t,e){let n=`${this.path.label}.resolve`;(!["accept","reject"].includes(t)||e!==void 0&&!Array.isArray(e))&&i({code:"InvalidArgument",target:n});let r=e===void 0?void 0:[...e],{result:s,fill:a}=Xt(n);return this.enqueue({sort:"write",label:n,plan:()=>({op:"resolveRevisionBatch",body:this.#t,action:t,...r===void 0?{}:{revisions:r.map(d=>V.batchHandle(d,this.context))}}),settle:d=>{d.kind!=="revisionBatch"&&i({code:"GeneralException",target:n}),a(d.result);}}),s}setAuthor(t,e,n){let r=`${this.path.label}.setAuthor`,s=n?.date,a=Array.isArray(e)?e:void 0,d=e!==void 0&&!Array.isArray(e)?e?.authors:void 0;(typeof t!="string"||t.trim().length===0||e!==void 0&&!Array.isArray(e)&&(typeof e!="object"||e===null||!Array.isArray(d)||d.some(k=>typeof k!="string"))||n!==void 0&&(typeof n!="object"||n===null)||s!==void 0&&(!(s instanceof Date)||Number.isNaN(s.getTime()))||a?.some(k=>!(k instanceof V)||k.context!==this.context))&&i({code:"InvalidArgument",target:r});let h=a===void 0?void 0:[...a],{result:g,fill:H}=Xt(r);return this.enqueue({sort:"write",label:r,plan:()=>({op:"setRevisionAuthorBatch",body:this.#t,author:t,...s===void 0?{}:{date:s.toISOString()},...d===void 0?{}:{authors:[...d]},...h===void 0?{}:{revisions:h.map(k=>V.batchHandle(k,this.context,r))}}),settle:k=>{k.kind!=="revisionAuthors"&&i({code:"GeneralException",target:r}),H(k.result);}}),g}listing(){return {op:"getRevisions",body:this.#t}}itemAt(t,e){return V.at(this.context,t,e)}promised(t,e){return V.promised(this.context,t,e)}commandOn(t,e){let n=`${this.path.label}.${t}`;this.enqueue({sort:"write",label:n,plan:e,settle:r=>{m(r,n);}});}};var pn=new Set(["matchCase","matchWholeWord","ignorePunct","ignoreSpace","matchWildcards"]);function zt(o,t){if(o===void 0)return;typeof o!="object"&&i({code:"InvalidArgument",target:t});for(let[n,r]of Object.entries(o))pn.has(n)||i({code:"InvalidArgument",target:`${t}.${n}`}),r!==void 0&&typeof r!="boolean"&&i({code:"InvalidArgument",target:`${t}.${n}`});let e={...o.matchCase===void 0?{}:{matchCase:o.matchCase},...o.matchWholeWord===void 0?{}:{matchWholeWord:o.matchWholeWord},...o.ignorePunct===void 0?{}:{ignorePunct:o.ignorePunct},...o.ignoreSpace===void 0?{}:{ignoreSpace:o.ignoreSpace},...o.matchWildcards===void 0?{}:{matchWildcards:o.matchWildcards}};return Object.keys(e).length===0?void 0:e}var y=class o extends p{#t;#e;#n;#o;#a;#s;static at(t,e,n){return n.kind!=="span"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.ofSpan(e,n.span),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="span"?this.path.resolveToSpan(t.span):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get text(){return this.loadedProperty("text")}get font(){return this.#a??=$.of(this.context,`${this.path.label}.font`,this.path,"span"),this.#a}get paragraphs(){return this.#o??=w.of(this.context,`${this.path.label}.paragraphs`,this.path),this.#o}get style(){return this.loadedProperty("style")}set style(t){let e=`${this.path.label}.style`,n=ct(t,e);this.requireAddressable(),this.command("style",()=>({op:"setStyle",span:I(this.path,"span"),name:n}));}get hyperlink(){return this.loadedProperty("hyperlink")}set hyperlink(t){let e=`${this.path.label}.hyperlink`;(typeof t!="string"||t.length>2048)&&i({code:"InvalidArgument",target:e}),this.requireUsablePath(),this.command("hyperlink",()=>({op:"setHyperlink",span:this.#i(),target:t}));}get bookmarks(){let t=this.#i();return this.#s??=tt.of(this.context,`${this.path.label}.bookmarks`,this.path,()=>({op:"getBookmarks",scope:{start:t.start,end:t.end}})),this.#s}search(t,e){let n=`${this.path.label}.search`;typeof t!="string"&&i({code:"InvalidArgument",target:n});let r=zt(e,n),s=this.#i();return B.of(this.context,n,this.path,()=>({op:"search",scope:s,text:t,options:{...r??{},projection:this.revisionTextView()}}))}insertText(t,e){let n=`${this.path.label}.insertText`,r=L(t,n),s=St(e,n);this.requireUsablePath();let a=o.promised(this.context,n,false);return this.commandAnswering(n,()=>{let d=this.#i();return s==="Replace"?{op:"replaceSpan",span:d,text:r}:{op:"insertText",at:s==="Start"||s==="Before"?d.start:d.end,text:r}},d=>{a.hydrateAddress({kind:"span",span:O(d,n)});}),a}delete(){this.requireUsablePath(),this.commandDiscarding("delete",()=>({op:"replaceSpan",span:this.#i(),text:""}));}clear(){let t=this.#i();this.commandDiscarding("clear",()=>({op:"replaceSpan",span:t,text:""}));}insertComment(t){let e=`${this.path.label}.insertComment`;(typeof t!="string"||t.length===0)&&i({code:"InvalidArgument",target:e});let n=this.internals.author;(typeof n!="string"||n.trim().length===0)&&i({code:"NotSupported",target:e});let r=Y.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"insertComment",span:this.#i(),text:t,author:n}),s=>{s.kind!=="handle"&&i({code:"GeneralException",target:e}),r.hydrateAddress(s);}),r}insertContentControl(t){let e=`${this.path.label}.insertContentControl`,n=t??"RichText";n!=="RichText"&&n!=="PlainText"&&n!=="DatePicker"&&i({code:"NotSupported",target:e});let r=M.promised(this.context,e,false);return this.commandAnswering(e,()=>({op:"insertContentControl",span:this.#i(),subtype:n==="DatePicker"?"date":n==="PlainText"?"plainText":"richText",returnHandle:true}),s=>{s.kind!=="handle"&&i({code:"GeneralException",target:e}),r.hydrateAddress(s);}),r}get tables(){return this.requireUsablePath(),this.#t??=Z.over(this.context,`${this.path.label}.tables`,this.path,()=>I(this.path,"span"))}get fields(){return this.requireUsablePath(),this.#e??=z.of(this.context,`${this.path.label}.fields`,this.path,"span")}insertField(t,e,n,r){let s=`${this.path.label}.insertField`;(e!==void 0&&typeof e!="string"||n!==void 0&&typeof n!="string"||r!==void 0&&typeof r!="boolean")&&i({code:"InvalidArgument",target:s});let a=St(t,s);this.requireUsablePath();let d=G.promised(this.context,s,false);return this.commandAnswering(s,()=>({op:"insertField",span:this.#i(),location:a,...e===void 0?{}:{fieldType:e},...n===void 0?{}:{text:n},...r===void 0?{}:{removeFormatting:r}}),h=>d.hydrateAddress({kind:"handle",handle:u(h,s)})),d}get inlinePictures(){return this.requireUsablePath(),this.#n??=X.of(this.context,`${this.path.label}.inlinePictures`,this.path,"span")}insertInlinePictureFromBase64(t,e){let n=`${this.path.label}.insertInlinePictureFromBase64`;(typeof t!="string"||t.length===0)&&i({code:"InvalidArgument",target:n});let r=St(e,n);this.requireUsablePath();let s=Q.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertInlinePicture",span:this.#i(),base64:t,location:r}),a=>{s.hydrateAddress({kind:"handle",handle:u(a,n)});}),s}insertBreak(t,e){let n=`${this.path.label}.insertBreak`;e!=="Before"&&e!=="After"&&i({code:"InvalidArgument",target:n});let r=e;this.requireUsablePath(),this.commandAnswering(n,()=>({op:"insertBreak",span:this.#i(),breakType:t,location:r}),s=>m(s,n));}insertTable(t,e,n,r){let s=`${this.path.label}.insertTable`;(!Number.isInteger(t)||!Number.isInteger(e)||t<1||e<1||!["Before","After"].includes(n))&&i({code:"InvalidArgument",target:s}),r!==void 0&&(!Array.isArray(r)||r.some(h=>!Array.isArray(h)||h.some(g=>typeof g!="string")))&&i({code:"InvalidArgument",target:s});let a=r?.map(h=>[...h]),d=K.promised(this.context,s);return this.commandAnswering(s,()=>({op:"insertTable",span:I(this.path,"span"),location:n,rowCount:t,columnCount:e,...a?{values:a}:{}}),h=>{h.kind!=="handle"&&i({code:"GeneralException",target:s}),d.hydrateAddress({kind:"handle",handle:h.handle});}),d}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=L(t,n),s=St(e,n);s!=="Before"&&s!=="After"&&i({code:"InvalidArgument",target:n});let a=this.#i(),d=s==="Before"?a.start.paragraph:a.end.paragraph,h=j.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertParagraph",anchor:{paragraph:d},where:s==="Before"?"before":"after",text:r}),g=>{g.kind!=="handle"&&i({code:"GeneralException",target:n}),h.hydrateAddress({kind:"handle",handle:g.handle});}),h}select(t){let e=`${this.path.label}.select`,n=Wt(t,e);this.requireAddressable(),this.internals.capabilities.selection||i({code:"NotSupported",target:e});let r=this.#i();this.command("select",()=>({op:"selectSpan",span:r,mode:n==="Select"?"select":n==="Start"?"start":"end"}));}onLoad(t){let e=this.selection(t,["text","style","hyperlink"]);if(e.includes("hyperlink")&&this.loadTextInto("hyperlink",()=>({op:"getHyperlink",span:this.#i()})),e.includes("text")){let r=`${this.path.label}.text`;this.read(r,()=>({op:"getSpanText",span:this.#i(),projection:this.revisionTextView()}),s=>{this.setLoadedProperty("text",P(s,r));});}if(!e.includes("style"))return;let n=`${this.path.label}.style`;this.requireUsablePath(),this.read(n,()=>({op:"getStyle",span:I(this.path,"span")}),r=>{this.setLoadedProperty("style",Rt(r,n));});}#i(){return this.requireAddressable(),this.path.span()}};var yt=class o extends p{#t;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get name(){return this.loadedProperty("name")}get range(){return this.#t??=this.#e(`${this.path.label}.range`),this.#t}select(t){let e=`${this.path.label}.select`,n=Wt(t,e);this.requireUsablePath(),this.internals.capabilities.selection||i({code:"NotSupported",target:e}),this.command("select",()=>({op:"selectBookmark",bookmark:this.#n(),mode:n==="Select"?"select":n==="Start"?"start":"end"}));}onLoad(t){if(!this.selection(t,["name"]).includes("name"))return;let e=`${this.path.label}.name`;this.read(e,()=>({op:"getBookmarkName",bookmark:this.#n()}),n=>{this.setLoadedProperty("name",P(n,e));});}#e(t){let e=y.promised(this.context,t,false);return this.read(t,()=>({op:"getBookmarkRange",bookmark:this.#n()}),n=>{e.hydrateAddress({kind:"span",span:O(n,t)});}),e}#n(){return this.requireAddressable(),this.path.handle()}},tt=class o extends C{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}listing(){return this.#t()}itemAt(t,e){return yt.at(this.context,t,e)}promised(t,e){return yt.promised(this.context,t,e)}};var S=class o extends p{#t;#e;get footnotes(){return this.#t??=q.of(this.context,`${this.path.label}.footnotes`,this.path,()=>({op:"getNotes",document:this.internals.roots().document,scope:this.#l(),noteKind:"footnote"}))}get endnotes(){return this.#e??=q.of(this.context,`${this.path.label}.endnotes`,this.path,()=>({op:"getNotes",document:this.internals.roots().document,scope:this.#l(),noteKind:"endnote"}))}#n;#o;#a;#s;#i;#r;#d;#c;#h;#p;static main(t,e){return new o(t,c.of(e,ot(t).roots().body))}static promisedStory(t,e){return new o(t,c.pending(e))}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}constructor(t,e){super(t,e);}get text(){return this.loadedProperty("text")}get paragraphs(){return this.#i??=this.paragraphsUnder(`${this.path.label}.paragraphs`),this.#i}get bookmarks(){let t=this.#l();return this.#r??=tt.of(this.context,`${this.path.label}.bookmarks`,this.path,()=>({op:"getBookmarks",scope:{body:t}})),this.#r}get font(){return this.#d??=$.of(this.context,`${this.path.label}.font`,this.path,"body"),this.#d}paragraphsUnder(t){return w.of(this.context,t,this.path)}get style(){return this.loadedProperty("style")}set style(t){let e=`${this.path.label}.style`,n=ct(t,e);this.requireAddressable(),this.command("style",()=>({op:"setStyle",span:I(this.path,"body"),name:n}));}get lists(){return this.#c??=gt.of(this.context,`${this.path.label}.lists`,this.path,this.#l()),this.#c}get contentControls(){return this.#h??=F.of(this.context,`${this.path.label}.contentControls`,this.path,{body:this.#l()}),this.#h}getComments(){let t=`${this.path.label}.getComments`,e=this.#l();return J.of(this.context,t,this.path,()=>({op:"getComments",scope:{body:e}}))}get revisions(){return this.#p??=_.of(this.context,`${this.path.label}.revisions`,this.path,this.#l()),this.#p}getRange(t="Whole"){let e=`${this.path.label}.getRange`;this.requireUsablePath();let n=y.promised(this.context,e,false);return this.read(e,()=>({op:"getRange",span:{body:this.path.handle()},location:t}),r=>{n.hydrateAddress({kind:"span",span:O(r,e)});}),n}search(t,e){let n=`${this.path.label}.search`;typeof t!="string"&&i({code:"InvalidArgument",target:n});let r=zt(e,n),s=this.#l();return B.of(this.context,n,this.path,()=>({op:"search",scope:{body:s},text:t,options:{...r??{},projection:this.revisionTextView()}}))}clear(){let t=this.#l();this.commandDiscarding("clear",()=>({op:"replaceSpan",span:{body:t},text:""}));}insertText(t,e){let n=`${this.path.label}.insertText`,r=L(t,n),s=Pe(e,n);this.requireUsablePath();let a=y.promised(this.context,n,false);return this.commandAnswering(n,()=>s==="Replace"?{op:"replaceSpan",span:{body:this.#l()},text:r}:{op:"insertText",at:{body:this.#l(),at:s==="Start"?"start":"end"},text:r},d=>{a.hydrateAddress({kind:"span",span:O(d,n)});}),a}insertParagraph(t,e){let n=`${this.path.label}.insertParagraph`,r=L(t,n),s=Oe(e,n),a=this.#l(),d=j.promised(this.context,n,false);return this.commandAnswering(n,()=>({op:"insertParagraph",anchor:{body:a,at:s==="Start"?"first":"last"},where:s==="Start"?"before":"after",text:r}),h=>{h.kind!=="handle"&&i({code:"GeneralException",target:n}),d.hydrateAddress({kind:"handle",handle:h.handle});}),d}onLoad(t){let e=this.selection(t,["text","style"]);e.includes("text")&&this.loadTextInto("text",()=>({op:"getText",target:this.#l(),projection:this.revisionTextView()})),e.includes("style")&&this.#u();}#u(){let t=`${this.path.label}.style`;this.requireUsablePath(),this.read(t,()=>({op:"getStyle",span:I(this.path,"body")}),e=>{this.setLoadedProperty("style",Rt(e,t));});}get fields(){return this.requireUsablePath(),this.#o??=z.of(this.context,`${this.path.label}.fields`,this.path,"body")}get inlinePictures(){return this.requireUsablePath(),this.#a??=X.of(this.context,`${this.path.label}.inlinePictures`,this.path,"body")}get shapes(){return this.requireUsablePath(),this.#s??=U.of(this.context,`${this.path.label}.shapes`,this.path,"body")}get tables(){return this.requireUsablePath(),this.#n??=Z.over(this.context,`${this.path.label}.tables`,this.path,()=>({body:this.#l()}))}#l(){return this.requireAddressable(),this.path.handle()}};var un=Object.freeze({Primary:"default",FirstPage:"first",EvenPages:"even"}),mn=["pageWidth","pageHeight","orientation","topMargin","rightMargin","bottomMargin","leftMargin"],jt=class o extends p{#t;static of(t,e,n){return new o(t,c.derived(e,n))}constructor(t,e){super(t,e);}get pageWidth(){return this.loadedProperty("pageWidth")}set pageWidth(t){this.#e("pageWidth",xt(t,`${this.path.label}.pageWidth`));}get pageHeight(){return this.loadedProperty("pageHeight")}set pageHeight(t){this.#e("pageHeight",xt(t,`${this.path.label}.pageHeight`));}get orientation(){return this.loadedProperty("orientation")}set orientation(t){let e=`${this.path.label}.orientation`;t!=="Portrait"&&t!=="Landscape"&&i({code:"InvalidArgument",target:e}),this.#e("orientation",t==="Portrait"?"portrait":"landscape");}get topMargin(){return this.loadedProperty("topMargin")}set topMargin(t){this.#e("topMargin",xt(t,`${this.path.label}.topMargin`));}get bottomMargin(){return this.loadedProperty("bottomMargin")}set bottomMargin(t){this.#e("bottomMargin",xt(t,`${this.path.label}.bottomMargin`));}get leftMargin(){return this.loadedProperty("leftMargin")}set leftMargin(t){this.#e("leftMargin",xt(t,`${this.path.label}.leftMargin`));}get rightMargin(){return this.loadedProperty("rightMargin")}set rightMargin(t){this.#e("rightMargin",xt(t,`${this.path.label}.rightMargin`));}onLoad(t){let e=this.selection(t,mn);if(e.length===0)return;let n=`${this.path.label}.pageSetup`;this.read(n,()=>({op:"getPageSetup",section:this.#n()}),r=>{let s=Yt(r,n);for(let a of e)this.setLoadedProperty(a,a==="orientation"?s.orientation==="landscape"?"Landscape":"Portrait":s[a]);});}#e(t,e){if(this.requireUsablePath(),this.#t){this.#t[t]=e;return}let n={[t]:e};this.#t=n;let r=`${this.path.label}.${t}`;this.commandAnswering(`${this.path.label}.pageSetup`,()=>({op:"setPageSetup",section:this.#n(),setup:n}),s=>{m(s,r);},()=>{this.#t===n&&(this.#t=void 0);});}#n(){this.requireAddressable();let t=this.path.address();return t.kind!=="handle"&&i({code:"InvalidObjectPath",target:this.path.label}),t.handle}},At=class o extends p{#t;#e;static at(t,e,n){return n.kind!=="handle"&&i({code:"InvalidObjectPath",target:e}),new o(t,c.of(e,n.handle),false)}static promised(t,e,n){return new o(t,c.pending(e),n)}constructor(t,e,n){super(t,e,{nullable:n});}hydrateAddress(t){t.kind==="handle"?this.path.resolveTo(t.handle):this.path.resolveNull();}hydrateNull(){this.path.resolveNull();}get body(){return this.#e??=S.main(this.context,`${this.path.label}.body`),this.#e}get pageSetup(){return this.#t??=jt.of(this.context,`${this.path.label}.pageSetup`,this.path),this.#t}getHeader(t){return this.#n("header",t,"getHeader")}getFooter(t){return this.#n("footer",t,"getFooter")}getNext(){let t=`${this.path.label}.getNext`,e=o.promised(this.context,t,false),n=this.internals.roots().document;return this.read(t,()=>({op:"getSections",document:n}),r=>{let s=v(r,t),a=s.findIndex(h=>h.ref===this.#o().ref),d=a<0?void 0:s[a+1];d||i({code:"ItemNotFound",target:t}),e.hydrateAddress({kind:"handle",handle:d});}),e}onLoad(t){this.selection(t,[]);}#n(t,e,n){let r=`${this.path.label}.${n}`,s=un[e];s===void 0&&i({code:"InvalidArgument",target:r});let a=S.promisedStory(this.context,r);return this.read(r,()=>({op:"getFurniture",section:this.#o(),kind:t,variant:s}),d=>{a.hydrateAddress({kind:"handle",handle:u(d,r)});}),a}#o(){return this.requireAddressable(),this.path.handle()}},vt=class o extends C{#t;static of(t,e,n,r){return new o(t,c.derived(e,n),r)}constructor(t,e,n){super(t,e),this.#t=n;}getFirst(){return this.edge("first","getFirst",false)}listing(){return this.#t()}itemAt(t,e){return At.at(this.context,t,e)}promised(t,e){return At.promised(this.context,t,e)}};function xt(o,t){return (typeof o!="number"||!Number.isFinite(o)||o<0)&&i({code:"InvalidArgument",target:t}),o}var Ct=class o extends p{#t;#e;#n;#o;#a;#s;#i;#r;#d;static open(t){return new o(t)}constructor(t){super(t,c.of("document",ot(t).roots().document));}get changeTrackingMode(){return this.loadedProperty("changeTrackingMode")}set changeTrackingMode(t){["Off","TrackAll","TrackMineOnly"].includes(t)||i({code:"InvalidArgument",target:"document.changeTrackingMode"});let e=this.internals.author;this.commandAnswering("document.changeTrackingMode",()=>({op:"setChangeTrackingMode",mode:t,...e===void 0?{}:{author:e}}),()=>this.setLoadedProperty("changeTrackingMode",t));}get body(){return this.#e??=S.main(this.context,"document.body"),this.#e}removeDocumentInformation(t){this.command(`${this.path.label}.removeDocumentInformation`,()=>({op:"removeDocumentInformation",removeDocInfoType:t}));}get properties(){return this.#t??=lt.of(this.context,this.path),this.#t}get paragraphs(){return this.#n??=this.body.paragraphsUnder("document.paragraphs"),this.#n}get sections(){let t=this.path.handle();return this.#o??=vt.of(this.context,"document.sections",this.path,()=>({op:"getSections",document:t})),this.#o}get contentControls(){return this.#i??=F.of(this.context,"document.contentControls",this.path,{body:this.internals.roots().body}),this.#i}get comments(){return this.#a??=J.of(this.context,"document.comments",this.path,()=>({op:"getComments",scope:{body:this.internals.roots().body}})),this.#a}get revisions(){return this.#s??=_.of(this.context,"document.revisions",this.path,this.internals.roots().body),this.#s}get footnotes(){let t=this.path.handle();return this.#r??=q.of(this.context,"document.footnotes",this.path,()=>({op:"getNotes",document:t,noteKind:"footnote"})),this.#r}get endnotes(){let t=this.path.handle();return this.#d??=q.of(this.context,"document.endnotes",this.path,()=>({op:"getNotes",document:t,noteKind:"endnote"})),this.#d}onLoad(t){if(t.select.length===0)return;this.selection(t,["changeTrackingMode"]).includes("changeTrackingMode")&&this.loadTextInto("changeTrackingMode",()=>({op:"getChangeTrackingMode"}));}};function Ne(o){let t=o.host,e=Object.freeze({...t.capabilities,save:o.save&&t.capabilities.save}),n=typeof o.author=="string"&&o.author.trim().length>0?o.author:void 0,r=o.revisionTextView??"allMarkup";r!=="allMarkup"&&r!=="original"&&i({code:"InvalidArgument",target:"revisionTextView"});let s=false,a=null,d=f=>{s&&i({code:"RuntimeDisposed",...f===void 0?{}:{target:f}});},h=()=>{if(a)return a;d("document");let f=Ee(t.execute({operations:[{op:"getDocument"}]}),"document"),et=Ee(t.execute({operations:[{op:"getBody",document:f}]}),"document.body");return a={document:f,body:et},a},g={host:t,capabilities:e,...n===void 0?{}:{author:n},revisionTextView:r,id:{},roots:h,assertLive:d,openDocument:f=>Ct.open(f)};try{h();}catch{a=null;}async function H(f,et){d();let dt=typeof f=="function"?f:et,Qt=typeof f=="function"?[]:Array.isArray(f)?f:[f];typeof dt!="function"&&i({code:"InvalidArgument",target:"run"});let{context:Et,adopt:x,finish:De}=Ot.begin(g);try{return x(Qt),await dt(Et)}finally{De();}}let k={capabilities:e,run:H,dispose(){s||(s=true,a=null,t.dispose());}};return o.save?{...k,async save(){d("save"),e.save||i({code:"NotSupported",target:"save"});let f=t.save();if(!f.ok)throw Ht(f.error,{target:"save"});return f.bytes}}:k}function Ee(o,t){let e=o.results[0];if(e?.status==="error")throw Ht(e.error,{target:t});if(e?.status!=="ok")throw new R({code:"GeneralException",target:t});return u(e.value,t)}function fn(o){if(o){for(let t of o)if(t.collaboration)return t.collaboration}}function bn(o){let t=[o?.zip?.maxEntries,o?.zip?.maxTotalBytes,o?.xml?.maxBytes,o?.xml?.maxElements,o?.maxXmlParts,o?.maxRelationships],e=o?.zip?.maxRatio;(t.some(n=>n!==void 0&&(!Number.isInteger(n)||n<0))||e!==void 0&&(!Number.isFinite(e)||e<0))&&i({code:"InvalidArgument",target:"createServer"});}async function ue(o,t={}){bn(t.limits);let e=fn(t.modules),n=createServerAutomationHost(o,{...t.pagination?{pagination:ge(t.pagination)}:{},...t.limits===void 0?{}:{limits:t.limits},...e===void 0?{}:{collaborationModel:e}});if(!n.ok){let r={"too-many-entries":"zip.maxEntries","too-large":"xml.maxBytes","too-many-elements":"xml.maxElements","too-deep":"xml.maxDepth","too-many-xml-parts":"maxXmlParts","too-many-relationships":"maxRelationships"},s=n.limit??r[n.reason];i({code:s===void 0?"InvalidArgument":"ResourceLimitExceeded",target:"createServer",...s===void 0?{}:{limit:s}});}return Ne({host:n.host,save:true,...t.author===void 0?{}:{author:t.author},...t.revisionTextView===void 0?{}:{revisionTextView:t.revisionTextView}})}function qe(o,t,e={}){return ue(o,{...e,modules:[...e.modules??[],{id:"collaboration",collaboration:{session:t}}]})}var me=(l=>(l.addin="Addin",l.addressBlock="AddressBlock",l.advance="Advance",l.ask="Ask",l.author="Author",l.autoText="AutoText",l.autoTextList="AutoTextList",l.barCode="BarCode",l.bibliography="Bibliography",l.bidiOutline="BidiOutline",l.citation="Citation",l.comments="Comments",l.compare="Compare",l.createDate="CreateDate",l.data="Data",l.database="Database",l.date="Date",l.displayBarcode="DisplayBarcode",l.docProperty="DocProperty",l.docVariable="DocVariable",l.editTime="EditTime",l.embedded="Embedded",l.empty="Empty",l.eq="EQ",l.expression="Expression",l.fileName="FileName",l.fileSize="FileSize",l.fillIn="FillIn",l.formCheckbox="FormCheckbox",l.formDropdown="FormDropdown",l.formText="FormText",l.gotoButton="GotoButton",l.greetingLine="GreetingLine",l.hyperlink="Hyperlink",l.if="If",l.import="Import",l.include="Include",l.includePicture="IncludePicture",l.includeText="IncludeText",l.index="Index",l.info="Info",l.keywords="Keywords",l.lastSavedBy="LastSavedBy",l.link="Link",l.listNum="ListNum",l.macroButton="MacroButton",l.mergeBarcode="MergeBarcode",l.mergeField="MergeField",l.mergeRec="MergeRec",l.mergeSeq="MergeSeq",l.next="Next",l.nextIf="NextIf",l.noteRef="NoteRef",l.numChars="NumChars",l.numPages="NumPages",l.numWords="NumWords",l.ocx="OCX",l.others="Others",l.page="Page",l.pageRef="PageRef",l.print="Print",l.printDate="PrintDate",l.private="Private",l.quote="Quote",l.rd="RD",l.ref="Ref",l.revNum="RevNum",l.saveDate="SaveDate",l.section="Section",l.sectionPages="SectionPages",l.seq="Seq",l.set="Set",l.shape="Shape",l.skipIf="SkipIf",l.styleRef="StyleRef",l.subject="Subject",l.subscriber="Subscriber",l.symbol="Symbol",l.ta="TA",l.tc="TC",l.template="Template",l.time="Time",l.title="Title",l.toa="TOA",l.toc="TOC",l.undefined="Undefined",l.userAddress="UserAddress",l.userInitials="UserInitials",l.userName="UserName",l.xe="XE",l))(me||{});var us=Object.freeze({createServer:ue,createCollaborative:qe});export{ee as Alignment,S as Body,yt as Bookmark,tt as BookmarkCollection,ie as BreakType,oe as ChangeTrackingMode,W as ClientObject,Dt as ClientResult,Y as Comment,J as CommentCollection,at as CommentReply,wt as CommentReplyCollection,M as ContentControl,F as ContentControlCollection,se as ContentControlType,Ct as Document,lt as DocumentProperties,us as DocxEditor,R as DocxEditorError,G as Field,z as FieldCollection,me as FieldType,$ as Font,Q as InlinePicture,X as InlinePictureCollection,te as InsertLocation,N as List,le as ListBullet,gt as ListCollection,ft as ListItem,ce as ListNumbering,pt as NoteItem,q as NoteItemCollection,ne as PageOrientation,jt as PageSetup,j as Paragraph,w as ParagraphCollection,y as Range,B as RangeCollection,ae as RemoveDocInfoType,Ot as RequestContext,V as Revision,_ as RevisionCollection,At as Section,vt as SectionCollection,ht as Shape,U as ShapeCollection,Ft as ShapeType,K as Table,it as TableCell,It as TableCellCollection,Z as TableCollection,ut as TableRow,st as TableRowCollection,Pt as TrackedObjects,he as UnderlineType,re as VerticalAlignment,Be as isDocxEditorError};