← All changes
|
assets/js/packages/editor-global-classes/editor-global-classes.min.js
+2
-57
4.3.2
→
3.35.0-dev4
View file →
| @@ -1,60 +1,5 @@ | ||
| 1 | -(function(){var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,__commonJSMin=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),__copyProps=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},__toESM=(n,r,a)=>(a=n==null?{}:e(i(n)),__copyProps(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),o=__commonJSMin((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function memo(e,t,n){let r=n.initialDeps??[],i,a=!0;function memoizedFunction(){let o;n.key&&n.debug?.call(n)&&(o=Date.now());let s=e();if(!(s.length!==r.length||s.some((e,t)=>r[t]!==e)))return i;r=s;let c;if(n.key&&n.debug?.call(n)&&(c=Date.now()),i=t(...s),n.key&&n.debug?.call(n)){let e=Math.round((Date.now()-o)*100)/100,t=Math.round((Date.now()-c)*100)/100,r=t/16,pad=(e,t)=>{for(e=String(e);e.length<t;)e=` `+e;return e};console.info(`%c⏱ ${pad(t,5)} /${pad(e,5)} ms`,` | |
| 2 | - font-size: .6rem; | |
| 3 | - font-weight: bold; | |
| 4 | - color: hsl(${Math.max(0,Math.min(120-120*r,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i}return memoizedFunction.updateDeps=e=>{r=e},memoizedFunction}function notUndefined(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var approxEqual=(e,t)=>Math.abs(e-t)<1.01,debounce=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}};e.approxEqual=approxEqual,e.debounce=debounce,e.memo=memo,e.notUndefined=notUndefined})),s=__commonJSMin((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=o(),getRect=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},defaultKeyExtractor=e=>e,defaultRangeExtractor=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let e=t;e<=n;e++)r.push(e);return r},observeElementRect=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let handler=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(handler(getRect(n)),!r.ResizeObserver)return()=>{};let i=new r.ResizeObserver(t=>{let run=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){handler({width:t.inlineSize,height:t.blockSize});return}}handler(getRect(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(run):run()});return i.observe(n,{box:`border-box`}),()=>{i.unobserve(n)}},n={passive:!0},observeWindowRect=(e,t)=>{let r=e.scrollElement;if(!r)return;let handler=()=>{t({width:r.innerWidth,height:r.innerHeight})};return handler(),r.addEventListener(`resize`,handler,n),()=>{r.removeEventListener(`resize`,handler)}},r=typeof window>`u`||`onscrollend`in window,observeElementOffset=(e,i)=>{let a=e.scrollElement;if(!a)return;let o=e.targetWindow;if(!o)return;let s=0,c=e.options.useScrollendEvent&&r?()=>void 0:t.debounce(o,()=>{i(s,!1)},e.options.isScrollingResetDelay),createHandler=t=>()=>{let{horizontal:n,isRtl:r}=e.options;s=n?a.scrollLeft*(r&&-1||1):a.scrollTop,c(),i(s,t)},l=createHandler(!0),u=createHandler(!1);a.addEventListener(`scroll`,l,n);let d=e.options.useScrollendEvent&&r;return d&&a.addEventListener(`scrollend`,u,n),()=>{a.removeEventListener(`scroll`,l),d&&a.removeEventListener(`scrollend`,u)}},observeWindowOffset=(e,i)=>{let a=e.scrollElement;if(!a)return;let o=e.targetWindow;if(!o)return;let s=0,c=e.options.useScrollendEvent&&r?()=>void 0:t.debounce(o,()=>{i(s,!1)},e.options.isScrollingResetDelay),createHandler=t=>()=>{s=a[e.options.horizontal?`scrollX`:`scrollY`],c(),i(s,t)},l=createHandler(!0),u=createHandler(!1);a.addEventListener(`scroll`,l,n);let d=e.options.useScrollendEvent&&r;return d&&a.addEventListener(`scrollend`,u,n),()=>{a.removeEventListener(`scroll`,l),d&&a.removeEventListener(`scrollend`,u)}},measureElement=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},windowScroll=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},elementScroll=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;let o=e+t;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:o,behavior:n})},Virtualizer=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,get=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let run=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(run):run()})}));return{disconnect:()=>{var t;(t=get())==null||t.disconnect(),e=null},observe:e=>get()?.observe(e,{box:`border-box`}),unobserve:e=>get()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:defaultKeyExtractor,rangeExtractor:defaultRangeExtractor,onChange:()=>{},measureElement,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,...e}},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=t.memo(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=t.memo(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=t.memo(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let c=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let l=this.measurementsCache.slice(0,c),u=Array(a).fill(void 0);for(let e=0;e<c;e++){let t=l[e];t&&(u[t.lane]=e)}for(let i=c;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),c,d,f=o===`estimate`||s.has(e);if(a!==void 0&&this.options.lanes>1){c=a;let e=u[c],r=e===void 0?void 0:l[e];d=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?l[i-1]:this.getFurthestMeasurement(l,i);d=e?e.end+this.options.gap:t+n,c=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,c)}let p=s.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=d+m;l[i]={index:i,start:d,size:m,end:h,key:e,lane:c},u[c]=i}return this.measurementsCache=l,l},{key:!1,debug:()=>this.options.debug}),this.calculateRange=t.memo(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?calculateRange({measurements:e,outerSize:t,scrollOffset:n,lanes:r}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=t.memo(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{let n=this.measurementsCache[e];if(!n)return;let r=t-(this.itemSizeCache.get(n.key)??n.size);r!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?n.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(n,r,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=r,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,t)),this.notify(!1))},this.getVirtualItems=t.memo(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let n=this.getMeasurements();if(n.length!==0)return t.notUndefined(n[findNearestBinarySearch(0,n.length-1,e=>t.notUndefined(n[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1)t=e[e.length-1]?.end??0;else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),n=e?e[0]:this.scrollState.lastTargetOffset,r=n!==this.scrollState.lastTargetOffset;if(!r&&t.approxEqual(n,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,r&&(this.scrollState.lastTargetOffset=n,this.scrollState.behavior=`auto`,this._scrollToOffset(n,{adjustments:void 0,behavior:`auto`}));this.scheduleScrollReconcile()}},findNearestBinarySearch=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function calculateRange({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){let i=e.length-1,getOffset=t=>e[t].start;if(e.length<=r)return{startIndex:0,endIndex:i};let a=findNearestBinarySearch(0,i,getOffset,n),o=a;if(r===1)for(;o<i&&e[o].end<n+t;)o++;else if(r>1){let s=Array(r).fill(0);for(;o<i&&s.some(e=>e<n+t);){let t=e[o];s[t.lane]=t.end,o++}let c=Array(r).fill(n+t);for(;a>=0&&c.some(e=>e>=n);){let t=e[a];c[t.lane]=t.start,a--}a=Math.max(0,a-a%r),o=Math.min(i,o+(r-1-o%r))}return{startIndex:a,endIndex:o}}e.approxEqual=t.approxEqual,e.debounce=t.debounce,e.memo=t.memo,e.notUndefined=t.notUndefined,e.Virtualizer=Virtualizer,e.defaultKeyExtractor=defaultKeyExtractor,e.defaultRangeExtractor=defaultRangeExtractor,e.elementScroll=elementScroll,e.measureElement=measureElement,e.observeElementOffset=observeElementOffset,e.observeElementRect=observeElementRect,e.observeWindowOffset=observeWindowOffset,e.observeWindowRect=observeWindowRect,e.windowScroll=windowScroll})),c=__commonJSMin((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=globalThis.React,n=globalThis.ReactDOM,r=s();function _interopNamespaceDefault(e){let t=Object.create(null,{[Symbol.toStringTag]:{value:`Module`}});if(e){for(let n in e)if(n!=="default"){let r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}var i=_interopNamespaceDefault(t),a=typeof document<`u`?i.useLayoutEffect:i.useEffect;function useVirtualizerBase({useFlushSync:e=!0,...t}){let o=i.useReducer(()=>({}),{})[1],s={...t,onChange:(r,i)=>{var a;e&&i?n.flushSync(o):o(),(a=t.onChange)==null||a.call(t,r,i)}},[c]=i.useState(()=>new r.Virtualizer(s));return c.setOptions(s),a(()=>c._didMount(),[]),a(()=>c._willUpdate()),c}function useVirtualizer(e){return useVirtualizerBase({observeElementRect:r.observeElementRect,observeElementOffset:r.observeElementOffset,scrollToFn:r.elementScroll,...e})}function useWindowVirtualizer(e){return useVirtualizerBase({getScrollElement:()=>typeof document<`u`?window:null,observeElementRect:r.observeWindowRect,observeElementOffset:r.observeWindowOffset,scrollToFn:r.windowScroll,initialOffset:()=>typeof document<`u`?window.scrollY:0,...e})}e.useVirtualizer=useVirtualizer,e.useWindowVirtualizer=useWindowVirtualizer,Object.keys(r).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:()=>r[t]})})})),l=__toESM(__commonJSMin(((e,t)=>{var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,__export=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},__copyProps=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!s.call(e,c)&&c!==n&&r(e,c,{get:()=>t[c],enumerable:!(o=i(t,c))||o.enumerable});return e},__toESM=(e,t,i)=>(i=e==null?{}:n(o(e)),__copyProps(t||!e||!e.__esModule?r(i,`default`,{value:e,enumerable:!0}):i,e)),__toCommonJS=e=>__copyProps(r({},`__esModule`,{value:!0}),e),l={};__export(l,{ClassManagerPanelEmbedded:()=>ClassManagerPanelEmbedded,GLOBAL_CLASSES_URI:()=>Y,addDocumentClasses:()=>addDocumentClasses,createLabelsForClasses:()=>createLabelsForClasses,init:()=>init,loadExistingClasses:()=>loadExistingClasses,trackGlobalClasses:()=>trackGlobalClasses}),t.exports=__toCommonJS(l);var u=__toESM(globalThis.React),d=globalThis.React,f=globalThis.elementorV2.editorCurrentUser,p=globalThis.elementorV2.editorDocuments,m=globalThis.elementorV2.editorPanels,h=globalThis.elementorV2.editorUi,ee=globalThis.elementorV2.query,te=globalThis.elementorV2.store,g=globalThis.elementorV2.ui,_=globalThis.wp.i18n,ne=globalThis.elementorV2.store,re=globalThis.elementorV2.editorStyles,v=globalThis.elementorV2.store,ie=globalThis.elementorV2.utils,ae=(0,ie.createError)({code:`global_class_not_found`,message:`Global class not found.`}),oe=(0,ie.createError)({code:`global_class_label_already_exists`,message:`Class with this name already exists.`}),se=(0,ie.createError)({code:`global_class_tracking_error`,message:`Error tracking global classes event.`});function createLink({value:e,next:t,prev:n}){return{value:e,prev:n||null,next:t||null}}var y=class _SnapshotHistory{constructor(e){this.namespace=e}static registry={};static get(e){return _SnapshotHistory.registry[e]||(_SnapshotHistory.registry[e]=new _SnapshotHistory(e)),_SnapshotHistory.registry[e]}first=null;current=null;transform(e){return JSON.parse(JSON.stringify(e))}reset(){this.first=this.current=null}prev(){return!this.current||this.current===this.first?null:(this.current=this.current.prev,this.current?.value||null)}isLast(){return!this.current||!this.current.next}next(e){if(e){if(!this.current)return this.first=createLink({value:this.transform(e)}),this.current=this.first,this.current.value;let t=createLink({value:this.transform(e),prev:this.current});return this.current.next=t,this.current=t,this.current.value}return!this.current||!this.current.next?null:(this.current=this.current.next,this.current.value)}}.get(`global-classes`),ce={data:{items:{},order:[]},classLabels:{},initialData:{frontend:{items:{},order:[]},preview:{items:{},order:[]}},isDirty:!1},b=`globalClasses`,x=(0,v.__createSlice)({name:b,initialState:ce,reducers:{load(e,{payload:{frontend:t,preview:n,classLabels:r}}){e.initialData.frontend=t,e.initialData.preview=n,e.data=n,e.classLabels=r,e.isDirty=!1},add(e,{payload:t}){y.next(e.data),e.data.items[t.id]=t,e.data.order.unshift(t.id),e.classLabels[t.id]=t.label,e.isDirty=!0},delete(e,{payload:t}){y.next(e.data),e.data.items=Object.fromEntries(Object.entries(e.data.items).filter(([e])=>e!==t)),e.data.order=e.data.order.filter(e=>e!==t),delete e.classLabels[t],e.isDirty=!0},setOrder(e,{payload:t}){y.next(e.data),e.data.order=t,e.isDirty=!0},update(e,{payload:t}){let n=e.classLabels[t.style.id];y.next(e.data);let r={...e.data.items[t.style.id],...t.style};n&&t.style.label&&t.style.label!==n&&(e.classLabels[t.style.id]=t.style.label),e.data.items[t.style.id]=r,e.isDirty=!0},updateMultiple(e,{payload:t}){y.next(e.data),Object.entries(t).forEach(([t,{modified:n}])=>{e.data.items[t].label=n,e.classLabels[t]=n}),e.isDirty=!1},updateProps(e,{payload:t}){let n=e.data.items[t.id];if(!n)throw new ae({context:{styleId:t.id}});y.next(e.data);let r=(0,re.getVariantByMeta)(n,t.meta),i=(`custom_css`in t?t.custom_css:r?.custom_css)??null;if(i=i?.raw?i:null,r){let e=JSON.parse(JSON.stringify(t.props));(t.mode??`merge`)===`replace`?r.props=e:r.props=mergeProps(JSON.parse(JSON.stringify(r.props)),e),r.custom_css=i,n.variants=getNonEmptyVariants(n)}else n.variants.push({meta:t.meta,props:t.props,custom_css:i});e.isDirty=!0},reset(e,{payload:{context:t}}){t===`frontend`&&(y.reset(),e.initialData.frontend=e.data,e.isDirty=!1),e.initialData.preview=e.data},undo(e){y.isLast()&&y.next(e.data);let t=y.prev();t?(e.data=t,e.isDirty=!0):e.data=e.initialData.preview},resetToInitialState(e,{payload:{context:t}}){y.reset(),e.data=e.initialData[t],e.isDirty=!1},redo(e){let t=y.next();y.isLast()&&y.prev(),t&&(e.data=t,e.isDirty=!0)},mergeExistingClasses(e,{payload:{preview:t,frontend:n}}){Object.entries(t).forEach(([t,r])=>{let i=n[t];r!=null&&(t in e.data.items||(e.data.items[t]=r),i&&!(t in e.initialData.frontend.items)&&(e.initialData.frontend.items[t]=i),t in e.initialData.preview.items||(e.initialData.preview.items[t]=r),t in e.classLabels||(e.classLabels[t]=r.label))})},setOrderWithoutHistory(e,{payload:t}){e.data.order=t},updateAfterTemplateImport(e,{payload:t}){e.initialData.frontend.items={...e.initialData.frontend.items,...t.addedItems},e.initialData.frontend.order=[...e.initialData.frontend.order,...t.addedIdsOrder],e.initialData.preview.items={...e.initialData.preview.items,...t.addedItems},e.initialData.preview.order=[...e.initialData.preview.order,...t.addedIdsOrder],e.data.items={...e.data.items,...t.addedItems},e.data.order=[...e.data.order,...t.addedIdsOrder],e.classLabels={...e.classLabels,...t.addedClassLabels}}}}),mergeProps=(e,t)=>{let n=Array.isArray(e)?{}:e;return Object.entries(t).forEach(([e,t])=>{t==null?delete n[e]:n[e]=t}),n},getNonEmptyVariants=e=>e.variants.filter(({props:e,custom_css:t})=>Object.keys(e).length||t?.raw),placeholderDefinition=(e,t)=>({id:e,type:`class`,label:t,variants:[]}),selectData=e=>e[b].data,selectClassLabels=e=>e[b].classLabels,selectFrontendInitialData=e=>e[b].initialData.frontend,selectPreviewInitialData=e=>e[b].initialData.preview,le=(0,v.__createSelector)(selectData,({order:e})=>e),ue=(0,v.__createSelector)(selectData,({items:e})=>e),selectIsDirty=e=>e[b].isDirty,de=(0,v.__createSelector)(selectData,selectClassLabels,({items:e,order:t},n)=>t.map(t=>{let r=e[t];if(r)return r;let i=n[t];return i===void 0?null:placeholderDefinition(t,i)}).filter(e=>e!==null)),selectClass=(e,t)=>e[b].data.items[t]??null,fe=(0,v.__createSelector)(selectData,({items:e})=>Object.values(e).filter(e=>(e.variants?.length??0)===0)),selectIsClassFetched=(e,t)=>!!e[b].initialData.preview.items[t]||!!e[b].initialData.frontend.items[t]||!1,useClassesOrder=()=>(0,ne.__useSelector)(le),pe=globalThis.elementorV2.store,useDirtyState=()=>(0,pe.__useSelector)(selectIsDirty),me=globalThis.React,he=__toESM(globalThis.React),ge=globalThis.React,_e=globalThis.elementorV2.utils,ve=(0,ge.createContext)(void 0),ye={empty:!1,onThisPage:!1,unused:!1},SearchAndFilterProvider=({children:e})=>{let[t,n]=(0,ge.useState)(ye),getInitialSearchValue=()=>{let e=localStorage.getItem(`elementor-global-classes-search`);return e?(localStorage.removeItem(`elementor-global-classes-search`),e):``},{debouncedValue:r,inputValue:i,handleChange:a}=(0,_e.useDebounceState)({delay:300,initialValue:getInitialSearchValue()}),onClearSearch=()=>{a(``)},onClearFilter=()=>{n(ye)};return he.createElement(ve.Provider,{value:{search:{debouncedValue:r,inputValue:i,handleChange:a,onClearSearch},filters:{filters:t,setFilters:n,onClearFilter}}},e)},useSearchAndFilters=()=>{let e=(0,ge.useContext)(ve);if(!e)throw Error(`useSearchContext must be used within a SearchContextProvider`);return e},be=globalThis.React,xe=globalThis.elementorV2.editorDocuments,Se=globalThis.elementorV2.query,Ce=globalThis.elementorV2.httpClient,we=`/global-classes`,Te=`elementor/v1`,Ee=`${we}/usage`,De=`${we}/post`,Oe=`${we}/styles`;function saveGlobalClasses(e,t){return(0,Ce.httpService)().put(`${Te}${we}`,t,{params:{context:e}})}var S={usage:()=>(0,Ce.httpService)().get(`${Te}${Ee}`),all:(e=`preview`)=>(0,Ce.httpService)().get(`${Te}${we}`,{params:{context:e}}),getStylesForPost:(e,t=`preview`)=>(0,Ce.httpService)().get(`${Te}${De}`,{params:{context:t,post_id:e}}),getStylesByIds:(e,t=`preview`)=>(0,Ce.httpService)().get(`${Te}${Oe}`,{params:{context:t,ids:e.join(`,`)}}),publish:e=>saveGlobalClasses(`frontend`,e),saveDraft:e=>saveGlobalClasses(`preview`,e)},ke={DUPLICATED_LABEL:`DUPLICATED_LABEL`},transformData=e=>Object.entries(e).reduce((e,[t,n])=>(e[t]={content:n||[],total:n.reduce((e,t)=>e+(t?.total||0),0)},e),{}),fetchCssClassUsage=async()=>transformData((await S.usage())?.data?.data||{}),Ae=`css-classes-usage`,useCssClassUsage=()=>(0,Se.useQuery)({queryKey:[Ae],queryFn:fetchCssClassUsage,refetchOnMount:!1,refetchOnWindowFocus:!0}),je=globalThis.elementorV2.store,useEmptyCssClass=()=>(0,je.__useSelector)(fe),useAllCssClassesIDs=()=>{let e=(0,je.__useSelector)(ue);return Object.keys(e)},findCssClassKeysByPageID=(e,t)=>{let n=[];for(let r in e)e[r].content.forEach(e=>{+e.pageId===t&&n.push(r)});return n},getUnusedClasses=(e,t)=>{let n=new Set(e);return t.filter(e=>!n.has(e))},Me={empty:[],onThisPage:[],unused:[]},useFilteredCssClassUsage=()=>{let e=(0,xe.__useActiveDocument)(),t=useEmptyCssClass(),{data:n,isLoading:r}=useCssClassUsage(),i=useAllCssClassesIDs(),a=(0,be.useMemo)(()=>t.map(({id:e})=>e),[t]),o=(0,be.useMemo)(()=>!n||!e?[]:findCssClassKeysByPageID(n,e.id),[n,e]),s=(0,be.useMemo)(()=>n?getUnusedClasses(Object.keys(n),i):[],[n,i]);return r||!n||!e?Me:{onThisPage:o,unused:s,empty:a}},useFilters=()=>{let{filters:{filters:e}}=useSearchAndFilters(),t=useFilteredCssClassUsage();return(0,me.useMemo)(()=>{let n=Object.entries(e).filter(([,e])=>e);return n.length===0?null:n.reduce((e,[n],r)=>{let i=t[n]||[];return r===0?i:e.filter(e=>i.includes(e))},[])},[e,t])},Ne=globalThis.elementorV2.store,Pe=globalThis.elementorV2.editorDocuments,Fe=globalThis.elementorV2.store;function createLabelsForClasses(e){return Object.fromEntries(e.map(e=>[e.id,e.label]))}function styleDefinitionsMapWithoutNull(e){return Object.fromEntries(Object.entries(e).filter(e=>e[1]!==null))}function resetGlobalClassesState(e,t){(0,Fe.__dispatch)(x.actions.load({preview:{items:{},order:e},frontend:{items:{},order:e},classLabels:t}))}async function loadCurrentDocumentClasses(){let[e,t]=await Promise.all([S.all(`preview`),S.all(`frontend`)]),n=e.data.data,r=t.data.data,i=createLabelsForClasses(n),a=n.map(e=>e.id),o=r.map(e=>e.id);resetGlobalClassesState(a,i);let s=(0,Pe.getCurrentDocument)()?.id;if(!s)return;let[c,l]=await Promise.all([S.getStylesForPost(s,`preview`),S.getStylesForPost(s,`frontend`)]),u=styleDefinitionsMapWithoutNull(c.data.data),d=styleDefinitionsMapWithoutNull(l.data.data);(0,Fe.__dispatch)(x.actions.load({preview:{items:u,order:a},frontend:{items:d,order:o},classLabels:i}))}async function addDocumentClasses(e){let[t,n]=await Promise.all([S.getStylesForPost(e,`preview`),S.getStylesForPost(e,`frontend`)]),r=styleDefinitionsMapWithoutNull(t.data.data),i=styleDefinitionsMapWithoutNull(n.data.data);(0,Fe.__dispatch)(x.actions.mergeExistingClasses({preview:r,frontend:i}))}var Ie=null,Le=new Set;async function loadExistingClasses(e){let t=ue((0,Ne.__getState)()),n=e.filter(e=>!(e in t));if(n.length!==0){if(n.forEach(e=>Le.add(e)),Ie)return await Ie,loadExistingClasses(e);Ie=fetchAndMergeClasses();try{await Ie}finally{Ie=null}}}async function fetchAndMergeClasses(){let e=Array.from(Le);if(Le.clear(),e.length===0)return;let[t,n]=await Promise.all([S.getStylesByIds(e,`preview`),S.getStylesByIds(e,`frontend`)]),r=styleDefinitionsMapWithoutNull(t.data.data),i=styleDefinitionsMapWithoutNull(n.data.data);(0,Ne.__dispatch)(x.actions.mergeExistingClasses({preview:r,frontend:i}))}var Re=__toESM(globalThis.React),ze=globalThis.elementorV2.editorUi,Be=globalThis.elementorV2.store,Ve=globalThis.elementorV2.utils,C=__toESM(globalThis.React),He=globalThis.elementorV2.editorUi,Ue=globalThis.elementorV2.icons,w=globalThis.elementorV2.ui,T=globalThis.wp.i18n,We=`DUP_`,DuplicateLabelDialog=({modifiedLabels:e,onApprove:t})=>{let handleButtonClick=()=>{localStorage.setItem(`elementor-global-classes-search`,We),t?.(),(0,He.closeDialog)()};return C.createElement(C.Fragment,null,C.createElement(w.DialogHeader,{logo:!1},C.createElement(w.Box,{display:`flex`,alignItems:`center`,gap:1},C.createElement(w.Icon,{color:`secondary`},C.createElement(Ue.InfoCircleFilledIcon,{fontSize:`medium`})),C.createElement(w.Typography,{variant:`subtitle1`},(0,T.__)(`We've published your page and updated class names.`,`elementor`)))),C.createElement(w.DialogContent,null,C.createElement(w.Stack,{spacing:2,direction:`column`},C.createElement(w.Typography,{variant:`body2`},(0,T.__)(`Some new classes used the same names as existing ones. To prevent conflicts, we added the prefix`,`elementor`),C.createElement(`strong`,null,` `,We)),C.createElement(w.Box,null,C.createElement(w.Box,{sx:{width:`100%`,display:`flex`,gap:2,alignItems:`flex-start`}},C.createElement(w.Typography,{variant:`subtitle2`,sx:{fontWeight:`bold`,flex:1,flexShrink:1,flexGrow:1,minWidth:0}},(0,T.__)(`Before`,`elementor`)),C.createElement(w.Typography,{variant:`subtitle2`,sx:{minWidth:`200px`,fontWeight:`bold`,flexShrink:0,flexGrow:0,width:`200px`,maxWidth:`200px`}},(0,T.__)(`After`,`elementor`))),C.createElement(w.Divider,{sx:{mt:.5,mb:.5}}),C.createElement(w.Stack,{direction:`column`,gap:.5,sx:{pb:2}},Object.values(e).map(({original:e,modified:t},n)=>C.createElement(w.Box,{key:n,sx:{width:`100%`,display:`flex`,gap:2,alignItems:`flex-start`}},C.createElement(w.Box,{sx:{flex:1,flexShrink:1,flexGrow:1,minWidth:0}},C.createElement(He.EllipsisWithTooltip,{title:e},C.createElement(w.Typography,{variant:`body2`,sx:{color:`text.secondary`}},e))),C.createElement(w.Box,{sx:{minWidth:`200px`,flexShrink:0,flexGrow:0,width:`200px`,maxWidth:`200px`}},C.createElement(He.EllipsisWithTooltip,{title:t},C.createElement(w.Typography,{variant:`body2`,sx:{color:`text.primary`}},t)))))),C.createElement(w.Box,null,C.createElement(w.Alert,{severity:`info`,size:`small`,color:`secondary`},C.createElement(`strong`,null,(0,T.__)(`Your designs and classes are safe.`,`elementor`)),(0,T.__)(`Only the prefixes were added. Find them in Class Manager by searching`,`elementor`),C.createElement(`strong`,null,We)))))),C.createElement(w.DialogActions,null,C.createElement(w.Button,{color:`secondary`,variant:`text`,onClick:handleButtonClick},(0,T.__)(`Go to Class Manager`,`elementor`)),C.createElement(w.Button,{color:`secondary`,variant:`contained`,onClick:He.closeDialog},(0,T.__)(`Done`,`elementor`))))},Ge=globalThis.elementorV2.events,Ke=globalThis.elementorV2.store,trackGlobalClasses=async e=>{let{runAction:t}=e,n=await getSanitizedData(e);n&&(track(n),n.event===`classCreated`&&`classId`in n&&fireClassApplied(n.classId)),t?.()},fireClassApplied=async e=>{track({event:`classApplied`,classId:e,...await getAppliedInfo(e),totalInstancesAfterApply:1})},getSanitizedData=async e=>{switch(e.event){case`classApplied`:if(`classId`in e&&e.classId){let t=await getAppliedInfo(e.classId);return{...e,...t}}break;case`classRemoved`:if(`classId`in e&&e.classId){let t=getRemovedInfo(e.classId);return{...e,...t}}break;case`classDeleted`:if(`classId`in e&&e.classId){let t=await trackDeleteClass(e.classId);return{...e,...t}}break;case`classCreated`:return`source`in e&&e.source!==`created`&&`classId`in e&&e.classId?{...e,classTitle:getCssClass(e.classId).label}:e;case`classStateClicked`:if(`classId`in e&&e.classId)return{...e,classTitle:getCssClass(e.classId).label};break;case`classSyncToV3PopupShown`:return{...e,interaction_type:`popup_shown`,target_type:`popup`,target_name:`sync_to_v3_popup`,interaction_result:`popup_viewed`,target_location:`widget_panel`,location_l1:`class_manager`};case`classSyncToV3`:{let t=getCssClass(e.classId).label,n=e.action===`sync`;return{...e,interaction_type:`click`,target_type:t,target_name:n?`sync_to_v3`:`unsync_to_v3`,interaction_result:n?`class_is_synced_to_V3`:`class_is_unsynced_from_V3`,target_location:`widget_panel`,location_l1:`class_manager`,interaction_description:n?`user_synced_${t}_to_v3`:`user_unsync_${t}_from_v3`}}case`classSyncToV3PopupClick`:{let t=e.action===`sync`;return{...e,interaction_type:`click`,target_type:`button`,target_name:t?`sync_to_v3`:`cancel`,interaction_result:t?`class_is_synced`:`cancel`,target_location:`sync_to_v3_popup`}}default:return e}},track=e=>{let{dispatchEvent:t,config:n}=(0,Ge.getMixpanel)();if(!n?.names?.global_classes?.[e.event]){console.error(`Global class tracking event not found`,{event:e.event});return}let r=n.names.global_classes[e.event],{event:i,...a}=e;try{t?.(r,{event:i,...a})}catch(e){throw new se({cause:e})}},extractCssClassData=e=>({classTitle:getCssClass(e).label}),getCssClass=e=>{let t=(0,Ke.__getState)(),n=selectClass(t,e);if(n)return n;let r=selectClassLabels(t)[e];if(r!==void 0)return placeholderDefinition(e,r);throw Error(`CSS class with ID ${e} not found`)},trackDeleteClass=async e=>{let t=getCssClass(e).label;return{totalInstances:await getTotalInstancesByCssClassID(e),classTitle:t}},getTotalInstancesByCssClassID=async e=>(await fetchCssClassUsage())[e]?.total??1,getAppliedInfo=async e=>{let{classTitle:t}=extractCssClassData(e);return{classTitle:t,totalInstancesAfterApply:await getTotalInstancesByCssClassID(e)+1}},getRemovedInfo=e=>{let{classTitle:t}=extractCssClassData(e);return{classTitle:t}};async function saveGlobalClasses2({context:e,onApprove:t}){let n=selectData((0,Be.__getState)()),r=e===`preview`?S.saveDraft:S.publish,i=calculateChanges(n,(e===`preview`?selectPreviewInitialData:selectFrontendInitialData)((0,Be.__getState)())),a=[...i.added,...i.modified],o=await r({items:Object.fromEntries(a.map(e=>[e,n.items[e]]).filter(([,e])=>e)),order:n.order,changes:i});(0,Be.__dispatch)(x.actions.reset({context:e})),window.dispatchEvent(new CustomEvent(`classes:updated`,{detail:{context:e}})),o?.data?.data?.code===ke.DUPLICATED_LABEL&&((0,Be.__dispatch)(x.actions.updateMultiple(o.data.data.modifiedLabels)),trackGlobalClasses({event:`classPublishConflict`,numOfConflicts:Object.keys(o.data.data.modifiedLabels).length}),(0,ze.openDialog)({component:Re.createElement(DuplicateLabelDialog,{modifiedLabels:o.data.data.modifiedLabels||[],onApprove:t})}))}function calculateChanges(e,t){let n=Object.keys(e.items),r=Object.keys(t.items),{order:i}=e,{order:a}=t,o=new Set(i),s=a.filter(e=>!o.has(e)),c=i.join(`;`)!==a.join(`;`);return{added:n.filter(e=>!r.includes(e)),deleted:s,modified:n.filter(n=>n in t.items&&(0,Ve.hash)(e.items[n])!==(0,Ve.hash)(t.items[n])),order:c}}var qe=__toESM(globalThis.React),Je=globalThis.elementorV2.ui,Ye=globalThis.wp.i18n,Xe=__toESM(globalThis.React),Ze=globalThis.elementorV2.icons,Qe=globalThis.elementorV2.ui,ClearIconButton=({tooltipText:e,sx:t,trigger:n})=>{let{filters:{onClearFilter:r}}=useSearchAndFilters(),handleClearFilters=()=>{r(n),trackGlobalClasses({event:`classManagerFilterCleared`,trigger:n})};return Xe.createElement(Qe.Tooltip,{title:e,placement:`top`,disableInteractive:!0},Xe.createElement(Qe.Box,null,Xe.createElement($e,{"aria-label":e,size:`tiny`,onClick:handleClearFilters,sx:t},Xe.createElement(Ze.BrushBigIcon,{fontSize:`tiny`}))))},$e=(0,Qe.styled)(Qe.IconButton)(({theme:e})=>({"&.Mui-disabled":{pointerEvents:`auto`,"&:hover":{color:e.palette.action.disabled}}})),E=__toESM(globalThis.React),D=globalThis.elementorV2.ui,et=globalThis.wp.i18n,tt={unused:(0,et.__)(`Unused`,`elementor`),empty:(0,et.__)(`Empty`,`elementor`),onThisPage:(0,et.__)(`On this page`,`elementor`)},FilterList=()=>{let{filters:{filters:e,setFilters:t}}=useSearchAndFilters(),n=useFilteredCssClassUsage(),handleOnClick=n=>{t(e=>({...e,[n]:!e[n]})),trackGlobalClasses({event:`classManagerFilterUsed`,action:e[n]?`remove`:`apply`,type:n,trigger:`menu`})};return E.createElement(D.MenuList,null,E.createElement(D.MenuItem,{onClick:()=>handleOnClick(`unused`)},E.createElement(LabeledCheckbox,{label:tt.unused,checked:e.unused,suffix:E.createElement(D.Chip,{size:`tiny`,sx:{ml:`auto`},label:n.unused.length})})),E.createElement(D.MenuItem,{onClick:()=>handleOnClick(`empty`)},E.createElement(LabeledCheckbox,{label:tt.empty,checked:e.empty,suffix:E.createElement(D.Chip,{size:`tiny`,sx:{ml:`auto`},label:n.empty.length})})),E.createElement(D.MenuItem,{onClick:()=>handleOnClick(`onThisPage`)},E.createElement(LabeledCheckbox,{label:tt.onThisPage,checked:e.onThisPage,suffix:E.createElement(D.Chip,{size:`tiny`,sx:{ml:`auto`},label:n.onThisPage.length})})))},LabeledCheckbox=({label:e,suffix:t,checked:n})=>E.createElement(D.Stack,{direction:`row`,alignItems:`center`,gap:.5,flex:1},E.createElement(D.Checkbox,{size:`small`,checked:n,sx:{padding:0,color:`text.tertiary`,"&.Mui-checked":{color:`text.tertiary`}}}),E.createElement(D.Typography,{variant:`caption`,sx:{color:`text.secondary`}},e),t),ActiveFilters=()=>{let{filters:{filters:e,setFilters:t}}=useSearchAndFilters(),handleRemove=e=>{t(t=>({...t,[e]:!1})),trackGlobalClasses({event:`classManagerFilterUsed`,action:`remove`,type:e,trigger:`header`})},n=Object.keys(e).filter(t=>e[t]),r=n.length>0;return qe.createElement(Je.Stack,{direction:`row`,alignItems:`center`,justifyContent:`space-between`},qe.createElement(Je.Stack,{direction:`row`,gap:.5,alignItems:`center`,flexWrap:`wrap`},n.map(e=>qe.createElement(Je.Chip,{key:e,label:tt[e],onDelete:()=>handleRemove(e),sx:nt,size:`tiny`}))),r&&qe.createElement(ClearIconButton,{trigger:`header`,tooltipText:(0,Ye.__)(`Clear Filters`,`elementor`),sx:{margin:`0 0 auto auto`}}))},nt={"& .MuiChip-deleteIcon":{display:`none`,transition:`opacity 0.2s`},"&:hover .MuiChip-deleteIcon":{display:`block`}},O=__toESM(globalThis.React),rt=globalThis.React,it=globalThis.elementorV2.editorUi,at=globalThis.elementorV2.icons,k=globalThis.elementorV2.ui,ot=globalThis.wp.i18n,CssClassFilter=()=>{let{filters:{filters:e}}=useSearchAndFilters(),t=(0,k.usePopupState)({variant:`popover`,disableAutoFocus:!0});(0,rt.useEffect)(()=>{t.isOpen&&trackGlobalClasses({event:`classManagerFiltersOpened`})},[t.isOpen]);let n=Object.values(e).some(e=>e);return O.createElement(O.Fragment,null,O.createElement(k.Tooltip,{title:(0,ot.__)(`Filters`,`elementor`),placement:`top`},O.createElement(k.ToggleButton,{value:`filter`,size:`tiny`,selected:t.isOpen,...(0,k.bindToggle)(t)},O.createElement(at.FilterIcon,{fontSize:`tiny`}))),O.createElement(k.Popover,{sx:{maxWidth:`344px`},anchorOrigin:{vertical:`top`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:-21},...(0,k.bindPopover)(t)},O.createElement(it.PopoverHeader,{actions:n?[O.createElement(ClearIconButton,{trigger:`menu`,key:`clear-all-button`,tooltipText:(0,ot.__)(`Clear all`,`elementor`)})]:[],onClose:t.close,title:(0,ot.__)(`Filters`,`elementor`),icon:O.createElement(at.FilterIcon,{fontSize:`tiny`})}),O.createElement(k.Divider,{sx:{borderWidth:`1px 0 0 0`}}),O.createElement(it.PopoverBody,{width:344,height:125},O.createElement(FilterList,null))))},st=__toESM(globalThis.React),ct=globalThis.elementorV2.icons,lt=globalThis.elementorV2.ui,ut=globalThis.wp.i18n,ClassManagerSearch=()=>{let{search:{inputValue:e,handleChange:t}}=useSearchAndFilters();return st.createElement(lt.Stack,{direction:`row`,gap:.5,sx:{width:`100%`}},st.createElement(lt.Box,{sx:{flexGrow:1}},st.createElement(lt.TextField,{role:`search`,fullWidth:!0,size:`tiny`,value:e,onFocus:()=>{trackGlobalClasses({event:`classManagerSearched`})},placeholder:(0,ut.__)(`Search`,`elementor`),onChange:e=>t(e.target.value),InputProps:{startAdornment:st.createElement(lt.InputAdornment,{position:`start`},st.createElement(ct.SearchIcon,{fontSize:`tiny`}))}})))},A=__toESM(globalThis.React),dt=globalThis.React,ft=globalThis.elementorV2.editorCurrentUser,pt=globalThis.elementorV2.editorUi,mt=globalThis.elementorV2.ui,ht=globalThis.wp.i18n,gt=`global-class-manager`,ClassManagerIntroduction=()=>{let[e,t]=(0,ft.useSuppressedMessage)(gt),[n,r]=(0,dt.useState)(!e);return A.createElement(pt.IntroductionModal,{open:n,title:(0,ht.__)(`Class Manager`,`elementor`),handleClose:e=>{e||t(),r(!1)}},A.createElement(mt.Image,{sx:{width:`100%`,aspectRatio:`16 / 9`},src:`https://assets.elementor.com/packages/v1/images/class-manager-intro.svg`,alt:``}),A.createElement(IntroductionContent,null))},IntroductionContent=()=>A.createElement(mt.Box,{p:3},A.createElement(mt.Typography,{variant:`body2`},(0,ht.__)(`The Class Manager lets you see all the classes you've created, plus adjust their priority, rename them, and delete unused classes to keep your CSS structured.`,`elementor`)),A.createElement(`br`,null),A.createElement(mt.Typography,{variant:`body2`},(0,ht.__)(`Remember, when editing an item within a specific class, any changes you make will apply across all elements in that class.`,`elementor`))),_t=globalThis.elementorV2.store,vt=!1,deleteClass=e=>{trackGlobalClasses({event:`classDeleted`,classId:e,runAction:()=>{(0,_t.__dispatch)(x.actions.delete(e)),vt=!0}})},onDelete=async()=>{vt=!1},hasDeletedItems=()=>vt,yt=__toESM(globalThis.React),bt=globalThis.elementorV2.icons,FlippedColorSwatchIcon=({sx:e,...t})=>yt.createElement(bt.ColorSwatchIcon,{sx:{transform:`rotate(90deg)`,...e},...t}),j=__toESM(globalThis.React),xt=globalThis.React,St=globalThis.elementorV2.store,Ct=globalThis.elementorV2.ui,wt=c(),Tt=globalThis.wp.i18n,Et=globalThis.elementorV2.store,useOrderedClasses=()=>(0,Et.__useSelector)(de),M=__toESM(globalThis.React),Dt=globalThis.React,Ot=globalThis.elementorV2.editorStylesRepository,N=globalThis.elementorV2.editorUi,kt=globalThis.elementorV2.icons,P=globalThis.elementorV2.ui,At=globalThis.wp.i18n,F=__toESM(globalThis.React),jt=globalThis.elementorV2.editorDocuments,Mt=globalThis.elementorV2.editorUi,I=globalThis.elementorV2.icons,L=globalThis.elementorV2.ui,R=globalThis.wp.i18n,Nt={total:0,content:[]},useCssClassUsageByID=e=>{let{data:t,...n}=useCssClassUsage(),r=t?.[e]??Nt;return{...n,data:r}},Pt={"wp-post":{label:(0,R.__)(`Post`,`elementor`),icon:F.createElement(I.PostTypeIcon,{fontSize:`inherit`})},"wp-page":{label:(0,R.__)(`Page`,`elementor`),icon:F.createElement(I.PagesIcon,{fontSize:`inherit`})},popup:{label:(0,R.__)(`Popup`,`elementor`),icon:F.createElement(I.PopupTemplateIcon,{fontSize:`inherit`})},header:{label:(0,R.__)(`Header`,`elementor`),icon:F.createElement(I.HeaderTemplateIcon,{fontSize:`inherit`})},footer:{label:(0,R.__)(`Footer`,`elementor`),icon:F.createElement(I.FooterTemplateIcon,{fontSize:`inherit`})}},CssClassUsagePopover=({cssClassID:e,onClose:t})=>{let{data:n}=useCssClassUsageByID(e),r=(0,jt.__useOpenDocumentInNewTab)(),i=n?.content.map(({title:e,elements:t,pageId:n,type:r})=>({type:`item`,value:n,label:e,secondaryText:t.length.toString(),docType:r}))??[],handleSelect=t=>{r(+t),trackGlobalClasses({event:`classUsageLocate`,classId:e})};return F.createElement(F.Fragment,null,F.createElement(Mt.PopoverHeader,{icon:F.createElement(I.CurrentLocationIcon,{fontSize:`tiny`}),title:F.createElement(L.Stack,{flexDirection:`row`,gap:1,alignItems:`center`},F.createElement(L.Box,{"aria-label":`header-title`},(0,R.__)(`Locator`,`elementor`)),F.createElement(L.Box,null,F.createElement(L.Chip,{sx:{lineHeight:1},size:`tiny`,label:n.total}))),onClose:t}),F.createElement(L.Divider,null),F.createElement(Mt.PopoverBody,{width:300},F.createElement(Mt.PopoverMenuList,{onSelect:handleSelect,items:i,onClose:()=>{},menuListTemplate:Ft,menuItemContentTemplate:e=>F.createElement(L.Stack,{flexDirection:`row`,flex:1,alignItems:`center`},F.createElement(L.Box,{display:`flex`,sx:{pr:1}},F.createElement(L.Tooltip,{disableInteractive:!0,title:Pt?.[e.docType]?.label??e.docType,placement:`top`},F.createElement(L.Icon,{fontSize:`small`},Pt?.[e.docType]?.icon||F.createElement(I.PagesIcon,{fontSize:`inherit`})))),F.createElement(L.Box,{sx:{pr:.5,maxWidth:`173px`},display:`flex`},F.createElement(Mt.EllipsisWithTooltip,{title:e.label,as:L.Typography,variant:`caption`,maxWidth:`173px`,sx:{lineHeight:1}})),F.createElement(I.ExternalLinkIcon,{className:`hover-only-icon`,fontSize:`tiny`}),F.createElement(L.Chip,{sx:{ml:`auto`},size:`tiny`,label:e.secondaryText}))})))},Ft=(0,L.styled)(L.MenuList)(({theme:e})=>({"& > li":{display:`flex`,cursor:`pointer`,height:32,width:`100%`},'& > [role="option"]':{...e.typography.caption,lineHeight:`inherit`,padding:e.spacing(.5,1,.5,2),textOverflow:`ellipsis`,position:`absolute`,top:0,left:0,opacity:1,".hover-only-icon":{color:e.palette.text.disabled,opacity:0},"&:hover":{borderRadius:e.spacing(.5),backgroundColor:e.palette.action.hover,".hover-only-icon":{color:e.palette.text.disabled,opacity:1}}},width:`100%`,position:`relative`})),z=__toESM(globalThis.React),It=globalThis.elementorV2.editorUi,Lt=globalThis.elementorV2.icons,B=globalThis.elementorV2.ui,Rt=globalThis.wp.i18n,CssClassUsageTrigger=({id:e,onClick:t})=>{let{data:{total:n},isLoading:r}=useCssClassUsageByID(e),i=(0,B.usePopupState)({variant:`popover`,popupId:`css-class-usage-popover`});if(r)return null;let a=n===0?InfoAlertMessage:TooltipWrapper,handleMouseEnter=()=>{trackGlobalClasses({event:`classUsageHovered`,classId:e,usage:n})},handleClick=r=>{n!==0&&((0,B.bindTrigger)(i).onClick(r),t(e),trackGlobalClasses({event:`classUsageClicked`,classId:e}))};return z.createElement(z.Fragment,null,z.createElement(B.Box,{position:`relative`,onMouseEnter:handleMouseEnter},z.createElement(a,{total:n},z.createElement(zt,{disabled:n===0,size:`tiny`,...(0,B.bindTrigger)(i),onClick:handleClick},z.createElement(Lt.CurrentLocationIcon,{fontSize:`tiny`})))),z.createElement(B.Box,null,z.createElement(B.Popover,{anchorOrigin:{vertical:`center`,horizontal:`right`},transformOrigin:{vertical:15,horizontal:-50},...(0,B.bindPopover)(i),onClose:()=>{(0,B.bindPopover)(i).onClose(),t(``)}},z.createElement(CssClassUsagePopover,{onClose:i.close,"aria-label":`css-class-usage-popover`,cssClassID:e}))))},zt=(0,B.styled)(B.IconButton)(({theme:e})=>({"&.Mui-disabled":{pointerEvents:`auto`,"&:hover":{color:e.palette.action.disabled}},height:`22px`,width:`22px`})),TooltipWrapper=({children:e,total:t})=>z.createElement(B.Tooltip,{disableInteractive:!0,placement:`top`,title:`${(0,Rt.__)(`Show {{number}} {{locations}}`,`elementor`).replace(`{{number}}`,t.toString()).replace(`{{locations}}`,t===1?(0,Rt.__)(`location`,`elementor`):(0,Rt.__)(`locations`,`elementor`))}`},z.createElement(`span`,null,e)),InfoAlertMessage=({children:e})=>z.createElement(B.Infotip,{disableInteractive:!0,placement:`top`,color:`secondary`,content:z.createElement(It.InfoAlert,{sx:{mt:1}},(0,Rt.__)(`This class isn’t being used yet.`,`elementor`))},z.createElement(`span`,null,e)),V=__toESM(globalThis.React),Bt=globalThis.React,Vt=globalThis.elementorV2.editorUi,Ht=globalThis.elementorV2.ui,Ut=globalThis.wp.i18n,Wt=(0,Bt.createContext)(null),DeleteConfirmationProvider=({children:e})=>{let[t,n]=(0,Bt.useState)(null),openDialog2=e=>{n(e)},closeDialog2=()=>{n(null)};return V.createElement(Wt.Provider,{value:{openDialog:openDialog2,closeDialog:closeDialog2,dialogProps:t}},e,!!t&&V.createElement(DeleteClassDialog,{...t}))},DeleteClassDialog=({label:e,id:t})=>{let{closeDialog:n}=useDeleteConfirmation(),{data:{total:r,content:i}}=useCssClassUsageByID(t),handleConfirm=()=>{n(),deleteClass(t)},a=r&&i.length?(0,Ut.__)(`Will permanently remove it from your project and may affect the design across all elements using it. Used %1 times across %2 pages. This action cannot be undone.`,`elementor`).replace(`%1`,r.toString()).replace(`%2`,i.length.toString()):(0,Ut.__)(`Will permanently remove it from your project and may affect the design across all elements using it. This action cannot be undone.`,`elementor`);return V.createElement(Vt.ConfirmationDialog,{open:!0,onClose:n},V.createElement(Vt.ConfirmationDialog.Title,null,(0,Ut.__)(`Delete this class?`,`elementor`)),V.createElement(Vt.ConfirmationDialog.Content,null,V.createElement(Vt.ConfirmationDialog.ContentText,null,(0,Ut.__)(`Deleting`,`elementor`),V.createElement(Ht.Typography,{variant:`subtitle2`,component:`span`},`\xA0`,e,`\xA0`),a)),V.createElement(Vt.ConfirmationDialog.Actions,{onClose:n,onConfirm:handleConfirm}))},useDeleteConfirmation=()=>{let e=(0,Bt.useContext)(Wt);if(!e)throw Error(`useDeleteConfirmation must be used within a DeleteConfirmationProvider`);return e},Gt=__toESM(globalThis.React),Kt=globalThis.elementorV2.icons,qt=globalThis.elementorV2.ui,SortableProvider=e=>Gt.createElement(qt.UnstableSortableProvider,{restrictAxis:!0,variant:`static`,dragPlaceholderStyle:{visibility:`hidden`},...e}),SortableTrigger=e=>Gt.createElement(Jt,{...e,role:`button`,className:`class-item-sortable-trigger`,"aria-label":`sort`},Gt.createElement(Kt.GripVerticalIcon,{fontSize:`tiny`})),SortableItem=({children:e,id:t,style:n,...r})=>Gt.createElement(qt.UnstableSortableItem,{...r,id:t,render:({itemProps:t,isDragged:r,triggerProps:i,itemStyle:a,triggerStyle:o,dropIndicationStyle:s,showDropIndication:c,isDragOverlay:l,isDragPlaceholder:u})=>Gt.createElement(qt.Box,{...t,style:{...a,...l?null:n},component:`li`,role:`listitem`,sx:{backgroundColor:l?`background.paper`:void 0}},e({itemProps:t,isDragged:r,triggerProps:i,itemStyle:a,triggerStyle:o,isDragPlaceholder:u}),c&&Gt.createElement(Yt,{style:s}))}),Jt=(0,qt.styled)(`div`)(({theme:e})=>({position:`absolute`,left:0,top:`50%`,transform:`translate( -${e.spacing(1.5)}, -50% )`,color:e.palette.action.active})),Yt=(0,qt.styled)(qt.Box)` | |
| 1 | +!function(){"use strict";var e={d:function(t,n){for(var a in n)e.o(n,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:n[a]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{GLOBAL_CLASSES_URI:function(){return K},init:function(){return Ut}});var n=window.elementorV2.editorMcp,a=window.elementorV2.editorStyles,r=window.elementorV2.editorStylesRepository,s=window.elementorV2.store,l=window.wp.i18n,o=window.elementorV2.editorV1Adapters;const i="elementor_global_classes_update_class";var c=window.elementorV2.utils;const d=(0,c.createError)({code:"global_class_not_found",message:"Global class not found."}),u=(0,c.createError)({code:"global_class_label_already_exists",message:"Class with this name already exists."}),m=(0,c.createError)({code:"global_class_tracking_error",message:"Error tracking global classes event."});function p({value:e,next:t,prev:n}){return{value:e,prev:n||null,next:t||null}}class g{static registry={};static get(e){return g.registry[e]||(g.registry[e]=new g(e)),g.registry[e]}first=null;current=null;constructor(e){this.namespace=e}transform(e){return JSON.parse(JSON.stringify(e))}reset(){this.first=this.current=null}prev(){return this.current&&this.current!==this.first?(this.current=this.current.prev,this.current?.value||null):null}isLast(){return!this.current||!this.current.next}next(e){if(e){if(!this.current)return this.first=p({value:this.transform(e)}),this.current=this.first,this.current.value;const t=p({value:this.transform(e),prev:this.current});return this.current.next=t,this.current=t,this.current.value}return this.current&&this.current.next?(this.current=this.current.next,this.current.value):null}}const h=g.get("global-classes"),y="globalClasses",f=(0,s.__createSlice)({name:y,initialState:{data:{items:{},order:[]},initialData:{frontend:{items:{},order:[]},preview:{items:{},order:[]}},isDirty:!1},reducers:{load(e,{payload:{frontend:t,preview:n}}){e.initialData.frontend=t,e.initialData.preview=n,e.data=n,e.isDirty=!1},add(e,{payload:t}){h.next(e.data),e.data.items[t.id]=t,e.data.order.unshift(t.id),e.isDirty=!0},delete(e,{payload:t}){h.next(e.data),e.data.items=Object.fromEntries(Object.entries(e.data.items).filter(([e])=>e!==t)),e.data.order=e.data.order.filter(e=>e!==t),e.isDirty=!0},setOrder(e,{payload:t}){h.next(e.data),e.data.order=t,e.isDirty=!0},update(e,{payload:t}){h.next(e.data);const n={...e.data.items[t.style.id],...t.style};e.data.items[t.style.id]=n,e.isDirty=!0},updateMultiple(e,{payload:t}){h.next(e.data),Object.entries(t).forEach(([t,{modified:n}])=>{e.data.items[t].label=n}),e.isDirty=!1},updateProps(e,{payload:t}){const n=e.data.items[t.id];if(!n)throw new d({context:{styleId:t.id}});h.next(e.data);const r=(0,a.getVariantByMeta)(n,t.meta);let s=("custom_css"in t?t.custom_css:r?.custom_css)??null;if(s=s?.raw?s:null,r){const e=JSON.parse(JSON.stringify(r.props)),a=JSON.parse(JSON.stringify(t.props));r.props=b(e,a),r.custom_css=s,n.variants=v(n)}else n.variants.push({meta:t.meta,props:t.props,custom_css:s});e.isDirty=!0},reset(e,{payload:{context:t}}){"frontend"===t&&(h.reset(),e.initialData.frontend=e.data,e.isDirty=!1),e.initialData.preview=e.data},undo(e){h.isLast()&&h.next(e.data);const t=h.prev();t?(e.data=t,e.isDirty=!0):e.data=e.initialData.preview},resetToInitialState(e,{payload:{context:t}}){h.reset(),e.data=e.initialData[t],e.isDirty=!1},redo(e){const t=h.next();h.isLast()&&h.prev(),t&&(e.data=t,e.isDirty=!0)}}}),b=(e,t)=>{const n=Array.isArray(e)?{}:e;return Object.entries(t).forEach(([e,t])=>{null==t?delete n[e]:n[e]=t}),n},v=e=>e.variants.filter(({props:e,custom_css:t})=>Object.keys(e).length||t?.raw),E=e=>e[y].data,w=e=>e[y].initialData.frontend,_=e=>e[y].initialData.preview,x=(0,s.__createSelector)(E,({order:e})=>e),C=(0,s.__createSelector)(E,({items:e})=>e),S=e=>e[y].isDirty,I=(0,s.__createSelector)(C,x,(e,t)=>t.map(t=>e[t])),D=(e,t)=>e[y].data.items[t]??null,T=(0,s.__createSelector)(E,({items:e})=>Object.values(e).filter(e=>0===e.variants.length));var P=window.elementorV2.mixpanel,k=window.elementorV2.httpClient;const O="/global-classes",A="elementor/v1",M=`${O}/usage`,z={usage:()=>(0,k.httpService)().get(`${A}${M}`),all:(e="preview")=>(0,k.httpService)().get(`${A}${O}`,{params:{context:e}}),publish:e=>(0,k.httpService)().put("elementor/v1"+O,e,{params:{context:"frontend"}}),saveDraft:e=>(0,k.httpService)().put("elementor/v1"+O,e,{params:{context:"preview"}})},L={DUPLICATED_LABEL:"DUPLICATED_LABEL"},j=async()=>{const e=await z.usage();return t=e?.data?.data||{},Object.entries(t).reduce((e,[t,n])=>(e[t]={content:n||[],total:n.reduce((e,t)=>e+(t?.total||0),0)},e),{});var t},B=async e=>{const{runAction:t}=e,n=await F(e);n&&(W(n),"classCreated"===n.event&&"classId"in n&&V(n.classId)),t?.()},V=async e=>{const t=await N(e);W({event:"classApplied",classId:e,...t,totalInstancesAfterApply:1})},F=async e=>{switch(e.event){case"classApplied":if("classId"in e&&e.classId){const t=await N(e.classId);return{...e,...t}}break;case"classRemoved":if("classId"in e&&e.classId){const t=q(e.classId);return{...e,...t}}break;case"classDeleted":if("classId"in e&&e.classId){const t=await $(e.classId);return{...e,...t}}break;case"classCreated":return"source"in e&&"created"!==e.source&&"classId"in e&&e.classId?{...e,classTitle:U(e.classId).label}:e;case"classStateClicked":if("classId"in e&&e.classId)return{...e,classTitle:U(e.classId).label};break;default:return e}},W=e=>{const{dispatchEvent:t,config:n}=(0,P.getMixpanel)();if(!n?.names?.global_classes?.[e.event])return void console.error("Global class tracking event not found",{event:e.event});const a=n.names.global_classes[e.event],{event:r,...s}=e;try{t?.(a,{event:r,...s})}catch(e){throw new m({cause:e})}},R=e=>({classTitle:U(e).label}),U=e=>{const t=D((0,s.__getState)(),e);if(!t)throw new Error(`CSS class with ID ${e} not found`);return t},$=async e=>({totalInstances:await G(e),classTitle:U(e).label}),G=async e=>{const t=await j();return t[e]?.total??1},N=async e=>{const{classTitle:t}=R(e);return{classTitle:t,totalInstancesAfterApply:await G(e)+1}},q=e=>{const{classTitle:t}=R(e);return{classTitle:t}},H="global-classes",Y=(0,r.createStylesProvider)({key:H,priority:30,limit:100,labels:{singular:(0,l.__)("class","elementor"),plural:(0,l.__)("classes","elementor")},subscribe:e=>J(e),capabilities:(()=>{if((0,o.isExperimentActive)("global_classes_should_enforce_capabilities"))return{update:i,create:i,delete:i,updateProps:i}})(),actions:{all:()=>{const e=I((0,s.__getState)());return localStorage.setItem("elementor-global-classes",JSON.stringify(e)),e},get:e=>D((0,s.__getState)(),e),resolveCssName:e=>D((0,s.__getState)(),e)?.label??e,create:(e,t=[])=>{const n=C((0,s.__getState)());if(Object.values(n).map(e=>e.label).includes(e))throw new u({context:{label:e}});const r=Object.keys(n),l=(0,a.generateId)("g-",r);return(0,s.__dispatch)(f.actions.add({id:l,type:"class",label:e,variants:t})),l},update:e=>{(0,s.__dispatch)(f.actions.update({style:e}))},delete:e=>{(0,s.__dispatch)(f.actions.delete(e))},updateProps:e=>{(0,s.__dispatch)(f.actions.updateProps({id:e.id,meta:e.meta,props:e.props}))},updateCustomCss:e=>{(0,s.__dispatch)(f.actions.updateProps({id:e.id,meta:e.meta,custom_css:e.custom_css,props:{}}))},tracking:e=>{B(e).catch(e=>{throw new m({cause:e})})}}}),J=e=>{let t=E((0,s.__getState)());return(0,s.__subscribeWithSelector)(e=>e.globalClasses,n=>{e(t.items,n.data.items),t=n.data})},K="elementor://global-classes";var Q=window.elementorV2.editor,X=window.elementorV2.editorEditingPanel,Z=window.elementorV2.editorPanels,ee=window.React,te=window.elementorV2.editorDocuments,ne=window.elementorV2.editorUi,ae=window.elementorV2.ui,re=window.elementorV2.query;const se="css-classes-usage";function le(){const e=(0,re.useQueryClient)();return{prefetchClassesUsage:()=>e.prefetchQuery({queryKey:[se],queryFn:j})}}const oe=()=>{const{prefetchClassesUsage:e}=le();return e(),null};var ie=window.elementorV2.icons;const ce=()=>(0,s.__useSelector)(x),de=()=>(0,s.__useSelector)(S),ue=(0,ee.createContext)(void 0),me={empty:!1,onThisPage:!1,unused:!1},pe=({children:e})=>{const[t,n]=ee.useState(me),{debouncedValue:a,inputValue:r,handleChange:s}=(0,c.useDebounceState)({delay:300,initialValue:(()=>{const e=localStorage.getItem("elementor-global-classes-search");return e?(localStorage.removeItem("elementor-global-classes-search"),e):""})()});return ee.createElement(ue.Provider,{value:{search:{debouncedValue:a,inputValue:r,handleChange:s,onClearSearch:()=>{s("")}},filters:{filters:t,setFilters:n,onClearFilter:()=>{n(me)}}}},e)},ge=()=>{const e=(0,ee.useContext)(ue);if(!e)throw new Error("useSearchContext must be used within a SearchContextProvider");return e},he=()=>(0,re.useQuery)({queryKey:[se],queryFn:j,refetchOnMount:!1,refetchOnWindowFocus:!0}),ye={empty:[],onThisPage:[],unused:[]},fe=()=>{const e=(0,te.__useActiveDocument)(),t=(0,s.__useSelector)(T),{data:n,isLoading:a}=he(),r=(()=>{const e=(0,s.__useSelector)(C);return Object.keys(e)})(),l=(0,ee.useMemo)(()=>t.map(({id:e})=>e),[t]),o=(0,ee.useMemo)(()=>n&&e?((e,t)=>{const n=[];for(const a in e)e[a].content.forEach(e=>{+e.pageId===t&&n.push(a)});return n})(n,e.id):[],[n,e]),i=(0,ee.useMemo)(()=>n?((e,t)=>{const n=new Set(e);return t.filter(e=>!n.has(e))})(Object.keys(n),r):[],[n,r]);return!a&&n&&e?{onThisPage:o,unused:i,empty:l}:ye},be=()=>{const{filters:{filters:e}}=ge(),t=fe();return(0,ee.useMemo)(()=>{const n=Object.entries(e).filter(([,e])=>e);return 0===n.length?null:n.reduce((e,[n],a)=>{const r=t[n]||[];return 0===a?r:e.filter(e=>r.includes(e))},[])},[e,t])},ve="DUP_",Ee=({modifiedLabels:e,onApprove:t})=>ee.createElement(ee.Fragment,null,ee.createElement(ae.DialogHeader,{logo:!1},ee.createElement(ae.Box,{display:"flex",alignItems:"center",gap:1},ee.createElement(ae.Icon,{color:"secondary"},ee.createElement(ie.InfoCircleFilledIcon,{fontSize:"medium"})),ee.createElement(ae.Typography,{variant:"subtitle1"},(0,l.__)("We've published your page and updated class names.","elementor")))),ee.createElement(ae.DialogContent,null,ee.createElement(ae.Stack,{spacing:2,direction:"column"},ee.createElement(ae.Typography,{variant:"body2"},(0,l.__)("Some new classes used the same names as existing ones. To prevent conflicts, we added the prefix","elementor"),ee.createElement("strong",null," ",ve)),ee.createElement(ae.Box,null,ee.createElement(ae.Box,{sx:{width:"100%",display:"flex",gap:2,alignItems:"flex-start"}},ee.createElement(ae.Typography,{variant:"subtitle2",sx:{fontWeight:"bold",flex:1,flexShrink:1,flexGrow:1,minWidth:0}},(0,l.__)("Before","elementor")),ee.createElement(ae.Typography,{variant:"subtitle2",sx:{minWidth:"200px",fontWeight:"bold",flexShrink:0,flexGrow:0,width:"200px",maxWidth:"200px"}},(0,l.__)("After","elementor"))),ee.createElement(ae.Divider,{sx:{mt:.5,mb:.5}}),ee.createElement(ae.Stack,{direction:"column",gap:.5,sx:{pb:2}},Object.values(e).map(({original:e,modified:t},n)=>ee.createElement(ae.Box,{key:n,sx:{width:"100%",display:"flex",gap:2,alignItems:"flex-start"}},ee.createElement(ae.Box,{sx:{flex:1,flexShrink:1,flexGrow:1,minWidth:0}},ee.createElement(ne.EllipsisWithTooltip,{title:e},ee.createElement(ae.Typography,{variant:"body2",sx:{color:"text.secondary"}},e))),ee.createElement(ae.Box,{sx:{minWidth:"200px",flexShrink:0,flexGrow:0,width:"200px",maxWidth:"200px"}},ee.createElement(ne.EllipsisWithTooltip,{title:t},ee.createElement(ae.Typography,{variant:"body2",sx:{color:"text.primary"}},t)))))),ee.createElement(ae.Box,null,ee.createElement(ae.Alert,{severity:"info",size:"small",color:"secondary"},ee.createElement("strong",null,(0,l.__)("Your designs and classes are safe.","elementor")),(0,l.__)("Only the prefixes were added. Find them in Class Manager by searching","elementor"),ee.createElement("strong",null,ve)))))),ee.createElement(ae.DialogActions,null,ee.createElement(ae.Button,{color:"secondary",variant:"text",onClick:()=>{localStorage.setItem("elementor-global-classes-search",ve),t?.(),(0,ne.closeDialog)()}},(0,l.__)("Go to Class Manager","elementor")),ee.createElement(ae.Button,{color:"secondary",variant:"contained",onClick:ne.closeDialog},(0,l.__)("Done","elementor"))));async function we({context:e,onApprove:t}){const n=E((0,s.__getState)()),a="preview"===e?z.saveDraft:z.publish,r="preview"===e?_:w,l=await a({items:n.items,order:n.order,changes:_e(n,r((0,s.__getState)()))});(0,s.__dispatch)(f.actions.reset({context:e})),l?.data?.data?.code===L.DUPLICATED_LABEL&&((0,s.__dispatch)(f.actions.updateMultiple(l.data.data.modifiedLabels)),B({event:"classPublishConflict",numOfConflicts:Object.keys(l.data.data.modifiedLabels).length}),(0,ne.openDialog)({component:ee.createElement(Ee,{modifiedLabels:l.data.data.modifiedLabels||[],onApprove:t})}))}function _e(e,t){const n=Object.keys(e.items),a=Object.keys(t.items);return{added:n.filter(e=>!a.includes(e)),deleted:a.filter(e=>!n.includes(e)),modified:n.filter(n=>n in t.items&&(0,c.hash)(e.items[n])!==(0,c.hash)(t.items[n]))}}const xe=({tooltipText:e,sx:t,trigger:n})=>{const{filters:{onClearFilter:a}}=ge();return ee.createElement(ae.Tooltip,{title:e,placement:"top",disableInteractive:!0},ee.createElement(ae.Box,null,ee.createElement(Ce,{"aria-label":e,size:"tiny",onClick:()=>{a(n),B({event:"classManagerFilterCleared",trigger:n})},sx:t},ee.createElement(ie.BrushBigIcon,{fontSize:"tiny"}))))},Ce=(0,ae.styled)(ae.IconButton)(({theme:e})=>({"&.Mui-disabled":{pointerEvents:"auto","&:hover":{color:e.palette.action.disabled}}})),Se={unused:(0,l.__)("Unused","elementor"),empty:(0,l.__)("Empty","elementor"),onThisPage:(0,l.__)("On this page","elementor")},Ie=()=>{const{filters:{filters:e,setFilters:t}}=ge(),n=fe(),a=n=>{t(e=>({...e,[n]:!e[n]})),B({event:"classManagerFilterUsed",action:e[n]?"remove":"apply",type:n,trigger:"menu"})};return ee.createElement(ae.MenuList,null,ee.createElement(ae.MenuItem,{onClick:()=>a("unused")},ee.createElement(De,{label:Se.unused,checked:e.unused,suffix:ee.createElement(ae.Chip,{size:"tiny",sx:{ml:"auto"},label:n.unused.length})})),ee.createElement(ae.MenuItem,{onClick:()=>a("empty")},ee.createElement(De,{label:Se.empty,checked:e.empty,suffix:ee.createElement(ae.Chip,{size:"tiny",sx:{ml:"auto"},label:n.empty.length})})),ee.createElement(ae.MenuItem,{onClick:()=>a("onThisPage")},ee.createElement(De,{label:Se.onThisPage,checked:e.onThisPage,suffix:ee.createElement(ae.Chip,{size:"tiny",sx:{ml:"auto"},label:n.onThisPage.length})})))},De=({label:e,suffix:t,checked:n})=>ee.createElement(ae.Stack,{direction:"row",alignItems:"center",gap:.5,flex:1},ee.createElement(ae.Checkbox,{size:"small",checked:n,sx:{padding:0,color:"text.tertiary","&.Mui-checked":{color:"text.tertiary"}}}),ee.createElement(ae.Typography,{variant:"caption",sx:{color:"text.secondary"}},e),t),Te=()=>{const{filters:{filters:e,setFilters:t}}=ge(),n=Object.keys(e).filter(t=>e[t]),a=n.length>0;return ee.createElement(ae.Stack,{direction:"row",alignItems:"center",justifyContent:"space-between"},ee.createElement(ae.Stack,{direction:"row",gap:.5,alignItems:"center",flexWrap:"wrap"},n.map(e=>ee.createElement(ae.Chip,{key:e,label:Se[e],onDelete:()=>(e=>{t(t=>({...t,[e]:!1})),B({event:"classManagerFilterUsed",action:"remove",type:e,trigger:"header"})})(e),sx:Pe,size:"tiny"}))),a&&ee.createElement(xe,{trigger:"header",tooltipText:(0,l.__)("Clear Filters","elementor"),sx:{margin:"0 0 auto auto"}}))},Pe={"& .MuiChip-deleteIcon":{display:"none",transition:"opacity 0.2s"},"&:hover .MuiChip-deleteIcon":{display:"block"}};function ke(){return ke=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},ke.apply(null,arguments)}const Oe=()=>{const{filters:{filters:e}}=ge(),t=(0,ae.usePopupState)({variant:"popover",disableAutoFocus:!0});ee.useEffect(()=>{t.isOpen&&B({event:"classManagerFiltersOpened"})},[t.isOpen]);const n=Object.values(e).some(e=>e);return ee.createElement(ee.Fragment,null,ee.createElement(ae.Tooltip,{title:(0,l.__)("Filters","elementor"),placement:"top"},ee.createElement(ae.ToggleButton,ke({value:"filter",size:"tiny",selected:t.isOpen},(0,ae.bindToggle)(t)),ee.createElement(ie.FilterIcon,{fontSize:"tiny"}))),ee.createElement(ae.Popover,ke({sx:{maxWidth:"344px"},anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:-21}},(0,ae.bindPopover)(t)),ee.createElement(ne.PopoverHeader,{actions:n?[ee.createElement(xe,{trigger:"menu",key:"clear-all-button",tooltipText:(0,l.__)("Clear all","elementor")})]:[],onClose:t.close,title:(0,l.__)("Filters","elementor"),icon:ee.createElement(ie.FilterIcon,{fontSize:"tiny"})}),ee.createElement(ae.Divider,{sx:{borderWidth:"1px 0 0 0"}}),ee.createElement(ne.PopoverBody,{width:344,height:125},ee.createElement(Ie,null))))},Ae=()=>{const{search:{inputValue:e,handleChange:t}}=ge();return ee.createElement(ae.Stack,{direction:"row",gap:.5,sx:{width:"100%"}},ee.createElement(ae.Box,{sx:{flexGrow:1}},ee.createElement(ae.TextField,{role:"search",fullWidth:!0,size:"tiny",value:e,onFocus:()=>{B({event:"classManagerSearched"})},placeholder:(0,l.__)("Search","elementor"),onChange:e=>t(e.target.value),InputProps:{startAdornment:ee.createElement(ae.InputAdornment,{position:"start"},ee.createElement(ie.SearchIcon,{fontSize:"tiny"}))}})))};var Me=window.elementorV2.editorCurrentUser;const ze=()=>{const[e,t]=(0,Me.useSuppressedMessage)("global-class-manager"),[n,a]=(0,ee.useState)(!e);return ee.createElement(ne.IntroductionModal,{open:n,title:(0,l.__)("Class Manager","elementor"),handleClose:e=>{e||t(),a(!1)}},ee.createElement(ae.Image,{sx:{width:"100%",aspectRatio:"16 / 9"},src:"https://assets.elementor.com/packages/v1/images/class-manager-intro.svg",alt:""}),ee.createElement(Le,null))},Le=()=>ee.createElement(ae.Box,{p:3},ee.createElement(ae.Typography,{variant:"body2"},(0,l.__)("The Class Manager lets you see all the classes you've created, plus adjust their priority, rename them, and delete unused classes to keep your CSS structured.","elementor")),ee.createElement("br",null),ee.createElement(ae.Typography,{variant:"body2"},(0,l.__)("Remember, when editing an item within a specific class, any changes you make will apply across all elements in that class.","elementor")));let je=!1;function Be(){return Be=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},Be.apply(null,arguments)}const Ve=({sx:e,...t})=>ee.createElement(ie.ColorSwatchIcon,Be({sx:{transform:"rotate(90deg)",...e}},t)),Fe=()=>(0,s.__useSelector)(I),We={total:0,content:[]},Re=e=>{const{data:t,...n}=he();return{...n,data:t?.[e]??We}},Ue={"wp-post":{label:(0,l.__)("Post","elementor"),icon:ee.createElement(ie.PostTypeIcon,{fontSize:"inherit"})},"wp-page":{label:(0,l.__)("Page","elementor"),icon:ee.createElement(ie.PagesIcon,{fontSize:"inherit"})},popup:{label:(0,l.__)("Popup","elementor"),icon:ee.createElement(ie.PopupTemplateIcon,{fontSize:"inherit"})},header:{label:(0,l.__)("Header","elementor"),icon:ee.createElement(ie.HeaderTemplateIcon,{fontSize:"inherit"})},footer:{label:(0,l.__)("Footer","elementor"),icon:ee.createElement(ie.FooterTemplateIcon,{fontSize:"inherit"})}},$e=({cssClassID:e,onClose:t})=>{const{data:n}=Re(e),a=(0,te.__useOpenDocumentInNewTab)(),r=n?.content.map(({title:e,elements:t,pageId:n,type:a})=>({type:"item",value:n,label:e,secondaryText:t.length.toString(),docType:a}))??[];return ee.createElement(ee.Fragment,null,ee.createElement(ne.PopoverHeader,{icon:ee.createElement(ie.CurrentLocationIcon,{fontSize:"tiny"}),title:ee.createElement(ae.Stack,{flexDirection:"row",gap:1,alignItems:"center"},ee.createElement(ae.Box,{"aria-label":"header-title"},(0,l.__)("Locator","elementor")),ee.createElement(ae.Box,null,ee.createElement(ae.Chip,{sx:{lineHeight:1},size:"tiny",label:n.total}))),onClose:t}),ee.createElement(ae.Divider,null),ee.createElement(ne.PopoverBody,{width:300},ee.createElement(ne.PopoverMenuList,{onSelect:t=>{a(+t),B({event:"classUsageLocate",classId:e})},items:r,onClose:()=>{},menuListTemplate:Ge,menuItemContentTemplate:e=>ee.createElement(ae.Stack,{flexDirection:"row",flex:1,alignItems:"center"},ee.createElement(ae.Box,{display:"flex",sx:{pr:1}},ee.createElement(ae.Tooltip,{disableInteractive:!0,title:Ue?.[e.docType]?.label??e.docType,placement:"top"},ee.createElement(ae.Icon,{fontSize:"small"},Ue?.[e.docType]?.icon||ee.createElement(ie.PagesIcon,{fontSize:"inherit"})))),ee.createElement(ae.Box,{sx:{pr:.5,maxWidth:"173px"},display:"flex"},ee.createElement(ne.EllipsisWithTooltip,{title:e.label,as:ae.Typography,variant:"caption",maxWidth:"173px",sx:{lineHeight:1}})),ee.createElement(ie.ExternalLinkIcon,{className:"hover-only-icon",fontSize:"tiny"}),ee.createElement(ae.Chip,{sx:{ml:"auto"},size:"tiny",label:e.secondaryText}))})))},Ge=(0,ae.styled)(ae.MenuList)(({theme:e})=>({"& > li":{display:"flex",cursor:"pointer",height:32,width:"100%"},'& > [role="option"]':{...e.typography.caption,lineHeight:"inherit",padding:e.spacing(.5,1,.5,2),textOverflow:"ellipsis",position:"absolute",top:0,left:0,opacity:1,".hover-only-icon":{color:e.palette.text.disabled,opacity:0},"&:hover":{borderRadius:e.spacing(.5),backgroundColor:e.palette.action.hover,".hover-only-icon":{color:e.palette.text.disabled,opacity:1}}},width:"100%",position:"relative"}));function Ne(){return Ne=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},Ne.apply(null,arguments)}const qe=({id:e,onClick:t})=>{const{data:{total:n},isLoading:a}=Re(e),r=(0,ae.usePopupState)({variant:"popover",popupId:"css-class-usage-popover"});if(a)return null;const s=0!==n?Ye:Je;return ee.createElement(ee.Fragment,null,ee.createElement(ae.Box,{position:"relative",onMouseEnter:()=>{B({event:"classUsageHovered",classId:e,usage:n})}},ee.createElement(s,{total:n},ee.createElement(He,Ne({disabled:0===n,size:"tiny"},(0,ae.bindTrigger)(r),{onClick:a=>{0!==n&&((0,ae.bindTrigger)(r).onClick(a),t(e),B({event:"classUsageClicked",classId:e}))}}),ee.createElement(ie.CurrentLocationIcon,{fontSize:"tiny"})))),ee.createElement(ae.Box,null,ee.createElement(ae.Popover,Ne({anchorOrigin:{vertical:"center",horizontal:"right"},transformOrigin:{vertical:15,horizontal:-50}},(0,ae.bindPopover)(r),{onClose:()=>{(0,ae.bindPopover)(r).onClose(),t("")}}),ee.createElement($e,{onClose:r.close,"aria-label":"css-class-usage-popover",cssClassID:e}))))},He=(0,ae.styled)(ae.IconButton)(({theme:e})=>({"&.Mui-disabled":{pointerEvents:"auto","&:hover":{color:e.palette.action.disabled}},height:"22px",width:"22px"})),Ye=({children:e,total:t})=>ee.createElement(ae.Tooltip,{disableInteractive:!0,placement:"top",title:`${(0,l.__)("Show {{number}} {{locations}}","elementor").replace("{{number}}",t.toString()).replace("{{locations}}",1===t?(0,l.__)("location","elementor"):(0,l.__)("locations","elementor"))}`},ee.createElement("span",null,e)),Je=({children:e})=>ee.createElement(ae.Infotip,{disableInteractive:!0,placement:"top",color:"secondary",content:ee.createElement(ne.InfoAlert,{sx:{mt:1}},(0,l.__)("This class isn’t being used yet.","elementor"))},ee.createElement("span",null,e)),Ke=(0,ee.createContext)(null),Qe=({children:e})=>{const[t,n]=(0,ee.useState)(null);return ee.createElement(Ke.Provider,{value:{openDialog:e=>{n(e)},closeDialog:()=>{n(null)},dialogProps:t}},e,!!t&&ee.createElement(Xe,t))},Xe=({label:e,id:t})=>{const{closeDialog:n}=Ze(),{data:{total:a,content:r}}=Re(t),o=a&&r.length?(0,l.__)("Will permanently remove it from your project and may affect the design across all elements using it. Used %1 times across %2 pages. This action cannot be undone.","elementor").replace("%1",a.toString()).replace("%2",r.length.toString()):(0,l.__)("Will permanently remove it from your project and may affect the design across all elements using it. This action cannot be undone.","elementor");return ee.createElement(ne.ConfirmationDialog,{open:!0,onClose:n},ee.createElement(ne.ConfirmationDialog.Title,null,(0,l.__)("Delete this class?","elementor")),ee.createElement(ne.ConfirmationDialog.Content,null,ee.createElement(ne.ConfirmationDialog.ContentText,null,(0,l.__)("Deleting","elementor"),ee.createElement(ae.Typography,{variant:"subtitle2",component:"span"}," ",e," "),o)),ee.createElement(ne.ConfirmationDialog.Actions,{onClose:n,onConfirm:()=>{n(),(e=>{B({event:"classDeleted",classId:e,runAction:()=>{(0,s.__dispatch)(f.actions.delete(e)),je=!0}})})(t)}}))},Ze=()=>{const e=(0,ee.useContext)(Ke);if(!e)throw new Error("useDeleteConfirmation must be used within a DeleteConfirmationProvider");return e};function et(){return et=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},et.apply(null,arguments)}const tt=e=>ee.createElement(ae.UnstableSortableProvider,et({restrictAxis:!0,variant:"static",dragPlaceholderStyle:{opacity:"1"}},e)),nt=e=>ee.createElement(rt,et({},e,{role:"button",className:"class-item-sortable-trigger","aria-label":"sort"}),ee.createElement(ie.GripVerticalIcon,{fontSize:"tiny"})),at=({children:e,id:t,...n})=>ee.createElement(ae.UnstableSortableItem,et({},n,{id:t,render:({itemProps:t,isDragged:n,triggerProps:a,itemStyle:r,triggerStyle:s,dropIndicationStyle:l,showDropIndication:o,isDragOverlay:i,isDragPlaceholder:c})=>ee.createElement(ae.Box,et({},t,{style:r,component:"li",role:"listitem",sx:{backgroundColor:i?"background.paper":void 0}}),e({itemProps:t,isDragged:n,triggerProps:a,itemStyle:r,triggerStyle:s,isDragPlaceholder:c}),o&&ee.createElement(st,{style:l}))})),rt=(0,ae.styled)("div")(({theme:e})=>({position:"absolute",left:0,top:"50%",transform:`translate( -${e.spacing(1.5)}, -50% )`,color:e.palette.action.active})),st=(0,ae.styled)(ae.Box)` | |
| 5 | 2 | width: 100%; |
| 6 | 3 | height: 1px; |
| 7 | 4 | background-color: ${({theme:e})=>e.palette.text.primary}; |
| 8 | -`,ClassItem=({id:e,label:t,renameClass:n,selected:r,disabled:i,sortableTriggerProps:a,showSortIndicator:o,syncToV3:s,onToggleSync:c})=>{let l=(0,Dt.useRef)(null),{ref:u,openEditMode:d,isEditing:f,error:p,getProps:m}=(0,N.useEditable)({value:t,onSubmit:n,validation:validateLabel}),[h,ee]=(0,Dt.useState)(``),{openDialog:te}=useDeleteConfirmation(),g=(0,P.usePopupState)({variant:`popover`,disableAutoFocus:!0}),_=(h===e||r||g.isOpen)&&!i;return M.createElement(M.Fragment,null,M.createElement(P.Stack,{p:0},M.createElement(N.WarningInfotip,{open:!!p,text:p??``,placement:`bottom`,width:l.current?.getBoundingClientRect().width,offset:[0,-15]},M.createElement(Xt,{ref:l,dense:!0,disableGutters:!0,showSortIndicator:o,showActions:_||f,shape:`rounded`,onDoubleClick:d,selected:_,disabled:i,focusVisibleClassName:`visible-class-item`},M.createElement(SortableTrigger,{...a}),M.createElement(Zt,{isActive:f,isError:!!p},f?M.createElement(N.EditableField,{ref:u,as:P.Typography,variant:`caption`,...m()}):M.createElement(N.EllipsisWithTooltip,{title:t,as:P.Typography,variant:`caption`})),M.createElement(P.Box,{className:`class-item-locator`},M.createElement(CssClassUsageTrigger,{id:e,onClick:ee})),M.createElement(P.Tooltip,{placement:`top`,className:`class-item-more-actions`,title:(0,At.__)(`More actions`,`elementor`)},M.createElement(P.IconButton,{size:`tiny`,...(0,P.bindTrigger)(g),"aria-label":`More actions`},M.createElement(kt.DotsVerticalIcon,{fontSize:`tiny`})))))),M.createElement(P.Menu,{...(0,P.bindMenu)(g),anchorOrigin:{vertical:`bottom`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:`right`}},M.createElement(N.MenuListItem,{sx:{minWidth:`160px`},onClick:()=>{g.close(),d()}},M.createElement(P.Typography,{variant:`caption`,sx:{color:`text.primary`}},(0,At.__)(`Rename`,`elementor`))),c&&M.createElement(N.MenuListItem,{onClick:()=>{g.close(),c(e,!s)}},M.createElement(P.Stack,{direction:`row`,alignItems:`center`,gap:1},s?M.createElement(kt.RefreshOffIcon,{fontSize:`tiny`}):M.createElement(kt.RefreshIcon,{fontSize:`tiny`}),M.createElement(P.Typography,{variant:`caption`,sx:{color:`text.primary`}},s?(0,At.__)(`Stop syncing to Global Fonts`,`elementor`):(0,At.__)(`Sync to Global Fonts`,`elementor`)))),M.createElement(N.MenuListItem,{onClick:()=>{g.close(),te({id:e,label:t})}},M.createElement(P.Typography,{variant:`caption`,sx:{color:`error.light`}},(0,At.__)(`Delete`,`elementor`)))))},Xt=(0,P.styled)(P.ListItemButton,{shouldForwardProp:e=>![`showActions`,`showSortIndicator`].includes(e)})(({showActions:e,showSortIndicator:t})=>` | |
| 9 | - min-height: 36px; | |
| 10 | - | |
| 11 | - &.visible-class-item { | |
| 12 | - box-shadow: none !important; | |
| 13 | - } | |
| 14 | - | |
| 15 | - .class-item-locator { | |
| 16 | - visibility: hidden; | |
| 17 | - } | |
| 18 | - | |
| 19 | - .class-item-sortable-trigger { | |
| 20 | - visibility: ${t&&e?`visible`:`hidden`}; | |
| 21 | - } | |
| 22 | - | |
| 23 | - &:hover:not(:disabled) { | |
| 24 | - .class-item-locator { | |
| 25 | - visibility: visible; | |
| 26 | - } | |
| 27 | - | |
| 28 | - .class-item-sortable-trigger { | |
| 29 | - visibility: ${t?`visible`:`hidden`}; | |
| 30 | - } | |
| 31 | - } | |
| 32 | - `),Zt=(0,P.styled)(P.Box,{shouldForwardProp:e=>![`isActive`,`isError`].includes(e)})(({theme:e,isActive:t,isError:n})=>({display:`flex`,width:`100%`,flexGrow:1,borderRadius:e.spacing(.5),border:getIndicatorBorder({isActive:t,isError:n,theme:e}),padding:`0 ${e.spacing(1)}`,marginLeft:t?e.spacing(1):0,minWidth:0})),getIndicatorBorder=({isActive:e,isError:t,theme:n})=>t?`2px solid ${n.palette.error.main}`:e?`2px solid ${n.palette.secondary.main}`:`none`,validateLabel=e=>{let t=(0,Ot.validateStyleLabel)(e,`rename`);return t.isValid?null:t.errorMessage},H=__toESM(globalThis.React),Qt=globalThis.elementorV2.icons,U=globalThis.elementorV2.ui,W=globalThis.wp.i18n,getNotFoundType=(e,t,n)=>{let r=n.length<=0&&e.length>1,i=t&&t.length===0;if(r&&i)return`filterAndSearch`;if(r)return`search`;if(i)return`filter`},$t={filterAndSearch:{mainText:(0,W.__)(`Sorry, nothing matched.`,`elementor`),sceneryText:(0,W.__)(`Try something else.`,`elementor`),icon:H.createElement(Qt.PhotoIcon,{color:`inherit`,fontSize:`large`})},search:{mainText:(0,W.__)(`Sorry, nothing matched`,`elementor`),sceneryText:(0,W.__)(`Clear your input and try something else.`,`elementor`),icon:H.createElement(Qt.PhotoIcon,{color:`inherit`,fontSize:`large`})},filter:{mainText:(0,W.__)(`Sorry, nothing matched that search.`,`elementor`),sceneryText:(0,W.__)(`Clear the filters and try something else.`,`elementor`),icon:H.createElement(Qt.ColorSwatchIcon,{color:`inherit`,fontSize:`large`})}},NotFound=({notFoundType:e})=>{let{search:{onClearSearch:t,inputValue:n},filters:{onClearFilter:r}}=useSearchAndFilters();switch(e){case`filter`:return H.createElement(NotFoundLayout,{...$t.filter,onClear:r});case`search`:return H.createElement(NotFoundLayout,{...$t.search,searchValue:n,onClear:t});case`filterAndSearch`:return H.createElement(NotFoundLayout,{...$t.filterAndSearch,onClear:()=>{r(),t()}})}},NotFoundLayout=({onClear:e,searchValue:t,mainText:n,sceneryText:r,icon:i})=>H.createElement(U.Stack,{color:`text.secondary`,pt:5,alignItems:`center`,gap:1,overflow:`hidden`,justifySelf:`center`},i,H.createElement(U.Box,{sx:{width:`100%`}},H.createElement(U.Typography,{align:`center`,variant:`subtitle2`,color:`inherit`},n),t&&H.createElement(U.Typography,{variant:`subtitle2`,color:`inherit`,sx:{display:`flex`,width:`100%`,justifyContent:`center`}},H.createElement(`span`,null,`“`),H.createElement(`span`,{style:{maxWidth:`80%`,overflow:`hidden`,textOverflow:`ellipsis`}},t),H.createElement(`span`,null,`”.`))),H.createElement(U.Typography,{align:`center`,variant:`caption`,color:`inherit`},r),H.createElement(U.Typography,{align:`center`,variant:`caption`,color:`inherit`},H.createElement(U.Link,{color:`secondary`,variant:`caption`,component:`button`,onClick:e},(0,W.__)(`Clear & try again`,`elementor`)))),en=40,tn=6,GlobalClassesList=({disabled:e,scrollElement:t,onStopSyncRequest:n,onStartSyncRequest:r})=>{let{search:{debouncedValue:i}}=useSearchAndFilters(),a=useOrderedClasses(),o=(0,St.__useDispatch)(),s=useFilters(),[c,l]=(0,xt.useState)(null),[u,d]=(0,xt.useState)({}),addLoadingClass=e=>d(t=>({...t,[e]:!0})),removeLoadingClass=e=>d(t=>{let{[e]:n,...r}=t;return r}),[f,p]=useReorder(c,l,a.find(e=>e.id===c)?.label??``??``),m=useFilteredCssClasses(),h=(0,wt.useVirtualizer)({count:m.length,getScrollElement:()=>t??null,estimateSize:()=>en,overscan:tn,getItemKey:e=>m[e].id,rangeExtractor:e=>{let t=new Set((0,wt.defaultRangeExtractor)(e));if(c){let e=m.findIndex(e=>e.id===c);e>=0&&t.add(e)}return[...t].sort((e,t)=>e-t)}});if((0,xt.useEffect)(()=>{let handler=e=>{if(e.key===`z`&&(e.ctrlKey||e.metaKey)){if(e.stopImmediatePropagation(),e.preventDefault(),e.shiftKey){o(x.actions.redo());return}o(x.actions.undo())}};return window.addEventListener(`keydown`,handler,{capture:!0}),()=>window.removeEventListener(`keydown`,handler)},[o]),!a?.length)return j.createElement(EmptyState,null);let ee=getNotFoundType(i,s,m);if(ee)return j.createElement(NotFound,{notFoundType:ee});let te=s?.length||i,g=m.length>1&&!te;return j.createElement(DeleteConfirmationProvider,null,j.createElement(Ct.List,{sx:{position:`relative`,display:`block`,height:h.getTotalSize(),padding:0}},j.createElement(SortableProvider,{value:f,onChange:p,onDragStart:e=>l(e.active.id),onDragEnd:()=>l(null),onDragCancel:()=>l(null),disableDragOverlay:!g},h.getVirtualItems().map(t=>{let i=m[t.index];return j.createElement(SortableItem,{key:t.key,id:i.id,style:{position:`absolute`,top:t.start,left:0,width:`100%`}},({isDragged:t,isDragPlaceholder:a,triggerProps:s,triggerStyle:c})=>j.createElement(ClassItem,{id:i.id,label:i.label,renameClass:async e=>{addLoadingClass(i.id);try{trackGlobalClasses({event:`classRenamed`,classId:i.id,oldValue:i.label,newValue:e,source:`class-manager`}),await loadExistingClasses([i.id]),o(x.actions.update({style:{id:i.id,label:e}}))}finally{removeLoadingClass(i.id)}},selected:t,disabled:e||a||u[i.id],sortableTriggerProps:{...s,style:c},showSortIndicator:g,syncToV3:i.sync_to_v3,onToggleSync:(e,t)=>{!t&&n?n(e):t&&r?r(e):o(x.actions.update({style:{id:e,sync_to_v3:t}}))}}))}))))},EmptyState=()=>j.createElement(Ct.Stack,{alignItems:`center`,gap:1.5,pt:10,px:.5,maxWidth:`260px`,margin:`auto`},j.createElement(FlippedColorSwatchIcon,{fontSize:`large`}),j.createElement(nn,{variant:`subtitle2`,component:`h2`,color:`text.secondary`},(0,Tt.__)(`There are no global classes yet.`,`elementor`)),j.createElement(Ct.Typography,{align:`center`,variant:`caption`,color:`text.secondary`},(0,Tt.__)(`CSS classes created in the editor panel will appear here. Once they are available, you can arrange their hierarchy, rename them, or delete them as needed.`,`elementor`))),nn=(0,Ct.styled)(Ct.Typography)(({theme:e,variant:t})=>({"&.MuiTypography-root":{...e.typography[t]}})),useReorder=(e,t,n)=>{let r=(0,St.__useDispatch)(),i=useClassesOrder(),reorder=i=>{r(x.actions.setOrder(i)),e&&(trackGlobalClasses({event:`classManagerReorder`,classId:e,classTitle:n}),t(null))};return[i,reorder]},useFilteredCssClasses=()=>{let e=useOrderedClasses(),{search:{debouncedValue:t}}=useSearchAndFilters(),n=useFilters(),r=(0,xt.useMemo)(()=>e.map(e=>({...e,lowerLabel:e.label.toLowerCase()})),[e]),i=(0,xt.useMemo)(()=>{let n=t.replace(/[^a-zA-Z0-9_-]/g,``).toLowerCase();return n.length>1?r.filter(e=>e.lowerLabel.includes(n)):e},[t,e,r]);return(0,xt.useMemo)(()=>n&&n.length>0?i.filter(e=>n.includes(e.id)):i,[i,n])};function blockPanelInteractions(){window.$e?.components?.get?.(`panel`)?.blockUserInteractions?.()}function unblockPanelInteractions(){window.$e?.components?.get?.(`panel`)?.unblockUserInteractions?.()}var G=__toESM(globalThis.React),rn=globalThis.React,K=globalThis.elementorV2.ui,an=globalThis.wp.i18n,on=`https://assets.elementor.com/packages/v1/images/class-manager-sync-modal.png`,StartSyncToV3Modal=({externalOpen:e,classId:t,onExternalClose:n,onConfirm:r}={})=>{let[i,a]=(0,rn.useState)(!0),o=(0,rn.useRef)(!1);(0,rn.useEffect)(()=>{e&&t&&!o.current&&(o.current=!0,trackGlobalClasses({event:`classSyncToV3PopupShown`,classId:t})),e||(o.current=!1)},[e,t]);let handleClose=()=>{t&&trackGlobalClasses({event:`classSyncToV3PopupClick`,classId:t,action:`cancel`}),n?.()},handleConfirm=()=>{t&&trackGlobalClasses({event:`classSyncToV3PopupClick`,classId:t,action:`sync`}),r?.(),n?.()};return G.createElement(K.Dialog,{open:!!e,onClose:handleClose,maxWidth:`sm`,fullWidth:!0},G.createElement(K.DialogContent,{sx:{p:0}},G.createElement(K.Box,{component:`img`,src:on,alt:``,sx:{width:`100%`,display:`block`}}),G.createElement(K.Box,{sx:{px:3,pt:4,pb:1}},G.createElement(K.Typography,{variant:`h6`},(0,an.__)(`Sync class to Global Fonts`,`elementor`)),G.createElement(K.Typography,{variant:`body2`,color:`secondary`,sx:{mb:2,pt:1}},(0,an.__)(`Only typography settings supported in Global Fonts will be applied, including: font family, responsive font sizes, weight, text transform, decoration, line height, letter spacing, and word spacing. Changes made in the class will automatically apply to Global Fonts.`,`elementor`)))),G.createElement(K.DialogActions,{sx:{justifyContent:`space-between`,px:3,pb:2}},G.createElement(K.FormControlLabel,{control:G.createElement(K.Checkbox,{checked:!i,onChange:e=>a(!e.target.checked)}),label:G.createElement(K.Typography,{variant:`body2`,color:`secondary`},(0,an.__)(`Don't show again`,`elementor`))}),G.createElement(K.Box,{sx:{display:`flex`,gap:1}},G.createElement(K.Button,{onClick:handleClose,color:`secondary`,size:`small`},(0,an.__)(`Cancel`,`elementor`)),G.createElement(K.Button,{onClick:handleConfirm,variant:`contained`,size:`small`},(0,an.__)(`Sync to Global Fonts`,`elementor`)))))},sn=`stop-sync-class`;function ClassManagerPanelEmbedded({onRequestClose:e,onExposeCloseAttempt:t,isActive:n}){return u.createElement(ClassManagerPanelContent,{onRequestClose:e,onExposeCloseAttempt:t,isActive:n})}function ClassManagerPanelContent({onRequestClose:e,onExposeCloseAttempt:t,isActive:n=!0}){let r=useDirtyState(),{open:i,close:a,isOpen:o}=(0,h.useDialog)(),[s,c]=(0,d.useState)(null),[l,p]=(0,d.useState)(null),[ee]=(0,f.useSuppressedMessage)(sn),[ne,re]=(0,d.useState)(null),{mutateAsync:v,isPending:ie}=usePublish(),resetAndClosePanel=()=>{(0,te.__dispatch)(x.actions.resetToInitialState({context:`frontend`})),a()},ae=(0,d.useCallback)(()=>{if(r){i();return}e()},[r,i,e]);(0,d.useEffect)(()=>{if(t)return t(()=>ae()),()=>t(null)},[t,ae]),(0,d.useEffect)(()=>(blockPanelInteractions(),()=>{unblockPanelInteractions()}),[]);let oe=(0,d.useCallback)(async e=>{await loadExistingClasses([e]),(0,te.__dispatch)(x.actions.update({style:{id:e,sync_to_v3:!1}})),trackGlobalClasses({event:`classSyncToV3`,classId:e,action:`unsync`}),c(null)},[]),se=(0,d.useCallback)(async e=>{await loadExistingClasses([e]),(0,te.__dispatch)(x.actions.update({style:{id:e,sync_to_v3:!0}})),trackGlobalClasses({event:`classSyncToV3`,classId:e,action:`sync`}),p(null)},[]),y=(0,d.useCallback)(e=>{ee?oe(e):c(e)},[ee,oe]);return usePreventUnload(),u.createElement(u.Fragment,null,u.createElement(g.ErrorBoundary,{fallback:u.createElement(ErrorBoundaryFallback,null)},u.createElement(SearchAndFilterProvider,null,u.createElement(g.Stack,{direction:`column`,sx:{height:`100%`,width:`100%`,flex:1,minHeight:0,overflow:`hidden`}},u.createElement(g.Box,{px:2,pb:1},u.createElement(g.Stack,{direction:`row`,alignItems:`center`,justifyContent:`space-between`,gap:.5,sx:{pb:.5}},u.createElement(g.Box,{sx:{flexGrow:1,minWidth:0}},u.createElement(ClassManagerSearch,null)),u.createElement(CssClassFilter,null),u.createElement(TotalCssClassCounter,null)),u.createElement(ActiveFilters,null)),u.createElement(g.Divider,null),u.createElement(g.Box,{ref:re,px:2,sx:{flexGrow:1,overflowY:`auto`,minHeight:0}},u.createElement(GlobalClassesList,{disabled:ie,scrollElement:ne,onStopSyncRequest:y,onStartSyncRequest:e=>p(e)})),u.createElement(m.PanelFooter,null,u.createElement(g.Button,{fullWidth:!0,size:`small`,color:`global`,variant:`contained`,onClick:v,disabled:!r,loading:ie},(0,_.__)(`Save changes`,`elementor`)))))),n&&u.createElement(ClassManagerIntroduction,null),l&&u.createElement(StartSyncToV3Modal,{externalOpen:!0,classId:l,onExternalClose:()=>p(null),onConfirm:()=>se(l)}),s&&u.createElement(StopSyncConfirmationDialog,{open:!0,onClose:()=>c(null),onConfirm:()=>oe(s)}),o&&u.createElement(h.SaveChangesDialog,null,u.createElement(g.DialogHeader,{onClose:a,logo:!1},u.createElement(h.SaveChangesDialog.Title,null,(0,_.__)(`You have unsaved changes`,`elementor`))),u.createElement(h.SaveChangesDialog.Content,null,u.createElement(h.SaveChangesDialog.ContentText,null,(0,_.__)(`You have unsaved changes in the Class Manager.`,`elementor`)),u.createElement(h.SaveChangesDialog.ContentText,null,(0,_.__)(`To avoid losing your updates, save your changes before leaving.`,`elementor`))),u.createElement(h.SaveChangesDialog.Actions,{actions:{discard:{label:(0,_.__)(`Discard`,`elementor`),action:()=>{resetAndClosePanel()}},confirm:{label:(0,_.__)(`Save & Continue`,`elementor`),action:async()=>{await v(),a(),e()}}}})))}var ErrorBoundaryFallback=()=>u.createElement(g.Box,{role:`alert`,sx:{minHeight:`100%`,p:2}},u.createElement(g.Alert,{severity:`error`,sx:{mb:2,maxWidth:400,textAlign:`center`}},u.createElement(`strong`,null,(0,_.__)(`Something went wrong`,`elementor`)))),usePreventUnload=()=>{let e=useDirtyState();(0,d.useEffect)(()=>{let handleBeforeUnload=t=>{e&&t.preventDefault()};return window.addEventListener(`beforeunload`,handleBeforeUnload),()=>{window.removeEventListener(`beforeunload`,handleBeforeUnload)}},[e])},usePublish=()=>(0,ee.useMutation)({mutationFn:()=>saveGlobalClasses2({context:`frontend`}),onSuccess:async()=>{(0,p.setDocumentModifiedStatus)(!1),hasDeletedItems()&&await onDelete()}}),TotalCssClassCounter=()=>{let e=useFilters(),t=useClassesOrder();return u.createElement(g.Chip,{size:`small`,label:e?`${e.length} / ${t?.length}`:t?.length})},StopSyncConfirmationDialog=({open:e,onClose:t,onConfirm:n})=>{let[,r]=(0,f.useSuppressedMessage)(sn);return u.createElement(h.ConfirmationDialog,{open:e,onClose:t},u.createElement(h.ConfirmationDialog.Title,{icon:FlippedColorSwatchIcon,iconColor:`primary`},(0,_.__)(`Un-sync typography class`,`elementor`)),u.createElement(h.ConfirmationDialog.Content,null,u.createElement(h.ConfirmationDialog.ContentText,null,(0,_.__)(`You're about to stop syncing a typography class to Global Fonts.`,`elementor`)),u.createElement(h.ConfirmationDialog.ContentText,{sx:{mt:1}},(0,_.__)(`Note that if it's being used anywhere, the affected elements will inherit the default typography.`,`elementor`))),u.createElement(h.ConfirmationDialog.Actions,{onClose:t,onConfirm:n,cancelLabel:(0,_.__)(`Cancel`,`elementor`),confirmLabel:(0,_.__)(`Got it`,`elementor`),color:`primary`,onSuppressMessage:r,suppressLabel:(0,_.__)(`Don't show again`,`elementor`)}))},cn=globalThis.elementorV2.store,ln=globalThis.elementorV2.editorStyles,un=globalThis.elementorV2.editorStylesRepository,q=globalThis.elementorV2.store,dn=globalThis.wp.i18n,fn=`elementor_global_classes_update_class`,getCapabilities=()=>({update:fn,create:fn,delete:fn,updateProps:fn}),pn=1e3,mn=`global-classes`,hn=/^global-([0-9]+-)?(preview|frontend)-[a-zA-Z_-]+-css$/,J=(0,un.createStylesProvider)({key:mn,priority:30,limit:pn,isPregeneratedLink:({id:e})=>hn.test(e),labels:{singular:(0,dn.__)(`class`,`elementor`),plural:(0,dn.__)(`classes`,`elementor`)},subscribe:e=>subscribeWithStates(e),capabilities:getCapabilities(),actions:{all:()=>de((0,q.__getState)()),get:e=>{let t=(0,q.__getState)(),n=selectIsClassFetched(t,e),r=selectClass(t,e);return n||r?r:(loadExistingClasses([e]),placeholderDefinition(e,selectClassLabels(t)[e]??e))},resolveCssName:e=>{let t=(0,q.__getState)(),n=selectClass(t,e);return n?n.label:selectClassLabels(t)[e]??e},create:(e,t=[],n)=>{let r=Object.entries(selectClassLabels((0,q.__getState)()));if(r.map(([,e])=>e).includes(e))throw new oe({context:{label:e}});let i=r.map(([e])=>e);return n||=(0,ln.generateId)(`g-`,i),(0,q.__dispatch)(x.actions.add({id:n,type:`class`,label:e,variants:t})),n},update:e=>{(0,q.__dispatch)(x.actions.update({style:e}))},delete:e=>{(0,q.__dispatch)(x.actions.delete(e))},updateProps:e=>{(0,q.__dispatch)(x.actions.updateProps({id:e.id,meta:e.meta,props:e.props,mode:e.mode}))},updateCustomCss:e=>{(0,q.__dispatch)(x.actions.updateProps({id:e.id,meta:e.meta,custom_css:e.custom_css,props:{}}))},tracking:e=>{trackGlobalClasses(e).catch(e=>{throw new se({cause:e})})}}}),subscribeWithStates=e=>{let t=selectData((0,q.__getState)());return(0,q.__subscribeWithSelector)(e=>selectData(e),n=>{e(t.items,n.items),t=n})},Y=`elementor://global-classes`,gn=`elementor-global-classes`,updateLocalStorageCache=()=>{let e=de((0,cn.__getState)());localStorage.setItem(gn,JSON.stringify(e))},initClassesResource=(e,t)=>{[t,e].forEach(e=>{let{sendResourceUpdated:t,resource:n,waitForReady:r}=e;n(`global-classes`,Y,{description:`Global classes list.`},async()=>({contents:[{uri:Y,text:localStorage[gn]??`[]`}]})),r().then(()=>{updateLocalStorageCache(),J.subscribe(()=>{updateLocalStorageCache(),t({uri:Y})})})})},_n=globalThis.elementorV2.editor,vn=globalThis.elementorV2.editorEditingPanel,yn=globalThis.elementorV2.editorEmbeddedDocumentsManager,bn=globalThis.elementorV2.editorMcp,xn=globalThis.elementorV2.editorStylesRepository,Sn=globalThis.elementorV2.store,Cn=__toESM(globalThis.React),wn=globalThis.elementorV2.editorStylesRepository,Tn=globalThis.elementorV2.ui,En=globalThis.wp.i18n,Dn=globalThis.elementorV2.query;function usePrefetchCssClassUsage(){let e=(0,Dn.useQueryClient)(),prefetchClassesUsage=()=>e.prefetchQuery({queryKey:[Ae],queryFn:fetchCssClassUsage});return{prefetchClassesUsage}}var PrefetchCssClassUsage=()=>{let{prefetchClassesUsage:e}=usePrefetchCssClassUsage();return e(),null},On=`elementor/toggle-design-system`,ClassManagerButton=()=>{let{prefetchClassesUsage:e}=usePrefetchCssClassUsage(),{userCan:t}=(0,wn.useUserStylesCapability)();if(!t(J.getKey()).update)return null;let handleOpenPanel=()=>{window.dispatchEvent(new CustomEvent(On,{detail:{tab:`classes`}})),trackGlobalClasses({event:`classManagerOpened`,source:`style-panel`}),e()};return Cn.createElement(Tn.Tooltip,{title:(0,En.__)(`Class Manager`,`elementor`),placement:`top`},Cn.createElement(Tn.IconButton,{size:`tiny`,onClick:handleOpenPanel,sx:{marginInlineEnd:-.75}},Cn.createElement(FlippedColorSwatchIcon,{fontSize:`tiny`})))},kn=__toESM(globalThis.React),An=globalThis.elementorV2.editorStylesRepository,jn=globalThis.elementorV2.editorUi,Mn=globalThis.elementorV2.ui,Nn=globalThis.wp.i18n,ConvertLocalClassToGlobalClass=e=>{let t=e.styleDef,handleConversion=()=>{let n=createClassName(`converted-class-`);if(!t)throw Error(`Style definition is required for converting local class to global class.`);let r=J.actions.create?.(n,t.variants);r&&(e.successCallback(r),trackGlobalClasses({classId:r,event:`classCreated`,source:`converted`,classTitle:n}))};return kn.createElement(kn.Fragment,null,kn.createElement(jn.MenuListItem,{disabled:!e.canConvert,onClick:handleConversion,dense:!0,sx:{"&.Mui-focusVisible":{border:`none`,boxShadow:`none !important`,backgroundColor:`transparent`}}},(0,Nn.__)(`Convert to global class`,`elementor`)),kn.createElement(Mn.Divider,null))};function createClassName(e){let t=1,n=`${e}${t}`;for(;!(0,An.validateStyleLabel)(n,`create`).isValid;)n=`${e}${++t}`;return n}var Pn=globalThis.React,Fn=globalThis.elementorV2.editorCanvas,In=globalThis.elementorV2.store;function GlobalStylesImportListener(){let e=(0,In.__useDispatch)();return(0,Pn.useEffect)(()=>{let handleGlobalStylesImported=async t=>{let n=t.detail?.global_classes;if(!n?.added_items_order||!n?.added_items||n?.added_items_order?.length===0){loadCurrentDocumentClasses();return}e(x.actions.updateAfterTemplateImport({addedItems:n.added_items,addedIdsOrder:n.added_items_order,addedClassLabels:createLabelsForClasses(Object.values(n.added_items))}))};return window.addEventListener(Fn.GLOBAL_STYLES_IMPORTED_EVENT,handleGlobalStylesImported),()=>{window.removeEventListener(Fn.GLOBAL_STYLES_IMPORTED_EVENT,handleGlobalStylesImported)}},[e]),null}var Ln=globalThis.React,Rn=globalThis.elementorV2.editorV1Adapters;function PopulateStore(){return(0,Ln.useEffect)(()=>{loadCurrentDocumentClasses(),(0,Rn.registerDataHook)(`after`,`editor/documents/attach-preview`,async()=>{await loadCurrentDocumentClasses()})},[]),null}var zn=globalThis.elementorV2.httpClient,X=globalThis.elementorV2.schema,Bn=globalThis.elementorV2.store,Vn=`elementor/v1/mcp-proxy`,Hn=`manage-classes`,initManageClassesTool=e=>{let{addTool:t}=e;t({name:Hn,description:`Manage V4 global CSS classes on the active kit. Bulk create, update, or delete using raw CSS declarations (up to 50 operations). Duplicate labels are auto-renamed with a DUP_ prefix.`,schema:{action:X.z.enum([`create`,`update`,`delete`]),id:X.z.string().optional().describe(`Class id — required for update/delete. Get from the global-classes resource.`),label:X.z.string().optional().describe(`Class label (lowercase, dash-separated) — required for create/update.`),css:X.z.string().optional().describe(`Plain CSS string. Supports &:hover/&:focus/&:active nesting and @media(--breakpoint) blocks. font-family must be a single Google Font name (no fallback stacks). In patch mode: "prop: null" removes that prop; "all: null" wipes the variant.`),mode:X.z.enum([`patch`,`replace`]).optional().describe(`Merge strategy for update — patch (default): merge incoming props with existing; replace: discard all existing variants for the affected breakpoints.`)},outputSchema:{status:X.z.enum([`ok`]).describe(`Operation status`),id:X.z.string().optional().describe(`ID of the affected class — use for subsequent update/delete calls.`),label:X.z.string().optional().describe(`Final label of the class after any auto-rename.`)},requiredResources:[{uri:Y,description:`Current global classes — check before creating to avoid duplicates`}],isDestructive:!0,handler:async e=>{let{data:t}=await(0,zn.httpService)().post(Vn,{tool:Hn,input:{operations:[e]}}),n=t.data.results?.[0],{create:r,update:i,delete:a}=J.actions;switch(e.action){case`create`:n&&r&&r(n.label,n.variants,n.id);break;case`update`:n&&i&&i(n);break;case`delete`:e.id&&a&&a(e.id);break}return(0,Bn.__dispatch)(x.actions.reset({context:`frontend`})),window.dispatchEvent(new CustomEvent(`classes:updated`,{detail:{context:`frontend`}})),{status:`ok`,id:n?.id,label:n?.label}}})},Un=globalThis.elementorV2.editorEditingPanel,Z=globalThis.elementorV2.schema,Wn=globalThis.elementorV2.editorMcp,Gn=`elementor://global-classes/tools/apply-global-class-guide`,generateApplyGlobalClassGuidePrompt=()=>{let e=(0,Wn.toolPrompts)(`apply-global-class`);return e.description(`Apply a global class to an element, enabling consistent styling through your design system.`),e.instruction(`## When to use this tool: | |
| 33 | -**ALWAYS use this IMMEDIATELY AFTER creating or updating elements** to apply the global classes you created beforehand: | |
| 34 | -- After adding elements to the canvas, apply semantic classes to them | |
| 35 | -- When applying consistent typography styles (heading-primary, text-body, etc.) | |
| 36 | -- When applying theme colors or brand styles (bg-brand, button-cta, etc.) | |
| 37 | -- When ensuring spacing consistency (spacing-section-large, etc.) | |
| 38 | - | |
| 39 | -**DO NOT use this tool** for: | |
| 40 | -- Elements that don't share styles with other elements (use inline styles instead) | |
| 41 | -- Layout-specific properties (those should remain inline in stylesConfig)`),e.instruction(`## Prerequisites: | |
| 42 | -- **REQUIRED**: Get the list of available global classes from 'elementor://global-classes' resource | |
| 43 | -- **REQUIRED**: Get element IDs from the page structure or selected element resources | |
| 44 | -- Ensure you have the most up-to-date list of classes applied to the element to avoid duplicates | |
| 45 | -- Make sure you have the correct class ID that you want to apply`),e.instruction(`## Best Practices: | |
| 46 | -1. Apply multiple classes to a single element if needed (typography + color + spacing) | |
| 47 | -2. After applying, the tool will remind you to remove duplicate inline styles from elementConfig | |
| 48 | -3. Classes should describe purpose, not implementation (e.g., "heading-primary" not "big-red-text")`),e.prompt()};function initMcpApplyUnapplyGlobalClasses(e){let{addTool:t,resource:n}=e,r=generateApplyGlobalClassGuidePrompt();n(`apply-global-class-guide`,Gn,{description:`Workflow, prerequisites, and best practices for apply-global-class`,mimeType:`text/plain`,title:`Apply global class tool guide`},async e=>({contents:[{mimeType:`text/plain`,text:r,uri:e.href}]})),t({schema:{classId:Z.z.string().describe(`The ID of the class to apply`),elementId:Z.z.string().describe(`The ID of the element to which the class will be applied`)},outputSchema:{result:Z.z.string().describe(`Result message indicating the success of the apply operation`),llm_instructions:Z.z.string().describe(`Instructions what to do next, Important to follow these instructions!`)},name:`apply-global-class`,description:`Apply a global class to an element for shared design-system styling. Read the full guide at [${Gn}].`,requiredResources:[{description:`Apply global class tool guide`,uri:Gn},{description:`Global classes list`,uri:Y}],handler:async e=>{let{classId:t,elementId:n}=e,r=(0,Un.doGetAppliedClasses)(n);return(0,Un.doApplyClasses)(n,[...r,t]),J.actions.tracking?.({event:`classApplied`,executedBy:`mcp_tool`,classId:t}),{llm_instructions:`Please check the element configuration, find inline styles duplicated by the applied global class, and remove them`,result:`Class ${t} applied to element ${n} successfully.`}}}),t({name:`unapply-global-class`,schema:{classId:Z.z.string().describe(`The ID of the class to unapply`),elementId:Z.z.string().describe(`The ID of the element from which the class will be unapplied`)},outputSchema:{result:Z.z.string().describe(`Result message indicating the success of the unapply operation`)},description:`Unapply a global class from an element by class ID. Resolve class names to IDs via [${Y}].`,requiredResources:[{description:`Global classes list`,uri:Y}],handler:async e=>{let{classId:t,elementId:n}=e;if(!(0,Un.doUnapplyClass)(n,t))throw Error(`Class ${t} is not applied to element ${n}, cannot unapply it.`);return{result:`Class ${t} unapplied from element ${n} successfully.`}}})}var Q=globalThis.elementorV2.schema;function initMcpApplyGetGlobalClassUsages(e){let{addTool:t}=e,n={usages:Q.z.array(Q.z.object({classId:Q.z.string().describe(`The ID of the class, not visible to the user. To retrieve the name of the class, use the "list-global-classes" tool`),usages:Q.z.array(Q.z.object({pageId:Q.z.string().describe(`The ID of the page where the class is used`),title:Q.z.string().describe(`The title of the page where the class is used`),total:Q.z.number().describe(`The number of times the class is used on this page`),elements:Q.z.array(Q.z.string()).describe(`List of element IDs using this class on the page`)}))}))};t({name:`get-global-class-usages`,description:`Retrieve usages of global classes across all Elementor pages. Heavy operation — scans every page in the site. | |
| 49 | - | |
| 50 | -## When to use: | |
| 51 | -- Before deleting or radically changing a class — to understand cross-page side effects and decide whether to consult the user. | |
| 52 | -- To identify unused global classes for cleanup. | |
| 53 | - | |
| 54 | -## When NOT to use: | |
| 55 | -- To list global classes themselves — use the global-classes resource instead (this tool returns usages, not the class list).`,requiredResources:[{description:`Global classes list`,uri:Y}],outputSchema:n,handler:async()=>{let e=await fetchCssClassUsage(),t={usages:[]};return Object.entries(e).forEach(([e,n])=>{let r={classId:e,usages:[]};if(typeof n!=`number`){let{content:e}=n;e.forEach(e=>{r.usages.push({pageId:String(e.pageId),title:e.title,total:e.total,elements:e.elements})}),t.usages.push(r)}}),t}})}var initMcpIntegration=(e,t)=>{initMcpApplyUnapplyGlobalClasses(e),initMcpApplyGetGlobalClassUsages(e),initManageClassesTool(e),initClassesResource(e,t)},Kn=globalThis.React,qn=globalThis.elementorV2.editorV1Adapters,Jn=globalThis.elementorV2.editorCurrentUser,Yn=globalThis.elementorV2.editorDocuments,Xn=globalThis.elementorV2.editorV1Adapters,Zn=globalThis.elementorV2.store,$=null;function syncWithDocumentSave(e){let t=syncDirtyState();return bindSaveAction(e),bindBeforeSaveTemplateAction(),t}function syncDirtyState(){return(0,Zn.__subscribeWithSelector)(selectIsDirty,()=>{isDirty()&&(0,Yn.setDocumentModifiedStatus)(!0)})}function triggerSave(e,t=`preview`){if(!(0,Jn.getCurrentUser)()?.capabilities.includes(fn))return null;if($)return $;let n=saveGlobalClasses2({context:t,onApprove:e?.open});return $=n,n.finally(()=>{$=null}),n}function bindSaveAction(e){(0,Xn.registerDataHook)(`dependency`,`document/save/save`,t=>(triggerSave(e,t.status===`publish`?`frontend`:`preview`),!0))}function bindBeforeSaveTemplateAction(){window.addEventListener(`elementor/global-styles/before-save`,(e=>{!$&&isDirty()&&triggerSave(),$&&e.detail.promises.push($)}))}function isDirty(){return selectIsDirty((0,Zn.__getState)())}function SyncWithDocumentSave(){return(0,Kn.useEffect)(()=>(0,qn.__privateListenTo)((0,qn.v1ReadyEvent)(),()=>{let open=()=>{window.dispatchEvent(new CustomEvent(`elementor/open-global-classes-manager`))};syncWithDocumentSave({open})}),[]),null}function init(){(0,Sn.__registerSlice)(x),yn.embeddedDocumentsManager.onDocumentLoad(e=>{addDocumentClasses(e)}),xn.stylesRepository.register(J),(0,_n.injectIntoLogic)({id:`global-classes-populate-store`,component:PopulateStore}),(0,_n.injectIntoLogic)({id:`global-classes-sync-with-document`,component:SyncWithDocumentSave}),(0,_n.injectIntoLogic)({id:`global-classes-import-listener`,component:GlobalStylesImportListener}),(0,_n.injectIntoLogic)({id:`global-classes-prefetch-css-class-usage`,component:PrefetchCssClassUsage}),(0,vn.injectIntoCssClassConvert)({id:`global-classes-convert-from-local-class`,component:ConvertLocalClassToGlobalClass}),(0,vn.injectIntoClassSelectorActions)({id:`global-classes-manager-button`,component:ClassManagerButton}),(0,vn.registerStyleProviderToColors)(mn,{name:`global`,getThemeColor:e=>e.palette.global.dark}),initMcpIntegration((0,bn.getMCPByDomain)(`classes`,{instructions:`MCP server for management of Elementor global classes`,docs:`Everything related to V4 ( Atomic ) global classes. | |
| 56 | -# Global classes | |
| 57 | -- Create/update/delete global classes | |
| 58 | -- Get list of global classes | |
| 59 | -- Get details of a global class | |
| 60 | -`}),(0,bn.getMCPByDomain)(`canvas`))}0&&(t.exports={ClassManagerPanelEmbedded,GLOBAL_CLASSES_URI:Y,addDocumentClasses,createLabelsForClasses,init,loadExistingClasses,trackGlobalClasses})}))());(window.elementorV2=window.elementorV2||{}).editorGlobalClasses=l})(),window.elementorV2.editorGlobalClasses?.init?.(); | |
| 5 | +`;function lt(){return lt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},lt.apply(null,arguments)}const ot=({id:e,label:t,renameClass:n,selected:a,disabled:r,sortableTriggerProps:s,showSortIndicator:o})=>{const i=(0,ee.useRef)(null),{ref:c,openEditMode:d,isEditing:u,error:m,getProps:p}=(0,ne.useEditable)({value:t,onSubmit:n,validation:ut}),[g,h]=(0,ee.useState)(""),{openDialog:y}=Ze(),f=(0,ae.usePopupState)({variant:"popover",disableAutoFocus:!0}),b=(g===e||a||f.isOpen)&&!r;return ee.createElement(ee.Fragment,null,ee.createElement(ae.Stack,{p:0},ee.createElement(ne.WarningInfotip,{open:Boolean(m),text:m??"",placement:"bottom",width:i.current?.getBoundingClientRect().width,offset:[0,-15]},ee.createElement(it,{ref:i,dense:!0,disableGutters:!0,showSortIndicator:o,showActions:b||u,shape:"rounded",onDoubleClick:d,selected:b,disabled:r,focusVisibleClassName:"visible-class-item"},ee.createElement(nt,s),ee.createElement(ct,{isActive:u,isError:!!m},u?ee.createElement(ne.EditableField,lt({ref:c,as:ae.Typography,variant:"caption"},p())):ee.createElement(ne.EllipsisWithTooltip,{title:t,as:ae.Typography,variant:"caption"})),ee.createElement(ae.Box,{className:"class-item-locator"},ee.createElement(qe,{id:e,onClick:h})),ee.createElement(ae.Tooltip,{placement:"top",className:"class-item-more-actions",title:(0,l.__)("More actions","elementor")},ee.createElement(ae.IconButton,lt({size:"tiny"},(0,ae.bindTrigger)(f),{"aria-label":"More actions"}),ee.createElement(ie.DotsVerticalIcon,{fontSize:"tiny"})))))),ee.createElement(ae.Menu,lt({},(0,ae.bindMenu)(f),{anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"right"}}),ee.createElement(ne.MenuListItem,{sx:{minWidth:"160px"},onClick:()=>{f.close(),d()}},ee.createElement(ae.Typography,{variant:"caption",sx:{color:"text.primary"}},(0,l.__)("Rename","elementor"))),ee.createElement(ne.MenuListItem,{onClick:()=>{f.close(),y({id:e,label:t})}},ee.createElement(ae.Typography,{variant:"caption",sx:{color:"error.light"}},(0,l.__)("Delete","elementor")))))},it=(0,ae.styled)(ae.ListItemButton,{shouldForwardProp:e=>!["showActions","showSortIndicator"].includes(e)})(({showActions:e,showSortIndicator:t})=>`\n min-height: 36px;\n\n &.visible-class-item {\n box-shadow: none !important;\n }\n\n .class-item-locator {\n visibility: hidden;\n }\n\n .class-item-sortable-trigger {\n visibility: ${t&&e?"visible":"hidden"};\n }\n\n &:hover:not(:disabled) {\n .class-item-locator {\n visibility: visible;\n }\n\n .class-item-sortable-trigger {\n visibility: ${t?"visible":"hidden"};\n }\n }\n `),ct=(0,ae.styled)(ae.Box,{shouldForwardProp:e=>!["isActive","isError"].includes(e)})(({theme:e,isActive:t,isError:n})=>({display:"flex",width:"100%",flexGrow:1,borderRadius:e.spacing(.5),border:dt({isActive:t,isError:n,theme:e}),padding:`0 ${e.spacing(1)}`,marginLeft:t?e.spacing(1):0,minWidth:0})),dt=({isActive:e,isError:t,theme:n})=>t?`2px solid ${n.palette.error.main}`:e?`2px solid ${n.palette.secondary.main}`:"none",ut=e=>{const t=(0,r.validateStyleLabel)(e,"rename");return t.isValid?null:t.errorMessage};function mt(){return mt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},mt.apply(null,arguments)}const pt={filterAndSearch:{mainText:(0,l.__)("Sorry, nothing matched.","elementor"),sceneryText:(0,l.__)("Try something else.","elementor"),icon:ee.createElement(ie.PhotoIcon,{color:"inherit",fontSize:"large"})},search:{mainText:(0,l.__)("Sorry, nothing matched","elementor"),sceneryText:(0,l.__)("Clear your input and try something else.","elementor"),icon:ee.createElement(ie.PhotoIcon,{color:"inherit",fontSize:"large"})},filter:{mainText:(0,l.__)("Sorry, nothing matched that search.","elementor"),sceneryText:(0,l.__)("Clear the filters and try something else.","elementor"),icon:ee.createElement(ie.ColorSwatchIcon,{color:"inherit",fontSize:"large"})}},gt=({notFoundType:e})=>{const{search:{onClearSearch:t,inputValue:n},filters:{onClearFilter:a}}=ge();switch(e){case"filter":return ee.createElement(ht,mt({},pt.filter,{onClear:a}));case"search":return ee.createElement(ht,mt({},pt.search,{searchValue:n,onClear:t}));case"filterAndSearch":return ee.createElement(ht,mt({},pt.filterAndSearch,{onClear:()=>{a(),t()}}))}},ht=({onClear:e,searchValue:t,mainText:n,sceneryText:a,icon:r})=>ee.createElement(ae.Stack,{color:"text.secondary",pt:5,alignItems:"center",gap:1,overflow:"hidden",justifySelf:"center"},r,ee.createElement(ae.Box,{sx:{width:"100%"}},ee.createElement(ae.Typography,{align:"center",variant:"subtitle2",color:"inherit"},n),t&&ee.createElement(ae.Typography,{variant:"subtitle2",color:"inherit",sx:{display:"flex",width:"100%",justifyContent:"center"}},ee.createElement("span",null,"“"),ee.createElement("span",{style:{maxWidth:"80%",overflow:"hidden",textOverflow:"ellipsis"}},t),ee.createElement("span",null,"”."))),ee.createElement(ae.Typography,{align:"center",variant:"caption",color:"inherit"},a),ee.createElement(ae.Typography,{align:"center",variant:"caption",color:"inherit"},ee.createElement(ae.Link,{color:"secondary",variant:"caption",component:"button",onClick:e},(0,l.__)("Clear & try again","elementor")))),yt=({disabled:e})=>{const{search:{debouncedValue:t}}=ge(),n=Fe(),a=(0,s.__useDispatch)(),r=be(),[l,o]=ee.useState(null),i=n.find(e=>e.id===l)?.label??"",[c,d]=vt(l,o,i??""),u=Et();if((0,ee.useEffect)(()=>{const e=e=>{if("z"===e.key&&(e.ctrlKey||e.metaKey)){if(e.stopImmediatePropagation(),e.preventDefault(),e.shiftKey)return void a(f.actions.redo());a(f.actions.undo())}};return window.addEventListener("keydown",e,{capture:!0}),()=>window.removeEventListener("keydown",e)},[a]),!n?.length)return ee.createElement(ft,null);const m=((e,t,n)=>{const a=n.length<=0&&e.length>1,r=t&&0===t.length;return a&&r?"filterAndSearch":a?"search":r?"filter":void 0})(t,r,u);if(m)return ee.createElement(gt,{notFoundType:m});const p=r?.length||t,g=u.length>1&&!p;return ee.createElement(Qe,null,ee.createElement(ae.List,{sx:{display:"flex",flexDirection:"column",gap:.5}},ee.createElement(tt,{value:c,onChange:d,disableDragOverlay:!g},u?.map(({id:t,label:n})=>ee.createElement(at,{key:t,id:t},({isDragged:r,isDragPlaceholder:s,triggerProps:i,triggerStyle:c})=>(r&&!l&&o(t),ee.createElement(ot,{id:t,label:n,renameClass:e=>{B({event:"classRenamed",classId:t,oldValue:n,newValue:e,source:"class-manager"}),a(f.actions.update({style:{id:t,label:e}}))},selected:r,disabled:e||s,sortableTriggerProps:{...i,style:c},showSortIndicator:g})))))))},ft=()=>ee.createElement(ae.Stack,{alignItems:"center",gap:1.5,pt:10,px:.5,maxWidth:"260px",margin:"auto"},ee.createElement(Ve,{fontSize:"large"}),ee.createElement(bt,{variant:"subtitle2",component:"h2",color:"text.secondary"},(0,l.__)("There are no global classes yet.","elementor")),ee.createElement(ae.Typography,{align:"center",variant:"caption",color:"text.secondary"},(0,l.__)("CSS classes created in the editor panel will appear here. Once they are available, you can arrange their hierarchy, rename them, or delete them as needed.","elementor"))),bt=(0,ae.styled)(ae.Typography)(({theme:e,variant:t})=>({"&.MuiTypography-root":{...e.typography[t]}})),vt=(e,t,n)=>{const a=(0,s.__useDispatch)();return[ce(),r=>{a(f.actions.setOrder(r)),e&&(B({event:"classManagerReorder",classId:e,classTitle:n}),t(null))}]},Et=()=>{const e=Fe(),{search:{debouncedValue:t}}=ge(),n=be(),a=(0,ee.useMemo)(()=>e.map(e=>({...e,lowerLabel:e.label.toLowerCase()})),[e]),r=(0,ee.useMemo)(()=>t.length>1?a.filter(e=>e.lowerLabel.includes(t.toLowerCase())):e,[t,e,a]);return(0,ee.useMemo)(()=>n&&n.length>0?r.filter(e=>n.includes(e.id)):r,[r,n])};function wt(){return wt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},wt.apply(null,arguments)}const _t="global-classes-manager",{panel:xt,usePanelActions:Ct}=(0,Z.__createPanel)({id:_t,component:function(){const e=de(),{close:t}=Ct(),{open:n,close:a,isOpen:r}=(0,ne.useDialog)(),{mutateAsync:o,isPending:i}=Tt();return Dt(),ee.createElement(ne.ThemeProvider,null,ee.createElement(ae.ErrorBoundary,{fallback:ee.createElement(It,null)},ee.createElement(Z.Panel,null,ee.createElement(pe,null,ee.createElement(Z.PanelHeader,null,ee.createElement(ae.Stack,{p:1,pl:2,width:"100%",direction:"row",alignItems:"center"},ee.createElement(ae.Stack,{width:"100%",direction:"row",gap:1},ee.createElement(Z.PanelHeaderTitle,{sx:{display:"flex",alignItems:"center",gap:.5}},ee.createElement(Ve,{fontSize:"inherit"}),(0,l.__)("Class Manager","elementor")),ee.createElement(Pt,null)),ee.createElement(St,{sx:{marginLeft:"auto"},disabled:i,onClose:()=>{e?n():t()}}))),ee.createElement(Z.PanelBody,{sx:{display:"flex",flexDirection:"column",height:"100%"}},ee.createElement(ae.Box,{px:2,pb:1},ee.createElement(ae.Stack,{direction:"row",justifyContent:"spaceBetween",gap:.5,sx:{pb:.5}},ee.createElement(ae.Box,{sx:{flexGrow:1}},ee.createElement(Ae,null)),ee.createElement(Oe,null)),ee.createElement(Te,null)),ee.createElement(ae.Divider,null),ee.createElement(ae.Box,{px:2,sx:{flexGrow:1,overflowY:"auto"}},ee.createElement(yt,{disabled:i}))),ee.createElement(Z.PanelFooter,null,ee.createElement(ae.Button,{fullWidth:!0,size:"small",color:"global",variant:"contained",onClick:o,disabled:!e,loading:i},(0,l.__)("Save changes","elementor")))))),ee.createElement(ze,null),r&&ee.createElement(ne.SaveChangesDialog,null,ee.createElement(ae.DialogHeader,{onClose:a,logo:!1},ee.createElement(ne.SaveChangesDialog.Title,null,(0,l.__)("You have unsaved changes","elementor"))),ee.createElement(ne.SaveChangesDialog.Content,null,ee.createElement(ne.SaveChangesDialog.ContentText,null,(0,l.__)("You have unsaved changes in the Class Manager.","elementor")),ee.createElement(ne.SaveChangesDialog.ContentText,null,(0,l.__)("To avoid losing your updates, save your changes before leaving.","elementor"))),ee.createElement(ne.SaveChangesDialog.Actions,{actions:{discard:{label:(0,l.__)("Discard","elementor"),action:()=>{(0,s.__dispatch)(f.actions.resetToInitialState({context:"frontend"})),a()}},confirm:{label:(0,l.__)("Save & Continue","elementor"),action:async()=>{await o(),a(),t()}}}})))},allowedEditModes:["edit",_t],onOpen:()=>{(0,o.changeEditMode)(_t),function(){const e=window;e.$e?.components?.get?.("panel")?.blockUserInteractions?.()}()},onClose:async()=>{(0,o.changeEditMode)("edit"),await(()=>{const e=(0,te.getCurrentDocument)();return(0,te.getV1DocumentsManager)().invalidateCache(),(0,o.__privateRunCommand)("editor/documents/switch",{id:e?.id,shouldScroll:!1,shouldNavigateToDefaultRoute:!1})})(),function(){const e=window;e.$e?.components?.get?.("panel")?.unblockUserInteractions?.()}()},isOpenPreviousElement:!0}),St=({onClose:e,...t})=>ee.createElement(ae.IconButton,wt({size:"small",color:"secondary",onClick:e,"aria-label":"Close"},t),ee.createElement(ie.XIcon,{fontSize:"small"})),It=()=>ee.createElement(ae.Box,{role:"alert",sx:{minHeight:"100%",p:2}},ee.createElement(ae.Alert,{severity:"error",sx:{mb:2,maxWidth:400,textAlign:"center"}},ee.createElement("strong",null,(0,l.__)("Something went wrong","elementor")))),Dt=()=>{const e=de();(0,ee.useEffect)(()=>{const t=t=>{e&&t.preventDefault()};return window.addEventListener("beforeunload",t),()=>{window.removeEventListener("beforeunload",t)}},[e])},Tt=()=>(0,re.useMutation)({mutationFn:()=>we({context:"frontend"}),onSuccess:async()=>{(0,te.setDocumentModifiedStatus)(!1),je&&await(async()=>{je=!1})()}}),Pt=()=>{const e=be(),t=ce();return ee.createElement(ae.Chip,{size:"small",label:e?`${e.length} / ${t?.length}`:t?.length})},kt=()=>{B({event:"classManagerOpened",source:"style-panel"})},Ot=()=>{const e=(0,te.__useActiveDocument)(),{open:t}=Ct(),{save:n}=(0,te.__useActiveDocumentActions)(),{open:a,close:s,isOpen:o}=(0,ne.useDialog)(),{prefetchClassesUsage:i}=le(),{userCan:c}=(0,r.useUserStylesCapability)();return c(Y.getKey()).update?ee.createElement(ee.Fragment,null,ee.createElement(ae.Tooltip,{title:(0,l.__)("Class Manager","elementor"),placement:"top"},ee.createElement(ae.IconButton,{size:"tiny",onClick:()=>{e?.isDirty?a():(t(),kt(),B({event:"classManagerOpened",source:"style-panel"}),i())},sx:{marginInlineEnd:-.75}},ee.createElement(Ve,{fontSize:"tiny"}))),o&&ee.createElement(ne.SaveChangesDialog,null,ee.createElement(ne.SaveChangesDialog.Title,null,(0,l.__)("You have unsaved changes","elementor")),ee.createElement(ne.SaveChangesDialog.Content,null,ee.createElement(ne.SaveChangesDialog.ContentText,{sx:{mb:2}},(0,l.__)("To open the Class Manager, save your page first. You can't continue without saving.","elementor"))),ee.createElement(ne.SaveChangesDialog.Actions,{actions:{cancel:{label:(0,l.__)("Stay here","elementor"),action:s},confirm:{label:(0,l.__)("Save & Continue","elementor"),action:async()=>{await n(),s(),t(),kt(),i()}}}}))):null},At=e=>{const t=e.styleDef;return ee.createElement(ee.Fragment,null,ee.createElement(ne.MenuListItem,{disabled:!e.canConvert,onClick:()=>{const n=function(e){let t=1,n=`${e}${t}`;for(;!(0,r.validateStyleLabel)(n,"create").isValid;)n=`${e}${++t}`;return n}("converted-class-");if(!t)throw new Error("Style definition is required for converting local class to global class.");const a=Y.actions.create?.(n,t.variants);a&&(e.successCallback(a),B({classId:a,event:"classCreated",source:"converted",classTitle:n}))},dense:!0,sx:{"&.Mui-focusVisible":{border:"none",boxShadow:"none !important",backgroundColor:"transparent"}}},(0,l.__)("Convert to global class","elementor")),ee.createElement(ae.Divider,null))};function Mt(){const e=(0,s.__useDispatch)();return(0,ee.useEffect)(()=>{Promise.all([z.all("preview"),z.all("frontend")]).then(([t,n])=>{const{data:a}=t,{data:r}=n;e(f.actions.load({preview:{items:a.data,order:a.meta.order},frontend:{items:r.data,order:r.meta.order}}))})},[e]),null}var zt=window.elementorV2.schema,Lt=window.elementorV2.editorCanvas,jt=window.elementorV2.editorProps;const Bt={action:zt.z.enum(["create","modify","delete"]).describe("Operation to perform"),classId:zt.z.string().optional().describe("Global class ID (required for modify). Get from elementor://global-classes resource."),globalClassName:zt.z.string().optional().describe("Global class name (required for create)"),props:zt.z.record(zt.z.any()).describe('key-value of style-schema PropValues. Available properties at dynamic resource "elementor://styles/schema/{property-name}"'),breakpoint:zt.z.nullable(zt.z.string().describe("Responsive breakpoint name for styles. Defaults to desktop (null).")).default(null).describe("Responsive breakpoint name for styles. Defaults to desktop (null).")},Vt={status:zt.z.enum(["ok","error"]).describe("Operation status"),classId:zt.z.string().optional().describe("Class ID (returned on create success)"),message:zt.z.string().optional().describe("Error details if status is error")},Ft=async e=>{const{action:t,classId:n,globalClassName:r,props:s,breakpoint:l}=e;if("create"===t&&!r)return{status:"error",message:"Create requires globalClassName"};if("modify"===t&&!n)return{status:"error",message:"Modify requires classId"};if("delete"===t&&!n)return{status:"error",message:"Delete requires classId"};const{create:o,update:i,delete:c}=Y.actions;if(!o||!i||!c)return{status:"error",message:"Required actions not available"};const d=[],u=(0,a.getStylesSchema)(),m=Object.keys(u);if(Object.keys(s).forEach(e=>{const t=u[e];if(!t)return void d.push(`Property "${e}" does not exist in styles schema.`);const{valid:n,jsonSchema:a}=jt.Schema.validatePropValue(t,s[e]);n||d.push(`- Property "${e}" has invalid value\n Expected schema: ${a}\n`)}),d.length>0)return{status:"error",message:`Validation errors:\n${d.join("\n")}\nAvailable Properties: ${m.join(", ")}\nUpdate your input and try again.`};const p=window.elementorV2.editorVariables.Utils;Object.keys(s).forEach(e=>{s[e]=jt.Schema.adjustLlmPropValueSchema(s[e],{transformers:p.globalVariablesLLMResolvers})});const g=l??"desktop";try{switch(t){case"create":const e=await async function(e){const{props:t,breakpoint:n,className:a,stylesProvider:r}=e,{create:s,delete:l}=r.actions;if(!a)throw new Error("Global class name is a required for creation");if(!s||!l)throw new Error("User is unable to create global classes");const o=s(a,[{meta:{breakpoint:n,state:null},custom_css:null,props:t}]);try{return await we({context:"frontend"}),o}catch{return l(o),null}}({props:s,className:r,stylesProvider:Y,breakpoint:g});return e?{status:"ok",message:`created global class with ID ${e}`}:{status:"error",message:"error creating class"};case"modify":const t=await async function(e){const{props:t,breakpoint:n,classId:a,stylesProvider:r}=e,{updateProps:s,update:l}=r.actions;if(!a)throw new Error("Class ID is required for modification");if(!s||!l)throw new Error("User is unable to update global classes");const o=structuredClone(r.actions.all());try{return s({id:a,props:t,meta:{breakpoint:n,state:null}}),await we({context:"frontend"}),!0}catch{return o.forEach(e=>{l({id:e.id,variants:e.variants})}),await we({context:"frontend"}),!1}}({classId:n,props:s,stylesProvider:Y,breakpoint:g});return t?{status:"ok",classId:n}:{status:"error",message:"error modifying class"};case"delete":const a=await async function(e){const{classId:t,stylesProvider:n}=e,{delete:a,create:r}=n.actions;if(!t)throw new Error("Class ID is required for deletion");if(!a||!r)throw new Error("User is unable to delete global classes");if(!structuredClone(n.actions.all()).find(e=>e.id===t))throw new Error(`Class with ID "${t}" not found`);try{return a(t),await we({context:"frontend"}),!0}catch{return!1}}({classId:n,stylesProvider:Y});return a?{status:"ok",message:`deleted global class with ID ${n}`}:{status:"error",message:"error deleting class"}}}catch(e){return{status:"error",message:`${t} failed: ${e.message||"Unknown error"}`}}},Wt=()=>{const e=(0,n.getMCPByDomain)("classes",{instructions:"MCP server for management of Elementor global classes"});var t;(t=e).addTool({schema:{classId:zt.z.string().describe("The ID of the class to apply"),elementId:zt.z.string().describe("The ID of the element to which the class will be applied")},outputSchema:{result:zt.z.string().describe("Result message indicating the success of the apply operation")},name:"apply-global-class",modelPreferences:{intelligencePriority:.7,speedPriority:.8},description:'Apply a global class to an element, enabling consistent styling through your design system.\n\n## When to use this tool:\n**ALWAYS use this IMMEDIATELY AFTER building compositions** to apply the global classes you created beforehand:\n- After using "build-compositions" tool, apply semantic classes to the created elements\n- When applying consistent typography styles (heading-primary, text-body, etc.)\n- When applying theme colors or brand styles (bg-brand, button-cta, etc.)\n- When ensuring spacing consistency (spacing-section-large, etc.)\n\n**DO NOT use this tool** for:\n- Elements that don\'t share styles with other elements (use inline styles instead)\n- Layout-specific properties (those should remain inline in stylesConfig)\n\n## Prerequisites:\n- **REQUIRED**: Get the list of available global classes from \'elementor://global-classes\' resource\n- **REQUIRED**: Get element IDs from the composition XML returned by "build-compositions" tool\n- Ensure you have the most up-to-date list of classes applied to the element to avoid duplicates\n- Make sure you have the correct class ID that you want to apply\n\n## Best Practices:\n1. Apply multiple classes to a single element if needed (typography + color + spacing)\n2. After applying, the tool will remind you to remove duplicate inline styles from elementConfig\n3. Classes should describe purpose, not implementation (e.g., "heading-primary" not "big-red-text")',handler:async e=>{const{classId:t,elementId:n}=e,a=(0,X.doGetAppliedClasses)(n);return(0,X.doApplyClasses)(n,[...a,t]),{llm_instructions:"Please check the element-configuration, find DUPLICATES in the style schema that are in the class, and remove them",result:`Class ${t} applied to element ${n} successfully.`}}}),t.addTool({name:"unapply-global-class",schema:{classId:zt.z.string().describe("The ID of the class to unapply"),elementId:zt.z.string().describe("The ID of the element from which the class will be unapplied")},outputSchema:{result:zt.z.string().describe("Result message indicating the success of the unapply operation")},modelPreferences:{intelligencePriority:.7,speedPriority:.8},description:"Unapply a (global) class from the current element\n\n## When to use this tool:\n- When a user requests to unapply a global class or a class from an element in the Elementor editor.\n- When you need to remove a specific class from an element's applied classes.\n\n## Prerequisites:\n- Ensure you have the most up-to-date list of classes applied to the element to avoid errors.\n The list is available at always up-to-date resource 'elementor://global-classes'.\n- Make sure you have the correct class ID that you want to unapply.\n\n<note>\nIf the user want to unapply a class by it's name and not ID, retreive the id from the list, available at uri elementor://global-classes\n</note>\n",handler:async e=>{const{classId:t,elementId:n}=e;if(!(0,X.doUnapplyClass)(n,t))throw new Error(`Class ${t} is not applied to element ${n}, cannot unapply it.`);return{result:`Class ${t} unapplied from element ${n} successfully.`}}}),function(e){const{addTool:t}=e;t({name:"get-global-class-usages",modelPreferences:{intelligencePriority:.6,speedPriority:.8},description:"Retreive the usages of global-classes ACCROSS PAGES designed by Elementor editor.\n\n## Prequisites: CRITICAL\n- The list of global classes and their applid values is available at resource uri elementor://global-classes\n\n## When to use this tool:\n- When a user requests to see where a specific global class is being used accross the site.\n- When you need to manage or clean up unused global classes.\n- Before deleting a global class, to ensure it is not in use in any other pages.\n\n## When NOT to use this tool:\n- For getting the list of global classes, refer to the resource at uri elementor://global-classes\n",outputSchema:{usages:zt.z.array(zt.z.object({classId:zt.z.string().describe('The ID of the class, not visible to the user. To retreive the name of the class, use the "list-global-classes" tool'),usages:zt.z.array(zt.z.object({pageId:zt.z.string().describe("The ID of the page where the class is used"),title:zt.z.string().describe("The title of the page where the class is used"),total:zt.z.number().describe("The number of times the class is used on this page"),elements:zt.z.array(zt.z.string()).describe("List of element IDs using this class on the page")}))}))},handler:async()=>{const e=await j(),t={usages:[]};return Object.entries(e).forEach(([e,n])=>{const a={classId:e,usages:[]};if("number"!=typeof n){const{content:e}=n;e.forEach(e=>{a.usages.push({pageId:String(e.pageId),title:e.title,total:e.total,elements:e.elements})}),t.usages.push(a)}}),t}})}(e),(e=>{const{addTool:t}=e;t({name:"manage-global-classes",requiredResources:[{uri:K,description:"Global classes list"},{uri:Lt.STYLE_SCHEMA_URI,description:"Style schema resources"},{uri:Lt.BREAKPOINTS_SCHEMA_URI,description:"Breakpoints list"}],modelPreferences:{intelligencePriority:.85,speedPriority:.6},description:"Manages global classes (create/modify) in Elementor editor. Check [elementor://global-classes] and style schemas first.\n\nCREATE: Requires globalClassName, props. Use semantic naming (heading-primary, button-cta, text-muted). Check existing classes to avoid duplicates. ALWAYS create global classes BEFORE compositions for reusable styles.\nMODIFY: Requires classId, props. Get classId from [elementor://global-classes] resource.\n\nNaming pattern: [element-type]-[purpose/variant]-[modifier]\nDO NOT create global classes for: one-off styles, layout-specific properties.\n\nUse style schema at [elementor://styles/schema/{category}] for valid props. Errors include exact schema mismatch details.",schema:Bt,outputSchema:Vt,handler:Ft})})(e),[(0,n.getMCPByDomain)("canvas"),(0,n.getMCPByDomain)("classes")].forEach(e=>{const{mcpServer:t,resource:n,waitForReady:a}=e;n("global-classes",K,{description:"Global classes list."},async()=>({contents:[{uri:K,text:localStorage["elementor-global-classes"]??"{}"}]})),a().then(()=>{Y.subscribe(()=>{t.sendResourceListChanged()})})})};function Rt(){const e=Ct();return(0,ee.useEffect)(()=>{(0,o.__privateListenTo)((0,o.v1ReadyEvent)(),()=>{!function(e){const t=(0,s.__subscribeWithSelector)(S,()=>{S((0,s.__getState)())&&(0,te.setDocumentModifiedStatus)(!0)});(function(e){(0,o.registerDataHook)("dependency","document/save/save",t=>{const n=(0,Me.getCurrentUser)(),a=n?.capabilities.includes(i);return!a||(we({context:"publish"===t.status?"frontend":"preview",onApprove:e?.open}),!0)})})(e)}(e)})},[]),null}function Ut(){(0,s.__registerSlice)(f),(0,Z.__registerPanel)(xt),r.stylesRepository.register(Y),(0,Q.injectIntoLogic)({id:"global-classes-populate-store",component:Mt}),(0,Q.injectIntoLogic)({id:"global-classes-sync-with-document",component:Rt}),(0,Q.injectIntoLogic)({id:"global-classes-prefetch-css-class-usage",component:oe}),(0,X.injectIntoCssClassConvert)({id:"global-classes-convert-from-local-class",component:At}),(0,X.injectIntoClassSelectorActions)({id:"global-classes-manager-button",component:Ot}),(0,X.registerStyleProviderToColors)(H,{name:"global",getThemeColor:e=>e.palette.global.dark}),Wt()}(window.elementorV2=window.elementorV2||{}).editorGlobalClasses=t}(),window.elementorV2.editorGlobalClasses?.init?.(); | |