@harbour-enterprises/superdoc 0.8.27 → 0.8.29

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/superdoc.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ce=require("./chunks/super-editor.es-3mCiAAji.cjs"),o=require("./chunks/vue-Ckf0DkDN.cjs"),rn=require("./chunks/jszip-O1Upj8hc.cjs"),Gi=require("./chunks/blank-docx-BHgKMWrQ.cjs"),qi=require("./chunks/eventemitter3-DS1WPZxT.cjs"),Xi=require("@hocuspocus/provider"),Zo=require("yjs"),Yi=require("./chunks/uuid-DQp44bVU.cjs"),Wa=require("pdfjs-dist/legacy/build/pdf.mjs"),Ka=require("pdfjs-dist/web/pdf_viewer");function Ji(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const kr=Ji(Wa),_r=Ji(Ka),gt="application/vnd.openxmlformats-officedocument.wordprocessingml.document",gn="application/pdf",oo="text/html",$r={docx:gt,pdf:gn,html:oo},tn=Object.freeze({RESOLVED:"resolved",NEW:"new",ADD:"add",UPDATE:"update",DELETED:"deleted",PENDING:"pending",SELECTED:"selected",COMMENTS_LIST:"comments-list",CHANGE_ACCEPTED:"change-accepted",CHANGE_REJECTED:"change-rejected"}),Po=async(e,t,n)=>{const i=await(await fetch(e)).blob();return new File([i],t,{type:n})};function Ga(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,r.length);i++){const s=n[i]||0,a=r[i]||0;if(s>a)return 1;if(s<a)return-1}return 0}const Zi={mounted(e,t,n){const r=i=>{e.contains(i.target)||t.value(i)};document.addEventListener("click",r),e.__clickOutsideHandler=r},unmounted(e){document.removeEventListener("click",e.__clickOutsideHandler),delete e.__clickOutsideHandler}};function qa(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const Xa=new Int32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);function Qi(e){if(rn.Buffer.isBuffer(e))return e;if(typeof e=="number")return rn.Buffer.alloc(e);if(typeof e=="string")return rn.Buffer.from(e);throw new Error("input must be buffer, number, or string, received "+typeof e)}function Ya(e){const t=Qi(4);return t.writeInt32BE(e,0),t}function Qo(e,t){e=Qi(e),rn.Buffer.isBuffer(t)&&(t=t.readUInt32BE(0));let n=~~t^-1;for(var r=0;r<e.length;r++)n=Xa[(n^e[r])&255]^n>>>8;return n^-1}function er(){return Ya(Qo.apply(null,arguments))}er.signed=function(){return Qo.apply(null,arguments)};er.unsigned=function(){return Qo.apply(null,arguments)>>>0};var Ja=er;const Za=qa(Ja);function Qa(e){const t=new Uint8Array(e);for(let n=0;n<e;n++)t[n]=Math.floor(Math.random()*256);return t}class jn{enabled;superdocId;superdocVersion;licenseKey;endpoint;sessionId;statistics={nodeTypes:{},markTypes:{},attributes:{},errorCount:0};unknownElements=[];errors=[];fileStructure={totalFiles:0,maxDepth:0,totalNodes:0,files:[]};documentInfo=null;static COMMUNITY_LICENSE_KEY="community-and-eval-agplv3";static DEFAULT_ENDPOINT="https://ingest.superdoc.dev/v1/collect";constructor(t={}){this.enabled=t.enabled??!0,this.licenseKey=t.licenseKey??jn.COMMUNITY_LICENSE_KEY,this.endpoint=t.endpoint??jn.DEFAULT_ENDPOINT,this.superdocId=t.superdocId,this.superdocVersion=t.superdocVersion,this.sessionId=this.generateId()}getBrowserInfo(){return{userAgent:window.navigator.userAgent,currentUrl:window.location.href,hostname:window.location.hostname,referrerUrl:document.referrer,screenSize:{width:window.screen.width,height:window.screen.height}}}async trackUsage(t,n={}){if(!this.enabled)return;const r={id:this.generateId(),type:"usage",timestamp:new Date().toISOString(),sessionId:this.sessionId,superdocId:this.superdocId,superdocVersion:this.superdocVersion,file:this.documentInfo,browser:this.getBrowserInfo(),name:t,properties:n};await this.sendDataToTelemetry(r)}trackStatistic(t,n){if(t==="node")this.statistics.nodeTypes[n.elementName]=(this.statistics.nodeTypes[n.elementName]||0)+1,this.fileStructure.totalNodes++;else if(t==="unknown"){const r=this.unknownElements.find(i=>i.elementName===n.elementName);r?(r.count+=1,r.attributes={...r.attributes,...n.attributes}):this.unknownElements.push({...n,count:1})}else t==="error"&&(this.errors.push(n),this.statistics.errorCount++);if(n.marks?.length&&n.marks.forEach(r=>{this.statistics.markTypes[r.type]=(this.statistics.markTypes[r.type]||0)+1}),n.attributes&&Object.keys(n.attributes).length){const r=["textIndent","textAlign","spacing","lineHeight","indent","list-style-type","listLevel","textStyle","order","lvlText","lvlJc","listNumberingType","numId"];Object.keys(n.attributes).forEach(i=>{r.includes(i)&&(this.statistics.attributes[i]=(this.statistics.attributes[i]||0)+1)})}}async trackFileStructure(t,n,r,i){this.fileStructure=t,this.documentInfo=await this.processDocument(n,{id:r,internalId:i})}async processDocument(t,n={}){if(!t)return console.warn("Telemetry: missing file source"),{};let r="";try{r=await this.generateCrc32Hash(t)}catch(i){console.error("Failed to generate file hash:",i)}return{id:n.id,name:t.name,size:t.size,crc32:r,lastModified:t.lastModified?new Date(t.lastModified).toISOString():null,type:t.type||"docx",internalId:n.internalId}}async generateCrc32Hash(t){const n=await t.arrayBuffer(),r=rn.Buffer.from(n);return Za(r).toString("hex")}isTelemetryDataChanged(){const t={},n={};if(!(Object.keys(this.statistics.nodeTypes).length<=1))return this.statistics!==t||n!==this.fileStructure||this.errors.length>0||this.unknownElements.length>0}async sendReport(){if(!this.enabled||!this.isTelemetryDataChanged())return;const t=[{id:this.generateId(),type:"parsing",timestamp:new Date().toISOString(),sessionId:this.sessionId,superdocId:this.superdocId,superdocVersion:this.superdocVersion,file:this.documentInfo,browser:this.getBrowserInfo(),statistics:this.statistics,fileStructure:this.fileStructure,unknownElements:this.unknownElements,errors:this.errors}];await this.sendDataToTelemetry(t)}async sendDataToTelemetry(t){try{const n=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-License-Key":this.licenseKey},body:JSON.stringify(t)});if(n.ok)this.resetStatistics();else throw new Error(`Upload failed: ${n.statusText}`)}catch(n){console.error("Failed to upload telemetry:",n)}}generateId(){const t=Date.now(),n=Qa(4).toString("hex");return`${t}-${n}`}resetStatistics(){this.statistics={nodeTypes:{},markTypes:{},styleTypes:{},unknownElements:[],errorCount:0},this.fileStructure={totalFiles:0,maxDepth:0,totalNodes:0,files:[]},this.unknownElements=[],this.errors=[]}}function En(e,t,n){return Array.isArray(e)?(e.length=Math.max(e.length,t),e.splice(t,1,n),n):(e[t]=n,n)}function mo(e,t){if(Array.isArray(e)){e.splice(t,1);return}delete e[t]}function el(){return es().__VUE_DEVTOOLS_GLOBAL_HOOK__}function es(){return typeof navigator<"u"&&typeof window<"u"?window:typeof globalThis<"u"?globalThis:{}}const tl=typeof Proxy=="function",nl="devtools-plugin:setup",ol="plugin:settings:set";let Nt,Do;function rl(){var e;return Nt!==void 0||(typeof window<"u"&&window.performance?(Nt=!0,Do=window.performance):typeof globalThis<"u"&&(!((e=globalThis.perf_hooks)===null||e===void 0)&&e.performance)?(Nt=!0,Do=globalThis.perf_hooks.performance):Nt=!1),Nt}function il(){return rl()?Do.now():Date.now()}class sl{constructor(t,n){this.target=null,this.targetQueue=[],this.onQueue=[],this.plugin=t,this.hook=n;const r={};if(t.settings)for(const a in t.settings){const l=t.settings[a];r[a]=l.defaultValue}const i=`__vue-devtools-plugin-settings__${t.id}`;let s=Object.assign({},r);try{const a=localStorage.getItem(i),l=JSON.parse(a);Object.assign(s,l)}catch{}this.fallbacks={getSettings(){return s},setSettings(a){try{localStorage.setItem(i,JSON.stringify(a))}catch{}s=a},now(){return il()}},n&&n.on(ol,(a,l)=>{a===this.plugin.id&&this.fallbacks.setSettings(l)}),this.proxiedOn=new Proxy({},{get:(a,l)=>this.target?this.target.on[l]:(...c)=>{this.onQueue.push({method:l,args:c})}}),this.proxiedTarget=new Proxy({},{get:(a,l)=>this.target?this.target[l]:l==="on"?this.proxiedOn:Object.keys(this.fallbacks).includes(l)?(...c)=>(this.targetQueue.push({method:l,args:c,resolve:()=>{}}),this.fallbacks[l](...c)):(...c)=>new Promise(u=>{this.targetQueue.push({method:l,args:c,resolve:u})})})}async setRealTarget(t){this.target=t;for(const n of this.onQueue)this.target.on[n.method](...n.args);for(const n of this.targetQueue)n.resolve(await this.target[n.method](...n.args))}}function ts(e,t){const n=e,r=es(),i=el(),s=tl&&n.enableEarlyProxy;if(i&&(r.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__||!s))i.emit(nl,e,t);else{const a=s?new sl(n,i):null;(r.__VUE_DEVTOOLS_PLUGINS__=r.__VUE_DEVTOOLS_PLUGINS__||[]).push({pluginDescriptor:n,setupFn:t,proxy:a}),a&&t(a.proxiedTarget)}}let nn;const un=e=>nn=e,ns=o.process$1.env.NODE_ENV!=="production"?Symbol("pinia"):Symbol();function Ot(e){return e&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"&&typeof e.toJSON!="function"}var Ye;(function(e){e.direct="direct",e.patchObject="patch object",e.patchFunction="patch function"})(Ye||(Ye={}));const ht=typeof window<"u",Tr=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof o.global=="object"&&o.global.global===o.global?o.global:typeof globalThis=="object"?globalThis:{HTMLElement:null};function al(e,{autoBom:t=!1}={}){return t&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\uFEFF",e],{type:e.type}):e}function tr(e,t,n){const r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){is(r.response,t,n)},r.onerror=function(){console.error("could not download file")},r.send()}function os(e){const t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch{}return t.status>=200&&t.status<=299}function Rn(e){try{e.dispatchEvent(new MouseEvent("click"))}catch{const n=document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(n)}}const An=typeof navigator=="object"?navigator:{userAgent:""},rs=/Macintosh/.test(An.userAgent)&&/AppleWebKit/.test(An.userAgent)&&!/Safari/.test(An.userAgent),is=ht?typeof HTMLAnchorElement<"u"&&"download"in HTMLAnchorElement.prototype&&!rs?ll:"msSaveOrOpenBlob"in An?cl:ul:()=>{};function ll(e,t="download",n){const r=document.createElement("a");r.download=t,r.rel="noopener",typeof e=="string"?(r.href=e,r.origin!==location.origin?os(r.href)?tr(e,t,n):(r.target="_blank",Rn(r)):Rn(r)):(r.href=URL.createObjectURL(e),setTimeout(function(){URL.revokeObjectURL(r.href)},4e4),setTimeout(function(){Rn(r)},0))}function cl(e,t="download",n){if(typeof e=="string")if(os(e))tr(e,t,n);else{const r=document.createElement("a");r.href=e,r.target="_blank",setTimeout(function(){Rn(r)})}else navigator.msSaveOrOpenBlob(al(e,n),t)}function ul(e,t,n,r){if(r=r||open("","_blank"),r&&(r.document.title=r.document.body.innerText="downloading..."),typeof e=="string")return tr(e,t,n);const i=e.type==="application/octet-stream",s=/constructor/i.test(String(Tr.HTMLElement))||"safari"in Tr,a=/CriOS\/[\d]+/.test(navigator.userAgent);if((a||i&&s||rs)&&typeof FileReader<"u"){const l=new FileReader;l.onloadend=function(){let c=l.result;if(typeof c!="string")throw r=null,new Error("Wrong reader.result type");c=a?c:c.replace(/^data:[^;]*;/,"data:attachment/file;"),r?r.location.href=c:location.assign(c),r=null},l.readAsDataURL(e)}else{const l=URL.createObjectURL(e);r?r.location.assign(l):location.href=l,r=null,setTimeout(function(){URL.revokeObjectURL(l)},4e4)}}function xe(e,t){const n="🍍 "+e;typeof __VUE_DEVTOOLS_TOAST__=="function"?__VUE_DEVTOOLS_TOAST__(n,t):t==="error"?console.error(n):t==="warn"?console.warn(n):console.log(n)}function nr(e){return"_a"in e&&"install"in e}function ss(){if(!("clipboard"in navigator))return xe("Your browser doesn't support the Clipboard API","error"),!0}function as(e){return e instanceof Error&&e.message.toLowerCase().includes("document is not focused")?(xe('You need to activate the "Emulate a focused page" setting in the "Rendering" panel of devtools.',"warn"),!0):!1}async function dl(e){if(!ss())try{await navigator.clipboard.writeText(JSON.stringify(e.state.value)),xe("Global state copied to clipboard.")}catch(t){if(as(t))return;xe("Failed to serialize the state. Check the console for more details.","error"),console.error(t)}}async function fl(e){if(!ss())try{ls(e,JSON.parse(await navigator.clipboard.readText())),xe("Global state pasted from clipboard.")}catch(t){if(as(t))return;xe("Failed to deserialize the state from clipboard. Check the console for more details.","error"),console.error(t)}}async function pl(e){try{is(new Blob([JSON.stringify(e.state.value)],{type:"text/plain;charset=utf-8"}),"pinia-state.json")}catch(t){xe("Failed to export the state as JSON. Check the console for more details.","error"),console.error(t)}}let rt;function hl(){rt||(rt=document.createElement("input"),rt.type="file",rt.accept=".json");function e(){return new Promise((t,n)=>{rt.onchange=async()=>{const r=rt.files;if(!r)return t(null);const i=r.item(0);return t(i?{text:await i.text(),file:i}:null)},rt.oncancel=()=>t(null),rt.onerror=n,rt.click()})}return e}async function ml(e){try{const n=await hl()();if(!n)return;const{text:r,file:i}=n;ls(e,JSON.parse(r)),xe(`Global state imported from "${i.name}".`)}catch(t){xe("Failed to import the state from JSON. Check the console for more details.","error"),console.error(t)}}function ls(e,t){for(const n in t){const r=e.state.value[n];r?Object.assign(r,t[n]):e.state.value[n]=t[n]}}function Ue(e){return{_custom:{display:e}}}const cs="🍍 Pinia (root)",Mn="_root";function vl(e){return nr(e)?{id:Mn,label:cs}:{id:e.$id,label:e.$id}}function gl(e){if(nr(e)){const n=Array.from(e._s.keys()),r=e._s;return{state:n.map(s=>({editable:!0,key:s,value:e.state.value[s]})),getters:n.filter(s=>r.get(s)._getters).map(s=>{const a=r.get(s);return{editable:!1,key:s,value:a._getters.reduce((l,c)=>(l[c]=a[c],l),{})}})}}const t={state:Object.keys(e.$state).map(n=>({editable:!0,key:n,value:e.$state[n]}))};return e._getters&&e._getters.length&&(t.getters=e._getters.map(n=>({editable:!1,key:n,value:e[n]}))),e._customProperties.size&&(t.customProperties=Array.from(e._customProperties).map(n=>({editable:!0,key:n,value:e[n]}))),t}function bl(e){return e?Array.isArray(e)?e.reduce((t,n)=>(t.keys.push(n.key),t.operations.push(n.type),t.oldValue[n.key]=n.oldValue,t.newValue[n.key]=n.newValue,t),{oldValue:{},keys:[],operations:[],newValue:{}}):{operation:Ue(e.type),key:Ue(e.key),oldValue:e.oldValue,newValue:e.newValue}:{}}function yl(e){switch(e){case Ye.direct:return"mutation";case Ye.patchFunction:return"$patch";case Ye.patchObject:return"$patch";default:return"unknown"}}let jt=!0;const Nn=[],xt="pinia:mutations",Te="pinia",{assign:wl}=Object,Un=e=>"🍍 "+e;function Cl(e,t){ts({id:"dev.esm.pinia",label:"Pinia 🍍",logo:"https://pinia.vuejs.org/logo.svg",packageName:"pinia",homepage:"https://pinia.vuejs.org",componentStateTypes:Nn,app:e},n=>{typeof n.now!="function"&&xe("You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html."),n.addTimelineLayer({id:xt,label:"Pinia 🍍",color:15064968}),n.addInspector({id:Te,label:"Pinia 🍍",icon:"storage",treeFilterPlaceholder:"Search stores",actions:[{icon:"content_copy",action:()=>{dl(t)},tooltip:"Serialize and copy the state"},{icon:"content_paste",action:async()=>{await fl(t),n.sendInspectorTree(Te),n.sendInspectorState(Te)},tooltip:"Replace the state with the content of your clipboard"},{icon:"save",action:()=>{pl(t)},tooltip:"Save the state as a JSON file"},{icon:"folder_open",action:async()=>{await ml(t),n.sendInspectorTree(Te),n.sendInspectorState(Te)},tooltip:"Import the state from a JSON file"}],nodeActions:[{icon:"restore",tooltip:'Reset the state (with "$reset")',action:r=>{const i=t._s.get(r);i?typeof i.$reset!="function"?xe(`Cannot reset "${r}" store because it doesn't have a "$reset" method implemented.`,"warn"):(i.$reset(),xe(`Store "${r}" reset.`)):xe(`Cannot reset "${r}" store because it wasn't found.`,"warn")}}]}),n.on.inspectComponent((r,i)=>{const s=r.componentInstance&&r.componentInstance.proxy;if(s&&s._pStores){const a=r.componentInstance.proxy._pStores;Object.values(a).forEach(l=>{r.instanceData.state.push({type:Un(l.$id),key:"state",editable:!0,value:l._isOptionsAPI?{_custom:{value:o.toRaw(l.$state),actions:[{icon:"restore",tooltip:"Reset the state of this store",action:()=>l.$reset()}]}}:Object.keys(l.$state).reduce((c,u)=>(c[u]=l.$state[u],c),{})}),l._getters&&l._getters.length&&r.instanceData.state.push({type:Un(l.$id),key:"getters",editable:!1,value:l._getters.reduce((c,u)=>{try{c[u]=l[u]}catch(d){c[u]=d}return c},{})})})}}),n.on.getInspectorTree(r=>{if(r.app===e&&r.inspectorId===Te){let i=[t];i=i.concat(Array.from(t._s.values())),r.rootNodes=(r.filter?i.filter(s=>"$id"in s?s.$id.toLowerCase().includes(r.filter.toLowerCase()):cs.toLowerCase().includes(r.filter.toLowerCase())):i).map(vl)}}),globalThis.$pinia=t,n.on.getInspectorState(r=>{if(r.app===e&&r.inspectorId===Te){const i=r.nodeId===Mn?t:t._s.get(r.nodeId);if(!i)return;i&&(r.nodeId!==Mn&&(globalThis.$store=o.toRaw(i)),r.state=gl(i))}}),n.on.editInspectorState((r,i)=>{if(r.app===e&&r.inspectorId===Te){const s=r.nodeId===Mn?t:t._s.get(r.nodeId);if(!s)return xe(`store "${r.nodeId}" not found`,"error");const{path:a}=r;nr(s)?a.unshift("state"):(a.length!==1||!s._customProperties.has(a[0])||a[0]in s.$state)&&a.unshift("$state"),jt=!1,r.set(s,a,r.state.value),jt=!0}}),n.on.editComponentState(r=>{if(r.type.startsWith("🍍")){const i=r.type.replace(/^🍍\s*/,""),s=t._s.get(i);if(!s)return xe(`store "${i}" not found`,"error");const{path:a}=r;if(a[0]!=="state")return xe(`Invalid path for store "${i}":
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ce=require("./chunks/super-editor.es-DOk_Y-T9.cjs"),o=require("./chunks/vue-Ckf0DkDN.cjs"),rn=require("./chunks/jszip-O1Upj8hc.cjs"),Gi=require("./chunks/blank-docx-BHgKMWrQ.cjs"),qi=require("./chunks/eventemitter3-DS1WPZxT.cjs"),Xi=require("@hocuspocus/provider"),Zo=require("yjs"),Yi=require("./chunks/uuid-DQp44bVU.cjs"),Wa=require("pdfjs-dist/legacy/build/pdf.mjs"),Ka=require("pdfjs-dist/web/pdf_viewer");function Ji(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const kr=Ji(Wa),_r=Ji(Ka),gt="application/vnd.openxmlformats-officedocument.wordprocessingml.document",gn="application/pdf",oo="text/html",$r={docx:gt,pdf:gn,html:oo},tn=Object.freeze({RESOLVED:"resolved",NEW:"new",ADD:"add",UPDATE:"update",DELETED:"deleted",PENDING:"pending",SELECTED:"selected",COMMENTS_LIST:"comments-list",CHANGE_ACCEPTED:"change-accepted",CHANGE_REJECTED:"change-rejected"}),Po=async(e,t,n)=>{const i=await(await fetch(e)).blob();return new File([i],t,{type:n})};function Ga(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,r.length);i++){const s=n[i]||0,a=r[i]||0;if(s>a)return 1;if(s<a)return-1}return 0}const Zi={mounted(e,t,n){const r=i=>{e.contains(i.target)||t.value(i)};document.addEventListener("click",r),e.__clickOutsideHandler=r},unmounted(e){document.removeEventListener("click",e.__clickOutsideHandler),delete e.__clickOutsideHandler}};function qa(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}const Xa=new Int32Array([0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117]);function Qi(e){if(rn.Buffer.isBuffer(e))return e;if(typeof e=="number")return rn.Buffer.alloc(e);if(typeof e=="string")return rn.Buffer.from(e);throw new Error("input must be buffer, number, or string, received "+typeof e)}function Ya(e){const t=Qi(4);return t.writeInt32BE(e,0),t}function Qo(e,t){e=Qi(e),rn.Buffer.isBuffer(t)&&(t=t.readUInt32BE(0));let n=~~t^-1;for(var r=0;r<e.length;r++)n=Xa[(n^e[r])&255]^n>>>8;return n^-1}function er(){return Ya(Qo.apply(null,arguments))}er.signed=function(){return Qo.apply(null,arguments)};er.unsigned=function(){return Qo.apply(null,arguments)>>>0};var Ja=er;const Za=qa(Ja);function Qa(e){const t=new Uint8Array(e);for(let n=0;n<e;n++)t[n]=Math.floor(Math.random()*256);return t}class jn{enabled;superdocId;superdocVersion;licenseKey;endpoint;sessionId;statistics={nodeTypes:{},markTypes:{},attributes:{},errorCount:0};unknownElements=[];errors=[];fileStructure={totalFiles:0,maxDepth:0,totalNodes:0,files:[]};documentInfo=null;static COMMUNITY_LICENSE_KEY="community-and-eval-agplv3";static DEFAULT_ENDPOINT="https://ingest.superdoc.dev/v1/collect";constructor(t={}){this.enabled=t.enabled??!0,this.licenseKey=t.licenseKey??jn.COMMUNITY_LICENSE_KEY,this.endpoint=t.endpoint??jn.DEFAULT_ENDPOINT,this.superdocId=t.superdocId,this.superdocVersion=t.superdocVersion,this.sessionId=this.generateId()}getBrowserInfo(){return{userAgent:window.navigator.userAgent,currentUrl:window.location.href,hostname:window.location.hostname,referrerUrl:document.referrer,screenSize:{width:window.screen.width,height:window.screen.height}}}async trackUsage(t,n={}){if(!this.enabled)return;const r={id:this.generateId(),type:"usage",timestamp:new Date().toISOString(),sessionId:this.sessionId,superdocId:this.superdocId,superdocVersion:this.superdocVersion,file:this.documentInfo,browser:this.getBrowserInfo(),name:t,properties:n};await this.sendDataToTelemetry(r)}trackStatistic(t,n){if(t==="node")this.statistics.nodeTypes[n.elementName]=(this.statistics.nodeTypes[n.elementName]||0)+1,this.fileStructure.totalNodes++;else if(t==="unknown"){const r=this.unknownElements.find(i=>i.elementName===n.elementName);r?(r.count+=1,r.attributes={...r.attributes,...n.attributes}):this.unknownElements.push({...n,count:1})}else t==="error"&&(this.errors.push(n),this.statistics.errorCount++);if(n.marks?.length&&n.marks.forEach(r=>{this.statistics.markTypes[r.type]=(this.statistics.markTypes[r.type]||0)+1}),n.attributes&&Object.keys(n.attributes).length){const r=["textIndent","textAlign","spacing","lineHeight","indent","list-style-type","listLevel","textStyle","order","lvlText","lvlJc","listNumberingType","numId"];Object.keys(n.attributes).forEach(i=>{r.includes(i)&&(this.statistics.attributes[i]=(this.statistics.attributes[i]||0)+1)})}}async trackFileStructure(t,n,r,i){this.fileStructure=t,this.documentInfo=await this.processDocument(n,{id:r,internalId:i})}async processDocument(t,n={}){if(!t)return console.warn("Telemetry: missing file source"),{};let r="";try{r=await this.generateCrc32Hash(t)}catch(i){console.error("Failed to generate file hash:",i)}return{id:n.id,name:t.name,size:t.size,crc32:r,lastModified:t.lastModified?new Date(t.lastModified).toISOString():null,type:t.type||"docx",internalId:n.internalId}}async generateCrc32Hash(t){const n=await t.arrayBuffer(),r=rn.Buffer.from(n);return Za(r).toString("hex")}isTelemetryDataChanged(){const t={},n={};if(!(Object.keys(this.statistics.nodeTypes).length<=1))return this.statistics!==t||n!==this.fileStructure||this.errors.length>0||this.unknownElements.length>0}async sendReport(){if(!this.enabled||!this.isTelemetryDataChanged())return;const t=[{id:this.generateId(),type:"parsing",timestamp:new Date().toISOString(),sessionId:this.sessionId,superdocId:this.superdocId,superdocVersion:this.superdocVersion,file:this.documentInfo,browser:this.getBrowserInfo(),statistics:this.statistics,fileStructure:this.fileStructure,unknownElements:this.unknownElements,errors:this.errors}];await this.sendDataToTelemetry(t)}async sendDataToTelemetry(t){try{const n=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","X-License-Key":this.licenseKey},body:JSON.stringify(t)});if(n.ok)this.resetStatistics();else throw new Error(`Upload failed: ${n.statusText}`)}catch(n){console.error("Failed to upload telemetry:",n)}}generateId(){const t=Date.now(),n=Qa(4).toString("hex");return`${t}-${n}`}resetStatistics(){this.statistics={nodeTypes:{},markTypes:{},styleTypes:{},unknownElements:[],errorCount:0},this.fileStructure={totalFiles:0,maxDepth:0,totalNodes:0,files:[]},this.unknownElements=[],this.errors=[]}}function En(e,t,n){return Array.isArray(e)?(e.length=Math.max(e.length,t),e.splice(t,1,n),n):(e[t]=n,n)}function mo(e,t){if(Array.isArray(e)){e.splice(t,1);return}delete e[t]}function el(){return es().__VUE_DEVTOOLS_GLOBAL_HOOK__}function es(){return typeof navigator<"u"&&typeof window<"u"?window:typeof globalThis<"u"?globalThis:{}}const tl=typeof Proxy=="function",nl="devtools-plugin:setup",ol="plugin:settings:set";let Nt,Do;function rl(){var e;return Nt!==void 0||(typeof window<"u"&&window.performance?(Nt=!0,Do=window.performance):typeof globalThis<"u"&&(!((e=globalThis.perf_hooks)===null||e===void 0)&&e.performance)?(Nt=!0,Do=globalThis.perf_hooks.performance):Nt=!1),Nt}function il(){return rl()?Do.now():Date.now()}class sl{constructor(t,n){this.target=null,this.targetQueue=[],this.onQueue=[],this.plugin=t,this.hook=n;const r={};if(t.settings)for(const a in t.settings){const l=t.settings[a];r[a]=l.defaultValue}const i=`__vue-devtools-plugin-settings__${t.id}`;let s=Object.assign({},r);try{const a=localStorage.getItem(i),l=JSON.parse(a);Object.assign(s,l)}catch{}this.fallbacks={getSettings(){return s},setSettings(a){try{localStorage.setItem(i,JSON.stringify(a))}catch{}s=a},now(){return il()}},n&&n.on(ol,(a,l)=>{a===this.plugin.id&&this.fallbacks.setSettings(l)}),this.proxiedOn=new Proxy({},{get:(a,l)=>this.target?this.target.on[l]:(...c)=>{this.onQueue.push({method:l,args:c})}}),this.proxiedTarget=new Proxy({},{get:(a,l)=>this.target?this.target[l]:l==="on"?this.proxiedOn:Object.keys(this.fallbacks).includes(l)?(...c)=>(this.targetQueue.push({method:l,args:c,resolve:()=>{}}),this.fallbacks[l](...c)):(...c)=>new Promise(u=>{this.targetQueue.push({method:l,args:c,resolve:u})})})}async setRealTarget(t){this.target=t;for(const n of this.onQueue)this.target.on[n.method](...n.args);for(const n of this.targetQueue)n.resolve(await this.target[n.method](...n.args))}}function ts(e,t){const n=e,r=es(),i=el(),s=tl&&n.enableEarlyProxy;if(i&&(r.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__||!s))i.emit(nl,e,t);else{const a=s?new sl(n,i):null;(r.__VUE_DEVTOOLS_PLUGINS__=r.__VUE_DEVTOOLS_PLUGINS__||[]).push({pluginDescriptor:n,setupFn:t,proxy:a}),a&&t(a.proxiedTarget)}}let nn;const un=e=>nn=e,ns=o.process$1.env.NODE_ENV!=="production"?Symbol("pinia"):Symbol();function Ot(e){return e&&typeof e=="object"&&Object.prototype.toString.call(e)==="[object Object]"&&typeof e.toJSON!="function"}var Ye;(function(e){e.direct="direct",e.patchObject="patch object",e.patchFunction="patch function"})(Ye||(Ye={}));const ht=typeof window<"u",Tr=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof o.global=="object"&&o.global.global===o.global?o.global:typeof globalThis=="object"?globalThis:{HTMLElement:null};function al(e,{autoBom:t=!1}={}){return t&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\uFEFF",e],{type:e.type}):e}function tr(e,t,n){const r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){is(r.response,t,n)},r.onerror=function(){console.error("could not download file")},r.send()}function os(e){const t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch{}return t.status>=200&&t.status<=299}function Rn(e){try{e.dispatchEvent(new MouseEvent("click"))}catch{const n=document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(n)}}const An=typeof navigator=="object"?navigator:{userAgent:""},rs=/Macintosh/.test(An.userAgent)&&/AppleWebKit/.test(An.userAgent)&&!/Safari/.test(An.userAgent),is=ht?typeof HTMLAnchorElement<"u"&&"download"in HTMLAnchorElement.prototype&&!rs?ll:"msSaveOrOpenBlob"in An?cl:ul:()=>{};function ll(e,t="download",n){const r=document.createElement("a");r.download=t,r.rel="noopener",typeof e=="string"?(r.href=e,r.origin!==location.origin?os(r.href)?tr(e,t,n):(r.target="_blank",Rn(r)):Rn(r)):(r.href=URL.createObjectURL(e),setTimeout(function(){URL.revokeObjectURL(r.href)},4e4),setTimeout(function(){Rn(r)},0))}function cl(e,t="download",n){if(typeof e=="string")if(os(e))tr(e,t,n);else{const r=document.createElement("a");r.href=e,r.target="_blank",setTimeout(function(){Rn(r)})}else navigator.msSaveOrOpenBlob(al(e,n),t)}function ul(e,t,n,r){if(r=r||open("","_blank"),r&&(r.document.title=r.document.body.innerText="downloading..."),typeof e=="string")return tr(e,t,n);const i=e.type==="application/octet-stream",s=/constructor/i.test(String(Tr.HTMLElement))||"safari"in Tr,a=/CriOS\/[\d]+/.test(navigator.userAgent);if((a||i&&s||rs)&&typeof FileReader<"u"){const l=new FileReader;l.onloadend=function(){let c=l.result;if(typeof c!="string")throw r=null,new Error("Wrong reader.result type");c=a?c:c.replace(/^data:[^;]*;/,"data:attachment/file;"),r?r.location.href=c:location.assign(c),r=null},l.readAsDataURL(e)}else{const l=URL.createObjectURL(e);r?r.location.assign(l):location.href=l,r=null,setTimeout(function(){URL.revokeObjectURL(l)},4e4)}}function xe(e,t){const n="🍍 "+e;typeof __VUE_DEVTOOLS_TOAST__=="function"?__VUE_DEVTOOLS_TOAST__(n,t):t==="error"?console.error(n):t==="warn"?console.warn(n):console.log(n)}function nr(e){return"_a"in e&&"install"in e}function ss(){if(!("clipboard"in navigator))return xe("Your browser doesn't support the Clipboard API","error"),!0}function as(e){return e instanceof Error&&e.message.toLowerCase().includes("document is not focused")?(xe('You need to activate the "Emulate a focused page" setting in the "Rendering" panel of devtools.',"warn"),!0):!1}async function dl(e){if(!ss())try{await navigator.clipboard.writeText(JSON.stringify(e.state.value)),xe("Global state copied to clipboard.")}catch(t){if(as(t))return;xe("Failed to serialize the state. Check the console for more details.","error"),console.error(t)}}async function fl(e){if(!ss())try{ls(e,JSON.parse(await navigator.clipboard.readText())),xe("Global state pasted from clipboard.")}catch(t){if(as(t))return;xe("Failed to deserialize the state from clipboard. Check the console for more details.","error"),console.error(t)}}async function pl(e){try{is(new Blob([JSON.stringify(e.state.value)],{type:"text/plain;charset=utf-8"}),"pinia-state.json")}catch(t){xe("Failed to export the state as JSON. Check the console for more details.","error"),console.error(t)}}let rt;function hl(){rt||(rt=document.createElement("input"),rt.type="file",rt.accept=".json");function e(){return new Promise((t,n)=>{rt.onchange=async()=>{const r=rt.files;if(!r)return t(null);const i=r.item(0);return t(i?{text:await i.text(),file:i}:null)},rt.oncancel=()=>t(null),rt.onerror=n,rt.click()})}return e}async function ml(e){try{const n=await hl()();if(!n)return;const{text:r,file:i}=n;ls(e,JSON.parse(r)),xe(`Global state imported from "${i.name}".`)}catch(t){xe("Failed to import the state from JSON. Check the console for more details.","error"),console.error(t)}}function ls(e,t){for(const n in t){const r=e.state.value[n];r?Object.assign(r,t[n]):e.state.value[n]=t[n]}}function Ue(e){return{_custom:{display:e}}}const cs="🍍 Pinia (root)",Mn="_root";function vl(e){return nr(e)?{id:Mn,label:cs}:{id:e.$id,label:e.$id}}function gl(e){if(nr(e)){const n=Array.from(e._s.keys()),r=e._s;return{state:n.map(s=>({editable:!0,key:s,value:e.state.value[s]})),getters:n.filter(s=>r.get(s)._getters).map(s=>{const a=r.get(s);return{editable:!1,key:s,value:a._getters.reduce((l,c)=>(l[c]=a[c],l),{})}})}}const t={state:Object.keys(e.$state).map(n=>({editable:!0,key:n,value:e.$state[n]}))};return e._getters&&e._getters.length&&(t.getters=e._getters.map(n=>({editable:!1,key:n,value:e[n]}))),e._customProperties.size&&(t.customProperties=Array.from(e._customProperties).map(n=>({editable:!0,key:n,value:e[n]}))),t}function bl(e){return e?Array.isArray(e)?e.reduce((t,n)=>(t.keys.push(n.key),t.operations.push(n.type),t.oldValue[n.key]=n.oldValue,t.newValue[n.key]=n.newValue,t),{oldValue:{},keys:[],operations:[],newValue:{}}):{operation:Ue(e.type),key:Ue(e.key),oldValue:e.oldValue,newValue:e.newValue}:{}}function yl(e){switch(e){case Ye.direct:return"mutation";case Ye.patchFunction:return"$patch";case Ye.patchObject:return"$patch";default:return"unknown"}}let jt=!0;const Nn=[],xt="pinia:mutations",Te="pinia",{assign:wl}=Object,Un=e=>"🍍 "+e;function Cl(e,t){ts({id:"dev.esm.pinia",label:"Pinia 🍍",logo:"https://pinia.vuejs.org/logo.svg",packageName:"pinia",homepage:"https://pinia.vuejs.org",componentStateTypes:Nn,app:e},n=>{typeof n.now!="function"&&xe("You seem to be using an outdated version of Vue Devtools. Are you still using the Beta release instead of the stable one? You can find the links at https://devtools.vuejs.org/guide/installation.html."),n.addTimelineLayer({id:xt,label:"Pinia 🍍",color:15064968}),n.addInspector({id:Te,label:"Pinia 🍍",icon:"storage",treeFilterPlaceholder:"Search stores",actions:[{icon:"content_copy",action:()=>{dl(t)},tooltip:"Serialize and copy the state"},{icon:"content_paste",action:async()=>{await fl(t),n.sendInspectorTree(Te),n.sendInspectorState(Te)},tooltip:"Replace the state with the content of your clipboard"},{icon:"save",action:()=>{pl(t)},tooltip:"Save the state as a JSON file"},{icon:"folder_open",action:async()=>{await ml(t),n.sendInspectorTree(Te),n.sendInspectorState(Te)},tooltip:"Import the state from a JSON file"}],nodeActions:[{icon:"restore",tooltip:'Reset the state (with "$reset")',action:r=>{const i=t._s.get(r);i?typeof i.$reset!="function"?xe(`Cannot reset "${r}" store because it doesn't have a "$reset" method implemented.`,"warn"):(i.$reset(),xe(`Store "${r}" reset.`)):xe(`Cannot reset "${r}" store because it wasn't found.`,"warn")}}]}),n.on.inspectComponent((r,i)=>{const s=r.componentInstance&&r.componentInstance.proxy;if(s&&s._pStores){const a=r.componentInstance.proxy._pStores;Object.values(a).forEach(l=>{r.instanceData.state.push({type:Un(l.$id),key:"state",editable:!0,value:l._isOptionsAPI?{_custom:{value:o.toRaw(l.$state),actions:[{icon:"restore",tooltip:"Reset the state of this store",action:()=>l.$reset()}]}}:Object.keys(l.$state).reduce((c,u)=>(c[u]=l.$state[u],c),{})}),l._getters&&l._getters.length&&r.instanceData.state.push({type:Un(l.$id),key:"getters",editable:!1,value:l._getters.reduce((c,u)=>{try{c[u]=l[u]}catch(d){c[u]=d}return c},{})})})}}),n.on.getInspectorTree(r=>{if(r.app===e&&r.inspectorId===Te){let i=[t];i=i.concat(Array.from(t._s.values())),r.rootNodes=(r.filter?i.filter(s=>"$id"in s?s.$id.toLowerCase().includes(r.filter.toLowerCase()):cs.toLowerCase().includes(r.filter.toLowerCase())):i).map(vl)}}),globalThis.$pinia=t,n.on.getInspectorState(r=>{if(r.app===e&&r.inspectorId===Te){const i=r.nodeId===Mn?t:t._s.get(r.nodeId);if(!i)return;i&&(r.nodeId!==Mn&&(globalThis.$store=o.toRaw(i)),r.state=gl(i))}}),n.on.editInspectorState((r,i)=>{if(r.app===e&&r.inspectorId===Te){const s=r.nodeId===Mn?t:t._s.get(r.nodeId);if(!s)return xe(`store "${r.nodeId}" not found`,"error");const{path:a}=r;nr(s)?a.unshift("state"):(a.length!==1||!s._customProperties.has(a[0])||a[0]in s.$state)&&a.unshift("$state"),jt=!1,r.set(s,a,r.state.value),jt=!0}}),n.on.editComponentState(r=>{if(r.type.startsWith("🍍")){const i=r.type.replace(/^🍍\s*/,""),s=t._s.get(i);if(!s)return xe(`store "${i}" not found`,"error");const{path:a}=r;if(a[0]!=="state")return xe(`Invalid path for store "${i}":
2
2
  ${a}
3
3
  Only state can be modified.`);a[0]="$state",jt=!1,r.set(s,a,r.state.value),jt=!0}})})}function xl(e,t){Nn.includes(Un(t.$id))||Nn.push(Un(t.$id)),ts({id:"dev.esm.pinia",label:"Pinia 🍍",logo:"https://pinia.vuejs.org/logo.svg",packageName:"pinia",homepage:"https://pinia.vuejs.org",componentStateTypes:Nn,app:e,settings:{logStoreChanges:{label:"Notify about new/deleted stores",type:"boolean",defaultValue:!0}}},n=>{const r=typeof n.now=="function"?n.now.bind(n):Date.now;t.$onAction(({after:a,onError:l,name:c,args:u})=>{const d=us++;n.addTimelineEvent({layerId:xt,event:{time:r(),title:"🛫 "+c,subtitle:"start",data:{store:Ue(t.$id),action:Ue(c),args:u},groupId:d}}),a(p=>{mt=void 0,n.addTimelineEvent({layerId:xt,event:{time:r(),title:"🛬 "+c,subtitle:"end",data:{store:Ue(t.$id),action:Ue(c),args:u,result:p},groupId:d}})}),l(p=>{mt=void 0,n.addTimelineEvent({layerId:xt,event:{time:r(),logType:"error",title:"💥 "+c,subtitle:"end",data:{store:Ue(t.$id),action:Ue(c),args:u,error:p},groupId:d}})})},!0),t._customProperties.forEach(a=>{o.watch(()=>o.unref(t[a]),(l,c)=>{n.notifyComponentUpdate(),n.sendInspectorState(Te),jt&&n.addTimelineEvent({layerId:xt,event:{time:r(),title:"Change",subtitle:a,data:{newValue:l,oldValue:c},groupId:mt}})},{deep:!0})}),t.$subscribe(({events:a,type:l},c)=>{if(n.notifyComponentUpdate(),n.sendInspectorState(Te),!jt)return;const u={time:r(),title:yl(l),data:wl({store:Ue(t.$id)},bl(a)),groupId:mt};l===Ye.patchFunction?u.subtitle="⤵️":l===Ye.patchObject?u.subtitle="🧩":a&&!Array.isArray(a)&&(u.subtitle=a.type),a&&(u.data["rawEvent(s)"]={_custom:{display:"DebuggerEvent",type:"object",tooltip:"raw DebuggerEvent[]",value:a}}),n.addTimelineEvent({layerId:xt,event:u})},{detached:!0,flush:"sync"});const i=t._hotUpdate;t._hotUpdate=o.markRaw(a=>{i(a),n.addTimelineEvent({layerId:xt,event:{time:r(),title:"🔥 "+t.$id,subtitle:"HMR update",data:{store:Ue(t.$id),info:Ue("HMR update")}}}),n.notifyComponentUpdate(),n.sendInspectorTree(Te),n.sendInspectorState(Te)});const{$dispose:s}=t;t.$dispose=()=>{s(),n.notifyComponentUpdate(),n.sendInspectorTree(Te),n.sendInspectorState(Te),n.getSettings().logStoreChanges&&xe(`Disposed "${t.$id}" store 🗑`)},n.notifyComponentUpdate(),n.sendInspectorTree(Te),n.sendInspectorState(Te),n.getSettings().logStoreChanges&&xe(`"${t.$id}" store installed 🆕`)})}let us=0,mt;function Ir(e,t,n){const r=t.reduce((i,s)=>(i[s]=o.toRaw(e)[s],i),{});for(const i in r)e[i]=function(){const s=us,a=n?new Proxy(e,{get(...c){return mt=s,Reflect.get(...c)},set(...c){return mt=s,Reflect.set(...c)}}):e;mt=s;const l=r[i].apply(a,arguments);return mt=void 0,l}}function El({app:e,store:t,options:n}){if(!t.$id.startsWith("__hot:")){if(t._isOptionsAPI=!!n.state,!t._p._testing){Ir(t,Object.keys(n.actions),t._isOptionsAPI);const r=t._hotUpdate;o.toRaw(t)._hotUpdate=function(i){r.apply(this,arguments),Ir(t,Object.keys(i._hmrPayload.actions),!!t._isOptionsAPI)}}xl(e,t)}}function Sl(){const e=o.effectScope(!0),t=e.run(()=>o.ref({}));let n=[],r=[];const i=o.markRaw({install(s){un(i),i._a=s,s.provide(ns,i),s.config.globalProperties.$pinia=i,o.process$1.env.NODE_ENV!=="production"&&o.process$1.env.NODE_ENV!=="test"&&ht&&Cl(s,i),r.forEach(a=>n.push(a)),r=[]},use(s){return this._a?n.push(s):r.push(s),this},_p:n,_a:null,_e:e,_s:new Map,state:t});return o.process$1.env.NODE_ENV!=="production"&&o.process$1.env.NODE_ENV!=="test"&&ht&&typeof Proxy<"u"&&i.use(El),i}function ds(e,t){for(const n in t){const r=t[n];if(!(n in e))continue;const i=e[n];Ot(i)&&Ot(r)&&!o.isRef(r)&&!o.isReactive(r)?e[n]=ds(i,r):e[n]=r}return e}const fs=()=>{};function Or(e,t,n,r=fs){e.push(t);const i=()=>{const s=e.indexOf(t);s>-1&&(e.splice(s,1),r())};return!n&&o.getCurrentScope()&&o.onScopeDispose(i),i}function Ft(e,...t){e.slice().forEach(n=>{n(...t)})}const kl=e=>e(),Br=Symbol(),vo=Symbol();function Ro(e,t){e instanceof Map&&t instanceof Map?t.forEach((n,r)=>e.set(r,n)):e instanceof Set&&t instanceof Set&&t.forEach(e.add,e);for(const n in t){if(!t.hasOwnProperty(n))continue;const r=t[n],i=e[n];Ot(i)&&Ot(r)&&e.hasOwnProperty(n)&&!o.isRef(r)&&!o.isReactive(r)?e[n]=Ro(i,r):e[n]=r}return e}const _l=o.process$1.env.NODE_ENV!=="production"?Symbol("pinia:skipHydration"):Symbol();function $l(e){return!Ot(e)||!e.hasOwnProperty(_l)}const{assign:He}=Object;function Pr(e){return!!(o.isRef(e)&&e.effect)}function Dr(e,t,n,r){const{state:i,actions:s,getters:a}=t,l=n.state.value[e];let c;function u(){!l&&(o.process$1.env.NODE_ENV==="production"||!r)&&(n.state.value[e]=i?i():{});const d=o.process$1.env.NODE_ENV!=="production"&&r?o.toRefs(o.ref(i?i():{}).value):o.toRefs(n.state.value[e]);return He(d,s,Object.keys(a||{}).reduce((p,h)=>(o.process$1.env.NODE_ENV!=="production"&&h in d&&console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${h}" in store "${e}".`),p[h]=o.markRaw(o.computed(()=>{un(n);const b=n._s.get(e);return a[h].call(b,b)})),p),{}))}return c=Ao(e,u,t,n,r,!0),c}function Ao(e,t,n={},r,i,s){let a;const l=He({actions:{}},n);if(o.process$1.env.NODE_ENV!=="production"&&!r._e.active)throw new Error("Pinia destroyed");const c={deep:!0};o.process$1.env.NODE_ENV!=="production"&&(c.onTrigger=g=>{u?b=g:u==!1&&!f._hotUpdating&&(Array.isArray(b)?b.push(g):console.error("🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug."))});let u,d,p=[],h=[],b;const m=r.state.value[e];!s&&!m&&(o.process$1.env.NODE_ENV==="production"||!i)&&(r.state.value[e]={});const C=o.ref({});let w;function v(g){let E;u=d=!1,o.process$1.env.NODE_ENV!=="production"&&(b=[]),typeof g=="function"?(g(r.state.value[e]),E={type:Ye.patchFunction,storeId:e,events:b}):(Ro(r.state.value[e],g),E={type:Ye.patchObject,payload:g,storeId:e,events:b});const k=w=Symbol();o.nextTick().then(()=>{w===k&&(u=!0)}),d=!0,Ft(p,E,r.state.value[e])}const I=s?function(){const{state:E}=n,k=E?E():{};this.$patch(N=>{He(N,k)})}:o.process$1.env.NODE_ENV!=="production"?()=>{throw new Error(`🍍: Store "${e}" is built using the setup syntax and does not implement $reset().`)}:fs;function B(){a.stop(),p=[],h=[],r._s.delete(e)}const S=(g,E="")=>{if(Br in g)return g[vo]=E,g;const k=function(){un(r);const N=Array.from(arguments),P=[],x=[];function D(F){P.push(F)}function A(F){x.push(F)}Ft(h,{args:N,name:k[vo],store:f,after:D,onError:A});let z;try{z=g.apply(this&&this.$id===e?this:f,N)}catch(F){throw Ft(x,F),F}return z instanceof Promise?z.then(F=>(Ft(P,F),F)).catch(F=>(Ft(x,F),Promise.reject(F))):(Ft(P,z),z)};return k[Br]=!0,k[vo]=E,k},O=o.markRaw({actions:{},getters:{},state:[],hotState:C}),T={_p:r,$id:e,$onAction:Or.bind(null,h),$patch:v,$reset:I,$subscribe(g,E={}){const k=Or(p,g,E.detached,()=>N()),N=a.run(()=>o.watch(()=>r.state.value[e],P=>{(E.flush==="sync"?d:u)&&g({storeId:e,type:Ye.direct,events:b},P)},He({},c,E)));return k},$dispose:B},f=o.reactive(o.process$1.env.NODE_ENV!=="production"||o.process$1.env.NODE_ENV!=="production"&&o.process$1.env.NODE_ENV!=="test"&&ht?He({_hmrPayload:O,_customProperties:o.markRaw(new Set)},T):T);r._s.set(e,f);const $=(r._a&&r._a.runWithContext||kl)(()=>r._e.run(()=>(a=o.effectScope()).run(()=>t({action:S}))));for(const g in $){const E=$[g];if(o.isRef(E)&&!Pr(E)||o.isReactive(E))o.process$1.env.NODE_ENV!=="production"&&i?En(C.value,g,o.toRef($,g)):s||(m&&$l(E)&&(o.isRef(E)?E.value=m[g]:Ro(E,m[g])),r.state.value[e][g]=E),o.process$1.env.NODE_ENV!=="production"&&O.state.push(g);else if(typeof E=="function"){const k=o.process$1.env.NODE_ENV!=="production"&&i?E:S(E,g);$[g]=k,o.process$1.env.NODE_ENV!=="production"&&(O.actions[g]=E),l.actions[g]=E}else o.process$1.env.NODE_ENV!=="production"&&Pr(E)&&(O.getters[g]=s?n.getters[g]:E,ht&&($._getters||($._getters=o.markRaw([]))).push(g))}if(He(f,$),He(o.toRaw(f),$),Object.defineProperty(f,"$state",{get:()=>o.process$1.env.NODE_ENV!=="production"&&i?C.value:r.state.value[e],set:g=>{if(o.process$1.env.NODE_ENV!=="production"&&i)throw new Error("cannot set hotState");v(E=>{He(E,g)})}}),o.process$1.env.NODE_ENV!=="production"&&(f._hotUpdate=o.markRaw(g=>{f._hotUpdating=!0,g._hmrPayload.state.forEach(E=>{if(E in f.$state){const k=g.$state[E],N=f.$state[E];typeof k=="object"&&Ot(k)&&Ot(N)?ds(k,N):g.$state[E]=N}En(f,E,o.toRef(g.$state,E))}),Object.keys(f.$state).forEach(E=>{E in g.$state||mo(f,E)}),u=!1,d=!1,r.state.value[e]=o.toRef(g._hmrPayload,"hotState"),d=!0,o.nextTick().then(()=>{u=!0});for(const E in g._hmrPayload.actions){const k=g[E];En(f,E,S(k,E))}for(const E in g._hmrPayload.getters){const k=g._hmrPayload.getters[E],N=s?o.computed(()=>(un(r),k.call(f,f))):k;En(f,E,N)}Object.keys(f._hmrPayload.getters).forEach(E=>{E in g._hmrPayload.getters||mo(f,E)}),Object.keys(f._hmrPayload.actions).forEach(E=>{E in g._hmrPayload.actions||mo(f,E)}),f._hmrPayload=g._hmrPayload,f._getters=g._getters,f._hotUpdating=!1})),o.process$1.env.NODE_ENV!=="production"&&o.process$1.env.NODE_ENV!=="test"&&ht){const g={writable:!0,configurable:!0,enumerable:!1};["_p","_hmrPayload","_getters","_customProperties"].forEach(E=>{Object.defineProperty(f,E,He({value:f[E]},g))})}return r._p.forEach(g=>{if(o.process$1.env.NODE_ENV!=="production"&&o.process$1.env.NODE_ENV!=="test"&&ht){const E=a.run(()=>g({store:f,app:r._a,pinia:r,options:l}));Object.keys(E||{}).forEach(k=>f._customProperties.add(k)),He(f,E)}else He(f,a.run(()=>g({store:f,app:r._a,pinia:r,options:l})))}),o.process$1.env.NODE_ENV!=="production"&&f.$state&&typeof f.$state=="object"&&typeof f.$state.constructor=="function"&&!f.$state.constructor.toString().includes("[native code]")&&console.warn(`[🍍]: The "state" must be a plain object. It cannot be
4
4
  state: () => new MyClass()
@@ -506,7 +506,7 @@ ${t}
506
506
  -webkit-user-select: none;
507
507
  pointer-events: none;
508
508
  opacity: var(--n-opacity-spinning);
509
- `)])]),dv={small:20,medium:18,large:16},fv=Object.assign(Object.assign({},Re.props),{contentClass:String,contentStyle:[Object,String],description:String,stroke:String,size:{type:[String,Number],default:"medium"},show:{type:Boolean,default:!0},strokeWidth:Number,rotate:{type:Boolean,default:!0},spinning:{type:Boolean,validator:()=>!0,default:void 0},delay:Number}),pv=o.defineComponent({name:"Spin",props:fv,slots:Object,setup(e){o.process$1.env.NODE_ENV!=="production"&&o.watchEffect(()=>{e.spinning!==void 0&&Et("spin","`spinning` is deprecated, please use `show` instead.")});const{mergedClsPrefixRef:t,inlineThemeDisabled:n}=Gt(e),r=Re("Spin","-spin",uv,cv,e,t),i=o.computed(()=>{const{size:c}=e,{common:{cubicBezierEaseInOut:u},self:d}=r.value,{opacitySpinning:p,color:h,textColor:b}=d,m=typeof c=="number"?yc(c):d[Xe("size",c)];return{"--n-bezier":u,"--n-opacity-spinning":p,"--n-size":m,"--n-color":h,"--n-text-color":b}}),s=n?qt("spin",o.computed(()=>{const{size:c}=e;return typeof c=="number"?String(c):c[0]}),i,e):void 0,a=Is(e,["spinning","show"]),l=o.ref(!1);return o.watchEffect(c=>{let u;if(a.value){const{delay:d}=e;if(d){u=window.setTimeout(()=>{l.value=!0},d),c(()=>{clearTimeout(u)});return}}l.value=a.value}),{mergedClsPrefix:t,active:l,mergedStrokeWidth:o.computed(()=>{const{strokeWidth:c}=e;if(c!==void 0)return c;const{size:u}=e;return dv[typeof u=="number"?"medium":u]}),cssVars:n?void 0:i,themeClass:s?.themeClass,onRender:s?.onRender}},render(){var e,t;const{$slots:n,mergedClsPrefix:r,description:i}=this,s=n.icon&&this.rotate,a=(i||n.description)&&o.h("div",{class:`${r}-spin-description`},i||((e=n.description)===null||e===void 0?void 0:e.call(n))),l=n.icon?o.h("div",{class:[`${r}-spin-body`,this.themeClass]},o.h("div",{class:[`${r}-spin`,s&&`${r}-spin--rotate`],style:n.default?"":this.cssVars},n.icon()),a):o.h("div",{class:[`${r}-spin-body`,this.themeClass]},o.h(Kh,{clsPrefix:r,style:n.default?"":this.cssVars,stroke:this.stroke,"stroke-width":this.mergedStrokeWidth,class:`${r}-spin`}),a);return(t=this.onRender)===null||t===void 0||t.call(this),n.default?o.h("div",{class:[`${r}-spin-container`,this.themeClass],style:this.cssVars},o.h("div",{class:[`${r}-spin-content`,this.active&&`${r}-spin-content--spinning`,this.contentClass],style:this.contentStyle},n),o.h(o.Transition,{name:"fade-in-transition"},{default:()=>this.active?l:null})):l}}),hv='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M512 240c0 114.9-114.6 208-256 208c-37.1 0-72.3-6.4-104.1-17.9c-11.9 8.7-31.3 20.6-54.3 30.6C73.6 471.1 44.7 480 16 480c-6.5 0-12.3-3.9-14.8-9.9c-2.5-6-1.1-12.8 3.4-17.4c0 0 0 0 0 0s0 0 0 0s0 0 0 0c0 0 0 0 0 0l.3-.3c.3-.3 .7-.7 1.3-1.4c1.1-1.2 2.8-3.1 4.9-5.7c4.1-5 9.6-12.4 15.2-21.6c10-16.6 19.5-38.4 21.4-62.9C17.7 326.8 0 285.1 0 240C0 125.1 114.6 32 256 32s256 93.1 256 208z"/></svg>',mv='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M137.4 374.6c12.5 12.5 32.8 12.5 45.3 0l128-128c9.2-9.2 11.9-22.9 6.9-34.9s-16.6-19.8-29.6-19.8L32 192c-12.9 0-24.6 7.8-29.6 19.8s-2.2 25.7 6.9 34.9l128 128z"/></svg>',vv='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M96 128a128 128 0 1 1 256 0A128 128 0 1 1 96 128zM0 482.3C0 383.8 79.8 304 178.3 304l91.4 0C368.2 304 448 383.8 448 482.3c0 16.4-13.3 29.7-29.7 29.7L29.7 512C13.3 512 0 498.7 0 482.3zM625 177L497 305c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L591 143c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"/></svg>',gv='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M144 0a80 80 0 1 1 0 160A80 80 0 1 1 144 0zM512 0a80 80 0 1 1 0 160A80 80 0 1 1 512 0zM0 298.7C0 239.8 47.8 192 106.7 192l42.7 0c15.9 0 31 3.5 44.6 9.7c-1.3 7.2-1.9 14.7-1.9 22.3c0 38.2 16.8 72.5 43.3 96c-.2 0-.4 0-.7 0L21.3 320C9.6 320 0 310.4 0 298.7zM405.3 320c-.2 0-.4 0-.7 0c26.6-23.5 43.3-57.8 43.3-96c0-7.6-.7-15-1.9-22.3c13.6-6.3 28.7-9.7 44.6-9.7l42.7 0C592.2 192 640 239.8 640 298.7c0 11.8-9.6 21.3-21.3 21.3l-213.3 0zM224 224a96 96 0 1 1 192 0 96 96 0 1 1 -192 0zM128 485.3C128 411.7 187.7 352 261.3 352l117.3 0C452.3 352 512 411.7 512 485.3c0 14.7-11.9 26.7-26.7 26.7l-330.7 0c-14.7 0-26.7-11.9-26.7-26.7z"/></svg>',Vi='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"/></svg>',bv='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"/></svg>',yv='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M64 360a56 56 0 1 0 0 112 56 56 0 1 0 0-112zm0-160a56 56 0 1 0 0 112 56 56 0 1 0 0-112zM120 96A56 56 0 1 0 8 96a56 56 0 1 0 112 0z"/></svg>',st={comment:hv,caretDown:mv,internal:vv,external:gv,markDone:Vi,acceptChange:Vi,rejectChange:bv,overflow:yv},$e=Object.freeze({RESOLVE_OWN:"RESOLVE_OWN",RESOLVE_OTHER:"RESOLVE_OTHER",REJECT_OWN:"REJECT_OWN",REJECT_OTHER:"REJECT_OTHER",COMMENTS_OVERFLOW_OWN:"COMMENTS_OVERFLOW",COMMENTS_OVERFLOW_OTHER:"COMMENTS_OVERFLOW_OTHER",COMMENTS_DELETE_OWN:"COMMENTS_DELETE_OWN",COMMENTS_DELETE_OTHER:"COMMENTS_DELETE_OTHER",UPLOAD_VERSION:"UPLOAD_VERSION",VERSION_HISTORY:"VERSION_HISTORY"}),ve=Object.freeze({EDITOR:"editor",SUGGESTER:"suggester",VIEWER:"viewer"}),wv=Object.freeze({[$e.RESOLVE_OWN]:{internal:[ve.EDITOR],external:[ve.EDITOR]},[$e.RESOLVE_OTHER]:{internal:[ve.EDITOR],external:[]},[$e.REJECT_OWN]:{internal:[ve.EDITOR,ve.SUGGESTER],external:[ve.EDITOR,ve.SUGGESTER]},[$e.REJECT_OTHER]:{internal:[ve.EDITOR],external:[]},[$e.COMMENTS_OVERFLOW_OWN]:{internal:[ve.EDITOR,ve.SUGGESTER],external:[ve.EDITOR,ve.SUGGESTER]},[$e.COMMENTS_OVERFLOW_OTHER]:{internal:[ve.EDITOR],external:[]},[$e.COMMENTS_DELETE_OWN]:{internal:[ve.EDITOR,ve.SUGGESTER],external:[ve.EDITOR,ve.SUGGESTER]},[$e.COMMENTS_DELETE_OTHER]:{internal:[ve.EDITOR],external:[]},[$e.UPLOAD_VERSION]:{internal:[ve.EDITOR],external:[]},[$e.VERSION_HISTORY]:{internal:[ve.EDITOR],external:[]}}),Vt=(e,t,n)=>{const r=n?"internal":"external";return wv[e]?.[r]?.includes(t)},Se=(e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n},Cv={class:"user-container"},xv=["src"],Ev={key:1,class:"user-bg"},Sv={__name:"Avatar",props:{user:{type:Object,required:!0}},setup(e){const t=(n,r)=>!n&&!r?void 0:n?.substring(0,1)||r?.substring(0,1)||null;return(n,r)=>(o.openBlock(),o.createElementBlock("div",Cv,[e.user.image?(o.openBlock(),o.createElementBlock("img",{key:0,class:"user-bg",src:e.user.image.startsWith("http")?e.user.image:`data:image/png;base64,${e.user.image}`},null,8,xv)):(o.openBlock(),o.createElementBlock("span",Ev,o.toDisplayString(t(e.user.name,e.user.email)),1))]))}},kv=Se(Sv,[["__scopeId","data-v-53e13009"]]),_v={class:"comment-option"},$v=["innerHTML"],Tv={class:"option-state"},Iv=["innerHTML"],Ov={__name:"InternalDropdown",props:{state:{type:String,required:!1},isDisabled:{type:Boolean,default:!1}},emits:["select"],setup(e,{emit:t}){const n=t,r=e,i=p=>()=>o.h("div",{innerHTML:p,class:"internal-dropdown__item-icon"}),s=[{label:"Internal",key:"internal",icon:i(st.internal),iconString:st.internal,backgroundColor:"#CDE6E6"},{label:"External",key:"external",icon:i(st.external),iconString:st.external,backgroundColor:"#F5CFDA"}],a=o.computed(()=>s.find(p=>p.key===u.value)?.label),l=o.computed(()=>{if(!r.state)return{};const p=s.find(b=>b.key===u.value);if(!p)return{};const h={backgroundColor:p.backgroundColor};return r.isDisabled&&(h.opacity=.5,h.cursor="default"),h}),c=(p,h=!1)=>{u.value=p,d.value=s.find(b=>b.key===p)?.iconString,!h&&n("select",p)},u=o.ref(r.state),d=o.ref(null);return o.watch(()=>r.state,p=>{c(p)}),o.onMounted(()=>{c(r.state,!0)}),(p,h)=>(o.openBlock(),o.createElementBlock("div",{class:"internal-dropdown",style:o.normalizeStyle(l.value)},[o.createVNode(o.unref(Oa),{trigger:"click",options:s,onSelect:h[0]||(h[0]=b=>c(b)),disabled:e.isDisabled},{default:o.withCtx(()=>[o.createBaseVNode("div",_v,[o.createBaseVNode("div",{class:"active-icon",innerHTML:d.value},null,8,$v),o.createBaseVNode("div",Tv,o.toDisplayString(a.value),1),o.createBaseVNode("div",{class:"dropdown-caret",innerHTML:o.unref(st).caretDown},null,8,Iv)])]),_:1},8,["disabled"])],4))}},Bv=Se(Ov,[["__scopeId","data-v-c42ece92"]]);function Pv(e){const t=new Date(e),n=t.getHours(),r=t.getMinutes(),i=n>=12?"PM":"AM",s=n%12||12,l=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()],c=t.getDate();return`${`${s}:${r.toString().padStart(2,"0")}${i}`} ${l} ${c}`}const Dv={class:"card-section comment-header"},Rv={class:"comment-header-left"},Av={class:"user-info"},Mv={class:"user-name"},Nv={key:0,class:"user-timestamp"},Fv={class:"overflow-menu"},zv=["innerHTML"],Lv=["innerHTML"],Hv=["innerHTML"],Vv={__name:"CommentHeader",props:{timestamp:{type:Number,required:!1},config:{type:Object,required:!0},comment:{type:Object,required:!1},isPendingInput:{type:Boolean,required:!1,default:!1}},emits:["resolve","reject","overflow-select"],setup(e,{emit:t}){const n=t,r=at(),i=e,{proxy:s}=o.getCurrentInstance(),a=s.$superdoc.config.role,l=s.$superdoc.config.isInternal,c=i.comment.creatorEmail===s.$superdoc.config.user.email,u=Object.freeze({edit:{label:"Edit",key:"edit"},delete:{label:"Delete",key:"delete"}}),d=o.computed(()=>!(!i.comment||i.comment.resolvedTime||r.pendingComment||i.isPendingInput)),p=o.computed(()=>!d.value||i.comment.parentCommentId?!1:Vt(c?$e.RESOLVE_OWN:$e.RESOLVE_OTHER,a,l)),h=o.computed(()=>!d.value||!i.comment.trackedChange?!1:Vt(c?$e.REJECT_OWN:$e.REJECT_OTHER,a,l)),b=o.computed(()=>!(!d.value||i.comment.trackedChange||i.isPendingInput||m.value.length===0)),m=o.computed(()=>{if(!d.value)return!1;const B=[],S=new Set;i.comment.creatorEmail===s.$superdoc.config.user.email&&S.add("edit");const O=i.comment.creatorEmail===s.$superdoc.config.user.email;return(O&&Vt($e.COMMENTS_DELETE_OWN,a,l)||!O&&Vt($e.COMMENTS_DELETE_OTHER,a,l))&&S.add("delete"),S.forEach(T=>B.push(u[T])),B}),C=()=>n("resolve"),w=()=>n("reject"),v=B=>n("overflow-select",B),I=o.computed(()=>i.isPendingInput?s.$superdoc.config.user:i.comment.getCommentUser());return(B,S)=>(o.openBlock(),o.createElementBlock("div",Dv,[o.createBaseVNode("div",Rv,[o.createVNode(kv,{user:I.value,class:"avatar"},null,8,["user"]),o.createBaseVNode("div",Av,[o.createBaseVNode("div",Mv,o.toDisplayString(I.value.name),1),i.comment.createdTime?(o.openBlock(),o.createElementBlock("div",Nv,o.toDisplayString(o.unref(Pv)(i.comment.createdTime)),1)):o.createCommentVNode("",!0)])]),o.createBaseVNode("div",Fv,[p.value?(o.openBlock(),o.createElementBlock("div",{key:0,class:"overflow-menu__icon",innerHTML:o.unref(st).markDone,onClick:o.withModifiers(C,["stop","prevent"])},null,8,zv)):o.createCommentVNode("",!0),h.value?(o.openBlock(),o.createElementBlock("div",{key:1,class:"overflow-menu__icon",innerHTML:o.unref(st).rejectChange,onClick:o.withModifiers(w,["stop","prevent"])},null,8,Lv)):o.createCommentVNode("",!0),b.value?(o.openBlock(),o.createBlock(o.unref(Oa),{key:2,trigger:"click",options:m.value,onSelect:v},{default:o.withCtx(()=>[o.createBaseVNode("div",{class:"overflow-menu__icon",onClick:S[0]||(S[0]=o.withModifiers(()=>{},["stop","prevent"]))},[o.createBaseVNode("div",{class:"overflow-icon",innerHTML:o.unref(st).overflow},null,8,Hv)])]),_:1},8,["options"])):o.createCommentVNode("",!0)])]))}},Ba=Se(Vv,[["__scopeId","data-v-7e86617a"]]),jv={class:"input-section"},Uv={__name:"CommentInput",props:{users:{type:Array,required:!1,default:()=>[]},config:{type:Object,required:!0},isFocused:{type:Boolean,default:!1},includeHeader:{type:Boolean,default:!0},comment:{type:Object,required:!1}},emits:["focus"],setup(e,{emit:t}){const n=t;Qe();const r=at(),{currentCommentText:i}=Ve(r),s=a=>n("focus",a);return(a,l)=>(o.openBlock(),o.createElementBlock("div",jv,[e.includeHeader?(o.openBlock(),o.createBlock(Ba,{key:0,config:e.config,comment:e.comment,"is-pending-input":!0},null,8,["config","comment"])):o.createCommentVNode("",!0),o.createBaseVNode("div",{class:o.normalizeClass(["comment-entry",{"input-active":e.isFocused}])},[o.createVNode(o.unref(Ce.vo),{class:"superdoc-field",placeholder:"Add a comment",modelValue:o.unref(i),"onUpdate:modelValue":l[0]||(l[0]=c=>o.isRef(i)?i.value=c:null),users:e.users,onFocus:l[1]||(l[1]=c=>s(!0)),onBlur:l[2]||(l[2]=c=>s(!1))},null,8,["modelValue","users"])],2)]))}},ji=Se(Uv,[["__scopeId","data-v-76d953bd"]]),Wv={key:0,class:"existing-internal-input"},Kv={key:0,class:"card-section comment-body"},Gv={class:"tracked-change"},qv={class:"tracked-change"},Xv={key:0},Yv={class:"tracked-change-text"},Jv={key:1},Zv={class:"tracked-change-text"},Qv={key:2},eg={class:"tracked-change-text"},tg={key:1,class:"card-section comment-body"},ng=["innerHTML"],og={key:1,class:"comment"},rg={key:2,class:"comment-editing"},ig={class:"comment-footer"},sg=["onClick"],ag=["onClick"],lg={key:2,class:"comment-separator"},cg={key:1},ug={key:0,class:"comment-footer"},dg=["disabled"],fg={__name:"CommentDialog",props:{comment:{type:Object,required:!0},autoFocus:{type:Boolean,default:!1},parent:{type:Object,required:!1}},emits:["click-outside","ready","dialog-exit"],setup(e,{emit:t}){const n=t,r=e,{proxy:i}=o.getCurrentInstance();i.$superdoc.config.role,r.comment.email;const s=Qe(),a=at(),{addComment:l,cancelComment:c,deleteComment:u,removePendingComment:d}=a,{suppressInternalExternal:p,getConfig:h,activeComment:b,floatingCommentsOffset:m,pendingComment:C,currentCommentText:w,isDebugging:v,editingCommentId:I,editorCommentPositions:B}=Ve(a),{activeZoom:S}=Ve(s),O=o.ref(!0);o.ref(!1);const T=o.ref(null),f=o.ref(null),y=o.computed(()=>b.value===r.comment.commentId),$=o.computed(()=>!h.readOnly&&y.value&&!r.comment.resolvedTime&&I.value!==r.comment.commentId),g=o.computed(()=>X=>E.value&&X===k.value.length-1?!0:k.value.length>1&&X!==k.value.length-1),E=o.computed(()=>!h.readOnly&&y.value&&!r.comment.resolvedTime&&I.value!==r.comment.commentId),k=o.computed(()=>{const X=r.comment;return a.commentsList.filter(J=>{const ye=J.parentCommentId===X.commentId,ie=J.commentId===r.comment.commentId;return ye||ie}).sort((J,ye)=>J.commentId===r.comment.commentId&&J.createdTime-ye.createdTime)}),N=o.computed(()=>r.comment.resolvedTime?!0:h.value.readOnly),P=o.computed(()=>X=>I.value===X.commentId),x=o.computed(()=>i.$superdoc.config.isInternal?!p.value&&!r.comment.trackedChange:!1),D=o.computed(()=>w.value&&w.value!=="<p></p>"),A=()=>{r.comment.resolvedTime||(b.value=r.comment.commentId,r.comment.setActive(i.$superdoc))},z=X=>{X.target.classList.contains("n-dropdown-option-body__label")||X.target.classList.contains("comment-highlight")||(b.value===r.comment.commentId&&(m.value=0,n("dialog-exit")),b.value=null)},F=()=>{const X={documentId:r.comment.fileId,isInternal:C.value?C.value.isInternal:O.value,parentCommentId:C.value?null:r.comment.commentId};if(C.value){const ye=C.value.selection.getValues();X.selection=ye}const J=a.getPendingComment(X);l({superdoc:i.$superdoc,comment:J})},W=()=>{r.comment.trackedChange?(r.comment.resolveComment({email:s.user.email,name:s.user.name,superdoc:i.$superdoc}),i.$superdoc.activeEditor.commands.rejectTrackedChangeById(r.comment.commentId)):a.deleteComment({superdoc:i.$superdoc,commentId:r.comment.commentId}),o.nextTick(()=>{a.lastUpdate=new Date,b.value=null})},Y=()=>{r.comment.trackedChange&&i.$superdoc.activeEditor.commands.acceptTrackedChangeById(r.comment.commentId),r.comment.resolveComment({email:s.user.email,name:s.user.name,superdoc:i.$superdoc}),o.nextTick(()=>{a.lastUpdate=new Date,b.value=null})},ne=(X,J)=>{switch(X){case"edit":w.value=J.commentText,b.value=J.commentId,I.value=J.commentId;break;case"delete":u({superdoc:i.$superdoc,commentId:J.commentId});break}},ce=X=>{I.value=null,X.setText({text:w.value,superdoc:i.$superdoc}),d(i.$superdoc)},me=X=>{const J=!!C.value,ye=X.toLowerCase()==="internal";J?C.value.isInternal=ye:r.comment.setIsInternal({isInternal:ye,superdoc:i.$superdoc})},Be=o.computed(()=>{const X={};if(r.comment,y.value&&(X.backgroundColor="white",X.zIndex=50),C.value&&C.value.commentId===r.comment.commentId){const J=Math.max(96,C.value.selection?.selectionBounds.top-50);X.position="absolute",X.top=J+"px"}return X}),he=X=>typeof X=="string"?new Date(X).getTime():X,oe=X=>{I.value=null,c(i.$superdoc)},Ae=o.computed(()=>{const X=i.$superdoc.users;return r.comment.isInternal===!0?X.filter(J=>J.access?.role==="internal"):X});return o.onMounted(()=>{r.autoFocus&&o.nextTick(()=>A()),o.nextTick(()=>{const X=r.comment.importedId!==void 0?r.comment.importedId:r.comment.commentId;n("ready",{commentId:X,elementRef:f})})}),(X,J)=>{const ye=o.resolveDirective("click-outside");return o.withDirectives((o.openBlock(),o.createElementBlock("div",{class:o.normalizeClass(["comments-dialog",{"is-active":y.value,"is-resolved":r.comment.resolvedTime}]),onClick:o.withModifiers(A,["stop","prevent"]),style:o.normalizeStyle(Be.value),ref_key:"commentDialogElement",ref:f},[x.value?(o.openBlock(),o.createElementBlock("div",Wv,[o.createVNode(Bv,{onClick:J[0]||(J[0]=o.withModifiers(()=>{},["stop","prevent"])),class:"internal-dropdown","is-disabled":N.value,state:e.comment.isInternal?"internal":"external",onSelect:me},null,8,["is-disabled","state"])])):o.createCommentVNode("",!0),(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(k.value,(ie,Me)=>(o.openBlock(),o.createElementBlock("div",{key:Me,class:"conversation-item"},[o.createVNode(Ba,{config:o.unref(h),timestamp:he(ie.createdTime),comment:ie,onResolve:Y,onReject:W,onOverflowSelect:Ke=>ne(Ke,ie)},null,8,["config","timestamp","comment","onOverflowSelect"]),ie.trackedChange?(o.openBlock(),o.createElementBlock("div",Kv,[o.createBaseVNode("div",Gv,[o.createBaseVNode("div",qv,[ie.trackedChangeType==="trackFormat"?(o.openBlock(),o.createElementBlock("div",Xv,[J[2]||(J[2]=o.createBaseVNode("span",{class:"change-type"},"Format: ",-1)),o.createBaseVNode("span",Yv,o.toDisplayString(ie.trackedChangeText),1)])):o.createCommentVNode("",!0),ie.trackedChangeText&&ie.trackedChangeType!=="trackFormat"?(o.openBlock(),o.createElementBlock("div",Jv,[J[3]||(J[3]=o.createBaseVNode("span",{class:"change-type"},"Added: ",-1)),o.createBaseVNode("span",Zv,o.toDisplayString(ie.trackedChangeText),1)])):o.createCommentVNode("",!0),ie.deletedText&&ie.trackedChangeType!=="trackFormat"?(o.openBlock(),o.createElementBlock("div",Qv,[J[4]||(J[4]=o.createBaseVNode("span",{class:"change-type"},"Deleted: ",-1)),o.createBaseVNode("span",eg,o.toDisplayString(ie.deletedText),1)])):o.createCommentVNode("",!0)])])])):o.createCommentVNode("",!0),ie.trackedChange?o.createCommentVNode("",!0):(o.openBlock(),o.createElementBlock("div",tg,[!o.unref(v)&&!P.value(ie)?(o.openBlock(),o.createElementBlock("div",{key:0,class:"comment",innerHTML:ie.commentText},null,8,ng)):o.unref(v)&&!P.value(ie)?(o.openBlock(),o.createElementBlock("div",og,o.toDisplayString(o.unref(B)[ie.importedId!==void 0?ie.importedId:ie.commentId]?.bounds),1)):(o.openBlock(),o.createElementBlock("div",rg,[o.createVNode(ji,{users:Ae.value,config:o.unref(h),"include-header":!1,comment:ie},null,8,["users","config","comment"]),o.createBaseVNode("div",ig,[o.createBaseVNode("button",{class:"sd-button",onClick:o.withModifiers(Ke=>oe(),["stop","prevent"])},"Cancel",8,sg),o.createBaseVNode("button",{class:"sd-button primary",onClick:o.withModifiers(Ke=>ce(ie),["stop","prevent"])}," Update ",8,ag)])]))])),g.value(Me)?(o.openBlock(),o.createElementBlock("div",lg)):o.createCommentVNode("",!0)]))),128)),E.value&&!o.unref(h).readOnly?(o.openBlock(),o.createElementBlock("div",cg,[o.createVNode(ji,{ref_key:"commentInput",ref:T,users:Ae.value,config:o.unref(h),comment:r.comment},null,8,["users","config","comment"]),$.value&&!o.unref(h).readOnly?(o.openBlock(),o.createElementBlock("div",ug,[o.createBaseVNode("button",{class:"sd-button",onClick:J[1]||(J[1]=o.withModifiers((...ie)=>o.unref(c)&&o.unref(c)(...ie),["stop","prevent"]))},"Cancel"),o.createBaseVNode("button",{class:o.normalizeClass(["sd-button primary",{disabled:!D.value}]),onClick:o.withModifiers(F,["stop","prevent"]),disabled:!D.value}," Comment ",10,dg)])):o.createCommentVNode("",!0)])):o.createCommentVNode("",!0)],6)),[[ye,z]])}}},vn=Se(fg,[["__scopeId","data-v-afaf943d"]]),pg={class:"comments-list"},hg={key:0},mg={class:"comment-item"},vg={key:1},gg={class:"comment-item"},bg={__name:"commentsList",props:{showMainComments:{type:Boolean,default:!0},showResolvedComments:{type:Boolean,default:!0}},setup(e){const t=e;Qe();const n=at(),{COMMENT_EVENTS:r}=n,{commentsList:i,getGroupedComments:s,isCommentsListVisible:a}=Ve(n),{proxy:l}=o.getCurrentInstance(),c=o.computed(()=>t.showResolvedComments&&s.value?.resolvedComments?.length>0);return o.onMounted(()=>{a.value=!0}),o.onBeforeUnmount(()=>{a.value=!1}),(u,d)=>(o.openBlock(),o.createElementBlock("div",pg,[e.showMainComments?(o.openBlock(),o.createElementBlock("div",hg,[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(o.unref(s).parentComments,p=>(o.openBlock(),o.createElementBlock("div",mg,[o.createVNode(vn,{comment:p},null,8,["comment"])]))),256))])):o.createCommentVNode("",!0),c.value?(o.openBlock(),o.createElementBlock("div",vg,[d[0]||(d[0]=o.createBaseVNode("div",{class:"comment-title"},"Resolved",-1)),(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(o.unref(s).resolvedComments,p=>(o.openBlock(),o.createElementBlock("div",gg,[o.createVNode(vn,{comment:p},null,8,["comment"])]))),256))])):o.createCommentVNode("",!0)]))}},yg=Se(bg,[["__scopeId","data-v-12d3e3dd"]]);class wg extends qi.EventEmitter{element;config={comments:[],element:null,commentsStore:null};constructor(t,n){super(),this.config={...this.config,...t},this.element=this.config.element,this.app=null,this.superdoc=n,this.open()}createVueApp(){this.app=o.createApp(yg),this.app.directive("click-outside",Zi),this.app.config.globalProperties.$superdoc=this.superdoc,!this.element&&this.config.selector&&(this.element=document.getElementById(this.config.selector)),this.container=this.app.mount(this.element)}close(){this.app&&(this.app.unmount(),this.app=null,this.container=null,this.element=null)}open(){this.app||this.createVueApp()}}const Cg=(e,t)=>{const n=t-e;return Array.from({length:n},(r,i)=>e+i)},xg={key:0,class:"superdoc-pdf-viewer__loader"},Eg={__name:"PdfViewer",props:{documentData:{type:Object,required:!0}},emits:["page-loaded","ready","selection-change","bypass-selection"],setup(e,{emit:t}){const n=t,r=Qe(),{proxy:i}=o.getCurrentInstance(),{activeZoom:s}=Ve(r),a=o.ref(null),l=o.ref(null),c=o.ref(!1),d=i.$superdoc.config.pdfViewer.textLayerMode??0;let p=null,h=[];const b=e,m=b.documentData.id,C=b.documentData.data,w=E=>{const k=E.getViewport({scale:1}),N=k.width,P=k.height;return{width:N,height:P}};async function v(){i?.$superdoc?.config?.pdfjsWorkerSrcUrl&&(kr.GlobalWorkerOptions.workerSrc=i.$superdoc.config.pdfjsWorkerSrcUrl)}async function I(E){await v();const k=kr.getDocument(E),N=await k.promise;return{loadingTask:k,document:N}}async function B(E){const k=new FileReader;k.onload=async function(N){const{loadingTask:P,document:x}=await I(N.target.result);p=x,S(x)},k.readAsArrayBuffer(E)}const S=E=>{setTimeout(()=>{T(E)},150)};async function O(E,k,N){const P=Cg(k,N+1).map(x=>E.getPage(x));return await Promise.all(P)}async function T(E){try{const k=E.numPages;a.value=k;const P=await O(E,1,k),x=[];for(const[D,A]of P.entries()){const z=document.createElement("div");z.className="pdf-page",z.dataset.pageNumber=D+1,z.id=`${m}-page-${D+1}`,x.push(z);const{width:F,height:W}=w(A),Y=1,ne=new _r.EventBus,ce=new _r.PDFPageView({container:z,id:D+1,scale:Y,defaultViewport:A.getViewport({scale:Y}),eventBus:ne,textLayerMode:d});h.push(ce);const me=z.getBoundingClientRect();me.originalWidth=F,me.originalHeight=W,ce.setPdfPage(A),await ce.draw(),n("page-loaded",m,D,me)}l.value.append(...x),c.value=!0,n("ready",m,l)}catch(k){console.error("Error loading PDF:",k)}}function f(E){const k=window.getSelection();if(k.rangeCount===0)return null;const P=k.getRangeAt(0).getClientRects();if(P.length===0)return null;const x=P[0];let D={top:x.top,left:x.left,bottom:x.bottom,right:x.right};for(let z=1;z<P.length;z++){const F=P[z];F.width===0||F.height===0||(D.top=Math.min(D.top,F.top),D.left=Math.min(D.left,F.left),D.bottom=Math.max(D.bottom,F.bottom),D.right=Math.max(D.right,F.right))}const A=E.getBoundingClientRect();return l.value.getBoundingClientRect(),D.top=(D.top-A.top)/(s.value/100)+E.scrollTop,D.left=(D.left-A.left)/(s.value/100)+E.scrollLeft,D.bottom=(D.bottom-A.top)/(s.value/100)+E.scrollTop,D.right=(D.right-A.left)/(s.value/100)+E.scrollLeft,D}const y=E=>{const{target:k}=E;k.tagName!=="SPAN"&&n("bypass-selection",E)},$=E=>{if(window.getSelection().toString().length>0){const N=f(l.value),P=dn({selectionBounds:N,documentId:m});n("selection-change",P)}},g=()=>{h.forEach(E=>E.destroy()),p.cleanup(),p.destroy(),h=[],p=null,URL.revokeObjectURL(workerUrl)};return o.onMounted(async()=>{await Promise.resolve().then(()=>require("./chunks/pdf_viewer-Dyvby5gX.cjs")),await B(C)}),o.onUnmounted(()=>{g()}),(E,k)=>(o.openBlock(),o.createElementBlock("div",{class:"superdoc-pdf-viewer-container",onMousedown:y,onMouseup:$},[o.createBaseVNode("div",{class:"superdoc-pdf-viewer",ref_key:"viewer",ref:l,id:"viewerId"},null,512),c.value?o.createCommentVNode("",!0):(o.openBlock(),o.createElementBlock("div",xg,[o.createVNode(o.unref(pv),{class:"superdoc-pdf-viewer__spin",size:"large"})]))],32))}},Sg=Se(Eg,[["__scopeId","data-v-a923bc7a"]]),kg={class:"comments-container",id:"commentsContainer"},_g={class:"comments-layer"},$g=["onClick","data-id"],Tg={__name:"CommentsLayer",props:{user:{type:Object,required:!0},parent:{type:Object,required:!0}},emits:["highlight-click"],setup(e,{expose:t,emit:n}){const r=Qe(),i=at(),{COMMENT_EVENTS:s}=i,{documentsWithConverations:a,activeComment:l,floatingCommentsOffset:c,commentsList:u}=Ve(i),{documents:d,activeZoom:p}=Ve(r),{proxy:h}=o.getCurrentInstance(),b=n,m=e,C=S=>{const O={creatorEmail:m.user.email,creatorName:m.user.name,documentId:S.documentId,selection:S,isFocused:!0},T=S.selectionBounds;if(T.top>T.bottom){const $=T.top;T.top=T.bottom,T.bottom=$}if(T.left>T.right){const $=T.left;T.left=T.right,T.right=$}S.selectionBounds=T;const f=d.value.find($=>$.id===S.documentId),y=St(O);l.value=y.commentId,f.conversations.push(y),h.$superdoc.emit("comments-update",{type:s.NEW,comment:y.getValues()})},w=S=>{const{selection:O,commentId:T}=S,f=O.getContainerLocation(m.parent),y=S.selection.selectionBounds;(parseFloat(y.top)+f.top)*p.value;const $="#078383",g="#B1124B";let E="33";l.value===T&&(E="66");let k=S.isInternal?$:g;return k+=E,{position:"absolute",top:parseFloat(y.top)+"px",left:y.left+"px",width:y.right-y.left+"px",height:y.bottom-y.top+"px",backgroundColor:k,pointerEvents:S.suppressClick?"none":"auto"}},v=S=>{c.value=S.selection.selectionBounds.top},I=(S,O)=>{S.isFocused=!0,l.value=S.commentId,S.setActive(h.$superdoc),b("highlight-click",S)},B=o.computed(()=>u.value.filter(S=>!S.parentCommentId).filter(S=>S.selection&&S.selection.selectionBounds?.top).filter(S=>!S.resolvedTime).filter(S=>S.selection?.source!=="super-editor"));return o.watch(l,S=>{if(!S)return;document.getElementById(S)?.scrollIntoView({behavior:"smooth",block:"center"})}),t({addCommentEntry:C,activateComment:I,setFloatingCommentOffset:v}),(S,O)=>(o.openBlock(),o.createElementBlock("div",kg,[o.createBaseVNode("div",_g,[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(B.value,T=>(o.openBlock(),o.createElementBlock("div",{class:"comment-anchor sd-highlight",onClick:o.withModifiers(f=>I(T),["stop","prevent"]),"data-id":T.commentId,style:o.normalizeStyle(w(T))},null,12,$g))),256))])]))}},Ig=Se(Tg,[["__scopeId","data-v-fbd54adc"]]),Og={class:"sidebar-container calculation-container"},Bg=["id"],Pg={__name:"FloatingComments",props:{currentDocument:{type:Object,required:!0},parent:{type:Object,required:!0}},setup(e){const t=e;Qe();const n=at(),{getFloatingComments:r,hasInitializedLocations:i,activeComment:s,commentsList:a,editorCommentPositions:l}=Ve(n),c=o.ref(null),u=o.ref([]),d=o.ref(!1),p=o.ref(0),h=o.ref(0),b=o.computed(()=>v=>c.value?(c.value.getBoundingClientRect(),typeof v.top!="number"||isNaN(v.top)?{display:"none"}:{top:`${v.top}px`}):{top:"0px"}),m=v=>{if(!v)return window;let I=v.parentNode;for(;I&&I!==document;){const B=getComputedStyle(I);if(/(auto|scroll|overlay)/.test(B.overflow+B.overflowY+B.overflowX))return I;I=I.parentNode}return window},C=v=>{if(!v)return;const{elementRef:I,commentId:B}=v;I&&o.nextTick(()=>{const S=B;if(u.value.some(E=>E.id==S))return;const O=r.value.find(E=>E.commentId===S||E.importedId==S),T=l.value[S]?.bounds;if(!T)return;const f=m(t.parent);f===window?window.scrollY:f.scrollTop;const y=t.parent.getBoundingClientRect(),$=I.value?.getBoundingClientRect(),g={id:S,top:T.top-y.top,height:$.height,commentRef:O,elementRef:I};u.value.push(g)})},w=async()=>{let v=0;u.value.sort((I,B)=>I.top-B.top).forEach(I=>{I.top<=v+15&&(I.top=v+15),v=I.top+I.height}),await o.nextTick(),d.value=!0};return o.watchEffect(()=>{u.value.length===r.value.length&&o.nextTick(w)}),o.watch(s,(v,I)=>{o.nextTick(()=>{if(!s.value)return p.value=0;const B=n.getComment(s.value);if(!B)return p.value=0;const S=u.value.find(f=>f.id===B.commentId);if(!S)return p.value=0;const O=B.selection.selectionBounds.top,T=S.top;c.value.getBoundingClientRect(),p.value=O-T,setTimeout(()=>{S.elementRef.value?.scrollIntoView({behavior:"smooth",block:"center"})},200)})}),(v,I)=>(o.openBlock(),o.createElementBlock("div",{class:"section-wrapper",ref_key:"floatingCommentsContainer",ref:c},[o.createBaseVNode("div",Og,[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(o.unref(r),B=>(o.openBlock(),o.createElementBlock("div",{key:B.commentId||B.importedId},[o.createBaseVNode("div",{id:B.commentId||B.importedId,class:"measure-comment"},[(o.openBlock(),o.createBlock(vn,{onReady:C,key:B.commentId+h.value,class:"floating-comment",parent:e.parent,comment:B},null,8,["parent","comment"]))],8,Bg)]))),128))]),d.value?(o.openBlock(),o.createElementBlock("div",{key:0,class:"sidebar-container",style:o.normalizeStyle({top:p.value+"px"})},[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(u.value,B=>(o.openBlock(),o.createElementBlock("div",{key:B.id,style:o.normalizeStyle(b.value(B)),class:"floating-comment"},[(o.openBlock(),o.createBlock(vn,{key:B.id+h.value,class:"floating-comment",parent:e.parent,comment:B.commentRef},null,8,["parent","comment"]))],4))),128))],4)):o.createCommentVNode("",!0)],512))}},Dg=Se(Pg,[["__scopeId","data-v-76d3706b"]]),Rg={__name:"TextField",props:{field:{type:Object,required:!0},isEditing:{type:Boolean,required:!1,default:!1},styleOverride:{type:Object,required:!1,default:()=>({})}},setup(e){const t=e,n=o.computed(()=>{const r={...t.styleOverride};return t.isEditing&&(r.backgroundColor="#FFF"),r});return(r,i)=>(o.openBlock(),o.createElementBlock("div",{class:"text-field",style:o.normalizeStyle(n.value)},o.toDisplayString(e.field.value||e.field.placeholder),5))}},Ag=Se(Rg,[["__scopeId","data-v-f3984d30"]]),Mg=["innerHTML"],Ng={key:1},Fg={__name:"ParagraphField",props:{field:{type:Object,required:!0},isEditing:{type:Boolean,required:!1,default:!1},styleOverride:{type:Object,required:!1,default:()=>({})}},setup(e){const t=e,n=o.computed(()=>({fontSize:`${(t.styleOverride?.originalFontSize||120)/10}px`}));return(r,i)=>e.field.value?(o.openBlock(),o.createElementBlock("div",{key:0,class:"paragraph-field",style:o.normalizeStyle(n.value),innerHTML:e.field.value},null,12,Mg)):(o.openBlock(),o.createElementBlock("span",Ng,o.toDisplayString(e.field.placeholder||e.field.label),1))}},zg=Se(Fg,[["__scopeId","data-v-98d7a2df"]]),Lg=["src"],Hg={key:1},Vg={__name:"ImageField",props:{field:{type:Object,required:!0},isEditing:{type:Boolean,required:!1,default:!1},styleOverride:{type:Object,required:!1,default:()=>({})},optionId:{type:String,required:!0},noStyle:{type:Boolean,required:!1,default:!1}},setup(e){const t=e,n=o.computed(()=>({maxHeight:t.styleOverride.coordinates?.minHeight,maxWidth:t.styleOverride.coordinates?.minWidth})),r=o.computed(()=>{if(t.field.valueGetter&&typeof t.field.valueGetter=="function")return t.field.valueGetter({annotationId:t.optionId});if(typeof t.field.value=="string")return t.field.value});return(i,s)=>(o.openBlock(),o.createElementBlock("div",{class:"image-field",style:o.normalizeStyle(n.value)},[e.field.value&&r.value?(o.openBlock(),o.createElementBlock("img",{key:0,src:r.value,alt:"image",style:o.normalizeStyle(n.value)},null,12,Lg)):e.noStyle?o.createCommentVNode("",!0):(o.openBlock(),o.createElementBlock("span",Hg,o.toDisplayString(e.field.placeholder||e.field.label),1))],4))}},Ui=Se(Vg,[["__scopeId","data-v-7dd69850"]]),jg={class:"checkbox-container"},Ug={__name:"CheckboxField",props:{field:{type:Object,required:!0},isEditing:{type:Boolean,required:!1,default:!1},optionId:{type:String,required:!0}},setup(e){const t=e,n=o.computed(()=>t.field.options.find(i=>i.annotationId.includes(t.optionId))?.checked);return(r,i)=>(o.openBlock(),o.createElementBlock("div",jg,[o.createVNode(o.unref(Um),{checked:n.value,disabled:!t.isEditing},null,8,["checked","disabled"])]))}},Wg=Se(Ug,[["__scopeId","data-v-fc53fd29"]]),Kg={key:0},Gg={__name:"SelectField",props:{field:{type:Object,required:!0},fieldStyle:{type:Object,required:!1,default:()=>({})},styleOverride:{type:Object,required:!1,default:()=>({})}},setup(e){const t=e,n=o.computed(()=>{if(!t.isEditing)return{...t.styleOverride}});return(r,i)=>(o.openBlock(),o.createElementBlock("div",{style:o.normalizeStyle(n.value),class:"select-container"},[t.isEditing?o.createCommentVNode("",!0):(o.openBlock(),o.createElementBlock("div",Kg,o.toDisplayString(e.field.value||e.field.placeholder),1))],4))}},qg=Se(Gg,[["__scopeId","data-v-b8cacb22"]]),Xg=or("hrbr-fields",()=>{const e=Qe(),{documents:t,pages:n}=Ve(e),r=o.reactive({name:"hrbr-fields"}),i=Object.freeze({TEXTINPUT:o.markRaw(Ag),HTMLINPUT:o.markRaw(zg),SELECT:o.markRaw(qg),CHECKBOXINPUT:o.markRaw(Wg),SIGNATUREINPUT:o.markRaw(Ui),IMAGEINPUT:o.markRaw(Ui)}),s=(c,u)=>{const d=t.value.find(h=>h.id===c);if(!d)return;const p=d.fields.find(h=>h.id===u);if(p)return p},a=o.computed(()=>{const c=[];return t.value.forEach(u=>{const{id:d,annotations:p}=u,h=u.container;if(!h)return;const b=h.getBoundingClientRect(),m=u.pageContainers;!b||!m||p.forEach(C=>{const{itemid:w,page:v,nostyle:I}=C;let B=C.pageannotation;C.itemfieldtype==="CHECKBOXINPUT"&&(B=C.annotationid);const{x1:S,y1:O,x2:T,y2:f}=C,y={x1:S,y1:O,x2:T,y2:f},$=document.getElementById(`${d}-page-${v+1}`);if(!$)return;const g=$.getBoundingClientRect(),E=u.pageContainers.find(z=>z.page===v+1),k=g.height/E.containerBounds.originalHeight,N=g.bottom-b.top,P=g.left-b.left,x=l(y,k,N,P),D={fontSize:C.original_font_size+"px",originalFontSize:C.original_font_size,coordinates:x},A={documentId:d,fieldId:w,page:v,annotationId:B,originalAnnotationId:C.originalannotationid,coordinates:x,style:D,nostyle:I??!1};c.push(A)})}),c}),l=(c,u,d,p)=>{const{x1:h,y1:b,x2:m,y2:C}=c,w=h*u,v=b*u,I=m*u,B=C*u;return{top:`${d-B}px`,left:`${w+p}px`,minWidth:`${I-w}px`,minHeight:`${B-v}px`}};return{hrbrFieldsConfig:r,fieldComponentsMap:i,getAnnotations:a,getField:s}}),Yg={class:"main-container"},Jg={__name:"HrbrFieldsLayer",props:{fields:{type:Object,required:!0}},setup(e){const t=Xg(),{getAnnotations:n}=Ve(t),{fieldComponentsMap:r,getField:i}=t,s=o.computed(()=>l=>{const{coordinates:c,field:u}=l;if(["TEXTINPUT","SELECT"].includes(u.fieldType)){const b=c.top.split("px")[0]-4;c.top=`${b}px`}if(["HTMLINPUT"].includes(u.fieldType)){const m=c.minWidth.split("px")[0]/1.3362445414847162;c.width=`${m}px`}return{position:"absolute",...c,lineHeight:1}}),a=o.computed(()=>{const l=[];return n.value.forEach(c=>{const u=i(c.documentId,c.fieldId);u&&l.push({...c,field:u})}),l});return(l,c)=>(o.openBlock(),o.createElementBlock("div",Yg,[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(a.value,u=>(o.openBlock(),o.createElementBlock("div",{style:o.normalizeStyle(s.value(u)),class:o.normalizeClass(["field-container",{"field-container--no-style":u.nostyle}])},[(o.openBlock(),o.createBlock(o.resolveDynamicComponent(o.unref(r)[u.field.fieldType]),{class:"field-component",field:u.field,"style-override":u.style,"option-id":u.originalAnnotationId,"no-style":u.nostyle,"is-editing":!1},null,8,["field","style-override","option-id","no-style"]))],6))),256))]))}},Zg=Se(Jg,[["__scopeId","data-v-22e6ae02"]]),Qg={class:"superdoc-html-viewer"},eb={class:"superdoc-html-viewer__document"},tb=["innerHTML"],nb={__name:"HtmlViewer",props:{fileSource:{type:File,required:!0},documentId:{type:String,required:!0}},emits:["ready","selection-change"],setup(e,{emit:t}){const n=e,r=o.ref(""),i=t,s=()=>{const c=window.getSelection();console.debug("selection from html viewer",c),i("selection-change",c)},a=c=>new Promise((u,d)=>{const p=new FileReader;p.onload=h=>{const b=h.target.result;u(b)},p.onerror=h=>d(h),p.readAsText(c)}),l=async()=>{try{const c=await a(n.fileSource);r.value=c,i("ready",n.documentId)}catch(c){i("error",c),console.error("Error loading document",c)}};return o.onMounted(()=>{l()}),(c,u)=>(o.openBlock(),o.createElementBlock("div",Qg,[o.createBaseVNode("div",eb,[o.createBaseVNode("div",{class:"superdoc-html-viewer__content",innerHTML:r.value,onMouseup:s},null,40,tb)])]))}},ob=Se(nb,[["__scopeId","data-v-7bd2cb5d"]]),rb=["innerHTML"],ib={class:"superdoc__document document"},sb={key:0,class:"superdoc__right-sidebar right-sidebar"},ab={class:"floating-comments"},lb={__name:"SuperDoc",emits:["selection-update"],setup(e,{emit:t}){const n=Qe(),r=at(),{documents:i,isReady:s,areDocumentsReady:a,selectionPosition:l,activeSelection:c,activeZoom:u}=Ve(n),{handlePageReady:d,modules:p,user:h,getDocument:b}=n,{getConfig:m,documentsWithConverations:C,commentsList:w,pendingComment:v,activeComment:I,skipSelectionUpdate:B,commentsByDocument:S,isCommentsListVisible:O,isFloatingCommentsReady:T,generalCommentIds:f,getFloatingComments:y,hasSyncedCollaborationComments:$,editorCommentPositions:g,hasInitializedLocations:E}=Ve(r),{showAddComment:k,handleEditorLocationsUpdate:N,handleTrackedChangeUpdate:P}=r,{proxy:x}=o.getCurrentInstance();r.proxy=x;const D=o.ref(null),A=o.ref(null),z=o.reactive({top:null,right:"-25px",zIndex:101}),F=o.ref(null),W=(M,_)=>{const R=b(M);R.isReady=!0,R.container=_,a.value&&(x.$superdoc.config.collaboration||(s.value=!0)),T.value=!0,x.$superdoc.broadcastPdfDocumentReady()},Y=M=>{const _={comments:()=>k(x.$superdoc)};M in _&&_[M](c.value,l.value),c.value=null,z.top=null},ne=M=>{v.value},ce=()=>z.top=null,me=M=>{M.target.classList.contains("n-dropdown-option-body__label")||r.removePendingComment(x.$superdoc)},Be=({editor:M,comments:_,replacedFile:R})=>{(M.options.shouldLoadComments||R)&&o.nextTick(()=>{r.processLoadedDocxComments({superdoc:x.$superdoc,editor:M,comments:_,documentId:M.options.documentId})})},he=({editor:M})=>{x.$superdoc?.broadcastEditorBeforeCreate(M)},oe=({editor:M})=>{const{documentId:_}=M.options;b(_).setEditor(M),x.$superdoc.setActiveEditor(M),x.$superdoc.broadcastEditorCreate(M),x.$superdoc.log("[SuperDoc] Editor created",x.$superdoc.activeEditor),x.$superdoc.log("[SuperDoc] Page styles (pixels)",M.getPageStyles())},Ae=()=>{x.$superdoc.broadcastEditorDestroy()},X=({editor:M})=>{x.$superdoc.setActiveEditor(M)},J=({editor:M,isLocked:_,lockedBy:R})=>{x.$superdoc.lockSuperdoc(_,R)},ye=({editor:M})=>{x.$superdoc.emit("editor-update",{editor:M})},ie=({editor:M,transaction:_})=>{if(B.value){B.value=!1;return}const{documentId:R}=M.options,{$from:H,$to:ee}=_.selection;if(H.pos===ee.pos&&ze({x:null,y:null,source:"super-editor"}),!D.value)return;const{view:fe}=M,we=fe.coordsAtPos(H.pos),ke=fe.coordsAtPos(ee.pos),{pageMargins:ue}=M.getPageStyles(),Oe=D.value.getBoundingClientRect(),uo=Math.max(96,we.top-Oe.top),fo=ke.bottom-Oe.top,po={top:uo,left:we.left,right:ke.left,bottom:fo},ho=dn({selectionBounds:po,page:1,documentId:R,source:"super-editor"});Fe(ho)},Me=({editor:M})=>{x.$superdoc.emit("collaboration-ready",{editor:M}),o.nextTick(()=>{s.value=!0;const R=new URLSearchParams(window.location.search).get("commentId");R&&Ee(R)})},Ke=({error:M,editor:_})=>{x.$superdoc.emit("content-error",{error:M,editor:_})},L=({error:M,editor:_})=>{x.$superdoc.emit("exception",{error:M,editor:_})},V=M=>({pagination:x.$superdoc.config.pagination,documentId:M.id,user:x.$superdoc.user,users:x.$superdoc.users,colors:x.$superdoc.colors,role:x.$superdoc.config.role,documentMode:x.$superdoc.config.documentMode,rulers:M.rulers,isInternal:x.$superdoc.config.isInternal,annotations:x.$superdoc.config.annotations,isCommentsEnabled:x.$superdoc.config.modules?.comments,onBeforeCreate:he,onCreate:oe,onDestroy:Ae,onFocus:X,onDocumentLocked:J,onUpdate:ye,onSelectionUpdate:ie,onCollaborationReady:Me,onContentError:Ke,onException:L,onCommentsLoaded:Be,onCommentsUpdate:Q,onCommentLocationsUpdate:G,ydoc:M.ydoc,collaborationProvider:M.provider||null,isNewFile:M.isNewFile||!1,handleImageUpload:x.$superdoc.config.handleImageUpload,telemetry:x.$superdoc.telemetry,externalExtensions:x.$superdoc.config.editorExtensions||[]}),G=({allCommentIds:M,allCommentPositions:_})=>{x.$superdoc.config.modules?.comments&&N(_,M)},Q=(M={})=>{const{activeCommentId:_,type:R}=M;R==="trackedChange"&&P({superdoc:x.$superdoc,params:M}),o.nextTick(()=>{v.value||r.setActiveComment(_)}),typeof x.$superdoc.config.onCommentsUpdate=="function"&&x.$superdoc.config.onCommentsUpdate(M)},Z=o.computed(()=>"comments"in p),te=o.computed(()=>v.value||y.value?.length>0&&s.value&&D.value&&Z.value&&!O.value),q=o.computed(()=>Z.value?z.top&&!m.value?.readOnly:!1);o.computed(()=>{if(!Z.value)return!1;!m?.readOnly&&l.value}),o.watch(te,M=>{x.$superdoc.broadcastSidebarToggle(M)});const Ee=M=>{if(!x.$superdoc.config?.modules?.comments)return;const _=document.querySelector(`[data-thread-id=${M}]`);_&&(_.scrollIntoView({behavior:"smooth",block:"start"}),r.setActiveComment(M))};o.onMounted(()=>{Z.value&&!p.comments.readOnly&&document.addEventListener("mousedown",ne)}),o.onBeforeUnmount(()=>{document.removeEventListener("mousedown",ne)});const ae=o.ref(null),re=o.ref(!1),Pe=o.computed(()=>{if(!l.value||l.value.source==="super-editor")return{x:null,y:null};const M=l.value.top,_=l.value.left,R=l.value.right,H=l.value.bottom;return{zIndex:500,borderRadius:"4px",top:M+"px",left:_+"px",height:Math.abs(M-H)+"px",width:Math.abs(_-R)+"px"}}),Fe=M=>{if(!M.selectionBounds||!Z.value)return;Ge();const _=window.matchMedia("(max-width: 768px)").matches;if(ze({startX:M.selectionBounds.left,startY:M.selectionBounds.top,x:M.selectionBounds.right,y:M.selectionBounds.bottom,source:M.source}),!l.value)return;const R=Math.abs(l.value.left-l.value.right)>5,H=Math.abs(l.value.top-l.value.bottom)>5;if(!R||!H){ae.value.style.pointerEvents="none",Ge();return}c.value=M;let ee=M.selectionBounds.top;z.top=ee+"px",z.right=_?"0":"-25px"},Ge=()=>{l.value=null},ze=({startX:M,startY:_,x:R,y:H,source:ee})=>{if(!(M||_)&&!(R||H))return l.value=null;if(!l.value){if(_<=0||M<=0)return;l.value={top:_,left:M,right:M,bottom:_,startX:M,startY:_,source:ee}}M&&(l.value.startX=M),_&&(l.value.startY=_);const ke=l.value.startY;H<ke?l.value.top=H:l.value.bottom=H;const ue=l.value.startX;R<ue?l.value.left=R:l.value.right=R},ut=M=>{Ge(),ae.value.style.pointerEvents="auto",o.nextTick(()=>{re.value=!0;const _=M.offsetY/(u.value/100),R=M.offsetX/(u.value/100);ze({startX:R,startY:_}),ae.value.addEventListener("mousemove",Mt)})},Mt=M=>{if(!re.value)return;const _=M.offsetY/(u.value/100),R=M.offsetX/(u.value/100);ze({x:R,y:_})},Jt=M=>{if(!re.value||(ae.value.removeEventListener("mousemove",Mt),!l.value))return;const _=dn({selectionBounds:{top:l.value.top,left:l.value.left,right:l.value.right,bottom:l.value.bottom},documentId:i.value[0].id});Fe(_),ae.value.style.pointerEvents="none"},Zt=o.computed(()=>!(x.$superdoc.config.modules?.comments).readOnly),xn=(M,_)=>{M.documentMarginsLastChange=_.pageMargins},dt=M=>{Z.value&&(Ge(),re.value=!0,ut(M))};return o.watch(y,()=>{E.value=!1,o.nextTick(()=>{E.value=!0})}),(M,_)=>{const R=o.resolveDirective("click-outside");return o.openBlock(),o.createElementBlock("div",{class:o.normalizeClass(["superdoc",{"superdoc--with-sidebar":te.value}])},[o.createBaseVNode("div",{class:"superdoc__layers layers",ref_key:"layers",ref:D},[q.value?(o.openBlock(),o.createElementBlock("div",{key:0,class:"superdoc__tools tools",style:o.normalizeStyle(z)},[o.createBaseVNode("div",{class:"tools-item","data-id":"is-tool",onClick:_[0]||(_[0]=o.withModifiers(H=>Y("comments"),["stop","prevent"]))},[o.createBaseVNode("div",{class:"superdoc__tools-icon",innerHTML:o.unref(st).comment},null,8,rb)])],4)):o.createCommentVNode("",!0),o.createBaseVNode("div",ib,[Z.value?(o.openBlock(),o.createElementBlock("div",{key:0,class:"superdoc__selection-layer selection-layer",onMousedown:ut,onMouseup:Jt,ref_key:"selectionLayer",ref:ae},[o.unref(l)&&Zt.value?(o.openBlock(),o.createElementBlock("div",{key:0,style:o.normalizeStyle(Pe.value),class:"superdoc__temp-selection temp-selection sd-highlight sd-initial-highlight"},null,4)):o.createCommentVNode("",!0)],544)):o.createCommentVNode("",!0),"hrbr-fields"in o.unref(p)&&D.value?(o.openBlock(),o.createBlock(Zg,{key:1,fields:o.unref(p)["hrbr-fields"],class:"superdoc__comments-layer comments-layer",style:{"z-index":"2"},ref_key:"hrbrFieldsLayer",ref:F},null,8,["fields"])):o.createCommentVNode("",!0),D.value?(o.openBlock(),o.createBlock(Ig,{key:2,class:"superdoc__comments-layer comments-layer",style:{"z-index":"3"},ref_key:"commentsLayer",ref:A,parent:D.value,user:o.unref(h),onHighlightClick:ce},null,8,["parent","user"])):o.createCommentVNode("",!0),(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(o.unref(i),H=>(o.openBlock(),o.createElementBlock("div",{class:"superdoc__sub-document sub-document",key:H.id},[H.type===o.unref(gn)?(o.openBlock(),o.createBlock(Sg,{key:0,"document-data":H,onSelectionChange:Fe,onReady:W,onPageLoaded:o.unref(d),onBypassSelection:dt},null,8,["document-data","onPageLoaded"])):o.createCommentVNode("",!0),H.type===o.unref(gt)?(o.openBlock(),o.createBlock(o.unref(Ce.fo),{key:1,"file-source":H.data,state:H.state,"document-id":H.id,options:V(H),onPageMarginsChange:ee=>xn(H,ee)},null,8,["file-source","state","document-id","options","onPageMarginsChange"])):o.createCommentVNode("",!0),H.type===o.unref(oo)?(o.openBlock(),o.createBlock(ob,{key:2,onReady:_[1]||(_[1]=ee=>W(ee,null)),onSelectionChange:Fe,"file-source":H.data,"document-id":H.id},null,8,["file-source","document-id"])):o.createCommentVNode("",!0)]))),128))])],512),te.value?(o.openBlock(),o.createElementBlock("div",sb,[o.unref(v)?o.withDirectives((o.openBlock(),o.createBlock(vn,{key:0,comment:o.unref(v),"auto-focus":!0,"is-floating":!0},null,8,["comment"])),[[R,me]]):o.createCommentVNode("",!0),o.createBaseVNode("div",ab,[o.unref(E)&&o.unref(y).length>0?(o.openBlock(!0),o.createElementBlock(o.Fragment,{key:0},o.renderList(o.unref(C),H=>(o.openBlock(),o.createBlock(Dg,{parent:D.value,"current-document":H},null,8,["parent","current-document"]))),256)):o.createCommentVNode("",!0)])])):o.createCommentVNode("",!0)],2)}}},cb=Se(lb,[["__scopeId","data-v-3731e285"]]),ub=()=>{const e=o.createApp(cb),t=Sl();e.use(t),e.directive("click-outside",Zi);const n=Qe(),r=at();return{app:e,pinia:t,superdocStore:n,commentsStore:r}},Wi=(e,t,n)=>{const r=URL.createObjectURL(e),i=document.createElement("a");i.href=r,i.download=`${t}.${n}`,i.click()},Ki=e=>e.toLowerCase().endsWith(".docx")||e.toLowerCase().endsWith(".pdf")?e.slice(0,-5):e;class db extends qi.EventEmitter{static allowedTypes=[gt,gn,oo];version;users;config={superdocId:null,selector:"#superdoc",documentMode:"editing",role:"editor",documents:[],format:null,editorExtensions:[],colors:[],user:{name:null,email:null},users:[],pdfjsWorkerSrcUrl:null,modules:{},title:"SuperDoc",conversations:[],pagination:!1,isCollaborative:!1,isInternal:!1,toolbar:null,toolbarGroups:["left","center","right"],toolbarIcons:{},isDev:!1,telemetry:null,pdfViewer:{},onEditorBeforeCreate:()=>null,onEditorCreate:()=>null,onEditorDestroy:()=>null,onContentError:()=>null,onReady:()=>null,onCommentsUpdate:()=>null,onAwarenessUpdate:()=>null,onLocked:()=>null,onPdfDocumentReady:()=>null,onSidebarToggle:()=>null,onCollaborationReady:()=>null,onEditorUpdate:()=>null,onCommentsListChange:()=>null,onException:()=>null,handleImageUpload:null};constructor(t){super(),this.#n(t)}async#n(t){this.config={...this.config,...t},this.config.colors=Rl(this.config.colors),this.userColorMap=new Map,this.colorIndex=0,this.version="0.8.27",console.debug("🦋 [superdoc] Using SuperDoc version:",this.version),this.superdocId=t.superdocId||Yi.v4(),this.colors=this.config.colors,await this.#i(this.config.modules),this.#o(),this.#r(),this.user=this.config.user,this.users=this.config.users||[],this.socket=null,this.isDev=this.config.isDev||!1,this.activeEditor=null,this.comments=[],this.#s(this),this.app.mount(this.config.selector),this.readyEditors=0,this.isLocked=this.config.isLocked||!1,this.lockedBy=this.config.lockedBy||null}get requiredNumberOfEditors(){return this.superdocStore.documents.filter(t=>t.type===gt).length}get state(){return{documents:this.superdocStore.documents,users:this.users}}#o(){const{app:t,pinia:n,superdocStore:r,commentsStore:i}=ub();this.app=t,this.pinia=n,this.app.config.globalProperties.$config=this.config,this.app.config.globalProperties.$documentMode=this.config.documentMode,this.app.config.globalProperties.$superdoc=this,this.superdocStore=r,this.commentsStore=i,this.version=this.config.version,this.superdocStore.init(this.config),this.commentsStore.init(this.config.modules.comments)}#r(){this.on("editorBeforeCreate",this.config.onEditorBeforeCreate),this.on("editorCreate",this.config.onEditorCreate),this.on("editorDestroy",this.config.onEditorDestroy),this.on("ready",this.config.onReady),this.on("comments-update",this.config.onCommentsUpdate),this.on("awareness-update",this.config.onAwarenessUpdate),this.on("locked",this.config.onLocked),this.on("pdf-document-ready",this.config.onPdfDocumentReady),this.on("sidebar-toggle",this.config.onSidebarToggle),this.on("collaboration-ready",this.config.onCollaborationReady),this.on("editor-update",this.config.onEditorUpdate),this.on("content-error",this.onContentError),this.on("exception",this.config.onException)}async#i({collaboration:t}={}){return t?(this.isCollaborative=!0,this.config.socket=new Xi.HocuspocusProviderWebsocket({url:t.url}),Ul(this),jl(this),Wl(this)):this.config.documents}addSharedUser(t){this.users.some(n=>n.email===t.email)||this.users.push(t)}removeSharedUser(t){this.users=this.users.filter(n=>n.email!==t)}#c(){this.telemetry=new jn({enabled:this.config.telemetry?.enabled??!0,licenseKey:this.config.telemetry?.licenseKey,endpoint:this.config.telemetry?.endpoint,superdocId:this.superdocId,superdocVersion:this.version})}onContentError({error:t,editor:n}){const{documentId:r}=n.options,i=this.superdocStore.documents.find(s=>s.id===r);this.config.onContentError({error:t,editor:n,documentId:i.id,file:i.data})}broadcastPdfDocumentReady(){this.emit("pdf-document-ready")}broadcastReady(){this.readyEditors===this.requiredNumberOfEditors&&this.emit("ready",{superdoc:this})}broadcastEditorBeforeCreate(t){this.emit("editorBeforeCreate",{editor:t})}broadcastEditorCreate(t){this.readyEditors++,this.broadcastReady(),this.emit("editorCreate",{editor:t})}broadcastEditorDestroy(){this.emit("editorDestroy")}broadcastSidebarToggle(t){this.emit("sidebar-toggle",t)}log(...t){console.debug("🦋 🦸‍♀️ [superdoc]",...t)}setActiveEditor(t){this.activeEditor=t,this.toolbar&&this.toolbar.setActiveEditor(t)}toggleRuler(){this.config.rulers=!this.config.rulers,this.superdocStore.documents.forEach(t=>{t.rulers=this.config.rulers})}#s(){const t=this.config.modules?.toolbar||{};this.toolbarElement=this.config.modules?.toolbar?.selector||this.config.toolbar,this.toolbar=null;const n={selector:this.toolbarElement||null,isDev:this.isDev||!1,toolbarGroups:this.config.modules?.toolbar?.groups||this.config.toolbarGroups,role:this.config.role,pagination:this.config.pagination,icons:this.config.toolbarIcons,documentMode:this.config.documentMode,superdoc:this,...t};this.toolbar=new Ce.po(n),this.toolbar.on("superdoc-command",this.onToolbarCommand.bind(this)),this.once("editorCreate",()=>this.toolbar.updateToolbarState())}addCommentsList(t){!this.config?.modules?.comments||this.config.role==="viewer"||(console.debug("🦋 [superdoc] Adding comments list to:",t),t&&(this.config.modules.comments.element=t),this.commentsList=new wg(this.config.modules?.comments,this),this.config.onCommentsListChange&&this.config.onCommentsListChange({isRendered:!0}))}removeCommentsList(){this.commentsList&&(this.commentsList.close(),this.commentsList=null,this.config.onCommentsListChange&&this.config.onCommentsListChange({isRendered:!1}))}onToolbarCommand({item:t,argument:n}){t.command==="setDocumentMode"?this.setDocumentMode(n):t.command==="setZoom"&&(this.superdocStore.activeZoom=n)}setDocumentMode(t){if(!t)return;t=t.toLowerCase(),this.config.documentMode=t;const n={viewing:()=>this.#t(),editing:()=>this.#a(),suggesting:()=>this.#e()};n[t]&&n[t]()}#a(){if(this.config.role!=="editor")return this.#e();if(this.superdocStore.documents.length>0){const t=this.superdocStore.documents[0]?.getEditor();t&&this.setActiveEditor(t)}this.superdocStore.documents.forEach(t=>{t.restoreComments();const n=t.getEditor();n&&n.setDocumentMode("editing")}),this.toolbar&&(this.toolbar.documentMode="editing",this.toolbar.updateToolbarState())}#e(){if(!["editor","suggester"].includes(this.config.role))return this.#t();if(this.superdocStore.documents.length>0){const t=this.superdocStore.documents[0]?.getEditor();t&&this.setActiveEditor(t)}this.superdocStore.documents.forEach(t=>{t.restoreComments();const n=t.getEditor();n&&n.setDocumentMode("suggesting")}),this.toolbar&&(this.toolbar.documentMode="suggesting",this.toolbar.updateToolbarState())}#t(){this.toolbar.activeEditor=null,this.superdocStore.documents.forEach(t=>{t.removeComments();const n=t.getEditor();n&&n.setDocumentMode("viewing")}),this.toolbar&&(this.toolbar.documentMode="viewing",this.toolbar.updateToolbarState())}setLocked(t=!0){this.config.documents.forEach(n=>{const r=n.ydoc.getMap("meta");n.ydoc.transact(()=>{r.set("locked",t),r.set("lockedBy",this.user)})})}getHTML(){const t=[];return this.superdocStore.documents.forEach(n=>{const r=n.getEditor();r&&t.push(r)}),t.map(n=>n.getHTML())}lockSuperdoc(t=!1,n){this.isLocked=t,this.lockedBy=n,console.debug("🦋 [superdoc] Locking superdoc:",t,n,`
509
+ `)])]),dv={small:20,medium:18,large:16},fv=Object.assign(Object.assign({},Re.props),{contentClass:String,contentStyle:[Object,String],description:String,stroke:String,size:{type:[String,Number],default:"medium"},show:{type:Boolean,default:!0},strokeWidth:Number,rotate:{type:Boolean,default:!0},spinning:{type:Boolean,validator:()=>!0,default:void 0},delay:Number}),pv=o.defineComponent({name:"Spin",props:fv,slots:Object,setup(e){o.process$1.env.NODE_ENV!=="production"&&o.watchEffect(()=>{e.spinning!==void 0&&Et("spin","`spinning` is deprecated, please use `show` instead.")});const{mergedClsPrefixRef:t,inlineThemeDisabled:n}=Gt(e),r=Re("Spin","-spin",uv,cv,e,t),i=o.computed(()=>{const{size:c}=e,{common:{cubicBezierEaseInOut:u},self:d}=r.value,{opacitySpinning:p,color:h,textColor:b}=d,m=typeof c=="number"?yc(c):d[Xe("size",c)];return{"--n-bezier":u,"--n-opacity-spinning":p,"--n-size":m,"--n-color":h,"--n-text-color":b}}),s=n?qt("spin",o.computed(()=>{const{size:c}=e;return typeof c=="number"?String(c):c[0]}),i,e):void 0,a=Is(e,["spinning","show"]),l=o.ref(!1);return o.watchEffect(c=>{let u;if(a.value){const{delay:d}=e;if(d){u=window.setTimeout(()=>{l.value=!0},d),c(()=>{clearTimeout(u)});return}}l.value=a.value}),{mergedClsPrefix:t,active:l,mergedStrokeWidth:o.computed(()=>{const{strokeWidth:c}=e;if(c!==void 0)return c;const{size:u}=e;return dv[typeof u=="number"?"medium":u]}),cssVars:n?void 0:i,themeClass:s?.themeClass,onRender:s?.onRender}},render(){var e,t;const{$slots:n,mergedClsPrefix:r,description:i}=this,s=n.icon&&this.rotate,a=(i||n.description)&&o.h("div",{class:`${r}-spin-description`},i||((e=n.description)===null||e===void 0?void 0:e.call(n))),l=n.icon?o.h("div",{class:[`${r}-spin-body`,this.themeClass]},o.h("div",{class:[`${r}-spin`,s&&`${r}-spin--rotate`],style:n.default?"":this.cssVars},n.icon()),a):o.h("div",{class:[`${r}-spin-body`,this.themeClass]},o.h(Kh,{clsPrefix:r,style:n.default?"":this.cssVars,stroke:this.stroke,"stroke-width":this.mergedStrokeWidth,class:`${r}-spin`}),a);return(t=this.onRender)===null||t===void 0||t.call(this),n.default?o.h("div",{class:[`${r}-spin-container`,this.themeClass],style:this.cssVars},o.h("div",{class:[`${r}-spin-content`,this.active&&`${r}-spin-content--spinning`,this.contentClass],style:this.contentStyle},n),o.h(o.Transition,{name:"fade-in-transition"},{default:()=>this.active?l:null})):l}}),hv='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M512 240c0 114.9-114.6 208-256 208c-37.1 0-72.3-6.4-104.1-17.9c-11.9 8.7-31.3 20.6-54.3 30.6C73.6 471.1 44.7 480 16 480c-6.5 0-12.3-3.9-14.8-9.9c-2.5-6-1.1-12.8 3.4-17.4c0 0 0 0 0 0s0 0 0 0s0 0 0 0c0 0 0 0 0 0l.3-.3c.3-.3 .7-.7 1.3-1.4c1.1-1.2 2.8-3.1 4.9-5.7c4.1-5 9.6-12.4 15.2-21.6c10-16.6 19.5-38.4 21.4-62.9C17.7 326.8 0 285.1 0 240C0 125.1 114.6 32 256 32s256 93.1 256 208z"/></svg>',mv='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M137.4 374.6c12.5 12.5 32.8 12.5 45.3 0l128-128c9.2-9.2 11.9-22.9 6.9-34.9s-16.6-19.8-29.6-19.8L32 192c-12.9 0-24.6 7.8-29.6 19.8s-2.2 25.7 6.9 34.9l128 128z"/></svg>',vv='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M96 128a128 128 0 1 1 256 0A128 128 0 1 1 96 128zM0 482.3C0 383.8 79.8 304 178.3 304l91.4 0C368.2 304 448 383.8 448 482.3c0 16.4-13.3 29.7-29.7 29.7L29.7 512C13.3 512 0 498.7 0 482.3zM625 177L497 305c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L591 143c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"/></svg>',gv='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M144 0a80 80 0 1 1 0 160A80 80 0 1 1 144 0zM512 0a80 80 0 1 1 0 160A80 80 0 1 1 512 0zM0 298.7C0 239.8 47.8 192 106.7 192l42.7 0c15.9 0 31 3.5 44.6 9.7c-1.3 7.2-1.9 14.7-1.9 22.3c0 38.2 16.8 72.5 43.3 96c-.2 0-.4 0-.7 0L21.3 320C9.6 320 0 310.4 0 298.7zM405.3 320c-.2 0-.4 0-.7 0c26.6-23.5 43.3-57.8 43.3-96c0-7.6-.7-15-1.9-22.3c13.6-6.3 28.7-9.7 44.6-9.7l42.7 0C592.2 192 640 239.8 640 298.7c0 11.8-9.6 21.3-21.3 21.3l-213.3 0zM224 224a96 96 0 1 1 192 0 96 96 0 1 1 -192 0zM128 485.3C128 411.7 187.7 352 261.3 352l117.3 0C452.3 352 512 411.7 512 485.3c0 14.7-11.9 26.7-26.7 26.7l-330.7 0c-14.7 0-26.7-11.9-26.7-26.7z"/></svg>',Vi='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"/></svg>',bv='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"/></svg>',yv='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M64 360a56 56 0 1 0 0 112 56 56 0 1 0 0-112zm0-160a56 56 0 1 0 0 112 56 56 0 1 0 0-112zM120 96A56 56 0 1 0 8 96a56 56 0 1 0 112 0z"/></svg>',st={comment:hv,caretDown:mv,internal:vv,external:gv,markDone:Vi,acceptChange:Vi,rejectChange:bv,overflow:yv},$e=Object.freeze({RESOLVE_OWN:"RESOLVE_OWN",RESOLVE_OTHER:"RESOLVE_OTHER",REJECT_OWN:"REJECT_OWN",REJECT_OTHER:"REJECT_OTHER",COMMENTS_OVERFLOW_OWN:"COMMENTS_OVERFLOW",COMMENTS_OVERFLOW_OTHER:"COMMENTS_OVERFLOW_OTHER",COMMENTS_DELETE_OWN:"COMMENTS_DELETE_OWN",COMMENTS_DELETE_OTHER:"COMMENTS_DELETE_OTHER",UPLOAD_VERSION:"UPLOAD_VERSION",VERSION_HISTORY:"VERSION_HISTORY"}),ve=Object.freeze({EDITOR:"editor",SUGGESTER:"suggester",VIEWER:"viewer"}),wv=Object.freeze({[$e.RESOLVE_OWN]:{internal:[ve.EDITOR],external:[ve.EDITOR]},[$e.RESOLVE_OTHER]:{internal:[ve.EDITOR],external:[]},[$e.REJECT_OWN]:{internal:[ve.EDITOR,ve.SUGGESTER],external:[ve.EDITOR,ve.SUGGESTER]},[$e.REJECT_OTHER]:{internal:[ve.EDITOR],external:[]},[$e.COMMENTS_OVERFLOW_OWN]:{internal:[ve.EDITOR,ve.SUGGESTER],external:[ve.EDITOR,ve.SUGGESTER]},[$e.COMMENTS_OVERFLOW_OTHER]:{internal:[ve.EDITOR],external:[]},[$e.COMMENTS_DELETE_OWN]:{internal:[ve.EDITOR,ve.SUGGESTER],external:[ve.EDITOR,ve.SUGGESTER]},[$e.COMMENTS_DELETE_OTHER]:{internal:[ve.EDITOR],external:[]},[$e.UPLOAD_VERSION]:{internal:[ve.EDITOR],external:[]},[$e.VERSION_HISTORY]:{internal:[ve.EDITOR],external:[]}}),Vt=(e,t,n)=>{const r=n?"internal":"external";return wv[e]?.[r]?.includes(t)},Se=(e,t)=>{const n=e.__vccOpts||e;for(const[r,i]of t)n[r]=i;return n},Cv={class:"user-container"},xv=["src"],Ev={key:1,class:"user-bg"},Sv={__name:"Avatar",props:{user:{type:Object,required:!0}},setup(e){const t=(n,r)=>!n&&!r?void 0:n?.substring(0,1)||r?.substring(0,1)||null;return(n,r)=>(o.openBlock(),o.createElementBlock("div",Cv,[e.user.image?(o.openBlock(),o.createElementBlock("img",{key:0,class:"user-bg",src:e.user.image.startsWith("http")?e.user.image:`data:image/png;base64,${e.user.image}`},null,8,xv)):(o.openBlock(),o.createElementBlock("span",Ev,o.toDisplayString(t(e.user.name,e.user.email)),1))]))}},kv=Se(Sv,[["__scopeId","data-v-53e13009"]]),_v={class:"comment-option"},$v=["innerHTML"],Tv={class:"option-state"},Iv=["innerHTML"],Ov={__name:"InternalDropdown",props:{state:{type:String,required:!1},isDisabled:{type:Boolean,default:!1}},emits:["select"],setup(e,{emit:t}){const n=t,r=e,i=p=>()=>o.h("div",{innerHTML:p,class:"internal-dropdown__item-icon"}),s=[{label:"Internal",key:"internal",icon:i(st.internal),iconString:st.internal,backgroundColor:"#CDE6E6"},{label:"External",key:"external",icon:i(st.external),iconString:st.external,backgroundColor:"#F5CFDA"}],a=o.computed(()=>s.find(p=>p.key===u.value)?.label),l=o.computed(()=>{if(!r.state)return{};const p=s.find(b=>b.key===u.value);if(!p)return{};const h={backgroundColor:p.backgroundColor};return r.isDisabled&&(h.opacity=.5,h.cursor="default"),h}),c=(p,h=!1)=>{u.value=p,d.value=s.find(b=>b.key===p)?.iconString,!h&&n("select",p)},u=o.ref(r.state),d=o.ref(null);return o.watch(()=>r.state,p=>{c(p)}),o.onMounted(()=>{c(r.state,!0)}),(p,h)=>(o.openBlock(),o.createElementBlock("div",{class:"internal-dropdown",style:o.normalizeStyle(l.value)},[o.createVNode(o.unref(Oa),{trigger:"click",options:s,onSelect:h[0]||(h[0]=b=>c(b)),disabled:e.isDisabled},{default:o.withCtx(()=>[o.createBaseVNode("div",_v,[o.createBaseVNode("div",{class:"active-icon",innerHTML:d.value},null,8,$v),o.createBaseVNode("div",Tv,o.toDisplayString(a.value),1),o.createBaseVNode("div",{class:"dropdown-caret",innerHTML:o.unref(st).caretDown},null,8,Iv)])]),_:1},8,["disabled"])],4))}},Bv=Se(Ov,[["__scopeId","data-v-c42ece92"]]);function Pv(e){const t=new Date(e),n=t.getHours(),r=t.getMinutes(),i=n>=12?"PM":"AM",s=n%12||12,l=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()],c=t.getDate();return`${`${s}:${r.toString().padStart(2,"0")}${i}`} ${l} ${c}`}const Dv={class:"card-section comment-header"},Rv={class:"comment-header-left"},Av={class:"user-info"},Mv={class:"user-name"},Nv={key:0,class:"user-timestamp"},Fv={class:"overflow-menu"},zv=["innerHTML"],Lv=["innerHTML"],Hv=["innerHTML"],Vv={__name:"CommentHeader",props:{timestamp:{type:Number,required:!1},config:{type:Object,required:!0},comment:{type:Object,required:!1},isPendingInput:{type:Boolean,required:!1,default:!1}},emits:["resolve","reject","overflow-select"],setup(e,{emit:t}){const n=t,r=at(),i=e,{proxy:s}=o.getCurrentInstance(),a=s.$superdoc.config.role,l=s.$superdoc.config.isInternal,c=i.comment.creatorEmail===s.$superdoc.config.user.email,u=Object.freeze({edit:{label:"Edit",key:"edit"},delete:{label:"Delete",key:"delete"}}),d=o.computed(()=>!(!i.comment||i.comment.resolvedTime||r.pendingComment||i.isPendingInput)),p=o.computed(()=>!d.value||i.comment.parentCommentId?!1:Vt(c?$e.RESOLVE_OWN:$e.RESOLVE_OTHER,a,l)),h=o.computed(()=>!d.value||!i.comment.trackedChange?!1:Vt(c?$e.REJECT_OWN:$e.REJECT_OTHER,a,l)),b=o.computed(()=>!(!d.value||i.comment.trackedChange||i.isPendingInput||m.value.length===0)),m=o.computed(()=>{if(!d.value)return!1;const B=[],S=new Set;i.comment.creatorEmail===s.$superdoc.config.user.email&&S.add("edit");const O=i.comment.creatorEmail===s.$superdoc.config.user.email;return(O&&Vt($e.COMMENTS_DELETE_OWN,a,l)||!O&&Vt($e.COMMENTS_DELETE_OTHER,a,l))&&S.add("delete"),S.forEach(T=>B.push(u[T])),B}),C=()=>n("resolve"),w=()=>n("reject"),v=B=>n("overflow-select",B),I=o.computed(()=>i.isPendingInput?s.$superdoc.config.user:i.comment.getCommentUser());return(B,S)=>(o.openBlock(),o.createElementBlock("div",Dv,[o.createBaseVNode("div",Rv,[o.createVNode(kv,{user:I.value,class:"avatar"},null,8,["user"]),o.createBaseVNode("div",Av,[o.createBaseVNode("div",Mv,o.toDisplayString(I.value.name),1),i.comment.createdTime?(o.openBlock(),o.createElementBlock("div",Nv,o.toDisplayString(o.unref(Pv)(i.comment.createdTime)),1)):o.createCommentVNode("",!0)])]),o.createBaseVNode("div",Fv,[p.value?(o.openBlock(),o.createElementBlock("div",{key:0,class:"overflow-menu__icon",innerHTML:o.unref(st).markDone,onClick:o.withModifiers(C,["stop","prevent"])},null,8,zv)):o.createCommentVNode("",!0),h.value?(o.openBlock(),o.createElementBlock("div",{key:1,class:"overflow-menu__icon",innerHTML:o.unref(st).rejectChange,onClick:o.withModifiers(w,["stop","prevent"])},null,8,Lv)):o.createCommentVNode("",!0),b.value?(o.openBlock(),o.createBlock(o.unref(Oa),{key:2,trigger:"click",options:m.value,onSelect:v},{default:o.withCtx(()=>[o.createBaseVNode("div",{class:"overflow-menu__icon",onClick:S[0]||(S[0]=o.withModifiers(()=>{},["stop","prevent"]))},[o.createBaseVNode("div",{class:"overflow-icon",innerHTML:o.unref(st).overflow},null,8,Hv)])]),_:1},8,["options"])):o.createCommentVNode("",!0)])]))}},Ba=Se(Vv,[["__scopeId","data-v-7e86617a"]]),jv={class:"input-section"},Uv={__name:"CommentInput",props:{users:{type:Array,required:!1,default:()=>[]},config:{type:Object,required:!0},isFocused:{type:Boolean,default:!1},includeHeader:{type:Boolean,default:!0},comment:{type:Object,required:!1}},emits:["focus"],setup(e,{emit:t}){const n=t;Qe();const r=at(),{currentCommentText:i}=Ve(r),s=a=>n("focus",a);return(a,l)=>(o.openBlock(),o.createElementBlock("div",jv,[e.includeHeader?(o.openBlock(),o.createBlock(Ba,{key:0,config:e.config,comment:e.comment,"is-pending-input":!0},null,8,["config","comment"])):o.createCommentVNode("",!0),o.createBaseVNode("div",{class:o.normalizeClass(["comment-entry",{"input-active":e.isFocused}])},[o.createVNode(o.unref(Ce.vo),{class:"superdoc-field",placeholder:"Add a comment",modelValue:o.unref(i),"onUpdate:modelValue":l[0]||(l[0]=c=>o.isRef(i)?i.value=c:null),users:e.users,onFocus:l[1]||(l[1]=c=>s(!0)),onBlur:l[2]||(l[2]=c=>s(!1))},null,8,["modelValue","users"])],2)]))}},ji=Se(Uv,[["__scopeId","data-v-76d953bd"]]),Wv={key:0,class:"existing-internal-input"},Kv={key:0,class:"card-section comment-body"},Gv={class:"tracked-change"},qv={class:"tracked-change"},Xv={key:0},Yv={class:"tracked-change-text"},Jv={key:1},Zv={class:"tracked-change-text"},Qv={key:2},eg={class:"tracked-change-text"},tg={key:1,class:"card-section comment-body"},ng=["innerHTML"],og={key:1,class:"comment"},rg={key:2,class:"comment-editing"},ig={class:"comment-footer"},sg=["onClick"],ag=["onClick"],lg={key:2,class:"comment-separator"},cg={key:1},ug={key:0,class:"comment-footer"},dg=["disabled"],fg={__name:"CommentDialog",props:{comment:{type:Object,required:!0},autoFocus:{type:Boolean,default:!1},parent:{type:Object,required:!1}},emits:["click-outside","ready","dialog-exit"],setup(e,{emit:t}){const n=t,r=e,{proxy:i}=o.getCurrentInstance();i.$superdoc.config.role,r.comment.email;const s=Qe(),a=at(),{addComment:l,cancelComment:c,deleteComment:u,removePendingComment:d}=a,{suppressInternalExternal:p,getConfig:h,activeComment:b,floatingCommentsOffset:m,pendingComment:C,currentCommentText:w,isDebugging:v,editingCommentId:I,editorCommentPositions:B}=Ve(a),{activeZoom:S}=Ve(s),O=o.ref(!0);o.ref(!1);const T=o.ref(null),f=o.ref(null),y=o.computed(()=>b.value===r.comment.commentId),$=o.computed(()=>!h.readOnly&&y.value&&!r.comment.resolvedTime&&I.value!==r.comment.commentId),g=o.computed(()=>X=>E.value&&X===k.value.length-1?!0:k.value.length>1&&X!==k.value.length-1),E=o.computed(()=>!h.readOnly&&y.value&&!r.comment.resolvedTime&&I.value!==r.comment.commentId),k=o.computed(()=>{const X=r.comment;return a.commentsList.filter(J=>{const ye=J.parentCommentId===X.commentId,ie=J.commentId===r.comment.commentId;return ye||ie}).sort((J,ye)=>J.commentId===r.comment.commentId&&J.createdTime-ye.createdTime)}),N=o.computed(()=>r.comment.resolvedTime?!0:h.value.readOnly),P=o.computed(()=>X=>I.value===X.commentId),x=o.computed(()=>i.$superdoc.config.isInternal?!p.value&&!r.comment.trackedChange:!1),D=o.computed(()=>w.value&&w.value!=="<p></p>"),A=()=>{r.comment.resolvedTime||(b.value=r.comment.commentId,r.comment.setActive(i.$superdoc))},z=X=>{X.target.classList.contains("n-dropdown-option-body__label")||X.target.classList.contains("comment-highlight")||(b.value===r.comment.commentId&&(m.value=0,n("dialog-exit")),b.value=null)},F=()=>{const X={documentId:r.comment.fileId,isInternal:C.value?C.value.isInternal:O.value,parentCommentId:C.value?null:r.comment.commentId};if(C.value){const ye=C.value.selection.getValues();X.selection=ye}const J=a.getPendingComment(X);l({superdoc:i.$superdoc,comment:J})},W=()=>{r.comment.trackedChange?(r.comment.resolveComment({email:s.user.email,name:s.user.name,superdoc:i.$superdoc}),i.$superdoc.activeEditor.commands.rejectTrackedChangeById(r.comment.commentId)):a.deleteComment({superdoc:i.$superdoc,commentId:r.comment.commentId}),o.nextTick(()=>{a.lastUpdate=new Date,b.value=null})},Y=()=>{r.comment.trackedChange&&i.$superdoc.activeEditor.commands.acceptTrackedChangeById(r.comment.commentId),r.comment.resolveComment({email:s.user.email,name:s.user.name,superdoc:i.$superdoc}),o.nextTick(()=>{a.lastUpdate=new Date,b.value=null})},ne=(X,J)=>{switch(X){case"edit":w.value=J.commentText,b.value=J.commentId,I.value=J.commentId;break;case"delete":u({superdoc:i.$superdoc,commentId:J.commentId});break}},ce=X=>{I.value=null,X.setText({text:w.value,superdoc:i.$superdoc}),d(i.$superdoc)},me=X=>{const J=!!C.value,ye=X.toLowerCase()==="internal";J?C.value.isInternal=ye:r.comment.setIsInternal({isInternal:ye,superdoc:i.$superdoc})},Be=o.computed(()=>{const X={};if(r.comment,y.value&&(X.backgroundColor="white",X.zIndex=50),C.value&&C.value.commentId===r.comment.commentId){const J=Math.max(96,C.value.selection?.selectionBounds.top-50);X.position="absolute",X.top=J+"px"}return X}),he=X=>typeof X=="string"?new Date(X).getTime():X,oe=X=>{I.value=null,c(i.$superdoc)},Ae=o.computed(()=>{const X=i.$superdoc.users;return r.comment.isInternal===!0?X.filter(J=>J.access?.role==="internal"):X});return o.onMounted(()=>{r.autoFocus&&o.nextTick(()=>A()),o.nextTick(()=>{const X=r.comment.importedId!==void 0?r.comment.importedId:r.comment.commentId;n("ready",{commentId:X,elementRef:f})})}),(X,J)=>{const ye=o.resolveDirective("click-outside");return o.withDirectives((o.openBlock(),o.createElementBlock("div",{class:o.normalizeClass(["comments-dialog",{"is-active":y.value,"is-resolved":r.comment.resolvedTime}]),onClick:o.withModifiers(A,["stop","prevent"]),style:o.normalizeStyle(Be.value),ref_key:"commentDialogElement",ref:f},[x.value?(o.openBlock(),o.createElementBlock("div",Wv,[o.createVNode(Bv,{onClick:J[0]||(J[0]=o.withModifiers(()=>{},["stop","prevent"])),class:"internal-dropdown","is-disabled":N.value,state:e.comment.isInternal?"internal":"external",onSelect:me},null,8,["is-disabled","state"])])):o.createCommentVNode("",!0),(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(k.value,(ie,Me)=>(o.openBlock(),o.createElementBlock("div",{key:Me,class:"conversation-item"},[o.createVNode(Ba,{config:o.unref(h),timestamp:he(ie.createdTime),comment:ie,onResolve:Y,onReject:W,onOverflowSelect:Ke=>ne(Ke,ie)},null,8,["config","timestamp","comment","onOverflowSelect"]),ie.trackedChange?(o.openBlock(),o.createElementBlock("div",Kv,[o.createBaseVNode("div",Gv,[o.createBaseVNode("div",qv,[ie.trackedChangeType==="trackFormat"?(o.openBlock(),o.createElementBlock("div",Xv,[J[2]||(J[2]=o.createBaseVNode("span",{class:"change-type"},"Format: ",-1)),o.createBaseVNode("span",Yv,o.toDisplayString(ie.trackedChangeText),1)])):o.createCommentVNode("",!0),ie.trackedChangeText&&ie.trackedChangeType!=="trackFormat"?(o.openBlock(),o.createElementBlock("div",Jv,[J[3]||(J[3]=o.createBaseVNode("span",{class:"change-type"},"Added: ",-1)),o.createBaseVNode("span",Zv,o.toDisplayString(ie.trackedChangeText),1)])):o.createCommentVNode("",!0),ie.deletedText&&ie.trackedChangeType!=="trackFormat"?(o.openBlock(),o.createElementBlock("div",Qv,[J[4]||(J[4]=o.createBaseVNode("span",{class:"change-type"},"Deleted: ",-1)),o.createBaseVNode("span",eg,o.toDisplayString(ie.deletedText),1)])):o.createCommentVNode("",!0)])])])):o.createCommentVNode("",!0),ie.trackedChange?o.createCommentVNode("",!0):(o.openBlock(),o.createElementBlock("div",tg,[!o.unref(v)&&!P.value(ie)?(o.openBlock(),o.createElementBlock("div",{key:0,class:"comment",innerHTML:ie.commentText},null,8,ng)):o.unref(v)&&!P.value(ie)?(o.openBlock(),o.createElementBlock("div",og,o.toDisplayString(o.unref(B)[ie.importedId!==void 0?ie.importedId:ie.commentId]?.bounds),1)):(o.openBlock(),o.createElementBlock("div",rg,[o.createVNode(ji,{users:Ae.value,config:o.unref(h),"include-header":!1,comment:ie},null,8,["users","config","comment"]),o.createBaseVNode("div",ig,[o.createBaseVNode("button",{class:"sd-button",onClick:o.withModifiers(Ke=>oe(),["stop","prevent"])},"Cancel",8,sg),o.createBaseVNode("button",{class:"sd-button primary",onClick:o.withModifiers(Ke=>ce(ie),["stop","prevent"])}," Update ",8,ag)])]))])),g.value(Me)?(o.openBlock(),o.createElementBlock("div",lg)):o.createCommentVNode("",!0)]))),128)),E.value&&!o.unref(h).readOnly?(o.openBlock(),o.createElementBlock("div",cg,[o.createVNode(ji,{ref_key:"commentInput",ref:T,users:Ae.value,config:o.unref(h),comment:r.comment},null,8,["users","config","comment"]),$.value&&!o.unref(h).readOnly?(o.openBlock(),o.createElementBlock("div",ug,[o.createBaseVNode("button",{class:"sd-button",onClick:J[1]||(J[1]=o.withModifiers((...ie)=>o.unref(c)&&o.unref(c)(...ie),["stop","prevent"]))},"Cancel"),o.createBaseVNode("button",{class:o.normalizeClass(["sd-button primary",{disabled:!D.value}]),onClick:o.withModifiers(F,["stop","prevent"]),disabled:!D.value}," Comment ",10,dg)])):o.createCommentVNode("",!0)])):o.createCommentVNode("",!0)],6)),[[ye,z]])}}},vn=Se(fg,[["__scopeId","data-v-afaf943d"]]),pg={class:"comments-list"},hg={key:0},mg={class:"comment-item"},vg={key:1},gg={class:"comment-item"},bg={__name:"commentsList",props:{showMainComments:{type:Boolean,default:!0},showResolvedComments:{type:Boolean,default:!0}},setup(e){const t=e;Qe();const n=at(),{COMMENT_EVENTS:r}=n,{commentsList:i,getGroupedComments:s,isCommentsListVisible:a}=Ve(n),{proxy:l}=o.getCurrentInstance(),c=o.computed(()=>t.showResolvedComments&&s.value?.resolvedComments?.length>0);return o.onMounted(()=>{a.value=!0}),o.onBeforeUnmount(()=>{a.value=!1}),(u,d)=>(o.openBlock(),o.createElementBlock("div",pg,[e.showMainComments?(o.openBlock(),o.createElementBlock("div",hg,[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(o.unref(s).parentComments,p=>(o.openBlock(),o.createElementBlock("div",mg,[o.createVNode(vn,{comment:p},null,8,["comment"])]))),256))])):o.createCommentVNode("",!0),c.value?(o.openBlock(),o.createElementBlock("div",vg,[d[0]||(d[0]=o.createBaseVNode("div",{class:"comment-title"},"Resolved",-1)),(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(o.unref(s).resolvedComments,p=>(o.openBlock(),o.createElementBlock("div",gg,[o.createVNode(vn,{comment:p},null,8,["comment"])]))),256))])):o.createCommentVNode("",!0)]))}},yg=Se(bg,[["__scopeId","data-v-12d3e3dd"]]);class wg extends qi.EventEmitter{element;config={comments:[],element:null,commentsStore:null};constructor(t,n){super(),this.config={...this.config,...t},this.element=this.config.element,this.app=null,this.superdoc=n,this.open()}createVueApp(){this.app=o.createApp(yg),this.app.directive("click-outside",Zi),this.app.config.globalProperties.$superdoc=this.superdoc,!this.element&&this.config.selector&&(this.element=document.getElementById(this.config.selector)),this.container=this.app.mount(this.element)}close(){this.app&&(this.app.unmount(),this.app=null,this.container=null,this.element=null)}open(){this.app||this.createVueApp()}}const Cg=(e,t)=>{const n=t-e;return Array.from({length:n},(r,i)=>e+i)},xg={key:0,class:"superdoc-pdf-viewer__loader"},Eg={__name:"PdfViewer",props:{documentData:{type:Object,required:!0}},emits:["page-loaded","ready","selection-change","bypass-selection"],setup(e,{emit:t}){const n=t,r=Qe(),{proxy:i}=o.getCurrentInstance(),{activeZoom:s}=Ve(r),a=o.ref(null),l=o.ref(null),c=o.ref(!1),d=i.$superdoc.config.pdfViewer.textLayerMode??0;let p=null,h=[];const b=e,m=b.documentData.id,C=b.documentData.data,w=E=>{const k=E.getViewport({scale:1}),N=k.width,P=k.height;return{width:N,height:P}};async function v(){i?.$superdoc?.config?.pdfjsWorkerSrcUrl&&(kr.GlobalWorkerOptions.workerSrc=i.$superdoc.config.pdfjsWorkerSrcUrl)}async function I(E){await v();const k=kr.getDocument(E),N=await k.promise;return{loadingTask:k,document:N}}async function B(E){const k=new FileReader;k.onload=async function(N){const{loadingTask:P,document:x}=await I(N.target.result);p=x,S(x)},k.readAsArrayBuffer(E)}const S=E=>{setTimeout(()=>{T(E)},150)};async function O(E,k,N){const P=Cg(k,N+1).map(x=>E.getPage(x));return await Promise.all(P)}async function T(E){try{const k=E.numPages;a.value=k;const P=await O(E,1,k),x=[];for(const[D,A]of P.entries()){const z=document.createElement("div");z.className="pdf-page",z.dataset.pageNumber=D+1,z.id=`${m}-page-${D+1}`,x.push(z);const{width:F,height:W}=w(A),Y=1,ne=new _r.EventBus,ce=new _r.PDFPageView({container:z,id:D+1,scale:Y,defaultViewport:A.getViewport({scale:Y}),eventBus:ne,textLayerMode:d});h.push(ce);const me=z.getBoundingClientRect();me.originalWidth=F,me.originalHeight=W,ce.setPdfPage(A),await ce.draw(),n("page-loaded",m,D,me)}l.value.append(...x),c.value=!0,n("ready",m,l)}catch(k){console.error("Error loading PDF:",k)}}function f(E){const k=window.getSelection();if(k.rangeCount===0)return null;const P=k.getRangeAt(0).getClientRects();if(P.length===0)return null;const x=P[0];let D={top:x.top,left:x.left,bottom:x.bottom,right:x.right};for(let z=1;z<P.length;z++){const F=P[z];F.width===0||F.height===0||(D.top=Math.min(D.top,F.top),D.left=Math.min(D.left,F.left),D.bottom=Math.max(D.bottom,F.bottom),D.right=Math.max(D.right,F.right))}const A=E.getBoundingClientRect();return l.value.getBoundingClientRect(),D.top=(D.top-A.top)/(s.value/100)+E.scrollTop,D.left=(D.left-A.left)/(s.value/100)+E.scrollLeft,D.bottom=(D.bottom-A.top)/(s.value/100)+E.scrollTop,D.right=(D.right-A.left)/(s.value/100)+E.scrollLeft,D}const y=E=>{const{target:k}=E;k.tagName!=="SPAN"&&n("bypass-selection",E)},$=E=>{if(window.getSelection().toString().length>0){const N=f(l.value),P=dn({selectionBounds:N,documentId:m});n("selection-change",P)}},g=()=>{h.forEach(E=>E.destroy()),p.cleanup(),p.destroy(),h=[],p=null};return o.onMounted(async()=>{await Promise.resolve().then(()=>require("./chunks/pdf_viewer-Dyvby5gX.cjs")),await B(C)}),o.onUnmounted(()=>{g()}),(E,k)=>(o.openBlock(),o.createElementBlock("div",{class:"superdoc-pdf-viewer-container",onMousedown:y,onMouseup:$},[o.createBaseVNode("div",{class:"superdoc-pdf-viewer",ref_key:"viewer",ref:l,id:"viewerId"},null,512),c.value?o.createCommentVNode("",!0):(o.openBlock(),o.createElementBlock("div",xg,[o.createVNode(o.unref(pv),{class:"superdoc-pdf-viewer__spin",size:"large"})]))],32))}},Sg=Se(Eg,[["__scopeId","data-v-33ecc09d"]]),kg={class:"comments-container",id:"commentsContainer"},_g={class:"comments-layer"},$g=["onClick","data-id"],Tg={__name:"CommentsLayer",props:{user:{type:Object,required:!0},parent:{type:Object,required:!0}},emits:["highlight-click"],setup(e,{expose:t,emit:n}){const r=Qe(),i=at(),{COMMENT_EVENTS:s}=i,{documentsWithConverations:a,activeComment:l,floatingCommentsOffset:c,commentsList:u}=Ve(i),{documents:d,activeZoom:p}=Ve(r),{proxy:h}=o.getCurrentInstance(),b=n,m=e,C=S=>{const O={creatorEmail:m.user.email,creatorName:m.user.name,documentId:S.documentId,selection:S,isFocused:!0},T=S.selectionBounds;if(T.top>T.bottom){const $=T.top;T.top=T.bottom,T.bottom=$}if(T.left>T.right){const $=T.left;T.left=T.right,T.right=$}S.selectionBounds=T;const f=d.value.find($=>$.id===S.documentId),y=St(O);l.value=y.commentId,f.conversations.push(y),h.$superdoc.emit("comments-update",{type:s.NEW,comment:y.getValues()})},w=S=>{const{selection:O,commentId:T}=S,f=O.getContainerLocation(m.parent),y=S.selection.selectionBounds;(parseFloat(y.top)+f.top)*p.value;const $="#078383",g="#B1124B";let E="33";l.value===T&&(E="66");let k=S.isInternal?$:g;return k+=E,{position:"absolute",top:parseFloat(y.top)+"px",left:y.left+"px",width:y.right-y.left+"px",height:y.bottom-y.top+"px",backgroundColor:k,pointerEvents:S.suppressClick?"none":"auto"}},v=S=>{c.value=S.selection.selectionBounds.top},I=(S,O)=>{S.isFocused=!0,l.value=S.commentId,S.setActive(h.$superdoc),b("highlight-click",S)},B=o.computed(()=>u.value.filter(S=>!S.parentCommentId).filter(S=>S.selection&&S.selection.selectionBounds?.top).filter(S=>!S.resolvedTime).filter(S=>S.selection?.source!=="super-editor"));return o.watch(l,S=>{if(!S)return;document.getElementById(S)?.scrollIntoView({behavior:"smooth",block:"center"})}),t({addCommentEntry:C,activateComment:I,setFloatingCommentOffset:v}),(S,O)=>(o.openBlock(),o.createElementBlock("div",kg,[o.createBaseVNode("div",_g,[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(B.value,T=>(o.openBlock(),o.createElementBlock("div",{class:"comment-anchor sd-highlight",onClick:o.withModifiers(f=>I(T),["stop","prevent"]),"data-id":T.commentId,style:o.normalizeStyle(w(T))},null,12,$g))),256))])]))}},Ig=Se(Tg,[["__scopeId","data-v-fbd54adc"]]),Og={class:"sidebar-container calculation-container"},Bg=["id"],Pg={__name:"FloatingComments",props:{currentDocument:{type:Object,required:!0},parent:{type:Object,required:!0}},setup(e){const t=e;Qe();const n=at(),{getFloatingComments:r,hasInitializedLocations:i,activeComment:s,commentsList:a,editorCommentPositions:l}=Ve(n),c=o.ref(null),u=o.ref([]),d=o.ref(!1),p=o.ref(0),h=o.ref(0),b=o.computed(()=>v=>c.value?(c.value.getBoundingClientRect(),typeof v.top!="number"||isNaN(v.top)?{display:"none"}:{top:`${v.top}px`}):{top:"0px"}),m=v=>{if(!v)return window;let I=v.parentNode;for(;I&&I!==document;){const B=getComputedStyle(I);if(/(auto|scroll|overlay)/.test(B.overflow+B.overflowY+B.overflowX))return I;I=I.parentNode}return window},C=v=>{if(!v)return;const{elementRef:I,commentId:B}=v;I&&o.nextTick(()=>{const S=B;if(u.value.some(E=>E.id==S))return;const O=r.value.find(E=>E.commentId===S||E.importedId==S),T=l.value[S]?.bounds;if(!T)return;const f=m(t.parent);f===window?window.scrollY:f.scrollTop;const y=t.parent.getBoundingClientRect(),$=I.value?.getBoundingClientRect(),g={id:S,top:T.top-y.top,height:$.height,commentRef:O,elementRef:I};u.value.push(g)})},w=async()=>{let v=0;u.value.sort((I,B)=>I.top-B.top).forEach(I=>{I.top<=v+15&&(I.top=v+15),v=I.top+I.height}),await o.nextTick(),d.value=!0};return o.watchEffect(()=>{u.value.length===r.value.length&&o.nextTick(w)}),o.watch(s,(v,I)=>{o.nextTick(()=>{if(!s.value)return p.value=0;const B=n.getComment(s.value);if(!B)return p.value=0;const S=u.value.find(f=>f.id===B.commentId);if(!S)return p.value=0;const O=B.selection.selectionBounds.top,T=S.top;c.value.getBoundingClientRect(),p.value=O-T,setTimeout(()=>{S.elementRef.value?.scrollIntoView({behavior:"smooth",block:"center"})},200)})}),(v,I)=>(o.openBlock(),o.createElementBlock("div",{class:"section-wrapper",ref_key:"floatingCommentsContainer",ref:c},[o.createBaseVNode("div",Og,[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(o.unref(r),B=>(o.openBlock(),o.createElementBlock("div",{key:B.commentId||B.importedId},[o.createBaseVNode("div",{id:B.commentId||B.importedId,class:"measure-comment"},[(o.openBlock(),o.createBlock(vn,{onReady:C,key:B.commentId+h.value,class:"floating-comment",parent:e.parent,comment:B},null,8,["parent","comment"]))],8,Bg)]))),128))]),d.value?(o.openBlock(),o.createElementBlock("div",{key:0,class:"sidebar-container",style:o.normalizeStyle({top:p.value+"px"})},[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(u.value,B=>(o.openBlock(),o.createElementBlock("div",{key:B.id,style:o.normalizeStyle(b.value(B)),class:"floating-comment"},[(o.openBlock(),o.createBlock(vn,{key:B.id+h.value,class:"floating-comment",parent:e.parent,comment:B.commentRef},null,8,["parent","comment"]))],4))),128))],4)):o.createCommentVNode("",!0)],512))}},Dg=Se(Pg,[["__scopeId","data-v-76d3706b"]]),Rg={__name:"TextField",props:{field:{type:Object,required:!0},isEditing:{type:Boolean,required:!1,default:!1},styleOverride:{type:Object,required:!1,default:()=>({})}},setup(e){const t=e,n=o.computed(()=>{const r={...t.styleOverride};return t.isEditing&&(r.backgroundColor="#FFF"),r});return(r,i)=>(o.openBlock(),o.createElementBlock("div",{class:"text-field",style:o.normalizeStyle(n.value)},o.toDisplayString(e.field.value||e.field.placeholder),5))}},Ag=Se(Rg,[["__scopeId","data-v-f3984d30"]]),Mg=["innerHTML"],Ng={key:1},Fg={__name:"ParagraphField",props:{field:{type:Object,required:!0},isEditing:{type:Boolean,required:!1,default:!1},styleOverride:{type:Object,required:!1,default:()=>({})}},setup(e){const t=e,n=o.computed(()=>({fontSize:`${(t.styleOverride?.originalFontSize||120)/10}px`}));return(r,i)=>e.field.value?(o.openBlock(),o.createElementBlock("div",{key:0,class:"paragraph-field",style:o.normalizeStyle(n.value),innerHTML:e.field.value},null,12,Mg)):(o.openBlock(),o.createElementBlock("span",Ng,o.toDisplayString(e.field.placeholder||e.field.label),1))}},zg=Se(Fg,[["__scopeId","data-v-98d7a2df"]]),Lg=["src"],Hg={key:1},Vg={__name:"ImageField",props:{field:{type:Object,required:!0},isEditing:{type:Boolean,required:!1,default:!1},styleOverride:{type:Object,required:!1,default:()=>({})},optionId:{type:String,required:!0},noStyle:{type:Boolean,required:!1,default:!1}},setup(e){const t=e,n=o.computed(()=>({maxHeight:t.styleOverride.coordinates?.minHeight,maxWidth:t.styleOverride.coordinates?.minWidth})),r=o.computed(()=>{if(t.field.valueGetter&&typeof t.field.valueGetter=="function")return t.field.valueGetter({annotationId:t.optionId});if(typeof t.field.value=="string")return t.field.value});return(i,s)=>(o.openBlock(),o.createElementBlock("div",{class:"image-field",style:o.normalizeStyle(n.value)},[e.field.value&&r.value?(o.openBlock(),o.createElementBlock("img",{key:0,src:r.value,alt:"image",style:o.normalizeStyle(n.value)},null,12,Lg)):e.noStyle?o.createCommentVNode("",!0):(o.openBlock(),o.createElementBlock("span",Hg,o.toDisplayString(e.field.placeholder||e.field.label),1))],4))}},Ui=Se(Vg,[["__scopeId","data-v-7dd69850"]]),jg={class:"checkbox-container"},Ug={__name:"CheckboxField",props:{field:{type:Object,required:!0},isEditing:{type:Boolean,required:!1,default:!1},optionId:{type:String,required:!0}},setup(e){const t=e,n=o.computed(()=>t.field.options.find(i=>i.annotationId.includes(t.optionId))?.checked);return(r,i)=>(o.openBlock(),o.createElementBlock("div",jg,[o.createVNode(o.unref(Um),{checked:n.value,disabled:!t.isEditing},null,8,["checked","disabled"])]))}},Wg=Se(Ug,[["__scopeId","data-v-fc53fd29"]]),Kg={key:0},Gg={__name:"SelectField",props:{field:{type:Object,required:!0},fieldStyle:{type:Object,required:!1,default:()=>({})},styleOverride:{type:Object,required:!1,default:()=>({})}},setup(e){const t=e,n=o.computed(()=>{if(!t.isEditing)return{...t.styleOverride}});return(r,i)=>(o.openBlock(),o.createElementBlock("div",{style:o.normalizeStyle(n.value),class:"select-container"},[t.isEditing?o.createCommentVNode("",!0):(o.openBlock(),o.createElementBlock("div",Kg,o.toDisplayString(e.field.value||e.field.placeholder),1))],4))}},qg=Se(Gg,[["__scopeId","data-v-b8cacb22"]]),Xg=or("hrbr-fields",()=>{const e=Qe(),{documents:t,pages:n}=Ve(e),r=o.reactive({name:"hrbr-fields"}),i=Object.freeze({TEXTINPUT:o.markRaw(Ag),HTMLINPUT:o.markRaw(zg),SELECT:o.markRaw(qg),CHECKBOXINPUT:o.markRaw(Wg),SIGNATUREINPUT:o.markRaw(Ui),IMAGEINPUT:o.markRaw(Ui)}),s=(c,u)=>{const d=t.value.find(h=>h.id===c);if(!d)return;const p=d.fields.find(h=>h.id===u);if(p)return p},a=o.computed(()=>{const c=[];return t.value.forEach(u=>{const{id:d,annotations:p}=u,h=u.container;if(!h)return;const b=h.getBoundingClientRect(),m=u.pageContainers;!b||!m||p.forEach(C=>{const{itemid:w,page:v,nostyle:I}=C;let B=C.pageannotation;C.itemfieldtype==="CHECKBOXINPUT"&&(B=C.annotationid);const{x1:S,y1:O,x2:T,y2:f}=C,y={x1:S,y1:O,x2:T,y2:f},$=document.getElementById(`${d}-page-${v+1}`);if(!$)return;const g=$.getBoundingClientRect(),E=u.pageContainers.find(z=>z.page===v+1),k=g.height/E.containerBounds.originalHeight,N=g.bottom-b.top,P=g.left-b.left,x=l(y,k,N,P),D={fontSize:C.original_font_size+"px",originalFontSize:C.original_font_size,coordinates:x},A={documentId:d,fieldId:w,page:v,annotationId:B,originalAnnotationId:C.originalannotationid,coordinates:x,style:D,nostyle:I??!1};c.push(A)})}),c}),l=(c,u,d,p)=>{const{x1:h,y1:b,x2:m,y2:C}=c,w=h*u,v=b*u,I=m*u,B=C*u;return{top:`${d-B}px`,left:`${w+p}px`,minWidth:`${I-w}px`,minHeight:`${B-v}px`}};return{hrbrFieldsConfig:r,fieldComponentsMap:i,getAnnotations:a,getField:s}}),Yg={class:"main-container"},Jg={__name:"HrbrFieldsLayer",props:{fields:{type:Object,required:!0}},setup(e){const t=Xg(),{getAnnotations:n}=Ve(t),{fieldComponentsMap:r,getField:i}=t,s=o.computed(()=>l=>{const{coordinates:c,field:u}=l;if(["TEXTINPUT","SELECT"].includes(u.fieldType)){const b=c.top.split("px")[0]-4;c.top=`${b}px`}if(["HTMLINPUT"].includes(u.fieldType)){const m=c.minWidth.split("px")[0]/1.3362445414847162;c.width=`${m}px`}return{position:"absolute",...c,lineHeight:1}}),a=o.computed(()=>{const l=[];return n.value.forEach(c=>{const u=i(c.documentId,c.fieldId);u&&l.push({...c,field:u})}),l});return(l,c)=>(o.openBlock(),o.createElementBlock("div",Yg,[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(a.value,u=>(o.openBlock(),o.createElementBlock("div",{style:o.normalizeStyle(s.value(u)),class:o.normalizeClass(["field-container",{"field-container--no-style":u.nostyle}])},[(o.openBlock(),o.createBlock(o.resolveDynamicComponent(o.unref(r)[u.field.fieldType]),{class:"field-component",field:u.field,"style-override":u.style,"option-id":u.originalAnnotationId,"no-style":u.nostyle,"is-editing":!1},null,8,["field","style-override","option-id","no-style"]))],6))),256))]))}},Zg=Se(Jg,[["__scopeId","data-v-22e6ae02"]]),Qg={class:"superdoc-html-viewer"},eb={class:"superdoc-html-viewer__document"},tb=["innerHTML"],nb={__name:"HtmlViewer",props:{fileSource:{type:File,required:!0},documentId:{type:String,required:!0}},emits:["ready","selection-change"],setup(e,{emit:t}){const n=e,r=o.ref(""),i=t,s=()=>{const c=window.getSelection();console.debug("selection from html viewer",c),i("selection-change",c)},a=c=>new Promise((u,d)=>{const p=new FileReader;p.onload=h=>{const b=h.target.result;u(b)},p.onerror=h=>d(h),p.readAsText(c)}),l=async()=>{try{const c=await a(n.fileSource);r.value=c,i("ready",n.documentId)}catch(c){i("error",c),console.error("Error loading document",c)}};return o.onMounted(()=>{l()}),(c,u)=>(o.openBlock(),o.createElementBlock("div",Qg,[o.createBaseVNode("div",eb,[o.createBaseVNode("div",{class:"superdoc-html-viewer__content",innerHTML:r.value,onMouseup:s},null,40,tb)])]))}},ob=Se(nb,[["__scopeId","data-v-7bd2cb5d"]]),rb=["innerHTML"],ib={class:"superdoc__document document"},sb={key:0,class:"superdoc__right-sidebar right-sidebar"},ab={class:"floating-comments"},lb={__name:"SuperDoc",emits:["selection-update"],setup(e,{emit:t}){const n=Qe(),r=at(),{documents:i,isReady:s,areDocumentsReady:a,selectionPosition:l,activeSelection:c,activeZoom:u}=Ve(n),{handlePageReady:d,modules:p,user:h,getDocument:b}=n,{getConfig:m,documentsWithConverations:C,commentsList:w,pendingComment:v,activeComment:I,skipSelectionUpdate:B,commentsByDocument:S,isCommentsListVisible:O,isFloatingCommentsReady:T,generalCommentIds:f,getFloatingComments:y,hasSyncedCollaborationComments:$,editorCommentPositions:g,hasInitializedLocations:E}=Ve(r),{showAddComment:k,handleEditorLocationsUpdate:N,handleTrackedChangeUpdate:P}=r,{proxy:x}=o.getCurrentInstance();r.proxy=x;const D=o.ref(null),A=o.ref(null),z=o.reactive({top:null,right:"-25px",zIndex:101}),F=o.ref(null),W=(M,_)=>{const R=b(M);R.isReady=!0,R.container=_,a.value&&(x.$superdoc.config.collaboration||(s.value=!0)),T.value=!0,x.$superdoc.broadcastPdfDocumentReady()},Y=M=>{const _={comments:()=>k(x.$superdoc)};M in _&&_[M](c.value,l.value),c.value=null,z.top=null},ne=M=>{v.value},ce=()=>z.top=null,me=M=>{M.target.classList.contains("n-dropdown-option-body__label")||r.removePendingComment(x.$superdoc)},Be=({editor:M,comments:_,replacedFile:R})=>{(M.options.shouldLoadComments||R)&&o.nextTick(()=>{r.processLoadedDocxComments({superdoc:x.$superdoc,editor:M,comments:_,documentId:M.options.documentId})})},he=({editor:M})=>{x.$superdoc?.broadcastEditorBeforeCreate(M)},oe=({editor:M})=>{const{documentId:_}=M.options;b(_).setEditor(M),x.$superdoc.setActiveEditor(M),x.$superdoc.broadcastEditorCreate(M),x.$superdoc.log("[SuperDoc] Editor created",x.$superdoc.activeEditor),x.$superdoc.log("[SuperDoc] Page styles (pixels)",M.getPageStyles())},Ae=()=>{x.$superdoc.broadcastEditorDestroy()},X=({editor:M})=>{x.$superdoc.setActiveEditor(M)},J=({editor:M,isLocked:_,lockedBy:R})=>{x.$superdoc.lockSuperdoc(_,R)},ye=({editor:M})=>{x.$superdoc.emit("editor-update",{editor:M})},ie=({editor:M,transaction:_})=>{if(B.value){B.value=!1;return}const{documentId:R}=M.options,{$from:H,$to:ee}=_.selection;if(H.pos===ee.pos&&ze({x:null,y:null,source:"super-editor"}),!D.value)return;const{view:fe}=M,we=fe.coordsAtPos(H.pos),ke=fe.coordsAtPos(ee.pos),{pageMargins:ue}=M.getPageStyles(),Oe=D.value.getBoundingClientRect(),uo=Math.max(96,we.top-Oe.top),fo=ke.bottom-Oe.top,po={top:uo,left:we.left,right:ke.left,bottom:fo},ho=dn({selectionBounds:po,page:1,documentId:R,source:"super-editor"});Fe(ho)},Me=({editor:M})=>{x.$superdoc.emit("collaboration-ready",{editor:M}),o.nextTick(()=>{s.value=!0;const R=new URLSearchParams(window.location.search).get("commentId");R&&Ee(R)})},Ke=({error:M,editor:_})=>{x.$superdoc.emit("content-error",{error:M,editor:_})},L=({error:M,editor:_})=>{x.$superdoc.emit("exception",{error:M,editor:_})},V=M=>({pagination:x.$superdoc.config.pagination,documentId:M.id,user:x.$superdoc.user,users:x.$superdoc.users,colors:x.$superdoc.colors,role:x.$superdoc.config.role,documentMode:x.$superdoc.config.documentMode,rulers:M.rulers,isInternal:x.$superdoc.config.isInternal,annotations:x.$superdoc.config.annotations,isCommentsEnabled:x.$superdoc.config.modules?.comments,onBeforeCreate:he,onCreate:oe,onDestroy:Ae,onFocus:X,onDocumentLocked:J,onUpdate:ye,onSelectionUpdate:ie,onCollaborationReady:Me,onContentError:Ke,onException:L,onCommentsLoaded:Be,onCommentsUpdate:Q,onCommentLocationsUpdate:G,ydoc:M.ydoc,collaborationProvider:M.provider||null,isNewFile:M.isNewFile||!1,handleImageUpload:x.$superdoc.config.handleImageUpload,telemetry:x.$superdoc.telemetry,externalExtensions:x.$superdoc.config.editorExtensions||[]}),G=({allCommentIds:M,allCommentPositions:_})=>{x.$superdoc.config.modules?.comments&&N(_,M)},Q=(M={})=>{const{activeCommentId:_,type:R}=M;R==="trackedChange"&&P({superdoc:x.$superdoc,params:M}),o.nextTick(()=>{v.value||r.setActiveComment(_)}),typeof x.$superdoc.config.onCommentsUpdate=="function"&&x.$superdoc.config.onCommentsUpdate(M)},Z=o.computed(()=>"comments"in p),te=o.computed(()=>v.value||y.value?.length>0&&s.value&&D.value&&Z.value&&!O.value),q=o.computed(()=>Z.value?z.top&&!m.value?.readOnly:!1);o.computed(()=>{if(!Z.value)return!1;!m?.readOnly&&l.value}),o.watch(te,M=>{x.$superdoc.broadcastSidebarToggle(M)});const Ee=M=>{if(!x.$superdoc.config?.modules?.comments)return;const _=document.querySelector(`[data-thread-id=${M}]`);_&&(_.scrollIntoView({behavior:"smooth",block:"start"}),r.setActiveComment(M))};o.onMounted(()=>{Z.value&&!p.comments.readOnly&&document.addEventListener("mousedown",ne)}),o.onBeforeUnmount(()=>{document.removeEventListener("mousedown",ne)});const ae=o.ref(null),re=o.ref(!1),Pe=o.computed(()=>{if(!l.value||l.value.source==="super-editor")return{x:null,y:null};const M=l.value.top,_=l.value.left,R=l.value.right,H=l.value.bottom;return{zIndex:500,borderRadius:"4px",top:M+"px",left:_+"px",height:Math.abs(M-H)+"px",width:Math.abs(_-R)+"px"}}),Fe=M=>{if(!M.selectionBounds||!Z.value)return;Ge();const _=window.matchMedia("(max-width: 768px)").matches;if(ze({startX:M.selectionBounds.left,startY:M.selectionBounds.top,x:M.selectionBounds.right,y:M.selectionBounds.bottom,source:M.source}),!l.value)return;const R=Math.abs(l.value.left-l.value.right)>5,H=Math.abs(l.value.top-l.value.bottom)>5;if(!R||!H){ae.value.style.pointerEvents="none",Ge();return}c.value=M;let ee=M.selectionBounds.top;z.top=ee+"px",z.right=_?"0":"-25px"},Ge=()=>{l.value=null},ze=({startX:M,startY:_,x:R,y:H,source:ee})=>{if(!(M||_)&&!(R||H))return l.value=null;if(!l.value){if(_<=0||M<=0)return;l.value={top:_,left:M,right:M,bottom:_,startX:M,startY:_,source:ee}}M&&(l.value.startX=M),_&&(l.value.startY=_);const ke=l.value.startY;H<ke?l.value.top=H:l.value.bottom=H;const ue=l.value.startX;R<ue?l.value.left=R:l.value.right=R},ut=M=>{Ge(),ae.value.style.pointerEvents="auto",o.nextTick(()=>{re.value=!0;const _=M.offsetY/(u.value/100),R=M.offsetX/(u.value/100);ze({startX:R,startY:_}),ae.value.addEventListener("mousemove",Mt)})},Mt=M=>{if(!re.value)return;const _=M.offsetY/(u.value/100),R=M.offsetX/(u.value/100);ze({x:R,y:_})},Jt=M=>{if(!re.value||(ae.value.removeEventListener("mousemove",Mt),!l.value))return;const _=dn({selectionBounds:{top:l.value.top,left:l.value.left,right:l.value.right,bottom:l.value.bottom},documentId:i.value[0].id});Fe(_),ae.value.style.pointerEvents="none"},Zt=o.computed(()=>!(x.$superdoc.config.modules?.comments).readOnly),xn=(M,_)=>{M.documentMarginsLastChange=_.pageMargins},dt=M=>{Z.value&&(Ge(),re.value=!0,ut(M))};return o.watch(y,()=>{E.value=!1,o.nextTick(()=>{E.value=!0})}),(M,_)=>{const R=o.resolveDirective("click-outside");return o.openBlock(),o.createElementBlock("div",{class:o.normalizeClass(["superdoc",{"superdoc--with-sidebar":te.value}])},[o.createBaseVNode("div",{class:"superdoc__layers layers",ref_key:"layers",ref:D},[q.value?(o.openBlock(),o.createElementBlock("div",{key:0,class:"superdoc__tools tools",style:o.normalizeStyle(z)},[o.createBaseVNode("div",{class:"tools-item","data-id":"is-tool",onClick:_[0]||(_[0]=o.withModifiers(H=>Y("comments"),["stop","prevent"]))},[o.createBaseVNode("div",{class:"superdoc__tools-icon",innerHTML:o.unref(st).comment},null,8,rb)])],4)):o.createCommentVNode("",!0),o.createBaseVNode("div",ib,[Z.value?(o.openBlock(),o.createElementBlock("div",{key:0,class:"superdoc__selection-layer selection-layer",onMousedown:ut,onMouseup:Jt,ref_key:"selectionLayer",ref:ae},[o.unref(l)&&Zt.value?(o.openBlock(),o.createElementBlock("div",{key:0,style:o.normalizeStyle(Pe.value),class:"superdoc__temp-selection temp-selection sd-highlight sd-initial-highlight"},null,4)):o.createCommentVNode("",!0)],544)):o.createCommentVNode("",!0),"hrbr-fields"in o.unref(p)&&D.value?(o.openBlock(),o.createBlock(Zg,{key:1,fields:o.unref(p)["hrbr-fields"],class:"superdoc__comments-layer comments-layer",style:{"z-index":"2"},ref_key:"hrbrFieldsLayer",ref:F},null,8,["fields"])):o.createCommentVNode("",!0),D.value?(o.openBlock(),o.createBlock(Ig,{key:2,class:"superdoc__comments-layer comments-layer",style:{"z-index":"3"},ref_key:"commentsLayer",ref:A,parent:D.value,user:o.unref(h),onHighlightClick:ce},null,8,["parent","user"])):o.createCommentVNode("",!0),(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(o.unref(i),H=>(o.openBlock(),o.createElementBlock("div",{class:"superdoc__sub-document sub-document",key:H.id},[H.type===o.unref(gn)?(o.openBlock(),o.createBlock(Sg,{key:0,"document-data":H,onSelectionChange:Fe,onReady:W,onPageLoaded:o.unref(d),onBypassSelection:dt},null,8,["document-data","onPageLoaded"])):o.createCommentVNode("",!0),H.type===o.unref(gt)?(o.openBlock(),o.createBlock(o.unref(Ce.fo),{key:1,"file-source":H.data,state:H.state,"document-id":H.id,options:V(H),onPageMarginsChange:ee=>xn(H,ee)},null,8,["file-source","state","document-id","options","onPageMarginsChange"])):o.createCommentVNode("",!0),H.type===o.unref(oo)?(o.openBlock(),o.createBlock(ob,{key:2,onReady:_[1]||(_[1]=ee=>W(ee,null)),onSelectionChange:Fe,"file-source":H.data,"document-id":H.id},null,8,["file-source","document-id"])):o.createCommentVNode("",!0)]))),128))])],512),te.value?(o.openBlock(),o.createElementBlock("div",sb,[o.unref(v)?o.withDirectives((o.openBlock(),o.createBlock(vn,{key:0,comment:o.unref(v),"auto-focus":!0,"is-floating":!0},null,8,["comment"])),[[R,me]]):o.createCommentVNode("",!0),o.createBaseVNode("div",ab,[o.unref(E)&&o.unref(y).length>0?(o.openBlock(!0),o.createElementBlock(o.Fragment,{key:0},o.renderList(o.unref(C),H=>(o.openBlock(),o.createBlock(Dg,{parent:D.value,"current-document":H},null,8,["parent","current-document"]))),256)):o.createCommentVNode("",!0)])])):o.createCommentVNode("",!0)],2)}}},cb=Se(lb,[["__scopeId","data-v-3731e285"]]),ub=()=>{const e=o.createApp(cb),t=Sl();e.use(t),e.directive("click-outside",Zi);const n=Qe(),r=at();return{app:e,pinia:t,superdocStore:n,commentsStore:r}},Wi=(e,t,n)=>{const r=URL.createObjectURL(e),i=document.createElement("a");i.href=r,i.download=`${t}.${n}`,i.click()},Ki=e=>e.toLowerCase().endsWith(".docx")||e.toLowerCase().endsWith(".pdf")?e.slice(0,-5):e;class db extends qi.EventEmitter{static allowedTypes=[gt,gn,oo];version;users;config={superdocId:null,selector:"#superdoc",documentMode:"editing",role:"editor",documents:[],format:null,editorExtensions:[],colors:[],user:{name:null,email:null},users:[],pdfjsWorkerSrcUrl:null,modules:{},title:"SuperDoc",conversations:[],pagination:!1,isCollaborative:!1,isInternal:!1,toolbar:null,toolbarGroups:["left","center","right"],toolbarIcons:{},isDev:!1,telemetry:null,pdfViewer:{},onEditorBeforeCreate:()=>null,onEditorCreate:()=>null,onEditorDestroy:()=>null,onContentError:()=>null,onReady:()=>null,onCommentsUpdate:()=>null,onAwarenessUpdate:()=>null,onLocked:()=>null,onPdfDocumentReady:()=>null,onSidebarToggle:()=>null,onCollaborationReady:()=>null,onEditorUpdate:()=>null,onCommentsListChange:()=>null,onException:()=>null,handleImageUpload:null};constructor(t){super(),this.#n(t)}async#n(t){this.config={...this.config,...t},this.config.colors=Rl(this.config.colors),this.userColorMap=new Map,this.colorIndex=0,this.version="0.8.29",console.debug("🦋 [superdoc] Using SuperDoc version:",this.version),this.superdocId=t.superdocId||Yi.v4(),this.colors=this.config.colors,await this.#i(this.config.modules),this.#o(),this.#r(),this.user=this.config.user,this.users=this.config.users||[],this.socket=null,this.isDev=this.config.isDev||!1,this.activeEditor=null,this.comments=[],this.app.mount(this.config.selector),this.readyEditors=0,this.isLocked=this.config.isLocked||!1,this.lockedBy=this.config.lockedBy||null,this.#s(this)}get requiredNumberOfEditors(){return this.superdocStore.documents.filter(t=>t.type===gt).length}get state(){return{documents:this.superdocStore.documents,users:this.users}}#o(){const{app:t,pinia:n,superdocStore:r,commentsStore:i}=ub();this.app=t,this.pinia=n,this.app.config.globalProperties.$config=this.config,this.app.config.globalProperties.$documentMode=this.config.documentMode,this.app.config.globalProperties.$superdoc=this,this.superdocStore=r,this.commentsStore=i,this.version=this.config.version,this.superdocStore.init(this.config),this.commentsStore.init(this.config.modules.comments)}#r(){this.on("editorBeforeCreate",this.config.onEditorBeforeCreate),this.on("editorCreate",this.config.onEditorCreate),this.on("editorDestroy",this.config.onEditorDestroy),this.on("ready",this.config.onReady),this.on("comments-update",this.config.onCommentsUpdate),this.on("awareness-update",this.config.onAwarenessUpdate),this.on("locked",this.config.onLocked),this.on("pdf-document-ready",this.config.onPdfDocumentReady),this.on("sidebar-toggle",this.config.onSidebarToggle),this.on("collaboration-ready",this.config.onCollaborationReady),this.on("editor-update",this.config.onEditorUpdate),this.on("content-error",this.onContentError),this.on("exception",this.config.onException)}async#i({collaboration:t}={}){return t?(this.isCollaborative=!0,this.config.socket=new Xi.HocuspocusProviderWebsocket({url:t.url}),Ul(this),jl(this),Wl(this)):this.config.documents}addSharedUser(t){this.users.some(n=>n.email===t.email)||this.users.push(t)}removeSharedUser(t){this.users=this.users.filter(n=>n.email!==t)}#c(){this.telemetry=new jn({enabled:this.config.telemetry?.enabled??!0,licenseKey:this.config.telemetry?.licenseKey,endpoint:this.config.telemetry?.endpoint,superdocId:this.superdocId,superdocVersion:this.version})}onContentError({error:t,editor:n}){const{documentId:r}=n.options,i=this.superdocStore.documents.find(s=>s.id===r);this.config.onContentError({error:t,editor:n,documentId:i.id,file:i.data})}broadcastPdfDocumentReady(){this.emit("pdf-document-ready")}broadcastReady(){this.readyEditors===this.requiredNumberOfEditors&&this.emit("ready",{superdoc:this})}broadcastEditorBeforeCreate(t){this.emit("editorBeforeCreate",{editor:t})}broadcastEditorCreate(t){this.readyEditors++,this.broadcastReady(),this.emit("editorCreate",{editor:t})}broadcastEditorDestroy(){this.emit("editorDestroy")}broadcastSidebarToggle(t){this.emit("sidebar-toggle",t)}log(...t){console.debug("🦋 🦸‍♀️ [superdoc]",...t)}setActiveEditor(t){this.activeEditor=t,this.toolbar&&this.toolbar.setActiveEditor(t)}toggleRuler(){this.config.rulers=!this.config.rulers,this.superdocStore.documents.forEach(t=>{t.rulers=this.config.rulers})}#s(){const t=this.config.modules?.toolbar||{};this.toolbarElement=this.config.modules?.toolbar?.selector||this.config.toolbar,this.toolbar=null;const n={selector:this.toolbarElement||null,isDev:this.isDev||!1,toolbarGroups:this.config.modules?.toolbar?.groups||this.config.toolbarGroups,role:this.config.role,pagination:this.config.pagination,icons:this.config.toolbarIcons,documentMode:this.config.documentMode,superdoc:this,...t};this.toolbar=new Ce.po(n),this.toolbar.on("superdoc-command",this.onToolbarCommand.bind(this)),this.once("editorCreate",()=>this.toolbar.updateToolbarState())}addCommentsList(t){!this.config?.modules?.comments||this.config.role==="viewer"||(console.debug("🦋 [superdoc] Adding comments list to:",t),t&&(this.config.modules.comments.element=t),this.commentsList=new wg(this.config.modules?.comments,this),this.config.onCommentsListChange&&this.config.onCommentsListChange({isRendered:!0}))}removeCommentsList(){this.commentsList&&(this.commentsList.close(),this.commentsList=null,this.config.onCommentsListChange&&this.config.onCommentsListChange({isRendered:!1}))}onToolbarCommand({item:t,argument:n}){t.command==="setDocumentMode"?this.setDocumentMode(n):t.command==="setZoom"&&(this.superdocStore.activeZoom=n)}setDocumentMode(t){if(!t)return;t=t.toLowerCase(),this.config.documentMode=t;const n={viewing:()=>this.#t(),editing:()=>this.#a(),suggesting:()=>this.#e()};n[t]&&n[t]()}#a(){if(this.config.role!=="editor")return this.#e();if(this.superdocStore.documents.length>0){const t=this.superdocStore.documents[0]?.getEditor();t&&this.setActiveEditor(t)}this.superdocStore.documents.forEach(t=>{t.restoreComments();const n=t.getEditor();n&&n.setDocumentMode("editing")}),this.toolbar&&(this.toolbar.documentMode="editing",this.toolbar.updateToolbarState())}#e(){if(!["editor","suggester"].includes(this.config.role))return this.#t();if(this.superdocStore.documents.length>0){const t=this.superdocStore.documents[0]?.getEditor();t&&this.setActiveEditor(t)}this.superdocStore.documents.forEach(t=>{t.restoreComments();const n=t.getEditor();n&&n.setDocumentMode("suggesting")}),this.toolbar&&(this.toolbar.documentMode="suggesting",this.toolbar.updateToolbarState())}#t(){this.toolbar.activeEditor=null,this.superdocStore.documents.forEach(t=>{t.removeComments();const n=t.getEditor();n&&n.setDocumentMode("viewing")}),this.toolbar&&(this.toolbar.documentMode="viewing",this.toolbar.updateToolbarState())}setLocked(t=!0){this.config.documents.forEach(n=>{const r=n.ydoc.getMap("meta");n.ydoc.transact(()=>{r.set("locked",t),r.set("lockedBy",this.user)})})}getHTML(){const t=[];return this.superdocStore.documents.forEach(n=>{const r=n.getEditor();r&&t.push(r)}),t.map(n=>n.getHTML())}lockSuperdoc(t=!1,n){this.isLocked=t,this.lockedBy=n,console.debug("🦋 [superdoc] Locking superdoc:",t,n,`
510
510
 
511
511
 
512
512
  `),this.emit("locked",{isLocked:t,lockedBy:n})}async export({exportType:t=["docx"],commentsType:n,exportedName:r,additionalFiles:i=[],additionalFileNames:s=[]}){const a=Ki(r||this.config.title),l=await this.exportEditorsToDOCX({commentsType:n}),c=[...i],u=[...s];if(t.includes("docx")&&l.forEach((d,p)=>{c.push(d),u.push(`${a}.docx`)}),c.length===1)Wi(c[0],a,t[0]);else{const d=await Ce.c(c,u);Wi(d,a,"zip")}}async exportEditorsToDOCX({commentsType:t}={}){const n=[];t!=="clean"&&n.push(...this.commentsStore?.translateCommentsForExport());const r=[];return this.superdocStore.documents.forEach(i=>{const s=i.getEditor();s&&r.push(s.exportDocx({comments:n,commentsType:t}))}),await Promise.all(r)}async#l(){return console.debug("🦋 [superdoc] Triggering collaboration saves"),new Promise((t,n)=>{this.superdocStore.documents.forEach(r=>{if(this.pendingCollaborationSaves=0,r.ydoc){this.pendingCollaborationSaves++;const i=r.ydoc.getMap("meta");i.observe(s=>{s.changes.keys.has("immediate-save-finished")&&(this.pendingCollaborationSaves--,this.pendingCollaborationSaves<=0&&t())}),i.set("immediate-save",!0)}})})}async save(){const t=[this.#l()];console.debug("🦋 [superdoc] Saving superdoc");const n=await Promise.all(t);return console.debug("🦋 [superdoc] Save complete:",n),n}destroy(){this.app&&(this.log("[superdoc] Unmounting app"),this.config.socket?.cancelWebsocketRetry(),this.config.socket?.disconnect(),this.config.socket?.destroy(),this.ydoc?.destroy(),this.provider?.disconnect(),this.provider?.destroy(),this.config.documents.forEach(t=>{t.provider&&(t.provider.disconnect(),t.provider.destroy()),t.ydoc?.destroy()}),this.superdocStore.reset(),this.telemetry?.destroy(),this.app.unmount(),this.removeAllListeners(),delete this.app.config.globalProperties.$config,delete this.app.config.globalProperties.$superdoc)}}exports.Editor=Ce.Ni;exports.SuperConverter=Ce.Ft;exports.createZip=Ce.c;exports.fieldAnnotationHelpers=Ce.Av;exports.getRichTextExtensions=Ce.hv;exports.superEditorHelpers=Ce.td;exports.trackChangesHelpers=Ce.Tv;exports.BlankDOCX=Gi.BlankDOCX;exports.DOCX=gt;exports.HTML=oo;exports.PDF=gn;exports.SuperDoc=db;exports.compareVersions=Ga;exports.getFileObject=Po;