@veltdev/sdk-staging 6.0.40 → 6.0.41

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.
@@ -9,6 +9,7 @@
9
9
  * Suggestion objects internally and customers do not build them directly.
10
10
  */
11
11
  import { User } from './user.data.model';
12
+ import { Location } from './location.model';
12
13
  /**
13
14
  * Lifecycle state machine for a Suggestion.
14
15
  *
@@ -386,6 +387,26 @@ export interface CommitSuggestionConfig<T = unknown> {
386
387
  * resolver (self-hosting) it is stored by the resolver only.
387
388
  */
388
389
  textChange?: SuggestionTextChange;
390
+ /**
391
+ * Optional location to file the suggestion under (only `id` is required), like `addManualComment`'s
392
+ * `location`. When omitted, the suggestion takes the location of its target element's nearest
393
+ * `data-velt-location-id` (or `data-velt-location` with an `id`) container, else the root location. Pass
394
+ * it when the target has no element (a `registerTarget` getter) but sits in a location's container.
395
+ * A location already set with `setLocations` is used as set (your other fields are not used); any other
396
+ * location is added to the page's locations, as for manual comments.
397
+ */
398
+ location?: Location;
399
+ /**
400
+ * Optional comment context for the suggestion's annotation, stored as `addComment` stores a comment's `context`
401
+ * (e.g. `{ textEditorConfig: { editorId } }`, the editor it was made in, as a rich-text text comment records it).
402
+ * A page-level comment context provider replaces it, as for every comment. It is comment context, not suggestion
403
+ * content: under self-hosting it is kept in Velt's copy (except `context.textEditorConfig.text`, which goes to the
404
+ * comment resolver, as for comments). A JSON copy is taken at commit. Not saved, with a dev warning: anything that
405
+ * is not stored as an object (string, number, array, Date) or cannot be stored as JSON. The SDK's own access keys
406
+ * (`accessFields`, `_setAccessFields`, `_replaceAccessFields`, `_setVisibilityConfig`) are dropped with a dev
407
+ * warning; `access` (context access) is kept, as for a comment.
408
+ */
409
+ context?: Record<string, any>;
389
410
  }
390
411
  /**
391
412
  * Pre-bound builder attached to `targetEditCommit` payloads. Calling it
@@ -0,0 +1,2 @@
1
+ import{f as P,j as ae}from"./chunk-3COV4GP2.js";import{D as he,E as fe}from"./chunk-36PXOB25.js";import{He as A,Kg as D,M as O,V as Z,Xa as ne,Xe as ge,Ya as se,Ze as ue,_i as U,a as b,aa as ee,ac as oe,b as M,ba as x,c as J,ca as te,de as p,di as z,ea as S,g as Y,i as C,k as B,l as Q,oj as de,qd as ce,qj as R,r as $,sa as re,ui as le,v as k,wa as ie,xg as _}from"./chunk-UQB52CCU.js";var V=class{_totalWeight=0;_averageItemSize;_defaultItemSize;constructor(n=50){this._defaultItemSize=n,this._averageItemSize=n}getAverageItemSize(){return this._averageItemSize}addSample(n,a){let e=this._totalWeight+n.end-n.start;if(e){let t=(a+this._averageItemSize*this._totalWeight)/e;t&&(this._averageItemSize=t,this._totalWeight=e)}}reset(){this._averageItemSize=this._defaultItemSize,this._totalWeight=0}},H=class{scrolledIndexChange=new C(()=>{});_viewport=null;_minBufferPx;_maxBufferPx;_averager;_lastScrollOffset;_lastRenderedContentSize;_lastRenderedContentOffset;_removalFailures=0;constructor(n,a,e=new V){this._minBufferPx=n,this._maxBufferPx=a,this._averager=e}attach(n){this._averager.reset(),this._viewport=n,this._renderContentForCurrentOffset()}detach(){this._viewport=null}onContentScrolled(){this._viewport&&this._updateRenderedContentAfterScroll()}onDataLengthChanged(){this._viewport&&(this._renderContentForCurrentOffset(),this._checkRenderedContentSize())}onContentRendered(){this._viewport&&this._checkRenderedContentSize()}onRenderedOffsetChanged(){this._viewport&&this._checkRenderedContentOffset()}scrollToIndex(){}updateBufferSize(n,a){if(a<n)throw Error("CDK virtual scroll: maxBufferPx must be greater than or equal to minBufferPx");this._minBufferPx=n,this._maxBufferPx=a}_updateRenderedContentAfterScroll(){let n=this._viewport,a=n.measureScrollOffset(),e=a-this._lastScrollOffset,t=Math.abs(e),r=n.getRenderedRange(),i=0;if(e<0){let l=r.start*this._averager.getAverageItemSize()-this._lastRenderedContentOffset;i=Math.round(l*Math.max(0,Math.min(1,t/(a+t)))),e=e-i,t=Math.abs(e)}let o=this._lastScrollOffset-this._lastRenderedContentOffset,c=this._lastRenderedContentOffset+this._lastRenderedContentSize-(this._lastScrollOffset+n.getViewportSize()),u=t+this._minBufferPx-(e<0?o:c);if(u>0)if(t>=n.getViewportSize())this._renderContentForCurrentOffset();else{let g=Math.max(0,Math.ceil((u-this._minBufferPx+this._maxBufferPx)/this._averager.getAverageItemSize())),l=(e<0?c:o)-this._minBufferPx+t,h=Math.floor(l/this._averager.getAverageItemSize()/(this._removalFailures+1)),f=Math.min(r.end-r.start,Math.max(0,h)),d=this._expandRange(r,e<0?g:0,e>0?g:0);e<0?d.end=Math.max(d.start+1,d.end-f):d.start=Math.min(d.end-1,d.start+f);let v,E;if(e<0){let y=n.measureRangeSize({start:d.end,end:r.end});y<=l?(v=this._lastRenderedContentOffset+this._lastRenderedContentSize-y,this._removalFailures=0):(d.end=r.end,v=this._lastRenderedContentOffset+this._lastRenderedContentSize,this._removalFailures++),E="to-end"}else{let y=n.measureRangeSize({start:r.start,end:d.start});y<=l?(v=this._lastRenderedContentOffset+y,this._removalFailures=0):(d.start=r.start,v=this._lastRenderedContentOffset,this._removalFailures++),E="to-start"}n.setRenderedRange(d),n.setRenderedContentOffset(v+i,E)}else i&&n.setRenderedContentOffset(this._lastRenderedContentOffset+i);this._lastScrollOffset=a}_checkRenderedContentSize(){let n=this._viewport;this._lastRenderedContentSize=n.measureRenderedContentSize(),this._averager.addSample(n.getRenderedRange(),this._lastRenderedContentSize),this._updateTotalContentSize(this._lastRenderedContentSize)}_checkRenderedContentOffset(){let n=this._viewport;this._lastRenderedContentOffset=n.getOffsetToRenderedContentStart()}_renderContentForCurrentOffset(){let n=this._viewport,a=n.measureScrollOffset();this._lastScrollOffset=a,this._removalFailures=0;let e=this._averager.getAverageItemSize(),t=Math.min(n.getDataLength()-1,Math.floor(a/e)),r=Math.ceil(this._maxBufferPx/e),i=this._expandRange(this._getVisibleRangeForIndex(t),r,r);n.setRenderedRange(i),n.setRenderedContentOffset(e*i.start)}_getVisibleRangeForIndex(n){let a=this._viewport,e={start:n,end:n+Math.ceil(a.getViewportSize()/this._averager.getAverageItemSize())},t=e.end-a.getDataLength();return t>0&&(e.start=Math.max(0,e.start-t)),e}_expandRange(n,a,e){let t=this._viewport,r=Math.max(0,n.start-a),i=Math.min(t.getDataLength(),n.end+e);return{start:r,end:i}}_updateTotalContentSize(n){let a=this._viewport,e=a.getRenderedRange(),t=n+(a.getDataLength()-(e.end-e.start))*this._averager.getAverageItemSize();a.setTotalContentSize(t)}};function Ae(s){return s._scrollStrategy}var Ue=(()=>{class s{get minBufferPx(){return this._minBufferPx}set minBufferPx(a){this._minBufferPx=P(a)}_minBufferPx=100;get maxBufferPx(){return this._maxBufferPx}set maxBufferPx(a){this._maxBufferPx=P(a)}_maxBufferPx=200;_scrollStrategy=new H(this.minBufferPx,this.maxBufferPx);ngOnChanges(){this._scrollStrategy.updateBufferSize(this.minBufferPx,this.maxBufferPx)}static \u0275fac=function(e){return new(e||s)};static \u0275dir=se({type:s,selectors:[["cdk-virtual-scroll-viewport","autosize",""]],inputs:{minBufferPx:"minBufferPx",maxBufferPx:"maxBufferPx"},features:[oe([{provide:ae,useFactory:Ae,deps:[ee(()=>s)]}]),ie]})}return s})(),Ve=(()=>{class s{static \u0275fac=function(e){return new(e||s)};static \u0275mod=ne({type:s});static \u0275inj=te({})}return s})();var xe=["removed","added","contextBefore","contextAfter","occurrence"];function q(s){if(s==null)return{value:null,reason:null,droppedKeys:[]};let n=typeof s=="object"?Object.getPrototypeOf(s):void 0;if(n!==Object.prototype&&n!==null)return{value:null,reason:"it is not a plain object",droppedKeys:[]};let a=s;for(let i of["removed","added","contextBefore","contextAfter"])if(typeof a[i]!="string")return{value:null,reason:`"${i}" must be a string`,droppedKeys:[]};let e=a.occurrence;if(typeof e!="number"||!Number.isInteger(e)||e<1)return{value:null,reason:'"occurrence" must be an integer of 1 or more',droppedKeys:[]};let t={removed:a.removed,added:a.added,contextBefore:a.contextBefore,contextAfter:a.contextAfter,occurrence:e};if(t.removed.length+t.added.length>8192)return{value:null,reason:'"removed" and "added" together are longer than 8192 characters',droppedKeys:[]};let r=Object.keys(a).filter(i=>!xe.includes(i));return{value:t,reason:null,droppedKeys:r}}function _e(s,n,a){if(!n)return 0;let e=0,t=0;for(;;){let r=s.indexOf(n,t);if(r<0||r>=a)return e;e++,t=r+1}}var Re=s=>s>=55296&&s<=56319,we=s=>s>=56320&&s<=57343,I=(s,n)=>n>0&&n<s.length&&Re(s.charCodeAt(n-1))&&we(s.charCodeAt(n)),Oe=/[\p{L}\p{N}_]/u,w=s=>!!s&&Oe.test(s),m=s=>s.replace(/\u00a0/g," ");function Se(s,n){let a=m(s),e=m(n),t=Math.min(a.length,e.length),r=0;for(;r<t&&a.charCodeAt(r)===e.charCodeAt(r);)r++;let i=0;for(;i<t-r&&a.charCodeAt(a.length-1-i)===e.charCodeAt(e.length-1-i);)i++;let o=a.length-r-i,c=e.length-r-i;if(o>0&&c>0){for(;r>0&&w(a[r-1])&&(w(a[r])||w(e[r]));)r--;for(;i<t-r&&a.charCodeAt(a.length-1-i)===e.charCodeAt(e.length-1-i);)i++;for(;i>0&&w(a[a.length-i])&&(w(a[a.length-i-1])||w(e[e.length-i-1]));)i--}else if(o+c>0){let u=o>0?a:e,g=o+c,l=f=>w(u[f])&&!w(u[f-1]),h=r;for(let f=r;f>0&&u[f-1]===u[f+g-1];)f--,l(f)&&(h=f);!l(r)&&h!==r&&(i+=r-h,r=h)}for(;r>0&&(I(a,r)||I(e,r));)r--;for(;i>0&&(I(a,a.length-i)||I(e,e.length-i));)i--;return{prefix:r,suffix:i}}function N(s,n,a,e){if(n<0||a<n||a>s.length)return null;let t=s.slice(n,a);if(m(t)===m(e)||t.length+e.length>8192)return null;let r=Math.max(0,n-32);I(s,r)&&r++;let i=Math.min(s.length,a+32);I(s,i)&&i--;let o=s.slice(r,n),c=s.slice(a,i),u=o+t+c,g=1+_e(s,u,r);return{removed:t,added:e,contextBefore:o,contextAfter:c,occurrence:g}}function me(s,n,a){return m(n).includes(m(s.contextBefore+s.removed+s.contextAfter))&&m(a).includes(m(s.contextBefore+s.added+s.contextAfter))}function G(s){return{removed:m(s.removed),added:m(s.added),contextBefore:m(s.contextBefore),contextAfter:m(s.contextAfter),occurrence:s.occurrence}}function ve(s,n){if(m(s)===m(n))return null;let{prefix:a,suffix:e}=Se(s,n);return N(s,a,s.length-e,n.slice(a,n.length-e))}function qe(s,n){if(m(s)===m(n))return null;let{prefix:a,suffix:e}=Se(s,n);return{removed:s.slice(a,s.length-e),start:a,end:n.length-e}}var j=(()=>{let n=class n{constructor(e){this.loggingService=e,this.enabledSignal=re(!1),this.onTargetEditStart=null,this.onTargetEditCommit=null,this.autoCommit=!0;try{this.enabled$=ce(this.enabledSignal).pipe(O())}catch(t){this.loggingService.catch("Error in SuggestionModeService constructor: ",t),this.enabled$=new C}}enable(e){try{this.onTargetEditStart=e?.onTargetEditStart??null,this.onTargetEditCommit=e?.onTargetEditCommit??null,this.autoCommit=e?.autoCommit!==!1,this.enabledSignal.set(!0)}catch(t){this.loggingService.catch("Error in SuggestionModeService enable: ",t)}}disable(){try{this.onTargetEditStart=null,this.onTargetEditCommit=null,this.autoCommit=!0,this.enabledSignal.set(!1)}catch(e){this.loggingService.catch("Error in SuggestionModeService disable: ",e)}}isEnabled(){try{return this.enabledSignal()}catch(e){return this.loggingService.catch("Error in SuggestionModeService isEnabled: ",e),!1}}getOnTargetEditStart(){try{return this.onTargetEditStart}catch(e){return this.loggingService.catch("Error in SuggestionModeService getOnTargetEditStart: ",e),null}}getOnTargetEditCommit(){try{return this.onTargetEditCommit}catch(e){return this.loggingService.catch("Error in SuggestionModeService getOnTargetEditCommit: ",e),null}}isAutoCommitEnabled(){try{return this.autoCommit}catch(e){return this.loggingService.catch("Error in SuggestionModeService isAutoCommitEnabled: ",e),!1}}};n.\u0275fac=function(t){return new(t||n)(S(R))},n.\u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"});let s=n;return s})();var L=(()=>{let n=class n{constructor(e){this.loggingService=e,this.snapshots=new Map}captureFromGetter(e,t){try{if(!e||typeof t!="function")return!1;let r;try{r=t()}catch(i){return _()&&this.loggingService.catch(`[velt] Suggestion target "${e}" getter threw: `,i),!1}return this.captureValue(e,r)}catch(r){return this.loggingService.catch("Error in SuggestionSnapshotService captureFromGetter: ",r),!1}}captureValue(e,t){try{if(!e)return!1;let r;try{r=structuredClone(t)}catch(i){return _()&&this.loggingService.catch(`[velt] Suggestion target "${e}" snapshot failed (value not cloneable). Cause: structuredClone rejected the value (cyclic refs, DOM nodes, or functions are common culprits). Fix: ensure your getter returns plain JSON-serializable data.`,i),!1}return this.snapshots.set(e,r),!0}catch(r){return this.loggingService.catch("Error in SuggestionSnapshotService captureValue: ",r),!1}}getSnapshot(e){try{return this.snapshots.has(e)?this.snapshots.get(e):void 0}catch(t){this.loggingService.catch("Error in SuggestionSnapshotService getSnapshot: ",t);return}}hasSnapshot(e){try{return this.snapshots.has(e)}catch(t){return this.loggingService.catch("Error in SuggestionSnapshotService hasSnapshot: ",t),!1}}clearSnapshot(e){try{this.snapshots.delete(e)}catch(t){this.loggingService.catch("Error in SuggestionSnapshotService clearSnapshot: ",t)}}clearAllSnapshots(){try{this.snapshots.clear()}catch(e){this.loggingService.catch("Error in SuggestionSnapshotService clearAllSnapshots: ",e)}}};n.\u0275fac=function(t){return new(t||n)(S(R))},n.\u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"});let s=n;return s})();var Ee=(()=>{let n=class n{constructor(e,t,r){this.loggingService=e,this.modeService=t,this.snapshotService=r,this.registry=new Map,this.warnedUnstableIds=new Set,this.latestEdit=new Map,this.editSeq=0,this.actionsService=null,this.typedEditSource=null}registerTarget(e,t,r){try{if(!e||typeof t!="function")return;this.warnIfUnstableId(e);let i=this.registry.get(e)??{};i.getter=t,i.setter=typeof r?.setter=="function"?r.setter:void 0,i.restoreOnCommit=r?.restoreOnCommit,this.registry.set(e,i)}catch(i){this.loggingService.catch("Error in SuggestionTargetRegistryService registerTarget: ",i)}}unregisterTarget(e){try{let t=this.registry.get(e);if(!t)return;delete t.getter,delete t.setter,delete t.restoreOnCommit,this.latestEdit.delete(e),t.node||this.registry.delete(e)}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService unregisterTarget: ",t)}}getSetter(e){try{return this.registry.get(e)?.setter}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService getSetter: ",t);return}}callSetter(e,t,r){return this.runSetter(e,t,r)!==null}runSetter(e,t,r){let i=this.registry.get(e)?.setter;if(!i)return null;let o=c=>this.loggingService.catch("Error in SuggestionTargetRegistryService: the target setter threw",c,{targetId:e,reason:r.reason});try{let c=i(t,b({targetId:e},r));if(c&&typeof c.then=="function")return Promise.resolve(c).catch(o)}catch(c){o(c)}return Promise.resolve()}getGetter(e){try{return this.registry.get(e)?.getter}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService getGetter: ",t);return}}setActionsService(e){try{this.actionsService=e}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService setActionsService: ",t)}}getNode(e){try{if(!e)return;let t=this.registry.get(e)?.node;if(t&&t.isConnected)return t;let r=this.queryAll(e);if(r.length===0)return;r.length>1&&this.warnDuplicateId(e,r.length);let i=r[0],o=this.registry.get(e)??{};return o.node=i,this.registry.set(e,o),i}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService getNode: ",t);return}}setTypedEditSource(e){this.typedEditSource=e}getTypedEdits(e){try{return this.typedEditSource?.(e)??[]}catch(t){return this.loggingService.catch("Error in SuggestionTargetRegistryService getTypedEdits: ",t),[]}}getFallbackValue(e){try{let t=this.getNode(e);if(!t)return{hasValue:!1};let r=t.textContent??"";return r.length>0?{hasValue:!0,value:r}:{hasValue:!1}}catch(t){return this.loggingService.catch("Error in SuggestionTargetRegistryService getFallbackValue: ",t),{hasValue:!1}}}isRegistered(e){try{return this.registry.get(e)?.getter?!0:!!this.getNode(e)}catch(t){return this.loggingService.catch("Error in SuggestionTargetRegistryService isRegistered: ",t),!1}}countTaggedElements(e){try{let t=e??this.rootEl??document.body;return t?t.querySelectorAll(`[${A.ATTRIBUTES.VELT_SUGGESTION_TARGET}]`).length:0}catch(t){return this.loggingService.catch("Error in SuggestionTargetRegistryService countTaggedElements: ",t),0}}startObserving(e=document.body){try{if(this.observer)return;this.rootEl=e,this.scanAndRefresh(e),this.observer=new MutationObserver(()=>{try{this.scanAndRefresh(this.rootEl??document.body)}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService observer callback: ",t)}}),this.observer.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[A.ATTRIBUTES.VELT_SUGGESTION_TARGET]}),this.installDelegatedListeners(e)}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService startObserving: ",t)}}stopObserving(){try{this.observer?.disconnect(),this.observer=void 0,this.rootEl&&this.removeDelegatedListeners(this.rootEl),this.rootEl=void 0}catch(e){this.loggingService.catch("Error in SuggestionTargetRegistryService stopObserving: ",e)}}clear(){try{this.registry.clear(),this.latestEdit.clear(),this.warnedUnstableIds.clear()}catch(e){this.loggingService.catch("Error in SuggestionTargetRegistryService clear: ",e)}}installDelegatedListeners(e){try{this.boundFocusIn=t=>this.handleFocusIn(t),this.boundChange=t=>this.handleChange(t),this.boundFocusOut=t=>this.handleFocusOut(t),e.addEventListener("focusin",this.boundFocusIn,!0),e.addEventListener("change",this.boundChange,!0),e.addEventListener("focusout",this.boundFocusOut,!0)}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService installDelegatedListeners: ",t)}}removeDelegatedListeners(e){try{this.boundFocusIn&&e.removeEventListener("focusin",this.boundFocusIn,!0),this.boundChange&&e.removeEventListener("change",this.boundChange,!0),this.boundFocusOut&&e.removeEventListener("focusout",this.boundFocusOut,!0),this.boundFocusIn=void 0,this.boundChange=void 0,this.boundFocusOut=void 0}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService removeDelegatedListeners: ",t)}}handleFocusIn(e){try{if(!this.modeService.isEnabled())return;let t=this.findTaggedAncestor(e.target);if(!t)return;this.captureSnapshotForTarget(t.targetId,t.element);let r=this.snapshotService.getSnapshot(t.targetId),i={targetId:t.targetId,oldValue:r,newValue:r,element:t.element},o=this.modeService.getOnTargetEditStart();if(o)try{o(i)}catch(c){this.loggingService.catch("Error in SuggestionTargetRegistryService onTargetEditStart customer callback threw: ",c)}this.actionsService?.triggerAction(p.TARGET_EDIT_START,{details:i,timestamp:Date.now()})}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService handleFocusIn: ",t)}}handleChange(e){try{if(!this.modeService.isEnabled())return;let t=this.findTaggedAncestor(e.target);if(!t||!this.isAtomicCommitTarget(e.target))return;this.processCommit(t.targetId,t.element)}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService handleChange: ",t)}}handleFocusOut(e){try{if(!this.modeService.isEnabled())return;let t=this.findTaggedAncestor(e.target);if(!t||this.isAtomicCommitTarget(e.target))return;this.processCommit(t.targetId,t.element)}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService handleFocusOut: ",t)}}isAtomicCommitTarget(e){try{if(e instanceof HTMLSelectElement)return!0;if(e instanceof HTMLInputElement){let t=(e.type||"").toLowerCase();return t==="checkbox"||t==="radio"}return!1}catch(t){return this.loggingService.catch("Error in SuggestionTargetRegistryService isAtomicCommitTarget: ",t),!1}}processCommit(e,t){try{let r=this.snapshotService.getSnapshot(e),i=this.readElementValue(e,t);if(D(r,i))return;let o=this.splitTypedEdits(t,r,i),c=this.restoreWhenCommitted(e,r,o?o.length:1);if(o){o.forEach((u,g)=>this.commitEdit(e,t,r,u.newValue,u.textChange,!0,c?.(g)));return}this.commitEdit(e,t,r,i,void 0,!1,c?.(0))}catch(r){this.loggingService.catch("Error in SuggestionTargetRegistryService processCommit: ",r)}}restoreWhenCommitted(e,t,r){let i=this.registry.get(e);if(!i?.setter||i.restoreOnCommit===!1){this.latestEdit.delete(e);return}let o=++this.editSeq;this.latestEdit.set(e,o);let c=new Set;return u=>g=>{try{if(!g||c.size===r||(c.add(u),c.size<r||this.latestEdit.get(e)!==o))return;this.latestEdit.delete(e);let l=this.runSetter(e,t,{reason:"restore"}),h=()=>{this.findTaggedAncestor(document.activeElement)?.targetId===e&&this.snapshotService.captureValue(e,t)};h(),l?.then(h,()=>{})}catch(l){this.loggingService.catch("Error in SuggestionTargetRegistryService restoreWhenCommitted: ",l)}}}splitTypedEdits(e,t,r){try{if(typeof t!="string"||typeof r!="string")return null;let i=this.getTypedEdits(e);if(i.length<2)return null;let o=g=>g.replace(/\u00a0/g," ");if(i.some(g=>o(g.base)!==o(t)))return null;let c=t;for(let g of[...i].sort((l,h)=>h.start-l.start))c=c.slice(0,g.start)+g.added+c.slice(g.end);if(o(c)!==o(r))return null;let u=[];for(let g of i){let l=N(t,g.start,g.end,g.added);if(!l)return null;u.push({newValue:t.slice(0,g.start)+o(g.added)+t.slice(g.end),textChange:G(l)})}return u}catch(i){return this.loggingService.catch("Error in SuggestionTargetRegistryService splitTypedEdits: ",i),null}}commitEdit(e,t,r,i,o,c=!1,u){try{let g={targetId:e,oldValue:r,newValue:i,element:t},l=this.modeService.getOnTargetEditCommit(),h=null;if(l){let d=null;try{d=l(g)}catch(v){this.loggingService.catch("Error in SuggestionTargetRegistryService onTargetEditCommit customer callback threw: ",v)}d&&(h=this.invokeAutoCommit({targetId:e,newValue:i,snapshot:c?{value:r}:void 0,summary:d.summary,summaryHtml:d.summaryHtml,metadata:d.metadata,textChange:d.textChange??o}),u&&h.then(u))}else this.modeService.isAutoCommitEnabled()&&(h=this.invokeAutoCommit({targetId:e,newValue:i,textChange:o,snapshot:c?{value:r}:void 0}),u&&h.then(u));let f=d=>Y(this,null,function*(){if(h&&(yield h))return null;let v=this.invokeAutoCommit({targetId:e,newValue:i,snapshot:c?{value:r}:void 0,summary:d?.summary,summaryHtml:d?.summaryHtml,metadata:d?.metadata,textChange:d?.textChange??o});return u&&v.then(u),v});this.actionsService?.triggerAction(p.TARGET_EDIT_COMMIT,{details:g,commitSuggestion:f,timestamp:Date.now()})}catch(g){this.loggingService.catch("Error in SuggestionTargetRegistryService commitEdit: ",g)}}invokeAutoCommit(r){var i=r,{snapshot:e}=i,t=J(i,["snapshot"]);try{return e&&this.snapshotService.captureValue(t.targetId,e.value),this.actionsService?this.actionsService.commitSuggestion(t).catch(o=>(_()&&this.loggingService.catch(`[velt] auto-commit for "${t.targetId}" rejected: `,o),null)):(_()&&this.loggingService.log("[velt] auto-commit skipped: actions service not wired. SuggestionActionsService constructor should call registry.setActionsService(this)."),Promise.resolve(null))}catch(o){return this.loggingService.catch("Error in SuggestionTargetRegistryService invokeAutoCommit: ",o),Promise.resolve(null)}}captureSnapshotForTarget(e,t){try{let r=this.registry.get(e);if(r?.getter){this.snapshotService.captureFromGetter(e,r.getter);return}let i=this.readElementValue(e,t);this.snapshotService.captureValue(e,i)}catch(r){this.loggingService.catch("Error in SuggestionTargetRegistryService captureSnapshotForTarget: ",r)}}readElementValue(e,t){try{let r=this.registry.get(e);if(r?.getter)try{return r.getter()}catch{return}if(t instanceof HTMLInputElement){let i=(t.type||"").toLowerCase();return i==="checkbox"||i==="radio"?t.checked:i==="number"||i==="range"?Number.isNaN(t.valueAsNumber)?t.value:t.valueAsNumber:t.value}return t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement?t.value:(t instanceof HTMLElement&&t.isContentEditable,t.textContent??"")}catch(r){this.loggingService.catch("Error in SuggestionTargetRegistryService readElementValue: ",r);return}}findTaggedAncestor(e){try{if(!(e instanceof Element))return null;let t=e.closest(`[${A.ATTRIBUTES.VELT_SUGGESTION_TARGET}]`);if(!t)return null;let r=t.getAttribute(A.ATTRIBUTES.VELT_SUGGESTION_TARGET);return r?{element:t,targetId:r}:null}catch(t){return this.loggingService.catch("Error in SuggestionTargetRegistryService findTaggedAncestor: ",t),null}}queryAll(e){try{let t=window.CSS?.escape?window.CSS.escape(e):e.replace(/"/g,'\\"');return Array.from(document.querySelectorAll(`[${A.ATTRIBUTES.VELT_SUGGESTION_TARGET}="${t}"]`))}catch{return[]}}scanAndRefresh(e){try{e.querySelectorAll(`[${A.ATTRIBUTES.VELT_SUGGESTION_TARGET}]`).forEach(r=>{let i=r.getAttribute(A.ATTRIBUTES.VELT_SUGGESTION_TARGET);if(!i)return;let o=this.registry.get(i)??{};(!o.node||!o.node.isConnected)&&(o.node=r,this.registry.set(i,o))})}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService scanAndRefresh: ",t)}}warnIfUnstableId(e){try{if(!_()||this.warnedUnstableIds.has(e))return;let t=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i.test(e),r=/\d{10,}/.test(e);(t||r)&&(this.warnedUnstableIds.add(e),this.loggingService.catch(`[velt] Target id "${e}" appears unstable. Cause: contains a UUID or timestamp shape \u2014 these typically change across re-renders. Fix: use a stable customer-owned id (the same one you use in your state). Docs: velt.dev/docs/suggestions/target-ids`,new Error("UNSTABLE_TARGET_ID")))}catch(t){this.loggingService.catch("Error in SuggestionTargetRegistryService warnIfUnstableId: ",t)}}warnDuplicateId(e,t){try{if(!_())return;this.loggingService.catch(`[velt] Duplicate target id "${e}" \u2014 ${t} elements share this id. Cause: the same ${A.ATTRIBUTES.VELT_SUGGESTION_TARGET} appears on multiple DOM nodes. Fix: ensure each suggestable element has a unique id. Velt is using the first registered element. Docs: velt.dev/docs/suggestions/target-ids`,new Error("DUPLICATE_TARGET_ID"))}catch(r){this.loggingService.catch("Error in SuggestionTargetRegistryService warnDuplicateId: ",r)}}};n.\u0275fac=function(t){return new(t||n)(S(R),S(j),S(L))},n.\u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"});let s=n;return s})();var Me=new Set(["apiKey","documentId","clientDocumentId","organizationId","clientOrganizationId","folderId","veltFolderId","parentVeltFolderId","documentMetadata","sdkVersion","pageInfo"]),St=(()=>{let n=class n{constructor(e,t,r,i,o,c,u){this.loggingService=e,this.modeService=t,this.snapshotService=r,this.targetRegistry=i,this.serviceBook=o,this.commonDbService=c,this.docService=u,this.actionSubjects=new Map,this.appliedValues=new Map,this.observingActive=!1,this.commentService=null,this.inlineSuggestionsEnabled$=new Q(!0);try{this.targetRegistry.setActionsService(this),this.serviceBook.observe(U).subscribe(g=>{this.commentService=g})}catch(g){this.loggingService.catch("Error in SuggestionActionsService constructor: ",g)}}enableSuggestionMode(e){try{this.modeService.enable(e),this.startObservingIfNeeded(),this.warnIfNoTaggedElements()}catch(t){this.loggingService.catch("Error in SuggestionActionsService enableSuggestionMode: ",t)}}disableSuggestionMode(){try{this.modeService.disable(),this.stopObservingIfNeeded()}catch(e){this.loggingService.catch("Error in SuggestionActionsService disableSuggestionMode: ",e)}}isSuggestionModeEnabled(){try{return this.modeService.isEnabled()}catch(e){return this.loggingService.catch("Error in SuggestionActionsService isSuggestionModeEnabled: ",e),!1}}enableInlineSuggestions(){try{this.inlineSuggestionsEnabled$.value||this.inlineSuggestionsEnabled$.next(!0)}catch(e){this.loggingService.catch("Error in SuggestionActionsService enableInlineSuggestions: ",e)}}disableInlineSuggestions(){try{this.inlineSuggestionsEnabled$.value&&this.inlineSuggestionsEnabled$.next(!1)}catch(e){this.loggingService.catch("Error in SuggestionActionsService disableInlineSuggestions: ",e)}}isInlineSuggestionsEnabled$(){return this.inlineSuggestionsEnabled$.pipe(O())}isSuggestionModeEnabled$(){try{return this.modeService.enabled$}catch(e){return this.loggingService.catch("Error in SuggestionActionsService isSuggestionModeEnabled$: ",e),new C}}registerTarget(e){try{if(!e?.targetId||typeof e?.getter!="function")return;this.targetRegistry.registerTarget(e.targetId,e.getter,{setter:e.setter,restoreOnCommit:e.restoreOnCommit})}catch(t){this.loggingService.catch("Error in SuggestionActionsService registerTarget: ",t)}}unregisterTarget(e){try{this.targetRegistry.unregisterTarget(e)}catch(t){this.loggingService.catch("Error in SuggestionActionsService unregisterTarget: ",t)}}startSuggestion(e){try{let t=this.targetRegistry.getGetter(e);if(t){this.snapshotService.captureFromGetter(e,t);return}let r=this.targetRegistry.getFallbackValue(e);r.hasValue?this.snapshotService.captureValue(e,r.value):this.loggingService.warn(`[velt] startSuggestion: target "${e}" not registered. Cause: no getter via registerTarget() and no textContent fallback. Fix: tag the element with data-velt-suggestion-target and register a getter via registerTarget(). Docs: velt.dev/docs/suggestions/targets`)}catch(t){this.loggingService.catch("Error in SuggestionActionsService startSuggestion: ",t)}}commitSuggestion(e){return new Promise((t,r)=>{try{if(!e?.targetId){r(new Error("INVALID_CONFIG"));return}if(!this.modeService.isEnabled()){this.loggingService.warn("[velt] commitSuggestion called while suggestion mode is disabled. Cause: enableSuggestionMode() has not been called (or disableSuggestionMode() was called). Fix: call enableSuggestionMode() before commit, or branch on isSuggestionModeEnabled() in your onSave handler. Docs: velt.dev/docs/suggestions/mode"),r(new Error("MODE_NOT_SUGGESTING"));return}if(!this.targetRegistry.isRegistered(e.targetId)){this.loggingService.warn(`[velt] commitSuggestion: target "${e.targetId}" not registered. Cause: no element has data-velt-suggestion-target="${e.targetId}" and no registerTarget() call provided a getter. Fix: tag the element or register a getter at app boot. Docs: velt.dev/docs/suggestions/targets`),r(new Error("TARGET_NOT_REGISTERED"));return}if(!this.snapshotService.hasSnapshot(e.targetId)){let E=this.targetRegistry.getGetter(e.targetId);if(E){if(!this.snapshotService.captureFromGetter(e.targetId,E)){r(new Error("SNAPSHOT_FAILED"));return}}else{let y=this.targetRegistry.getFallbackValue(e.targetId);if(y.hasValue)this.snapshotService.captureValue(e.targetId,y.value);else{this.loggingService.warn(`[velt] commitSuggestion: target "${e.targetId}" requires registerTarget() for complex values. Cause: complex objects need a getter so the SDK can deep-clone the snapshot. Fix: call velt.getSuggestionElement().registerTarget("${e.targetId}", () => yourState.${e.targetId}) at app boot. Docs: velt.dev/docs/suggestions/getter`),r(new Error("NO_GETTER_FOR_COMPLEX"));return}}}let u=this.snapshotService.getSnapshot(e.targetId),g=e.newValue;if(D(u,g)){this.loggingService.warn(`[velt] commitSuggestion: no change detected for target "${e.targetId}". Cause: oldValue and newValue are deeply equal. Fix: only call commitSuggestion when the customer actually changed the value. Docs: velt.dev/docs/suggestions/edge-cases`),r(new Error("NO_CHANGE_TO_SUGGEST"));return}let l=new ge;l.type="suggestion",l.suggestion={status:"pending",targetId:e.targetId,targetType:"custom",oldValue:u,newValue:g,summary:e.summary??null,driftDetected:!1,rejectReason:null,resolvedBy:null,resolvedAt:null},this.setCustomerMetadata(l.suggestion,e.metadata),this.setTextChange(l.suggestion,e.targetId,e.textChange,u,g);let h=this.resolveSuggestionLocation(e),f=this.resolveSuggestionContext(e),d=Fe(e.summary,e.summaryHtml,u,g),v=new ue;if(v.commentText=d.commentText,v.commentHtml=d.commentHtml,l.comments=[v],!this.commentService){this.loggingService.catch('SuggestionActionsService.commitSuggestion: comment chunk not loaded \u2014 call Snippyly.preloadComment() first or include "comment" in featureAllowList.',new Error("comment chunk unavailable")),r(new Error("comment chunk not loaded"));return}this.commentService.addComment(void 0,void 0,void 0,void 0,!1,[],void 0,h?.location,void 0,void 0,void 0,void 0,void 0,E=>{try{this.snapshotService.clearSnapshot(e.targetId),this.projectAndTrigger(p.SUGGESTION_CREATED,E.annotation),t({id:E.annotation.annotationId})}catch(y){this.loggingService.catch("Error in SuggestionActionsService commitSuggestion callback: ",y),r(y)}},void 0,void 0,l,h?.locationId,f,!0,void 0,void 0,"internal",h?.locationId!==void 0?!0:void 0)}catch(i){this.loggingService.catch("Error in SuggestionActionsService commitSuggestion: ",i),r(i)}})}getSuggestions(e){try{let t=this.commentService?.getCommentAnnotationsOnCurrentOrganizationAndDocument()??[],r=[];for(let i of t){if(!i.suggestion)continue;let o=this.projectAnnotationToSuggestion(i);o&&this.matchesFilter(o,e)&&r.push(o)}return r}catch(t){return this.loggingService.catch("Error in SuggestionActionsService getSuggestions: ",t),[]}}getSuggestions$(e){try{return this.serviceBook.observe(U).pipe(Z(t=>t?t.getCommentAnnotationsOnCurrentOrganizationAndDocument$():$([]))).pipe(k(t=>{let r=[];for(let i of t??[]){if(!i.suggestion)continue;let o=this.projectAnnotationToSuggestion(i);o&&this.matchesFilter(o,e)&&r.push(o)}return r}),O(z))}catch(t){return this.loggingService.catch("Error in SuggestionActionsService getSuggestions$: ",t),new C}}getPendingSuggestion(e){try{if(!e)return null;let t=this.getSuggestions({targetId:e,status:"pending"});return t.length===0?null:t.sort((r,i)=>(i.createdAt??0)-(r.createdAt??0))[0]}catch(t){return this.loggingService.catch("Error in SuggestionActionsService getPendingSuggestion: ",t),null}}getPendingSuggestion$(e){try{return e?this.getSuggestions$({targetId:e,status:"pending"}).pipe(k(t=>t.length===0?null:t.sort((r,i)=>(i.createdAt??0)-(r.createdAt??0))[0]),O(z)):new C}catch(t){return this.loggingService.catch("Error in SuggestionActionsService getPendingSuggestion$: ",t),new C}}triggerAction(e,t){try{this.actionSubjects.has(e)||this.actionSubjects.set(e,new B),this.actionSubjects.get(e)?.next(t)}catch(r){this.loggingService.catch("Error in SuggestionActionsService triggerAction: ",r)}}onAction(e){try{return this.actionSubjects.has(e)||this.actionSubjects.set(e,new B),this.actionSubjects.get(e)?.asObservable()}catch(t){return this.loggingService.catch("Error in SuggestionActionsService onAction: ",t),$(null)}}projectAndTrigger(e,t){try{if(!t||!t.suggestion)return;let r=this.projectAnnotationToSuggestion(t);if(!r)return;let i=this.timestamp;switch(e){case p.SUGGESTION_CREATED:{let o={suggestion:r,timestamp:i};this.triggerAction(p.SUGGESTION_CREATED,o);break}case p.SUGGESTION_APPROVED:{let o={suggestion:r,timestamp:i};this.triggerAction(p.SUGGESTION_APPROVED,o);break}case p.SUGGESTION_REJECTED:{let o={suggestion:r,timestamp:i};this.triggerAction(p.SUGGESTION_REJECTED,o);break}case p.SUGGESTION_STALE:{let o={suggestion:r,timestamp:i};this.triggerAction(p.SUGGESTION_STALE,o);break}}}catch(r){this.loggingService.catch("Error in SuggestionActionsService projectAndTrigger: ",r)}}resolveSuggestionContext(e){try{let t=e.context;if(t==null)return;if(typeof t!="object"||Array.isArray(t)){this.loggingService.warn('[velt] commitSuggestion: context was not saved. Cause: it is not an object. Fix: pass an object, e.g. { textEditorConfig: { editorId: "<editor id>" } }. Docs: velt.dev/docs/suggestions');return}let r;try{r=JSON.parse(JSON.stringify(t))}catch{this.loggingService.warn("[velt] commitSuggestion: context was not saved. Cause: it cannot be stored as JSON (e.g. it refers to itself). Fix: pass plain JSON data. Docs: velt.dev/docs/suggestions");return}if(r===null||typeof r!="object"||Array.isArray(r)){this.loggingService.warn('[velt] commitSuggestion: context was not saved. Cause: it is not stored as an object (e.g. a Date). Fix: pass an object, e.g. { textEditorConfig: { editorId: "<editor id>" } }. Docs: velt.dev/docs/suggestions');return}let i=De.filter(o=>o in r);return i.length&&(i.forEach(o=>delete r[o]),this.loggingService.warn(`[velt] commitSuggestion: context keys ${i.join(", ")} were not saved. Cause: the SDK sets them. Fix: leave them out (use \`access\` for context access). Docs: velt.dev/docs/suggestions`)),r}catch(t){this.loggingService.catch("Error in SuggestionActionsService resolveSuggestionContext: ",t);return}}resolveSuggestionLocation(e){try{let t=null,r=e.location;if(r!=null){let o=typeof r=="object"&&!Array.isArray(r)?r.id:void 0;typeof o=="string"&&o.trim()?t=r:this.loggingService.warn('[velt] commitSuggestion: location was not used. Cause: it is not an object with a non-empty string id. Fix: pass { id: "<location id>" }, or omit it to use the location around the target element. Docs: velt.dev/docs/suggestions')}if(!t){let o=this.targetRegistry.getNode(e.targetId);t=o?this.docService.getAdditionLocationFromElement(o):null}if(!t?.id)return null;let i=this.docService.getLocationMetadataByClientLocationId(t.id);return i?.location?{location:i.location,locationId:i.locationId}:{location:t}}catch(t){return this.loggingService.catch("Error in SuggestionActionsService resolveSuggestionLocation: ",t),null}}setCustomerMetadata(e,t){let r=this.cloneCustomerMetadata(t);r&&(e.metadata=r)}setTextChange(e,t,r,i,o){try{let c=q(r);c.reason?this.loggingService.warn(`[velt] commitSuggestion: textChange was not saved. Cause: ${c.reason}. Fix: pass { removed, added, contextBefore, contextAfter, occurrence }. Docs: velt.dev/docs/suggestions`):c.droppedKeys.length&&this.loggingService.warn(`[velt] commitSuggestion: textChange keys ${c.droppedKeys.join(", ")} were not saved. Cause: they are not textChange keys. Fix: put your own data in metadata. Docs: velt.dev/docs/suggestions`);let u=c.value??this.computeTextChange(t,i,o);u&&(e.textChange=u)}catch(c){this.loggingService.catch("Error in SuggestionActionsService setTextChange: ",c)}}computeTextChange(e,t,r){if(typeof t!="string"||typeof r!="string")return null;let i=this.targetRegistry.getNode(e);if(!(i instanceof HTMLElement)||!i.isConnected||!i.isContentEditable||i.closest(".ProseMirror"))return null;for(let c of this.targetRegistry.getTypedEdits(i)??[]){let u=N(c.base,c.start,c.end,c.added);if(u&&me(u,t,r))return G(u)}let o=ve(t,r);return o&&G(o)}getTextChange(e){return q(e.textChange).value}cloneCustomerMetadata(e){if(e==null)return;let t=typeof e=="object"?Object.getPrototypeOf(e):void 0;if(t!==Object.prototype&&t!==null){this.loggingService.warn('[velt] commitSuggestion: metadata was not saved. Cause: it is not a plain object. Fix: pass a plain JSON object, e.g. { kind: "replacement" }. Docs: velt.dev/docs/suggestions');return}try{let r=le(e);return r&&typeof r=="object"&&!Array.isArray(r)?r:void 0}catch{this.loggingService.warn("[velt] commitSuggestion: metadata was not saved. Cause: it cannot be serialized as JSON (BigInt or a circular reference). Fix: pass JSON-safe values only. Docs: velt.dev/docs/suggestions");return}}getCustomerMetadata(e){let t=e.suggestion?.metadata;if(t&&typeof t=="object"&&!Array.isArray(t))return b({},t);let r={},i=e.metadata;if(i&&typeof i=="object")for(let o of Object.keys(i))Me.has(o)||Object.defineProperty(r,o,{value:i[o],enumerable:!0,writable:!0,configurable:!0});return r}setAppliedValues(e,t){this.appliedValues.set(e,t)}projectAnnotationToSuggestion(e){try{let t=e.suggestion;if(!t)return;let r={annotationId:e.annotationId,targetId:t.targetId,targetType:t.targetType,oldValue:t.oldValue,newValue:t.newValue,summary:t.summary,metadata:this.getCustomerMetadata(e),textChange:this.getTextChange(t),driftDetected:!!t.driftDetected,createdBy:e.from,createdAt:e.createdAt??0};switch(t.status){case"pending":return M(b({},r),{status:"pending",rejectReason:null,resolvedBy:null,resolvedAt:null});case"accepted":case"apply_failed":{let i=t.status==="accepted"?this.appliedValues.get(e.annotationId):void 0;return M(b(b({},r),i??{}),{status:t.status,rejectReason:null,resolvedBy:t.resolvedBy,resolvedAt:t.resolvedAt??this.timestamp})}case"rejected":return M(b({},r),{status:"rejected",rejectReason:t.rejectReason??null,resolvedBy:t.resolvedBy,resolvedAt:t.resolvedAt??this.timestamp});case"stale":return M(b({},r),{status:"stale",rejectReason:null,resolvedBy:t.resolvedBy,resolvedAt:t.resolvedAt});default:return}}catch(t){this.loggingService.catch("Error in SuggestionActionsService projectAnnotationToSuggestion: ",t);return}}startObservingIfNeeded(){try{if(this.observingActive)return;this.observingActive=!0,this.targetRegistry.startObserving()}catch(e){this.loggingService.catch("Error in SuggestionActionsService startObservingIfNeeded: ",e)}}stopObservingIfNeeded(){try{if(!this.observingActive)return;this.observingActive=!1,this.targetRegistry.stopObserving()}catch(e){this.loggingService.catch("Error in SuggestionActionsService stopObservingIfNeeded: ",e)}}warnIfNoTaggedElements(){try{this.targetRegistry.countTaggedElements()===0&&this.loggingService.warn('[velt] No suggestable elements found on this page. Cause: no DOM elements have a data-velt-suggestion-target attribute. Fix: tag at least one element with data-velt-suggestion-target="your.id" before enabling suggestion mode. Docs: velt.dev/docs/suggestions/getting-started')}catch(e){this.loggingService.catch("Error in SuggestionActionsService warnIfNoTaggedElements: ",e)}}get timestamp(){return this.commonDbService.getServerTimestamp()}matchesFilter(e,t){try{return t?!(t.targetId&&e.targetId!==t.targetId||t.status&&!(Array.isArray(t.status)?t.status:[t.status]).includes(e.status)):!0}catch(r){return this.loggingService.catch("Error in SuggestionActionsService matchesFilter: ",r),!1}}};n.\u0275fac=function(t){return new(t||n)(S(R),S(j),S(L),S(Ee),S(de),S(he),S(fe))},n.\u0275prov=x({token:n,factory:n.\u0275fac,providedIn:"root"});let s=n;return s})();function be(s){try{return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}catch{return""}}function T(s){try{if(s==null)return"";if(typeof s=="string")return s;if(typeof s=="object")try{return JSON.stringify(s)}catch{return String(s)}return String(s)}catch{return""}}var De=["accessFields","_setAccessFields","_replaceAccessFields","_setVisibilityConfig"];function Te(s){try{if(s===null||typeof s!="object"||Array.isArray(s))return!1;let n=Object.getPrototypeOf(s);return n===Object.prototype||n===null}catch{return!1}}function Ce(s,n){try{let a=s==null,e=n==null;if(a&&!e)return[{op:"add",newText:T(n)}];if(!a&&e)return[{op:"remove",oldText:T(s)}];if(Te(s)&&Te(n)){let t=s,r=n,i=[...Object.keys(t),...Object.keys(r).filter(c=>!(c in t))],o=[];for(let c of i){let u=c in t,g=c in r;u&&g?D(t[c],r[c])||o.push({op:"replace",oldText:`${c}: ${T(t[c])}`,newText:`${c}: ${T(r[c])}`}):u?o.push({op:"remove",oldText:`${c}: ${T(t[c])}`}):o.push({op:"add",newText:`${c}: ${T(r[c])}`})}if(o.length>0)return o}return[{op:"replace",oldText:T(s),newText:T(n)}]}catch{return[{op:"replace",oldText:T(s),newText:T(n)}]}}function Ne(s,n){try{return Ce(s,n).map(a=>a.op==="add"?`Add: "${a.newText??""}"`:a.op==="remove"?`Remove: "${a.oldText??""}"`:`Replace: "${a.oldText??""}" with "${a.newText??""}"`).join(`
2
+ `)}catch{return'Replace: "" with ""'}}var X="color:#e0492b;font-style:italic;",W="color:#0f8a4d;font-style:italic;";function Ge(s,n){try{let a=Ce(s,n),e=t=>be(t??"");if(a.length===1){let t=a[0],r=(i,o,c)=>`<div class="velt-suggestion-default-line">${i} <span class="velt-suggestion-default-${c}" dir="auto" style="${c==="old"?X:W}">&ldquo;${e(o)}&rdquo;</span></div>`;return t.op==="add"?r("Add",t.newText,"new"):t.op==="remove"?r("Remove",t.oldText,"old"):r("Replace",t.oldText,"old")+r("with",t.newText,"new")}return a.map(t=>t.op==="add"?`<div>Add: <span style="${W}">&ldquo;${e(t.newText)}&rdquo;</span></div>`:t.op==="remove"?`<div>Remove: <span style="${X}">&ldquo;${e(t.oldText)}&rdquo;</span></div>`:`<div>Replace: <span style="${X}">&ldquo;${e(t.oldText)}&rdquo;</span> with <span style="${W}">&ldquo;${e(t.newText)}&rdquo;</span></div>`).join("")}catch{return"<div>Replace:</div><div>with</div>"}}function Fe(s,n,a,e){try{let t=s||Ne(a,e),r;return n?r=n:s?r=`<p>${be(s)}</p>`:r=Ge(a,e),{commentText:t,commentHtml:r}}catch{return{commentText:"",commentHtml:""}}}export{Ue as a,Ve as b,q as c,qe as d,j as e,Ee as f,St as g};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veltdev/sdk-staging",
3
- "version": "6.0.40",
3
+ "version": "6.0.41",
4
4
  "description": "Velt is an SDK to add collaborative features to your product within minutes. Example: Comments like Figma, Frame.io, Google docs or sheets, Recording like Loom, Huddles like Slack and much more.",
5
5
  "homepage": "https://velt.dev",
6
6
  "keywords": [