@mohsinonxrm/pptb-commandbar-studio 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -4
- package/dist/assets/{BulkPublishModal-DqX2QmUD.js → BulkPublishModal-mFfxdo1T.js} +1 -1
- package/dist/assets/{CommandEditorPanel-DidGBtFC.js → CommandEditorPanel-_mV9SqAb.js} +1 -1
- package/dist/assets/{CommandPalette-AuDfsF8l.js → CommandPalette-CK3uU6Ky.js} +1 -1
- package/dist/assets/{ConflictDrawer-DxQ_jd-x.js → ConflictDrawer-BFlon1xn.js} +1 -1
- package/dist/assets/{CrmParameterEditor-BdmP65mF.js → CrmParameterEditor-B84bdjcT.js} +1 -1
- package/dist/assets/{DiffViewer-BZuqvP4f.js → DiffViewer-JSOMstAl.js} +2 -2
- package/dist/assets/{HideInsteadOfDeleteModal-BYHCTZrG.js → HideInsteadOfDeleteModal-DYsP_BRs.js} +1 -1
- package/dist/assets/{IconPickerModal-Bw0C7KwV.js → IconPickerModal-BF3KU0Ux.js} +1 -1
- package/dist/assets/{ImportXmlModal-B8NgiUDZ.js → ImportXmlModal-BYj1QmDX.js} +1 -1
- package/dist/assets/{LocalizationEditor-tmniX5PC.js → LocalizationEditor-SeIMV_0G.js} +1 -1
- package/dist/assets/{MonacoEditor-Bbg9u2FW.js → MonacoEditor-DakCq511.js} +2 -2
- package/dist/assets/{NewButtonModal-BVvlbCv4.js → NewButtonModal-D3iJDvUq.js} +1 -1
- package/dist/assets/{NewGroupModal-CgQy-uo4.js → NewGroupModal-Cfywgyga.js} +1 -1
- package/dist/assets/{NewTabModal-B_2-kwAx.js → NewTabModal-DGNwUnJ5.js} +1 -1
- package/dist/assets/{RuleEditorPanel-BkNwBgaP.js → RuleEditorPanel-BmI_wJKH.js} +1 -1
- package/dist/assets/{ScalingEditorPanel-ezMkzvG1.js → ScalingEditorPanel-VCqXvcQy.js} +1 -1
- package/dist/assets/{TabDisplayRulesPanel-trzExQ1T.js → TabDisplayRulesPanel-D26HGtKC.js} +1 -1
- package/dist/assets/{UrlComposerModal-BlVXHKRM.js → UrlComposerModal-gVBqcCZd.js} +1 -1
- package/dist/assets/{WebResourceBrowser-DaPOZQ5X.js → WebResourceBrowser-Hrw1yujP.js} +1 -1
- package/dist/assets/{XmlDrawer-BI6Wy6kL.js → XmlDrawer-lnZmbePV.js} +1 -1
- package/dist/assets/{cssMode-DdC7kBk-.js → cssMode-BGIqMXMp.js} +1 -1
- package/dist/assets/{dnd-fsSwRnQv.js → dnd-vmvAsOrM.js} +1 -1
- package/dist/assets/{fluent-icons-DxKNRZ1A.js → fluent-icons-4bzebHz-.js} +1 -1
- package/dist/assets/{fluent-ui-D7EtYwEg.js → fluent-ui-lAhdF0Ck.js} +1 -1
- package/dist/assets/{freemarker2-DDn-Wpd6.js → freemarker2-DpL6dihh.js} +1 -1
- package/dist/assets/{handlebars-Ck_SjSJx.js → handlebars-ChRbmRjV.js} +1 -1
- package/dist/assets/{html-BaJUqhKx.js → html-Bt7ZeSoE.js} +1 -1
- package/dist/assets/{htmlMode-CnYhJfhG.js → htmlMode-Uz2nWy9x.js} +1 -1
- package/dist/assets/{index-Bu7BlRFk.js → index-B2t4gwW0.js} +3 -3
- package/dist/assets/{javascript-2UlV1Qbm.js → javascript-Bu0Wr1JA.js} +1 -1
- package/dist/assets/{jsonMode-BmSpB9yr.js → jsonMode-Bc_oOneo.js} +1 -1
- package/dist/assets/{liquid-CE2reFvH.js → liquid-Cj1v6MBK.js} +1 -1
- package/dist/assets/{lspLanguageFeatures-BvbzEddk.js → lspLanguageFeatures-CbQqhnvj.js} +1 -1
- package/dist/assets/{mdx-BvcZv3tC.js → mdx-E7c9inFC.js} +1 -1
- package/dist/assets/{monaco-Bx8A1Vm1.js → monaco-BoSoLy50.js} +180 -179
- package/dist/assets/{python-MTPSN2vk.js → python-C7ICMPw1.js} +1 -1
- package/dist/assets/{razor-Ccq_CgR8.js → razor-xjSsEwAN.js} +1 -1
- package/dist/assets/{server.browser-C3R9jebn.js → server.browser-BZYwcDL4.js} +1 -1
- package/dist/assets/{tsMode-2cv3qhqp.js → tsMode-XBeIdV9f.js} +1 -1
- package/dist/assets/{typescript-BD6t7JEG.js → typescript-sgsLltTO.js} +1 -1
- package/dist/assets/{webResourceService-CvyHBu7T.js → webResourceService-DGt6sRPR.js} +1 -1
- package/dist/assets/{xml-DJGPA7j9.js → xml-DFgHgBBL.js} +1 -1
- package/dist/assets/{xmlValidator-D7JG-eNC.js → xmlValidator-D-tVo-1Z.js} +1 -1
- package/dist/assets/{yaml-Cpl0dvFM.js → yaml-DWfXsscO.js} +1 -1
- package/dist/index.html +5 -5
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./XmlDrawer-
|
|
2
|
-
import{y as le,z as s,i as gt,B as bl,E as ft,F as Qs,G as er,H as tr,J as nr,Q as or,K as ir,L as yl,M as Ct,N as Ht,O as sr,P as xl,U as rr,V as Sl,X as ar,Y as vl,Z as Cl,$ as wl,a0 as Il,a1 as Rl,a2 as jl,a3 as Nl,a4 as $l,a5 as Tl,a6 as kl,a7 as Al,a8 as Dl,a9 as zl,aa as Bl,ab as Ol,ac as El,ad as Ml,ae as Ll,af as Pl,ag as Fl,ah as _l,ai as ql,aj as Hl,ak as Gl,al as Wl,am as Ul,an as Xl,ao as Vl,ap as Jl,aq as Kl,ar as Yl,as as Zl,at as Ql,au as ec,av as tc,aw as nc,ax as oc,ay as ic,az as sc,aA as rc,aB as ac,aC as lc,aD as lr,aE as cc,aF as dc,aG as uc,aH as mc,aI as pc,aJ as fc,aK as hc,aL as gc,aM as bc,aN as yc,aO as xc,aP as Sc,aQ as vc,aR as Ye,aS as Cc,aT as wc,aU as Ic,aV as Rc,aW as jc,aX as Nc,aY as $c,aZ as Tc,a_ as kc,a$ as Ac,b0 as Dc,b1 as zc,b2 as Bc,b3 as Oc,b4 as Ec,b5 as Mc,b6 as Lc,b7 as Pc,b8 as Fc,b9 as _c,ba as cr,bb as qc,bc as Hc,bd as Gc,be as Wc,bf as Uc,bg as Xc,bh as Vc,bi as Jc,bj as Kc,bk as Yc,bl as Zc,bm as Qc,bn as ed,bo as to,bp as td,bq as nd,br as od,bs as id,bt as sd,bu as rd,bv as ad,bw as ld,bx as cd,by as dd,bz as ud,bA as md,bB as pd,bC as fd,bD as hd,bE as gd,bF as bd,bG as dr,bH as yd,bI as xd,bJ as Sd,bK as vd,bL as Cd,bM as wt,bN as wd,bO as Id,h as bi,g as Rd,bP as jd,w as Nd,x as $d,bQ as Td,bR as kd,bS as Ad,bT as Dd,bU as zd,bV as Bd,bW as Od,bX as ur,bY as Ed,bZ as Md,A as Ld,b_ as Pd,s as Fd,b$ as _d,c0 as qd,c1 as Hd,c2 as Gd,c3 as Wd,c4 as Ud,c5 as Xd,c6 as Vd,c7 as Jd,c8 as Kd,c9 as Yd,ca as Zd,cb as Qd,cc as eu,cd as tu,ce as nu,cf as ou,cg as iu,ch as su,ci as ru,cj as mn,ck as au,cl as lu,cm as no,cn as cu,co as Lt,cp as du,cq as Te,cr as Pt,cs as Pn,ct as mr,cu as pr,cv as uu,m as Ft,cw as mu,cx as pu,cy as fu,cz as hu}from"./fluent-icons-DxKNRZ1A.js";import{l as gu,m as bu,R as Ue,_ as Ne,a as M}from"./monaco-Bx8A1Vm1.js";import{a as yu,u as xu,T as q,P as Su,b as vu,B as K,c as ae,t as m,d as Cu,F as De,C as wu,S as dt,O as Iu,M as Ie,e as Re,f as Fn,g as pe,D as Gt,h as Wt,i as Ut,j as Xt,k as Vt,l as Jt,I as _e,m as ke,n as Fo,o as _o,p as qo,q as Ho,s as pt,v as Ru,w as ju,x as Nu,y as $u,z as fr,A as Tu,E as ku,G as Au,H as Du,J as zu,K as Bu,L as Ou,N as Eu,Q as Mu,R as Lu,U as Pu,V as Fu,W as _u,X as qu,Y as Ki,Z as $t,_ as Hu,$ as Tt,a0 as rt,a1 as yi,a2 as hr,a3 as gr,a4 as Oe,a5 as xi,a6 as Gu,a7 as Ve,a8 as Wu,a9 as go,aa as It,ab as Go,ac as Si,ad as Je,ae as Uu,af as Xu,ag as Vu}from"./fluent-ui-D7EtYwEg.js";import{u as Ju,a as br,b as _n,K as yr,P as xr,D as Sr,c as Ku,d as Yu,e as vr,f as Zu,S as Qu,h as em,g as tm,C as nm}from"./dnd-fsSwRnQv.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))o(i);new MutationObserver(i=>{for(const r of i)if(r.type==="childList")for(const l of r.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&o(l)}).observe(document,{childList:!0,subtree:!0});function n(i){const r={};return i.integrity&&(r.integrity=i.integrity),i.referrerPolicy&&(r.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?r.credentials="include":i.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function o(i){if(i.ep)return;i.ep=!0;const r=n(i);fetch(i.href,r)}})();function om(e){return new Worker(""+new URL("editor.worker-1APKdqmi.js",import.meta.url).href,{name:e?.name})}function im(e){return new Worker(""+new URL("json.worker-BoL8UZqY.js",import.meta.url).href,{name:e?.name})}function sm(e){return new Worker(""+new URL("ts.worker-BH9nVgjN.js",import.meta.url).href,{name:e?.name})}function rm(e){return new Worker(""+new URL("css.worker-DBVD8oXr.js",import.meta.url).href,{name:e?.name})}function am(e){return new Worker(""+new URL("html.worker-CwpTb9lJ.js",import.meta.url).href,{name:e?.name})}gu.config({monaco:bu});self.MonacoEnvironment={getWorker(e,t){return t==="json"?new im:t==="typescript"||t==="javascript"?new sm:t==="css"||t==="scss"||t==="less"?new rm:t==="html"||t==="handlebars"||t==="razor"?new am:new om}};var Nn={},Yi;function lm(){if(Yi)return Nn;Yi=1;var e=yu();return Nn.createRoot=e.createRoot,Nn.hydrateRoot=e.hydrateRoot,Nn}var cm=lm();const Zi=e=>{let t;const n=new Set,o=(d,u)=>{const p=typeof d=="function"?d(t):d;if(!Object.is(p,t)){const f=t;t=u??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(S=>S(t,f))}},i=()=>t,a={setState:o,getState:i,getInitialState:()=>c,subscribe:d=>(n.add(d),()=>n.delete(d))},c=t=e(o,i,a);return a},dm=(e=>e?Zi(e):Zi),um=e=>e;function mm(e,t=um){const n=Ue.useSyncExternalStore(e.subscribe,Ue.useCallback(()=>t(e.getState()),[e,t]),Ue.useCallback(()=>t(e.getInitialState()),[e,t]));return Ue.useDebugValue(n),n}const pm=e=>{const t=dm(e),n=o=>mm(t,o);return Object.assign(n,t),n},Rt=(e=>pm),Wo=new Set;function fm(e){return Wo.add(e),()=>Wo.delete(e)}const ie=Rt()((e,t)=>({connectionUrl:"",connectionName:"",environment:"Dev",publisherPrefix:"new",solutions:[],activeSolution:null,entities:[],activeEntity:null,solutionEntityIds:null,solutionRibbonComponentIds:null,currentUserId:"",currentUserName:"",setConnection:(n,o,i)=>e({connectionUrl:n,connectionName:o,environment:i}),setSolutions:n=>e({solutions:n}),setActiveSolution:n=>{Ne(async()=>{const{useRuntimeLogStore:i}=await Promise.resolve().then(()=>vm);return{useRuntimeLogStore:i}},void 0,import.meta.url).then(({useRuntimeLogStore:i})=>{i.getState().logInfo("dataverse",`Active solution: "${n.friendlyName||n.uniqueName}" — publisher="${n.publisherUniqueName||"(empty)"}", prefix="${n.publisherPrefix||"(empty)"}"`),(!n.publisherPrefix||n.publisherPrefix==="new"||/^defaultpublisher/i.test(n.publisherUniqueName??""))&&i.getState().logWarn("dataverse",`Solution "${n.friendlyName||n.uniqueName}" uses the org's default publisher (prefix="${n.publisherPrefix||"new"}"). All IDs and imports from CBS will land under that publisher. To use your own (e.g. "mxrm"), create a new solution in maker.powerapps.com bound to your custom publisher and pick that one here.`)});const o=t().activeSolution?.id!==n.id;if(e({activeSolution:n,publisherPrefix:n.publisherPrefix||"new",...o?{activeEntity:null,entities:[],solutionEntityIds:null,solutionRibbonComponentIds:null}:{}}),o)for(const i of Wo)i()},setEntities:n=>e({entities:n}),setActiveEntity:n=>e({activeEntity:n}),setSolutionEntityIds:n=>e({solutionEntityIds:n}),setSolutionRibbonComponentIds:n=>e({solutionRibbonComponentIds:n}),setCurrentUser:(n,o)=>e({currentUserId:n,currentUserName:o}),setPublisherPrefix:n=>e({publisherPrefix:n})})),hm=e=>(t,n,o)=>{const i=o.subscribe;return o.subscribe=((l,a,c)=>{let d=l;if(a){const u=c?.equalityFn||Object.is;let p=l(o.getState());d=f=>{const S=l(f);if(!u(p,S)){const v=p;a(p=S,v)}},c?.fireImmediately&&a(p,p)}return i(d)}),e(t,n,o)},gm=hm;function bm(e,t){let n;try{n=e()}catch{return}return{getItem:i=>{var r;const l=c=>c===null?null:JSON.parse(c,void 0),a=(r=n.getItem(i))!=null?r:null;return a instanceof Promise?a.then(l):l(a)},setItem:(i,r)=>n.setItem(i,JSON.stringify(r,void 0)),removeItem:i=>n.removeItem(i)}}const Uo=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(o){return Uo(o)(n)},catch(o){return this}}}catch(n){return{then(o){return this},catch(o){return Uo(o)(n)}}}},ym=(e,t)=>(n,o,i)=>{let r={storage:bm(()=>window.localStorage),partialize:g=>g,version:0,merge:(g,y)=>({...y,...g}),...t},l=!1,a=0;const c=new Set,d=new Set;let u=r.storage;if(!u)return e((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${r.name}', the given storage is currently unavailable.`),n(...g)},o,i);const p=()=>{const g=r.partialize({...o()});return u.setItem(r.name,{state:g,version:r.version})},f=i.setState;i.setState=(g,y)=>(f(g,y),p());const S=e((...g)=>(n(...g),p()),o,i);i.getInitialState=()=>S;let v;const x=()=>{var g,y;if(!u)return;const C=++a;l=!1,c.forEach(h=>{var I;return h((I=o())!=null?I:S)});const w=((y=r.onRehydrateStorage)==null?void 0:y.call(r,(g=o())!=null?g:S))||void 0;return Uo(u.getItem.bind(u))(r.name).then(h=>{if(h)if(typeof h.version=="number"&&h.version!==r.version){if(r.migrate){const I=r.migrate(h.state,h.version);return I instanceof Promise?I.then($=>[!0,$]):[!0,I]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,h.state];return[!1,void 0]}).then(h=>{var I;if(C!==a)return;const[$,R]=h;if(v=r.merge(R,(I=o())!=null?I:S),n(v,!0),$)return p()}).then(()=>{C===a&&(w?.(o(),void 0),v=o(),l=!0,d.forEach(h=>h(v)))}).catch(h=>{C===a&&w?.(void 0,h)})};return i.persist={setOptions:g=>{r={...r,...g},g.storage&&(u=g.storage)},clearStorage:()=>{++a,u?.removeItem(r.name)},getOptions:()=>r,rehydrate:()=>x(),hasHydrated:()=>l,onHydrate:g=>(c.add(g),()=>{c.delete(g)}),onFinishHydration:g=>(d.add(g),()=>{d.delete(g)})},r.skipHydration||x(),v||S},xm=ym,Sm=e=>({leftPaneWidth:260,rightPaneWidth:340,bottomPanelHeight:220,bottomCollapsed:!1,rightPaneMode:"docked",themeMode:"light",ribbonViewStyle:"modern",activeBottomTab:"commands",commandEditorOpen:!1,commandEditorId:null,ruleEditorOpen:!1,ruleEditorId:null,ruleEditorKind:null,xmlDrawerOpen:!1,bulkPublishOpen:!1,iconPickerOpen:!1,localizationEditorOpen:!1,localizationEditorButtonId:null,newGroupOpen:!1,newButtonGroupId:null,importXmlOpen:!1,importXmlSeed:"",conflictDrawerOpen:!1,conflictElementId:null,webResourceBrowserOpen:!1,urlComposerOpen:!1,diffViewerOpen:!1,diffViewerMode:"compare",tabDisplayRulesOpen:!1,scalingEditorOpen:!1,commandPaletteOpen:!1,newTabOpen:!1,hideInsteadOfDelete:null,announcement:"",setLeftPaneWidth:t=>e({leftPaneWidth:t}),setRightPaneWidth:t=>e({rightPaneWidth:t}),setBottomPanelHeight:t=>e({bottomPanelHeight:t}),setBottomCollapsed:t=>e({bottomCollapsed:t}),setRightPaneMode:t=>e({rightPaneMode:t}),setThemeMode:t=>e({themeMode:t}),setRibbonViewStyle:t=>e({ribbonViewStyle:t}),setActiveBottomTab:t=>e({activeBottomTab:t}),openCommandEditor:t=>e({commandEditorOpen:!0,commandEditorId:t}),closeCommandEditor:()=>e({commandEditorOpen:!1,commandEditorId:null}),openRuleEditor:(t,n)=>e({ruleEditorOpen:!0,ruleEditorId:t,ruleEditorKind:n}),closeRuleEditor:()=>e({ruleEditorOpen:!1,ruleEditorId:null,ruleEditorKind:null}),openXmlDrawer:()=>e({xmlDrawerOpen:!0}),closeXmlDrawer:()=>e({xmlDrawerOpen:!1}),openBulkPublish:()=>e({bulkPublishOpen:!0}),closeBulkPublish:()=>e({bulkPublishOpen:!1}),openIconPicker:()=>e({iconPickerOpen:!0}),closeIconPicker:()=>e({iconPickerOpen:!1}),openLocalizationEditor:t=>e({localizationEditorOpen:!0,localizationEditorButtonId:t}),closeLocalizationEditor:()=>e({localizationEditorOpen:!1,localizationEditorButtonId:null}),openNewGroup:()=>e({newGroupOpen:!0}),closeNewGroup:()=>e({newGroupOpen:!1}),openNewButton:t=>e({newButtonGroupId:t}),closeNewButton:()=>e({newButtonGroupId:null}),openImportXml:t=>e({importXmlOpen:!0,importXmlSeed:typeof t=="string"?t:""}),closeImportXml:()=>e({importXmlOpen:!1}),openConflictDrawer:t=>e({conflictDrawerOpen:!0,conflictElementId:t}),closeConflictDrawer:()=>e({conflictDrawerOpen:!1,conflictElementId:null}),openWebResourceBrowser:()=>e({webResourceBrowserOpen:!0}),closeWebResourceBrowser:()=>e({webResourceBrowserOpen:!1}),openUrlComposer:()=>e({urlComposerOpen:!0}),closeUrlComposer:()=>e({urlComposerOpen:!1}),openDiffViewer:t=>e({diffViewerOpen:!0,diffViewerMode:t}),closeDiffViewer:()=>e({diffViewerOpen:!1}),openTabDisplayRules:()=>e({tabDisplayRulesOpen:!0}),closeTabDisplayRules:()=>e({tabDisplayRulesOpen:!1}),openScalingEditor:()=>e({scalingEditorOpen:!0}),closeScalingEditor:()=>e({scalingEditorOpen:!1}),setCommandPaletteOpen:t=>e({commandPaletteOpen:t}),openNewTab:()=>e({newTabOpen:!0}),closeNewTab:()=>e({newTabOpen:!1}),openHideInsteadOfDelete:t=>e({hideInsteadOfDelete:t}),closeHideInsteadOfDelete:()=>e({hideInsteadOfDelete:null}),announce:t=>e({announcement:t})}),Y=Rt()(xm(Sm,{name:"cbs:ui",partialize:e=>({leftPaneWidth:e.leftPaneWidth,rightPaneWidth:e.rightPaneWidth,bottomPanelHeight:e.bottomPanelHeight,bottomCollapsed:e.bottomCollapsed,rightPaneMode:e.rightPaneMode,themeMode:e.themeMode,ribbonViewStyle:e.ribbonViewStyle})})),oe=Rt()((e,t)=>({entries:[],append:n=>{const i={id:`${Date.now()}-${t().entries.length+1}`,ts:new Date().toISOString(),...n};e({entries:[...t().entries,i].slice(-400)})},logInfo:(n,o)=>t().append({scope:n,level:"info",message:o}),logWarn:(n,o)=>t().append({scope:n,level:"warn",message:o}),logError:(n,o)=>t().append({scope:n,level:"error",message:o}),clear:()=>e({entries:[]})})),vm=Object.freeze(Object.defineProperty({__proto__:null,useRuntimeLogStore:oe},Symbol.toStringTag,{value:"Module"})),Cm=new Set(["Default","InvertResult","PropertyValue","ExpectedValue","TrackedInCrm","PassParams","AllowCustomRelationship","AllowSystemRelationship"]),Qi=["EnableRules","DisplayRules","Actions"];function wm(e,t){return Cm.has(t)||e.tagName==="BoolParameter"&&t==="Value"}function Im(e){const t=e.trim();return t==="1"?"true":t==="0"?"false":t}function Rm(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/"/g,""")}function On(e,t,n){const o=Array.from(e.attributes).map(l=>[l.name,wm(e,l.name)?Im(l.value):l.value]).sort(([l],[a])=>l<a?-1:l>a?1:0).map(([l,a])=>` ${l}="${Rm(a)}"`).join(""),i=[];let r=[];for(const l of Array.from(e.childNodes))if(l.nodeType===1)r.push(l);else if(l.nodeType===3||l.nodeType===4){const a=(l.textContent??"").trim();a&&i.push(`${n} #text ${a}`)}if(t.normalizeCommands&&e.tagName==="CommandDefinition"){const l=new Map(r.map(d=>[d.tagName,d])),a=r.filter(d=>!Qi.includes(d.tagName)),c=Qi.map(d=>{const u=l.get(d);return u?On(u,t,`${n} `):`${n} <${d}/>`});r=[],i.push(...c,...a.map(d=>On(d,t,`${n} `)))}for(const l of r)i.push(On(l,t,`${n} `));return i.length===0?`${n}<${e.tagName}${o}/>`:`${n}<${e.tagName}${o}>
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./XmlDrawer-lnZmbePV.js","./fluent-icons-4bzebHz-.js","./monaco-BoSoLy50.js","./monaco-Dprb6f6S.css","./webResourceService-DGt6sRPR.js","./MonacoEditor-DakCq511.js","./fluent-ui-lAhdF0Ck.js","./dnd-vmvAsOrM.js","./CommandEditorPanel-_mV9SqAb.js","./CrmParameterEditor-B84bdjcT.js","./crmParameters-rgfZhhzN.js","./RuleEditorPanel-BmI_wJKH.js","./ruleKinds-B9hACGaq.js","./BulkPublishModal-mFfxdo1T.js","./xmlValidator-D-tVo-1Z.js","./NewButtonModal-D3iJDvUq.js","./NewGroupModal-Cfywgyga.js","./NewTabModal-DGNwUnJ5.js","./ImportXmlModal-BYj1QmDX.js","./CommandPalette-CK3uU6Ky.js","./LocalizationEditor-SeIMV_0G.js","./IconPickerModal-BF3KU0Ux.js","./TabDisplayRulesPanel-D26HGtKC.js","./ScalingEditorPanel-VCqXvcQy.js","./ConflictDrawer-BFlon1xn.js","./WebResourceBrowser-Hrw1yujP.js","./UrlComposerModal-gVBqcCZd.js","./DiffViewer-JSOMstAl.js","./HideInsteadOfDeleteModal-DYsP_BRs.js","./server.browser-BZYwcDL4.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{y as le,z as s,i as gt,B as bl,E as ft,F as Qs,G as er,H as tr,J as nr,Q as or,K as ir,L as yl,M as Ct,N as Ht,O as sr,P as xl,U as rr,V as Sl,X as ar,Y as vl,Z as Cl,$ as wl,a0 as Il,a1 as Rl,a2 as jl,a3 as Nl,a4 as $l,a5 as Tl,a6 as kl,a7 as Al,a8 as Dl,a9 as zl,aa as Bl,ab as Ol,ac as El,ad as Ml,ae as Ll,af as Pl,ag as Fl,ah as _l,ai as ql,aj as Hl,ak as Gl,al as Wl,am as Ul,an as Xl,ao as Vl,ap as Jl,aq as Kl,ar as Yl,as as Zl,at as Ql,au as ec,av as tc,aw as nc,ax as oc,ay as ic,az as sc,aA as rc,aB as ac,aC as lc,aD as lr,aE as cc,aF as dc,aG as uc,aH as mc,aI as pc,aJ as fc,aK as hc,aL as gc,aM as bc,aN as yc,aO as xc,aP as Sc,aQ as vc,aR as Ye,aS as Cc,aT as wc,aU as Ic,aV as Rc,aW as jc,aX as Nc,aY as $c,aZ as Tc,a_ as kc,a$ as Ac,b0 as Dc,b1 as zc,b2 as Bc,b3 as Oc,b4 as Ec,b5 as Mc,b6 as Lc,b7 as Pc,b8 as Fc,b9 as _c,ba as cr,bb as qc,bc as Hc,bd as Gc,be as Wc,bf as Uc,bg as Xc,bh as Vc,bi as Jc,bj as Kc,bk as Yc,bl as Zc,bm as Qc,bn as ed,bo as to,bp as td,bq as nd,br as od,bs as id,bt as sd,bu as rd,bv as ad,bw as ld,bx as cd,by as dd,bz as ud,bA as md,bB as pd,bC as fd,bD as hd,bE as gd,bF as bd,bG as dr,bH as yd,bI as xd,bJ as Sd,bK as vd,bL as Cd,bM as wt,bN as wd,bO as Id,h as bi,g as Rd,bP as jd,w as Nd,x as $d,bQ as Td,bR as kd,bS as Ad,bT as Dd,bU as zd,bV as Bd,bW as Od,bX as ur,bY as Ed,bZ as Md,A as Ld,b_ as Pd,s as Fd,b$ as _d,c0 as qd,c1 as Hd,c2 as Gd,c3 as Wd,c4 as Ud,c5 as Xd,c6 as Vd,c7 as Jd,c8 as Kd,c9 as Yd,ca as Zd,cb as Qd,cc as eu,cd as tu,ce as nu,cf as ou,cg as iu,ch as su,ci as ru,cj as mn,ck as au,cl as lu,cm as no,cn as cu,co as Lt,cp as du,cq as Te,cr as Pt,cs as Pn,ct as mr,cu as pr,cv as uu,m as Ft,cw as mu,cx as pu,cy as fu,cz as hu}from"./fluent-icons-4bzebHz-.js";import{l as gu,m as bu,R as Ue,_ as Ne,a as M}from"./monaco-BoSoLy50.js";import{a as yu,u as xu,T as q,P as Su,b as vu,B as K,c as ae,t as m,d as Cu,F as De,C as wu,S as dt,O as Iu,M as Ie,e as Re,f as Fn,g as pe,D as Gt,h as Wt,i as Ut,j as Xt,k as Vt,l as Jt,I as _e,m as ke,n as Fo,o as _o,p as qo,q as Ho,s as pt,v as Ru,w as ju,x as Nu,y as $u,z as fr,A as Tu,E as ku,G as Au,H as Du,J as zu,K as Bu,L as Ou,N as Eu,Q as Mu,R as Lu,U as Pu,V as Fu,W as _u,X as qu,Y as Ki,Z as $t,_ as Hu,$ as Tt,a0 as rt,a1 as yi,a2 as hr,a3 as gr,a4 as Oe,a5 as xi,a6 as Gu,a7 as Ve,a8 as Wu,a9 as go,aa as It,ab as Go,ac as Si,ad as Je,ae as Uu,af as Xu,ag as Vu}from"./fluent-ui-lAhdF0Ck.js";import{u as Ju,a as br,b as _n,K as yr,P as xr,D as Sr,c as Ku,d as Yu,e as vr,f as Zu,S as Qu,h as em,g as tm,C as nm}from"./dnd-vmvAsOrM.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))o(i);new MutationObserver(i=>{for(const r of i)if(r.type==="childList")for(const l of r.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&o(l)}).observe(document,{childList:!0,subtree:!0});function n(i){const r={};return i.integrity&&(r.integrity=i.integrity),i.referrerPolicy&&(r.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?r.credentials="include":i.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function o(i){if(i.ep)return;i.ep=!0;const r=n(i);fetch(i.href,r)}})();function om(e){return new Worker(""+new URL("editor.worker-1APKdqmi.js",import.meta.url).href,{name:e?.name})}function im(e){return new Worker(""+new URL("json.worker-BoL8UZqY.js",import.meta.url).href,{name:e?.name})}function sm(e){return new Worker(""+new URL("ts.worker-BH9nVgjN.js",import.meta.url).href,{name:e?.name})}function rm(e){return new Worker(""+new URL("css.worker-DBVD8oXr.js",import.meta.url).href,{name:e?.name})}function am(e){return new Worker(""+new URL("html.worker-CwpTb9lJ.js",import.meta.url).href,{name:e?.name})}gu.config({monaco:bu});self.MonacoEnvironment={getWorker(e,t){return t==="json"?new im:t==="typescript"||t==="javascript"?new sm:t==="css"||t==="scss"||t==="less"?new rm:t==="html"||t==="handlebars"||t==="razor"?new am:new om}};var Nn={},Yi;function lm(){if(Yi)return Nn;Yi=1;var e=yu();return Nn.createRoot=e.createRoot,Nn.hydrateRoot=e.hydrateRoot,Nn}var cm=lm();const Zi=e=>{let t;const n=new Set,o=(d,u)=>{const p=typeof d=="function"?d(t):d;if(!Object.is(p,t)){const f=t;t=u??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(S=>S(t,f))}},i=()=>t,a={setState:o,getState:i,getInitialState:()=>c,subscribe:d=>(n.add(d),()=>n.delete(d))},c=t=e(o,i,a);return a},dm=(e=>e?Zi(e):Zi),um=e=>e;function mm(e,t=um){const n=Ue.useSyncExternalStore(e.subscribe,Ue.useCallback(()=>t(e.getState()),[e,t]),Ue.useCallback(()=>t(e.getInitialState()),[e,t]));return Ue.useDebugValue(n),n}const pm=e=>{const t=dm(e),n=o=>mm(t,o);return Object.assign(n,t),n},Rt=(e=>pm),Wo=new Set;function fm(e){return Wo.add(e),()=>Wo.delete(e)}const ie=Rt()((e,t)=>({connectionUrl:"",connectionName:"",environment:"Dev",publisherPrefix:"new",solutions:[],activeSolution:null,entities:[],activeEntity:null,solutionEntityIds:null,solutionRibbonComponentIds:null,currentUserId:"",currentUserName:"",setConnection:(n,o,i)=>e({connectionUrl:n,connectionName:o,environment:i}),setSolutions:n=>e({solutions:n}),setActiveSolution:n=>{Ne(async()=>{const{useRuntimeLogStore:i}=await Promise.resolve().then(()=>vm);return{useRuntimeLogStore:i}},void 0,import.meta.url).then(({useRuntimeLogStore:i})=>{i.getState().logInfo("dataverse",`Active solution: "${n.friendlyName||n.uniqueName}" — publisher="${n.publisherUniqueName||"(empty)"}", prefix="${n.publisherPrefix||"(empty)"}"`),(!n.publisherPrefix||n.publisherPrefix==="new"||/^defaultpublisher/i.test(n.publisherUniqueName??""))&&i.getState().logWarn("dataverse",`Solution "${n.friendlyName||n.uniqueName}" uses the org's default publisher (prefix="${n.publisherPrefix||"new"}"). All IDs and imports from CBS will land under that publisher. To use your own (e.g. "mxrm"), create a new solution in maker.powerapps.com bound to your custom publisher and pick that one here.`)});const o=t().activeSolution?.id!==n.id;if(e({activeSolution:n,publisherPrefix:n.publisherPrefix||"new",...o?{activeEntity:null,entities:[],solutionEntityIds:null,solutionRibbonComponentIds:null}:{}}),o)for(const i of Wo)i()},setEntities:n=>e({entities:n}),setActiveEntity:n=>e({activeEntity:n}),setSolutionEntityIds:n=>e({solutionEntityIds:n}),setSolutionRibbonComponentIds:n=>e({solutionRibbonComponentIds:n}),setCurrentUser:(n,o)=>e({currentUserId:n,currentUserName:o}),setPublisherPrefix:n=>e({publisherPrefix:n})})),hm=e=>(t,n,o)=>{const i=o.subscribe;return o.subscribe=((l,a,c)=>{let d=l;if(a){const u=c?.equalityFn||Object.is;let p=l(o.getState());d=f=>{const S=l(f);if(!u(p,S)){const v=p;a(p=S,v)}},c?.fireImmediately&&a(p,p)}return i(d)}),e(t,n,o)},gm=hm;function bm(e,t){let n;try{n=e()}catch{return}return{getItem:i=>{var r;const l=c=>c===null?null:JSON.parse(c,void 0),a=(r=n.getItem(i))!=null?r:null;return a instanceof Promise?a.then(l):l(a)},setItem:(i,r)=>n.setItem(i,JSON.stringify(r,void 0)),removeItem:i=>n.removeItem(i)}}const Uo=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(o){return Uo(o)(n)},catch(o){return this}}}catch(n){return{then(o){return this},catch(o){return Uo(o)(n)}}}},ym=(e,t)=>(n,o,i)=>{let r={storage:bm(()=>window.localStorage),partialize:g=>g,version:0,merge:(g,y)=>({...y,...g}),...t},l=!1,a=0;const c=new Set,d=new Set;let u=r.storage;if(!u)return e((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${r.name}', the given storage is currently unavailable.`),n(...g)},o,i);const p=()=>{const g=r.partialize({...o()});return u.setItem(r.name,{state:g,version:r.version})},f=i.setState;i.setState=(g,y)=>(f(g,y),p());const S=e((...g)=>(n(...g),p()),o,i);i.getInitialState=()=>S;let v;const x=()=>{var g,y;if(!u)return;const C=++a;l=!1,c.forEach(h=>{var I;return h((I=o())!=null?I:S)});const w=((y=r.onRehydrateStorage)==null?void 0:y.call(r,(g=o())!=null?g:S))||void 0;return Uo(u.getItem.bind(u))(r.name).then(h=>{if(h)if(typeof h.version=="number"&&h.version!==r.version){if(r.migrate){const I=r.migrate(h.state,h.version);return I instanceof Promise?I.then($=>[!0,$]):[!0,I]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,h.state];return[!1,void 0]}).then(h=>{var I;if(C!==a)return;const[$,R]=h;if(v=r.merge(R,(I=o())!=null?I:S),n(v,!0),$)return p()}).then(()=>{C===a&&(w?.(o(),void 0),v=o(),l=!0,d.forEach(h=>h(v)))}).catch(h=>{C===a&&w?.(void 0,h)})};return i.persist={setOptions:g=>{r={...r,...g},g.storage&&(u=g.storage)},clearStorage:()=>{++a,u?.removeItem(r.name)},getOptions:()=>r,rehydrate:()=>x(),hasHydrated:()=>l,onHydrate:g=>(c.add(g),()=>{c.delete(g)}),onFinishHydration:g=>(d.add(g),()=>{d.delete(g)})},r.skipHydration||x(),v||S},xm=ym,Sm=e=>({leftPaneWidth:260,rightPaneWidth:340,bottomPanelHeight:220,bottomCollapsed:!1,rightPaneMode:"docked",themeMode:"light",ribbonViewStyle:"modern",activeBottomTab:"commands",commandEditorOpen:!1,commandEditorId:null,ruleEditorOpen:!1,ruleEditorId:null,ruleEditorKind:null,xmlDrawerOpen:!1,bulkPublishOpen:!1,iconPickerOpen:!1,localizationEditorOpen:!1,localizationEditorButtonId:null,newGroupOpen:!1,newButtonGroupId:null,importXmlOpen:!1,importXmlSeed:"",conflictDrawerOpen:!1,conflictElementId:null,webResourceBrowserOpen:!1,urlComposerOpen:!1,diffViewerOpen:!1,diffViewerMode:"compare",tabDisplayRulesOpen:!1,scalingEditorOpen:!1,commandPaletteOpen:!1,newTabOpen:!1,hideInsteadOfDelete:null,announcement:"",setLeftPaneWidth:t=>e({leftPaneWidth:t}),setRightPaneWidth:t=>e({rightPaneWidth:t}),setBottomPanelHeight:t=>e({bottomPanelHeight:t}),setBottomCollapsed:t=>e({bottomCollapsed:t}),setRightPaneMode:t=>e({rightPaneMode:t}),setThemeMode:t=>e({themeMode:t}),setRibbonViewStyle:t=>e({ribbonViewStyle:t}),setActiveBottomTab:t=>e({activeBottomTab:t}),openCommandEditor:t=>e({commandEditorOpen:!0,commandEditorId:t}),closeCommandEditor:()=>e({commandEditorOpen:!1,commandEditorId:null}),openRuleEditor:(t,n)=>e({ruleEditorOpen:!0,ruleEditorId:t,ruleEditorKind:n}),closeRuleEditor:()=>e({ruleEditorOpen:!1,ruleEditorId:null,ruleEditorKind:null}),openXmlDrawer:()=>e({xmlDrawerOpen:!0}),closeXmlDrawer:()=>e({xmlDrawerOpen:!1}),openBulkPublish:()=>e({bulkPublishOpen:!0}),closeBulkPublish:()=>e({bulkPublishOpen:!1}),openIconPicker:()=>e({iconPickerOpen:!0}),closeIconPicker:()=>e({iconPickerOpen:!1}),openLocalizationEditor:t=>e({localizationEditorOpen:!0,localizationEditorButtonId:t}),closeLocalizationEditor:()=>e({localizationEditorOpen:!1,localizationEditorButtonId:null}),openNewGroup:()=>e({newGroupOpen:!0}),closeNewGroup:()=>e({newGroupOpen:!1}),openNewButton:t=>e({newButtonGroupId:t}),closeNewButton:()=>e({newButtonGroupId:null}),openImportXml:t=>e({importXmlOpen:!0,importXmlSeed:typeof t=="string"?t:""}),closeImportXml:()=>e({importXmlOpen:!1}),openConflictDrawer:t=>e({conflictDrawerOpen:!0,conflictElementId:t}),closeConflictDrawer:()=>e({conflictDrawerOpen:!1,conflictElementId:null}),openWebResourceBrowser:()=>e({webResourceBrowserOpen:!0}),closeWebResourceBrowser:()=>e({webResourceBrowserOpen:!1}),openUrlComposer:()=>e({urlComposerOpen:!0}),closeUrlComposer:()=>e({urlComposerOpen:!1}),openDiffViewer:t=>e({diffViewerOpen:!0,diffViewerMode:t}),closeDiffViewer:()=>e({diffViewerOpen:!1}),openTabDisplayRules:()=>e({tabDisplayRulesOpen:!0}),closeTabDisplayRules:()=>e({tabDisplayRulesOpen:!1}),openScalingEditor:()=>e({scalingEditorOpen:!0}),closeScalingEditor:()=>e({scalingEditorOpen:!1}),setCommandPaletteOpen:t=>e({commandPaletteOpen:t}),openNewTab:()=>e({newTabOpen:!0}),closeNewTab:()=>e({newTabOpen:!1}),openHideInsteadOfDelete:t=>e({hideInsteadOfDelete:t}),closeHideInsteadOfDelete:()=>e({hideInsteadOfDelete:null}),announce:t=>e({announcement:t})}),Y=Rt()(xm(Sm,{name:"cbs:ui",partialize:e=>({leftPaneWidth:e.leftPaneWidth,rightPaneWidth:e.rightPaneWidth,bottomPanelHeight:e.bottomPanelHeight,bottomCollapsed:e.bottomCollapsed,rightPaneMode:e.rightPaneMode,themeMode:e.themeMode,ribbonViewStyle:e.ribbonViewStyle})})),oe=Rt()((e,t)=>({entries:[],append:n=>{const i={id:`${Date.now()}-${t().entries.length+1}`,ts:new Date().toISOString(),...n};e({entries:[...t().entries,i].slice(-400)})},logInfo:(n,o)=>t().append({scope:n,level:"info",message:o}),logWarn:(n,o)=>t().append({scope:n,level:"warn",message:o}),logError:(n,o)=>t().append({scope:n,level:"error",message:o}),clear:()=>e({entries:[]})})),vm=Object.freeze(Object.defineProperty({__proto__:null,useRuntimeLogStore:oe},Symbol.toStringTag,{value:"Module"})),Cm=new Set(["Default","InvertResult","PropertyValue","ExpectedValue","TrackedInCrm","PassParams","AllowCustomRelationship","AllowSystemRelationship"]),Qi=["EnableRules","DisplayRules","Actions"];function wm(e,t){return Cm.has(t)||e.tagName==="BoolParameter"&&t==="Value"}function Im(e){const t=e.trim();return t==="1"?"true":t==="0"?"false":t}function Rm(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/"/g,""")}function On(e,t,n){const o=Array.from(e.attributes).map(l=>[l.name,wm(e,l.name)?Im(l.value):l.value]).sort(([l],[a])=>l<a?-1:l>a?1:0).map(([l,a])=>` ${l}="${Rm(a)}"`).join(""),i=[];let r=[];for(const l of Array.from(e.childNodes))if(l.nodeType===1)r.push(l);else if(l.nodeType===3||l.nodeType===4){const a=(l.textContent??"").trim();a&&i.push(`${n} #text ${a}`)}if(t.normalizeCommands&&e.tagName==="CommandDefinition"){const l=new Map(r.map(d=>[d.tagName,d])),a=r.filter(d=>!Qi.includes(d.tagName)),c=Qi.map(d=>{const u=l.get(d);return u?On(u,t,`${n} `):`${n} <${d}/>`});r=[],i.push(...c,...a.map(d=>On(d,t,`${n} `)))}for(const l of r)i.push(On(l,t,`${n} `));return i.length===0?`${n}<${e.tagName}${o}/>`:`${n}<${e.tagName}${o}>
|
|
3
3
|
${i.join(`
|
|
4
4
|
`)}
|
|
5
5
|
${n}</${e.tagName}>`}function Cr(e){const t=new DOMParser().parseFromString(e,"application/xml"),n=t.querySelector("parsererror");if(n)throw new Error(`XML parse error: ${n.textContent??"unknown"}`);return t.documentElement}function _t(e,t={}){const n=typeof e=="string"?Cr(e):e;return On(n,t,"")}function jm(e,t,n={}){try{return _t(e,n)===_t(t,n)}catch{return!1}}const pn={button:"Button",flyout:"FlyoutAnchor",splitButton:"SplitButton",textBox:"TextBox",comboBox:"ComboBox",checkBox:"CheckBox",toggleButton:"ToggleButton",label:"Label",dropDown:"DropDown",mruSplitButton:"MRUSplitButton",spinner:"Spinner",galleryButton:"GalleryButton"},wr=Object.fromEntries(Object.entries(pn).map(([e,t])=>[t,e])),Nm=new Set(["toggleButton","label","dropDown","mruSplitButton","spinner","galleryButton"]);function Ze(e){return!!e&&Nm.has(e)}const Ir=["Command","QueryCommand","MenuCommand","PopulateQueryCommand","CommandMenuOpen","CommandMenuClose","CommandPreview","CommandPreviewRevert","CommandRevert"],Rr=new RegExp(`\\s(?:${Ir.join("|")})="([^"]+)"`,"g");function jr(e){const t=new Set(e.commandId?[e.commandId]:[]);if(Ze(e.kind))for(const n of e.source?.xml?.matchAll(Rr)??[])t.add(n[1]);return[...t]}function $m(e,t,n){const o=i=>i.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<");return e.replace(Rr,(i,r)=>r===t||r===o(t)?i.replace(`"${r}"`,`"${o(n)}"`):i)}const qn={button:"Button",flyout:"Flyout",splitButton:"Split button",textBox:"Text box",comboBox:"Combo box",checkBox:"Check box",toggleButton:"Toggle button",label:"Label",dropDown:"Drop-down",mruSplitButton:"MRU split button",spinner:"Spinner",galleryButton:"Gallery button"};function Nr(e,t){const n=t.length>0?Math.min(...t):1/0,o=e.filter(i=>i<n);return{after:o.length>0?Math.max(...o):0,before:n}}function $r(e,t){let n=e.after>0?e.after+1:e.before>10?10:1;for(;t.has(n);)n++;return n<e.before?n:void 0}function Tr(e,t,n){const o=[],i=[],r=new Set([...t.maxSizes,...t.scales]),l=(f,S)=>{o.push({tabId:e,id:f.id,kind:f.kind,groupId:f.groupId,from:f.sequence,to:S}),r.add(S)},a=n.filter(f=>f.kind==="Scale"),c=[];for(const f of a)r.has(f.sequence)?c.push(f):r.add(f.sequence);for(const f of c)l(f,Math.max(0,...r)+1);const d=[...t.scales,...a.map(f=>o.find(S=>S.id===f.id&&S.kind==="Scale")?.to??f.sequence)],u=Nr(t.maxSizes,d),p=[];for(const f of n.filter(S=>S.kind==="MaxSize"))f.sequence<u.before&&!r.has(f.sequence)?r.add(f.sequence):p.push(f);for(const f of p){const S=$r(u,r);S===void 0?i.push(`The scaling of tab ${e} has no free position for MaxSize ${f.id} (Sequence ${f.sequence}): it must come before the first Scale (${u.before}) and use a Sequence no other step uses`):l(f,S)}return{changes:o,problems:i}}function Tm(e){return`Repaired the scaling of tab ${e.tabId}: ${e.kind} ${e.id} (group ${e.groupId}) moves from Sequence ${e.from} to ${e.to}, so no two scaling steps share a Sequence`}function Kt(){return{customActions:new Map,templates:new Map,commandDefinitions:new Map,tabDisplayRules:new Map,displayRules:new Map,enableRules:new Map,locLabels:new Map}}const wn=()=>new XMLSerializer;function kr(e){const t=new DOMParser().parseFromString(e,"application/xml"),n=t.querySelector("parsererror");if(n)throw new Error(`Invalid RibbonDiffXml: ${n.textContent??"parse error"}`);return t}function at(e,t){return e?Array.from(e.children).filter(n=>n.tagName===t):[]}function ue(e,t){return at(e,t)[0]}function Ar(e){if(e.tagName==="HideCustomAction"){const n=e.getAttribute("HideActionId");return n?`hide:${n}`:null}const t=e.getAttribute("Id");return t?`ca:${t}`:null}function Cy(e){const t=Kt(),o=kr(e).documentElement;if(o.tagName!=="RibbonDiffXml")throw new Error(`Expected <RibbonDiffXml> root, got <${o.tagName}>`);const i=wn();for(const a of Array.from(ue(o,"CustomActions")?.children??[])){const c=Ar(a);c&&t.customActions.set(c,i.serializeToString(a))}const r=ue(ue(o,"Templates"),"RibbonTemplates");for(const a of Array.from(r?.children??[])){const c=a.getAttribute("Id");c&&t.templates.set(c,i.serializeToString(a))}for(const a of at(ue(o,"CommandDefinitions"),"CommandDefinition")){const c=a.getAttribute("Id");c&&t.commandDefinitions.set(c,i.serializeToString(a))}const l=ue(o,"RuleDefinitions");for(const a of at(ue(l,"TabDisplayRules"),"TabDisplayRule")){const c=a.getAttribute("TabCommand");c&&t.tabDisplayRules.set(c,i.serializeToString(a))}for(const a of at(ue(l,"DisplayRules"),"DisplayRule")){const c=a.getAttribute("Id");c&&t.displayRules.set(c,i.serializeToString(a))}for(const a of at(ue(l,"EnableRules"),"EnableRule")){const c=a.getAttribute("Id");c&&t.enableRules.set(c,i.serializeToString(a))}for(const a of at(ue(o,"LocLabels"),"LocLabel")){const c=a.getAttribute("Id");c&&t.locLabels.set(c,i.serializeToString(a))}return t}function he(e){return kr(e).documentElement}function km(e){const t=Kt();for(const n of e.diffs){const o=n.rdx?.trim();if(!o)continue;const i=he(o);switch(n.difftype){case 3:{const r=i.getAttribute("Id")??n.diffid;r&&t.locLabels.set(r,o);break}case 2:{const r=i.getAttribute("Id")??n.diffid;r&&t.templates.set(r,o);break}default:{const r=Ar(i);r&&t.customActions.set(r,o)}}}for(const n of e.commands){const o=n.commanddefinition?.trim(),i=n.command??(o?he(o).getAttribute("Id"):null);o&&i&&t.commandDefinitions.set(i,o)}for(const n of e.rules){const o=n.ruledefinition?.trim();if(!o)continue;const i=he(o);if(n.ruletype===3||i.tagName==="TabDisplayRule"){const r=i.getAttribute("TabCommand")??n.ruleid;r&&t.tabDisplayRules.set(r,o)}else if(n.ruletype===1||i.tagName==="EnableRule"){const r=i.getAttribute("Id")??n.ruleid;r&&t.enableRules.set(r,o)}else{const r=i.getAttribute("Id")??n.ruleid;r&&t.displayRules.set(r,o)}}return t}function vi(e,t){const n=Kt();for(const o of Object.keys(n)){for(const[i,r]of e[o])n[o].set(i,r);for(const[i,r]of t[o])n[o].set(i,r)}return n}function wy(e){const t=(n,o)=>Array.from(n.values()).map(i=>`${o}${i}`).join(`
|
|
@@ -131,7 +131,7 @@ ${t.map(o=>` <Entity>
|
|
|
131
131
|
`)}
|
|
132
132
|
</Entities>`}
|
|
133
133
|
${e.applicationRibbonDiffXml??""}
|
|
134
|
-
</ImportExportXml>`}function Qo(e){return/^(Mscrm|Microsoft)\./.test(e)}function Xn(e,t){e.origin=t.origin,e.solutionName=t.solutionName,e.publisherName=t.publisherName,e.oob=t.origin==="oob",e.custom=t.origin==="unmanaged",e.managed=t.origin==="managed"}function Ip(e,t){return t?"unmanaged":Qo(e)?"oob":"unmanaged"}function ss(e,t){for(const n of e.tabs)for(const o of n.groups)for(const i of je(o))t.has(i.id)?Xn(i,{origin:"unmanaged"}):i.origin==="unmanaged"&&Xn(i,{origin:"managed"})}function xt(e){return e.origin==="unmanaged"}function In(e,t){return Zr(Yr(t),[e])}function Yr(e){const t=new Map;for(const n of e.tabs)for(const o of n.groups)for(const i of je(o))t.set(i.id,(t.get(i.id)??!0)&&xt(i));return t}function Zr(e,t){return Pr(t).every(n=>e.get(n.id)??xt(n))}function Qr(e,t,n){return t?n?"has"in n?n.has(e):n.includes(e):!1:!0}function $i(e,t,n){const o=t.tabs.some(i=>i.groups.some(r=>r.id===e.id));return Qr(e.id,o,n)&&Zr(Yr(t),e.buttons)}function ea(e,t,n){const o=t.tabs.some(i=>i.id===e.id);return Qr(e.id,o,n)&&e.groups.every(i=>$i(i,t,n))}function Dy(e,t){const n=t.tabs.flatMap(l=>l.groups.flatMap(a=>je(a))).filter(l=>l.id===e.id),o=n.find(l=>!xt(l)),i=o??n[0]??e,r=i.origin==="oob"?"the out-of-the-box ribbon":i.origin==="managed"?i.solutionName?`the managed solution "${i.solutionName}"`:"a managed solution":void 0;return o&&n.some(xt)?`The ribbon also places a button with this id from ${r??"another solution"}, and that one can't be deleted.`:r&&xt(e)?`It is your override of a button from ${r}: the original stays in the ribbon underneath it.`:r?`It comes from ${r}.`:xt(i)?"Its menu holds items from another solution.":"It comes from another solution."}function Rp(e,t){if(t.size!==0)for(const n of Object.keys(e))for(const o of e[n].tabs)for(const i of o.groups)for(const r of je(i)){const l=t.get(r.id);l&&Xn(r,l)}}function mo(e,t,n,o=[]){const r=new DOMParser().parseFromString(e,"application/xml"),l=r.querySelector("parsererror");if(l)throw new Error(`Ribbon XML parse error: ${l.textContent??"Unknown"}`);const a=jp(r),c=Np(r);Tp(r,a);const d=new zp,u=Bp(r,d),p=Ep(r,d),f=Mp(r,d);d.flush();const S=[...Fp(r)];for(const y of o)S.some(C=>C.id===y.id)||S.push(y);const v=new Set,x=new Set;r.querySelectorAll("CustomAction").forEach(y=>{const C=y.querySelector("CommandUIDefinition");if(C?.firstElementChild){const w=C.firstElementChild.getAttribute("Id")??"";w&&v.add(w)}}),r.querySelectorAll("HideCustomAction").forEach(y=>{const C=y.getAttribute("Location")??"";C&&x.add(C)});for(const y of a)for(const C of y.groups)for(const w of je(C)){const h=v.has(w.id);Xn(w,{origin:Ip(w.id,h)}),w.hidden=x.has(w.id),w.source&&(w.source.labelToken=w.source.attributes.LabelText,w.source.tooltipTitleToken=w.source.attributes.ToolTipTitle,w.source.tooltipBodyToken=w.source.attributes.ToolTipDescription),w.label=ce(w.label,S),w.tooltipTitle&&(w.tooltipTitle=ce(w.tooltipTitle,S)),w.tooltipBody&&(w.tooltipBody=ce(w.tooltipBody,S));for(const I of w.menu?.sections??[])I.title&&(I.title=ce(I.title,S))}const g=$p(r,a);return{ribbon:{location:t,entityLogicalName:n,tabs:a,...Object.keys(c).length>0?{scalingByTab:c}:{},...Object.keys(g).length?{templateLayouts:g}:{}},commands:u,displayRules:f,enableRules:p,locLabels:S}}const ta="Ribbon > Tabs > Tab, Ribbon > ContextualTabs > ContextualGroup > Tab";function rs(e){const t=e.getAttribute("Description");return t===null?{}:{description:t}}function jp(e){const t=[];return e.querySelectorAll(ta).forEach(n=>{const o=n.getAttribute("Id")??"";if(!o)return;const i=n.getAttribute("Title")??o,r=[];n.querySelectorAll(":scope > Groups > Group").forEach(l=>{const a=l.getAttribute("Id")??"";if(!a)return;const c=l.getAttribute("Title")??l.getAttribute("Label")??a,d=parseInt(l.getAttribute("Sequence")??"0",10),u=l.getAttribute("Template")??"",p=[];l.querySelectorAll(":scope > Controls > *").forEach(f=>{wr[f.tagName]&&na(f,p)}),r.push({id:a,label:c,sequence:d,template:u,...rs(l),buttons:p})}),t.push({id:o,label:i,sequence:parseInt(n.getAttribute("Sequence")??"0",10),commandId:n.getAttribute("Command")??void 0,...rs(n),tabDisplayRules:[],groups:r})}),t.sort((n,o)=>n.sequence-o.sequence)}function Np(e){const t={};return e.querySelectorAll(ta).forEach(n=>{const o=n.getAttribute("Id"),i=Array.from(n.children).find(a=>a.tagName==="Scaling");if(!o||!i||t[o])return;const r=a=>({id:a.getAttribute("Id")??"",groupId:a.getAttribute("GroupId")??"",size:a.getAttribute("Size")??"",sequence:parseInt(a.getAttribute("Sequence")??"0",10)}),l=Array.from(i.children);t[o]={tabId:o,maxSizes:l.filter(a=>a.tagName==="MaxSize").map(r),scales:l.filter(a=>a.tagName==="Scale").map(r)}}),t}function $p(e,t){const n=new Set(t.flatMap(i=>i.groups.map(r=>r.template)).filter(Boolean)),o={};return e.querySelectorAll("GroupTemplate").forEach(i=>{const r=i.getAttribute("Id");!r||!n.has(r)||(o[r]=Array.from(i.querySelectorAll(":scope > Layout")).map(l=>l.getAttribute("Title")??"").filter(Boolean))}),o}function Tp(e,t){const n=new Map;for(const o of t)o.commandId&&n.set(o.commandId,o);e.querySelectorAll("RuleDefinitions > TabDisplayRules > TabDisplayRule").forEach(o=>{const i=o.getAttribute("TabCommand")??"",r=n.get(i);if(!r)return;const l=[];o.querySelectorAll("EntityRule").forEach(a=>{l.push({kind:"EntityRule",entityName:a.getAttribute("EntityName")??void 0,appliesTo:a.getAttribute("AppliesTo")??void 0,context:a.getAttribute("Context")??void 0})}),o.querySelectorAll("PageRule").forEach(a=>{l.push({kind:"PageRule",address:a.getAttribute("Address")??""})}),l.length>0&&r.tabDisplayRules.push({tabCommand:i,rules:l})})}function na(e,t){const n=e.getAttribute("Id")??"";if(!n)return;const o=wr[e.tagName]??"button",i=Ze(o),r=e.getAttribute("LabelText")??n,l=Dp(e.getAttribute("ModernImage")??void 0),a=parseInt(e.getAttribute("Sequence")??"0",10),c=e.getAttribute("TemplateAlias")??"",d=e.getAttribute("Command")??"";t.push({id:n,label:r,icon:l,sequence:a,templateAlias:c,commandId:d,kind:o,hidden:!1,oob:!0,custom:!1,managed:!1,tooltipTitle:e.getAttribute("ToolTipTitle")??void 0,tooltipBody:e.getAttribute("ToolTipDescription")??void 0,image16:e.getAttribute("Image16by16")??void 0,image32:e.getAttribute("Image32by32")??void 0,source:{modernImage:e.getAttribute("ModernImage")??void 0,attributes:ei(e),...i?{xml:qt().serializeToString(e)}:{}},menu:i?void 0:Ap(e)})}const kp=new Set(["Button","FlyoutAnchor","SplitButton","TextBox","ComboBox","CheckBox"]);function ei(e){return Object.fromEntries(Array.from(e.attributes).map(t=>[t.name,t.value]))}function Ap(e){const t=Me(e).find(i=>i.tagName==="Menu");if(!t)return;const n=ei(t),o=[];for(const i of Me(t)){if(i.tagName!=="MenuSection")continue;const r=i.getAttribute("Id")??"",l=Me(i).find(u=>u.tagName==="Controls"),a=[],c=[];Me(l).forEach((u,p)=>{kp.has(u.tagName)&&u.getAttribute("Id")?na(u,a):c.push({index:p,xml:qt().serializeToString(u)})});const d=ei(i);o.push({id:r,title:i.getAttribute("Title")??void 0,sequence:parseInt(i.getAttribute("Sequence")??"0",10),displayMode:i.getAttribute("DisplayMode")??void 0,controlsId:l?.getAttribute("Id")??`${r}.Controls`,controls:a,attributes:d,...c.length?{rawControls:c}:{},...l?{}:{rawContent:Me(i).map(u=>qt().serializeToString(u)).join("")}})}return{id:t.getAttribute("Id")??`${e.getAttribute("Id")}.Menu`,sections:o,attributes:n}}function Dp(e){if(e)return e.includes("_")?e.toLowerCase():e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").toLowerCase()}const qt=()=>new XMLSerializer;function Me(e){return e?Array.from(e.childNodes).filter(t=>t.nodeType===Node.ELEMENT_NODE):[]}class zp{pending=[];add(t){this.pending.push(t)}flush(){for(const t of[0,1]){const n=this.pending.filter(r=>r.phase===t);if(n.length===0)continue;const o=n.map(r=>r.generate());let i=null;try{const r=Cr(`<v>${o.map(l=>`<i>${l}</i>`).join("")}</v>`);i=Me(r).map(l=>Me(l)[0])}catch{i=null}n.forEach((r,l)=>{(i?i[l]&&_t(i[l])===_t(r.source):jm(o[l],r.source))||r.fallback()})}this.pending=[]}}function Bp(e,t){const n=[];return e.querySelectorAll("CommandDefinition").forEach(o=>{const i=o.getAttribute("Id")??"";if(!i)return;const r=Me(o),l=f=>r.find(S=>S.tagName===f),a=[],c=(f,S)=>{const v=[];return Me(l(f)).forEach((x,g)=>{const y=x.getAttribute("Id");x.tagName===S&&y&&x.attributes.length===1&&Me(x).length===0?v.push(y):a.push({container:f,index:g,xml:qt().serializeToString(x)})}),v},d=c("EnableRules","EnableRule"),u=c("DisplayRules","DisplayRule"),p=[];Me(l("Actions")).forEach((f,S)=>{const v=Op(f);if(!v){p.push(as(f));return}p.push(v),t.add({source:f,generate:()=>Kr(v),fallback:()=>p[S]=as(f),phase:0})}),n.push({id:i,enableRules:d,displayRules:u,actions:p,...a.length>0?{rawRuleRefs:a}:{}})}),n}function as(e){return{kind:"raw",tagName:e.tagName,xml:qt().serializeToString(e)}}function Op(e){switch(e.tagName){case"JavaScriptFunction":{const t=ti(e);return t?{kind:"javascript",library:e.getAttribute("Library")??"",functionName:e.getAttribute("FunctionName")??"",params:t}:null}case"Url":{const t=ti(e);if(!t)return null;const n=e.getAttribute("WinMode");return{kind:"url",address:e.getAttribute("Address")??"",passParams:lt(e.getAttribute("PassParams")),winMode:n===null?void 0:Number(n),winParams:e.getAttribute("WinParams")??void 0,params:t}}case"OutlookCommand":return{kind:"outlookCommand",actionType:e.getAttribute("ActionType")??"",data:e.getAttribute("Data")??void 0};default:return null}}function lt(e){if(e===null)return;const t=e.trim();if(t==="true"||t==="1")return!0;if(t==="false"||t==="0")return!1}function ti(e){const t=[];for(const n of Me(e)){const o=n.getAttribute("Name")??void 0,i=n.getAttribute("Value")??"";switch(n.tagName){case"CrmParameter":t.push({kind:"CrmParameter",name:o,value:i});break;case"BoolParameter":t.push({kind:"BoolParameter",name:o,value:lt(i)??!1});break;case"IntParameter":t.push({kind:"IntParameter",name:o,value:parseInt(i,10)});break;case"DecimalParameter":t.push({kind:"DecimalParameter",name:o,value:parseFloat(i)});break;case"StringParameter":t.push({kind:"StringParameter",name:o,value:i});break;default:return null}}return t}function Ep(e,t){const n=[];return e.querySelectorAll("RuleDefinitions > EnableRules > EnableRule").forEach(o=>{const i=o.getAttribute("Id")??"";i&&n.push({id:i,steps:Ti(o,t)})}),n}function Mp(e,t){const n=[];return e.querySelectorAll("RuleDefinitions > DisplayRules > DisplayRule").forEach(o=>{const i=o.getAttribute("Id")??"";i&&n.push({id:i,steps:Ti(o,t)})}),n}function Ti(e,t){const n=[];return Me(e).forEach((o,i)=>{const r=Pp(o,t);if(!r){n.push(ls(o));return}n.push(r),t.add({source:o,generate:()=>uo(n[i]),fallback:()=>n[i]=ls(o),phase:r.kind==="OrRule"?1:0})}),n}function ls(e){return{kind:"RawRule",tagName:e.tagName,xml:qt().serializeToString(e)}}function Lp(e){const t={},n=lt(e.getAttribute("Default")),o=lt(e.getAttribute("InvertResult"));return n!==void 0&&(t.default=n),o!==void 0&&(t.invertResult=o),t}function Qt(e,t){const n=e.getAttribute(t);return n===null?void 0:parseInt(n,10)}function Ge(e,t){return e.getAttribute(t)??void 0}function de(e,t){return e.getAttribute(t)??""}function Pp(e,t){const n=Lp(e);switch(e.tagName){case"OrRule":{const o=Me(e);return o.some(i=>i.tagName!=="Or")?null:{kind:"OrRule",groups:o.map(i=>Ti(i,t))}}case"SelectionCountRule":return{kind:"SelectionCountRule",minimum:Qt(e,"Minimum"),maximum:Qt(e,"Maximum"),appliesTo:Ge(e,"AppliesTo"),...n};case"EntityRule":return{kind:"EntityRule",entityName:Ge(e,"EntityName"),context:Ge(e,"Context"),appliesTo:Ge(e,"AppliesTo"),...n};case"FormStateRule":return{kind:"FormStateRule",state:de(e,"State"),...n};case"CommandClientTypeRule":return{kind:"CommandClientTypeRule",type:de(e,"Type"),...n};case"CustomRule":{const o=ti(e);return o?{kind:"CustomRule",library:de(e,"Library"),functionName:de(e,"FunctionName"),...o.length>0?{params:o}:{},...n}:null}case"FeatureControlRule":{const o=lt(e.getAttribute("ExpectedValue"));return o===void 0?null:{kind:"FeatureControlRule",featureControlBit:de(e,"FeatureControlBit"),expectedValue:o,...n}}case"MiscellaneousPrivilegeRule":return{kind:"MiscellaneousPrivilegeRule",privilegeName:de(e,"PrivilegeName"),privilegeDepth:Ge(e,"PrivilegeDepth"),...n};case"CrmClientTypeRule":return{kind:"CrmClientTypeRule",type:de(e,"Type"),...n};case"FormTypeRule":return{kind:"FormTypeRule",type:de(e,"Type"),...n};case"ValueRule":return{kind:"ValueRule",field:de(e,"Field"),value:de(e,"Value"),...n};case"SkuRule":return{kind:"SkuRule",sku:de(e,"Sku"),...n};case"HideForTabletExperienceRule":return{kind:"HideForTabletExperienceRule",...n};case"OrganizationSettingRule":return{kind:"OrganizationSettingRule",setting:de(e,"Setting"),...n};case"EntityPrivilegeRule":return{kind:"EntityPrivilegeRule",entityName:Ge(e,"EntityName"),appliesTo:Ge(e,"AppliesTo"),privilegeType:de(e,"PrivilegeType"),privilegeDepth:de(e,"PrivilegeDepth"),...n};case"EntityPropertyRule":{const o=lt(e.getAttribute("PropertyValue"));return o===void 0?null:{kind:"EntityPropertyRule",entityName:Ge(e,"EntityName"),appliesTo:Ge(e,"AppliesTo"),propertyName:de(e,"PropertyName"),propertyValue:o,...n}}case"DeviceTypeRule":return{kind:"DeviceTypeRule",type:de(e,"Type"),...n};case"OptionSetRule":return{kind:"OptionSetRule",optionSet:de(e,"OptionSet"),stateCode:de(e,"StateCode"),objectTypeCode:de(e,"ObjectTypeCode"),...n};case"RecordPrivilegeRule":return{kind:"RecordPrivilegeRule",privilegeType:de(e,"PrivilegeType"),appliesTo:Ge(e,"AppliesTo"),...n};case"FormEntityContextRule":return{kind:"FormEntityContextRule",entityName:de(e,"EntityName"),...n};case"PageRule":return{kind:"PageRule",address:de(e,"Address"),...n};case"RelationshipTypeRule":return{kind:"RelationshipTypeRule",appliesTo:"SelectedEntity",relationshipType:Ge(e,"RelationshipType"),allowCustomRelationship:lt(e.getAttribute("AllowCustomRelationship")),allowSystemRelationship:lt(e.getAttribute("AllowSystemRelationship")),...n};case"ReferencingAttributeRequiredRule":return{kind:"ReferencingAttributeRequiredRule",...n};case"OutlookItemTrackingRule":{const o=lt(e.getAttribute("TrackedInCrm"));return o===void 0?null:{kind:"OutlookItemTrackingRule",trackedInCrm:o,appliesTo:Ge(e,"AppliesTo"),...n}}case"OutlookRenderTypeRule":return{kind:"OutlookRenderTypeRule",type:de(e,"Type"),...n};case"OutlookVersionRule":return{kind:"OutlookVersionRule",version:de(e,"Version"),...n};case"CrmOfflineAccessStateRule":return{kind:"CrmOfflineAccessStateRule",state:de(e,"State"),...n};case"CrmOutlookClientTypeRule":return{kind:"CrmOutlookClientTypeRule",type:de(e,"Type"),...n};case"CrmOutlookClientVersionRule":return{kind:"CrmOutlookClientVersionRule",major:parseInt(de(e,"Major"),10),minor:Qt(e,"Minor"),build:Qt(e,"Build"),revision:Qt(e,"Revision"),...n};default:return null}}function Fp(e){const t=[];return e.querySelectorAll("LocLabel").forEach(n=>{const o=n.getAttribute("Id")??"";if(!o)return;const i=[];n.querySelectorAll("Title").forEach(r=>{const l=parseInt(r.getAttribute("languagecode")??"1033",10),a=r.getAttribute("description")??"";i.push({languageCode:l,description:a})}),t.push({id:o,titles:i})}),t}function Vn(e){return{controlIds:[...Gn(e)],containerIds:[...Er(e)],locLabelIds:[...e.locLabels.keys()],hides:oo(e),scalingStepIds:wi(e).map(t=>t.id),commandIds:[...e.commandDefinitions.keys()],commandRefIds:[...Mr(e)]}}async function zy(e){try{return Vn(await ni(e))}catch{return null}}function _p(e){const t=`<RibbonDiffXml><CommandDefinitions>${[...e.commandDefinitions.values()].join("")}</CommandDefinitions><RuleDefinitions><DisplayRules>${[...e.displayRules.values()].join("")}</DisplayRules><EnableRules>${[...e.enableRules.values()].join("")}</EnableRules></RuleDefinitions></RibbonDiffXml>`,n=mo(t,"HomepageGrid","");return{commands:n.commands,enableRules:n.enableRules,displayRules:n.displayRules}}function qp(){return window.dataverseAPI}async function Co(e){const t=[];let n=e;for(;n;){const o=await qp().queryData(n);t.push(...o.value??[]);const i=o["@odata.nextLink"];n=i?i.replace(/^.*\/api\/data\/v[\d.]+\//,""):void 0}return t}async function ni(e){const t=e===null?"entity eq null and ismanaged eq false":`entity eq '${e.replace(/'/g,"''")}' and ismanaged eq false`,[n,o,i]=await Promise.all([Co(`ribbondiffs?$select=diffid,difftype,rdx,sequence&$filter=${t}&$orderby=sequence asc,diffid asc`),Co(`ribboncommands?$select=command,commanddefinition&$filter=${t}&$orderby=command asc`),Co(`ribbonrules?$select=ruleid,ruletype,ruledefinition&$filter=${t}&$orderby=ruleid asc`)]);return km({diffs:n,commands:o,rules:i})}function oi(e){const t=[];for(const[n,o]of e.locLabels){const i=new DOMParser().parseFromString(o,"application/xml"),r=Array.from(i.querySelectorAll("Title")).map(l=>({languageCode:Number(l.getAttribute("languagecode")??1033),description:l.getAttribute("description")??""}));t.push({id:n,titles:r})}return t}function cs(e,t,n,o){const r=`${Ai()}.${Et(e)}.${Et(t)}.${Et(n)}`;return Di(r,o)}function ki(e,t,n){const i=`${Ai()}.${Et(e)}.${Et(t)}.Command`;return Di(i,n)}function hn(e,t,n){const i=`${Ai()}.${Et(e)}.${t}Rule`;return Di(i,n)}function ds(e){return e.replace(/\.Command$/,"").split(".").pop()||"Rule"}function Ai(){try{return ie.getState().publisherPrefix||"new"}catch{return"new"}}function Et(e){return e.replace(/[^a-zA-Z0-9._]/g,"").replace(/^[^a-zA-Z]/,"x")}function Di(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}${n}`);)n++;return`${e}${n}`}function oa(e,t,n,o,i){const r=o.replace(/[^a-zA-Z0-9_]/g,"")||"Button",l=`${e}.${t}.${n}.${r}`;let a=l;for(let c=2;i.has(`${a}.Button`)||i.has(`${a}.Command`);c++)a=`${l}${c}`;return{id:`${a}.Button`,commandId:`${a}.Command`}}function By(e){return/\s/.test(e)?"ID must not contain whitespace":e?/^[a-zA-Z]/.test(e)?null:"ID must start with a letter":"ID must not be empty"}const Z=Rt()(e=>({location:"HomepageGrid",tabId:"MainTab",selectedButtonId:null,selectedGroupId:null,setLocation(t){e({location:t,tabId:"MainTab",selectedButtonId:null,selectedGroupId:null})},setTabId(t){e({tabId:t,selectedButtonId:null,selectedGroupId:null})},selectGroup(t){e({selectedGroupId:t,selectedButtonId:null})},selectButton(t,n){e({selectedGroupId:t,selectedButtonId:n})},selectButtonInContext(t,n,o,i){e({location:t,tabId:n,selectedGroupId:o,selectedButtonId:i})},clearSelection(){e({selectedButtonId:null,selectedGroupId:null})}}));function po(e){return/\.AllEntities\./.test(e)||/\.VisualizationTab$/.test(e)}function dn(e){const t=e.filter(n=>!po(n.id));return(t.find(n=>/\.MainTab$/.test(n.id))??t[0]??e[0])?.id}const Be="Mscrm.OpenRecordItem",ia=["HomepageGrid","SubGrid"],Hp=/\.(HomepageGrid|SubGrid)\.OpenRecordItem\d*\.Button$/;function sa(e){return e.commandId===Be&&Hp.test(e.id)}function zi(e){const t=[];for(const n of e?.tabs??[])for(const o of n.groups)for(const i of je(o))i.commandId===Be&&t.push({tabId:n.id,groupId:o.id,button:i});return t}function ra(e){return zi(e).filter(t=>sa(t.button))}function aa(e){const t=e.button.origin;return t==="unmanaged"?"yours":t===void 0?"unknown":"theirs"}function la(e){const t=e?.tabs??[],n=dn(t.filter(r=>r.groups.length>0)),o=t.find(r=>r.id===n),i=o?.groups.find(r=>/\.Management$/.test(r.id))??o?.groups[0];return o&&i?{tabId:o.id,groupId:i.id}:null}function Gp(){return{id:Be,enableRules:[],displayRules:[],actions:[{kind:"javascript",library:"$webresource:",functionName:"YourNamespace.openRecord",params:[{kind:"CrmParameter",value:"SelectedControlSelectedItemReferences"}]}]}}function Wp(e){for(const t of e.actions){if(t.kind!=="javascript")continue;if(!t.library.trim().replace(/^\$webresource:/i,"").trim()||!t.functionName.trim())return`${Be} has a JavaScript action without a web resource or function — set them in the Command Editor, or turn the override off`}return null}const Up=["Mscrm.HideOnModern","Mscrm.ShowOnlyOnModern"];function en(e,t){const n=new Set;for(const o of[t,e.baseline])for(const i of Object.values(o??{}))for(const r of i.tabs){n.add(r.id);for(const l of r.groups){n.add(l.id);for(const a of je(l))n.add(a.id)}}for(const o of Object.values(e.layers??{})){for(const i of o?.containerIds??[])n.add(i);for(const i of o?.controlIds??[])n.add(i)}return n}function Jn(e,t){return e.layers[t==="Application"?"application":"entity"]?.containerIds}function Le(e){return JSON.parse(JSON.stringify(e))}function et(e){return{ribbons:e.ribbons,commands:e.commands,enableRules:e.enableRules,displayRules:e.displayRules,locLabels:e.locLabels,pendingUnhides:e.pendingUnhides,pendingOrphanDeletes:e.pendingOrphanDeletes,customisedCommandIds:e.customisedCommandIds,uncustomisedCommandIds:e.uncustomisedCommandIds}}function be(e,t,n,o,i="info"){return{ts:new Date().toISOString(),userId:"",userName:"You",op:e,target:t,detail:n,icon:o,color:i}}let Fe=null;const Xp=1e3;function $e(e,t,n,o){if(Fe)return Fe.meta||(Fe.meta=n),t;const i=e.past[e.past.length-1];if(o&&i?.coalesceKey===o&&e.future.length===0&&Date.parse(n.ts)-Date.parse(i.ts)<Xp)return{...t,past:[...e.past.slice(0,-1),{...i,...n}],mutationsSincePublish:e.mutationsSincePublish+1};const r={...n,coalesceKey:o,snapshot:et(e)};return{...t,past:[...e.past,r].slice(-80),future:[],mutationsSincePublish:e.mutationsSincePublish+1}}function ye(e,t,n,o){const i=Le(e.ribbons);return t(i),$e(e,{ribbons:i},n,o)}function Ln(e){const t=(n,o)=>JSON.stringify(n)===JSON.stringify(o);return e.pendingUnhides.entity.length+e.pendingUnhides.application.length>0||e.pendingOrphanDeletes.entity.length+e.pendingOrphanDeletes.application.length>0||e.customisedCommandIds.length>0||e.uncustomisedCommandIds.entity.length+e.uncustomisedCommandIds.application.length>0||!t(e.ribbons,e.baseline)||!t(e.commands,e.baselineCommands)||!t(e.enableRules,e.baselineEnableRules)||!t(e.displayRules,e.baselineDisplayRules)||!t(e.locLabels,e.baselineLocLabels)}function tn(e,t){const n=e.findIndex(o=>o.id===t.id);return n<0?[...e,t]:JSON.stringify(e[n])===JSON.stringify(t)?null:e.map((o,i)=>i===n?t:o)}const us={entity:null,application:null},wo={entity:[],application:[]},ms=["HomepageGrid","SubGrid","Form"];function Vp(e,t,n){return(t===void 0||e>t)&&(n===void 0||e<n)?e:t!==void 0&&n!==void 0?n-t>1?Math.floor((t+n)/2):void 0:t!==void 0?t+10:n!==void 0?n>1?Math.max(1,n-10):void 0:e}function Jp(e,t,n){let o=t;for(;o>0&&n(e[o-1]);)o--;let i=t;for(;i<e.length-1&&n(e[i+1]);)i++;const r=o>0?e[o-1].sequence:0,l=i<e.length-1?e[i+1].sequence:1/0;if(l-r-1>=i-o+1){let d=r;for(let u=o;u<=i;u++){const p=i-u,f=e[u];f.sequence>d&&f.sequence<=l-1-p||(f.sequence=l===1/0?d+10:d+Math.max(1,Math.min(10,Math.floor((l-d)/(p+2))))),d=f.sequence}return}const a=new Set(e.filter((d,u)=>u!==t).map(d=>d.sequence));let c=(t>0?e[t-1].sequence:0)+1;for(;a.has(c);)c++;e[t].sequence=c}const Io={HomepageGrid:{location:"HomepageGrid",entityLogicalName:"",tabs:[]},SubGrid:{location:"SubGrid",entityLogicalName:"",tabs:[]},Form:{location:"Form",entityLogicalName:"",tabs:[]},Application:{location:"Application",entityLogicalName:"",tabs:[]}};function Qe(e,t,n,o,i){const r=e[t].tabs.find(a=>a.id===n)?.groups.find(a=>a.id===o),l=Yt(r,i);return r&&l?{group:r,button:l}:void 0}function Pe(e,t,n){return e==="Application"&&t==="Mscrm.GlobalTab"&&n.oob===!0&&n.custom!==!0}function Bi(e,t,n){return n.origin!=="unmanaged"&&!n.hidden&&n.kind!=="flyout"&&n.kind!=="splitButton"&&!Ze(n.kind)&&!Pe(e,t,n)}function Kp(e,t,n){for(const o of e.baseline[t].tabs)for(const i of o.groups){const r=i.buttons.find(l=>l.id===n);if(r)return r}}function Yp(e,t,n){if(t.location!==n.location||t.tabId!==n.tabId||t.groupId!==n.groupId)return!1;const o=e.buttons.findIndex(r=>r.id===t.buttonId),i=e.buttons[o+1]?.id;return n.beforeButtonId?n.beforeButtonId===t.buttonId||n.beforeButtonId===i:i===void 0}const Kn=/^\$LocLabels:/;function Zp(e){if(!e)return;const t=o=>o&&!Kn.test(o)?o:void 0,n={};for(const[o,i]of Object.entries(e.attributes))o!=="Id"&&!Kn.test(i)&&(n[o]=i);return{...e,labelToken:t(e.labelToken),tooltipTitleToken:t(e.tooltipTitleToken),tooltipBodyToken:t(e.tooltipBodyToken),attributes:n}}const Ro=(e,t)=>({entity:e.entity.filter(n=>n!==t),application:e.application.filter(n=>n!==t)});function ps(e,t){const n=e.baselineCommands.find(i=>i.id===t),o=e.commands.find(i=>i.id===t);return!n||!o||JSON.stringify(n)===JSON.stringify(o)?e.commands:e.commands.map(i=>i.id===t?JSON.parse(JSON.stringify(n)):i)}const D=Rt()(gm((e,t)=>({ribbons:Le(Io),baseline:Le(Io),baselineCommands:[],baselineEnableRules:[],baselineDisplayRules:[],baselineLocLabels:[],layers:{...us},pendingUnhides:{entity:[],application:[]},orphans:{entity:[],application:[]},pendingOrphanDeletes:{entity:[],application:[]},baseLanguageCode:1033,customisedCommandIds:[],uncustomisedCommandIds:{entity:[],application:[]},reloadRequiredCommandIds:[],commands:[],displayRules:[],enableRules:[],locLabels:[],templates:[],conflicts:[],mutationsSincePublish:0,past:[],future:[],loadRibbons(n){e({ribbons:Le(n),baseline:Le(n),mutationsSincePublish:0,past:[],future:[]}),Fe&&(Fe={snapshot:et(t()),meta:null})},setConflicts(n){e({conflicts:n})},applyImport(n,o){e(i=>$e(i,{ribbons:{...i.ribbons,...Le(n.ribbons)},commands:[...n.commands],enableRules:[...n.enableRules],displayRules:[...n.displayRules],locLabels:[...n.locLabels]},be("imported","RibbonDiffXml",o,"arrow_upload","success")))},loadWorkspace(n){const o=Le(n.ribbons);e({ribbons:o,baseline:Le(o),commands:[...n.commands],displayRules:[...n.displayRules],enableRules:[...n.enableRules],baselineCommands:JSON.parse(JSON.stringify(n.commands)),baselineDisplayRules:JSON.parse(JSON.stringify(n.displayRules)),baselineEnableRules:JSON.parse(JSON.stringify(n.enableRules)),locLabels:[...n.locLabels],baselineLocLabels:JSON.parse(JSON.stringify(n.locLabels)),layers:{...us,...n.layers??{}},pendingUnhides:{...wo},orphans:{entity:[],application:[],...n.orphans??{}},pendingOrphanDeletes:{...wo},baseLanguageCode:n.baseLanguageCode??1033,customisedCommandIds:[],uncustomisedCommandIds:{entity:[],application:[]},reloadRequiredCommandIds:[],templates:[...n.templates??[]],conflicts:[...n.conflicts??[]],mutationsSincePublish:0,past:[],future:[]}),Fe&&(Fe={snapshot:et(t()),meta:null})},restoreWorkspace(n,o){const i=JSON.parse(JSON.stringify(n));e(r=>{const l=c=>{const d=r.layers[c];return d?i.pendingUnhides[c].filter(u=>d.hides.some(p=>p.location===u)):i.pendingUnhides[c]},a={...i,pendingUnhides:{entity:l("entity"),application:l("application")}};return JSON.stringify(et({...r,...a}))===JSON.stringify(et(r))?r:$e(r,a,be("restored","unsaved changes",o,"history"))})},resetWorkspace(){t().loadWorkspace({ribbons:Io,commands:[],displayRules:[],enableRules:[],locLabels:[]})},undo(){t().restore(t().past.length-1)},redo(){const n=t();if(n.future.length===0||Fe)return;const[o,...i]=n.future;e({...o.snapshot,past:[...n.past,{...o,snapshot:et(n)}],future:i,mutationsSincePublish:Ln({...n,...o.snapshot})?n.mutationsSincePublish+1:0})},restore(n){const o=t(),{past:i}=o;if(n<0||n>=i.length||Fe)return;let r=et(o),l=o.future;for(let c=i.length-1;c>=n;c--)l=[{...i[c],coalesceKey:void 0,snapshot:r},...l],r=i[c].snapshot;const a=i.length-n;e({...r,past:i.slice(0,n),future:l,mutationsSincePublish:Ln({...o,...r})?Math.max(1,o.mutationsSincePublish-a):0})},batch(n){if(Fe){n();return}Fe={snapshot:et(t()),meta:null};try{n()}finally{const{snapshot:o,meta:i}=Fe;Fe=null,i&&e(r=>({past:[...r.past,{...i,snapshot:o}].slice(-80),future:[],mutationsSincePublish:r.mutationsSincePublish+1}))}},moveButton(n,o){const i=t(),l=i.ribbons[n.location].tabs.find(p=>p.id===n.tabId)?.groups.find(p=>p.id===n.groupId),a=l?.buttons.find(p=>p.id===n.buttonId),c=i.ribbons[o.location].tabs.find(p=>p.id===o.tabId)?.groups.find(p=>p.id===o.groupId);if(!a||!l||!c)return null;const d=Kp(i,n.location,a.id)?.origin;if(d!==void 0&&d!=="unmanaged"&&!a.menu&&!Ot(a.kind)&&!Pe(n.location,n.tabId,a)){if(Yp(l,n,o))return null;const p=y=>(oe.getState().logWarn("ribbon",`Can't move ${a.id}: ${y}`),null);if(a.hidden)return p("it's hidden — move your copy of it instead.");if(n.location==="Application"!=(o.location==="Application"))return p("it isn't yours, and a copy can't move between the table's ribbon and the application ribbon.");const{activeSolution:f,publisherPrefix:S}=ie.getState(),v=f?.publisherPrefix?.trim()||S?.trim()||"new";let x=null,g=!1;return t().batch(()=>{const y=t().customiseButton(n.location,n.tabId,n.groupId,n.buttonId,v);y&&(g=!0,x=t().moveButton({...n,buttonId:y},o),oe.getState().logInfo("ribbon",`${a.id} isn't yours, so it can't be moved: moved your copy ${y} instead and hid the original.`))}),g&&!x&&t().undo(),g?x:p("it isn't yours and can't be copied (e.g. it has an override of its command); undo the override, then move it.")}return Pe(n.location,n.tabId,a)?null:(e(p=>ye(p,f=>{const S=f[n.location].tabs.find($=>$.id===n.tabId);if(!S)return;const v=S.groups.find($=>$.id===n.groupId);if(!v)return;const x=v.buttons.findIndex($=>$.id===n.buttonId);if(x===-1||Pe(n.location,n.tabId,v.buttons[x]))return;const y=(n.tabId===o.tabId&&n.location===o.location?S:f[o.location].tabs.find($=>$.id===o.tabId))?.groups.find($=>$.id===o.groupId);if(!y)return;const[C]=v.buttons.splice(x,1),w=o.beforeButtonId?y.buttons.findIndex($=>$.id===o.beforeButtonId):y.buttons.length,h=w<0?y.buttons.length:w;y.buttons.splice(h,0,C);const I=Vp(C.sequence,y.buttons[h-1]?.sequence,y.buttons[h+1]?.sequence);if(I!==void 0)C.sequence=I;else{const $=new Set(p.layers[o.location==="Application"?"application":"entity"]?.controlIds??[]),R=new Set(p.baseline[o.location].tabs.flatMap(B=>B.groups.flatMap(T=>T.buttons.map(H=>H.id))));Jp(y.buttons,h,B=>B===C||$.has(B.id)||!R.has(B.id))}},{ts:new Date().toISOString(),userId:"",userName:"You",op:"moved",target:n.buttonId,detail:`to ${o.groupId}`,icon:"arrow_move",color:"info"})),n.buttonId)},setButtonProp(n,o,i,r,l){const c=Object.values(l).every(d=>typeof d=="string")?`button:${n}:${r}:${Object.keys(l).sort().join(",")}`:void 0;e(d=>ye(d,u=>{const p=Qe(u,n,o,i,r)?.button;p&&(Pe(n,o,p)||(Object.assign(p,l),Ot(p.kind)&&!p.menu&&(p.menu=xo(p.id))))},{ts:new Date().toISOString(),userId:"",userName:"You",op:"edited",target:l.label??r,detail:Object.keys(l).join(", "),icon:"edit",color:"info"},c))},deleteButton(n,o,i,r){const l=t(),a=Qe(l.ribbons,n,o,i,r)?.button;if(a&&!In(a,l.baseline[n])){oe.getState().logWarn("ribbon",`"${a.label}" (${r}) was not deleted: only your own buttons can be deleted — hide it instead.`);return}e(c=>ye(c,d=>{const u=Qe(d,n,o,i,r);if(!u)return;const{group:p,button:f}=u;Pe(n,o,f)||Fr(p,r)||(p.buttons=p.buttons.filter(S=>S.id!==r))},{ts:new Date().toISOString(),userId:"",userName:"You",op:"deleted",target:r,detail:i,icon:"delete",color:"danger"}))},addMenuItem({location:n,tabId:o,groupId:i,parentId:r,sectionId:l,item:a}){e(c=>ye(c,d=>{const u=Qe(d,n,o,i,r)?.button;if(!u||Pe(n,o,u))return;u.menu=u.menu??xo(u.id),u.menu.sections.length===0&&u.menu.sections.push(Vo(u.id,[]));const p=u.menu.sections.find(S=>S.id===l)??u.menu.sections[0],f=p.controls[p.controls.length-1]?.sequence??0;p.controls.push({...a,kind:a.kind??"button",sequence:a.sequence??f+10,templateAlias:a.templateAlias??"",hidden:!1,oob:!1,custom:!0,managed:!1,origin:"unmanaged"})},{ts:new Date().toISOString(),userId:"",userName:"You",op:"added",target:a.label,detail:`menu of ${r}`,icon:"add",color:"success"}))},addMenuSection(n,o,i,r,l){e(a=>ye(a,c=>{const d=Qe(c,n,o,i,r)?.button;!d||Pe(n,o,d)||(d.menu=d.menu??{id:`${d.id}.Menu`,sections:[]},d.menu.sections.push(Vo(d.id,d.menu.sections,l)))},{ts:new Date().toISOString(),userId:"",userName:"You",op:"added",target:l??"Menu section",detail:`menu of ${r}`,icon:"add",color:"success"}))},setMenuSectionProp(n,o,i,r,l,a){e(c=>ye(c,d=>{const u=Qe(d,n,o,i,r)?.button,p=u?.menu?.sections.find(f=>f.id===l);!u||!p||Pe(n,o,u)||Object.assign(p,a)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"edited",target:l,detail:Object.keys(a).join(", "),icon:"edit",color:"info"}))},deleteMenuSection(n,o,i,r,l){e(a=>ye(a,c=>{const d=Qe(c,n,o,i,r)?.button;!d?.menu||Pe(n,o,d)||(d.menu.sections=d.menu.sections.filter(u=>u.id!==l))},{ts:new Date().toISOString(),userId:"",userName:"You",op:"deleted",target:l,detail:`menu of ${r}`,icon:"delete",color:"danger"}))},duplicateButton(n,o,i,r){e(l=>ye(l,a=>{const c=Qe(a,n,o,i,r);if(c){const{group:d,button:u}=c;if(Pe(n,o,u))return;const p=Ii(u.source?.labelToken),f={...Un(u,`${u.id}_copy_${Date.now()}`),label:Ze(u.kind)||p?u.label:`${u.label} (copy)`,sequence:u.sequence+5},S=Wn(d,r),v=S?S.section.controls:d.buttons,x=v.findIndex(g=>g.id===r);v.splice(x+1,0,f)}},{ts:new Date().toISOString(),userId:"",userName:"You",op:"duplicated",target:r,detail:i,icon:"copy",color:"info"}))},createButton({tabId:n,groupId:o,location:i,button:r}){e(l=>ye(l,a=>{const d=a[i].tabs.find(u=>u.id===n)?.groups.find(u=>u.id===o);if(d){const u=new Set(d.buttons.map(v=>v.sequence)),p=Math.max(0,...d.buttons.map(v=>v.sequence))+10,f=r.sequence!==void 0&&!u.has(r.sequence)?r.sequence:p,S={...r,id:r.id??`new_${Date.now()}`,label:r.label??"New Button",kind:r.kind??"button",sequence:f,templateAlias:r.templateAlias??"o1",commandId:r.commandId??"",hidden:r.hidden??!1,oob:!1,custom:!0,managed:!1,origin:"unmanaged"};Ot(S.kind)&&!S.menu&&(S.menu=xo(S.id)),d.buttons.push(S)}},{ts:new Date().toISOString(),userId:"",userName:"You",op:"added",target:r.label??"New Button",detail:o,icon:"add",color:"success"}))},createGroup({tabId:n,location:o,group:i}){e(r=>ye(r,l=>{const a=l[o].tabs.find(c=>c.id===n);if(a){const c=l[o],d=o==="Application"?"global":c.entityLogicalName,u={id:i.id??cs(d,`${o}.${i.label??"New Group"}`,"Group",en(r,l)),label:i.label??"New Group",sequence:i.sequence!==void 0&&!a.groups.some(p=>p.sequence===i.sequence)?i.sequence:Math.max(0,...a.groups.map(p=>p.sequence))+10,template:i.template??"Flexible2",buttons:i.buttons??[]};a.groups.push(u)}},{ts:new Date().toISOString(),userId:"",userName:"You",op:"added",target:i.label??"New Group",detail:n,icon:"add",color:"success"}))},renameGroup(n,o,i,r){e(l=>ye(l,a=>{const d=a[n].tabs.find(u=>u.id===o)?.groups.find(u=>u.id===i);d&&(d.label=r)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"renamed",target:i,detail:r,icon:"edit",color:"info"}))},duplicateGroup(n,o,i){e(r=>ye(r,l=>{const a=l[n].tabs.find(f=>f.id===o);if(!a)return;const c=a.groups.find(f=>f.id===i);if(!c)return;const d=`_copy_${Date.now()}`,u={...JSON.parse(JSON.stringify(c)),id:`${c.id}${d}`,label:`${c.label} (copy)`,source:void 0,description:void 0,sequence:c.sequence+5,buttons:c.buttons.map(f=>Un(f,`${f.id}${d}`))},p=a.groups.findIndex(f=>f.id===i);a.groups.splice(p+1,0,u)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"duplicated",target:i,detail:o,icon:"copy",color:"info"}))},setGroupTemplate(n,o,i,r){e(l=>ye(l,a=>{const d=a[n].tabs.find(u=>u.id===o)?.groups.find(u=>u.id===i);d&&(d.template=r)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"edited",target:i,detail:`template → ${r}`,icon:"edit",color:"info"}))},deleteGroup(n,o,i){const r=t(),l=r.ribbons[n].tabs.find(a=>a.id===o)?.groups.find(a=>a.id===i);if(l&&!$i(l,r.baseline[n],Jn(r,n))){oe.getState().logWarn("ribbon",`Group "${l.label}" (${i}) was not deleted: only your own groups, with only your own buttons in them, can be deleted — hide its buttons instead.`);return}e(a=>ye(a,c=>{const d=c[n].tabs.find(u=>u.id===o);d&&(d.groups=d.groups.filter(u=>u.id!==i))},{ts:new Date().toISOString(),userId:"",userName:"You",op:"deleted",target:i,detail:o,icon:"delete",color:"danger"}))},createTab(n,o){e(i=>o.id&&en(i,i.ribbons).has(o.id)?{}:ye(i,r=>{const l=r[n],a=n==="Application"?"global":l.entityLogicalName,c=o.id??cs(a,`${n}.${o.label??"New Tab"}`,"Tab",en(i,r)),d=qr({...o,id:c}),u={id:c,label:o.label??"New Tab",sequence:o.sequence!==void 0&&!l.tabs.some(p=>p.sequence===o.sequence)?o.sequence:Math.max(0,...l.tabs.map(p=>p.sequence))+10,commandId:d,tabDisplayRules:o.tabDisplayRules?.length?o.tabDisplayRules:Hr(n,l.entityLogicalName,d),groups:[]};l.tabs.push(u)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"added",target:o.label??"New Tab",detail:n,icon:"add",color:"success"}))},renameTab(n,o,i){e(r=>ye(r,l=>{const a=l[n].tabs.find(c=>c.id===o);a&&(a.label=i)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"renamed",target:o,detail:i,icon:"edit",color:"info"}))},deleteTab(n,o){const i=t(),r=i.ribbons[n].tabs.find(l=>l.id===o);if(r&&!ea(r,i.baseline[n],Jn(i,n))){oe.getState().logWarn("ribbon",`Tab "${r.label}" (${o}) was not deleted: only your own tabs, with only your own groups and buttons in them, can be deleted.`);return}e(l=>ye(l,a=>{a[n].tabs=a[n].tabs.filter(c=>c.id!==o)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"deleted",target:o,detail:n,icon:"delete",color:"danger"}))},reorderTabs(n,o){e(i=>ye(i,r=>{const l=r[n].tabs;r[n].tabs=o.map(a=>l.find(c=>c.id===a)).filter(a=>a!==void 0)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"reordered",target:"Tabs",detail:n,icon:"arrow_sort",color:"info"}))},setTabDisplayRules(n,o,i){e(r=>ye(r,l=>{const a=l[n].tabs.find(c=>c.id===o);a&&(a.tabDisplayRules=i)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"edited",target:`${o} display rules`,detail:`${i.length} rule(s)`,icon:"eye",color:"info"}))},setScaling(n,o,i){e(r=>ye(r,l=>{const a=l[n];a.scalingByTab=a.scalingByTab??{},a.scalingByTab[o]={tabId:o,maxSizes:[...i.maxSizes],scales:[...i.scales]}},{ts:new Date().toISOString(),userId:"",userName:"You",op:"edited",target:`${o} scaling`,detail:`${i.maxSizes.length} MaxSize, ${i.scales.length} Scale`,icon:"resize",color:"info"}))},hideOobButton(n,o,i,r){e(l=>ye(l,a=>{const c=Qe(a,n,o,i,r)?.button;c&&(Pe(n,o,c)||(c.hidden=!0))},{ts:new Date().toISOString(),userId:"",userName:"You",op:"hid",target:r,detail:i,icon:"eye_off",color:"warn"}))},customizeOobButton(n,o,i,r){e(l=>ye(l,a=>{const c=Qe(a,n,o,i,r)?.button;if(c){if(Pe(n,o,c))return;c.oob=!1,c.custom=!0,c.managed=!1,c.origin="unmanaged"}},{ts:new Date().toISOString(),userId:"",userName:"You",op:"customized",target:r,detail:"OOB override",icon:"edit",color:"info"}))},customiseButton(n,o,i,r,l){const a=t(),c=a.ribbons[n].tabs.find(g=>g.id===o)?.groups.find(g=>g.id===i)?.buttons.find(g=>g.id===r);if(!c||!Bi(n,o,c))return null;const d=en(a,a.ribbons),u=`${(l||"new").trim()}.${c.id}`;let p=u;for(let g=2;d.has(p);g++)p=`${u}.${g}`;const f=[],S=[],v=[[c.source?.labelToken,so(p)],[c.source?.tooltipTitleToken,ro(p)],[c.source?.tooltipBodyToken,ao(p)]];for(const[g,y]of v){if(!g||!Kn.test(g))continue;const C=a.locLabels.find(w=>w.id===g.replace(Kn,""));C?f.push({id:y,titles:C.titles.map(w=>({...w}))}):S.push(g)}S.length>0&&oe.getState().logWarn("ribbon",`Customise button ${c.id}: the translations of ${S.join(", ")} aren't loaded, so the copy ${p} gets its text in the base language only. Add the other languages in the Localization editor.`);const x=new Set(f.map(g=>g.id));return e(g=>{const y=Le(g.ribbons),C=y[n].tabs.find(R=>R.id===o)?.groups.find(R=>R.id===i),w=C?.buttons.findIndex(R=>R.id===r)??-1;if(!C||w<0)return{};const h=C.buttons[w],I={...h,id:p,source:Zp(h.source),hidden:!1,custom:!0,oob:!1,managed:!1,origin:"unmanaged",solutionName:void 0,publisherName:void 0},$=C.buttons[w+1]?.sequence;return($===void 0||h.sequence+1<$)&&(I.sequence=h.sequence+1),h.hidden=!0,C.buttons.splice(w+1,0,I),$e(g,{ribbons:y,...f.length>0?{locLabels:[...g.locLabels.filter(R=>!x.has(R.id)),...f]}:{}},be("customised",r,`copied to ${p}, original hidden`+(S.length>0?" (translations not loaded: base language only)":""),"copy"))}),p},customiseCommand(n){const o=t();return!o.commands.some(i=>i.id===n)||o.reloadRequiredCommandIds.includes(n)?!1:(e(i=>$e(i,{customisedCommandIds:[...i.customisedCommandIds.filter(r=>r!==n),n],uncustomisedCommandIds:Ro(i.uncustomisedCommandIds,n)},be("customised",n,"command copied to your layer on publish","code"))),!0)},uncustomiseCommand(n,o){e(i=>$e(i,{commands:ps(i,n),customisedCommandIds:i.customisedCommandIds.filter(r=>r!==n),uncustomisedCommandIds:{...Ro(i.uncustomisedCommandIds,n),[o]:[...i.uncustomisedCommandIds[o].filter(r=>r!==n),n]}},be("uncustomised",n,`command removed from the ${o==="entity"?"table's":"application ribbon's"} layer on publish`,"arrow_undo")))},discardCommandChanges(n){const o=t(),i=ps(o,n);(i!==o.commands||o.customisedCommandIds.includes(n)||o.uncustomisedCommandIds.entity.includes(n)||o.uncustomisedCommandIds.application.includes(n))&&e(l=>$e(l,{commands:i,customisedCommandIds:l.customisedCommandIds.filter(a=>a!==n),uncustomisedCommandIds:Ro(l.uncustomisedCommandIds,n)},be("discarded",n,"command changes","arrow_undo")))},setOpenRecordOverride(n,o,i){if(!ia.includes(n))return!1;const r=t(),l=r.ribbons[n],a=ra(l);if(o){if(a.length>0)return!0;const c=la(l);if(!c)return!1;const d=en(r,r.ribbons);for(const p of r.commands)d.add(p.id);const{id:u}=oa(i,l.entityLogicalName,n,"OpenRecordItem",d);return t().batch(()=>{t().createButton({location:n,tabId:c.tabId,groupId:c.groupId,button:{id:u,label:"Open record",tooltipTitle:"Open record",tooltipBody:`Runs the table's ${Be} action for the selected row, as opening a row does.`,kind:"button",templateAlias:"o1",commandId:Be,hidden:!1,oob:!1,custom:!0,managed:!1}}),t().commands.some(p=>p.id===Be)||t().upsertCommand(Gp())}),!0}return a.length===0?!0:a.some(c=>aa(c)!=="yours")?!1:(t().batch(()=>{for(const u of a)t().deleteButton(n,u.tabId,u.groupId,u.button.id);const c=t();!Object.values(c.ribbons).some(u=>zi(u).length>0)&&!c.baselineCommands.some(u=>u.id===Be)&&e(u=>$e(u,{commands:u.commands.filter(p=>p.id!==Be)},be("removed",Be,"grid open override","delete","danger")))}),!0)},hideWithDisplayRules(n){const o=n?t().commands.find(r=>r.id===n):void 0;if(!o)return!1;const i=[...o.displayRules];for(const r of Up)i.includes(r)||i.push(r);return e(r=>{const l=tn(r.commands,{...o,displayRules:i});return l?$e(r,{commands:l},be("hid",o.id,"with display rules","eye_off","warn")):r}),!0},upsertCommand(n){e(o=>{const i=tn(o.commands,n);if(!i)return o;const r=i.length>o.commands.length;return $e(o,{commands:i},r?be("added",n.id,"command","add","success"):be("edited",n.id,"command","edit"),r?void 0:`command:${n.id}`)})},renameCommandId(n,o){const i=t();return!n||!o||n===o?!0:i.commands.some(r=>r.id===o)?!1:(e(r=>{const l=Le(r.ribbons);for(const c of Object.keys(l))for(const d of l[c].tabs)for(const u of d.groups)for(const p of je(u))p.commandId===n&&(p.commandId=o),p.source?.xml&&(p.source.xml=$m(p.source.xml,n,o));const a=r.commands.map(c=>c.id===n?{...c,id:o}:c);return $e(r,{ribbons:l,commands:a},be("renamed",n,`command -> ${o}`,"edit"))}),!0)},upsertDisplayRule(n){e(o=>{const i=tn(o.displayRules,n);if(!i)return o;const r=i.length>o.displayRules.length;return $e(o,{displayRules:i},r?be("added",n.id,"display rule","add","success"):be("edited",n.id,"display rule","edit"),r?void 0:`displayRule:${n.id}`)})},renameDisplayRuleId(n,o){const i=t();return!n||!o||n===o?!0:i.displayRules.some(r=>r.id===o)?!1:(e(r=>{const l=r.displayRules.map(c=>c.id===n?{...c,id:o}:c),a=r.commands.map(c=>({...c,displayRules:c.displayRules.map(d=>d===n?o:d)}));return $e(r,{displayRules:l,commands:a},be("renamed",n,`display rule -> ${o}`,"edit"))}),!0)},upsertEnableRule(n){e(o=>{const i=tn(o.enableRules,n);if(!i)return o;const r=i.length>o.enableRules.length;return $e(o,{enableRules:i},r?be("added",n.id,"enable rule","add","success"):be("edited",n.id,"enable rule","edit"),r?void 0:`enableRule:${n.id}`)})},renameEnableRuleId(n,o){const i=t();return!n||!o||n===o?!0:i.enableRules.some(r=>r.id===o)?!1:(e(r=>{const l=r.enableRules.map(c=>c.id===n?{...c,id:o}:c),a=r.commands.map(c=>({...c,enableRules:c.enableRules.map(d=>d===n?o:d)}));return $e(r,{enableRules:l,commands:a},be("renamed",n,`enable rule -> ${o}`,"edit"))}),!0)},upsertLocLabel(n){e(o=>{const i=tn(o.locLabels,n);return i?$e(o,{locLabels:i},be("edited",n.id,"label","translate"),`locLabel:${n.id}`):o})},setLayerHideUnhidden(n,o,i){e(r=>{if(r.pendingUnhides[n].includes(o)===i)return r;const l=r.pendingUnhides[n].filter(a=>a!==o);return i&&l.push(o),$e(r,{pendingUnhides:{...r.pendingUnhides,[n]:l}},i?be("un-hid",o,"on publish","eye"):be("kept hidden",o,"by customizations","eye_off"))})},setOrphanDeleted(n,o,i){e(r=>{const l=r.orphans[n].find(c=>c.id===o);if(!l||i&&l.recentPublish?.published||r.pendingOrphanDeletes[n].includes(o)===i)return r;const a=r.pendingOrphanDeletes[n].filter(c=>c!==o);return i&&a.push(o),$e(r,{pendingOrphanDeletes:{...r.pendingOrphanDeletes,[n]:a}},i?be("deleted",o,"not on the canvas — removed on publish","delete","danger"):be("kept",o,"not on the canvas","arrow_undo"))})},setLayerSnapshot(n,o){e(i=>({layers:{...i.layers,[n]:o}}))},markPublished(n,o){e(i=>{const r=Object.keys(i.ribbons),l=n??r,a=Le(i.baseline),c=Le(i.ribbons);let d=i.locLabels,u=i.baselineLocLabels;const p=(j,E)=>[...j.filter(N=>!E.some(W=>W.id===N.id)),...E];for(const[j,E]of Object.entries(o??{})){const N=j==="entity"?ms:["Application"];for(const U of N)l.includes(U)&&Fm(c[U],E);const W=oi(E);d=p(d,W),u=p(u,JSON.parse(JSON.stringify(W)))}for(const j of l)a[j]=Le(c)[j];const f=r.every(j=>l.includes(j)),S={...i.layers},v={...i.pendingUnhides},x={entity:[],application:[]},g=[["entity",ms.every(j=>l.includes(j))],["application",l.includes("Application")]];for(const[j,E]of g){const N=o?.[j];if(!E||!N)continue;const W=S[j],U=(V,ee)=>[...new Set([...V,...ee])];S[j]=W?{...W,containerIds:U(W.containerIds,Er(N)),controlIds:U(W.controlIds,Gn(N))}:Vn(N)}for(const[j,E]of g){if(!E||v[j].length===0)continue;const N=S[j];N&&(S[j]={...N,hides:N.hides.filter(W=>!v[j].includes(W.location))}),x[j]=v[j],v[j]=[]}const y={...i.orphans},C={...i.pendingOrphanDeletes},w={entity:[],application:[]};for(const[j,E]of g)!E||C[j].length===0||(y[j]=y[j].filter(N=>!C[j].includes(N.id)),w[j]=C[j],C[j]=[]);const h={...i.uncustomisedCommandIds},I=[...i.reloadRequiredCommandIds],$={entity:[],application:[]};for(const[j,E]of g)if(E){for(const N of h[j])I.includes(N)||I.push(N);$[j]=h[j],h[j]=[]}const R=(j,E)=>({entity:j.entity.filter(N=>!E.entity.includes(N)),application:j.application.filter(N=>!E.application.includes(N))}),B=j=>({...j,snapshot:{...j.snapshot,pendingUnhides:R(j.snapshot.pendingUnhides,x),pendingOrphanDeletes:R(j.snapshot.pendingOrphanDeletes??wo,w),uncustomisedCommandIds:R(j.snapshot.uncustomisedCommandIds,$)}}),T=[x,$,w].reduce((j,E)=>j+E.entity.length+E.application.length,0)>0,H=i.past.map((j,E)=>{const N=T?B(j):j;return E===i.past.length-1&&N.coalesceKey?{...N,coalesceKey:void 0}:N}),k={ribbons:c,locLabels:d,baselineLocLabels:u,baseline:a,layers:S,pendingUnhides:v,uncustomisedCommandIds:h,orphans:y,pendingOrphanDeletes:C,...f?{baselineCommands:JSON.parse(JSON.stringify(i.commands)),baselineEnableRules:JSON.parse(JSON.stringify(i.enableRules)),baselineDisplayRules:JSON.parse(JSON.stringify(i.displayRules)),baselineLocLabels:JSON.parse(JSON.stringify(d)),customisedCommandIds:[]}:{}},P=Ln({...i,...k});return{...k,past:H,future:T?i.future.map(B):i.future,reloadRequiredCommandIds:I,mutationsSincePublish:P?Math.max(1,i.mutationsSincePublish):0}})}})));fm(()=>{D.getState().resetWorkspace(),Z.getState().clearSelection()});var xe=Uint8Array,qe=Uint16Array,Oi=Int32Array,fo=new xe([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ho=new xe([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ii=new xe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ca=function(e,t){for(var n=new qe(31),o=0;o<31;++o)n[o]=t+=1<<e[o-1];for(var i=new Oi(n[30]),o=1;o<30;++o)for(var r=n[o];r<n[o+1];++r)i[r]=r-n[o]<<5|o;return{b:n,r:i}},da=ca(fo,2),ua=da.b,si=da.r;ua[28]=258,si[258]=28;var ma=ca(ho,0),Qp=ma.b,fs=ma.r,ri=new qe(32768);for(var fe=0;fe<32768;++fe){var ut=(fe&43690)>>1|(fe&21845)<<1;ut=(ut&52428)>>2|(ut&13107)<<2,ut=(ut&61680)>>4|(ut&3855)<<4,ri[fe]=((ut&65280)>>8|(ut&255)<<8)>>1}var ot=(function(e,t,n){for(var o=e.length,i=0,r=new qe(t);i<o;++i)e[i]&&++r[e[i]-1];var l=new qe(t);for(i=1;i<t;++i)l[i]=l[i-1]+r[i-1]<<1;var a;if(n){a=new qe(1<<t);var c=15-t;for(i=0;i<o;++i)if(e[i])for(var d=i<<4|e[i],u=t-e[i],p=l[e[i]-1]++<<u,f=p|(1<<u)-1;p<=f;++p)a[ri[p]>>c]=d}else for(a=new qe(o),i=0;i<o;++i)e[i]&&(a[i]=ri[l[e[i]-1]++]>>15-e[i]);return a}),bt=new xe(288);for(var fe=0;fe<144;++fe)bt[fe]=8;for(var fe=144;fe<256;++fe)bt[fe]=9;for(var fe=256;fe<280;++fe)bt[fe]=7;for(var fe=280;fe<288;++fe)bt[fe]=8;var gn=new xe(32);for(var fe=0;fe<32;++fe)gn[fe]=5;var ef=ot(bt,9,0),tf=ot(bt,9,1),nf=ot(gn,5,0),of=ot(gn,5,1),jo=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Xe=function(e,t,n){var o=t/8|0;return(e[o]|e[o+1]<<8)>>(t&7)&n},No=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Ei=function(e){return(e+7)/8|0},Rn=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new xe(e.subarray(t,n))},sf=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ze=function(e,t,n){var o=new Error(t||sf[e]);if(o.code=e,Error.captureStackTrace&&Error.captureStackTrace(o,ze),!n)throw o;return o},rf=function(e,t,n,o){var i=e.length,r=o?o.length:0;if(!i||t.f&&!t.l)return n||new xe(0);var l=!n,a=l||t.i!=2,c=t.i;l&&(n=new xe(i*3));var d=function(He){var z=n.length;if(He>z){var G=new xe(Math.max(z*2,He));G.set(n),n=G}},u=t.f||0,p=t.p||0,f=t.b||0,S=t.l,v=t.d,x=t.m,g=t.n,y=i*8;do{if(!S){u=Xe(e,p,1);var C=Xe(e,p+1,3);if(p+=3,C)if(C==1)S=tf,v=of,x=9,g=5;else if(C==2){var $=Xe(e,p,31)+257,R=Xe(e,p+10,15)+4,B=$+Xe(e,p+5,31)+1;p+=14;for(var T=new xe(B),H=new xe(19),k=0;k<R;++k)H[ii[k]]=Xe(e,p+k*3,7);p+=R*3;for(var P=jo(H),j=(1<<P)-1,E=ot(H,P,1),k=0;k<B;){var N=E[Xe(e,p,j)];p+=N&15;var w=N>>4;if(w<16)T[k++]=w;else{var W=0,U=0;for(w==16?(U=3+Xe(e,p,3),p+=2,W=T[k-1]):w==17?(U=3+Xe(e,p,7),p+=3):w==18&&(U=11+Xe(e,p,127),p+=7);U--;)T[k++]=W}}var V=T.subarray(0,$),ee=T.subarray($);x=jo(V),g=jo(ee),S=ot(V,x,1),v=ot(ee,g,1)}else ze(1);else{var w=Ei(p)+4,h=e[w-4]|e[w-3]<<8,I=w+h;if(I>i){c&&ze(0);break}a&&d(f+h),n.set(e.subarray(w,I),f),t.b=f+=h,t.p=p=I*8,t.f=u;continue}if(p>y){c&&ze(0);break}}a&&d(f+131072);for(var _=(1<<x)-1,L=(1<<g)-1,O=p;;O=p){var W=S[No(e,p)&_],F=W>>4;if(p+=W&15,p>y){c&&ze(0);break}if(W||ze(2),F<256)n[f++]=F;else if(F==256){O=p,S=null;break}else{var b=F-254;if(F>264){var k=F-257,A=fo[k];b=Xe(e,p,(1<<A)-1)+ua[k],p+=A}var X=v[No(e,p)&L],re=X>>4;X||ze(3),p+=X&15;var ee=Qp[re];if(re>3){var A=ho[re];ee+=No(e,p)&(1<<A)-1,p+=A}if(p>y){c&&ze(0);break}a&&d(f+131072);var me=f+b;if(f<ee){var Ee=r-ee,Ce=Math.min(ee,me);for(Ee+f<0&&ze(3);f<Ce;++f)n[f]=o[Ee+f]}for(;f<me;++f)n[f]=n[f-ee]}}t.l=S,t.p=O,t.b=f,t.f=u,S&&(u=1,t.m=x,t.d=v,t.n=g)}while(!u);return f!=n.length&&l?Rn(n,0,f):n.subarray(0,f)},it=function(e,t,n){n<<=t&7;var o=t/8|0;e[o]|=n,e[o+1]|=n>>8},nn=function(e,t,n){n<<=t&7;var o=t/8|0;e[o]|=n,e[o+1]|=n>>8,e[o+2]|=n>>16},$o=function(e,t){for(var n=[],o=0;o<e.length;++o)e[o]&&n.push({s:o,f:e[o]});var i=n.length,r=n.slice();if(!i)return{t:fa,l:0};if(i==1){var l=new xe(n[0].s+1);return l[n[0].s]=1,{t:l,l:1}}n.sort(function(I,$){return I.f-$.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],d=0,u=1,p=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};u!=i-1;)a=n[n[d].f<n[p].f?d++:p++],c=n[d!=u&&n[d].f<n[p].f?d++:p++],n[u++]={s:-1,f:a.f+c.f,l:a,r:c};for(var f=r[0].s,o=1;o<i;++o)r[o].s>f&&(f=r[o].s);var S=new qe(f+1),v=ai(n[u-1],S,0);if(v>t){var o=0,x=0,g=v-t,y=1<<g;for(r.sort(function($,R){return S[R.s]-S[$.s]||$.f-R.f});o<i;++o){var C=r[o].s;if(S[C]>t)x+=y-(1<<v-S[C]),S[C]=t;else break}for(x>>=g;x>0;){var w=r[o].s;S[w]<t?x-=1<<t-S[w]++-1:++o}for(;o>=0&&x;--o){var h=r[o].s;S[h]==t&&(--S[h],++x)}v=t}return{t:new xe(S),l:v}},ai=function(e,t,n){return e.s==-1?Math.max(ai(e.l,t,n+1),ai(e.r,t,n+1)):t[e.s]=n},hs=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new qe(++t),o=0,i=e[0],r=1,l=function(c){n[o++]=c},a=1;a<=t;++a)if(e[a]==i&&a!=t)++r;else{if(!i&&r>2){for(;r>138;r-=138)l(32754);r>2&&(l(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(l(i),--r;r>6;r-=6)l(8304);r>2&&(l(r-3<<5|8208),r=0)}for(;r--;)l(i);r=1,i=e[a]}return{c:n.subarray(0,o),n:t}},on=function(e,t){for(var n=0,o=0;o<t.length;++o)n+=e[o]*t[o];return n},pa=function(e,t,n){var o=n.length,i=Ei(t+2);e[i]=o&255,e[i+1]=o>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var r=0;r<o;++r)e[i+r+4]=n[r];return(i+4+o)*8},gs=function(e,t,n,o,i,r,l,a,c,d,u){it(t,u++,n),++i[256];for(var p=$o(i,15),f=p.t,S=p.l,v=$o(r,15),x=v.t,g=v.l,y=hs(f),C=y.c,w=y.n,h=hs(x),I=h.c,$=h.n,R=new qe(19),B=0;B<C.length;++B)++R[C[B]&31];for(var B=0;B<I.length;++B)++R[I[B]&31];for(var T=$o(R,7),H=T.t,k=T.l,P=19;P>4&&!H[ii[P-1]];--P);var j=d+5<<3,E=on(i,bt)+on(r,gn)+l,N=on(i,f)+on(r,x)+l+14+3*P+on(R,H)+2*R[16]+3*R[17]+7*R[18];if(c>=0&&j<=E&&j<=N)return pa(t,u,e.subarray(c,c+d));var W,U,V,ee;if(it(t,u,1+(N<E)),u+=2,N<E){W=ot(f,S,0),U=f,V=ot(x,g,0),ee=x;var _=ot(H,k,0);it(t,u,w-257),it(t,u+5,$-1),it(t,u+10,P-4),u+=14;for(var B=0;B<P;++B)it(t,u+3*B,H[ii[B]]);u+=3*P;for(var L=[C,I],O=0;O<2;++O)for(var F=L[O],B=0;B<F.length;++B){var b=F[B]&31;it(t,u,_[b]),u+=H[b],b>15&&(it(t,u,F[B]>>5&127),u+=F[B]>>12)}}else W=ef,U=bt,V=nf,ee=gn;for(var B=0;B<a;++B){var A=o[B];if(A>255){var b=A>>18&31;nn(t,u,W[b+257]),u+=U[b+257],b>7&&(it(t,u,A>>23&31),u+=fo[b]);var X=A&31;nn(t,u,V[X]),u+=ee[X],X>3&&(nn(t,u,A>>5&8191),u+=ho[X])}else nn(t,u,W[A]),u+=U[A]}return nn(t,u,W[256]),u+U[256]},af=new Oi([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),fa=new xe(0),lf=function(e,t,n,o,i,r){var l=r.z||e.length,a=new xe(o+l+5*(1+Math.ceil(l/7e3))+i),c=a.subarray(o,a.length-i),d=r.l,u=(r.r||0)&7;if(t){u&&(c[0]=r.r>>3);for(var p=af[t-1],f=p>>13,S=p&8191,v=(1<<n)-1,x=r.p||new qe(32768),g=r.h||new qe(v+1),y=Math.ceil(n/3),C=2*y,w=function(te){return(e[te]^e[te+1]<<y^e[te+2]<<C)&v},h=new Oi(25e3),I=new qe(288),$=new qe(32),R=0,B=0,T=r.i||0,H=0,k=r.w||0,P=0;T+2<l;++T){var j=w(T),E=T&32767,N=g[j];if(x[E]=N,g[j]=E,k<=T){var W=l-T;if((R>7e3||H>24576)&&(W>423||!d)){u=gs(e,c,0,h,I,$,B,H,P,T-P,u),H=R=B=0,P=T;for(var U=0;U<286;++U)I[U]=0;for(var U=0;U<30;++U)$[U]=0}var V=2,ee=0,_=S,L=E-N&32767;if(W>2&&j==w(T-L))for(var O=Math.min(f,W)-1,F=Math.min(32767,T),b=Math.min(258,W);L<=F&&--_&&E!=N;){if(e[T+V]==e[T+V-L]){for(var A=0;A<b&&e[T+A]==e[T+A-L];++A);if(A>V){if(V=A,ee=L,A>O)break;for(var X=Math.min(L,A-2),re=0,U=0;U<X;++U){var me=T-L+U&32767,Ee=x[me],Ce=me-Ee&32767;Ce>re&&(re=Ce,N=me)}}}E=N,N=x[E],L+=E-N&32767}if(ee){h[H++]=268435456|si[V]<<18|fs[ee];var He=si[V]&31,z=fs[ee]&31;B+=fo[He]+ho[z],++I[257+He],++$[z],k=T+V,++R}else h[H++]=e[T],++I[e[T]]}}for(T=Math.max(T,k);T<l;++T)h[H++]=e[T],++I[e[T]];u=gs(e,c,d,h,I,$,B,H,P,T-P,u),d||(r.r=u&7|c[u/8|0]<<3,u-=7,r.h=g,r.p=x,r.i=T,r.w=k)}else{for(var T=r.w||0;T<l+d;T+=65535){var G=T+65535;G>=l&&(c[u/8|0]=d,G=l),u=pa(c,u+1,e.subarray(T,G))}r.i=l}return Rn(a,0,o+Ei(u)+i)},cf=(function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,o=9;--o;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e})(),df=function(){var e=-1;return{p:function(t){for(var n=e,o=0;o<t.length;++o)n=cf[n&255^t[o]]^n>>>8;e=n},d:function(){return~e}}},uf=function(e,t,n,o,i){if(!i&&(i={l:1},t.dictionary)){var r=t.dictionary.subarray(-32768),l=new xe(r.length+e.length);l.set(r),l.set(e,r.length),e=l,i.w=r.length}return lf(e,t.level==null?6:t.level,t.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,o,i)},ha=function(e,t){var n={};for(var o in e)n[o]=e[o];for(var o in t)n[o]=t[o];return n},tt=function(e,t){return e[t]|e[t+1]<<8},We=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},To=function(e,t){return We(e,t)+We(e,t+4)*4294967296},Ae=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function ga(e,t){return uf(e,t||{},0,0)}function ba(e,t){return rf(e,{i:2},t&&t.out,t&&t.dictionary)}var ya=function(e,t,n,o){for(var i in e){var r=e[i],l=t+i,a=o;Array.isArray(r)&&(a=ha(o,r[1]),r=r[0]),ArrayBuffer.isView(r)?n[l]=[r,a]:(n[l+="/"]=[new xe(0),a],ya(r,l,n,o))}},bs=typeof TextEncoder<"u"&&new TextEncoder,li=typeof TextDecoder<"u"&&new TextDecoder,mf=0;try{li.decode(fa,{stream:!0}),mf=1}catch{}var pf=function(e){for(var t="",n=0;;){var o=e[n++],i=(o>127)+(o>223)+(o>239);if(n+i>e.length)return{s:t,r:Rn(e,n-1)};i?i==3?(o=((o&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|o>>10,56320|o&1023)):i&1?t+=String.fromCharCode((o&31)<<6|e[n++]&63):t+=String.fromCharCode((o&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(o)}};function Yn(e,t){if(t){for(var n=new xe(e.length),o=0;o<e.length;++o)n[o]=e.charCodeAt(o);return n}if(bs)return bs.encode(e);for(var i=e.length,r=new xe(e.length+(e.length>>1)),l=0,a=function(u){r[l++]=u},o=0;o<i;++o){if(l+5>r.length){var c=new xe(l+8+(i-o<<1));c.set(r),r=c}var d=e.charCodeAt(o);d<128||t?a(d):d<2048?(a(192|d>>6),a(128|d&63)):d>55295&&d<57344?(d=65536+(d&1047552)|e.charCodeAt(++o)&1023,a(240|d>>18),a(128|d>>12&63),a(128|d>>6&63),a(128|d&63)):(a(224|d>>12),a(128|d>>6&63),a(128|d&63))}return Rn(r,0,l)}function bn(e,t){if(t){for(var n="",o=0;o<e.length;o+=16384)n+=String.fromCharCode.apply(null,e.subarray(o,o+16384));return n}else{if(li)return li.decode(e);var i=pf(e),r=i.s,n=i.r;return n.length&&ze(8),r}}var ff=function(e,t){return t+30+tt(e,t+26)+tt(e,t+28)},hf=function(e,t,n){var o=tt(e,t+28),i=tt(e,t+30),r=bn(e.subarray(t+46,t+46+o),!(tt(e,t+8)&2048)),l=t+46+o,a=gf(e,l,i,n,We(e,t+20),We(e,t+24),We(e,t+42)),c=a[0],d=a[1],u=a[2];return[tt(e,t+10),c,d,r,l+i+tt(e,t+32),u]},gf=function(e,t,n,o,i,r,l){var a=i==4294967295,c=r==4294967295,d=l==4294967295,u=t+n,p=a+c+d;if(o&&p){for(;t+4<u;t+=4+tt(e,t+2))if(tt(e,t)==1)return[a?To(e,t+4+8*c):i,c?To(e,t+4):r,d?To(e,t+4+8*(c+a)):l,1];o<2&&ze(13)}return[i,r,l,0]},ci=function(e){var t=0;if(e)for(var n in e){var o=e[n].length;o>65535&&ze(9),t+=o+4}return t},ys=function(e,t,n,o,i,r,l,a){var c=o.length,d=n.extra,u=a&&a.length,p=ci(d);Ae(e,t,l!=null?33639248:67324752),t+=4,l!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(r<0&&8),e[t++]=i&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),S=f.getFullYear()-1980;if((S<0||S>119)&&ze(10),Ae(e,t,S<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,r!=-1&&(Ae(e,t,n.crc),Ae(e,t+4,r<0?-r-2:r),Ae(e,t+8,n.size)),Ae(e,t+12,c),Ae(e,t+14,p),t+=16,l!=null&&(Ae(e,t,u),Ae(e,t+6,n.attrs),Ae(e,t+10,l),t+=14),e.set(o,t),t+=c,p)for(var v in d){var x=d[v],g=x.length;Ae(e,t,+v),Ae(e,t+2,g),e.set(x,t+4),t+=4+g}return u&&(e.set(a,t),t+=u),t},bf=function(e,t,n,o,i){Ae(e,t,101010256),Ae(e,t+8,n),Ae(e,t+10,n),Ae(e,t+12,o),Ae(e,t+16,i)};function Oy(e,t){t||(t={});var n={},o=[];ya(e,"",n,t);var i=0,r=0;for(var l in n){var a=n[l],c=a[0],d=a[1],u=d.level==0?0:8,p=Yn(l),f=p.length,S=d.comment,v=S&&Yn(S),x=v&&v.length,g=ci(d.extra);f>65535&&ze(11);var y=u?ga(c,d):c,C=y.length,w=df();w.p(c),o.push(ha(d,{size:c.length,crc:w.d(),c:y,f:p,m:v,u:f!=l.length||v&&S.length!=x,o:i,compression:u})),i+=30+f+g+C,r+=76+2*(f+g)+(x||0)+C}for(var h=new xe(r+22),I=i,$=r-i,R=0;R<o.length;++R){var p=o[R];ys(h,p.o,p,p.f,p.u,p.c.length);var B=30+p.f.length+ci(p.extra);h.set(p.c,p.o+B),ys(h,i,p,p.f,p.u,p.c.length,p.o,p.m),i+=16+B+(p.m?p.m.length:0)}return bf(h,i,o.length,$,I),h}function yf(e,t){for(var n={},o=e.length-22;We(e,o)!=101010256;--o)(!o||e.length-o>65558)&&ze(13);var i=tt(e,o+8);if(!i)return{};var r=We(e,o+16),l=We(e,o-20)==117853008;if(l){var a=We(e,o-12);l=We(e,a)==101075792,l&&(i=We(e,a+32),r=We(e,a+48))}for(var c=0;c<i;++c){var d=hf(e,r,l),u=d[0],p=d[1],f=d[2],S=d[3],v=d[4],x=d[5],g=ff(e,x);r=v,u?u==8?n[S]=ba(e.subarray(g,g+p),{out:new xe(f)}):ze(14,"unknown compression type "+u):n[S]=Rn(e,g,g+p)}return n}const Mi=4,xa=30,Sa=`cbs:draft:v${Mi}:`,xf=["cbs:ribbon:","cbs:draft:"],Mt={commands:"baselineCommands",enableRules:"baselineEnableRules",displayRules:"baselineDisplayRules",locLabels:"baselineLocLabels"},Li=["HomepageGrid","SubGrid","Form","Application"];function va(e){return{orgUrl:e.orgUrl.trim().replace(/\/+$/,"").toLowerCase(),solutionId:e.solutionId.trim().toLowerCase(),entityLogicalName:e.entityLogicalName.trim().toLowerCase()}}function yn(e){const t=va(e);return`${Sa}${encodeURIComponent(t.orgUrl)}:${encodeURIComponent(t.solutionId)}:${encodeURIComponent(t.entityLogicalName)}`}function di(e,t){return!e||!t?!1:yn(e)===yn(t)}function Sf(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return`${(t>>>0).toString(16)}.${e.length}`}let $n=null;function Ca(e){const t=[e.baseline,e.baselineCommands,e.baselineEnableRules,e.baselineDisplayRules,e.baselineLocLabels,e.layers,e.baseLanguageCode];if($n&&$n.of.every((o,i)=>o===t[i]))return $n.value;const n=Sf(JSON.stringify(t));return $n={of:t,value:n},n}const xs=new WeakMap;function Tn(e){let t=xs.get(e);return t===void 0&&(t=JSON.stringify(e),xs.set(e,t)),t}const Bt=e=>JSON.parse(JSON.stringify(e)),jn={},wa={list:"groups",child:{list:"buttons",child:jn}};function Ia(e){const t=new Map;for(const n of e)t.set(n.id,t.has(n.id)?null:n);return t}function ko(e,t,n){if(!n.list||!Array.isArray(e[n.list]))return e;const o=t?.[n.list]??[];return{...e,[n.list]:ui(e[n.list],o,n.child??jn)}}function kn(e,t,n){if(!n.list||e[n.list]===void 0)return e;const o=t?.[n.list]??[];return{...e,[n.list]:mi(e[n.list],o,n.child??jn)}}function ui(e,t,n){const o=Ia(t),i=new Set(e.map(r=>r.id));if(i.size===e.length&&o.size===t.length){const r=t.filter(a=>i.has(a.id)),l=e.slice(r.length);if(r.every((a,c)=>e[c].id===a.id)&&l.every(a=>!o.has(a.id)))return{set:e.slice(0,r.length).filter(a=>Tn(o.get(a.id))!==Tn(a)).map(a=>ko(a,o.get(a.id),n)),drop:t.filter(a=>!i.has(a.id)).map(a=>a.id),add:l.map(a=>ko(a,void 0,n))}}return e.map(r=>{const l=o.get(r.id)??void 0;return l&&Tn(l)===Tn(r)?r.id:ko(r,l,n)})}function mi(e,t,n){const o=Ia(t);if(Array.isArray(e)){const c=[];for(const d of e)if(typeof d!="string")c.push(kn(d,o.get(d.id)??void 0,n));else{const u=o.get(d);u&&c.push(Bt(u))}return c}const i=new Set(e.drop),r=new Map(e.set.map(c=>[c.id,c])),l=[];for(const c of e.add)o.has(c.id)?r.set(c.id,c):l.push(c);const a=new Set(t.map(c=>c.id));return[...t.filter(c=>!i.has(c.id)).map(c=>r.has(c.id)?kn(r.get(c.id),c,n):Bt(c)),...[...r.values()].filter(c=>!a.has(c.id)).map(c=>kn(c,void 0,n)),...l.map(c=>kn(c,void 0,n))]}const vf=e=>!Array.isArray(e)&&e.set.length+e.drop.length+e.add.length===0,Zn=e=>e;function Cf(e){const t=et(e),n={};for(const r of Li){const l=t.ribbons[r],a=e.baseline[r];if(!l)continue;const c=ui(l.tabs,a?.tabs??[],wa),d={};for(const[p,f]of Object.entries(l))p!=="tabs"&&JSON.stringify(f)!==JSON.stringify(a?.[p])&&(d[p]=f);const u=Object.keys(a??{}).filter(p=>p!=="tabs"&&!(p in l));(!vf(c)||Object.keys(d).length+u.length>0)&&(n[r]={props:d,unset:u,tabs:c})}const o={};for(const r of Object.keys(Mt))o[r]=ui(Zn(t[r]),Zn(e[Mt[r]]),jn);const i={...t};delete i.ribbons;for(const r of Object.keys(Mt))delete i[r];return{ribbons:n,lists:o,other:i}}function wf(e,t){const{delta:n}=e,o={};for(const r of Li){const l=n.ribbons[r],a=t.baseline[r];if(!l){o[r]=Bt(a);continue}const c={...Bt(a),...Bt(l.props)};for(const d of l.unset)delete c[d];c.tabs=mi(l.tabs,Zn(a?.tabs??[]),wa),o[r]=c}const i={...et(t),...Bt(n.other),ribbons:o};for(const r of Object.keys(Mt))i[r]=mi(n.lists[r],Zn(t[Mt[r]]),jn);return i}function If(e){return btoa(bn(ga(Yn(JSON.stringify(e)),{level:9}),!0))}function Rf(e){return JSON.parse(bn(ba(Yn(atob(e),!0))))}const ht=e=>Array.isArray(e),Ao=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Ss=e=>{if(ht(e))return!0;const t=e;return!!t&&typeof t=="object"&&ht(t.set)&&ht(t.drop)&&ht(t.add)},jf=e=>!!e&&typeof e=="object"&&ht(e.entity)&&ht(e.application);function Nf(e){if(!e||typeof e!="object")return!1;const t=e,n=t.ribbons,o=t.other??{};return!!n&&typeof n=="object"&&Object.entries(n).every(([i,r])=>Li.includes(i)&&Ss(r?.tabs)&&Ao(r?.props)&&ht(r?.unset))&&Ao(t.lists)&&Object.keys(Mt).every(i=>Ss(t.lists[i]))&&Ao(t.other)&&["pendingUnhides","uncustomisedCommandIds"].every(i=>!(i in o)||jf(o[i]))&&(!("customisedCommandIds"in o)||ht(o.customisedCommandIds))}function $f(e,t){try{const n={format:Mi,key:va(e),savedAt:new Date().toISOString(),baselineFingerprint:Ca(t),data:If(Cf(t))};return localStorage.setItem(yn(e),JSON.stringify(n)),n.savedAt}catch{return null}}function Tf(e){const t=yn(e);let n;try{n=localStorage.getItem(t)}catch{return null}if(!n)return null;try{const o=JSON.parse(n);if(o.format===Mi&&di(o.key,e)&&typeof o.data=="string"){const i=Rf(o.data);if(Nf(i)){const r=o;return{format:r.format,key:r.key,savedAt:r.savedAt,baselineFingerprint:r.baselineFingerprint,delta:i}}}}catch{}return Qn(e),null}function Qn(e){try{localStorage.removeItem(yn(e))}catch{}}function kf(e,t){try{const n=Date.parse(JSON.parse(e??"").savedAt??"");return!(t-n<=xa*864e5)}catch{return!0}}function Af(e=Date.now()){const t=[];try{for(let n=0;n<localStorage.length;n++){const o=localStorage.key(n);o&&(o.startsWith(Sa)?kf(localStorage.getItem(o),e):xf.some(i=>o.startsWith(i)))&&t.push(o)}for(const n of t)localStorage.removeItem(n)}catch{return 0}return t.length}function Ra(e){return e.mutationsSincePublish>0||Ln(e)}function vs(){return Se.getState().target!==null&&Ra(D.getState())}let un=null;function zt(e){const{target:t,pending:n}=Se.getState();if(!t||n)return!0;const o=e.ribbons.HomepageGrid.entityLogicalName;if(o&&o.toLowerCase()!==t.entityLogicalName.toLowerCase())return!0;let i=!0;if(!Ra(e))un!==null&&e.future.some(a=>a.op==="restored"&&a.ts===un)||(Qn(t),Se.setState({lastSavedAt:null}));else{const l=$f(t,e);i=l!==null,l&&Se.setState({lastSavedAt:l})}const{saveFailed:r}=Se.getState();return!i&&!r&&oe.getState().logWarn("ribbon","Unsaved changes could not be saved as a draft (browser storage is full or unavailable): publish them, or they are lost when Command Bar Studio closes."),i===r&&Se.setState({saveFailed:!i}),i}const Df=["mutationsSincePublish","ribbons","commands","enableRules","displayRules","locLabels","pendingUnhides","customisedCommandIds","uncustomisedCommandIds","baseline","baselineCommands","baselineEnableRules","baselineDisplayRules","baselineLocLabels","layers"];function zf(){return D.subscribe((e,t)=>{Df.every(n=>e[n]===t[n])||zt(e)})}function Bf(e){const t=ie.getState();return{orgUrl:t.connectionUrl,solutionId:t.activeSolution?.id??"",entityLogicalName:e}}function Of(){const e=D.getState();e.loadWorkspace({ribbons:e.baseline,commands:e.baselineCommands,enableRules:e.baselineEnableRules,displayRules:e.baselineDisplayRules,locLabels:e.baselineLocLabels,templates:e.templates,conflicts:e.conflicts,layers:e.layers,baseLanguageCode:e.baseLanguageCode})}function Do(e){Se.setState({target:null,pending:null,pendingBaselineChanged:!1});const t=ie.getState();e.kind==="entity"?t.setActiveEntity(e.entity):t.setActiveSolution(e.solution)}const Se=Rt()((e,t)=>({target:null,pending:null,pendingBaselineChanged:!1,restoreError:null,pendingSwitch:null,saveFailed:!1,lastSavedAt:null,beginLoad(){un=null,e({target:null,pending:null,pendingBaselineChanged:!1,restoreError:null,saveFailed:!1,lastSavedAt:null})},workspaceLoaded(n){const o=Tf(n);un=null,e({target:n,pending:o,restoreError:null,lastSavedAt:o?.savedAt??null,pendingBaselineChanged:!!o&&o.baselineFingerprint!==Ca(D.getState())})},restoreDraft(){const{target:n,pending:o}=t();if(!n||!o||!di(n,o.key))return!1;const i=D.getState();try{i.restoreWorkspace(wf(o,i),`saved ${new Date(o.savedAt).toLocaleString()}`)}catch(a){const c=a instanceof Error?a.message:String(a);return oe.getState().logError("ribbon",`The unsaved changes saved ${o.savedAt} couldn't be restored: ${c}`),e({restoreError:c}),!1}const r=D.getState(),l=r.past[r.past.length-1];return r.past.length>i.past.length&&l?.op==="restored"&&(un=l.ts),e({pending:null,pendingBaselineChanged:!1,restoreError:null}),zt(r),!0},discardDraft(){const{target:n,pending:o}=t();o&&(Qn(o.key),e({pending:null,pendingBaselineChanged:!1,restoreError:null,lastSavedAt:null}),n&&di(n,o.key)&&zt(D.getState()))},requestEntitySwitch(n){ie.getState().activeEntity?.logicalName!==n.logicalName&&(vs()?(zt(D.getState()),e({pendingSwitch:{kind:"entity",entity:n}})):Do({kind:"entity",entity:n}))},requestSolutionSwitch(n){ie.getState().activeSolution?.id!==n.id&&(vs()?(zt(D.getState()),e({pendingSwitch:{kind:"solution",solution:n}})):Do({kind:"solution",solution:n}))},resolveSwitch(n){const{pendingSwitch:o,target:i,pending:r}=t();if(o){if(n==="cancel"){e({pendingSwitch:null});return}n==="keep"&&!zt(D.getState())||(n==="discard"&&i&&!r&&Qn(i),e({pendingSwitch:null,target:null,pending:null,pendingBaselineChanged:!1,saveFailed:!1}),Of(),Do(o))}}})),Ef=le({root:{height:"40px",display:"flex",alignItems:"center",gap:m.spacingHorizontalS,padding:`0 ${m.spacingHorizontalM}`,backgroundColor:m.colorNeutralBackground3,borderBottom:`1px solid ${m.colorNeutralStroke2}`,flexShrink:0},brand:{display:"flex",alignItems:"center",gap:m.spacingHorizontalS,marginRight:m.spacingHorizontalS},brandMark:{width:"24px",height:"24px",borderRadius:"4px",backgroundColor:m.colorBrandBackground,display:"flex",alignItems:"center",justifyContent:"center"},spacer:{flex:1},sep:{width:"1px",height:"20px",backgroundColor:m.colorNeutralStroke2,margin:`0 ${m.spacingHorizontalXS}`},paletteButton:{height:"28px",minWidth:"260px",display:"flex",alignItems:"center",gap:m.spacingHorizontalS,padding:`0 ${m.spacingHorizontalS}`,border:`1px solid ${m.colorNeutralStroke1}`,borderRadius:m.borderRadiusMedium,backgroundColor:m.colorNeutralBackground1,cursor:"pointer",color:m.colorNeutralForeground3,fontSize:m.fontSizeBase200,"&:hover":{border:`1px solid ${m.colorNeutralStroke1Hover}`,backgroundColor:m.colorNeutralBackground1Hover}},kbd:{padding:"1px 4px",border:`1px solid ${m.colorNeutralStroke2}`,borderRadius:"3px",fontSize:m.fontSizeBase100,backgroundColor:m.colorNeutralBackground2},solutionPickerSurface:{padding:m.spacingHorizontalM,minWidth:"360px",display:"flex",flexDirection:"column",gap:m.spacingVerticalS},solutionPickerHint:{color:m.colorNeutralForeground3}});function Mf(){const e=Ef(),[t,n]=M.useState("Loaded"),o=D(h=>h.past),i=D(h=>h.future),r=D(h=>h.undo),l=D(h=>h.redo),a=ie(h=>h.solutions),c=ie(h=>h.activeSolution),d=Se(h=>h.requestSolutionSwitch),u=Y(h=>h.openBulkPublish),p=Y(h=>h.openXmlDrawer),f=Y(h=>h.setCommandPaletteOpen),[S,v]=M.useState(!1),[x,g]=M.useState(""),y=M.useMemo(()=>a.filter(h=>!h.isManaged).map(h=>({value:h.id,children:h.friendlyName||h.uniqueName,searchText:`${h.friendlyName??""} ${h.uniqueName??""}`.toLowerCase(),solution:h})),[a]),C=xu(x,y,{optionToText:h=>h.searchText,filter:(h,I)=>h.includes(I.toLowerCase()),optionToReactKey:h=>h.value,renderOption:h=>s.jsx(Iu,{value:h.value,text:h.solution.friendlyName??h.solution.uniqueName,children:s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2,minWidth:0},children:[s.jsx(q,{size:200,weight:"semibold",children:h.solution.friendlyName||h.solution.uniqueName}),s.jsxs(q,{size:100,style:{color:m.colorNeutralForeground3},children:[h.solution.uniqueName," · v",h.solution.version,h.solution.publisherName?` · ${h.solution.publisherName}`:""]})]})},h.value),noOptionsMessage:a.length===0?"Loading solutions…":"No solutions match the filter."}),w=(h,I)=>{const $=a.find(R=>R.id===I.optionValue);$&&(d($),v(!1),g(""))};return s.jsxs("header",{className:e.root,children:[s.jsxs("div",{className:e.brand,children:[s.jsx("div",{className:e.brandMark,children:s.jsx(q,{size:100,weight:"bold",style:{color:"white",lineHeight:1},children:"CBS"})}),s.jsx(q,{weight:"semibold",size:300,children:"Command Bar Studio"})]}),s.jsx("div",{className:e.sep}),s.jsxs(Su,{open:S,onOpenChange:(h,I)=>v(I.open),positioning:"below-start",trapFocus:!0,children:[s.jsx(vu,{disableButtonEnhancement:!0,children:s.jsxs(K,{appearance:c?"subtle":"primary",size:"small",icon:s.jsx(bl,{}),iconPosition:"before","aria-label":"Select solution",children:[s.jsx(q,{size:200,children:"Solution: "}),s.jsx(q,{size:200,weight:"semibold",children:c?.friendlyName??"Select solution…"}),c&&s.jsxs(s.Fragment,{children:[s.jsx(ae,{appearance:"tint",color:c.isManaged?"informative":"success",size:"small",style:{marginLeft:m.spacingHorizontalXS},children:c.isManaged?"Managed":"Unmanaged"}),(()=>{const h=c.publisherPrefix||"new",I=h==="new"||/^defaultpublisher/i.test(c.publisherUniqueName??"");return s.jsxs(ae,{appearance:"tint",color:I?"warning":"informative",size:"small",title:I?`Imports will land under the org's default publisher "${h}". To use your own publisher, create a new solution in maker.powerapps.com bound to it.`:`Publisher: ${c.publisherName||c.publisherUniqueName||h}`,style:{marginLeft:m.spacingHorizontalXS},children:[h,"_"]})})()]}),s.jsx(gt,{fontSize:12,style:{marginLeft:m.spacingHorizontalXS,color:m.colorNeutralForeground3}})]})}),s.jsxs(Cu,{className:e.solutionPickerSurface,children:[s.jsx(q,{size:200,weight:"semibold",children:"Select an unmanaged solution"}),s.jsx(De,{label:"Solution",children:s.jsx(wu,{placeholder:a.length===0?"Loading solutions…":"Search by display name or unique name",value:x,onChange:h=>g(h.target.value),onOptionSelect:w,freeform:!0,clearable:!0,children:C})}),s.jsxs(q,{size:100,className:e.solutionPickerHint,children:[y.length," unmanaged solution",y.length!==1?"s":""," available"]})]})]}),s.jsx("div",{className:e.spacer}),s.jsxs("button",{type:"button",className:e.paletteButton,onClick:()=>f(!0),"aria-label":"Search buttons, commands, rules (Ctrl+K)",children:[s.jsx(ft,{fontSize:14}),s.jsx("span",{style:{flex:1,textAlign:"left"},children:"Search buttons, commands, rules…"}),s.jsx("kbd",{className:e.kbd,children:"Ctrl"}),s.jsx("kbd",{className:e.kbd,children:"K"})]}),s.jsx("div",{className:e.sep}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(Qs,{}),disabled:o.length===0,onClick:r,title:"Undo (Ctrl+Z)","aria-label":"Undo"}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(er,{}),disabled:i.length===0,onClick:l,title:"Redo (Ctrl+Shift+Z)","aria-label":"Redo"}),s.jsx("div",{className:e.sep}),s.jsxs(dt,{value:t,onChange:(h,I)=>n(I.value),size:"small",title:"State simulator","aria-label":"State simulator",children:[s.jsx("option",{value:"Loaded",children:"Loaded"}),s.jsx("option",{value:"Empty",children:"Empty"}),s.jsx("option",{value:"Error",children:"Error"}),s.jsx("option",{value:"Publishing",children:"Publishing"})]}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(tr,{}),onClick:()=>{p()},title:"Import / Export RibbonDiffXml","aria-label":"Import/Export"}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(nr,{}),title:"Settings","aria-label":"Settings"}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(or,{}),title:"Help","aria-label":"Help"}),s.jsx("div",{className:e.sep}),s.jsx(K,{appearance:"secondary",size:"small",icon:s.jsx(ir,{}),children:"Save"}),s.jsx(K,{appearance:"primary",size:"small",icon:s.jsx(yl,{}),onClick:u,children:"Publish All"})]})}const Lf=le({root:{height:"36px",display:"flex",alignItems:"center",gap:m.spacingHorizontalS,padding:`0 ${m.spacingHorizontalM}`,backgroundColor:m.colorNeutralBackground2,borderBottom:`1px solid ${m.colorNeutralStroke2}`,flexShrink:0,position:"relative"},breadcrumb:{display:"flex",alignItems:"center",gap:m.spacingHorizontalXS,color:m.colorNeutralForeground3,fontSize:m.fontSizeBase200},separator:{color:m.colorNeutralForeground4},activeSegment:{color:m.colorNeutralForeground1,fontWeight:m.fontWeightSemibold},spacer:{flex:1}});function Pf(){const e=Lf(),t=D(p=>p.mutationsSincePublish),n=ie(p=>p.activeSolution),o=ie(p=>p.activeEntity),i=ie(p=>p.connectionUrl),r=Y(p=>p.openXmlDrawer),l=Y(p=>p.openImportXml),a=Y(p=>p.openDiffViewer),c=Y(p=>p.rightPaneMode),d=Y(p=>p.setRightPaneMode);async function u(){if(!i||!o?.logicalName)return;const p=`${i.replace(/\/$/,"")}/main.aspx?pagetype=entitylist&etn=${encodeURIComponent(o.logicalName)}`;await window.toolboxAPI?.utils.openInConnectionBrowser(p,"primary")}return s.jsxs("div",{className:e.root,children:[s.jsxs("nav",{"aria-label":"Breadcrumb",className:e.breadcrumb,children:[s.jsx("span",{children:"Solutions"}),s.jsx("span",{className:e.separator,children:"›"}),s.jsx("span",{children:n?.friendlyName??"—"}),s.jsx("span",{className:e.separator,children:"›"}),s.jsx("span",{children:"Tables"}),s.jsx("span",{className:e.separator,children:"›"}),s.jsx("span",{className:e.activeSegment,children:o?.displayName??"Select a table"})]}),s.jsx("div",{className:e.spacer}),t>0&&s.jsxs(ae,{appearance:"tint",color:"warning",children:[t," change",t!==1?"s":""," since publish"]}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(Ct,{}),onClick:()=>{u()},disabled:!o?.logicalName,children:"Preview in app"}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(Ht,{}),onClick:r,children:"RibbonDiffXml"}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(tr,{}),onClick:()=>l(),children:"Import / Export"}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(sr,{}),onClick:()=>a("compare"),children:"Compare"}),s.jsxs(dt,{size:"small",value:c,onChange:(p,f)=>d(f.value),"aria-label":"Properties pane mode",children:[s.jsx("option",{value:"docked",children:"Properties: Docked"}),s.jsx("option",{value:"floating",children:"Properties: Floating"}),s.jsx("option",{value:"hidden",children:"Properties: Hidden"})]})]})}function Ff(e){return e instanceof Element?e instanceof HTMLElement&&e.isContentEditable?!0:!!e.closest('input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="textbox"], [role="combobox"], [role="spinbutton"], .monaco-editor'):!1}const _f='[role="dialog"], [role="alertdialog"], [role="menu"], [role="menubar"], [role="listbox"], .fui-PopoverSurface, .fui-MenuPopover',ja=".fui-OverlayDrawer, .fui-InlineDrawer",Cs=e=>!!e.closest(ja)&&!e.matches('[role="alertdialog"]');function qf(e){const t=e instanceof Element?e.closest(_f):null;return t&&!Cs(t)?!0:Array.from(document.querySelectorAll('[aria-modal="true"], [role="alertdialog"]')).some(n=>!Cs(n))}function Hf(e){return e instanceof Element&&!!e.closest(ja)}function Gf(){const e=Y(h=>h.setCommandPaletteOpen),t=Y(h=>h.openBulkPublish),n=Y(h=>h.announce),o=Y(h=>h.openHideInsteadOfDelete),i=D(h=>h.undo),r=D(h=>h.redo),l=D(h=>h.past),a=D(h=>h.future),c=Z(h=>h.selectedButtonId),d=Z(h=>h.selectedGroupId),u=Z(h=>h.tabId),p=Z(h=>h.location),f=D(h=>h.duplicateButton),S=D(h=>h.deleteButton),v=D(h=>h.moveButton),x=D(h=>h.ribbons),g=D(h=>h.baseline),y=Z(h=>h.selectButtonInContext),C=Z(h=>h.selectGroup),w=M.useRef(null);M.useEffect(()=>{const h=I=>{const R=navigator.platform.toUpperCase().includes("MAC")?I.metaKey:I.ctrlKey,B=I.target;if(I.key==="Escape"){e(!1);return}if(qf(B)){R&&I.key==="s"&&I.preventDefault();return}if(R&&I.key==="k"){I.preventDefault(),e(!0),n("Command palette opened");return}if(R&&I.key==="s"){I.preventDefault(),t(),n("Bulk publish dialog opened");return}const T=Ff(B);if(R&&I.key==="z"&&!I.shiftKey&&l.length>0&&!T){I.preventDefault(),i(),n("Undo");return}if((R&&I.key==="y"||R&&I.shiftKey&&I.key==="z")&&!T){I.preventDefault(),a.length>0&&(r(),n("Redo"));return}if(!Hf(B)){if(R&&I.key==="d"){!T&&c&&d&&u&&p&&(I.preventDefault(),f(p,u,d,c),n("Button duplicated"));return}if(R&&I.key.toLowerCase()==="x"){if(!T&&c&&d&&u&&p){I.preventDefault();const H=x[p].tabs.find(k=>k.id===u)?.groups.find(k=>k.id===d);if(H&&Wn(H,c)){n("Menu items can't be cut. Delete the item and add a new one to the other menu.");return}w.current={location:p,tabId:u,groupId:d,buttonId:c},n("Button cut. Focus a destination group, then press paste.")}return}if(R&&I.key.toLowerCase()==="v"){const H=w.current;if(!T&&H&&d&&u&&p){I.preventDefault();const k=v({groupId:H.groupId,buttonId:H.buttonId,tabId:H.tabId,location:H.location},{groupId:d,tabId:u,location:p});if(w.current=null,!k){n("The button couldn't be moved there.");return}requestAnimationFrame(()=>{y(p,u,d,k),document.querySelector(`[data-ribbon-btn-id="${k}"]`)?.focus()}),n(k===H.buttonId?"Button pasted to destination group.":"Pasted your copy of the button to the destination group; the original is hidden.")}return}if((I.key==="Delete"||I.key==="Backspace")&&c&&d&&u&&p&&!T){const H=x[p].tabs.find(V=>V.id===u),k=H?.groups.find(V=>V.id===d),P=Yt(k,c);if(!P)return;if(I.preventDefault(),!In(P,g[p])){p==="Application"&&u==="Mscrm.GlobalTab"&&P.oob&&!P.custom?n(`"${P.label}" is read-only and can't be deleted.`):P.hidden?n(`"${P.label}" can't be deleted — only your own buttons can. It is already hidden.`):o({location:p,tabId:u,groupId:d,buttonId:c});return}const j=k?Wn(k,c):void 0,E=j?j.section.controls.map(V=>({groupId:d,buttonId:V.id})):H?.groups.flatMap(V=>V.buttons.map(ee=>({groupId:V.id,buttonId:ee.id})))??[],N=E.findIndex(V=>V.buttonId===c),W=E[N+1]??E[N-1]??(j?{groupId:d,buttonId:j.parent.id}:null),U=d;S(p,u,d,c),requestAnimationFrame(()=>{if(W){y(p,u,W.groupId,W.buttonId),document.querySelector(`[data-ribbon-btn-id="${W.buttonId}"]`)?.focus();return}U&&(C(U),document.querySelector(`[data-add-btn-group-id="${U}"]`)?.focus())}),n("Button deleted")}}};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[e,t,n,o,i,r,l.length,a.length,c,d,u,p,f,S,v,x,g,y,C])}const Wf=le({handleV:{width:"4px",cursor:"col-resize",backgroundColor:"transparent",flexShrink:0,":hover":{backgroundColor:m.colorNeutralStroke2},":active":{backgroundColor:m.colorBrandStroke1},userSelect:"none"},handleH:{height:"4px",cursor:"row-resize",backgroundColor:"transparent",flexShrink:0,":hover":{backgroundColor:m.colorNeutralStroke2},":active":{backgroundColor:m.colorBrandStroke1},userSelect:"none"}});function zo({direction:e,onResize:t,"aria-label":n=`Resize ${e} pane`}){const o=Wf(),i=M.useRef(0),r=M.useCallback(a=>{a.currentTarget.setPointerCapture(a.pointerId),i.current=e==="vertical"?a.clientX:a.clientY},[e]),l=M.useCallback(a=>{if(!a.currentTarget.hasPointerCapture(a.pointerId))return;const c=e==="vertical"?a.clientX:a.clientY,d=c-i.current;i.current=c,t(d)},[e,t]);return s.jsx("div",{className:e==="vertical"?o.handleV:o.handleH,role:"separator","aria-orientation":e==="vertical"?"vertical":"horizontal","aria-label":n,onPointerDown:r,onPointerMove:l})}class kt extends Ue.Component{state={hasError:!1,error:null};static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("[CBS ErrorBoundary]",this.props.label??"panel",t,n)}handleRetry=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError?this.props.fallback?this.props.fallback:s.jsxs(Ie,{intent:"error",style:{margin:8},children:[s.jsxs(Re,{children:[s.jsx("strong",{children:this.props.label??"Panel"})," encountered an error:"," ",this.state.error?.message??"Unknown error"]}),s.jsx(Fn,{children:s.jsx(K,{size:"small",onClick:this.handleRetry,children:"Retry"})})]}):this.props.children}}const Uf=M.lazy(()=>Ne(()=>import("./XmlDrawer-BI6Wy6kL.js"),__vite__mapDeps([0,1,2,3,4,5,6,7]),import.meta.url)),Xf=M.lazy(()=>Ne(()=>import("./CommandEditorPanel-DidGBtFC.js"),__vite__mapDeps([8,1,2,3,9,10,6,5,4,7]),import.meta.url)),Vf=M.lazy(()=>Ne(()=>import("./RuleEditorPanel-BkNwBgaP.js"),__vite__mapDeps([11,1,2,3,12,6,9,10,7]),import.meta.url)),Jf=M.lazy(()=>Ne(()=>import("./BulkPublishModal-DqX2QmUD.js"),__vite__mapDeps([13,1,2,3,14,12,10,4,6,7]),import.meta.url)),Kf=M.lazy(()=>Ne(()=>import("./NewButtonModal-BVvlbCv4.js"),__vite__mapDeps([15,1,2,3,6,7]),import.meta.url)),Yf=M.lazy(()=>Ne(()=>import("./NewGroupModal-CgQy-uo4.js"),__vite__mapDeps([16,1,2,3,6,7]),import.meta.url)),Zf=M.lazy(()=>Ne(()=>import("./NewTabModal-B_2-kwAx.js"),__vite__mapDeps([17,1,2,3,6,7]),import.meta.url)),Qf=M.lazy(()=>Ne(()=>import("./ImportXmlModal-B8NgiUDZ.js"),__vite__mapDeps([18,1,2,3,14,12,10,5,6,7]),import.meta.url)),eh=M.lazy(()=>Ne(()=>import("./CommandPalette-AuDfsF8l.js"),__vite__mapDeps([19,1,2,3,6,7]),import.meta.url)),th=M.lazy(()=>Ne(()=>import("./LocalizationEditor-tmniX5PC.js"),__vite__mapDeps([20,1,2,3,6,7]),import.meta.url)),nh=M.lazy(()=>Ne(()=>import("./IconPickerModal-Bw0C7KwV.js"),__vite__mapDeps([21,1,2,3,4,6,7]),import.meta.url)),oh=M.lazy(()=>Ne(()=>import("./TabDisplayRulesPanel-trzExQ1T.js"),__vite__mapDeps([22,1,2,3,6,7]),import.meta.url)),ih=M.lazy(()=>Ne(()=>import("./ScalingEditorPanel-ezMkzvG1.js"),__vite__mapDeps([23,1,2,3,6,7]),import.meta.url)),sh=M.lazy(()=>Ne(()=>import("./ConflictDrawer-DxQ_jd-x.js"),__vite__mapDeps([24,1,2,3,6,7]),import.meta.url)),rh=M.lazy(()=>Ne(()=>import("./WebResourceBrowser-DaPOZQ5X.js"),__vite__mapDeps([25,1,2,3,4,6,7]),import.meta.url)),ah=M.lazy(()=>Ne(()=>import("./UrlComposerModal-BlVXHKRM.js"),__vite__mapDeps([26,1,2,3,6,7]),import.meta.url)),lh=M.lazy(()=>Ne(()=>import("./DiffViewer-BZuqvP4f.js"),__vite__mapDeps([27,2,3,1,6,7]),import.meta.url)),ch=M.lazy(()=>Ne(()=>import("./HideInsteadOfDeleteModal-BYHCTZrG.js"),__vite__mapDeps([28,1,2,3,6,7]),import.meta.url)),dh=le({root:{display:"flex",flexDirection:"column",height:"100vh",overflow:"hidden",backgroundColor:m.colorNeutralBackground1,color:m.colorNeutralForeground1,fontFamily:m.fontFamilyBase},body:{display:"flex",flex:1,overflow:"hidden",position:"relative"},leftPane:{flexShrink:0,overflow:"hidden",borderRight:`1px solid ${m.colorNeutralStroke2}`},rightPane:{flexShrink:0,overflow:"hidden",borderLeft:`1px solid ${m.colorNeutralStroke2}`},bottomPanel:{flexShrink:0}});function uh({children:e,leftPane:t,rightPane:n,bottomPanel:o}){const i=dh(),r=Y(h=>h.leftPaneWidth),l=Y(h=>h.rightPaneWidth),a=Y(h=>h.rightPaneMode),c=Y(h=>h.setLeftPaneWidth),d=Y(h=>h.setRightPaneWidth),u=Y(h=>h.bottomPanelHeight),p=Y(h=>h.bottomCollapsed),f=Y(h=>h.setBottomPanelHeight),S=Y(h=>h.announcement),v=Y(h=>h.xmlDrawerOpen||h.commandEditorOpen||h.ruleEditorOpen||h.bulkPublishOpen||h.newButtonGroupId!==null||h.newGroupOpen||h.newTabOpen||h.importXmlOpen||h.commandPaletteOpen||h.localizationEditorOpen||h.iconPickerOpen||h.tabDisplayRulesOpen||h.scalingEditorOpen||h.conflictDrawerOpen||h.webResourceBrowserOpen||h.urlComposerOpen||h.diffViewerOpen||h.hideInsteadOfDelete!==null),x=M.useRef(null),g=M.useRef(!1);Gf(),M.useEffect(()=>{if(v&&!g.current){const h=document.activeElement;x.current=h instanceof HTMLElement?h:null}if(!v&&g.current){const h=x.current;requestAnimationFrame(()=>{!h||!h.isConnected||h.focus()})}g.current=v},[v]);const y=M.useCallback(h=>{c(Math.max(160,Math.min(500,r+h)))},[r,c]),C=M.useCallback(h=>{d(Math.max(200,Math.min(600,l-h)))},[l,d]),w=M.useCallback(h=>{const I=u-h;f(Math.max(120,Math.min(520,I)))},[u,f]);return s.jsxs("div",{className:i.root,children:[s.jsx(Mf,{}),s.jsx(Pf,{}),s.jsxs("div",{className:i.body,children:[s.jsx("div",{className:i.leftPane,style:{width:r},children:s.jsx(kt,{label:"Left pane",children:t})}),s.jsx(zo,{direction:"vertical",onResize:y,"aria-label":"Resize left pane"}),s.jsx(kt,{label:"Ribbon canvas",children:e}),a==="docked"&&s.jsxs(s.Fragment,{children:[s.jsx(zo,{direction:"vertical",onResize:C,"aria-label":"Resize right pane"}),s.jsx("div",{className:i.rightPane,style:{width:l},children:s.jsx(kt,{label:"Properties pane",children:n})})]}),a==="floating"&&s.jsx("div",{style:{position:"absolute",right:8,top:8,bottom:8,width:l,maxWidth:"90vw",border:`1px solid ${m.colorNeutralStroke2}`,backgroundColor:m.colorNeutralBackground1,boxShadow:m.shadow16,borderRadius:m.borderRadiusMedium,overflow:"hidden",zIndex:10},children:s.jsx(kt,{label:"Properties pane",children:n})})]}),!p&&s.jsx(zo,{direction:"horizontal",onResize:w,"aria-label":"Resize bottom panel"}),s.jsx("div",{className:i.bottomPanel,children:s.jsx(kt,{label:"Bottom panel",children:o})}),s.jsx(kt,{label:"Panels",children:s.jsxs(M.Suspense,{fallback:null,children:[s.jsx(Uf,{}),s.jsx(Xf,{}),s.jsx(Vf,{}),s.jsx(Jf,{}),s.jsx(Kf,{}),s.jsx(Yf,{}),s.jsx(Zf,{}),s.jsx(Qf,{}),s.jsx(eh,{}),s.jsx(th,{}),s.jsx(nh,{}),s.jsx(oh,{}),s.jsx(ih,{}),s.jsx(sh,{}),s.jsx(rh,{}),s.jsx(ah,{}),s.jsx(lh,{}),s.jsx(ch,{})]})}),s.jsx("div",{role:"status","aria-live":"polite","aria-atomic":"true",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",left:-9999,top:"auto"},children:S})]})}const Na="Unified Interface has no visible tabs: this tab's buttons appear in the table's command bar (or its overflow menu) wherever the tab's display rule applies.",sn=(e,t)=>JSON.stringify(e)===JSON.stringify(t),mh=e=>[e.icon,e.image16,e.image32].some(t=>!!t&&t.startsWith("$webresource:")),ph=e=>!!e.source&&Ni(e)===e.source.modernImage&&(e.source.modernImage!==void 0||!e.icon),fh=/^\$LocLabels:(.+)$/,mt=e=>e?fh.exec(e)?.[1]??null:null,hh=/^\s*<(EnableRule|DisplayRule)\b[^>]*?\sId="([^"]+)"/,rn=e=>new Set(e??[]);function gh(e){const t=[];for(const n of Object.values(e.source?.attributes??{})){const o=mt(n);o&&t.push(o)}for(const n of e.source?.xml?.matchAll(/\$LocLabels:([^"'\s<]+)/g)??[])t.includes(n[1])||t.push(n[1]);return t}function ws(e){return(e.menu?.sections??[]).map(t=>({id:t.id,title:t.title??"",sequence:t.sequence,displayMode:t.displayMode??"",controlsId:t.controlsId}))}function Ey(e){const t=[],n=[],o=[],i=[],r=[],l=[],a=[],c=[],d=new Map,u=(_,L)=>{const O=mt(_);O&&d.set(O,new Set([...d.get(O)??[],L]))};for(const{baseline:_}of e.locations)for(const L of _.tabs){u(L.label,L.id);for(const O of L.groups){u(O.label,O.id);for(const F of je(O))for(const b of Object.values(F.source?.attributes??{}))u(b,F.id)}}const p=new Set([...(e.locLabels??[]).map(_=>_.id),...rn(e.layer?.locLabelIds)]);let f=!1;const S=new Set,v=rn(e.layer?.containerIds),x=rn(e.layer?.locLabelIds),g=new Set,y=new Set,C=new Map,w=new Map,h=[],I=new Set(e.locations.flatMap(({current:_})=>Array.from(St(_).values(),L=>L.button.id))),$=(_,L,O,F)=>{const b=mt(O);if(v.has(L)&&b&&x.has(b)&&!mt(F)&&F.trim())if([...d.get(b)??[]].some(A=>A!==L)){let A=`${L}.Title`;for(let X=2;A===b||p.has(A);X++)A=`${L}.Title${X}`;p.add(A),c.push({id:A,text:F,containerId:L,newLabel:!0})}else c.push({id:b,text:F,containerId:L});else t.push(`Renaming ${_} ${L} — only tabs and groups your unmanaged customizations add (with a translatable title) can be renamed`)};for(const{current:_,baseline:L}of e.locations){const O=ep(_,L);O.newButtons+O.overriddenButtons+O.hiddenButtons+O.newTabs+O.newGroups>0&&(f=!0),O.scalingChanges>0&&t.push(`Scaling changes on ${_.location} (not supported yet)`);const F=Wr(_,L);t.push(...F.problems);const b=rn(e.layer?.scalingStepIds);for(const[z,G]of Object.entries(L.scalingByTab??{})){const te=_.tabs.find(ne=>ne.id===z),Q=[...G.maxSizes.filter(ne=>b.has(ne.id)).map(ne=>({...ne,kind:"MaxSize"})),...G.scales.filter(ne=>b.has(ne.id)).map(ne=>({...ne,kind:"Scale"})),...(te?.groups??[]).map(ne=>F.steps.get(ne.id)).filter(ne=>!!ne).map(ne=>({...ne,kind:"MaxSize"}))];if(Q.length===0)continue;const we=Tr(z,{maxSizes:G.maxSizes.filter(ne=>!b.has(ne.id)).map(ne=>ne.sequence),scales:G.scales.filter(ne=>!b.has(ne.id)).map(ne=>ne.sequence)},Q);n.push(...we.changes.map(Tm)),t.push(...we.problems)}const A=St(_),X=St(L);for(const{button:z}of A.values())for(const G of jr(z))S.add(G);for(const[z,{button:G}]of A){const te=gh(G);te.forEach(ne=>g.add(ne));const Q=X.get(z)?.button,we=!Q||Jo(Q,G);for(const ne of[so(G.id),ro(G.id),ao(G.id)])we?y.add(ne):te.includes(ne)||C.set(ne,G);we&&te.forEach(ne=>y.add(ne))}for(const[z,G]of X){const te=G.button.id,Q=A.get(z);if(!Q){if(G.menu&&I.has(te)&&I.has(G.menu.parentId)&&G.button.origin!=="unmanaged"){t.push(`Moving the menu of ${G.menu.parentId} to another location — its item "${G.button.label}" (${te}) comes from another solution and can't be moved with it; move the flyout back`);continue}if(Ze(G.button.kind)&&I.has(te)&&/<Menu[\s>/]/.test(G.button.source?.xml??"")){t.push(`Moving the <${pn[G.button.kind]}> "${G.button.label}" (${te}) to another location — its menu may hold items of other solutions; move it within its location instead`);continue}xt(G.button)?o.push(te):t.push(`Removing "${G.button.label}" (${te}) — only your own unmanaged buttons can be deleted; hide it instead`);continue}G.button.hidden&&!Q.button.hidden&&i.push(te),(Q.button.kind??"button")!==(G.button.kind??"button")&&t.push(`Changing the kind of "${Q.button.label}" (${te}) — not supported yet`);const we=Jo(G.button,Q.button);we&&Ze(Q.button.kind)&&t.push(`Editing the <${pn[Q.button.kind]}> "${Q.button.label}" (${te}) — CBS shows it read-only; it can be hidden, or moved and deleted when it's your own`),we&&(Ot(Q.button.kind)||Q.button.menu)&&G.button.origin!=="unmanaged"&&t.push(`Editing the flyout / split button "${Q.button.label}" (${te}) itself — only your own can be edited; its menu items can be edited, hidden or added to`),sn(ws(G.button),ws(Q.button))||t.push(`Adding, removing or changing menu sections of "${Q.button.label}" (${te}) — not supported yet for an existing menu; add, edit or remove its items instead`),(Q.button.icon??"")!==(G.button.icon??"")&&!mh(Q.button)&&!ph(Q.button)&&t.push(`Changing the icon of "${Q.button.label}" (${te}) to a built-in icon — not supported yet; choose an SVG web resource`),((Q.menu||G.menu?Q.menu?.controlsId!==G.menu?.controlsId:Q.groupId!==G.groupId)||Q.button.sequence!==G.button.sequence)&&(G.button.origin==="unmanaged"?l.push({id:te,groupId:Q.groupId,sequence:Q.button.sequence,...Q.menu?{controlsId:Q.menu.controlsId}:{}}):t.push(`Moving or re-ordering "${Q.button.label}" (${te}) — only your own unmanaged buttons, and copies made with "Customise button", can be moved; undo the move, then hide it and add a new button instead`))}for(const[z,G]of A){if(X.has(z))continue;w.has(G.button.id)||w.set(G.button.id,{groupId:G.groupId,sequence:G.button.sequence,...G.menu?{controlsId:G.menu.controlsId}:{}});const te=G.button.source?.attributes.PopulateDynamically?.toLowerCase()==="true";Ot(G.button.kind)&&!te&&!vt(G.button).some(Q=>!Q.hidden)&&h.push({id:G.button.id,label:G.button.label})}const re=new Map(L.tabs.flatMap(z=>z.groups.map(G=>[G.id,G]))),me=new Map(L.tabs.map(z=>[z.id,z])),Ee=new Set(_.tabs.map(z=>z.id)),Ce=new Set(_.tabs.flatMap(z=>z.groups.map(G=>G.id)));for(const z of _.tabs){const G=mt(z.label);G&&g.add(G);const te=me.get(z.id);if(!te){y.add(`${z.id}.Title`);const Q=mt(z.source?.titleToken);Q&&y.add(Q),z.commandId&&S.add(z.commandId),_.location==="Application"&&(z.tabDisplayRules??[]).length===0&&t.push(`New tab ${z.id} has no tab display rule, so it would never be shown — add one in Tab rules`),n.push(`New tab "${z.label}" (${z.id}): ${Na}`)}te&&te.label!==z.label&&$("tab",z.id,te.label,z.label),te&&!sn(te.tabDisplayRules??[],z.tabDisplayRules??[])&&(v.has(z.id)?z.commandId?a.push(z.id):t.push(`Changing the display rules of tab ${z.id} — the tab has no Command to attach them to`):t.push(`Changing the display rules of tab ${z.id} — only tabs your unmanaged customizations add can be changed`));for(const Q of z.groups){const we=mt(Q.label);we&&g.add(we);const ne=re.get(Q.id);if(!ne){y.add(`${Q.id}.Title`);const Nt=mt(Q.source?.titleToken);Nt&&y.add(Nt)}ne&&ne.template!==Q.template&&t.push(`Re-templating group ${Q.id} — not supported yet`),ne&&ne.label!==Q.label&&$("group",Q.id,ne.label,Q.label)}}const He=(z,G)=>t.push(`Removing ${z} ${G} — only tabs and groups your unmanaged customizations add can be deleted; hide it instead`);for(const z of L.tabs){if(!Ee.has(z.id)){v.has(z.id)?r.push(z.id):He("tab",z.id);continue}for(const G of z.groups)Ce.has(G.id)||(v.has(G.id)?r.push(G.id):He("group",G.id))}}for(let _=o.length-1;_>=0;_--){const L=w.get(o[_]);L&&(l.push({id:o[_],...L}),o.splice(_,1))}for(const _ of e.deletedOrphans??[]){for(const L of _.deleteControlIds)o.includes(L)||o.push(L);for(const L of _.deleteContainerIds)r.includes(L)||r.push(L)}for(const _ of h)l.some(L=>L.id===_.id)||t.push(`New flyout / split button "${_.label}" has no menu items — add at least one item to its menu`);const R=e.layer?.commandIds?rn(e.layer.commandIds):null,B=new Set(e.uncustomisedCommandIds??[]),T=[...B].filter(_=>R?R.has(_):S.has(_)&&!e.excludeCommandIds?.has(_));for(const _ of T)e.layer?.commandRefIds&&!Ci(_,e.layer.commandRefIds)&&t.push(`Uncustomising ${_} — it is your own command (your customizations' buttons use it and no other solution defines it); undo the uncustomise`);T.includes(Be)&&S.has(Be)&&t.push(`Uncustomising ${Be} — its "Open record" buttons still use it; undo the uncustomise and turn the record open override off in the Advanced section instead`);for(const _ of e.excludeCommandIds??[])S.delete(_);const H=new Set(e.customisedCommandIds??[]),k=new Map(e.baselineCommands.map(_=>[_.id,_])),P=e.commands.filter(_=>S.has(_.id)&&!B.has(_.id)&&(!k.has(_.id)||!sn(k.get(_.id),_)||H.has(_.id)&&!R?.has(_.id))).map(_=>_.id);for(const _ of e.commands){if(!P.includes(_.id))continue;_.actions.some(O=>O.kind==="powerFx"||O.kind==="customApi")&&t.push(`Power Fx / Custom API action in command ${_.id} — classic ribbon commands can't run these; remove the action (#28)`);const L=_.id===Be?Wp(_):null;L&&t.push(L)}const j=new Set,E=new Set;for(const _ of e.commands)if(!(!S.has(_.id)||B.has(_.id))){_.enableRules.forEach(L=>j.add(L)),_.displayRules.forEach(L=>E.add(L));for(const L of _.rawRuleRefs??[]){const O=hh.exec(L.xml);O&&(O[1]==="EnableRule"?j:E).add(O[2])}}const N=(_,L,O)=>{const F=new Map(L.map(b=>[b.id,b]));return _.filter(b=>O.has(b.id)&&(!F.has(b.id)||!sn(F.get(b.id),b))).map(b=>b.id)},W=N(e.enableRules,e.baselineEnableRules,j),U=N(e.displayRules,e.baselineDisplayRules,E),V=[];if(e.locLabels&&e.baselineLocLabels){const _=new Map(e.baselineLocLabels.map(L=>[L.id,L]));for(const L of e.locLabels){const O=_.get(L.id);if(O&&sn(O,L)||y.has(L.id))continue;if(g.has(L.id)){x.has(L.id)?V.push(L.id):t.push(`Translations of label ${L.id} — it is defined by another solution; change the text in the properties pane instead`);continue}const F=C.get(L.id);F&&t.push(`Translations for "${F.label}" (${F.id}) — its text isn't a translatable label yet; change the text in the properties pane first, then add translations`)}}const ee=(e.unhiddenLayerHideIds??[]).filter(_=>!i.includes(_));return{hasChanges:f||P.length>0||T.length>0||W.length>0||U.length>0||o.length>0||i.length>0||ee.length>0||r.length>0||l.length>0||V.length>0||a.length>0||c.length>0,editedCommandIds:P,uncustomisedCommandIds:T,editedEnableRuleIds:W,editedDisplayRuleIds:U,deletedButtonIds:o,unhiddenButtonIds:[...i,...ee],deletedContainerIds:r,movedButtons:l,editedLocLabelIds:V,editedTabIds:a,renamedLabels:c,unsupported:[...new Set(t)],warnings:[...new Set(n)]}}const bh=["HomepageGrid","SubGrid","Form"];function yh(e,t){const n=new Map;for(const v of Object.values(t.baseline))for(const x of v.tabs)for(const g of x.groups)for(const y of g.buttons)n.set(y.id,y.origin);let o=!1,i=!1,r=Qo(e);for(const[v,x]of Object.entries(t.ribbons))for(const g of x.tabs)for(const y of g.groups)for(const C of y.buttons)C.commandId===e&&(bh.includes(v)?o=!0:i=!0,n.has(C.id)&&n.get(C.id)!=="unmanaged"&&(r=!0));const l=o||!i?"entity":"application",a=o&&i,c=t.layers[l],d=c?.commandIds?c.commandIds.includes(e):void 0,u=t.baselineCommands.find(v=>v.id===e),p=(v,x=l)=>({provenance:v,scope:x,sharedWithApplication:a});if(t.reloadRequiredCommandIds.includes(e))return p("reloadRequired");for(const v of["entity","application"])if(t.uncustomisedCommandIds[v].includes(e))return p("uncustomising",v);if(!u||!r&&d!==!1)return p("custom");if(d){const v=c?.commandRefIds?Ci(e,c.commandRefIds):Qo(e);return p(v?"customised":"custom")}const f=t.commands.find(v=>v.id===e),S=!!f&&JSON.stringify(f)!==JSON.stringify(u);return t.customisedCommandIds.includes(e)||S?p("customising"):p("oob")}const xh={oob:"Out of the box",customising:"Customised (unpublished)",customised:"Customised in your layer",uncustomising:"Uncustomised (unpublished)",custom:"Custom",reloadRequired:"Uncustomised — reload the table"};function $a(e){const t=D(d=>d.commands),n=D(d=>d.baselineCommands),o=D(d=>d.ribbons),i=D(d=>d.baseline),r=D(d=>d.layers),l=D(d=>d.customisedCommandIds),a=D(d=>d.uncustomisedCommandIds),c=D(d=>d.reloadRequiredCommandIds);return Ue.useMemo(()=>e&&t.some(d=>d.id===e)?yh(e,{commands:t,baselineCommands:n,ribbons:o,baseline:i,layers:r,customisedCommandIds:l,uncustomisedCommandIds:a,reloadRequiredCommandIds:c}):null,[e,t,n,o,i,r,l,a,c])}function My(e){return e?.provenance==="uncustomising"||e?.provenance==="reloadRequired"}function Ta({location:e,tabId:t,groupId:n,button:o,onDone:i}){const r=D(f=>f.customiseButton),l=D(f=>f.customiseCommand),a=ie(f=>f.activeSolution),c=ie(f=>f.publisherPrefix),d=Z(f=>f.selectButtonInContext),u=Y(f=>f.openCommandEditor),p=$a(o.commandId||void 0);return s.jsxs(s.Fragment,{children:[o.origin!=="unmanaged"&&s.jsx(pe,{icon:s.jsx(xl,{}),disabled:!Bi(e,t,o),onClick:()=>{const f=a?.publisherPrefix?.trim()||c?.trim()||"new",S=r(e,t,n,o.id,f);S&&d(e,t,n,S),i()},children:"Customise button (copy, hide original)"}),p?.provenance==="oob"&&s.jsx(pe,{icon:s.jsx(Ht,{}),onClick:()=>{l(o.commandId)&&u(o.commandId),i()},children:"Customise command"})]})}function ka(e,t,n,o,i){const r=e.groups.filter(a=>a.id!==t&&!(n&&a.buttons.some(c=>c.id===n))).map(a=>({groupId:a.id,text:ce(a.label,o,i).trim()||a.id})),l=new Map;for(const a of r)l.set(a.text,(l.get(a.text)??0)+1);return r.map(a=>(l.get(a.text)??0)>1&&a.text!==a.groupId?{...a,text:`${a.text} (${a.groupId})`}:a)}const Pi=({open:e,buttonLabel:t,commandId:n,deleteBlockedReason:o,onConfirmHide:i,onConfirmDisplayRule:r,onCancel:l})=>s.jsx(Gt,{open:e,onOpenChange:()=>l(),children:s.jsxs(Wt,{style:{maxWidth:"560px"},children:[s.jsxs(Ut,{children:[s.jsx(rr,{style:{marginRight:"8px",color:"var(--colorStatusWarningForeground1)"}}),o?`Can't delete "${t}"`:`Hide "${t}"`]}),s.jsxs(Xt,{children:[s.jsxs(Vt,{children:[o&&s.jsxs(q,{style:{display:"block",marginBottom:"12px"},children:[o," Only buttons your solution adds can be deleted — you can hide this one instead."]}),s.jsx(Ie,{intent:"warning",children:s.jsxs(Re,{children:[s.jsx(q,{weight:"semibold",children:"A HideCustomAction removes the button from the ribbon."})," ","To show it again, use Unhide under “Hidden by customizations” in the Properties pane; in a managed solution a hide can't be undone with a patch."]})}),s.jsxs(q,{style:{display:"block",marginTop:"12px"},children:["The reversible alternative adds the display rules ",s.jsx("code",{children:"Mscrm.HideOnModern"})," +"," ",s.jsx("code",{children:"Mscrm.ShowOnlyOnModern"})," (never both true) to the button's command",n?s.jsxs(s.Fragment,{children:[" ",s.jsx("code",{children:n}),". Every button that uses this command is hidden too."]}):s.jsx(s.Fragment,{children:". This button has no command, so only the HideCustomAction is available."})]})]}),s.jsxs(Jt,{children:[s.jsx(K,{appearance:"secondary",onClick:l,children:"Cancel"}),s.jsx(K,{appearance:"secondary",onClick:r,disabled:!n,children:"Use display rules (reversible)"}),s.jsx(K,{appearance:"primary",onClick:i,children:"Use HideCustomAction (permanent)"})]})]})]})}),Sh=({open:e,initialLabel:t,onRename:n,onCancel:o})=>{const[i,r]=M.useState(t),l=i.trim(),a=()=>{l&&(l===t.trim()?o():n(l))};return s.jsx(Gt,{open:e,onOpenChange:(c,d)=>!d.open&&o(),children:s.jsx(Wt,{style:{maxWidth:"440px"},children:s.jsxs(Xt,{children:[s.jsx(Ut,{children:"Rename group"}),s.jsx(Vt,{children:s.jsx(De,{label:"Group title",required:!0,validationState:l?"none":"error",validationMessage:l?void 0:"Enter a title for the group.",children:s.jsx(_e,{value:i,onChange:(c,d)=>r(d.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),a())},autoFocus:!0})})}),s.jsxs(Jt,{children:[s.jsx(K,{appearance:"secondary",onClick:o,children:"Cancel"}),s.jsx(K,{appearance:"primary",onClick:a,disabled:!l,children:"Rename"})]})]})})})},vh=e=>e.replace(/^Mscrm\.Templates\./,""),Ch=({open:e,currentTemplate:t,customTemplateIds:n=[],loadedGroup:o=!1,onChange:i,onCancel:r})=>{const l=Ri(t),[a,c]=M.useState(l),d=[...new Set([...np,...n,l])],u=()=>{a===l?r():i(a)};return s.jsx(Gt,{open:e,onOpenChange:(p,f)=>!f.open&&r(),children:s.jsx(Wt,{style:{maxWidth:"480px"},children:s.jsxs(Xt,{children:[s.jsx(Ut,{children:"Change group template"}),s.jsxs(Vt,{children:[s.jsx(De,{label:"Group template",children:s.jsx(dt,{value:a,onChange:(p,f)=>c(f.value),children:d.map(p=>s.jsxs("option",{value:p,children:[vh(p),p===l?" (current)":""]},p))})}),s.jsx(q,{size:200,style:{display:"block",marginTop:"8px"},children:"The group template defines how buttons scale when the ribbon is resized."}),o&&s.jsx(Ie,{intent:"warning",style:{marginTop:"12px"},children:s.jsx(Re,{children:"This group was loaded from the environment. Publishing can't change an existing group's template yet (it's reported as not supported); groups you add publish theirs."})})]}),s.jsxs(Jt,{children:[s.jsx(K,{appearance:"secondary",onClick:r,children:"Cancel"}),s.jsx(K,{appearance:"primary",onClick:u,disabled:a===l,children:"Change template"})]})]})})})},wh=le({destructive:{backgroundColor:m.colorStatusDangerBackground3,color:m.colorNeutralForegroundOnBrand,":hover":{backgroundColor:m.colorStatusDangerBackground3Hover,color:m.colorNeutralForegroundOnBrand},":hover:active":{backgroundColor:m.colorStatusDangerBackground3Pressed,color:m.colorNeutralForegroundOnBrand}}}),Fi=({open:e,title:t,children:n,confirmLabel:o,cancelLabel:i="Cancel",destructive:r=!1,onConfirm:l,onCancel:a})=>{const c=wh();return s.jsx(Gt,{modalType:"alert",open:e,onOpenChange:(d,u)=>!u.open&&a(),children:s.jsx(Wt,{style:{maxWidth:"480px"},children:s.jsxs(Xt,{children:[s.jsx(Ut,{children:t}),s.jsx(Vt,{children:n}),s.jsxs(Jt,{children:[s.jsx(K,{appearance:"secondary",onClick:a,children:i}),s.jsx(K,{appearance:"primary",className:r?c.destructive:void 0,onClick:l,children:o})]})]})})})};function Aa(e){const o=({columns:"layout_column_two",history:"clock_arrow_counterclockwise",window_dev_tools:"code_block"}[e.trim().toLowerCase()]??e).trim().replace(/_\d+_(regular|filled)$/i,"").replace(/_?(regular|filled)$/i,"").replace(/\d+(Regular|Filled)$/i,"").replace(/(Regular|Filled)$/i,"");return o?o.includes("_")?o.toLowerCase():o.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").toLowerCase():"apps_add_in"}const Da={add:{regular:Te,filled:du},delete:{regular:Lt,filled:cu},edit:{regular:no,filled:lu},save:{regular:ir,filled:au},copy:{regular:mn,filled:ru},cut:{regular:su,filled:iu},clipboardpaste:{regular:ou,filled:nu},share:{regular:tu,filled:eu},mail:{regular:Qd,filled:Zd},chat:{regular:Yd,filled:Kd},phone:{regular:Jd,filled:Vd},search:{regular:ft,filled:Xd},filter:{regular:Ud,filled:Wd},arrowleft:{regular:Gd,filled:Hd},arrowright:{regular:qd,filled:_d},arrowup:{regular:Fd,filled:Pd},arrowdown:{regular:Ld,filled:Md},chevrondown:{regular:gt,filled:Ed},chevronup:{regular:ur,filled:Od},navigation:{regular:Bd,filled:zd},home:{regular:Dd,filled:Ad},settings:{regular:nr,filled:kd},info:{regular:Td,filled:$d},warning:{regular:rr,filled:Nd},checkmark:{regular:jd,filled:Rd},dismiss:{regular:bi,filled:Id},questioncircle:{regular:or,filled:wd},lockclosed:{regular:wt,filled:Cd},lockopen:{regular:vd,filled:Sd},shield:{regular:xd,filled:yd},person:{regular:dr,filled:bd},people:{regular:gd,filled:hd},personadd:{regular:fd,filled:pd},building:{regular:md,filled:ud},briefcase:{regular:dd,filled:cd},money:{regular:ld,filled:ad},creditcard:{regular:rd,filled:sd},cart:{regular:id,filled:od},tag:{regular:nd,filled:td},document:{regular:to,filled:ed},documentbulletlist:{regular:Qc,filled:Zc},folder:{regular:Yc,filled:Kc},folderopen:{regular:Jc,filled:Vc},attach:{regular:Xc,filled:Uc},arrowdownload:{regular:Wc,filled:Gc},arrowupload:{regular:Hc,filled:qc},globe:{regular:cr,filled:_c},link:{regular:Fc,filled:Pc},open:{regular:Lc,filled:Mc},calendar:{regular:Ec,filled:Oc},clock:{regular:Bc,filled:zc},timer:{regular:Dc,filled:Ac},star:{regular:kc,filled:Tc},heart:{regular:$c,filled:Nc},thumblike:{regular:jc,filled:Rc},thumbdislike:{regular:Ic,filled:wc},eye:{regular:Ct,filled:Cc},eyeoff:{regular:Ye,filled:vc},zoomin:{regular:Sc,filled:xc},zoomout:{regular:yc,filled:bc},maximize:{regular:gc,filled:hc},minimize:{regular:fc,filled:pc},grid:{regular:mc,filled:uc},list:{regular:dc,filled:cc},table:{regular:lr,filled:lc},tablesimple:{regular:ac,filled:rc},code:{regular:Ht,filled:sc},bug:{regular:ic,filled:oc},play:{regular:nc,filled:tc},pause:{regular:ec,filled:Ql},stop:{regular:Zl,filled:Yl},refresh:{regular:Kl,filled:Jl},arrowsync:{regular:Vl,filled:Xl},arrowundo:{regular:Qs,filled:Ul},arrowredo:{regular:er,filled:Wl},printer:{regular:Gl,filled:Hl},send:{regular:ql,filled:_l},rocket:{regular:Fl,filled:Pl},sparkle:{regular:Ll,filled:Ml},trophy:{regular:El,filled:Ol},lightbulb:{regular:Bl,filled:zl},bot:{regular:Dl,filled:Al},databar:{regular:kl,filled:Tl},chartmultiple:{regular:$l,filled:Nl},poll:{regular:jl,filled:Rl},layoutcolumntwo:{regular:Il,filled:wl},codeblock:{regular:Cl,filled:vl},clockarrowcounterclockwise:{regular:ar,filled:Sl}},jt=({name:e,size:t=20,variant:n="regular",style:o,className:i,"aria-hidden":r=!0})=>{const l=Aa(e).replace(/_/g,""),a=Da[l],c=n==="filled"?a?.filled??a?.regular??Pt:a?.regular??Pt;return s.jsx(c,{fontSize:t,"aria-hidden":r,className:i,style:{display:"inline-block",verticalAlign:"middle",flexShrink:0,color:m.colorNeutralForeground1,...o}})};async function Ly(e,t=32,n="regular"){const o=Aa(e).replace(/_/g,""),i=Da[o],r=n==="filled"?i?.filled??i?.regular:i?.regular;if(!r)return null;const{renderToStaticMarkup:l}=await Ne(async()=>{const{renderToStaticMarkup:c}=await import("./server.browser-C3R9jebn.js").then(d=>d.s);return{renderToStaticMarkup:c}},__vite__mapDeps([29,2,3]),import.meta.url);let a=l(Ue.createElement(r,{fontSize:t}));return a.includes("<svg")?(a.includes("xmlns")||(a=a.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"')),a=a.replace(/width="1em"/,`width="${t}"`).replace(/height="1em"/,`height="${t}"`),a=a.replace(/\s(?:class|aria-hidden|focusable|data-fui-icon|font-size)="[^"]*"/g,""),a):null}const za="__end__";function Ih(e,t){return`slot::${e}::${t??za}`}function Rh(e){return`group::${e}`}function Is(e){if(e.startsWith("slot::")){const[,t,n]=e.split("::");return{kind:"slot",groupId:t,beforeButtonId:n===za?null:n}}return e.startsWith("group::")?{kind:"group",groupId:e.slice(7)}:null}const At={root:{display:"flex",gap:m.spacingHorizontalM,flexWrap:"wrap",alignItems:"flex-start",minHeight:"120px",padding:`${m.spacingVerticalS} ${m.spacingHorizontalM}`},groupButtons:{display:"flex",gap:m.spacingHorizontalXS,flexWrap:"wrap",minHeight:"72px",alignItems:"flex-start",padding:m.spacingHorizontalXS},groupLabel:{textAlign:"center",fontSize:m.fontSizeBase100,color:m.colorNeutralForeground3,borderTop:`1px solid ${m.colorNeutralStroke2}`,paddingTop:m.spacingVerticalXS,paddingBottom:m.spacingVerticalXS,marginTop:"auto"},emptyTab:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:m.spacingVerticalM,minHeight:"160px",color:m.colorNeutralForeground3,flex:1,padding:"48px",textAlign:"center"},addGroupBtn:{minHeight:"96px",width:"40px",display:"flex",alignItems:"center",justifyContent:"center",border:`1px dashed ${m.colorNeutralStroke2}`,borderRadius:m.borderRadiusMedium,cursor:"pointer",color:m.colorNeutralForeground3,backgroundColor:"transparent"},addButtonGhost:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"60px",minHeight:"72px",borderRadius:m.borderRadiusMedium,border:`1px dashed ${m.colorNeutralStroke2}`,backgroundColor:"transparent",cursor:"pointer",color:m.colorNeutralForeground3}};function jh({button:e}){const t=D(i=>i.locLabels),n=ce(e.label,t),o=e.icon||"apps_add_in";return s.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"4px",width:"60px",minHeight:"72px",padding:"4px",borderRadius:m.borderRadiusMedium,border:`1px solid ${m.colorBrandStroke1}`,backgroundColor:m.colorNeutralBackground1,boxShadow:m.shadow16,opacity:.9,cursor:"grabbing",pointerEvents:"none",color:e.custom?m.colorBrandForeground1:m.colorNeutralForeground1},children:[s.jsx(jt,{name:o,size:24}),s.jsx("span",{style:{fontSize:m.fontSizeBase100,textAlign:"center",lineHeight:"1.2",maxWidth:"56px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:m.colorNeutralForeground1},children:n})]})}function Nh({group:e,isDropTarget:t,children:n,...o}){const{setNodeRef:i,isOver:r}=vr({id:Rh(e.id),data:{type:"group",groupId:e.id}});return s.jsx("div",{ref:i,style:{display:"flex",flexDirection:"column",minWidth:"80px",border:`1px solid ${r||t?m.colorBrandStroke1:m.colorNeutralStroke2}`,borderRadius:m.borderRadiusMedium,backgroundColor:r||t?m.colorBrandBackground2:m.colorNeutralBackground2,padding:`${m.spacingVerticalXS} ${m.spacingHorizontalXS}`,transition:"border-color 0.1s, background-color 0.1s"},...o,children:n})}function Rs({groupId:e,beforeButtonId:t}){const n=Ih(e,t),{setNodeRef:o,isOver:i}=vr({id:n,data:{type:"slot",groupId:e,beforeButtonId:t}});return s.jsx("div",{ref:o,style:{width:i?"2px":"0px",minHeight:"72px",backgroundColor:m.colorBrandStroke1,borderRadius:"2px",flexShrink:0,transition:"width 0.1s"},"aria-hidden":!0})}function $h({tab:e,location:t}){const n=D(z=>z.locLabels),o=D(z=>z.baseLanguageCode),i=z=>ce(z.label,n,o)||z.id,r=D(z=>z.baseline),l=D(z=>z.templates),a=D(z=>z.moveButton),c=D(z=>z.createGroup),d=D(z=>z.deleteButton),u=D(z=>z.layers),p=D(z=>z.duplicateButton),f=D(z=>z.duplicateGroup),S=D(z=>z.setGroupTemplate),v=D(z=>z.hideOobButton),x=D(z=>z.customizeOobButton),g=D(z=>z.setButtonProp),y=D(z=>z.renameGroup),C=D(z=>z.deleteGroup),w=Y(z=>z.openNewButton),h=Y(z=>z.openNewGroup),I=Y(z=>z.openIconPicker),$=Y(z=>z.openLocalizationEditor),R=Z(z=>z.selectButtonInContext),B=Z(z=>z.selectGroup),[T,H]=M.useState(null),[k,P]=M.useState(null),[j,E]=M.useState(null),[N,W]=M.useState(null),[U,V]=M.useState(null),[ee,_]=M.useState(null),[L,O]=M.useState(null),[F,b]=M.useState(null),A=M.useMemo(()=>{if(!L)return null;for(const z of e.groups){const G=z.buttons.find(te=>te.id===L);if(G)return{button:G,groupId:z.id}}return null},[L,e.groups]),X=br(_n(xr,{activationConstraint:{distance:5}}),_n(yr)),re=z=>t==="Application"&&e.id==="Mscrm.GlobalTab"&&z.oob&&!z.custom,me=z=>Ze(z.kind);function Ee(z){O(String(z.active.id))}function Ce(z){const G=z.over;if(!G){b(null);return}const te=Is(String(G.id));b(te?te.groupId:null)}function He(z){const{active:G,over:te}=z;if(O(null),b(null),!te||!G)return;let Q=null;for(const Nt of e.groups)if(Nt.buttons.some(gl=>gl.id===G.id)){Q=Nt.id;break}if(!Q)return;const we=Is(String(te.id));if(!we)return;let ne=null;we.kind==="slot"?ne=a({groupId:Q,buttonId:String(G.id),tabId:e.id,location:t},{groupId:we.groupId,beforeButtonId:we.beforeButtonId??void 0,tabId:e.id,location:t}):we.kind==="group"&&we.groupId!==Q&&(ne=a({groupId:Q,buttonId:String(G.id),tabId:e.id,location:t},{groupId:we.groupId,tabId:e.id,location:t})),ne&&ne!==String(G.id)&&R(t,e.id,we.groupId,ne)}return e.groups.length===0?s.jsxs("div",{style:At.emptyTab,children:[s.jsx(to,{fontSize:36,"aria-hidden":!0}),s.jsx(q,{children:"This tab has no groups yet"}),s.jsxs("button",{type:"button",style:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"6px 16px",background:m.colorBrandBackground,color:m.colorNeutralForegroundInverted,border:"none",borderRadius:m.borderRadiusMedium,cursor:"pointer",fontSize:m.fontSizeBase300},onClick:()=>h(),children:[s.jsx(Te,{fontSize:12})," Add first group"]})]}):s.jsxs(s.Fragment,{children:[t==="SubGrid"&&s.jsx(Ie,{intent:"info",style:{margin:`${m.spacingVerticalS} ${m.spacingHorizontalM} 0`},children:s.jsxs(Re,{children:["Subgrid ribbons support only 3 native controls: ",s.jsx("strong",{children:"Add"}),","," ",s.jsx("strong",{children:"Show List"}),", and ",s.jsx("strong",{children:"Delete"}),". Their icons cannot be changed."]})}),s.jsxs(Sr,{sensors:X,collisionDetection:Ku,onDragStart:Ee,onDragOver:Ce,onDragEnd:He,children:[s.jsxs("div",{style:At.root,role:"treegrid","aria-label":"Ribbon canvas","data-ribbon-canvas-root":"1",children:[e.groups.map(z=>s.jsxs(Nh,{group:z,isDropTarget:F===z.id,role:"rowgroup","aria-label":i(z),tabIndex:0,"data-ribbon-group-id":z.id,onContextMenu:G=>{G.target.closest("[data-btn]")||(G.preventDefault(),P({group:z,x:G.clientX,y:G.clientY}))},onFocus:()=>B(z.id),onKeyDown:G=>{if((G.key==="Enter"||G.key===" ")&&z.buttons.length>0){G.preventDefault();const te=z.buttons[0];if(!te)return;R(t,e.id,z.id,te.id),document.querySelector(`[data-ribbon-btn-id="${te.id}"]`)?.focus()}},children:[s.jsxs("div",{style:At.groupButtons,children:[z.buttons.map(G=>s.jsxs(Ue.Fragment,{children:[L&&s.jsx(Rs,{groupId:z.id,beforeButtonId:G.id}),s.jsx(Th,{button:G,groupId:z.id,tabId:e.id,location:t,activeId:L,onContextMenu:te=>H({groupId:z.id,button:G,x:te.clientX,y:te.clientY})})]},G.id)),L&&s.jsx(Rs,{groupId:z.id,beforeButtonId:null}),s.jsxs("button",{type:"button",style:At.addButtonGhost,"data-add-btn-group-id":z.id,onClick:()=>w(z.id),title:`Add button to ${i(z)}`,"aria-label":`Add button to ${i(z)}`,children:[s.jsx(Te,{fontSize:16}),s.jsx(q,{size:100,style:{color:"inherit"},children:"Add"})]})]}),s.jsx(ke,{content:`Template: ${z.template||"Flexible2"}`,relationship:"description",children:s.jsx("div",{style:At.groupLabel,children:i(z)})})]},z.id)),s.jsx("button",{type:"button",style:At.addGroupBtn,onClick:()=>c({tabId:e.id,location:t,group:{label:"New Group",sequence:(e.groups.length+1)*10,template:"Flexible2",buttons:[]}}),title:"Add group","aria-label":"Add group",children:s.jsx(Te,{fontSize:16})})]}),s.jsx(Yu,{dropAnimation:null,children:A?s.jsx(jh,{button:A.button}):null})]}),T&&s.jsxs(Fo,{open:!0,onOpenChange:(z,G)=>!G.open&&H(null),positioning:{position:"below",align:"start",target:{getBoundingClientRect:()=>({x:T.x,y:T.y,top:T.y,left:T.x,right:T.x,bottom:T.y,width:0,height:0,toJSON:()=>({})})}},children:[s.jsx(_o,{disableButtonEnhancement:!0,children:s.jsx("span",{style:{display:"none"}})}),s.jsx(qo,{children:s.jsxs(Ho,{children:[re(T.button)&&s.jsx(pe,{disabled:!0,icon:s.jsx(wt,{}),children:"OOB global command bar buttons cannot be customized."}),re(T.button)&&s.jsx(pt,{}),s.jsx(pe,{icon:s.jsx(no,{}),onClick:()=>{R(t,e.id,T.groupId,T.button.id),H(null)},children:"Edit properties"}),s.jsx(pe,{icon:s.jsx(Pn,{}),disabled:re(T.button)||me(T.button),onClick:()=>{R(t,e.id,T.groupId,T.button.id),I(),H(null)},children:"Change icon…"}),s.jsx(pe,{icon:s.jsx(mr,{}),disabled:re(T.button)||me(T.button),onClick:()=>{$(T.button.id),H(null)},children:"Edit labels…"}),s.jsx(pt,{}),T.button.hidden?s.jsx(pe,{icon:s.jsx(Ct,{}),disabled:re(T.button),onClick:()=>{g(t,e.id,T.groupId,T.button.id,{hidden:!1}),H(null)},children:"Show button"}):s.jsx(pe,{icon:s.jsx(Ye,{}),disabled:re(T.button),onClick:()=>{T.button.oob?E(T):g(t,e.id,T.groupId,T.button.id,{hidden:!0}),H(null)},children:"Hide button"}),(T.button.origin==="oob"||T.button.origin==="managed")&&s.jsx(pe,{icon:s.jsx(Pt,{}),disabled:re(T.button)||me(T.button),onClick:()=>{x(t,e.id,T.groupId,T.button.id),H(null)},children:"Create override…"}),s.jsx(Ta,{location:t,tabId:e.id,groupId:T.groupId,button:T.button,onDone:()=>H(null)}),s.jsx(pt,{}),s.jsx(pe,{icon:s.jsx(mn,{}),disabled:re(T.button),onClick:()=>{p(t,e.id,T.groupId,T.button.id),H(null)},children:"Duplicate"}),ka(e,T.groupId,T.button.id,n,o).map(z=>s.jsxs(pe,{icon:s.jsx(pr,{}),disabled:re(T.button),onClick:()=>{const G=a({groupId:T.groupId,buttonId:T.button.id,tabId:e.id,location:t},{groupId:z.groupId,tabId:e.id,location:t});G&&R(t,e.id,z.groupId,G),H(null)},children:["Move to: ",z.text]},z.groupId)),In(T.button,r[t])&&s.jsxs(s.Fragment,{children:[s.jsx(pt,{}),s.jsx(pe,{icon:s.jsx(Lt,{}),disabled:re(T.button),onClick:()=>{d(t,e.id,T.groupId,T.button.id),H(null)},children:"Delete"})]})]})})]}),k&&s.jsxs(Fo,{open:!0,onOpenChange:(z,G)=>!G.open&&P(null),positioning:{position:"below",align:"start",target:{getBoundingClientRect:()=>({x:k.x,y:k.y,top:k.y,left:k.x,right:k.x,bottom:k.y,width:0,height:0,toJSON:()=>({})})}},children:[s.jsx(_o,{disableButtonEnhancement:!0,children:s.jsx("span",{style:{display:"none"}})}),s.jsx(qo,{children:s.jsxs(Ho,{children:[s.jsx(pe,{icon:s.jsx(uu,{}),onClick:()=>{W(k.group),P(null)},children:"Rename…"}),s.jsx(pe,{icon:s.jsx(mn,{}),onClick:()=>{f(t,e.id,k.group.id),P(null)},children:"Duplicate group"}),s.jsx(pe,{icon:s.jsx(Pt,{}),onClick:()=>{V(k.group),P(null)},children:"Change template…"}),$i(k.group,r[t],Jn({layers:u},t))&&s.jsxs(s.Fragment,{children:[s.jsx(pt,{}),s.jsx(pe,{icon:s.jsx(Lt,{}),onClick:()=>{_(k.group),P(null)},children:"Delete group"})]})]})})]}),N&&s.jsx(Sh,{open:!0,initialLabel:i(N),onRename:z=>{y(t,e.id,N.id,z),W(null)},onCancel:()=>W(null)}),U&&s.jsx(Ch,{open:!0,currentTemplate:U.template,customTemplateIds:l.map(z=>z.id),loadedGroup:r[t].tabs.some(z=>z.id===e.id&&z.groups.some(G=>G.id===U.id)),onChange:z=>{S(t,e.id,U.id,z),V(null)},onCancel:()=>V(null)}),ee&&s.jsxs(Fi,{open:!0,title:"Delete group",confirmLabel:"Delete group",destructive:!0,onConfirm:()=>{C(t,e.id,ee.id),_(null)},onCancel:()=>_(null),children:["Delete the group “",i(ee),"” and its ",ee.buttons.length," button",ee.buttons.length===1?"":"s","?"]}),j&&s.jsx(Pi,{open:!0,buttonLabel:ce(j.button.label,n),onConfirmHide:()=>{v(t,e.id,j.groupId,j.button.id),E(null)},commandId:j.button.commandId,onConfirmDisplayRule:()=>{D.getState().hideWithDisplayRules(j.button.commandId),E(null)},onCancel:()=>E(null)})]})}const Th=Ue.memo(function({button:t,groupId:n,tabId:o,location:i,activeId:r,onContextMenu:l}){const a=Z(R=>R.selectedButtonId),c=Z(R=>R.selectButtonInContext),d=D(R=>R.locLabels),u=a===t.id,p=i==="Application"&&o==="Mscrm.GlobalTab"&&t.oob&&!t.custom,f=ce(t.label,d),S=Ze(t.kind)?qn[t.kind]:void 0,v=S?` (${S}, read-only)`:"",{attributes:x,listeners:g,setNodeRef:y,isDragging:C}=Ju({id:t.id,data:{type:"button",button:t,groupId:n},disabled:t.managed||p}),w=C||r===t.id,h={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"4px",width:"60px",minHeight:"72px",padding:"4px",borderRadius:m.borderRadiusMedium,cursor:"grab",border:u?`1px solid ${m.colorBrandStroke1}`:t.custom?`1px solid ${m.colorBrandStroke2}`:"1px solid transparent",backgroundColor:u?m.colorBrandBackground2:t.managed?m.colorNeutralBackground3:"transparent",opacity:w?.3:t.hidden?.4:1,position:"relative",userSelect:"none",color:t.custom?m.colorBrandForeground1:m.colorNeutralForeground1,transition:"opacity 0.15s, border-color 0.1s, background-color 0.1s"},I=t.icon||"apps_add_in",$=R=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(R.key))return;R.preventDefault();const B=R.currentTarget.closest("[data-ribbon-canvas-root='1']");if(!B)return;const T=Array.from(B.querySelectorAll(`[data-ribbon-tab-id="${o}"][data-btn="1"]`)),H=T.findIndex(W=>W.dataset.ribbonBtnId===t.id);if(H<0||T.length===0)return;const k=R.key==="ArrowLeft"||R.key==="ArrowUp"?-1:1,P=Math.max(0,Math.min(T.length-1,H+k)),j=T[P],E=j?.dataset.ribbonGroupId,N=j?.dataset.ribbonBtnId;!j||!E||!N||(c(i,o,E,N),j.focus())};return s.jsx(ke,{content:p?"OOB global command bar buttons cannot be customized.":`${f}${v}${t.hidden?" — hidden":""}`,relationship:"label",children:s.jsxs("button",{ref:y,type:"button","data-btn":"1","data-ribbon-tab-id":o,"data-ribbon-group-id":n,"data-ribbon-btn-id":t.id,style:h,"aria-selected":u,"aria-label":`${f}${v}${t.hidden?" — hidden":""}${t.custom?" (custom)":""}${t.managed?" (read-only)":""}`,onClick:()=>c(i,o,n,t.id),onFocus:()=>c(i,o,n,t.id),onKeyDown:R=>{if(R.key==="Enter"||R.key===" "){R.preventDefault(),c(i,o,n,t.id);return}$(R)},onContextMenu:R=>{R.preventDefault(),R.stopPropagation(),c(i,o,n,t.id),l(R)},...x,...g,children:[s.jsx(jt,{name:I,size:24,style:{filter:t.custom?"none":"grayscale(40%) opacity(0.85)"}}),s.jsx("span",{style:{fontSize:m.fontSizeBase100,textAlign:"center",lineHeight:"1.2",maxWidth:"56px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:m.colorNeutralForeground1},children:f}),S&&s.jsx("span",{style:{fontSize:m.fontSizeBase100,lineHeight:"1",maxWidth:"56px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:m.colorNeutralForeground3},children:S}),t.menu&&s.jsx(gt,{fontSize:10,"aria-label":"Has a menu"}),t.hidden&&s.jsx("span",{style:{position:"absolute",top:2,right:2},"aria-hidden":!0,children:s.jsx(Ye,{fontSize:10,style:{color:m.colorNeutralForeground3}})}),t.custom&&!t.managed&&s.jsx(ae,{size:"extra-small",color:"brand",appearance:"tint",style:{position:"absolute",bottom:2,right:2},"aria-label":"Custom",children:"NEW"}),(t.managed||p)&&s.jsx("span",{style:{position:"absolute",top:2,left:2},title:p?"OOB global command bar buttons cannot be customized.":"Read-only (managed)",children:s.jsx(wt,{fontSize:10,style:{color:m.colorNeutralForeground3}})})]})})}),ge=Rt()((e,t)=>({tableLogicalName:null,status:"idle",error:null,commands:[],apps:[],appFilter:"all",selectedCommandId:null,loadToken:0,beginLoad(n){const o=t().loadToken+1;return e({tableLogicalName:n,status:"loading",error:null,commands:[],apps:[],selectedCommandId:null,loadToken:o}),o},finishLoad(n,o){if(n!==t().loadToken)return;const{appFilter:i}=t(),r=i==="all"||o.apps.some(l=>l.id===i);e({status:o.error?"unavailable":"loaded",error:o.error??null,commands:o.commands,apps:o.apps,appFilter:r?i:"all"})},reset(){e(n=>({tableLogicalName:null,status:"idle",error:null,commands:[],apps:[],selectedCommandId:null,loadToken:n.loadToken+1}))},setAppFilter(n){e({appFilter:n?n.toLowerCase():"all"})},selectCommand(n){n&&Z.getState().clearSelection(),e({selectedCommandId:n})}}));Z.subscribe((e,t)=>{if(!ge.getState().selectedCommandId)return;(e.selectedButtonId&&e.selectedButtonId!==t.selectedButtonId||e.location!==t.location||e.tabId!==t.tabId)&&ge.setState({selectedCommandId:null})});const an={Form:0,MainGrid:1,SubGrid:2,AssociatedGrid:3,GlobalHeader:5},Ba={0:"Form",1:"Main grid",2:"Subgrid",3:"Associated grid",4:"Quick form",5:"Global header",6:"Dashboard"},Oa="appaction_appactionrule_classicrules",kh=["appactionid","name","uniquename","buttonlabeltext","buttontooltiptitle","buttontooltipdescription","buttonaccessibilitytext","_appmoduleid_value","context","_contextentity_value","contextvalue","location","type","sequence","buttonsequencepriority","hidden","isdisabled","origin","ismanaged","fonticon","_iconwebresourceid_value","_parentappactionid_value","grouptitle","isgrouptitlehidden","onclickeventtype","onclickeventjavascriptfunctionname","onclickeventjavascriptparameters","_onclickeventjavascriptwebresourceid_value","onclickeventformulacomponentlibrary","onclickeventformulacomponentname","onclickeventformulafunctionname","visibilitytype","visibilityformulacomponentlibrary","visibilityformulacomponentname","visibilityformulafunctionname"],Bo="@OData.Community.Display.V1.FormattedValue",ve=e=>typeof e=="string"&&e.trim()!==""?e:typeof e=="number"?String(e):void 0,ct=e=>{if(e==null||e==="")return;const t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:void 0},An=e=>e===!0||e===1||e==="true"||e==="1",yt=e=>{const t=ve(e);return t?t.toLowerCase():null};function Ah(e){switch(ct(e)){case 1:return"dropdown";case 2:return"split";case 3:return"group";default:return"button"}}function Dh(e){const t=ct(e);return t===1?"formula":t===2?"javascript":"none"}function zh(e){const t=ct(e);return t===1?"formula":t===2?"classicRules":"none"}function Bh(e){const t=ct(e);return t===1?"migrated":t===2?"enhancedMigrated":"default"}function js(e,t){const n={componentLibrary:ve(e[`${t}componentlibrary`]),componentName:ve(e[`${t}componentname`]),functionName:ve(e[`${t}functionname`])};return n.componentLibrary||n.componentName||n.functionName?n:void 0}function Oh(e){return Array.isArray(e)?e.map(t=>{const n=yt(t.appactionruleid);return n?{id:n,name:ve(t.name)??ve(t.uniquename)??n,uniqueName:ve(t.uniquename),kind:ct(t.type)===0?"enable":"display"}:null}).filter(t=>t!==null):[]}function Eh(e){const t=yt(e.appactionid);if(!t)return null;const n=ct(e.location);if(n===void 0)return null;const o=ve(e.name)??"",i=ve(e.uniquename)??o;return{id:t,name:o,uniqueName:i,label:ve(e.buttonlabeltext)??(o||i||t),tooltipTitle:ve(e.buttontooltiptitle),tooltipDescription:ve(e.buttontooltipdescription),accessibilityText:ve(e.buttonaccessibilitytext),appModuleId:yt(e._appmoduleid_value),appName:ve(e[`_appmoduleid_value${Bo}`]),scope:ct(e.context)===0?"all":"entity",contextValue:ve(e.contextvalue),contextEntityId:yt(e._contextentity_value)??void 0,location:n,type:Ah(e.type),sequence:ct(e.sequence)??ct(e.buttonsequencepriority)??0,hidden:An(e.hidden),disabled:An(e.isdisabled),origin:Bh(e.origin),managed:An(e.ismanaged),fontIcon:ve(e.fonticon),iconWebResourceId:yt(e._iconwebresourceid_value)??void 0,iconWebResourceName:ve(e[`_iconwebresourceid_value${Bo}`]),parentId:yt(e._parentappactionid_value),groupTitle:ve(e.grouptitle),groupTitleHidden:An(e.isgrouptitlehidden),action:Dh(e.onclickeventtype),jsFunctionName:ve(e.onclickeventjavascriptfunctionname),jsParameters:ve(e.onclickeventjavascriptparameters),jsWebResourceId:yt(e._onclickeventjavascriptwebresourceid_value)??void 0,jsWebResourceName:ve(e[`_onclickeventjavascriptwebresourceid_value${Bo}`]),onSelectFormula:js(e,"onclickeventformula"),visibility:zh(e.visibilitytype),visibilityFormula:js(e,"visibilityformula"),classicRules:Oh(e[Oa])}}function Mh(e){const t=new Map;for(const n of e){const o=Eh(n);o&&!t.has(o.id)&&t.set(o.id,o)}return[...t.values()]}function Lh(e){switch(e){case"HomepageGrid":return[an.MainGrid];case"SubGrid":return[an.SubGrid,an.AssociatedGrid];case"Form":return[an.Form];case"Application":return[an.GlobalHeader]}}function Ph(e,t){if(e.scope==="all")return!0;const n=t.metadataId?.toLowerCase();return n&&e.contextEntityId===n?!0:!!e.contextValue&&e.contextValue.toLowerCase()===t.logicalName.toLowerCase()}function Fh(e,t){return t==="all"||e.appModuleId===null||e.appModuleId===t.toLowerCase()}function _h(e,t){const n=new Set(Lh(t.location));return e.filter(o=>n.has(o.location)&&Fh(o,t.appFilter)&&Ph(o,t.table))}const pi=(e,t)=>e.sequence-t.sequence||e.label.localeCompare(t.label)||e.id.localeCompare(t.id);function Ea(e){const t=new Set(e.map(l=>l.id)),n=new Map,o=[];for(const l of e)if(l.parentId&&l.parentId!==l.id&&t.has(l.parentId)){const a=n.get(l.parentId)??[];a.push(l),n.set(l.parentId,a)}else o.push(l);const i=new Set,r=l=>{i.add(l.id);const a=(n.get(l.id)??[]).filter(c=>!i.has(c.id)).sort(pi);return{command:l,children:a.map(r)}};return o.sort(pi).map(r)}function Ma(e){return e.flatMap(t=>[t.command,...Ma(t.children)])}const La=/\{!EntityLogicalName\}/gi,qh=/(?:![A-Za-z0-9_]+)*!\d+$/;function Hh(e,t){if(e.origin==="default")return[];const n=[],o=i=>{i.includes(".")&&!n.includes(i)&&n.push(i)};for(const i of[e.uniqueName,e.name]){if(!i)continue;const r=i.trim().replace(La,t).replace(qh,""),l=r.indexOf("_"),a=r.indexOf(".");l>0&&(a===-1||l<a)&&o(r.slice(l+1)),o(r)}return n}function fi(e,t){return e.replace(La,t).toLowerCase()}function Ns(e,t){const n=fi(e,t).split(".");return n.length<4||n[0]!=="mscrm"?null:[n[0],n[1],"*",...n.slice(3)].join(".")}function $s(e,t,n,o={}){const i=new Map,r=new Map;for(const a of t){const c=fi(a,n);i.has(c)||i.set(c,a);const d=Ns(a,n);d&&!r.has(d)&&r.set(d,a)}const l=new Map;for(const a of e){if(a.disabled&&!o.includeDisabled)continue;const c=Hh(a,n),d=c.map(p=>i.get(fi(p,n))).find(Boolean)??c.map(p=>Ns(p,n)).map(p=>p?r.get(p):void 0).find(Boolean);if(!d)continue;const u=l.get(d)??[];u.push({buttonId:d,command:a,effect:a.hidden?"hidden":"replaced"}),l.set(d,u)}return l}function Gh(e,t,n){const o=l=>l.toLowerCase(),i=`mscrm.${o(t)}.${o(n)}.maintab`,r=e.find(l=>l.id==="Mscrm.GlobalTab")?.id;return t==="Application"&&r?r:e.find(l=>o(l.id)===i)?.id??e.find(l=>/maintab$/i.test(l.id)&&!/\.allentities\./i.test(l.id))?.id??r??e[0]?.id}function Pa(e){return(e.menu?.sections??[]).flatMap(t=>t.controls.flatMap(n=>[n,...Pa(n)]))}function Wh(e){const{commands:t,tabs:n,location:o,entityLogicalName:i}=e,r=n.flatMap(y=>y.groups.flatMap(C=>C.buttons)),l=[...r,...r.flatMap(Pa)].map(y=>y.id),a=new Map(t.map(y=>[y.id,y])),c=new Set([...$s(t,l,i,{includeDisabled:!0}).values()].flat().map(y=>y.command.id)),d=new Map,u=(y,C=new Set)=>{const w=d.get(y.id);if(w!==void 0)return w;let h=y.parentId?a.get(y.parentId):void 0;for(const $=new Set;h?.type==="group"&&!c.has(h.id)&&!$.has(h.id);)$.add(h.id),h=h.parentId?a.get(h.parentId):void 0;const I=c.has(y.id)&&(!h||!C.has(h.id)&&u(h,C.add(y.id)));return d.set(y.id,I),I},f=(y=>{for(const[C,w]of y){const h=w.filter(I=>u(I.command));h.length>0?y.set(C,h):y.delete(C)}return y})($s(t,l,i)),S=new Set([...f.values()].flat().map(y=>y.command.id)),v=y=>{const C=new Set;for(let w=y.parentId;w&&!C.has(w);w=a.get(w)?.parentId??null){C.add(w);const h=a.get(w);if(h&&u(h))return w}},x=new Map,g=[];for(const y of t){const C=v(y);if(!C){u(y)||g.push(y);continue}if(S.has(y.id))continue;const w=x.get(C)??[];w.push(y),x.set(C,w)}for(const y of f.values())for(const C of y){const w=x.get(C.command.id);w&&(C.items=[...w].sort(pi))}return{commandBarTabId:Gh(n,o,i),nodes:Ea(g),overrides:f,unmatchedMigrated:g.filter(y=>y.origin!=="default")}}function Uh(e,t){const n=new Map,o=[];for(const i of t){const r=e.find(a=>a.sequence>i.command.sequence);if(!r){o.push(i);continue}const l=n.get(r.id)??[];l.push(i),n.set(r.id,l)}return{before:n,trailing:o}}function Ts(e){if(!e)return;const t=[e.componentName,e.functionName].filter(Boolean).join("."),n=e.componentLibrary?` (component library ${e.componentLibrary})`:"";return`${t||"Power Fx formula"}${n}`}function Xh(e,t){if(!t)return e;const n=new Set([...t].map(o=>o.toLowerCase()));return e.filter(o=>o.appModuleId===null||n.has(o.appModuleId))}function Vh(e,t,n){const o=new Map(t.map(r=>[r.id.toLowerCase(),r])),i=new Map;for(const r of n??[]){const l=o.get(r.toLowerCase());l&&i.set(l.id.toLowerCase(),l)}if(n)return[...i.values()].sort((r,l)=>r.name.localeCompare(l.name)||r.id.localeCompare(l.id));for(const r of e)!r.appModuleId||i.has(r.appModuleId)||i.set(r.appModuleId,o.get(r.appModuleId)??{id:r.appModuleId,name:r.appName??r.appModuleId});return[...i.values()].sort((r,l)=>r.name.localeCompare(l.name)||r.id.localeCompare(l.id))}function xn(e,t){return e.appModuleId===null?"All apps":t?.get(e.appModuleId)??e.appName??e.appModuleId}function _i(e,t){const n=xn(e.command,t),o=e.command.appModuleId===null?"in all apps":`in ${n}`,i=e.effect==="hidden"?`Hidden by modern command ${e.command.label} ${o}`:`Rendered as modern command ${e.command.label} ${o} (migrated)`;return e.items?.length?`${i}; its menu also has ${e.items.map(r=>r.label).join(", ")}`:i}function Fa(e,t){if(!e?.length)return"";const n=e.find(o=>o.effect==="hidden");return n?` — ${_i(n,t).replace(/^Hidden/,"hidden")}`:" — modern (migrated)"}const Jh={button:"Command",dropdown:"Dropdown",split:"Split button",group:"Group"},Kh={default:"Command designer",migrated:"Migrated from classic",enhancedMigrated:"Enhanced migrated from classic"};function _a(e,t){const n=[{label:"App",value:xn(e,t)},{label:"Location",value:`${Ba[e.location]??`Location ${e.location}`}${e.scope==="all"?" (all tables)":""}`},{label:"Type",value:Jh[e.type]},{label:"Order",value:String(e.sequence)},{label:"Origin",value:Kh[e.origin]}];if(e.hidden?n.push({label:"Status",value:"Hidden"}):e.disabled&&n.push({label:"Status",value:e.origin==="default"?"Disabled":"Disabled — the classic (ribbon) equivalent is shown"}),e.visibility==="formula")n.push({label:"Visible (Power Fx)",value:Ts(e.visibilityFormula)??"Power Fx formula"});else if(e.visibility==="classicRules"){const o=e.classicRules.filter(i=>i.kind==="display").map(i=>i.name);n.push({label:"Visibility",value:o.length?`Classic rules: ${o.join(", ")}`:"Classic rules"})}if(e.action==="formula")n.push({label:"OnSelect (Power Fx)",value:Ts(e.onSelectFormula)??"Power Fx formula"});else if(e.action==="javascript"){const o=e.jsWebResourceName??e.jsWebResourceId,i=e.jsFunctionName??"(no function)";n.push({label:"Action (JavaScript)",value:o?`${i} in ${o}`:i}),e.jsParameters&&n.push({label:"Parameters",value:e.jsParameters})}return n}function Yh(){return window.dataverseAPI}const Sn=e=>e instanceof Error?e.message:String(e);async function eo(e){const t=[],n=new Set;let o=e;for(;o&&!n.has(o);){n.add(o);const i=await Yh().queryData(o);t.push(...i.value??[]);const r=i["@odata.nextLink"];o=r?r.replace(/^.*\/api\/data\/v[\d.]+\//,""):void 0}return t}function qa(e){return/\b40[13]\b|0x80040220|prvRead|privilege|unauthori[sz]ed|forbidden|not have permission/i.test(Sn(e))}const Ha=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function ks(e,t){const n=[`contextvalue eq '${e.logicalName.replace(/'/g,"''")}'`];e.metadataId&&Ha.test(e.metadataId)&&n.push(`_contextentity_value eq ${e.metadataId}`);const o=`statecode eq 0 and (context eq 0 or ${n.join(" or ")}) and (location eq 0 or location eq 1 or location eq 2 or location eq 3 or location eq 5)`,i=t?`&$expand=${Oa}($select=appactionruleid,name,uniquename,type)`:"";return`appactions?$select=${kh.join(",")}&$filter=${o}${i}`}async function Zh(e){const t=oe.getState();let n;try{n=await eo(ks(e,!0))}catch(o){if(qa(o))throw o;t.logInfo("dataverse",`Modern commands: classic rules couldn't be expanded (${Sn(o)}); retrying without them.`),n=await eo(ks(e,!1))}return Mh(n)}async function Qh(e){const t=oe.getState(),n="appmodules?$select=appmoduleid,appmoduleidunique,name,uniquename",o=e.metadataId&&Ha.test(e.metadataId)?`appmodulecomponents?$select=_appmoduleidunique_value&$filter=componenttype eq 1 and objectid eq ${e.metadataId}`:null,[i,r]=await Promise.all([eo(n),o?eo(o).catch(d=>(t.logInfo("dataverse",`Modern commands: couldn't resolve which apps contain ${e.logicalName} (${Sn(d)}).`),null)):Promise.resolve(null)]),l=i,a=l.filter(d=>!!d.appmoduleid).map(d=>({id:String(d.appmoduleid).toLowerCase(),name:d.name?.trim()||d.uniquename||String(d.appmoduleid),uniqueName:d.uniquename}));let c=null;if(r){const d=new Set(r.map(u=>u._appmoduleidunique_value).filter(u=>typeof u=="string").map(u=>u.toLowerCase()));c=new Set(l.filter(u=>u.appmoduleid&&u.appmoduleidunique&&d.has(u.appmoduleidunique.toLowerCase())).map(u=>String(u.appmoduleid).toLowerCase()))}return{apps:a,containingAppIds:c}}async function eg(e){const t=oe.getState(),[n,o]=await Promise.allSettled([Zh(e),Qh(e)]);if(n.status==="rejected"){const a=Sn(n.reason);return t.logWarn("dataverse",qa(n.reason)?`No permission to read modern commands (appaction) for ${e.logicalName}; the canvas shows classic commands only. (${a})`:`Modern commands unavailable for ${e.logicalName}: ${a}`),{commands:[],apps:[],error:a}}o.status==="rejected"&&t.logInfo("dataverse",`Modern commands: app list unavailable (${Sn(o.reason)}); showing app ids from the commands.`);const{apps:i,containingAppIds:r}=o.status==="fulfilled"?o.value:{apps:[],containingAppIds:null},l=Xh(n.value,r);return t.logInfo("dataverse",`Loaded ${l.length} modern command${l.length===1?"":"s"} for ${e.logicalName}.`),{commands:l,apps:Vh(l,i,r)}}function tg(){const e=ie(n=>n.activeEntity?.logicalName),t=ie(n=>n.activeEntity?.metadataId);M.useEffect(()=>{const n=ge.getState();if(!e||typeof window.dataverseAPI>"u"){n.reset();return}const o=n.beginLoad(e);eg({logicalName:e,metadataId:t}).then(i=>ge.getState().finishLoad(o,i))},[e,t])}function Zt(){const e=ge(n=>n.apps),t=ge(n=>n.commands);return M.useMemo(()=>{const n=new Map;for(const o of t)o.appModuleId&&o.appName&&n.set(o.appModuleId,o.appName);for(const o of e)n.set(o.id,o.name);return n},[e,t])}function Ga(e){const t=ge(r=>r.commands),n=ge(r=>r.appFilter),o=ie(r=>r.activeEntity?.logicalName),i=ie(r=>r.activeEntity?.metadataId);return M.useMemo(()=>o?_h(t,{location:e,appFilter:n,table:{logicalName:o,metadataId:i}}):[],[t,n,e,o,i])}const As=new Set;function qi(e){const t=Ga(e),n=ie(u=>u.activeEntity?.logicalName)??"",o=D(u=>u.ribbons[e]?.tabs),i=D(u=>u.ribbons[e]?.entityLogicalName??""),r=ge(u=>u.status==="loaded"?u.tableLogicalName:null),l=(o?.length??0)>0&&(e==="Application"||i.toLowerCase()===n.toLowerCase()),a=M.useMemo(()=>Wh({commands:t,tabs:l?o??[]:[],location:e,entityLogicalName:n}),[t,o,l,e,n]),d=!!n&&r===n&&l?a.unmatchedMigrated.map(u=>u.uniqueName).join(", "):"";return M.useEffect(()=>{const u=`${n}|${e}|${d}`;!d||As.has(u)||(As.add(u),oe.getState().logInfo("ribbon",`Migrated modern commands without a classic control in ${n} ${e}: ${d}`))},[d,n,e]),a}function Hi(e,t){const n=qi(e);return M.useMemo(()=>{const o=t.groups.flatMap(r=>r.buttons.map(l=>({id:l.id,sequence:l.sequence}))),i=t.id===n.commandBarTabId?n.nodes:[];return{nodes:i,placement:Uh(o,i),overrides:n.overrides}},[n,t])}function ng(e,t){const{overrides:n}=qi(e);return t&&n.get(t)||og}const og=[];function ig(){const e=ge(i=>i.selectedCommandId),t=Z(i=>i.selectedButtonId),n=Z(i=>i.location),o=Ga(n);return M.useMemo(()=>{if(!e||t)return null;const i=o.find(l=>l.id===e);if(!i)return null;let r;for(const l of Ea(o))if(r=Wa(l,e),r)break;return{command:i,children:r?Ma(r.children):[]}},[e,t,o])}function Wa(e,t){if(e.command.id===t)return e;for(const n of e.children){const o=Wa(n,t);if(o)return o}}const Ua=le({chip:{display:"flex",alignItems:"center",gap:m.spacingHorizontalXS,height:"32px",padding:`0 ${m.spacingHorizontalS}`,borderRadius:m.borderRadiusMedium,border:`1px dashed ${m.colorPaletteBerryBorderActive}`,backgroundColor:m.colorPaletteBerryBackground1,color:m.colorNeutralForeground1,cursor:"default",whiteSpace:"nowrap",flexShrink:0,userSelect:"none",":hover":{backgroundColor:m.colorPaletteBerryBackground2},":focus-visible":{outline:`2px solid ${m.colorBrandStroke1}`,outlineOffset:"2px"}},selected:{border:`1px solid ${m.colorPaletteBerryForeground2}`,backgroundColor:m.colorPaletteBerryBackground2},muted:{opacity:.5},hidden:{textDecoration:"line-through"},tooltip:{display:"flex",flexDirection:"column",gap:"2px",maxWidth:"360px"},tooltipRow:{fontSize:m.fontSizeBase200,overflowWrap:"anywhere"}});function Xa({node:e,appNames:t}){const n=Ua(),o=e.command;return s.jsxs("div",{className:n.tooltip,children:[s.jsx(q,{weight:"semibold",children:o.label}),s.jsx(q,{className:n.tooltipRow,children:"Modern command — read-only in CBS; edit it in the command designer."}),_a(o,t).map(i=>s.jsxs(q,{className:n.tooltipRow,children:[s.jsxs("b",{children:[i.label,":"]})," ",i.value]},i.label)),e.children.length>0&&s.jsxs(q,{className:n.tooltipRow,children:[s.jsx("b",{children:"Items:"})," ",e.children.map(i=>i.command.label).join(", ")]})]})}function sg({node:e,appNames:t,showApp:n,onDragRejected:o}){const i=Ua(),r=e.command,l=ge(v=>v.selectedCommandId),a=ge(v=>v.selectCommand),c=Z(v=>v.selectedButtonId),d=l===r.id&&!c,u=r.type==="dropdown"||r.type==="split"||e.children.length>0,p=r.fontIcon&&!r.fontIcon.startsWith("$")?r.fontIcon:"apps_add_in",f=`${r.hidden?" — hidden":""}${r.disabled?" — disabled":""}`,S=v=>{v.preventDefault(),v.stopPropagation(),v.dataTransfer.dropEffect="none",o?.()};return s.jsx(ke,{content:s.jsx(Xa,{node:e,appNames:t}),relationship:"description",children:s.jsxs("button",{type:"button",draggable:!1,className:Ft(i.chip,d&&i.selected,(r.hidden||r.disabled)&&i.muted,r.hidden&&i.hidden),"aria-pressed":d,"aria-label":`${r.label} — modern command (read-only), ${xn(r,t)}${f}`,onClick:()=>a(r.id),onDragStart:v=>v.preventDefault(),onDragOver:S,onDrop:S,onContextMenu:v=>{v.preventDefault(),a(r.id)},children:[s.jsx(jt,{name:p,size:16}),s.jsx(q,{size:200,children:r.label}),u&&s.jsx(gt,{fontSize:12,"aria-hidden":!0}),r.hidden&&s.jsx(Ye,{fontSize:12,"aria-hidden":!0}),s.jsx(ae,{size:"extra-small",appearance:"tint",color:"important",icon:s.jsx(wt,{}),children:"Modern"}),n&&s.jsx(ae,{size:"extra-small",appearance:"outline",color:"informative",children:xn(r,t)})]})})}function Gi({overrides:e,appNames:t}){if(!e?.length)return null;const n=e.some(i=>i.effect==="hidden"),o=e.map(i=>_i(i,t)).join(`
|
|
134
|
+
</ImportExportXml>`}function Qo(e){return/^(Mscrm|Microsoft)\./.test(e)}function Xn(e,t){e.origin=t.origin,e.solutionName=t.solutionName,e.publisherName=t.publisherName,e.oob=t.origin==="oob",e.custom=t.origin==="unmanaged",e.managed=t.origin==="managed"}function Ip(e,t){return t?"unmanaged":Qo(e)?"oob":"unmanaged"}function ss(e,t){for(const n of e.tabs)for(const o of n.groups)for(const i of je(o))t.has(i.id)?Xn(i,{origin:"unmanaged"}):i.origin==="unmanaged"&&Xn(i,{origin:"managed"})}function xt(e){return e.origin==="unmanaged"}function In(e,t){return Zr(Yr(t),[e])}function Yr(e){const t=new Map;for(const n of e.tabs)for(const o of n.groups)for(const i of je(o))t.set(i.id,(t.get(i.id)??!0)&&xt(i));return t}function Zr(e,t){return Pr(t).every(n=>e.get(n.id)??xt(n))}function Qr(e,t,n){return t?n?"has"in n?n.has(e):n.includes(e):!1:!0}function $i(e,t,n){const o=t.tabs.some(i=>i.groups.some(r=>r.id===e.id));return Qr(e.id,o,n)&&Zr(Yr(t),e.buttons)}function ea(e,t,n){const o=t.tabs.some(i=>i.id===e.id);return Qr(e.id,o,n)&&e.groups.every(i=>$i(i,t,n))}function Dy(e,t){const n=t.tabs.flatMap(l=>l.groups.flatMap(a=>je(a))).filter(l=>l.id===e.id),o=n.find(l=>!xt(l)),i=o??n[0]??e,r=i.origin==="oob"?"the out-of-the-box ribbon":i.origin==="managed"?i.solutionName?`the managed solution "${i.solutionName}"`:"a managed solution":void 0;return o&&n.some(xt)?`The ribbon also places a button with this id from ${r??"another solution"}, and that one can't be deleted.`:r&&xt(e)?`It is your override of a button from ${r}: the original stays in the ribbon underneath it.`:r?`It comes from ${r}.`:xt(i)?"Its menu holds items from another solution.":"It comes from another solution."}function Rp(e,t){if(t.size!==0)for(const n of Object.keys(e))for(const o of e[n].tabs)for(const i of o.groups)for(const r of je(i)){const l=t.get(r.id);l&&Xn(r,l)}}function mo(e,t,n,o=[]){const r=new DOMParser().parseFromString(e,"application/xml"),l=r.querySelector("parsererror");if(l)throw new Error(`Ribbon XML parse error: ${l.textContent??"Unknown"}`);const a=jp(r),c=Np(r);Tp(r,a);const d=new zp,u=Bp(r,d),p=Ep(r,d),f=Mp(r,d);d.flush();const S=[...Fp(r)];for(const y of o)S.some(C=>C.id===y.id)||S.push(y);const v=new Set,x=new Set;r.querySelectorAll("CustomAction").forEach(y=>{const C=y.querySelector("CommandUIDefinition");if(C?.firstElementChild){const w=C.firstElementChild.getAttribute("Id")??"";w&&v.add(w)}}),r.querySelectorAll("HideCustomAction").forEach(y=>{const C=y.getAttribute("Location")??"";C&&x.add(C)});for(const y of a)for(const C of y.groups)for(const w of je(C)){const h=v.has(w.id);Xn(w,{origin:Ip(w.id,h)}),w.hidden=x.has(w.id),w.source&&(w.source.labelToken=w.source.attributes.LabelText,w.source.tooltipTitleToken=w.source.attributes.ToolTipTitle,w.source.tooltipBodyToken=w.source.attributes.ToolTipDescription),w.label=ce(w.label,S),w.tooltipTitle&&(w.tooltipTitle=ce(w.tooltipTitle,S)),w.tooltipBody&&(w.tooltipBody=ce(w.tooltipBody,S));for(const I of w.menu?.sections??[])I.title&&(I.title=ce(I.title,S))}const g=$p(r,a);return{ribbon:{location:t,entityLogicalName:n,tabs:a,...Object.keys(c).length>0?{scalingByTab:c}:{},...Object.keys(g).length?{templateLayouts:g}:{}},commands:u,displayRules:f,enableRules:p,locLabels:S}}const ta="Ribbon > Tabs > Tab, Ribbon > ContextualTabs > ContextualGroup > Tab";function rs(e){const t=e.getAttribute("Description");return t===null?{}:{description:t}}function jp(e){const t=[];return e.querySelectorAll(ta).forEach(n=>{const o=n.getAttribute("Id")??"";if(!o)return;const i=n.getAttribute("Title")??o,r=[];n.querySelectorAll(":scope > Groups > Group").forEach(l=>{const a=l.getAttribute("Id")??"";if(!a)return;const c=l.getAttribute("Title")??l.getAttribute("Label")??a,d=parseInt(l.getAttribute("Sequence")??"0",10),u=l.getAttribute("Template")??"",p=[];l.querySelectorAll(":scope > Controls > *").forEach(f=>{wr[f.tagName]&&na(f,p)}),r.push({id:a,label:c,sequence:d,template:u,...rs(l),buttons:p})}),t.push({id:o,label:i,sequence:parseInt(n.getAttribute("Sequence")??"0",10),commandId:n.getAttribute("Command")??void 0,...rs(n),tabDisplayRules:[],groups:r})}),t.sort((n,o)=>n.sequence-o.sequence)}function Np(e){const t={};return e.querySelectorAll(ta).forEach(n=>{const o=n.getAttribute("Id"),i=Array.from(n.children).find(a=>a.tagName==="Scaling");if(!o||!i||t[o])return;const r=a=>({id:a.getAttribute("Id")??"",groupId:a.getAttribute("GroupId")??"",size:a.getAttribute("Size")??"",sequence:parseInt(a.getAttribute("Sequence")??"0",10)}),l=Array.from(i.children);t[o]={tabId:o,maxSizes:l.filter(a=>a.tagName==="MaxSize").map(r),scales:l.filter(a=>a.tagName==="Scale").map(r)}}),t}function $p(e,t){const n=new Set(t.flatMap(i=>i.groups.map(r=>r.template)).filter(Boolean)),o={};return e.querySelectorAll("GroupTemplate").forEach(i=>{const r=i.getAttribute("Id");!r||!n.has(r)||(o[r]=Array.from(i.querySelectorAll(":scope > Layout")).map(l=>l.getAttribute("Title")??"").filter(Boolean))}),o}function Tp(e,t){const n=new Map;for(const o of t)o.commandId&&n.set(o.commandId,o);e.querySelectorAll("RuleDefinitions > TabDisplayRules > TabDisplayRule").forEach(o=>{const i=o.getAttribute("TabCommand")??"",r=n.get(i);if(!r)return;const l=[];o.querySelectorAll("EntityRule").forEach(a=>{l.push({kind:"EntityRule",entityName:a.getAttribute("EntityName")??void 0,appliesTo:a.getAttribute("AppliesTo")??void 0,context:a.getAttribute("Context")??void 0})}),o.querySelectorAll("PageRule").forEach(a=>{l.push({kind:"PageRule",address:a.getAttribute("Address")??""})}),l.length>0&&r.tabDisplayRules.push({tabCommand:i,rules:l})})}function na(e,t){const n=e.getAttribute("Id")??"";if(!n)return;const o=wr[e.tagName]??"button",i=Ze(o),r=e.getAttribute("LabelText")??n,l=Dp(e.getAttribute("ModernImage")??void 0),a=parseInt(e.getAttribute("Sequence")??"0",10),c=e.getAttribute("TemplateAlias")??"",d=e.getAttribute("Command")??"";t.push({id:n,label:r,icon:l,sequence:a,templateAlias:c,commandId:d,kind:o,hidden:!1,oob:!0,custom:!1,managed:!1,tooltipTitle:e.getAttribute("ToolTipTitle")??void 0,tooltipBody:e.getAttribute("ToolTipDescription")??void 0,image16:e.getAttribute("Image16by16")??void 0,image32:e.getAttribute("Image32by32")??void 0,source:{modernImage:e.getAttribute("ModernImage")??void 0,attributes:ei(e),...i?{xml:qt().serializeToString(e)}:{}},menu:i?void 0:Ap(e)})}const kp=new Set(["Button","FlyoutAnchor","SplitButton","TextBox","ComboBox","CheckBox"]);function ei(e){return Object.fromEntries(Array.from(e.attributes).map(t=>[t.name,t.value]))}function Ap(e){const t=Me(e).find(i=>i.tagName==="Menu");if(!t)return;const n=ei(t),o=[];for(const i of Me(t)){if(i.tagName!=="MenuSection")continue;const r=i.getAttribute("Id")??"",l=Me(i).find(u=>u.tagName==="Controls"),a=[],c=[];Me(l).forEach((u,p)=>{kp.has(u.tagName)&&u.getAttribute("Id")?na(u,a):c.push({index:p,xml:qt().serializeToString(u)})});const d=ei(i);o.push({id:r,title:i.getAttribute("Title")??void 0,sequence:parseInt(i.getAttribute("Sequence")??"0",10),displayMode:i.getAttribute("DisplayMode")??void 0,controlsId:l?.getAttribute("Id")??`${r}.Controls`,controls:a,attributes:d,...c.length?{rawControls:c}:{},...l?{}:{rawContent:Me(i).map(u=>qt().serializeToString(u)).join("")}})}return{id:t.getAttribute("Id")??`${e.getAttribute("Id")}.Menu`,sections:o,attributes:n}}function Dp(e){if(e)return e.includes("_")?e.toLowerCase():e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").toLowerCase()}const qt=()=>new XMLSerializer;function Me(e){return e?Array.from(e.childNodes).filter(t=>t.nodeType===Node.ELEMENT_NODE):[]}class zp{pending=[];add(t){this.pending.push(t)}flush(){for(const t of[0,1]){const n=this.pending.filter(r=>r.phase===t);if(n.length===0)continue;const o=n.map(r=>r.generate());let i=null;try{const r=Cr(`<v>${o.map(l=>`<i>${l}</i>`).join("")}</v>`);i=Me(r).map(l=>Me(l)[0])}catch{i=null}n.forEach((r,l)=>{(i?i[l]&&_t(i[l])===_t(r.source):jm(o[l],r.source))||r.fallback()})}this.pending=[]}}function Bp(e,t){const n=[];return e.querySelectorAll("CommandDefinition").forEach(o=>{const i=o.getAttribute("Id")??"";if(!i)return;const r=Me(o),l=f=>r.find(S=>S.tagName===f),a=[],c=(f,S)=>{const v=[];return Me(l(f)).forEach((x,g)=>{const y=x.getAttribute("Id");x.tagName===S&&y&&x.attributes.length===1&&Me(x).length===0?v.push(y):a.push({container:f,index:g,xml:qt().serializeToString(x)})}),v},d=c("EnableRules","EnableRule"),u=c("DisplayRules","DisplayRule"),p=[];Me(l("Actions")).forEach((f,S)=>{const v=Op(f);if(!v){p.push(as(f));return}p.push(v),t.add({source:f,generate:()=>Kr(v),fallback:()=>p[S]=as(f),phase:0})}),n.push({id:i,enableRules:d,displayRules:u,actions:p,...a.length>0?{rawRuleRefs:a}:{}})}),n}function as(e){return{kind:"raw",tagName:e.tagName,xml:qt().serializeToString(e)}}function Op(e){switch(e.tagName){case"JavaScriptFunction":{const t=ti(e);return t?{kind:"javascript",library:e.getAttribute("Library")??"",functionName:e.getAttribute("FunctionName")??"",params:t}:null}case"Url":{const t=ti(e);if(!t)return null;const n=e.getAttribute("WinMode");return{kind:"url",address:e.getAttribute("Address")??"",passParams:lt(e.getAttribute("PassParams")),winMode:n===null?void 0:Number(n),winParams:e.getAttribute("WinParams")??void 0,params:t}}case"OutlookCommand":return{kind:"outlookCommand",actionType:e.getAttribute("ActionType")??"",data:e.getAttribute("Data")??void 0};default:return null}}function lt(e){if(e===null)return;const t=e.trim();if(t==="true"||t==="1")return!0;if(t==="false"||t==="0")return!1}function ti(e){const t=[];for(const n of Me(e)){const o=n.getAttribute("Name")??void 0,i=n.getAttribute("Value")??"";switch(n.tagName){case"CrmParameter":t.push({kind:"CrmParameter",name:o,value:i});break;case"BoolParameter":t.push({kind:"BoolParameter",name:o,value:lt(i)??!1});break;case"IntParameter":t.push({kind:"IntParameter",name:o,value:parseInt(i,10)});break;case"DecimalParameter":t.push({kind:"DecimalParameter",name:o,value:parseFloat(i)});break;case"StringParameter":t.push({kind:"StringParameter",name:o,value:i});break;default:return null}}return t}function Ep(e,t){const n=[];return e.querySelectorAll("RuleDefinitions > EnableRules > EnableRule").forEach(o=>{const i=o.getAttribute("Id")??"";i&&n.push({id:i,steps:Ti(o,t)})}),n}function Mp(e,t){const n=[];return e.querySelectorAll("RuleDefinitions > DisplayRules > DisplayRule").forEach(o=>{const i=o.getAttribute("Id")??"";i&&n.push({id:i,steps:Ti(o,t)})}),n}function Ti(e,t){const n=[];return Me(e).forEach((o,i)=>{const r=Pp(o,t);if(!r){n.push(ls(o));return}n.push(r),t.add({source:o,generate:()=>uo(n[i]),fallback:()=>n[i]=ls(o),phase:r.kind==="OrRule"?1:0})}),n}function ls(e){return{kind:"RawRule",tagName:e.tagName,xml:qt().serializeToString(e)}}function Lp(e){const t={},n=lt(e.getAttribute("Default")),o=lt(e.getAttribute("InvertResult"));return n!==void 0&&(t.default=n),o!==void 0&&(t.invertResult=o),t}function Qt(e,t){const n=e.getAttribute(t);return n===null?void 0:parseInt(n,10)}function Ge(e,t){return e.getAttribute(t)??void 0}function de(e,t){return e.getAttribute(t)??""}function Pp(e,t){const n=Lp(e);switch(e.tagName){case"OrRule":{const o=Me(e);return o.some(i=>i.tagName!=="Or")?null:{kind:"OrRule",groups:o.map(i=>Ti(i,t))}}case"SelectionCountRule":return{kind:"SelectionCountRule",minimum:Qt(e,"Minimum"),maximum:Qt(e,"Maximum"),appliesTo:Ge(e,"AppliesTo"),...n};case"EntityRule":return{kind:"EntityRule",entityName:Ge(e,"EntityName"),context:Ge(e,"Context"),appliesTo:Ge(e,"AppliesTo"),...n};case"FormStateRule":return{kind:"FormStateRule",state:de(e,"State"),...n};case"CommandClientTypeRule":return{kind:"CommandClientTypeRule",type:de(e,"Type"),...n};case"CustomRule":{const o=ti(e);return o?{kind:"CustomRule",library:de(e,"Library"),functionName:de(e,"FunctionName"),...o.length>0?{params:o}:{},...n}:null}case"FeatureControlRule":{const o=lt(e.getAttribute("ExpectedValue"));return o===void 0?null:{kind:"FeatureControlRule",featureControlBit:de(e,"FeatureControlBit"),expectedValue:o,...n}}case"MiscellaneousPrivilegeRule":return{kind:"MiscellaneousPrivilegeRule",privilegeName:de(e,"PrivilegeName"),privilegeDepth:Ge(e,"PrivilegeDepth"),...n};case"CrmClientTypeRule":return{kind:"CrmClientTypeRule",type:de(e,"Type"),...n};case"FormTypeRule":return{kind:"FormTypeRule",type:de(e,"Type"),...n};case"ValueRule":return{kind:"ValueRule",field:de(e,"Field"),value:de(e,"Value"),...n};case"SkuRule":return{kind:"SkuRule",sku:de(e,"Sku"),...n};case"HideForTabletExperienceRule":return{kind:"HideForTabletExperienceRule",...n};case"OrganizationSettingRule":return{kind:"OrganizationSettingRule",setting:de(e,"Setting"),...n};case"EntityPrivilegeRule":return{kind:"EntityPrivilegeRule",entityName:Ge(e,"EntityName"),appliesTo:Ge(e,"AppliesTo"),privilegeType:de(e,"PrivilegeType"),privilegeDepth:de(e,"PrivilegeDepth"),...n};case"EntityPropertyRule":{const o=lt(e.getAttribute("PropertyValue"));return o===void 0?null:{kind:"EntityPropertyRule",entityName:Ge(e,"EntityName"),appliesTo:Ge(e,"AppliesTo"),propertyName:de(e,"PropertyName"),propertyValue:o,...n}}case"DeviceTypeRule":return{kind:"DeviceTypeRule",type:de(e,"Type"),...n};case"OptionSetRule":return{kind:"OptionSetRule",optionSet:de(e,"OptionSet"),stateCode:de(e,"StateCode"),objectTypeCode:de(e,"ObjectTypeCode"),...n};case"RecordPrivilegeRule":return{kind:"RecordPrivilegeRule",privilegeType:de(e,"PrivilegeType"),appliesTo:Ge(e,"AppliesTo"),...n};case"FormEntityContextRule":return{kind:"FormEntityContextRule",entityName:de(e,"EntityName"),...n};case"PageRule":return{kind:"PageRule",address:de(e,"Address"),...n};case"RelationshipTypeRule":return{kind:"RelationshipTypeRule",appliesTo:"SelectedEntity",relationshipType:Ge(e,"RelationshipType"),allowCustomRelationship:lt(e.getAttribute("AllowCustomRelationship")),allowSystemRelationship:lt(e.getAttribute("AllowSystemRelationship")),...n};case"ReferencingAttributeRequiredRule":return{kind:"ReferencingAttributeRequiredRule",...n};case"OutlookItemTrackingRule":{const o=lt(e.getAttribute("TrackedInCrm"));return o===void 0?null:{kind:"OutlookItemTrackingRule",trackedInCrm:o,appliesTo:Ge(e,"AppliesTo"),...n}}case"OutlookRenderTypeRule":return{kind:"OutlookRenderTypeRule",type:de(e,"Type"),...n};case"OutlookVersionRule":return{kind:"OutlookVersionRule",version:de(e,"Version"),...n};case"CrmOfflineAccessStateRule":return{kind:"CrmOfflineAccessStateRule",state:de(e,"State"),...n};case"CrmOutlookClientTypeRule":return{kind:"CrmOutlookClientTypeRule",type:de(e,"Type"),...n};case"CrmOutlookClientVersionRule":return{kind:"CrmOutlookClientVersionRule",major:parseInt(de(e,"Major"),10),minor:Qt(e,"Minor"),build:Qt(e,"Build"),revision:Qt(e,"Revision"),...n};default:return null}}function Fp(e){const t=[];return e.querySelectorAll("LocLabel").forEach(n=>{const o=n.getAttribute("Id")??"";if(!o)return;const i=[];n.querySelectorAll("Title").forEach(r=>{const l=parseInt(r.getAttribute("languagecode")??"1033",10),a=r.getAttribute("description")??"";i.push({languageCode:l,description:a})}),t.push({id:o,titles:i})}),t}function Vn(e){return{controlIds:[...Gn(e)],containerIds:[...Er(e)],locLabelIds:[...e.locLabels.keys()],hides:oo(e),scalingStepIds:wi(e).map(t=>t.id),commandIds:[...e.commandDefinitions.keys()],commandRefIds:[...Mr(e)]}}async function zy(e){try{return Vn(await ni(e))}catch{return null}}function _p(e){const t=`<RibbonDiffXml><CommandDefinitions>${[...e.commandDefinitions.values()].join("")}</CommandDefinitions><RuleDefinitions><DisplayRules>${[...e.displayRules.values()].join("")}</DisplayRules><EnableRules>${[...e.enableRules.values()].join("")}</EnableRules></RuleDefinitions></RibbonDiffXml>`,n=mo(t,"HomepageGrid","");return{commands:n.commands,enableRules:n.enableRules,displayRules:n.displayRules}}function qp(){return window.dataverseAPI}async function Co(e){const t=[];let n=e;for(;n;){const o=await qp().queryData(n);t.push(...o.value??[]);const i=o["@odata.nextLink"];n=i?i.replace(/^.*\/api\/data\/v[\d.]+\//,""):void 0}return t}async function ni(e){const t=e===null?"entity eq null and ismanaged eq false":`entity eq '${e.replace(/'/g,"''")}' and ismanaged eq false`,[n,o,i]=await Promise.all([Co(`ribbondiffs?$select=diffid,difftype,rdx,sequence&$filter=${t}&$orderby=sequence asc,diffid asc`),Co(`ribboncommands?$select=command,commanddefinition&$filter=${t}&$orderby=command asc`),Co(`ribbonrules?$select=ruleid,ruletype,ruledefinition&$filter=${t}&$orderby=ruleid asc`)]);return km({diffs:n,commands:o,rules:i})}function oi(e){const t=[];for(const[n,o]of e.locLabels){const i=new DOMParser().parseFromString(o,"application/xml"),r=Array.from(i.querySelectorAll("Title")).map(l=>({languageCode:Number(l.getAttribute("languagecode")??1033),description:l.getAttribute("description")??""}));t.push({id:n,titles:r})}return t}function cs(e,t,n,o){const r=`${Ai()}.${Et(e)}.${Et(t)}.${Et(n)}`;return Di(r,o)}function ki(e,t,n){const i=`${Ai()}.${Et(e)}.${Et(t)}.Command`;return Di(i,n)}function hn(e,t,n){const i=`${Ai()}.${Et(e)}.${t}Rule`;return Di(i,n)}function ds(e){return e.replace(/\.Command$/,"").split(".").pop()||"Rule"}function Ai(){try{return ie.getState().publisherPrefix||"new"}catch{return"new"}}function Et(e){return e.replace(/[^a-zA-Z0-9._]/g,"").replace(/^[^a-zA-Z]/,"x")}function Di(e,t){if(!t.has(e))return e;let n=2;for(;t.has(`${e}${n}`);)n++;return`${e}${n}`}function oa(e,t,n,o,i){const r=o.replace(/[^a-zA-Z0-9_]/g,"")||"Button",l=`${e}.${t}.${n}.${r}`;let a=l;for(let c=2;i.has(`${a}.Button`)||i.has(`${a}.Command`);c++)a=`${l}${c}`;return{id:`${a}.Button`,commandId:`${a}.Command`}}function By(e){return/\s/.test(e)?"ID must not contain whitespace":e?/^[a-zA-Z]/.test(e)?null:"ID must start with a letter":"ID must not be empty"}const Z=Rt()(e=>({location:"HomepageGrid",tabId:"MainTab",selectedButtonId:null,selectedGroupId:null,setLocation(t){e({location:t,tabId:"MainTab",selectedButtonId:null,selectedGroupId:null})},setTabId(t){e({tabId:t,selectedButtonId:null,selectedGroupId:null})},selectGroup(t){e({selectedGroupId:t,selectedButtonId:null})},selectButton(t,n){e({selectedGroupId:t,selectedButtonId:n})},selectButtonInContext(t,n,o,i){e({location:t,tabId:n,selectedGroupId:o,selectedButtonId:i})},clearSelection(){e({selectedButtonId:null,selectedGroupId:null})}}));function po(e){return/\.AllEntities\./.test(e)||/\.VisualizationTab$/.test(e)}function dn(e){const t=e.filter(n=>!po(n.id));return(t.find(n=>/\.MainTab$/.test(n.id))??t[0]??e[0])?.id}const Be="Mscrm.OpenRecordItem",ia=["HomepageGrid","SubGrid"],Hp=/\.(HomepageGrid|SubGrid)\.OpenRecordItem\d*\.Button$/;function sa(e){return e.commandId===Be&&Hp.test(e.id)}function zi(e){const t=[];for(const n of e?.tabs??[])for(const o of n.groups)for(const i of je(o))i.commandId===Be&&t.push({tabId:n.id,groupId:o.id,button:i});return t}function ra(e){return zi(e).filter(t=>sa(t.button))}function aa(e){const t=e.button.origin;return t==="unmanaged"?"yours":t===void 0?"unknown":"theirs"}function la(e){const t=e?.tabs??[],n=dn(t.filter(r=>r.groups.length>0)),o=t.find(r=>r.id===n),i=o?.groups.find(r=>/\.Management$/.test(r.id))??o?.groups[0];return o&&i?{tabId:o.id,groupId:i.id}:null}function Gp(){return{id:Be,enableRules:[],displayRules:[],actions:[{kind:"javascript",library:"$webresource:",functionName:"YourNamespace.openRecord",params:[{kind:"CrmParameter",value:"SelectedControlSelectedItemReferences"}]}]}}function Wp(e){for(const t of e.actions){if(t.kind!=="javascript")continue;if(!t.library.trim().replace(/^\$webresource:/i,"").trim()||!t.functionName.trim())return`${Be} has a JavaScript action without a web resource or function — set them in the Command Editor, or turn the override off`}return null}const Up=["Mscrm.HideOnModern","Mscrm.ShowOnlyOnModern"];function en(e,t){const n=new Set;for(const o of[t,e.baseline])for(const i of Object.values(o??{}))for(const r of i.tabs){n.add(r.id);for(const l of r.groups){n.add(l.id);for(const a of je(l))n.add(a.id)}}for(const o of Object.values(e.layers??{})){for(const i of o?.containerIds??[])n.add(i);for(const i of o?.controlIds??[])n.add(i)}return n}function Jn(e,t){return e.layers[t==="Application"?"application":"entity"]?.containerIds}function Le(e){return JSON.parse(JSON.stringify(e))}function et(e){return{ribbons:e.ribbons,commands:e.commands,enableRules:e.enableRules,displayRules:e.displayRules,locLabels:e.locLabels,pendingUnhides:e.pendingUnhides,pendingOrphanDeletes:e.pendingOrphanDeletes,customisedCommandIds:e.customisedCommandIds,uncustomisedCommandIds:e.uncustomisedCommandIds}}function be(e,t,n,o,i="info"){return{ts:new Date().toISOString(),userId:"",userName:"You",op:e,target:t,detail:n,icon:o,color:i}}let Fe=null;const Xp=1e3;function $e(e,t,n,o){if(Fe)return Fe.meta||(Fe.meta=n),t;const i=e.past[e.past.length-1];if(o&&i?.coalesceKey===o&&e.future.length===0&&Date.parse(n.ts)-Date.parse(i.ts)<Xp)return{...t,past:[...e.past.slice(0,-1),{...i,...n}],mutationsSincePublish:e.mutationsSincePublish+1};const r={...n,coalesceKey:o,snapshot:et(e)};return{...t,past:[...e.past,r].slice(-80),future:[],mutationsSincePublish:e.mutationsSincePublish+1}}function ye(e,t,n,o){const i=Le(e.ribbons);return t(i),$e(e,{ribbons:i},n,o)}function Ln(e){const t=(n,o)=>JSON.stringify(n)===JSON.stringify(o);return e.pendingUnhides.entity.length+e.pendingUnhides.application.length>0||e.pendingOrphanDeletes.entity.length+e.pendingOrphanDeletes.application.length>0||e.customisedCommandIds.length>0||e.uncustomisedCommandIds.entity.length+e.uncustomisedCommandIds.application.length>0||!t(e.ribbons,e.baseline)||!t(e.commands,e.baselineCommands)||!t(e.enableRules,e.baselineEnableRules)||!t(e.displayRules,e.baselineDisplayRules)||!t(e.locLabels,e.baselineLocLabels)}function tn(e,t){const n=e.findIndex(o=>o.id===t.id);return n<0?[...e,t]:JSON.stringify(e[n])===JSON.stringify(t)?null:e.map((o,i)=>i===n?t:o)}const us={entity:null,application:null},wo={entity:[],application:[]},ms=["HomepageGrid","SubGrid","Form"];function Vp(e,t,n){return(t===void 0||e>t)&&(n===void 0||e<n)?e:t!==void 0&&n!==void 0?n-t>1?Math.floor((t+n)/2):void 0:t!==void 0?t+10:n!==void 0?n>1?Math.max(1,n-10):void 0:e}function Jp(e,t,n){let o=t;for(;o>0&&n(e[o-1]);)o--;let i=t;for(;i<e.length-1&&n(e[i+1]);)i++;const r=o>0?e[o-1].sequence:0,l=i<e.length-1?e[i+1].sequence:1/0;if(l-r-1>=i-o+1){let d=r;for(let u=o;u<=i;u++){const p=i-u,f=e[u];f.sequence>d&&f.sequence<=l-1-p||(f.sequence=l===1/0?d+10:d+Math.max(1,Math.min(10,Math.floor((l-d)/(p+2))))),d=f.sequence}return}const a=new Set(e.filter((d,u)=>u!==t).map(d=>d.sequence));let c=(t>0?e[t-1].sequence:0)+1;for(;a.has(c);)c++;e[t].sequence=c}const Io={HomepageGrid:{location:"HomepageGrid",entityLogicalName:"",tabs:[]},SubGrid:{location:"SubGrid",entityLogicalName:"",tabs:[]},Form:{location:"Form",entityLogicalName:"",tabs:[]},Application:{location:"Application",entityLogicalName:"",tabs:[]}};function Qe(e,t,n,o,i){const r=e[t].tabs.find(a=>a.id===n)?.groups.find(a=>a.id===o),l=Yt(r,i);return r&&l?{group:r,button:l}:void 0}function Pe(e,t,n){return e==="Application"&&t==="Mscrm.GlobalTab"&&n.oob===!0&&n.custom!==!0}function Bi(e,t,n){return n.origin!=="unmanaged"&&!n.hidden&&n.kind!=="flyout"&&n.kind!=="splitButton"&&!Ze(n.kind)&&!Pe(e,t,n)}function Kp(e,t,n){for(const o of e.baseline[t].tabs)for(const i of o.groups){const r=i.buttons.find(l=>l.id===n);if(r)return r}}function Yp(e,t,n){if(t.location!==n.location||t.tabId!==n.tabId||t.groupId!==n.groupId)return!1;const o=e.buttons.findIndex(r=>r.id===t.buttonId),i=e.buttons[o+1]?.id;return n.beforeButtonId?n.beforeButtonId===t.buttonId||n.beforeButtonId===i:i===void 0}const Kn=/^\$LocLabels:/;function Zp(e){if(!e)return;const t=o=>o&&!Kn.test(o)?o:void 0,n={};for(const[o,i]of Object.entries(e.attributes))o!=="Id"&&!Kn.test(i)&&(n[o]=i);return{...e,labelToken:t(e.labelToken),tooltipTitleToken:t(e.tooltipTitleToken),tooltipBodyToken:t(e.tooltipBodyToken),attributes:n}}const Ro=(e,t)=>({entity:e.entity.filter(n=>n!==t),application:e.application.filter(n=>n!==t)});function ps(e,t){const n=e.baselineCommands.find(i=>i.id===t),o=e.commands.find(i=>i.id===t);return!n||!o||JSON.stringify(n)===JSON.stringify(o)?e.commands:e.commands.map(i=>i.id===t?JSON.parse(JSON.stringify(n)):i)}const D=Rt()(gm((e,t)=>({ribbons:Le(Io),baseline:Le(Io),baselineCommands:[],baselineEnableRules:[],baselineDisplayRules:[],baselineLocLabels:[],layers:{...us},pendingUnhides:{entity:[],application:[]},orphans:{entity:[],application:[]},pendingOrphanDeletes:{entity:[],application:[]},baseLanguageCode:1033,customisedCommandIds:[],uncustomisedCommandIds:{entity:[],application:[]},reloadRequiredCommandIds:[],commands:[],displayRules:[],enableRules:[],locLabels:[],templates:[],conflicts:[],mutationsSincePublish:0,past:[],future:[],loadRibbons(n){e({ribbons:Le(n),baseline:Le(n),mutationsSincePublish:0,past:[],future:[]}),Fe&&(Fe={snapshot:et(t()),meta:null})},setConflicts(n){e({conflicts:n})},applyImport(n,o){e(i=>$e(i,{ribbons:{...i.ribbons,...Le(n.ribbons)},commands:[...n.commands],enableRules:[...n.enableRules],displayRules:[...n.displayRules],locLabels:[...n.locLabels]},be("imported","RibbonDiffXml",o,"arrow_upload","success")))},loadWorkspace(n){const o=Le(n.ribbons);e({ribbons:o,baseline:Le(o),commands:[...n.commands],displayRules:[...n.displayRules],enableRules:[...n.enableRules],baselineCommands:JSON.parse(JSON.stringify(n.commands)),baselineDisplayRules:JSON.parse(JSON.stringify(n.displayRules)),baselineEnableRules:JSON.parse(JSON.stringify(n.enableRules)),locLabels:[...n.locLabels],baselineLocLabels:JSON.parse(JSON.stringify(n.locLabels)),layers:{...us,...n.layers??{}},pendingUnhides:{...wo},orphans:{entity:[],application:[],...n.orphans??{}},pendingOrphanDeletes:{...wo},baseLanguageCode:n.baseLanguageCode??1033,customisedCommandIds:[],uncustomisedCommandIds:{entity:[],application:[]},reloadRequiredCommandIds:[],templates:[...n.templates??[]],conflicts:[...n.conflicts??[]],mutationsSincePublish:0,past:[],future:[]}),Fe&&(Fe={snapshot:et(t()),meta:null})},restoreWorkspace(n,o){const i=JSON.parse(JSON.stringify(n));e(r=>{const l=c=>{const d=r.layers[c];return d?i.pendingUnhides[c].filter(u=>d.hides.some(p=>p.location===u)):i.pendingUnhides[c]},a={...i,pendingUnhides:{entity:l("entity"),application:l("application")}};return JSON.stringify(et({...r,...a}))===JSON.stringify(et(r))?r:$e(r,a,be("restored","unsaved changes",o,"history"))})},resetWorkspace(){t().loadWorkspace({ribbons:Io,commands:[],displayRules:[],enableRules:[],locLabels:[]})},undo(){t().restore(t().past.length-1)},redo(){const n=t();if(n.future.length===0||Fe)return;const[o,...i]=n.future;e({...o.snapshot,past:[...n.past,{...o,snapshot:et(n)}],future:i,mutationsSincePublish:Ln({...n,...o.snapshot})?n.mutationsSincePublish+1:0})},restore(n){const o=t(),{past:i}=o;if(n<0||n>=i.length||Fe)return;let r=et(o),l=o.future;for(let c=i.length-1;c>=n;c--)l=[{...i[c],coalesceKey:void 0,snapshot:r},...l],r=i[c].snapshot;const a=i.length-n;e({...r,past:i.slice(0,n),future:l,mutationsSincePublish:Ln({...o,...r})?Math.max(1,o.mutationsSincePublish-a):0})},batch(n){if(Fe){n();return}Fe={snapshot:et(t()),meta:null};try{n()}finally{const{snapshot:o,meta:i}=Fe;Fe=null,i&&e(r=>({past:[...r.past,{...i,snapshot:o}].slice(-80),future:[],mutationsSincePublish:r.mutationsSincePublish+1}))}},moveButton(n,o){const i=t(),l=i.ribbons[n.location].tabs.find(p=>p.id===n.tabId)?.groups.find(p=>p.id===n.groupId),a=l?.buttons.find(p=>p.id===n.buttonId),c=i.ribbons[o.location].tabs.find(p=>p.id===o.tabId)?.groups.find(p=>p.id===o.groupId);if(!a||!l||!c)return null;const d=Kp(i,n.location,a.id)?.origin;if(d!==void 0&&d!=="unmanaged"&&!a.menu&&!Ot(a.kind)&&!Pe(n.location,n.tabId,a)){if(Yp(l,n,o))return null;const p=y=>(oe.getState().logWarn("ribbon",`Can't move ${a.id}: ${y}`),null);if(a.hidden)return p("it's hidden — move your copy of it instead.");if(n.location==="Application"!=(o.location==="Application"))return p("it isn't yours, and a copy can't move between the table's ribbon and the application ribbon.");const{activeSolution:f,publisherPrefix:S}=ie.getState(),v=f?.publisherPrefix?.trim()||S?.trim()||"new";let x=null,g=!1;return t().batch(()=>{const y=t().customiseButton(n.location,n.tabId,n.groupId,n.buttonId,v);y&&(g=!0,x=t().moveButton({...n,buttonId:y},o),oe.getState().logInfo("ribbon",`${a.id} isn't yours, so it can't be moved: moved your copy ${y} instead and hid the original.`))}),g&&!x&&t().undo(),g?x:p("it isn't yours and can't be copied (e.g. it has an override of its command); undo the override, then move it.")}return Pe(n.location,n.tabId,a)?null:(e(p=>ye(p,f=>{const S=f[n.location].tabs.find($=>$.id===n.tabId);if(!S)return;const v=S.groups.find($=>$.id===n.groupId);if(!v)return;const x=v.buttons.findIndex($=>$.id===n.buttonId);if(x===-1||Pe(n.location,n.tabId,v.buttons[x]))return;const y=(n.tabId===o.tabId&&n.location===o.location?S:f[o.location].tabs.find($=>$.id===o.tabId))?.groups.find($=>$.id===o.groupId);if(!y)return;const[C]=v.buttons.splice(x,1),w=o.beforeButtonId?y.buttons.findIndex($=>$.id===o.beforeButtonId):y.buttons.length,h=w<0?y.buttons.length:w;y.buttons.splice(h,0,C);const I=Vp(C.sequence,y.buttons[h-1]?.sequence,y.buttons[h+1]?.sequence);if(I!==void 0)C.sequence=I;else{const $=new Set(p.layers[o.location==="Application"?"application":"entity"]?.controlIds??[]),R=new Set(p.baseline[o.location].tabs.flatMap(B=>B.groups.flatMap(T=>T.buttons.map(H=>H.id))));Jp(y.buttons,h,B=>B===C||$.has(B.id)||!R.has(B.id))}},{ts:new Date().toISOString(),userId:"",userName:"You",op:"moved",target:n.buttonId,detail:`to ${o.groupId}`,icon:"arrow_move",color:"info"})),n.buttonId)},setButtonProp(n,o,i,r,l){const c=Object.values(l).every(d=>typeof d=="string")?`button:${n}:${r}:${Object.keys(l).sort().join(",")}`:void 0;e(d=>ye(d,u=>{const p=Qe(u,n,o,i,r)?.button;p&&(Pe(n,o,p)||(Object.assign(p,l),Ot(p.kind)&&!p.menu&&(p.menu=xo(p.id))))},{ts:new Date().toISOString(),userId:"",userName:"You",op:"edited",target:l.label??r,detail:Object.keys(l).join(", "),icon:"edit",color:"info"},c))},deleteButton(n,o,i,r){const l=t(),a=Qe(l.ribbons,n,o,i,r)?.button;if(a&&!In(a,l.baseline[n])){oe.getState().logWarn("ribbon",`"${a.label}" (${r}) was not deleted: only your own buttons can be deleted — hide it instead.`);return}e(c=>ye(c,d=>{const u=Qe(d,n,o,i,r);if(!u)return;const{group:p,button:f}=u;Pe(n,o,f)||Fr(p,r)||(p.buttons=p.buttons.filter(S=>S.id!==r))},{ts:new Date().toISOString(),userId:"",userName:"You",op:"deleted",target:r,detail:i,icon:"delete",color:"danger"}))},addMenuItem({location:n,tabId:o,groupId:i,parentId:r,sectionId:l,item:a}){e(c=>ye(c,d=>{const u=Qe(d,n,o,i,r)?.button;if(!u||Pe(n,o,u))return;u.menu=u.menu??xo(u.id),u.menu.sections.length===0&&u.menu.sections.push(Vo(u.id,[]));const p=u.menu.sections.find(S=>S.id===l)??u.menu.sections[0],f=p.controls[p.controls.length-1]?.sequence??0;p.controls.push({...a,kind:a.kind??"button",sequence:a.sequence??f+10,templateAlias:a.templateAlias??"",hidden:!1,oob:!1,custom:!0,managed:!1,origin:"unmanaged"})},{ts:new Date().toISOString(),userId:"",userName:"You",op:"added",target:a.label,detail:`menu of ${r}`,icon:"add",color:"success"}))},addMenuSection(n,o,i,r,l){e(a=>ye(a,c=>{const d=Qe(c,n,o,i,r)?.button;!d||Pe(n,o,d)||(d.menu=d.menu??{id:`${d.id}.Menu`,sections:[]},d.menu.sections.push(Vo(d.id,d.menu.sections,l)))},{ts:new Date().toISOString(),userId:"",userName:"You",op:"added",target:l??"Menu section",detail:`menu of ${r}`,icon:"add",color:"success"}))},setMenuSectionProp(n,o,i,r,l,a){e(c=>ye(c,d=>{const u=Qe(d,n,o,i,r)?.button,p=u?.menu?.sections.find(f=>f.id===l);!u||!p||Pe(n,o,u)||Object.assign(p,a)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"edited",target:l,detail:Object.keys(a).join(", "),icon:"edit",color:"info"}))},deleteMenuSection(n,o,i,r,l){e(a=>ye(a,c=>{const d=Qe(c,n,o,i,r)?.button;!d?.menu||Pe(n,o,d)||(d.menu.sections=d.menu.sections.filter(u=>u.id!==l))},{ts:new Date().toISOString(),userId:"",userName:"You",op:"deleted",target:l,detail:`menu of ${r}`,icon:"delete",color:"danger"}))},duplicateButton(n,o,i,r){e(l=>ye(l,a=>{const c=Qe(a,n,o,i,r);if(c){const{group:d,button:u}=c;if(Pe(n,o,u))return;const p=Ii(u.source?.labelToken),f={...Un(u,`${u.id}_copy_${Date.now()}`),label:Ze(u.kind)||p?u.label:`${u.label} (copy)`,sequence:u.sequence+5},S=Wn(d,r),v=S?S.section.controls:d.buttons,x=v.findIndex(g=>g.id===r);v.splice(x+1,0,f)}},{ts:new Date().toISOString(),userId:"",userName:"You",op:"duplicated",target:r,detail:i,icon:"copy",color:"info"}))},createButton({tabId:n,groupId:o,location:i,button:r}){e(l=>ye(l,a=>{const d=a[i].tabs.find(u=>u.id===n)?.groups.find(u=>u.id===o);if(d){const u=new Set(d.buttons.map(v=>v.sequence)),p=Math.max(0,...d.buttons.map(v=>v.sequence))+10,f=r.sequence!==void 0&&!u.has(r.sequence)?r.sequence:p,S={...r,id:r.id??`new_${Date.now()}`,label:r.label??"New Button",kind:r.kind??"button",sequence:f,templateAlias:r.templateAlias??"o1",commandId:r.commandId??"",hidden:r.hidden??!1,oob:!1,custom:!0,managed:!1,origin:"unmanaged"};Ot(S.kind)&&!S.menu&&(S.menu=xo(S.id)),d.buttons.push(S)}},{ts:new Date().toISOString(),userId:"",userName:"You",op:"added",target:r.label??"New Button",detail:o,icon:"add",color:"success"}))},createGroup({tabId:n,location:o,group:i}){e(r=>ye(r,l=>{const a=l[o].tabs.find(c=>c.id===n);if(a){const c=l[o],d=o==="Application"?"global":c.entityLogicalName,u={id:i.id??cs(d,`${o}.${i.label??"New Group"}`,"Group",en(r,l)),label:i.label??"New Group",sequence:i.sequence!==void 0&&!a.groups.some(p=>p.sequence===i.sequence)?i.sequence:Math.max(0,...a.groups.map(p=>p.sequence))+10,template:i.template??"Flexible2",buttons:i.buttons??[]};a.groups.push(u)}},{ts:new Date().toISOString(),userId:"",userName:"You",op:"added",target:i.label??"New Group",detail:n,icon:"add",color:"success"}))},renameGroup(n,o,i,r){e(l=>ye(l,a=>{const d=a[n].tabs.find(u=>u.id===o)?.groups.find(u=>u.id===i);d&&(d.label=r)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"renamed",target:i,detail:r,icon:"edit",color:"info"}))},duplicateGroup(n,o,i){e(r=>ye(r,l=>{const a=l[n].tabs.find(f=>f.id===o);if(!a)return;const c=a.groups.find(f=>f.id===i);if(!c)return;const d=`_copy_${Date.now()}`,u={...JSON.parse(JSON.stringify(c)),id:`${c.id}${d}`,label:`${c.label} (copy)`,source:void 0,description:void 0,sequence:c.sequence+5,buttons:c.buttons.map(f=>Un(f,`${f.id}${d}`))},p=a.groups.findIndex(f=>f.id===i);a.groups.splice(p+1,0,u)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"duplicated",target:i,detail:o,icon:"copy",color:"info"}))},setGroupTemplate(n,o,i,r){e(l=>ye(l,a=>{const d=a[n].tabs.find(u=>u.id===o)?.groups.find(u=>u.id===i);d&&(d.template=r)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"edited",target:i,detail:`template → ${r}`,icon:"edit",color:"info"}))},deleteGroup(n,o,i){const r=t(),l=r.ribbons[n].tabs.find(a=>a.id===o)?.groups.find(a=>a.id===i);if(l&&!$i(l,r.baseline[n],Jn(r,n))){oe.getState().logWarn("ribbon",`Group "${l.label}" (${i}) was not deleted: only your own groups, with only your own buttons in them, can be deleted — hide its buttons instead.`);return}e(a=>ye(a,c=>{const d=c[n].tabs.find(u=>u.id===o);d&&(d.groups=d.groups.filter(u=>u.id!==i))},{ts:new Date().toISOString(),userId:"",userName:"You",op:"deleted",target:i,detail:o,icon:"delete",color:"danger"}))},createTab(n,o){e(i=>o.id&&en(i,i.ribbons).has(o.id)?{}:ye(i,r=>{const l=r[n],a=n==="Application"?"global":l.entityLogicalName,c=o.id??cs(a,`${n}.${o.label??"New Tab"}`,"Tab",en(i,r)),d=qr({...o,id:c}),u={id:c,label:o.label??"New Tab",sequence:o.sequence!==void 0&&!l.tabs.some(p=>p.sequence===o.sequence)?o.sequence:Math.max(0,...l.tabs.map(p=>p.sequence))+10,commandId:d,tabDisplayRules:o.tabDisplayRules?.length?o.tabDisplayRules:Hr(n,l.entityLogicalName,d),groups:[]};l.tabs.push(u)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"added",target:o.label??"New Tab",detail:n,icon:"add",color:"success"}))},renameTab(n,o,i){e(r=>ye(r,l=>{const a=l[n].tabs.find(c=>c.id===o);a&&(a.label=i)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"renamed",target:o,detail:i,icon:"edit",color:"info"}))},deleteTab(n,o){const i=t(),r=i.ribbons[n].tabs.find(l=>l.id===o);if(r&&!ea(r,i.baseline[n],Jn(i,n))){oe.getState().logWarn("ribbon",`Tab "${r.label}" (${o}) was not deleted: only your own tabs, with only your own groups and buttons in them, can be deleted.`);return}e(l=>ye(l,a=>{a[n].tabs=a[n].tabs.filter(c=>c.id!==o)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"deleted",target:o,detail:n,icon:"delete",color:"danger"}))},reorderTabs(n,o){e(i=>ye(i,r=>{const l=r[n].tabs;r[n].tabs=o.map(a=>l.find(c=>c.id===a)).filter(a=>a!==void 0)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"reordered",target:"Tabs",detail:n,icon:"arrow_sort",color:"info"}))},setTabDisplayRules(n,o,i){e(r=>ye(r,l=>{const a=l[n].tabs.find(c=>c.id===o);a&&(a.tabDisplayRules=i)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"edited",target:`${o} display rules`,detail:`${i.length} rule(s)`,icon:"eye",color:"info"}))},setScaling(n,o,i){e(r=>ye(r,l=>{const a=l[n];a.scalingByTab=a.scalingByTab??{},a.scalingByTab[o]={tabId:o,maxSizes:[...i.maxSizes],scales:[...i.scales]}},{ts:new Date().toISOString(),userId:"",userName:"You",op:"edited",target:`${o} scaling`,detail:`${i.maxSizes.length} MaxSize, ${i.scales.length} Scale`,icon:"resize",color:"info"}))},hideOobButton(n,o,i,r){e(l=>ye(l,a=>{const c=Qe(a,n,o,i,r)?.button;c&&(Pe(n,o,c)||(c.hidden=!0))},{ts:new Date().toISOString(),userId:"",userName:"You",op:"hid",target:r,detail:i,icon:"eye_off",color:"warn"}))},customizeOobButton(n,o,i,r){e(l=>ye(l,a=>{const c=Qe(a,n,o,i,r)?.button;if(c){if(Pe(n,o,c))return;c.oob=!1,c.custom=!0,c.managed=!1,c.origin="unmanaged"}},{ts:new Date().toISOString(),userId:"",userName:"You",op:"customized",target:r,detail:"OOB override",icon:"edit",color:"info"}))},customiseButton(n,o,i,r,l){const a=t(),c=a.ribbons[n].tabs.find(g=>g.id===o)?.groups.find(g=>g.id===i)?.buttons.find(g=>g.id===r);if(!c||!Bi(n,o,c))return null;const d=en(a,a.ribbons),u=`${(l||"new").trim()}.${c.id}`;let p=u;for(let g=2;d.has(p);g++)p=`${u}.${g}`;const f=[],S=[],v=[[c.source?.labelToken,so(p)],[c.source?.tooltipTitleToken,ro(p)],[c.source?.tooltipBodyToken,ao(p)]];for(const[g,y]of v){if(!g||!Kn.test(g))continue;const C=a.locLabels.find(w=>w.id===g.replace(Kn,""));C?f.push({id:y,titles:C.titles.map(w=>({...w}))}):S.push(g)}S.length>0&&oe.getState().logWarn("ribbon",`Customise button ${c.id}: the translations of ${S.join(", ")} aren't loaded, so the copy ${p} gets its text in the base language only. Add the other languages in the Localization editor.`);const x=new Set(f.map(g=>g.id));return e(g=>{const y=Le(g.ribbons),C=y[n].tabs.find(R=>R.id===o)?.groups.find(R=>R.id===i),w=C?.buttons.findIndex(R=>R.id===r)??-1;if(!C||w<0)return{};const h=C.buttons[w],I={...h,id:p,source:Zp(h.source),hidden:!1,custom:!0,oob:!1,managed:!1,origin:"unmanaged",solutionName:void 0,publisherName:void 0},$=C.buttons[w+1]?.sequence;return($===void 0||h.sequence+1<$)&&(I.sequence=h.sequence+1),h.hidden=!0,C.buttons.splice(w+1,0,I),$e(g,{ribbons:y,...f.length>0?{locLabels:[...g.locLabels.filter(R=>!x.has(R.id)),...f]}:{}},be("customised",r,`copied to ${p}, original hidden`+(S.length>0?" (translations not loaded: base language only)":""),"copy"))}),p},customiseCommand(n){const o=t();return!o.commands.some(i=>i.id===n)||o.reloadRequiredCommandIds.includes(n)?!1:(e(i=>$e(i,{customisedCommandIds:[...i.customisedCommandIds.filter(r=>r!==n),n],uncustomisedCommandIds:Ro(i.uncustomisedCommandIds,n)},be("customised",n,"command copied to your layer on publish","code"))),!0)},uncustomiseCommand(n,o){e(i=>$e(i,{commands:ps(i,n),customisedCommandIds:i.customisedCommandIds.filter(r=>r!==n),uncustomisedCommandIds:{...Ro(i.uncustomisedCommandIds,n),[o]:[...i.uncustomisedCommandIds[o].filter(r=>r!==n),n]}},be("uncustomised",n,`command removed from the ${o==="entity"?"table's":"application ribbon's"} layer on publish`,"arrow_undo")))},discardCommandChanges(n){const o=t(),i=ps(o,n);(i!==o.commands||o.customisedCommandIds.includes(n)||o.uncustomisedCommandIds.entity.includes(n)||o.uncustomisedCommandIds.application.includes(n))&&e(l=>$e(l,{commands:i,customisedCommandIds:l.customisedCommandIds.filter(a=>a!==n),uncustomisedCommandIds:Ro(l.uncustomisedCommandIds,n)},be("discarded",n,"command changes","arrow_undo")))},setOpenRecordOverride(n,o,i){if(!ia.includes(n))return!1;const r=t(),l=r.ribbons[n],a=ra(l);if(o){if(a.length>0)return!0;const c=la(l);if(!c)return!1;const d=en(r,r.ribbons);for(const p of r.commands)d.add(p.id);const{id:u}=oa(i,l.entityLogicalName,n,"OpenRecordItem",d);return t().batch(()=>{t().createButton({location:n,tabId:c.tabId,groupId:c.groupId,button:{id:u,label:"Open record",tooltipTitle:"Open record",tooltipBody:`Runs the table's ${Be} action for the selected row, as opening a row does.`,kind:"button",templateAlias:"o1",commandId:Be,hidden:!1,oob:!1,custom:!0,managed:!1}}),t().commands.some(p=>p.id===Be)||t().upsertCommand(Gp())}),!0}return a.length===0?!0:a.some(c=>aa(c)!=="yours")?!1:(t().batch(()=>{for(const u of a)t().deleteButton(n,u.tabId,u.groupId,u.button.id);const c=t();!Object.values(c.ribbons).some(u=>zi(u).length>0)&&!c.baselineCommands.some(u=>u.id===Be)&&e(u=>$e(u,{commands:u.commands.filter(p=>p.id!==Be)},be("removed",Be,"grid open override","delete","danger")))}),!0)},hideWithDisplayRules(n){const o=n?t().commands.find(r=>r.id===n):void 0;if(!o)return!1;const i=[...o.displayRules];for(const r of Up)i.includes(r)||i.push(r);return e(r=>{const l=tn(r.commands,{...o,displayRules:i});return l?$e(r,{commands:l},be("hid",o.id,"with display rules","eye_off","warn")):r}),!0},upsertCommand(n){e(o=>{const i=tn(o.commands,n);if(!i)return o;const r=i.length>o.commands.length;return $e(o,{commands:i},r?be("added",n.id,"command","add","success"):be("edited",n.id,"command","edit"),r?void 0:`command:${n.id}`)})},renameCommandId(n,o){const i=t();return!n||!o||n===o?!0:i.commands.some(r=>r.id===o)?!1:(e(r=>{const l=Le(r.ribbons);for(const c of Object.keys(l))for(const d of l[c].tabs)for(const u of d.groups)for(const p of je(u))p.commandId===n&&(p.commandId=o),p.source?.xml&&(p.source.xml=$m(p.source.xml,n,o));const a=r.commands.map(c=>c.id===n?{...c,id:o}:c);return $e(r,{ribbons:l,commands:a},be("renamed",n,`command -> ${o}`,"edit"))}),!0)},upsertDisplayRule(n){e(o=>{const i=tn(o.displayRules,n);if(!i)return o;const r=i.length>o.displayRules.length;return $e(o,{displayRules:i},r?be("added",n.id,"display rule","add","success"):be("edited",n.id,"display rule","edit"),r?void 0:`displayRule:${n.id}`)})},renameDisplayRuleId(n,o){const i=t();return!n||!o||n===o?!0:i.displayRules.some(r=>r.id===o)?!1:(e(r=>{const l=r.displayRules.map(c=>c.id===n?{...c,id:o}:c),a=r.commands.map(c=>({...c,displayRules:c.displayRules.map(d=>d===n?o:d)}));return $e(r,{displayRules:l,commands:a},be("renamed",n,`display rule -> ${o}`,"edit"))}),!0)},upsertEnableRule(n){e(o=>{const i=tn(o.enableRules,n);if(!i)return o;const r=i.length>o.enableRules.length;return $e(o,{enableRules:i},r?be("added",n.id,"enable rule","add","success"):be("edited",n.id,"enable rule","edit"),r?void 0:`enableRule:${n.id}`)})},renameEnableRuleId(n,o){const i=t();return!n||!o||n===o?!0:i.enableRules.some(r=>r.id===o)?!1:(e(r=>{const l=r.enableRules.map(c=>c.id===n?{...c,id:o}:c),a=r.commands.map(c=>({...c,enableRules:c.enableRules.map(d=>d===n?o:d)}));return $e(r,{enableRules:l,commands:a},be("renamed",n,`enable rule -> ${o}`,"edit"))}),!0)},upsertLocLabel(n){e(o=>{const i=tn(o.locLabels,n);return i?$e(o,{locLabels:i},be("edited",n.id,"label","translate"),`locLabel:${n.id}`):o})},setLayerHideUnhidden(n,o,i){e(r=>{if(r.pendingUnhides[n].includes(o)===i)return r;const l=r.pendingUnhides[n].filter(a=>a!==o);return i&&l.push(o),$e(r,{pendingUnhides:{...r.pendingUnhides,[n]:l}},i?be("un-hid",o,"on publish","eye"):be("kept hidden",o,"by customizations","eye_off"))})},setOrphanDeleted(n,o,i){e(r=>{const l=r.orphans[n].find(c=>c.id===o);if(!l||i&&l.recentPublish?.published||r.pendingOrphanDeletes[n].includes(o)===i)return r;const a=r.pendingOrphanDeletes[n].filter(c=>c!==o);return i&&a.push(o),$e(r,{pendingOrphanDeletes:{...r.pendingOrphanDeletes,[n]:a}},i?be("deleted",o,"not on the canvas — removed on publish","delete","danger"):be("kept",o,"not on the canvas","arrow_undo"))})},setLayerSnapshot(n,o){e(i=>({layers:{...i.layers,[n]:o}}))},markPublished(n,o){e(i=>{const r=Object.keys(i.ribbons),l=n??r,a=Le(i.baseline),c=Le(i.ribbons);let d=i.locLabels,u=i.baselineLocLabels;const p=(j,E)=>[...j.filter(N=>!E.some(W=>W.id===N.id)),...E];for(const[j,E]of Object.entries(o??{})){const N=j==="entity"?ms:["Application"];for(const U of N)l.includes(U)&&Fm(c[U],E);const W=oi(E);d=p(d,W),u=p(u,JSON.parse(JSON.stringify(W)))}for(const j of l)a[j]=Le(c)[j];const f=r.every(j=>l.includes(j)),S={...i.layers},v={...i.pendingUnhides},x={entity:[],application:[]},g=[["entity",ms.every(j=>l.includes(j))],["application",l.includes("Application")]];for(const[j,E]of g){const N=o?.[j];if(!E||!N)continue;const W=S[j],U=(V,ee)=>[...new Set([...V,...ee])];S[j]=W?{...W,containerIds:U(W.containerIds,Er(N)),controlIds:U(W.controlIds,Gn(N))}:Vn(N)}for(const[j,E]of g){if(!E||v[j].length===0)continue;const N=S[j];N&&(S[j]={...N,hides:N.hides.filter(W=>!v[j].includes(W.location))}),x[j]=v[j],v[j]=[]}const y={...i.orphans},C={...i.pendingOrphanDeletes},w={entity:[],application:[]};for(const[j,E]of g)!E||C[j].length===0||(y[j]=y[j].filter(N=>!C[j].includes(N.id)),w[j]=C[j],C[j]=[]);const h={...i.uncustomisedCommandIds},I=[...i.reloadRequiredCommandIds],$={entity:[],application:[]};for(const[j,E]of g)if(E){for(const N of h[j])I.includes(N)||I.push(N);$[j]=h[j],h[j]=[]}const R=(j,E)=>({entity:j.entity.filter(N=>!E.entity.includes(N)),application:j.application.filter(N=>!E.application.includes(N))}),B=j=>({...j,snapshot:{...j.snapshot,pendingUnhides:R(j.snapshot.pendingUnhides,x),pendingOrphanDeletes:R(j.snapshot.pendingOrphanDeletes??wo,w),uncustomisedCommandIds:R(j.snapshot.uncustomisedCommandIds,$)}}),T=[x,$,w].reduce((j,E)=>j+E.entity.length+E.application.length,0)>0,H=i.past.map((j,E)=>{const N=T?B(j):j;return E===i.past.length-1&&N.coalesceKey?{...N,coalesceKey:void 0}:N}),k={ribbons:c,locLabels:d,baselineLocLabels:u,baseline:a,layers:S,pendingUnhides:v,uncustomisedCommandIds:h,orphans:y,pendingOrphanDeletes:C,...f?{baselineCommands:JSON.parse(JSON.stringify(i.commands)),baselineEnableRules:JSON.parse(JSON.stringify(i.enableRules)),baselineDisplayRules:JSON.parse(JSON.stringify(i.displayRules)),baselineLocLabels:JSON.parse(JSON.stringify(d)),customisedCommandIds:[]}:{}},P=Ln({...i,...k});return{...k,past:H,future:T?i.future.map(B):i.future,reloadRequiredCommandIds:I,mutationsSincePublish:P?Math.max(1,i.mutationsSincePublish):0}})}})));fm(()=>{D.getState().resetWorkspace(),Z.getState().clearSelection()});var xe=Uint8Array,qe=Uint16Array,Oi=Int32Array,fo=new xe([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ho=new xe([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ii=new xe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ca=function(e,t){for(var n=new qe(31),o=0;o<31;++o)n[o]=t+=1<<e[o-1];for(var i=new Oi(n[30]),o=1;o<30;++o)for(var r=n[o];r<n[o+1];++r)i[r]=r-n[o]<<5|o;return{b:n,r:i}},da=ca(fo,2),ua=da.b,si=da.r;ua[28]=258,si[258]=28;var ma=ca(ho,0),Qp=ma.b,fs=ma.r,ri=new qe(32768);for(var fe=0;fe<32768;++fe){var ut=(fe&43690)>>1|(fe&21845)<<1;ut=(ut&52428)>>2|(ut&13107)<<2,ut=(ut&61680)>>4|(ut&3855)<<4,ri[fe]=((ut&65280)>>8|(ut&255)<<8)>>1}var ot=(function(e,t,n){for(var o=e.length,i=0,r=new qe(t);i<o;++i)e[i]&&++r[e[i]-1];var l=new qe(t);for(i=1;i<t;++i)l[i]=l[i-1]+r[i-1]<<1;var a;if(n){a=new qe(1<<t);var c=15-t;for(i=0;i<o;++i)if(e[i])for(var d=i<<4|e[i],u=t-e[i],p=l[e[i]-1]++<<u,f=p|(1<<u)-1;p<=f;++p)a[ri[p]>>c]=d}else for(a=new qe(o),i=0;i<o;++i)e[i]&&(a[i]=ri[l[e[i]-1]++]>>15-e[i]);return a}),bt=new xe(288);for(var fe=0;fe<144;++fe)bt[fe]=8;for(var fe=144;fe<256;++fe)bt[fe]=9;for(var fe=256;fe<280;++fe)bt[fe]=7;for(var fe=280;fe<288;++fe)bt[fe]=8;var gn=new xe(32);for(var fe=0;fe<32;++fe)gn[fe]=5;var ef=ot(bt,9,0),tf=ot(bt,9,1),nf=ot(gn,5,0),of=ot(gn,5,1),jo=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Xe=function(e,t,n){var o=t/8|0;return(e[o]|e[o+1]<<8)>>(t&7)&n},No=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Ei=function(e){return(e+7)/8|0},Rn=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new xe(e.subarray(t,n))},sf=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],ze=function(e,t,n){var o=new Error(t||sf[e]);if(o.code=e,Error.captureStackTrace&&Error.captureStackTrace(o,ze),!n)throw o;return o},rf=function(e,t,n,o){var i=e.length,r=o?o.length:0;if(!i||t.f&&!t.l)return n||new xe(0);var l=!n,a=l||t.i!=2,c=t.i;l&&(n=new xe(i*3));var d=function(He){var z=n.length;if(He>z){var G=new xe(Math.max(z*2,He));G.set(n),n=G}},u=t.f||0,p=t.p||0,f=t.b||0,S=t.l,v=t.d,x=t.m,g=t.n,y=i*8;do{if(!S){u=Xe(e,p,1);var C=Xe(e,p+1,3);if(p+=3,C)if(C==1)S=tf,v=of,x=9,g=5;else if(C==2){var $=Xe(e,p,31)+257,R=Xe(e,p+10,15)+4,B=$+Xe(e,p+5,31)+1;p+=14;for(var T=new xe(B),H=new xe(19),k=0;k<R;++k)H[ii[k]]=Xe(e,p+k*3,7);p+=R*3;for(var P=jo(H),j=(1<<P)-1,E=ot(H,P,1),k=0;k<B;){var N=E[Xe(e,p,j)];p+=N&15;var w=N>>4;if(w<16)T[k++]=w;else{var W=0,U=0;for(w==16?(U=3+Xe(e,p,3),p+=2,W=T[k-1]):w==17?(U=3+Xe(e,p,7),p+=3):w==18&&(U=11+Xe(e,p,127),p+=7);U--;)T[k++]=W}}var V=T.subarray(0,$),ee=T.subarray($);x=jo(V),g=jo(ee),S=ot(V,x,1),v=ot(ee,g,1)}else ze(1);else{var w=Ei(p)+4,h=e[w-4]|e[w-3]<<8,I=w+h;if(I>i){c&&ze(0);break}a&&d(f+h),n.set(e.subarray(w,I),f),t.b=f+=h,t.p=p=I*8,t.f=u;continue}if(p>y){c&&ze(0);break}}a&&d(f+131072);for(var _=(1<<x)-1,L=(1<<g)-1,O=p;;O=p){var W=S[No(e,p)&_],F=W>>4;if(p+=W&15,p>y){c&&ze(0);break}if(W||ze(2),F<256)n[f++]=F;else if(F==256){O=p,S=null;break}else{var b=F-254;if(F>264){var k=F-257,A=fo[k];b=Xe(e,p,(1<<A)-1)+ua[k],p+=A}var X=v[No(e,p)&L],re=X>>4;X||ze(3),p+=X&15;var ee=Qp[re];if(re>3){var A=ho[re];ee+=No(e,p)&(1<<A)-1,p+=A}if(p>y){c&&ze(0);break}a&&d(f+131072);var me=f+b;if(f<ee){var Ee=r-ee,Ce=Math.min(ee,me);for(Ee+f<0&&ze(3);f<Ce;++f)n[f]=o[Ee+f]}for(;f<me;++f)n[f]=n[f-ee]}}t.l=S,t.p=O,t.b=f,t.f=u,S&&(u=1,t.m=x,t.d=v,t.n=g)}while(!u);return f!=n.length&&l?Rn(n,0,f):n.subarray(0,f)},it=function(e,t,n){n<<=t&7;var o=t/8|0;e[o]|=n,e[o+1]|=n>>8},nn=function(e,t,n){n<<=t&7;var o=t/8|0;e[o]|=n,e[o+1]|=n>>8,e[o+2]|=n>>16},$o=function(e,t){for(var n=[],o=0;o<e.length;++o)e[o]&&n.push({s:o,f:e[o]});var i=n.length,r=n.slice();if(!i)return{t:fa,l:0};if(i==1){var l=new xe(n[0].s+1);return l[n[0].s]=1,{t:l,l:1}}n.sort(function(I,$){return I.f-$.f}),n.push({s:-1,f:25001});var a=n[0],c=n[1],d=0,u=1,p=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};u!=i-1;)a=n[n[d].f<n[p].f?d++:p++],c=n[d!=u&&n[d].f<n[p].f?d++:p++],n[u++]={s:-1,f:a.f+c.f,l:a,r:c};for(var f=r[0].s,o=1;o<i;++o)r[o].s>f&&(f=r[o].s);var S=new qe(f+1),v=ai(n[u-1],S,0);if(v>t){var o=0,x=0,g=v-t,y=1<<g;for(r.sort(function($,R){return S[R.s]-S[$.s]||$.f-R.f});o<i;++o){var C=r[o].s;if(S[C]>t)x+=y-(1<<v-S[C]),S[C]=t;else break}for(x>>=g;x>0;){var w=r[o].s;S[w]<t?x-=1<<t-S[w]++-1:++o}for(;o>=0&&x;--o){var h=r[o].s;S[h]==t&&(--S[h],++x)}v=t}return{t:new xe(S),l:v}},ai=function(e,t,n){return e.s==-1?Math.max(ai(e.l,t,n+1),ai(e.r,t,n+1)):t[e.s]=n},hs=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new qe(++t),o=0,i=e[0],r=1,l=function(c){n[o++]=c},a=1;a<=t;++a)if(e[a]==i&&a!=t)++r;else{if(!i&&r>2){for(;r>138;r-=138)l(32754);r>2&&(l(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(l(i),--r;r>6;r-=6)l(8304);r>2&&(l(r-3<<5|8208),r=0)}for(;r--;)l(i);r=1,i=e[a]}return{c:n.subarray(0,o),n:t}},on=function(e,t){for(var n=0,o=0;o<t.length;++o)n+=e[o]*t[o];return n},pa=function(e,t,n){var o=n.length,i=Ei(t+2);e[i]=o&255,e[i+1]=o>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var r=0;r<o;++r)e[i+r+4]=n[r];return(i+4+o)*8},gs=function(e,t,n,o,i,r,l,a,c,d,u){it(t,u++,n),++i[256];for(var p=$o(i,15),f=p.t,S=p.l,v=$o(r,15),x=v.t,g=v.l,y=hs(f),C=y.c,w=y.n,h=hs(x),I=h.c,$=h.n,R=new qe(19),B=0;B<C.length;++B)++R[C[B]&31];for(var B=0;B<I.length;++B)++R[I[B]&31];for(var T=$o(R,7),H=T.t,k=T.l,P=19;P>4&&!H[ii[P-1]];--P);var j=d+5<<3,E=on(i,bt)+on(r,gn)+l,N=on(i,f)+on(r,x)+l+14+3*P+on(R,H)+2*R[16]+3*R[17]+7*R[18];if(c>=0&&j<=E&&j<=N)return pa(t,u,e.subarray(c,c+d));var W,U,V,ee;if(it(t,u,1+(N<E)),u+=2,N<E){W=ot(f,S,0),U=f,V=ot(x,g,0),ee=x;var _=ot(H,k,0);it(t,u,w-257),it(t,u+5,$-1),it(t,u+10,P-4),u+=14;for(var B=0;B<P;++B)it(t,u+3*B,H[ii[B]]);u+=3*P;for(var L=[C,I],O=0;O<2;++O)for(var F=L[O],B=0;B<F.length;++B){var b=F[B]&31;it(t,u,_[b]),u+=H[b],b>15&&(it(t,u,F[B]>>5&127),u+=F[B]>>12)}}else W=ef,U=bt,V=nf,ee=gn;for(var B=0;B<a;++B){var A=o[B];if(A>255){var b=A>>18&31;nn(t,u,W[b+257]),u+=U[b+257],b>7&&(it(t,u,A>>23&31),u+=fo[b]);var X=A&31;nn(t,u,V[X]),u+=ee[X],X>3&&(nn(t,u,A>>5&8191),u+=ho[X])}else nn(t,u,W[A]),u+=U[A]}return nn(t,u,W[256]),u+U[256]},af=new Oi([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),fa=new xe(0),lf=function(e,t,n,o,i,r){var l=r.z||e.length,a=new xe(o+l+5*(1+Math.ceil(l/7e3))+i),c=a.subarray(o,a.length-i),d=r.l,u=(r.r||0)&7;if(t){u&&(c[0]=r.r>>3);for(var p=af[t-1],f=p>>13,S=p&8191,v=(1<<n)-1,x=r.p||new qe(32768),g=r.h||new qe(v+1),y=Math.ceil(n/3),C=2*y,w=function(te){return(e[te]^e[te+1]<<y^e[te+2]<<C)&v},h=new Oi(25e3),I=new qe(288),$=new qe(32),R=0,B=0,T=r.i||0,H=0,k=r.w||0,P=0;T+2<l;++T){var j=w(T),E=T&32767,N=g[j];if(x[E]=N,g[j]=E,k<=T){var W=l-T;if((R>7e3||H>24576)&&(W>423||!d)){u=gs(e,c,0,h,I,$,B,H,P,T-P,u),H=R=B=0,P=T;for(var U=0;U<286;++U)I[U]=0;for(var U=0;U<30;++U)$[U]=0}var V=2,ee=0,_=S,L=E-N&32767;if(W>2&&j==w(T-L))for(var O=Math.min(f,W)-1,F=Math.min(32767,T),b=Math.min(258,W);L<=F&&--_&&E!=N;){if(e[T+V]==e[T+V-L]){for(var A=0;A<b&&e[T+A]==e[T+A-L];++A);if(A>V){if(V=A,ee=L,A>O)break;for(var X=Math.min(L,A-2),re=0,U=0;U<X;++U){var me=T-L+U&32767,Ee=x[me],Ce=me-Ee&32767;Ce>re&&(re=Ce,N=me)}}}E=N,N=x[E],L+=E-N&32767}if(ee){h[H++]=268435456|si[V]<<18|fs[ee];var He=si[V]&31,z=fs[ee]&31;B+=fo[He]+ho[z],++I[257+He],++$[z],k=T+V,++R}else h[H++]=e[T],++I[e[T]]}}for(T=Math.max(T,k);T<l;++T)h[H++]=e[T],++I[e[T]];u=gs(e,c,d,h,I,$,B,H,P,T-P,u),d||(r.r=u&7|c[u/8|0]<<3,u-=7,r.h=g,r.p=x,r.i=T,r.w=k)}else{for(var T=r.w||0;T<l+d;T+=65535){var G=T+65535;G>=l&&(c[u/8|0]=d,G=l),u=pa(c,u+1,e.subarray(T,G))}r.i=l}return Rn(a,0,o+Ei(u)+i)},cf=(function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,o=9;--o;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e})(),df=function(){var e=-1;return{p:function(t){for(var n=e,o=0;o<t.length;++o)n=cf[n&255^t[o]]^n>>>8;e=n},d:function(){return~e}}},uf=function(e,t,n,o,i){if(!i&&(i={l:1},t.dictionary)){var r=t.dictionary.subarray(-32768),l=new xe(r.length+e.length);l.set(r),l.set(e,r.length),e=l,i.w=r.length}return lf(e,t.level==null?6:t.level,t.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,o,i)},ha=function(e,t){var n={};for(var o in e)n[o]=e[o];for(var o in t)n[o]=t[o];return n},tt=function(e,t){return e[t]|e[t+1]<<8},We=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},To=function(e,t){return We(e,t)+We(e,t+4)*4294967296},Ae=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function ga(e,t){return uf(e,t||{},0,0)}function ba(e,t){return rf(e,{i:2},t&&t.out,t&&t.dictionary)}var ya=function(e,t,n,o){for(var i in e){var r=e[i],l=t+i,a=o;Array.isArray(r)&&(a=ha(o,r[1]),r=r[0]),ArrayBuffer.isView(r)?n[l]=[r,a]:(n[l+="/"]=[new xe(0),a],ya(r,l,n,o))}},bs=typeof TextEncoder<"u"&&new TextEncoder,li=typeof TextDecoder<"u"&&new TextDecoder,mf=0;try{li.decode(fa,{stream:!0}),mf=1}catch{}var pf=function(e){for(var t="",n=0;;){var o=e[n++],i=(o>127)+(o>223)+(o>239);if(n+i>e.length)return{s:t,r:Rn(e,n-1)};i?i==3?(o=((o&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|o>>10,56320|o&1023)):i&1?t+=String.fromCharCode((o&31)<<6|e[n++]&63):t+=String.fromCharCode((o&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(o)}};function Yn(e,t){if(t){for(var n=new xe(e.length),o=0;o<e.length;++o)n[o]=e.charCodeAt(o);return n}if(bs)return bs.encode(e);for(var i=e.length,r=new xe(e.length+(e.length>>1)),l=0,a=function(u){r[l++]=u},o=0;o<i;++o){if(l+5>r.length){var c=new xe(l+8+(i-o<<1));c.set(r),r=c}var d=e.charCodeAt(o);d<128||t?a(d):d<2048?(a(192|d>>6),a(128|d&63)):d>55295&&d<57344?(d=65536+(d&1047552)|e.charCodeAt(++o)&1023,a(240|d>>18),a(128|d>>12&63),a(128|d>>6&63),a(128|d&63)):(a(224|d>>12),a(128|d>>6&63),a(128|d&63))}return Rn(r,0,l)}function bn(e,t){if(t){for(var n="",o=0;o<e.length;o+=16384)n+=String.fromCharCode.apply(null,e.subarray(o,o+16384));return n}else{if(li)return li.decode(e);var i=pf(e),r=i.s,n=i.r;return n.length&&ze(8),r}}var ff=function(e,t){return t+30+tt(e,t+26)+tt(e,t+28)},hf=function(e,t,n){var o=tt(e,t+28),i=tt(e,t+30),r=bn(e.subarray(t+46,t+46+o),!(tt(e,t+8)&2048)),l=t+46+o,a=gf(e,l,i,n,We(e,t+20),We(e,t+24),We(e,t+42)),c=a[0],d=a[1],u=a[2];return[tt(e,t+10),c,d,r,l+i+tt(e,t+32),u]},gf=function(e,t,n,o,i,r,l){var a=i==4294967295,c=r==4294967295,d=l==4294967295,u=t+n,p=a+c+d;if(o&&p){for(;t+4<u;t+=4+tt(e,t+2))if(tt(e,t)==1)return[a?To(e,t+4+8*c):i,c?To(e,t+4):r,d?To(e,t+4+8*(c+a)):l,1];o<2&&ze(13)}return[i,r,l,0]},ci=function(e){var t=0;if(e)for(var n in e){var o=e[n].length;o>65535&&ze(9),t+=o+4}return t},ys=function(e,t,n,o,i,r,l,a){var c=o.length,d=n.extra,u=a&&a.length,p=ci(d);Ae(e,t,l!=null?33639248:67324752),t+=4,l!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(r<0&&8),e[t++]=i&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),S=f.getFullYear()-1980;if((S<0||S>119)&&ze(10),Ae(e,t,S<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,r!=-1&&(Ae(e,t,n.crc),Ae(e,t+4,r<0?-r-2:r),Ae(e,t+8,n.size)),Ae(e,t+12,c),Ae(e,t+14,p),t+=16,l!=null&&(Ae(e,t,u),Ae(e,t+6,n.attrs),Ae(e,t+10,l),t+=14),e.set(o,t),t+=c,p)for(var v in d){var x=d[v],g=x.length;Ae(e,t,+v),Ae(e,t+2,g),e.set(x,t+4),t+=4+g}return u&&(e.set(a,t),t+=u),t},bf=function(e,t,n,o,i){Ae(e,t,101010256),Ae(e,t+8,n),Ae(e,t+10,n),Ae(e,t+12,o),Ae(e,t+16,i)};function Oy(e,t){t||(t={});var n={},o=[];ya(e,"",n,t);var i=0,r=0;for(var l in n){var a=n[l],c=a[0],d=a[1],u=d.level==0?0:8,p=Yn(l),f=p.length,S=d.comment,v=S&&Yn(S),x=v&&v.length,g=ci(d.extra);f>65535&&ze(11);var y=u?ga(c,d):c,C=y.length,w=df();w.p(c),o.push(ha(d,{size:c.length,crc:w.d(),c:y,f:p,m:v,u:f!=l.length||v&&S.length!=x,o:i,compression:u})),i+=30+f+g+C,r+=76+2*(f+g)+(x||0)+C}for(var h=new xe(r+22),I=i,$=r-i,R=0;R<o.length;++R){var p=o[R];ys(h,p.o,p,p.f,p.u,p.c.length);var B=30+p.f.length+ci(p.extra);h.set(p.c,p.o+B),ys(h,i,p,p.f,p.u,p.c.length,p.o,p.m),i+=16+B+(p.m?p.m.length:0)}return bf(h,i,o.length,$,I),h}function yf(e,t){for(var n={},o=e.length-22;We(e,o)!=101010256;--o)(!o||e.length-o>65558)&&ze(13);var i=tt(e,o+8);if(!i)return{};var r=We(e,o+16),l=We(e,o-20)==117853008;if(l){var a=We(e,o-12);l=We(e,a)==101075792,l&&(i=We(e,a+32),r=We(e,a+48))}for(var c=0;c<i;++c){var d=hf(e,r,l),u=d[0],p=d[1],f=d[2],S=d[3],v=d[4],x=d[5],g=ff(e,x);r=v,u?u==8?n[S]=ba(e.subarray(g,g+p),{out:new xe(f)}):ze(14,"unknown compression type "+u):n[S]=Rn(e,g,g+p)}return n}const Mi=4,xa=30,Sa=`cbs:draft:v${Mi}:`,xf=["cbs:ribbon:","cbs:draft:"],Mt={commands:"baselineCommands",enableRules:"baselineEnableRules",displayRules:"baselineDisplayRules",locLabels:"baselineLocLabels"},Li=["HomepageGrid","SubGrid","Form","Application"];function va(e){return{orgUrl:e.orgUrl.trim().replace(/\/+$/,"").toLowerCase(),solutionId:e.solutionId.trim().toLowerCase(),entityLogicalName:e.entityLogicalName.trim().toLowerCase()}}function yn(e){const t=va(e);return`${Sa}${encodeURIComponent(t.orgUrl)}:${encodeURIComponent(t.solutionId)}:${encodeURIComponent(t.entityLogicalName)}`}function di(e,t){return!e||!t?!1:yn(e)===yn(t)}function Sf(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return`${(t>>>0).toString(16)}.${e.length}`}let $n=null;function Ca(e){const t=[e.baseline,e.baselineCommands,e.baselineEnableRules,e.baselineDisplayRules,e.baselineLocLabels,e.layers,e.baseLanguageCode];if($n&&$n.of.every((o,i)=>o===t[i]))return $n.value;const n=Sf(JSON.stringify(t));return $n={of:t,value:n},n}const xs=new WeakMap;function Tn(e){let t=xs.get(e);return t===void 0&&(t=JSON.stringify(e),xs.set(e,t)),t}const Bt=e=>JSON.parse(JSON.stringify(e)),jn={},wa={list:"groups",child:{list:"buttons",child:jn}};function Ia(e){const t=new Map;for(const n of e)t.set(n.id,t.has(n.id)?null:n);return t}function ko(e,t,n){if(!n.list||!Array.isArray(e[n.list]))return e;const o=t?.[n.list]??[];return{...e,[n.list]:ui(e[n.list],o,n.child??jn)}}function kn(e,t,n){if(!n.list||e[n.list]===void 0)return e;const o=t?.[n.list]??[];return{...e,[n.list]:mi(e[n.list],o,n.child??jn)}}function ui(e,t,n){const o=Ia(t),i=new Set(e.map(r=>r.id));if(i.size===e.length&&o.size===t.length){const r=t.filter(a=>i.has(a.id)),l=e.slice(r.length);if(r.every((a,c)=>e[c].id===a.id)&&l.every(a=>!o.has(a.id)))return{set:e.slice(0,r.length).filter(a=>Tn(o.get(a.id))!==Tn(a)).map(a=>ko(a,o.get(a.id),n)),drop:t.filter(a=>!i.has(a.id)).map(a=>a.id),add:l.map(a=>ko(a,void 0,n))}}return e.map(r=>{const l=o.get(r.id)??void 0;return l&&Tn(l)===Tn(r)?r.id:ko(r,l,n)})}function mi(e,t,n){const o=Ia(t);if(Array.isArray(e)){const c=[];for(const d of e)if(typeof d!="string")c.push(kn(d,o.get(d.id)??void 0,n));else{const u=o.get(d);u&&c.push(Bt(u))}return c}const i=new Set(e.drop),r=new Map(e.set.map(c=>[c.id,c])),l=[];for(const c of e.add)o.has(c.id)?r.set(c.id,c):l.push(c);const a=new Set(t.map(c=>c.id));return[...t.filter(c=>!i.has(c.id)).map(c=>r.has(c.id)?kn(r.get(c.id),c,n):Bt(c)),...[...r.values()].filter(c=>!a.has(c.id)).map(c=>kn(c,void 0,n)),...l.map(c=>kn(c,void 0,n))]}const vf=e=>!Array.isArray(e)&&e.set.length+e.drop.length+e.add.length===0,Zn=e=>e;function Cf(e){const t=et(e),n={};for(const r of Li){const l=t.ribbons[r],a=e.baseline[r];if(!l)continue;const c=ui(l.tabs,a?.tabs??[],wa),d={};for(const[p,f]of Object.entries(l))p!=="tabs"&&JSON.stringify(f)!==JSON.stringify(a?.[p])&&(d[p]=f);const u=Object.keys(a??{}).filter(p=>p!=="tabs"&&!(p in l));(!vf(c)||Object.keys(d).length+u.length>0)&&(n[r]={props:d,unset:u,tabs:c})}const o={};for(const r of Object.keys(Mt))o[r]=ui(Zn(t[r]),Zn(e[Mt[r]]),jn);const i={...t};delete i.ribbons;for(const r of Object.keys(Mt))delete i[r];return{ribbons:n,lists:o,other:i}}function wf(e,t){const{delta:n}=e,o={};for(const r of Li){const l=n.ribbons[r],a=t.baseline[r];if(!l){o[r]=Bt(a);continue}const c={...Bt(a),...Bt(l.props)};for(const d of l.unset)delete c[d];c.tabs=mi(l.tabs,Zn(a?.tabs??[]),wa),o[r]=c}const i={...et(t),...Bt(n.other),ribbons:o};for(const r of Object.keys(Mt))i[r]=mi(n.lists[r],Zn(t[Mt[r]]),jn);return i}function If(e){return btoa(bn(ga(Yn(JSON.stringify(e)),{level:9}),!0))}function Rf(e){return JSON.parse(bn(ba(Yn(atob(e),!0))))}const ht=e=>Array.isArray(e),Ao=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Ss=e=>{if(ht(e))return!0;const t=e;return!!t&&typeof t=="object"&&ht(t.set)&&ht(t.drop)&&ht(t.add)},jf=e=>!!e&&typeof e=="object"&&ht(e.entity)&&ht(e.application);function Nf(e){if(!e||typeof e!="object")return!1;const t=e,n=t.ribbons,o=t.other??{};return!!n&&typeof n=="object"&&Object.entries(n).every(([i,r])=>Li.includes(i)&&Ss(r?.tabs)&&Ao(r?.props)&&ht(r?.unset))&&Ao(t.lists)&&Object.keys(Mt).every(i=>Ss(t.lists[i]))&&Ao(t.other)&&["pendingUnhides","uncustomisedCommandIds"].every(i=>!(i in o)||jf(o[i]))&&(!("customisedCommandIds"in o)||ht(o.customisedCommandIds))}function $f(e,t){try{const n={format:Mi,key:va(e),savedAt:new Date().toISOString(),baselineFingerprint:Ca(t),data:If(Cf(t))};return localStorage.setItem(yn(e),JSON.stringify(n)),n.savedAt}catch{return null}}function Tf(e){const t=yn(e);let n;try{n=localStorage.getItem(t)}catch{return null}if(!n)return null;try{const o=JSON.parse(n);if(o.format===Mi&&di(o.key,e)&&typeof o.data=="string"){const i=Rf(o.data);if(Nf(i)){const r=o;return{format:r.format,key:r.key,savedAt:r.savedAt,baselineFingerprint:r.baselineFingerprint,delta:i}}}}catch{}return Qn(e),null}function Qn(e){try{localStorage.removeItem(yn(e))}catch{}}function kf(e,t){try{const n=Date.parse(JSON.parse(e??"").savedAt??"");return!(t-n<=xa*864e5)}catch{return!0}}function Af(e=Date.now()){const t=[];try{for(let n=0;n<localStorage.length;n++){const o=localStorage.key(n);o&&(o.startsWith(Sa)?kf(localStorage.getItem(o),e):xf.some(i=>o.startsWith(i)))&&t.push(o)}for(const n of t)localStorage.removeItem(n)}catch{return 0}return t.length}function Ra(e){return e.mutationsSincePublish>0||Ln(e)}function vs(){return Se.getState().target!==null&&Ra(D.getState())}let un=null;function zt(e){const{target:t,pending:n}=Se.getState();if(!t||n)return!0;const o=e.ribbons.HomepageGrid.entityLogicalName;if(o&&o.toLowerCase()!==t.entityLogicalName.toLowerCase())return!0;let i=!0;if(!Ra(e))un!==null&&e.future.some(a=>a.op==="restored"&&a.ts===un)||(Qn(t),Se.setState({lastSavedAt:null}));else{const l=$f(t,e);i=l!==null,l&&Se.setState({lastSavedAt:l})}const{saveFailed:r}=Se.getState();return!i&&!r&&oe.getState().logWarn("ribbon","Unsaved changes could not be saved as a draft (browser storage is full or unavailable): publish them, or they are lost when Command Bar Studio closes."),i===r&&Se.setState({saveFailed:!i}),i}const Df=["mutationsSincePublish","ribbons","commands","enableRules","displayRules","locLabels","pendingUnhides","customisedCommandIds","uncustomisedCommandIds","baseline","baselineCommands","baselineEnableRules","baselineDisplayRules","baselineLocLabels","layers"];function zf(){return D.subscribe((e,t)=>{Df.every(n=>e[n]===t[n])||zt(e)})}function Bf(e){const t=ie.getState();return{orgUrl:t.connectionUrl,solutionId:t.activeSolution?.id??"",entityLogicalName:e}}function Of(){const e=D.getState();e.loadWorkspace({ribbons:e.baseline,commands:e.baselineCommands,enableRules:e.baselineEnableRules,displayRules:e.baselineDisplayRules,locLabels:e.baselineLocLabels,templates:e.templates,conflicts:e.conflicts,layers:e.layers,baseLanguageCode:e.baseLanguageCode})}function Do(e){Se.setState({target:null,pending:null,pendingBaselineChanged:!1});const t=ie.getState();e.kind==="entity"?t.setActiveEntity(e.entity):t.setActiveSolution(e.solution)}const Se=Rt()((e,t)=>({target:null,pending:null,pendingBaselineChanged:!1,restoreError:null,pendingSwitch:null,saveFailed:!1,lastSavedAt:null,beginLoad(){un=null,e({target:null,pending:null,pendingBaselineChanged:!1,restoreError:null,saveFailed:!1,lastSavedAt:null})},workspaceLoaded(n){const o=Tf(n);un=null,e({target:n,pending:o,restoreError:null,lastSavedAt:o?.savedAt??null,pendingBaselineChanged:!!o&&o.baselineFingerprint!==Ca(D.getState())})},restoreDraft(){const{target:n,pending:o}=t();if(!n||!o||!di(n,o.key))return!1;const i=D.getState();try{i.restoreWorkspace(wf(o,i),`saved ${new Date(o.savedAt).toLocaleString()}`)}catch(a){const c=a instanceof Error?a.message:String(a);return oe.getState().logError("ribbon",`The unsaved changes saved ${o.savedAt} couldn't be restored: ${c}`),e({restoreError:c}),!1}const r=D.getState(),l=r.past[r.past.length-1];return r.past.length>i.past.length&&l?.op==="restored"&&(un=l.ts),e({pending:null,pendingBaselineChanged:!1,restoreError:null}),zt(r),!0},discardDraft(){const{target:n,pending:o}=t();o&&(Qn(o.key),e({pending:null,pendingBaselineChanged:!1,restoreError:null,lastSavedAt:null}),n&&di(n,o.key)&&zt(D.getState()))},requestEntitySwitch(n){ie.getState().activeEntity?.logicalName!==n.logicalName&&(vs()?(zt(D.getState()),e({pendingSwitch:{kind:"entity",entity:n}})):Do({kind:"entity",entity:n}))},requestSolutionSwitch(n){ie.getState().activeSolution?.id!==n.id&&(vs()?(zt(D.getState()),e({pendingSwitch:{kind:"solution",solution:n}})):Do({kind:"solution",solution:n}))},resolveSwitch(n){const{pendingSwitch:o,target:i,pending:r}=t();if(o){if(n==="cancel"){e({pendingSwitch:null});return}n==="keep"&&!zt(D.getState())||(n==="discard"&&i&&!r&&Qn(i),e({pendingSwitch:null,target:null,pending:null,pendingBaselineChanged:!1,saveFailed:!1}),Of(),Do(o))}}})),Ef=le({root:{height:"40px",display:"flex",alignItems:"center",gap:m.spacingHorizontalS,padding:`0 ${m.spacingHorizontalM}`,backgroundColor:m.colorNeutralBackground3,borderBottom:`1px solid ${m.colorNeutralStroke2}`,flexShrink:0},brand:{display:"flex",alignItems:"center",gap:m.spacingHorizontalS,marginRight:m.spacingHorizontalS},brandMark:{width:"24px",height:"24px",borderRadius:"4px",backgroundColor:m.colorBrandBackground,display:"flex",alignItems:"center",justifyContent:"center"},spacer:{flex:1},sep:{width:"1px",height:"20px",backgroundColor:m.colorNeutralStroke2,margin:`0 ${m.spacingHorizontalXS}`},paletteButton:{height:"28px",minWidth:"260px",display:"flex",alignItems:"center",gap:m.spacingHorizontalS,padding:`0 ${m.spacingHorizontalS}`,border:`1px solid ${m.colorNeutralStroke1}`,borderRadius:m.borderRadiusMedium,backgroundColor:m.colorNeutralBackground1,cursor:"pointer",color:m.colorNeutralForeground3,fontSize:m.fontSizeBase200,"&:hover":{border:`1px solid ${m.colorNeutralStroke1Hover}`,backgroundColor:m.colorNeutralBackground1Hover}},kbd:{padding:"1px 4px",border:`1px solid ${m.colorNeutralStroke2}`,borderRadius:"3px",fontSize:m.fontSizeBase100,backgroundColor:m.colorNeutralBackground2},solutionPickerSurface:{padding:m.spacingHorizontalM,minWidth:"360px",display:"flex",flexDirection:"column",gap:m.spacingVerticalS},solutionPickerHint:{color:m.colorNeutralForeground3}});function Mf(){const e=Ef(),[t,n]=M.useState("Loaded"),o=D(h=>h.past),i=D(h=>h.future),r=D(h=>h.undo),l=D(h=>h.redo),a=ie(h=>h.solutions),c=ie(h=>h.activeSolution),d=Se(h=>h.requestSolutionSwitch),u=Y(h=>h.openBulkPublish),p=Y(h=>h.openXmlDrawer),f=Y(h=>h.setCommandPaletteOpen),[S,v]=M.useState(!1),[x,g]=M.useState(""),y=M.useMemo(()=>a.filter(h=>!h.isManaged).map(h=>({value:h.id,children:h.friendlyName||h.uniqueName,searchText:`${h.friendlyName??""} ${h.uniqueName??""}`.toLowerCase(),solution:h})),[a]),C=xu(x,y,{optionToText:h=>h.searchText,filter:(h,I)=>h.includes(I.toLowerCase()),optionToReactKey:h=>h.value,renderOption:h=>s.jsx(Iu,{value:h.value,text:h.solution.friendlyName??h.solution.uniqueName,children:s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2,minWidth:0},children:[s.jsx(q,{size:200,weight:"semibold",children:h.solution.friendlyName||h.solution.uniqueName}),s.jsxs(q,{size:100,style:{color:m.colorNeutralForeground3},children:[h.solution.uniqueName," · v",h.solution.version,h.solution.publisherName?` · ${h.solution.publisherName}`:""]})]})},h.value),noOptionsMessage:a.length===0?"Loading solutions…":"No solutions match the filter."}),w=(h,I)=>{const $=a.find(R=>R.id===I.optionValue);$&&(d($),v(!1),g(""))};return s.jsxs("header",{className:e.root,children:[s.jsxs("div",{className:e.brand,children:[s.jsx("div",{className:e.brandMark,children:s.jsx(q,{size:100,weight:"bold",style:{color:"white",lineHeight:1},children:"CBS"})}),s.jsx(q,{weight:"semibold",size:300,children:"Command Bar Studio"})]}),s.jsx("div",{className:e.sep}),s.jsxs(Su,{open:S,onOpenChange:(h,I)=>v(I.open),positioning:"below-start",trapFocus:!0,children:[s.jsx(vu,{disableButtonEnhancement:!0,children:s.jsxs(K,{appearance:c?"subtle":"primary",size:"small",icon:s.jsx(bl,{}),iconPosition:"before","aria-label":"Select solution",children:[s.jsx(q,{size:200,children:"Solution: "}),s.jsx(q,{size:200,weight:"semibold",children:c?.friendlyName??"Select solution…"}),c&&s.jsxs(s.Fragment,{children:[s.jsx(ae,{appearance:"tint",color:c.isManaged?"informative":"success",size:"small",style:{marginLeft:m.spacingHorizontalXS},children:c.isManaged?"Managed":"Unmanaged"}),(()=>{const h=c.publisherPrefix||"new",I=h==="new"||/^defaultpublisher/i.test(c.publisherUniqueName??"");return s.jsxs(ae,{appearance:"tint",color:I?"warning":"informative",size:"small",title:I?`Imports will land under the org's default publisher "${h}". To use your own publisher, create a new solution in maker.powerapps.com bound to it.`:`Publisher: ${c.publisherName||c.publisherUniqueName||h}`,style:{marginLeft:m.spacingHorizontalXS},children:[h,"_"]})})()]}),s.jsx(gt,{fontSize:12,style:{marginLeft:m.spacingHorizontalXS,color:m.colorNeutralForeground3}})]})}),s.jsxs(Cu,{className:e.solutionPickerSurface,children:[s.jsx(q,{size:200,weight:"semibold",children:"Select an unmanaged solution"}),s.jsx(De,{label:"Solution",children:s.jsx(wu,{placeholder:a.length===0?"Loading solutions…":"Search by display name or unique name",value:x,onChange:h=>g(h.target.value),onOptionSelect:w,freeform:!0,clearable:!0,children:C})}),s.jsxs(q,{size:100,className:e.solutionPickerHint,children:[y.length," unmanaged solution",y.length!==1?"s":""," available"]})]})]}),s.jsx("div",{className:e.spacer}),s.jsxs("button",{type:"button",className:e.paletteButton,onClick:()=>f(!0),"aria-label":"Search buttons, commands, rules (Ctrl+K)",children:[s.jsx(ft,{fontSize:14}),s.jsx("span",{style:{flex:1,textAlign:"left"},children:"Search buttons, commands, rules…"}),s.jsx("kbd",{className:e.kbd,children:"Ctrl"}),s.jsx("kbd",{className:e.kbd,children:"K"})]}),s.jsx("div",{className:e.sep}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(Qs,{}),disabled:o.length===0,onClick:r,title:"Undo (Ctrl+Z)","aria-label":"Undo"}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(er,{}),disabled:i.length===0,onClick:l,title:"Redo (Ctrl+Shift+Z)","aria-label":"Redo"}),s.jsx("div",{className:e.sep}),s.jsxs(dt,{value:t,onChange:(h,I)=>n(I.value),size:"small",title:"State simulator","aria-label":"State simulator",children:[s.jsx("option",{value:"Loaded",children:"Loaded"}),s.jsx("option",{value:"Empty",children:"Empty"}),s.jsx("option",{value:"Error",children:"Error"}),s.jsx("option",{value:"Publishing",children:"Publishing"})]}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(tr,{}),onClick:()=>{p()},title:"Import / Export RibbonDiffXml","aria-label":"Import/Export"}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(nr,{}),title:"Settings","aria-label":"Settings"}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(or,{}),title:"Help","aria-label":"Help"}),s.jsx("div",{className:e.sep}),s.jsx(K,{appearance:"secondary",size:"small",icon:s.jsx(ir,{}),children:"Save"}),s.jsx(K,{appearance:"primary",size:"small",icon:s.jsx(yl,{}),onClick:u,children:"Publish All"})]})}const Lf=le({root:{height:"36px",display:"flex",alignItems:"center",gap:m.spacingHorizontalS,padding:`0 ${m.spacingHorizontalM}`,backgroundColor:m.colorNeutralBackground2,borderBottom:`1px solid ${m.colorNeutralStroke2}`,flexShrink:0,position:"relative"},breadcrumb:{display:"flex",alignItems:"center",gap:m.spacingHorizontalXS,color:m.colorNeutralForeground3,fontSize:m.fontSizeBase200},separator:{color:m.colorNeutralForeground4},activeSegment:{color:m.colorNeutralForeground1,fontWeight:m.fontWeightSemibold},spacer:{flex:1}});function Pf(){const e=Lf(),t=D(p=>p.mutationsSincePublish),n=ie(p=>p.activeSolution),o=ie(p=>p.activeEntity),i=ie(p=>p.connectionUrl),r=Y(p=>p.openXmlDrawer),l=Y(p=>p.openImportXml),a=Y(p=>p.openDiffViewer),c=Y(p=>p.rightPaneMode),d=Y(p=>p.setRightPaneMode);async function u(){if(!i||!o?.logicalName)return;const p=`${i.replace(/\/$/,"")}/main.aspx?pagetype=entitylist&etn=${encodeURIComponent(o.logicalName)}`;await window.toolboxAPI?.utils.openInConnectionBrowser(p,"primary")}return s.jsxs("div",{className:e.root,children:[s.jsxs("nav",{"aria-label":"Breadcrumb",className:e.breadcrumb,children:[s.jsx("span",{children:"Solutions"}),s.jsx("span",{className:e.separator,children:"›"}),s.jsx("span",{children:n?.friendlyName??"—"}),s.jsx("span",{className:e.separator,children:"›"}),s.jsx("span",{children:"Tables"}),s.jsx("span",{className:e.separator,children:"›"}),s.jsx("span",{className:e.activeSegment,children:o?.displayName??"Select a table"})]}),s.jsx("div",{className:e.spacer}),t>0&&s.jsxs(ae,{appearance:"tint",color:"warning",children:[t," change",t!==1?"s":""," since publish"]}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(Ct,{}),onClick:()=>{u()},disabled:!o?.logicalName,children:"Preview in app"}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(Ht,{}),onClick:r,children:"RibbonDiffXml"}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(tr,{}),onClick:()=>l(),children:"Import / Export"}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(sr,{}),onClick:()=>a("compare"),children:"Compare"}),s.jsxs(dt,{size:"small",value:c,onChange:(p,f)=>d(f.value),"aria-label":"Properties pane mode",children:[s.jsx("option",{value:"docked",children:"Properties: Docked"}),s.jsx("option",{value:"floating",children:"Properties: Floating"}),s.jsx("option",{value:"hidden",children:"Properties: Hidden"})]})]})}function Ff(e){return e instanceof Element?e instanceof HTMLElement&&e.isContentEditable?!0:!!e.closest('input, textarea, select, [contenteditable]:not([contenteditable="false"]), [role="textbox"], [role="combobox"], [role="spinbutton"], .monaco-editor'):!1}const _f='[role="dialog"], [role="alertdialog"], [role="menu"], [role="menubar"], [role="listbox"], .fui-PopoverSurface, .fui-MenuPopover',ja=".fui-OverlayDrawer, .fui-InlineDrawer",Cs=e=>!!e.closest(ja)&&!e.matches('[role="alertdialog"]');function qf(e){const t=e instanceof Element?e.closest(_f):null;return t&&!Cs(t)?!0:Array.from(document.querySelectorAll('[aria-modal="true"], [role="alertdialog"]')).some(n=>!Cs(n))}function Hf(e){return e instanceof Element&&!!e.closest(ja)}function Gf(){const e=Y(h=>h.setCommandPaletteOpen),t=Y(h=>h.openBulkPublish),n=Y(h=>h.announce),o=Y(h=>h.openHideInsteadOfDelete),i=D(h=>h.undo),r=D(h=>h.redo),l=D(h=>h.past),a=D(h=>h.future),c=Z(h=>h.selectedButtonId),d=Z(h=>h.selectedGroupId),u=Z(h=>h.tabId),p=Z(h=>h.location),f=D(h=>h.duplicateButton),S=D(h=>h.deleteButton),v=D(h=>h.moveButton),x=D(h=>h.ribbons),g=D(h=>h.baseline),y=Z(h=>h.selectButtonInContext),C=Z(h=>h.selectGroup),w=M.useRef(null);M.useEffect(()=>{const h=I=>{const R=navigator.platform.toUpperCase().includes("MAC")?I.metaKey:I.ctrlKey,B=I.target;if(I.key==="Escape"){e(!1);return}if(qf(B)){R&&I.key==="s"&&I.preventDefault();return}if(R&&I.key==="k"){I.preventDefault(),e(!0),n("Command palette opened");return}if(R&&I.key==="s"){I.preventDefault(),t(),n("Bulk publish dialog opened");return}const T=Ff(B);if(R&&I.key==="z"&&!I.shiftKey&&l.length>0&&!T){I.preventDefault(),i(),n("Undo");return}if((R&&I.key==="y"||R&&I.shiftKey&&I.key==="z")&&!T){I.preventDefault(),a.length>0&&(r(),n("Redo"));return}if(!Hf(B)){if(R&&I.key==="d"){!T&&c&&d&&u&&p&&(I.preventDefault(),f(p,u,d,c),n("Button duplicated"));return}if(R&&I.key.toLowerCase()==="x"){if(!T&&c&&d&&u&&p){I.preventDefault();const H=x[p].tabs.find(k=>k.id===u)?.groups.find(k=>k.id===d);if(H&&Wn(H,c)){n("Menu items can't be cut. Delete the item and add a new one to the other menu.");return}w.current={location:p,tabId:u,groupId:d,buttonId:c},n("Button cut. Focus a destination group, then press paste.")}return}if(R&&I.key.toLowerCase()==="v"){const H=w.current;if(!T&&H&&d&&u&&p){I.preventDefault();const k=v({groupId:H.groupId,buttonId:H.buttonId,tabId:H.tabId,location:H.location},{groupId:d,tabId:u,location:p});if(w.current=null,!k){n("The button couldn't be moved there.");return}requestAnimationFrame(()=>{y(p,u,d,k),document.querySelector(`[data-ribbon-btn-id="${k}"]`)?.focus()}),n(k===H.buttonId?"Button pasted to destination group.":"Pasted your copy of the button to the destination group; the original is hidden.")}return}if((I.key==="Delete"||I.key==="Backspace")&&c&&d&&u&&p&&!T){const H=x[p].tabs.find(V=>V.id===u),k=H?.groups.find(V=>V.id===d),P=Yt(k,c);if(!P)return;if(I.preventDefault(),!In(P,g[p])){p==="Application"&&u==="Mscrm.GlobalTab"&&P.oob&&!P.custom?n(`"${P.label}" is read-only and can't be deleted.`):P.hidden?n(`"${P.label}" can't be deleted — only your own buttons can. It is already hidden.`):o({location:p,tabId:u,groupId:d,buttonId:c});return}const j=k?Wn(k,c):void 0,E=j?j.section.controls.map(V=>({groupId:d,buttonId:V.id})):H?.groups.flatMap(V=>V.buttons.map(ee=>({groupId:V.id,buttonId:ee.id})))??[],N=E.findIndex(V=>V.buttonId===c),W=E[N+1]??E[N-1]??(j?{groupId:d,buttonId:j.parent.id}:null),U=d;S(p,u,d,c),requestAnimationFrame(()=>{if(W){y(p,u,W.groupId,W.buttonId),document.querySelector(`[data-ribbon-btn-id="${W.buttonId}"]`)?.focus();return}U&&(C(U),document.querySelector(`[data-add-btn-group-id="${U}"]`)?.focus())}),n("Button deleted")}}};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[e,t,n,o,i,r,l.length,a.length,c,d,u,p,f,S,v,x,g,y,C])}const Wf=le({handleV:{width:"4px",cursor:"col-resize",backgroundColor:"transparent",flexShrink:0,":hover":{backgroundColor:m.colorNeutralStroke2},":active":{backgroundColor:m.colorBrandStroke1},userSelect:"none"},handleH:{height:"4px",cursor:"row-resize",backgroundColor:"transparent",flexShrink:0,":hover":{backgroundColor:m.colorNeutralStroke2},":active":{backgroundColor:m.colorBrandStroke1},userSelect:"none"}});function zo({direction:e,onResize:t,"aria-label":n=`Resize ${e} pane`}){const o=Wf(),i=M.useRef(0),r=M.useCallback(a=>{a.currentTarget.setPointerCapture(a.pointerId),i.current=e==="vertical"?a.clientX:a.clientY},[e]),l=M.useCallback(a=>{if(!a.currentTarget.hasPointerCapture(a.pointerId))return;const c=e==="vertical"?a.clientX:a.clientY,d=c-i.current;i.current=c,t(d)},[e,t]);return s.jsx("div",{className:e==="vertical"?o.handleV:o.handleH,role:"separator","aria-orientation":e==="vertical"?"vertical":"horizontal","aria-label":n,onPointerDown:r,onPointerMove:l})}class kt extends Ue.Component{state={hasError:!1,error:null};static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("[CBS ErrorBoundary]",this.props.label??"panel",t,n)}handleRetry=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError?this.props.fallback?this.props.fallback:s.jsxs(Ie,{intent:"error",style:{margin:8},children:[s.jsxs(Re,{children:[s.jsx("strong",{children:this.props.label??"Panel"})," encountered an error:"," ",this.state.error?.message??"Unknown error"]}),s.jsx(Fn,{children:s.jsx(K,{size:"small",onClick:this.handleRetry,children:"Retry"})})]}):this.props.children}}const Uf=M.lazy(()=>Ne(()=>import("./XmlDrawer-lnZmbePV.js"),__vite__mapDeps([0,1,2,3,4,5,6,7]),import.meta.url)),Xf=M.lazy(()=>Ne(()=>import("./CommandEditorPanel-_mV9SqAb.js"),__vite__mapDeps([8,1,2,3,9,10,6,5,4,7]),import.meta.url)),Vf=M.lazy(()=>Ne(()=>import("./RuleEditorPanel-BmI_wJKH.js"),__vite__mapDeps([11,1,2,3,12,6,9,10,7]),import.meta.url)),Jf=M.lazy(()=>Ne(()=>import("./BulkPublishModal-mFfxdo1T.js"),__vite__mapDeps([13,1,2,3,14,12,10,4,6,7]),import.meta.url)),Kf=M.lazy(()=>Ne(()=>import("./NewButtonModal-D3iJDvUq.js"),__vite__mapDeps([15,1,2,3,6,7]),import.meta.url)),Yf=M.lazy(()=>Ne(()=>import("./NewGroupModal-Cfywgyga.js"),__vite__mapDeps([16,1,2,3,6,7]),import.meta.url)),Zf=M.lazy(()=>Ne(()=>import("./NewTabModal-DGNwUnJ5.js"),__vite__mapDeps([17,1,2,3,6,7]),import.meta.url)),Qf=M.lazy(()=>Ne(()=>import("./ImportXmlModal-BYj1QmDX.js"),__vite__mapDeps([18,1,2,3,14,12,10,5,6,7]),import.meta.url)),eh=M.lazy(()=>Ne(()=>import("./CommandPalette-CK3uU6Ky.js"),__vite__mapDeps([19,1,2,3,6,7]),import.meta.url)),th=M.lazy(()=>Ne(()=>import("./LocalizationEditor-SeIMV_0G.js"),__vite__mapDeps([20,1,2,3,6,7]),import.meta.url)),nh=M.lazy(()=>Ne(()=>import("./IconPickerModal-BF3KU0Ux.js"),__vite__mapDeps([21,1,2,3,4,6,7]),import.meta.url)),oh=M.lazy(()=>Ne(()=>import("./TabDisplayRulesPanel-D26HGtKC.js"),__vite__mapDeps([22,1,2,3,6,7]),import.meta.url)),ih=M.lazy(()=>Ne(()=>import("./ScalingEditorPanel-VCqXvcQy.js"),__vite__mapDeps([23,1,2,3,6,7]),import.meta.url)),sh=M.lazy(()=>Ne(()=>import("./ConflictDrawer-BFlon1xn.js"),__vite__mapDeps([24,1,2,3,6,7]),import.meta.url)),rh=M.lazy(()=>Ne(()=>import("./WebResourceBrowser-Hrw1yujP.js"),__vite__mapDeps([25,1,2,3,4,6,7]),import.meta.url)),ah=M.lazy(()=>Ne(()=>import("./UrlComposerModal-gVBqcCZd.js"),__vite__mapDeps([26,1,2,3,6,7]),import.meta.url)),lh=M.lazy(()=>Ne(()=>import("./DiffViewer-JSOMstAl.js"),__vite__mapDeps([27,2,3,1,6,7]),import.meta.url)),ch=M.lazy(()=>Ne(()=>import("./HideInsteadOfDeleteModal-DYsP_BRs.js"),__vite__mapDeps([28,1,2,3,6,7]),import.meta.url)),dh=le({root:{display:"flex",flexDirection:"column",height:"100vh",overflow:"hidden",backgroundColor:m.colorNeutralBackground1,color:m.colorNeutralForeground1,fontFamily:m.fontFamilyBase},body:{display:"flex",flex:1,overflow:"hidden",position:"relative"},leftPane:{flexShrink:0,overflow:"hidden",borderRight:`1px solid ${m.colorNeutralStroke2}`},rightPane:{flexShrink:0,overflow:"hidden",borderLeft:`1px solid ${m.colorNeutralStroke2}`},bottomPanel:{flexShrink:0}});function uh({children:e,leftPane:t,rightPane:n,bottomPanel:o}){const i=dh(),r=Y(h=>h.leftPaneWidth),l=Y(h=>h.rightPaneWidth),a=Y(h=>h.rightPaneMode),c=Y(h=>h.setLeftPaneWidth),d=Y(h=>h.setRightPaneWidth),u=Y(h=>h.bottomPanelHeight),p=Y(h=>h.bottomCollapsed),f=Y(h=>h.setBottomPanelHeight),S=Y(h=>h.announcement),v=Y(h=>h.xmlDrawerOpen||h.commandEditorOpen||h.ruleEditorOpen||h.bulkPublishOpen||h.newButtonGroupId!==null||h.newGroupOpen||h.newTabOpen||h.importXmlOpen||h.commandPaletteOpen||h.localizationEditorOpen||h.iconPickerOpen||h.tabDisplayRulesOpen||h.scalingEditorOpen||h.conflictDrawerOpen||h.webResourceBrowserOpen||h.urlComposerOpen||h.diffViewerOpen||h.hideInsteadOfDelete!==null),x=M.useRef(null),g=M.useRef(!1);Gf(),M.useEffect(()=>{if(v&&!g.current){const h=document.activeElement;x.current=h instanceof HTMLElement?h:null}if(!v&&g.current){const h=x.current;requestAnimationFrame(()=>{!h||!h.isConnected||h.focus()})}g.current=v},[v]);const y=M.useCallback(h=>{c(Math.max(160,Math.min(500,r+h)))},[r,c]),C=M.useCallback(h=>{d(Math.max(200,Math.min(600,l-h)))},[l,d]),w=M.useCallback(h=>{const I=u-h;f(Math.max(120,Math.min(520,I)))},[u,f]);return s.jsxs("div",{className:i.root,children:[s.jsx(Mf,{}),s.jsx(Pf,{}),s.jsxs("div",{className:i.body,children:[s.jsx("div",{className:i.leftPane,style:{width:r},children:s.jsx(kt,{label:"Left pane",children:t})}),s.jsx(zo,{direction:"vertical",onResize:y,"aria-label":"Resize left pane"}),s.jsx(kt,{label:"Ribbon canvas",children:e}),a==="docked"&&s.jsxs(s.Fragment,{children:[s.jsx(zo,{direction:"vertical",onResize:C,"aria-label":"Resize right pane"}),s.jsx("div",{className:i.rightPane,style:{width:l},children:s.jsx(kt,{label:"Properties pane",children:n})})]}),a==="floating"&&s.jsx("div",{style:{position:"absolute",right:8,top:8,bottom:8,width:l,maxWidth:"90vw",border:`1px solid ${m.colorNeutralStroke2}`,backgroundColor:m.colorNeutralBackground1,boxShadow:m.shadow16,borderRadius:m.borderRadiusMedium,overflow:"hidden",zIndex:10},children:s.jsx(kt,{label:"Properties pane",children:n})})]}),!p&&s.jsx(zo,{direction:"horizontal",onResize:w,"aria-label":"Resize bottom panel"}),s.jsx("div",{className:i.bottomPanel,children:s.jsx(kt,{label:"Bottom panel",children:o})}),s.jsx(kt,{label:"Panels",children:s.jsxs(M.Suspense,{fallback:null,children:[s.jsx(Uf,{}),s.jsx(Xf,{}),s.jsx(Vf,{}),s.jsx(Jf,{}),s.jsx(Kf,{}),s.jsx(Yf,{}),s.jsx(Zf,{}),s.jsx(Qf,{}),s.jsx(eh,{}),s.jsx(th,{}),s.jsx(nh,{}),s.jsx(oh,{}),s.jsx(ih,{}),s.jsx(sh,{}),s.jsx(rh,{}),s.jsx(ah,{}),s.jsx(lh,{}),s.jsx(ch,{})]})}),s.jsx("div",{role:"status","aria-live":"polite","aria-atomic":"true",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",left:-9999,top:"auto"},children:S})]})}const Na="Unified Interface has no visible tabs: this tab's buttons appear in the table's command bar (or its overflow menu) wherever the tab's display rule applies.",sn=(e,t)=>JSON.stringify(e)===JSON.stringify(t),mh=e=>[e.icon,e.image16,e.image32].some(t=>!!t&&t.startsWith("$webresource:")),ph=e=>!!e.source&&Ni(e)===e.source.modernImage&&(e.source.modernImage!==void 0||!e.icon),fh=/^\$LocLabels:(.+)$/,mt=e=>e?fh.exec(e)?.[1]??null:null,hh=/^\s*<(EnableRule|DisplayRule)\b[^>]*?\sId="([^"]+)"/,rn=e=>new Set(e??[]);function gh(e){const t=[];for(const n of Object.values(e.source?.attributes??{})){const o=mt(n);o&&t.push(o)}for(const n of e.source?.xml?.matchAll(/\$LocLabels:([^"'\s<]+)/g)??[])t.includes(n[1])||t.push(n[1]);return t}function ws(e){return(e.menu?.sections??[]).map(t=>({id:t.id,title:t.title??"",sequence:t.sequence,displayMode:t.displayMode??"",controlsId:t.controlsId}))}function Ey(e){const t=[],n=[],o=[],i=[],r=[],l=[],a=[],c=[],d=new Map,u=(_,L)=>{const O=mt(_);O&&d.set(O,new Set([...d.get(O)??[],L]))};for(const{baseline:_}of e.locations)for(const L of _.tabs){u(L.label,L.id);for(const O of L.groups){u(O.label,O.id);for(const F of je(O))for(const b of Object.values(F.source?.attributes??{}))u(b,F.id)}}const p=new Set([...(e.locLabels??[]).map(_=>_.id),...rn(e.layer?.locLabelIds)]);let f=!1;const S=new Set,v=rn(e.layer?.containerIds),x=rn(e.layer?.locLabelIds),g=new Set,y=new Set,C=new Map,w=new Map,h=[],I=new Set(e.locations.flatMap(({current:_})=>Array.from(St(_).values(),L=>L.button.id))),$=(_,L,O,F)=>{const b=mt(O);if(v.has(L)&&b&&x.has(b)&&!mt(F)&&F.trim())if([...d.get(b)??[]].some(A=>A!==L)){let A=`${L}.Title`;for(let X=2;A===b||p.has(A);X++)A=`${L}.Title${X}`;p.add(A),c.push({id:A,text:F,containerId:L,newLabel:!0})}else c.push({id:b,text:F,containerId:L});else t.push(`Renaming ${_} ${L} — only tabs and groups your unmanaged customizations add (with a translatable title) can be renamed`)};for(const{current:_,baseline:L}of e.locations){const O=ep(_,L);O.newButtons+O.overriddenButtons+O.hiddenButtons+O.newTabs+O.newGroups>0&&(f=!0),O.scalingChanges>0&&t.push(`Scaling changes on ${_.location} (not supported yet)`);const F=Wr(_,L);t.push(...F.problems);const b=rn(e.layer?.scalingStepIds);for(const[z,G]of Object.entries(L.scalingByTab??{})){const te=_.tabs.find(ne=>ne.id===z),Q=[...G.maxSizes.filter(ne=>b.has(ne.id)).map(ne=>({...ne,kind:"MaxSize"})),...G.scales.filter(ne=>b.has(ne.id)).map(ne=>({...ne,kind:"Scale"})),...(te?.groups??[]).map(ne=>F.steps.get(ne.id)).filter(ne=>!!ne).map(ne=>({...ne,kind:"MaxSize"}))];if(Q.length===0)continue;const we=Tr(z,{maxSizes:G.maxSizes.filter(ne=>!b.has(ne.id)).map(ne=>ne.sequence),scales:G.scales.filter(ne=>!b.has(ne.id)).map(ne=>ne.sequence)},Q);n.push(...we.changes.map(Tm)),t.push(...we.problems)}const A=St(_),X=St(L);for(const{button:z}of A.values())for(const G of jr(z))S.add(G);for(const[z,{button:G}]of A){const te=gh(G);te.forEach(ne=>g.add(ne));const Q=X.get(z)?.button,we=!Q||Jo(Q,G);for(const ne of[so(G.id),ro(G.id),ao(G.id)])we?y.add(ne):te.includes(ne)||C.set(ne,G);we&&te.forEach(ne=>y.add(ne))}for(const[z,G]of X){const te=G.button.id,Q=A.get(z);if(!Q){if(G.menu&&I.has(te)&&I.has(G.menu.parentId)&&G.button.origin!=="unmanaged"){t.push(`Moving the menu of ${G.menu.parentId} to another location — its item "${G.button.label}" (${te}) comes from another solution and can't be moved with it; move the flyout back`);continue}if(Ze(G.button.kind)&&I.has(te)&&/<Menu[\s>/]/.test(G.button.source?.xml??"")){t.push(`Moving the <${pn[G.button.kind]}> "${G.button.label}" (${te}) to another location — its menu may hold items of other solutions; move it within its location instead`);continue}xt(G.button)?o.push(te):t.push(`Removing "${G.button.label}" (${te}) — only your own unmanaged buttons can be deleted; hide it instead`);continue}G.button.hidden&&!Q.button.hidden&&i.push(te),(Q.button.kind??"button")!==(G.button.kind??"button")&&t.push(`Changing the kind of "${Q.button.label}" (${te}) — not supported yet`);const we=Jo(G.button,Q.button);we&&Ze(Q.button.kind)&&t.push(`Editing the <${pn[Q.button.kind]}> "${Q.button.label}" (${te}) — CBS shows it read-only; it can be hidden, or moved and deleted when it's your own`),we&&(Ot(Q.button.kind)||Q.button.menu)&&G.button.origin!=="unmanaged"&&t.push(`Editing the flyout / split button "${Q.button.label}" (${te}) itself — only your own can be edited; its menu items can be edited, hidden or added to`),sn(ws(G.button),ws(Q.button))||t.push(`Adding, removing or changing menu sections of "${Q.button.label}" (${te}) — not supported yet for an existing menu; add, edit or remove its items instead`),(Q.button.icon??"")!==(G.button.icon??"")&&!mh(Q.button)&&!ph(Q.button)&&t.push(`Changing the icon of "${Q.button.label}" (${te}) to a built-in icon — not supported yet; choose an SVG web resource`),((Q.menu||G.menu?Q.menu?.controlsId!==G.menu?.controlsId:Q.groupId!==G.groupId)||Q.button.sequence!==G.button.sequence)&&(G.button.origin==="unmanaged"?l.push({id:te,groupId:Q.groupId,sequence:Q.button.sequence,...Q.menu?{controlsId:Q.menu.controlsId}:{}}):t.push(`Moving or re-ordering "${Q.button.label}" (${te}) — only your own unmanaged buttons, and copies made with "Customise button", can be moved; undo the move, then hide it and add a new button instead`))}for(const[z,G]of A){if(X.has(z))continue;w.has(G.button.id)||w.set(G.button.id,{groupId:G.groupId,sequence:G.button.sequence,...G.menu?{controlsId:G.menu.controlsId}:{}});const te=G.button.source?.attributes.PopulateDynamically?.toLowerCase()==="true";Ot(G.button.kind)&&!te&&!vt(G.button).some(Q=>!Q.hidden)&&h.push({id:G.button.id,label:G.button.label})}const re=new Map(L.tabs.flatMap(z=>z.groups.map(G=>[G.id,G]))),me=new Map(L.tabs.map(z=>[z.id,z])),Ee=new Set(_.tabs.map(z=>z.id)),Ce=new Set(_.tabs.flatMap(z=>z.groups.map(G=>G.id)));for(const z of _.tabs){const G=mt(z.label);G&&g.add(G);const te=me.get(z.id);if(!te){y.add(`${z.id}.Title`);const Q=mt(z.source?.titleToken);Q&&y.add(Q),z.commandId&&S.add(z.commandId),_.location==="Application"&&(z.tabDisplayRules??[]).length===0&&t.push(`New tab ${z.id} has no tab display rule, so it would never be shown — add one in Tab rules`),n.push(`New tab "${z.label}" (${z.id}): ${Na}`)}te&&te.label!==z.label&&$("tab",z.id,te.label,z.label),te&&!sn(te.tabDisplayRules??[],z.tabDisplayRules??[])&&(v.has(z.id)?z.commandId?a.push(z.id):t.push(`Changing the display rules of tab ${z.id} — the tab has no Command to attach them to`):t.push(`Changing the display rules of tab ${z.id} — only tabs your unmanaged customizations add can be changed`));for(const Q of z.groups){const we=mt(Q.label);we&&g.add(we);const ne=re.get(Q.id);if(!ne){y.add(`${Q.id}.Title`);const Nt=mt(Q.source?.titleToken);Nt&&y.add(Nt)}ne&&ne.template!==Q.template&&t.push(`Re-templating group ${Q.id} — not supported yet`),ne&&ne.label!==Q.label&&$("group",Q.id,ne.label,Q.label)}}const He=(z,G)=>t.push(`Removing ${z} ${G} — only tabs and groups your unmanaged customizations add can be deleted; hide it instead`);for(const z of L.tabs){if(!Ee.has(z.id)){v.has(z.id)?r.push(z.id):He("tab",z.id);continue}for(const G of z.groups)Ce.has(G.id)||(v.has(G.id)?r.push(G.id):He("group",G.id))}}for(let _=o.length-1;_>=0;_--){const L=w.get(o[_]);L&&(l.push({id:o[_],...L}),o.splice(_,1))}for(const _ of e.deletedOrphans??[]){for(const L of _.deleteControlIds)o.includes(L)||o.push(L);for(const L of _.deleteContainerIds)r.includes(L)||r.push(L)}for(const _ of h)l.some(L=>L.id===_.id)||t.push(`New flyout / split button "${_.label}" has no menu items — add at least one item to its menu`);const R=e.layer?.commandIds?rn(e.layer.commandIds):null,B=new Set(e.uncustomisedCommandIds??[]),T=[...B].filter(_=>R?R.has(_):S.has(_)&&!e.excludeCommandIds?.has(_));for(const _ of T)e.layer?.commandRefIds&&!Ci(_,e.layer.commandRefIds)&&t.push(`Uncustomising ${_} — it is your own command (your customizations' buttons use it and no other solution defines it); undo the uncustomise`);T.includes(Be)&&S.has(Be)&&t.push(`Uncustomising ${Be} — its "Open record" buttons still use it; undo the uncustomise and turn the record open override off in the Advanced section instead`);for(const _ of e.excludeCommandIds??[])S.delete(_);const H=new Set(e.customisedCommandIds??[]),k=new Map(e.baselineCommands.map(_=>[_.id,_])),P=e.commands.filter(_=>S.has(_.id)&&!B.has(_.id)&&(!k.has(_.id)||!sn(k.get(_.id),_)||H.has(_.id)&&!R?.has(_.id))).map(_=>_.id);for(const _ of e.commands){if(!P.includes(_.id))continue;_.actions.some(O=>O.kind==="powerFx"||O.kind==="customApi")&&t.push(`Power Fx / Custom API action in command ${_.id} — classic ribbon commands can't run these; remove the action (#28)`);const L=_.id===Be?Wp(_):null;L&&t.push(L)}const j=new Set,E=new Set;for(const _ of e.commands)if(!(!S.has(_.id)||B.has(_.id))){_.enableRules.forEach(L=>j.add(L)),_.displayRules.forEach(L=>E.add(L));for(const L of _.rawRuleRefs??[]){const O=hh.exec(L.xml);O&&(O[1]==="EnableRule"?j:E).add(O[2])}}const N=(_,L,O)=>{const F=new Map(L.map(b=>[b.id,b]));return _.filter(b=>O.has(b.id)&&(!F.has(b.id)||!sn(F.get(b.id),b))).map(b=>b.id)},W=N(e.enableRules,e.baselineEnableRules,j),U=N(e.displayRules,e.baselineDisplayRules,E),V=[];if(e.locLabels&&e.baselineLocLabels){const _=new Map(e.baselineLocLabels.map(L=>[L.id,L]));for(const L of e.locLabels){const O=_.get(L.id);if(O&&sn(O,L)||y.has(L.id))continue;if(g.has(L.id)){x.has(L.id)?V.push(L.id):t.push(`Translations of label ${L.id} — it is defined by another solution; change the text in the properties pane instead`);continue}const F=C.get(L.id);F&&t.push(`Translations for "${F.label}" (${F.id}) — its text isn't a translatable label yet; change the text in the properties pane first, then add translations`)}}const ee=(e.unhiddenLayerHideIds??[]).filter(_=>!i.includes(_));return{hasChanges:f||P.length>0||T.length>0||W.length>0||U.length>0||o.length>0||i.length>0||ee.length>0||r.length>0||l.length>0||V.length>0||a.length>0||c.length>0,editedCommandIds:P,uncustomisedCommandIds:T,editedEnableRuleIds:W,editedDisplayRuleIds:U,deletedButtonIds:o,unhiddenButtonIds:[...i,...ee],deletedContainerIds:r,movedButtons:l,editedLocLabelIds:V,editedTabIds:a,renamedLabels:c,unsupported:[...new Set(t)],warnings:[...new Set(n)]}}const bh=["HomepageGrid","SubGrid","Form"];function yh(e,t){const n=new Map;for(const v of Object.values(t.baseline))for(const x of v.tabs)for(const g of x.groups)for(const y of g.buttons)n.set(y.id,y.origin);let o=!1,i=!1,r=Qo(e);for(const[v,x]of Object.entries(t.ribbons))for(const g of x.tabs)for(const y of g.groups)for(const C of y.buttons)C.commandId===e&&(bh.includes(v)?o=!0:i=!0,n.has(C.id)&&n.get(C.id)!=="unmanaged"&&(r=!0));const l=o||!i?"entity":"application",a=o&&i,c=t.layers[l],d=c?.commandIds?c.commandIds.includes(e):void 0,u=t.baselineCommands.find(v=>v.id===e),p=(v,x=l)=>({provenance:v,scope:x,sharedWithApplication:a});if(t.reloadRequiredCommandIds.includes(e))return p("reloadRequired");for(const v of["entity","application"])if(t.uncustomisedCommandIds[v].includes(e))return p("uncustomising",v);if(!u||!r&&d!==!1)return p("custom");if(d){const v=c?.commandRefIds?Ci(e,c.commandRefIds):Qo(e);return p(v?"customised":"custom")}const f=t.commands.find(v=>v.id===e),S=!!f&&JSON.stringify(f)!==JSON.stringify(u);return t.customisedCommandIds.includes(e)||S?p("customising"):p("oob")}const xh={oob:"Out of the box",customising:"Customised (unpublished)",customised:"Customised in your layer",uncustomising:"Uncustomised (unpublished)",custom:"Custom",reloadRequired:"Uncustomised — reload the table"};function $a(e){const t=D(d=>d.commands),n=D(d=>d.baselineCommands),o=D(d=>d.ribbons),i=D(d=>d.baseline),r=D(d=>d.layers),l=D(d=>d.customisedCommandIds),a=D(d=>d.uncustomisedCommandIds),c=D(d=>d.reloadRequiredCommandIds);return Ue.useMemo(()=>e&&t.some(d=>d.id===e)?yh(e,{commands:t,baselineCommands:n,ribbons:o,baseline:i,layers:r,customisedCommandIds:l,uncustomisedCommandIds:a,reloadRequiredCommandIds:c}):null,[e,t,n,o,i,r,l,a,c])}function My(e){return e?.provenance==="uncustomising"||e?.provenance==="reloadRequired"}function Ta({location:e,tabId:t,groupId:n,button:o,onDone:i}){const r=D(f=>f.customiseButton),l=D(f=>f.customiseCommand),a=ie(f=>f.activeSolution),c=ie(f=>f.publisherPrefix),d=Z(f=>f.selectButtonInContext),u=Y(f=>f.openCommandEditor),p=$a(o.commandId||void 0);return s.jsxs(s.Fragment,{children:[o.origin!=="unmanaged"&&s.jsx(pe,{icon:s.jsx(xl,{}),disabled:!Bi(e,t,o),onClick:()=>{const f=a?.publisherPrefix?.trim()||c?.trim()||"new",S=r(e,t,n,o.id,f);S&&d(e,t,n,S),i()},children:"Customise button (copy, hide original)"}),p?.provenance==="oob"&&s.jsx(pe,{icon:s.jsx(Ht,{}),onClick:()=>{l(o.commandId)&&u(o.commandId),i()},children:"Customise command"})]})}function ka(e,t,n,o,i){const r=e.groups.filter(a=>a.id!==t&&!(n&&a.buttons.some(c=>c.id===n))).map(a=>({groupId:a.id,text:ce(a.label,o,i).trim()||a.id})),l=new Map;for(const a of r)l.set(a.text,(l.get(a.text)??0)+1);return r.map(a=>(l.get(a.text)??0)>1&&a.text!==a.groupId?{...a,text:`${a.text} (${a.groupId})`}:a)}const Pi=({open:e,buttonLabel:t,commandId:n,deleteBlockedReason:o,onConfirmHide:i,onConfirmDisplayRule:r,onCancel:l})=>s.jsx(Gt,{open:e,onOpenChange:()=>l(),children:s.jsxs(Wt,{style:{maxWidth:"560px"},children:[s.jsxs(Ut,{children:[s.jsx(rr,{style:{marginRight:"8px",color:"var(--colorStatusWarningForeground1)"}}),o?`Can't delete "${t}"`:`Hide "${t}"`]}),s.jsxs(Xt,{children:[s.jsxs(Vt,{children:[o&&s.jsxs(q,{style:{display:"block",marginBottom:"12px"},children:[o," Only buttons your solution adds can be deleted — you can hide this one instead."]}),s.jsx(Ie,{intent:"warning",children:s.jsxs(Re,{children:[s.jsx(q,{weight:"semibold",children:"A HideCustomAction removes the button from the ribbon."})," ","To show it again, use Unhide under “Hidden by customizations” in the Properties pane; in a managed solution a hide can't be undone with a patch."]})}),s.jsxs(q,{style:{display:"block",marginTop:"12px"},children:["The reversible alternative adds the display rules ",s.jsx("code",{children:"Mscrm.HideOnModern"})," +"," ",s.jsx("code",{children:"Mscrm.ShowOnlyOnModern"})," (never both true) to the button's command",n?s.jsxs(s.Fragment,{children:[" ",s.jsx("code",{children:n}),". Every button that uses this command is hidden too."]}):s.jsx(s.Fragment,{children:". This button has no command, so only the HideCustomAction is available."})]})]}),s.jsxs(Jt,{children:[s.jsx(K,{appearance:"secondary",onClick:l,children:"Cancel"}),s.jsx(K,{appearance:"secondary",onClick:r,disabled:!n,children:"Use display rules (reversible)"}),s.jsx(K,{appearance:"primary",onClick:i,children:"Use HideCustomAction (permanent)"})]})]})]})}),Sh=({open:e,initialLabel:t,onRename:n,onCancel:o})=>{const[i,r]=M.useState(t),l=i.trim(),a=()=>{l&&(l===t.trim()?o():n(l))};return s.jsx(Gt,{open:e,onOpenChange:(c,d)=>!d.open&&o(),children:s.jsx(Wt,{style:{maxWidth:"440px"},children:s.jsxs(Xt,{children:[s.jsx(Ut,{children:"Rename group"}),s.jsx(Vt,{children:s.jsx(De,{label:"Group title",required:!0,validationState:l?"none":"error",validationMessage:l?void 0:"Enter a title for the group.",children:s.jsx(_e,{value:i,onChange:(c,d)=>r(d.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),a())},autoFocus:!0})})}),s.jsxs(Jt,{children:[s.jsx(K,{appearance:"secondary",onClick:o,children:"Cancel"}),s.jsx(K,{appearance:"primary",onClick:a,disabled:!l,children:"Rename"})]})]})})})},vh=e=>e.replace(/^Mscrm\.Templates\./,""),Ch=({open:e,currentTemplate:t,customTemplateIds:n=[],loadedGroup:o=!1,onChange:i,onCancel:r})=>{const l=Ri(t),[a,c]=M.useState(l),d=[...new Set([...np,...n,l])],u=()=>{a===l?r():i(a)};return s.jsx(Gt,{open:e,onOpenChange:(p,f)=>!f.open&&r(),children:s.jsx(Wt,{style:{maxWidth:"480px"},children:s.jsxs(Xt,{children:[s.jsx(Ut,{children:"Change group template"}),s.jsxs(Vt,{children:[s.jsx(De,{label:"Group template",children:s.jsx(dt,{value:a,onChange:(p,f)=>c(f.value),children:d.map(p=>s.jsxs("option",{value:p,children:[vh(p),p===l?" (current)":""]},p))})}),s.jsx(q,{size:200,style:{display:"block",marginTop:"8px"},children:"The group template defines how buttons scale when the ribbon is resized."}),o&&s.jsx(Ie,{intent:"warning",style:{marginTop:"12px"},children:s.jsx(Re,{children:"This group was loaded from the environment. Publishing can't change an existing group's template yet (it's reported as not supported); groups you add publish theirs."})})]}),s.jsxs(Jt,{children:[s.jsx(K,{appearance:"secondary",onClick:r,children:"Cancel"}),s.jsx(K,{appearance:"primary",onClick:u,disabled:a===l,children:"Change template"})]})]})})})},wh=le({destructive:{backgroundColor:m.colorStatusDangerBackground3,color:m.colorNeutralForegroundOnBrand,":hover":{backgroundColor:m.colorStatusDangerBackground3Hover,color:m.colorNeutralForegroundOnBrand},":hover:active":{backgroundColor:m.colorStatusDangerBackground3Pressed,color:m.colorNeutralForegroundOnBrand}}}),Fi=({open:e,title:t,children:n,confirmLabel:o,cancelLabel:i="Cancel",destructive:r=!1,onConfirm:l,onCancel:a})=>{const c=wh();return s.jsx(Gt,{modalType:"alert",open:e,onOpenChange:(d,u)=>!u.open&&a(),children:s.jsx(Wt,{style:{maxWidth:"480px"},children:s.jsxs(Xt,{children:[s.jsx(Ut,{children:t}),s.jsx(Vt,{children:n}),s.jsxs(Jt,{children:[s.jsx(K,{appearance:"secondary",onClick:a,children:i}),s.jsx(K,{appearance:"primary",className:r?c.destructive:void 0,onClick:l,children:o})]})]})})})};function Aa(e){const o=({columns:"layout_column_two",history:"clock_arrow_counterclockwise",window_dev_tools:"code_block"}[e.trim().toLowerCase()]??e).trim().replace(/_\d+_(regular|filled)$/i,"").replace(/_?(regular|filled)$/i,"").replace(/\d+(Regular|Filled)$/i,"").replace(/(Regular|Filled)$/i,"");return o?o.includes("_")?o.toLowerCase():o.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").toLowerCase():"apps_add_in"}const Da={add:{regular:Te,filled:du},delete:{regular:Lt,filled:cu},edit:{regular:no,filled:lu},save:{regular:ir,filled:au},copy:{regular:mn,filled:ru},cut:{regular:su,filled:iu},clipboardpaste:{regular:ou,filled:nu},share:{regular:tu,filled:eu},mail:{regular:Qd,filled:Zd},chat:{regular:Yd,filled:Kd},phone:{regular:Jd,filled:Vd},search:{regular:ft,filled:Xd},filter:{regular:Ud,filled:Wd},arrowleft:{regular:Gd,filled:Hd},arrowright:{regular:qd,filled:_d},arrowup:{regular:Fd,filled:Pd},arrowdown:{regular:Ld,filled:Md},chevrondown:{regular:gt,filled:Ed},chevronup:{regular:ur,filled:Od},navigation:{regular:Bd,filled:zd},home:{regular:Dd,filled:Ad},settings:{regular:nr,filled:kd},info:{regular:Td,filled:$d},warning:{regular:rr,filled:Nd},checkmark:{regular:jd,filled:Rd},dismiss:{regular:bi,filled:Id},questioncircle:{regular:or,filled:wd},lockclosed:{regular:wt,filled:Cd},lockopen:{regular:vd,filled:Sd},shield:{regular:xd,filled:yd},person:{regular:dr,filled:bd},people:{regular:gd,filled:hd},personadd:{regular:fd,filled:pd},building:{regular:md,filled:ud},briefcase:{regular:dd,filled:cd},money:{regular:ld,filled:ad},creditcard:{regular:rd,filled:sd},cart:{regular:id,filled:od},tag:{regular:nd,filled:td},document:{regular:to,filled:ed},documentbulletlist:{regular:Qc,filled:Zc},folder:{regular:Yc,filled:Kc},folderopen:{regular:Jc,filled:Vc},attach:{regular:Xc,filled:Uc},arrowdownload:{regular:Wc,filled:Gc},arrowupload:{regular:Hc,filled:qc},globe:{regular:cr,filled:_c},link:{regular:Fc,filled:Pc},open:{regular:Lc,filled:Mc},calendar:{regular:Ec,filled:Oc},clock:{regular:Bc,filled:zc},timer:{regular:Dc,filled:Ac},star:{regular:kc,filled:Tc},heart:{regular:$c,filled:Nc},thumblike:{regular:jc,filled:Rc},thumbdislike:{regular:Ic,filled:wc},eye:{regular:Ct,filled:Cc},eyeoff:{regular:Ye,filled:vc},zoomin:{regular:Sc,filled:xc},zoomout:{regular:yc,filled:bc},maximize:{regular:gc,filled:hc},minimize:{regular:fc,filled:pc},grid:{regular:mc,filled:uc},list:{regular:dc,filled:cc},table:{regular:lr,filled:lc},tablesimple:{regular:ac,filled:rc},code:{regular:Ht,filled:sc},bug:{regular:ic,filled:oc},play:{regular:nc,filled:tc},pause:{regular:ec,filled:Ql},stop:{regular:Zl,filled:Yl},refresh:{regular:Kl,filled:Jl},arrowsync:{regular:Vl,filled:Xl},arrowundo:{regular:Qs,filled:Ul},arrowredo:{regular:er,filled:Wl},printer:{regular:Gl,filled:Hl},send:{regular:ql,filled:_l},rocket:{regular:Fl,filled:Pl},sparkle:{regular:Ll,filled:Ml},trophy:{regular:El,filled:Ol},lightbulb:{regular:Bl,filled:zl},bot:{regular:Dl,filled:Al},databar:{regular:kl,filled:Tl},chartmultiple:{regular:$l,filled:Nl},poll:{regular:jl,filled:Rl},layoutcolumntwo:{regular:Il,filled:wl},codeblock:{regular:Cl,filled:vl},clockarrowcounterclockwise:{regular:ar,filled:Sl}},jt=({name:e,size:t=20,variant:n="regular",style:o,className:i,"aria-hidden":r=!0})=>{const l=Aa(e).replace(/_/g,""),a=Da[l],c=n==="filled"?a?.filled??a?.regular??Pt:a?.regular??Pt;return s.jsx(c,{fontSize:t,"aria-hidden":r,className:i,style:{display:"inline-block",verticalAlign:"middle",flexShrink:0,color:m.colorNeutralForeground1,...o}})};async function Ly(e,t=32,n="regular"){const o=Aa(e).replace(/_/g,""),i=Da[o],r=n==="filled"?i?.filled??i?.regular:i?.regular;if(!r)return null;const{renderToStaticMarkup:l}=await Ne(async()=>{const{renderToStaticMarkup:c}=await import("./server.browser-BZYwcDL4.js").then(d=>d.s);return{renderToStaticMarkup:c}},__vite__mapDeps([29,2,3]),import.meta.url);let a=l(Ue.createElement(r,{fontSize:t}));return a.includes("<svg")?(a.includes("xmlns")||(a=a.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"')),a=a.replace(/width="1em"/,`width="${t}"`).replace(/height="1em"/,`height="${t}"`),a=a.replace(/\s(?:class|aria-hidden|focusable|data-fui-icon|font-size)="[^"]*"/g,""),a):null}const za="__end__";function Ih(e,t){return`slot::${e}::${t??za}`}function Rh(e){return`group::${e}`}function Is(e){if(e.startsWith("slot::")){const[,t,n]=e.split("::");return{kind:"slot",groupId:t,beforeButtonId:n===za?null:n}}return e.startsWith("group::")?{kind:"group",groupId:e.slice(7)}:null}const At={root:{display:"flex",gap:m.spacingHorizontalM,flexWrap:"wrap",alignItems:"flex-start",minHeight:"120px",padding:`${m.spacingVerticalS} ${m.spacingHorizontalM}`},groupButtons:{display:"flex",gap:m.spacingHorizontalXS,flexWrap:"wrap",minHeight:"72px",alignItems:"flex-start",padding:m.spacingHorizontalXS},groupLabel:{textAlign:"center",fontSize:m.fontSizeBase100,color:m.colorNeutralForeground3,borderTop:`1px solid ${m.colorNeutralStroke2}`,paddingTop:m.spacingVerticalXS,paddingBottom:m.spacingVerticalXS,marginTop:"auto"},emptyTab:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:m.spacingVerticalM,minHeight:"160px",color:m.colorNeutralForeground3,flex:1,padding:"48px",textAlign:"center"},addGroupBtn:{minHeight:"96px",width:"40px",display:"flex",alignItems:"center",justifyContent:"center",border:`1px dashed ${m.colorNeutralStroke2}`,borderRadius:m.borderRadiusMedium,cursor:"pointer",color:m.colorNeutralForeground3,backgroundColor:"transparent"},addButtonGhost:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"60px",minHeight:"72px",borderRadius:m.borderRadiusMedium,border:`1px dashed ${m.colorNeutralStroke2}`,backgroundColor:"transparent",cursor:"pointer",color:m.colorNeutralForeground3}};function jh({button:e}){const t=D(i=>i.locLabels),n=ce(e.label,t),o=e.icon||"apps_add_in";return s.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"4px",width:"60px",minHeight:"72px",padding:"4px",borderRadius:m.borderRadiusMedium,border:`1px solid ${m.colorBrandStroke1}`,backgroundColor:m.colorNeutralBackground1,boxShadow:m.shadow16,opacity:.9,cursor:"grabbing",pointerEvents:"none",color:e.custom?m.colorBrandForeground1:m.colorNeutralForeground1},children:[s.jsx(jt,{name:o,size:24}),s.jsx("span",{style:{fontSize:m.fontSizeBase100,textAlign:"center",lineHeight:"1.2",maxWidth:"56px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:m.colorNeutralForeground1},children:n})]})}function Nh({group:e,isDropTarget:t,children:n,...o}){const{setNodeRef:i,isOver:r}=vr({id:Rh(e.id),data:{type:"group",groupId:e.id}});return s.jsx("div",{ref:i,style:{display:"flex",flexDirection:"column",minWidth:"80px",border:`1px solid ${r||t?m.colorBrandStroke1:m.colorNeutralStroke2}`,borderRadius:m.borderRadiusMedium,backgroundColor:r||t?m.colorBrandBackground2:m.colorNeutralBackground2,padding:`${m.spacingVerticalXS} ${m.spacingHorizontalXS}`,transition:"border-color 0.1s, background-color 0.1s"},...o,children:n})}function Rs({groupId:e,beforeButtonId:t}){const n=Ih(e,t),{setNodeRef:o,isOver:i}=vr({id:n,data:{type:"slot",groupId:e,beforeButtonId:t}});return s.jsx("div",{ref:o,style:{width:i?"2px":"0px",minHeight:"72px",backgroundColor:m.colorBrandStroke1,borderRadius:"2px",flexShrink:0,transition:"width 0.1s"},"aria-hidden":!0})}function $h({tab:e,location:t}){const n=D(z=>z.locLabels),o=D(z=>z.baseLanguageCode),i=z=>ce(z.label,n,o)||z.id,r=D(z=>z.baseline),l=D(z=>z.templates),a=D(z=>z.moveButton),c=D(z=>z.createGroup),d=D(z=>z.deleteButton),u=D(z=>z.layers),p=D(z=>z.duplicateButton),f=D(z=>z.duplicateGroup),S=D(z=>z.setGroupTemplate),v=D(z=>z.hideOobButton),x=D(z=>z.customizeOobButton),g=D(z=>z.setButtonProp),y=D(z=>z.renameGroup),C=D(z=>z.deleteGroup),w=Y(z=>z.openNewButton),h=Y(z=>z.openNewGroup),I=Y(z=>z.openIconPicker),$=Y(z=>z.openLocalizationEditor),R=Z(z=>z.selectButtonInContext),B=Z(z=>z.selectGroup),[T,H]=M.useState(null),[k,P]=M.useState(null),[j,E]=M.useState(null),[N,W]=M.useState(null),[U,V]=M.useState(null),[ee,_]=M.useState(null),[L,O]=M.useState(null),[F,b]=M.useState(null),A=M.useMemo(()=>{if(!L)return null;for(const z of e.groups){const G=z.buttons.find(te=>te.id===L);if(G)return{button:G,groupId:z.id}}return null},[L,e.groups]),X=br(_n(xr,{activationConstraint:{distance:5}}),_n(yr)),re=z=>t==="Application"&&e.id==="Mscrm.GlobalTab"&&z.oob&&!z.custom,me=z=>Ze(z.kind);function Ee(z){O(String(z.active.id))}function Ce(z){const G=z.over;if(!G){b(null);return}const te=Is(String(G.id));b(te?te.groupId:null)}function He(z){const{active:G,over:te}=z;if(O(null),b(null),!te||!G)return;let Q=null;for(const Nt of e.groups)if(Nt.buttons.some(gl=>gl.id===G.id)){Q=Nt.id;break}if(!Q)return;const we=Is(String(te.id));if(!we)return;let ne=null;we.kind==="slot"?ne=a({groupId:Q,buttonId:String(G.id),tabId:e.id,location:t},{groupId:we.groupId,beforeButtonId:we.beforeButtonId??void 0,tabId:e.id,location:t}):we.kind==="group"&&we.groupId!==Q&&(ne=a({groupId:Q,buttonId:String(G.id),tabId:e.id,location:t},{groupId:we.groupId,tabId:e.id,location:t})),ne&&ne!==String(G.id)&&R(t,e.id,we.groupId,ne)}return e.groups.length===0?s.jsxs("div",{style:At.emptyTab,children:[s.jsx(to,{fontSize:36,"aria-hidden":!0}),s.jsx(q,{children:"This tab has no groups yet"}),s.jsxs("button",{type:"button",style:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"6px 16px",background:m.colorBrandBackground,color:m.colorNeutralForegroundInverted,border:"none",borderRadius:m.borderRadiusMedium,cursor:"pointer",fontSize:m.fontSizeBase300},onClick:()=>h(),children:[s.jsx(Te,{fontSize:12})," Add first group"]})]}):s.jsxs(s.Fragment,{children:[t==="SubGrid"&&s.jsx(Ie,{intent:"info",style:{margin:`${m.spacingVerticalS} ${m.spacingHorizontalM} 0`},children:s.jsxs(Re,{children:["Subgrid ribbons support only 3 native controls: ",s.jsx("strong",{children:"Add"}),","," ",s.jsx("strong",{children:"Show List"}),", and ",s.jsx("strong",{children:"Delete"}),". Their icons cannot be changed."]})}),s.jsxs(Sr,{sensors:X,collisionDetection:Ku,onDragStart:Ee,onDragOver:Ce,onDragEnd:He,children:[s.jsxs("div",{style:At.root,role:"treegrid","aria-label":"Ribbon canvas","data-ribbon-canvas-root":"1",children:[e.groups.map(z=>s.jsxs(Nh,{group:z,isDropTarget:F===z.id,role:"rowgroup","aria-label":i(z),tabIndex:0,"data-ribbon-group-id":z.id,onContextMenu:G=>{G.target.closest("[data-btn]")||(G.preventDefault(),P({group:z,x:G.clientX,y:G.clientY}))},onFocus:()=>B(z.id),onKeyDown:G=>{if((G.key==="Enter"||G.key===" ")&&z.buttons.length>0){G.preventDefault();const te=z.buttons[0];if(!te)return;R(t,e.id,z.id,te.id),document.querySelector(`[data-ribbon-btn-id="${te.id}"]`)?.focus()}},children:[s.jsxs("div",{style:At.groupButtons,children:[z.buttons.map(G=>s.jsxs(Ue.Fragment,{children:[L&&s.jsx(Rs,{groupId:z.id,beforeButtonId:G.id}),s.jsx(Th,{button:G,groupId:z.id,tabId:e.id,location:t,activeId:L,onContextMenu:te=>H({groupId:z.id,button:G,x:te.clientX,y:te.clientY})})]},G.id)),L&&s.jsx(Rs,{groupId:z.id,beforeButtonId:null}),s.jsxs("button",{type:"button",style:At.addButtonGhost,"data-add-btn-group-id":z.id,onClick:()=>w(z.id),title:`Add button to ${i(z)}`,"aria-label":`Add button to ${i(z)}`,children:[s.jsx(Te,{fontSize:16}),s.jsx(q,{size:100,style:{color:"inherit"},children:"Add"})]})]}),s.jsx(ke,{content:`Template: ${z.template||"Flexible2"}`,relationship:"description",children:s.jsx("div",{style:At.groupLabel,children:i(z)})})]},z.id)),s.jsx("button",{type:"button",style:At.addGroupBtn,onClick:()=>c({tabId:e.id,location:t,group:{label:"New Group",sequence:(e.groups.length+1)*10,template:"Flexible2",buttons:[]}}),title:"Add group","aria-label":"Add group",children:s.jsx(Te,{fontSize:16})})]}),s.jsx(Yu,{dropAnimation:null,children:A?s.jsx(jh,{button:A.button}):null})]}),T&&s.jsxs(Fo,{open:!0,onOpenChange:(z,G)=>!G.open&&H(null),positioning:{position:"below",align:"start",target:{getBoundingClientRect:()=>({x:T.x,y:T.y,top:T.y,left:T.x,right:T.x,bottom:T.y,width:0,height:0,toJSON:()=>({})})}},children:[s.jsx(_o,{disableButtonEnhancement:!0,children:s.jsx("span",{style:{display:"none"}})}),s.jsx(qo,{children:s.jsxs(Ho,{children:[re(T.button)&&s.jsx(pe,{disabled:!0,icon:s.jsx(wt,{}),children:"OOB global command bar buttons cannot be customized."}),re(T.button)&&s.jsx(pt,{}),s.jsx(pe,{icon:s.jsx(no,{}),onClick:()=>{R(t,e.id,T.groupId,T.button.id),H(null)},children:"Edit properties"}),s.jsx(pe,{icon:s.jsx(Pn,{}),disabled:re(T.button)||me(T.button),onClick:()=>{R(t,e.id,T.groupId,T.button.id),I(),H(null)},children:"Change icon…"}),s.jsx(pe,{icon:s.jsx(mr,{}),disabled:re(T.button)||me(T.button),onClick:()=>{$(T.button.id),H(null)},children:"Edit labels…"}),s.jsx(pt,{}),T.button.hidden?s.jsx(pe,{icon:s.jsx(Ct,{}),disabled:re(T.button),onClick:()=>{g(t,e.id,T.groupId,T.button.id,{hidden:!1}),H(null)},children:"Show button"}):s.jsx(pe,{icon:s.jsx(Ye,{}),disabled:re(T.button),onClick:()=>{T.button.oob?E(T):g(t,e.id,T.groupId,T.button.id,{hidden:!0}),H(null)},children:"Hide button"}),(T.button.origin==="oob"||T.button.origin==="managed")&&s.jsx(pe,{icon:s.jsx(Pt,{}),disabled:re(T.button)||me(T.button),onClick:()=>{x(t,e.id,T.groupId,T.button.id),H(null)},children:"Create override…"}),s.jsx(Ta,{location:t,tabId:e.id,groupId:T.groupId,button:T.button,onDone:()=>H(null)}),s.jsx(pt,{}),s.jsx(pe,{icon:s.jsx(mn,{}),disabled:re(T.button),onClick:()=>{p(t,e.id,T.groupId,T.button.id),H(null)},children:"Duplicate"}),ka(e,T.groupId,T.button.id,n,o).map(z=>s.jsxs(pe,{icon:s.jsx(pr,{}),disabled:re(T.button),onClick:()=>{const G=a({groupId:T.groupId,buttonId:T.button.id,tabId:e.id,location:t},{groupId:z.groupId,tabId:e.id,location:t});G&&R(t,e.id,z.groupId,G),H(null)},children:["Move to: ",z.text]},z.groupId)),In(T.button,r[t])&&s.jsxs(s.Fragment,{children:[s.jsx(pt,{}),s.jsx(pe,{icon:s.jsx(Lt,{}),disabled:re(T.button),onClick:()=>{d(t,e.id,T.groupId,T.button.id),H(null)},children:"Delete"})]})]})})]}),k&&s.jsxs(Fo,{open:!0,onOpenChange:(z,G)=>!G.open&&P(null),positioning:{position:"below",align:"start",target:{getBoundingClientRect:()=>({x:k.x,y:k.y,top:k.y,left:k.x,right:k.x,bottom:k.y,width:0,height:0,toJSON:()=>({})})}},children:[s.jsx(_o,{disableButtonEnhancement:!0,children:s.jsx("span",{style:{display:"none"}})}),s.jsx(qo,{children:s.jsxs(Ho,{children:[s.jsx(pe,{icon:s.jsx(uu,{}),onClick:()=>{W(k.group),P(null)},children:"Rename…"}),s.jsx(pe,{icon:s.jsx(mn,{}),onClick:()=>{f(t,e.id,k.group.id),P(null)},children:"Duplicate group"}),s.jsx(pe,{icon:s.jsx(Pt,{}),onClick:()=>{V(k.group),P(null)},children:"Change template…"}),$i(k.group,r[t],Jn({layers:u},t))&&s.jsxs(s.Fragment,{children:[s.jsx(pt,{}),s.jsx(pe,{icon:s.jsx(Lt,{}),onClick:()=>{_(k.group),P(null)},children:"Delete group"})]})]})})]}),N&&s.jsx(Sh,{open:!0,initialLabel:i(N),onRename:z=>{y(t,e.id,N.id,z),W(null)},onCancel:()=>W(null)}),U&&s.jsx(Ch,{open:!0,currentTemplate:U.template,customTemplateIds:l.map(z=>z.id),loadedGroup:r[t].tabs.some(z=>z.id===e.id&&z.groups.some(G=>G.id===U.id)),onChange:z=>{S(t,e.id,U.id,z),V(null)},onCancel:()=>V(null)}),ee&&s.jsxs(Fi,{open:!0,title:"Delete group",confirmLabel:"Delete group",destructive:!0,onConfirm:()=>{C(t,e.id,ee.id),_(null)},onCancel:()=>_(null),children:["Delete the group “",i(ee),"” and its ",ee.buttons.length," button",ee.buttons.length===1?"":"s","?"]}),j&&s.jsx(Pi,{open:!0,buttonLabel:ce(j.button.label,n),onConfirmHide:()=>{v(t,e.id,j.groupId,j.button.id),E(null)},commandId:j.button.commandId,onConfirmDisplayRule:()=>{D.getState().hideWithDisplayRules(j.button.commandId),E(null)},onCancel:()=>E(null)})]})}const Th=Ue.memo(function({button:t,groupId:n,tabId:o,location:i,activeId:r,onContextMenu:l}){const a=Z(R=>R.selectedButtonId),c=Z(R=>R.selectButtonInContext),d=D(R=>R.locLabels),u=a===t.id,p=i==="Application"&&o==="Mscrm.GlobalTab"&&t.oob&&!t.custom,f=ce(t.label,d),S=Ze(t.kind)?qn[t.kind]:void 0,v=S?` (${S}, read-only)`:"",{attributes:x,listeners:g,setNodeRef:y,isDragging:C}=Ju({id:t.id,data:{type:"button",button:t,groupId:n},disabled:t.managed||p}),w=C||r===t.id,h={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"4px",width:"60px",minHeight:"72px",padding:"4px",borderRadius:m.borderRadiusMedium,cursor:"grab",border:u?`1px solid ${m.colorBrandStroke1}`:t.custom?`1px solid ${m.colorBrandStroke2}`:"1px solid transparent",backgroundColor:u?m.colorBrandBackground2:t.managed?m.colorNeutralBackground3:"transparent",opacity:w?.3:t.hidden?.4:1,position:"relative",userSelect:"none",color:t.custom?m.colorBrandForeground1:m.colorNeutralForeground1,transition:"opacity 0.15s, border-color 0.1s, background-color 0.1s"},I=t.icon||"apps_add_in",$=R=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(R.key))return;R.preventDefault();const B=R.currentTarget.closest("[data-ribbon-canvas-root='1']");if(!B)return;const T=Array.from(B.querySelectorAll(`[data-ribbon-tab-id="${o}"][data-btn="1"]`)),H=T.findIndex(W=>W.dataset.ribbonBtnId===t.id);if(H<0||T.length===0)return;const k=R.key==="ArrowLeft"||R.key==="ArrowUp"?-1:1,P=Math.max(0,Math.min(T.length-1,H+k)),j=T[P],E=j?.dataset.ribbonGroupId,N=j?.dataset.ribbonBtnId;!j||!E||!N||(c(i,o,E,N),j.focus())};return s.jsx(ke,{content:p?"OOB global command bar buttons cannot be customized.":`${f}${v}${t.hidden?" — hidden":""}`,relationship:"label",children:s.jsxs("button",{ref:y,type:"button","data-btn":"1","data-ribbon-tab-id":o,"data-ribbon-group-id":n,"data-ribbon-btn-id":t.id,style:h,"aria-selected":u,"aria-label":`${f}${v}${t.hidden?" — hidden":""}${t.custom?" (custom)":""}${t.managed?" (read-only)":""}`,onClick:()=>c(i,o,n,t.id),onFocus:()=>c(i,o,n,t.id),onKeyDown:R=>{if(R.key==="Enter"||R.key===" "){R.preventDefault(),c(i,o,n,t.id);return}$(R)},onContextMenu:R=>{R.preventDefault(),R.stopPropagation(),c(i,o,n,t.id),l(R)},...x,...g,children:[s.jsx(jt,{name:I,size:24,style:{filter:t.custom?"none":"grayscale(40%) opacity(0.85)"}}),s.jsx("span",{style:{fontSize:m.fontSizeBase100,textAlign:"center",lineHeight:"1.2",maxWidth:"56px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:m.colorNeutralForeground1},children:f}),S&&s.jsx("span",{style:{fontSize:m.fontSizeBase100,lineHeight:"1",maxWidth:"56px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:m.colorNeutralForeground3},children:S}),t.menu&&s.jsx(gt,{fontSize:10,"aria-label":"Has a menu"}),t.hidden&&s.jsx("span",{style:{position:"absolute",top:2,right:2},"aria-hidden":!0,children:s.jsx(Ye,{fontSize:10,style:{color:m.colorNeutralForeground3}})}),t.custom&&!t.managed&&s.jsx(ae,{size:"extra-small",color:"brand",appearance:"tint",style:{position:"absolute",bottom:2,right:2},"aria-label":"Custom",children:"NEW"}),(t.managed||p)&&s.jsx("span",{style:{position:"absolute",top:2,left:2},title:p?"OOB global command bar buttons cannot be customized.":"Read-only (managed)",children:s.jsx(wt,{fontSize:10,style:{color:m.colorNeutralForeground3}})})]})})}),ge=Rt()((e,t)=>({tableLogicalName:null,status:"idle",error:null,commands:[],apps:[],appFilter:"all",selectedCommandId:null,loadToken:0,beginLoad(n){const o=t().loadToken+1;return e({tableLogicalName:n,status:"loading",error:null,commands:[],apps:[],selectedCommandId:null,loadToken:o}),o},finishLoad(n,o){if(n!==t().loadToken)return;const{appFilter:i}=t(),r=i==="all"||o.apps.some(l=>l.id===i);e({status:o.error?"unavailable":"loaded",error:o.error??null,commands:o.commands,apps:o.apps,appFilter:r?i:"all"})},reset(){e(n=>({tableLogicalName:null,status:"idle",error:null,commands:[],apps:[],selectedCommandId:null,loadToken:n.loadToken+1}))},setAppFilter(n){e({appFilter:n?n.toLowerCase():"all"})},selectCommand(n){n&&Z.getState().clearSelection(),e({selectedCommandId:n})}}));Z.subscribe((e,t)=>{if(!ge.getState().selectedCommandId)return;(e.selectedButtonId&&e.selectedButtonId!==t.selectedButtonId||e.location!==t.location||e.tabId!==t.tabId)&&ge.setState({selectedCommandId:null})});const an={Form:0,MainGrid:1,SubGrid:2,AssociatedGrid:3,GlobalHeader:5},Ba={0:"Form",1:"Main grid",2:"Subgrid",3:"Associated grid",4:"Quick form",5:"Global header",6:"Dashboard"},Oa="appaction_appactionrule_classicrules",kh=["appactionid","name","uniquename","buttonlabeltext","buttontooltiptitle","buttontooltipdescription","buttonaccessibilitytext","_appmoduleid_value","context","_contextentity_value","contextvalue","location","type","sequence","buttonsequencepriority","hidden","isdisabled","origin","ismanaged","fonticon","_iconwebresourceid_value","_parentappactionid_value","grouptitle","isgrouptitlehidden","onclickeventtype","onclickeventjavascriptfunctionname","onclickeventjavascriptparameters","_onclickeventjavascriptwebresourceid_value","onclickeventformulacomponentlibrary","onclickeventformulacomponentname","onclickeventformulafunctionname","visibilitytype","visibilityformulacomponentlibrary","visibilityformulacomponentname","visibilityformulafunctionname"],Bo="@OData.Community.Display.V1.FormattedValue",ve=e=>typeof e=="string"&&e.trim()!==""?e:typeof e=="number"?String(e):void 0,ct=e=>{if(e==null||e==="")return;const t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:void 0},An=e=>e===!0||e===1||e==="true"||e==="1",yt=e=>{const t=ve(e);return t?t.toLowerCase():null};function Ah(e){switch(ct(e)){case 1:return"dropdown";case 2:return"split";case 3:return"group";default:return"button"}}function Dh(e){const t=ct(e);return t===1?"formula":t===2?"javascript":"none"}function zh(e){const t=ct(e);return t===1?"formula":t===2?"classicRules":"none"}function Bh(e){const t=ct(e);return t===1?"migrated":t===2?"enhancedMigrated":"default"}function js(e,t){const n={componentLibrary:ve(e[`${t}componentlibrary`]),componentName:ve(e[`${t}componentname`]),functionName:ve(e[`${t}functionname`])};return n.componentLibrary||n.componentName||n.functionName?n:void 0}function Oh(e){return Array.isArray(e)?e.map(t=>{const n=yt(t.appactionruleid);return n?{id:n,name:ve(t.name)??ve(t.uniquename)??n,uniqueName:ve(t.uniquename),kind:ct(t.type)===0?"enable":"display"}:null}).filter(t=>t!==null):[]}function Eh(e){const t=yt(e.appactionid);if(!t)return null;const n=ct(e.location);if(n===void 0)return null;const o=ve(e.name)??"",i=ve(e.uniquename)??o;return{id:t,name:o,uniqueName:i,label:ve(e.buttonlabeltext)??(o||i||t),tooltipTitle:ve(e.buttontooltiptitle),tooltipDescription:ve(e.buttontooltipdescription),accessibilityText:ve(e.buttonaccessibilitytext),appModuleId:yt(e._appmoduleid_value),appName:ve(e[`_appmoduleid_value${Bo}`]),scope:ct(e.context)===0?"all":"entity",contextValue:ve(e.contextvalue),contextEntityId:yt(e._contextentity_value)??void 0,location:n,type:Ah(e.type),sequence:ct(e.sequence)??ct(e.buttonsequencepriority)??0,hidden:An(e.hidden),disabled:An(e.isdisabled),origin:Bh(e.origin),managed:An(e.ismanaged),fontIcon:ve(e.fonticon),iconWebResourceId:yt(e._iconwebresourceid_value)??void 0,iconWebResourceName:ve(e[`_iconwebresourceid_value${Bo}`]),parentId:yt(e._parentappactionid_value),groupTitle:ve(e.grouptitle),groupTitleHidden:An(e.isgrouptitlehidden),action:Dh(e.onclickeventtype),jsFunctionName:ve(e.onclickeventjavascriptfunctionname),jsParameters:ve(e.onclickeventjavascriptparameters),jsWebResourceId:yt(e._onclickeventjavascriptwebresourceid_value)??void 0,jsWebResourceName:ve(e[`_onclickeventjavascriptwebresourceid_value${Bo}`]),onSelectFormula:js(e,"onclickeventformula"),visibility:zh(e.visibilitytype),visibilityFormula:js(e,"visibilityformula"),classicRules:Oh(e[Oa])}}function Mh(e){const t=new Map;for(const n of e){const o=Eh(n);o&&!t.has(o.id)&&t.set(o.id,o)}return[...t.values()]}function Lh(e){switch(e){case"HomepageGrid":return[an.MainGrid];case"SubGrid":return[an.SubGrid,an.AssociatedGrid];case"Form":return[an.Form];case"Application":return[an.GlobalHeader]}}function Ph(e,t){if(e.scope==="all")return!0;const n=t.metadataId?.toLowerCase();return n&&e.contextEntityId===n?!0:!!e.contextValue&&e.contextValue.toLowerCase()===t.logicalName.toLowerCase()}function Fh(e,t){return t==="all"||e.appModuleId===null||e.appModuleId===t.toLowerCase()}function _h(e,t){const n=new Set(Lh(t.location));return e.filter(o=>n.has(o.location)&&Fh(o,t.appFilter)&&Ph(o,t.table))}const pi=(e,t)=>e.sequence-t.sequence||e.label.localeCompare(t.label)||e.id.localeCompare(t.id);function Ea(e){const t=new Set(e.map(l=>l.id)),n=new Map,o=[];for(const l of e)if(l.parentId&&l.parentId!==l.id&&t.has(l.parentId)){const a=n.get(l.parentId)??[];a.push(l),n.set(l.parentId,a)}else o.push(l);const i=new Set,r=l=>{i.add(l.id);const a=(n.get(l.id)??[]).filter(c=>!i.has(c.id)).sort(pi);return{command:l,children:a.map(r)}};return o.sort(pi).map(r)}function Ma(e){return e.flatMap(t=>[t.command,...Ma(t.children)])}const La=/\{!EntityLogicalName\}/gi,qh=/(?:![A-Za-z0-9_]+)*!\d+$/;function Hh(e,t){if(e.origin==="default")return[];const n=[],o=i=>{i.includes(".")&&!n.includes(i)&&n.push(i)};for(const i of[e.uniqueName,e.name]){if(!i)continue;const r=i.trim().replace(La,t).replace(qh,""),l=r.indexOf("_"),a=r.indexOf(".");l>0&&(a===-1||l<a)&&o(r.slice(l+1)),o(r)}return n}function fi(e,t){return e.replace(La,t).toLowerCase()}function Ns(e,t){const n=fi(e,t).split(".");return n.length<4||n[0]!=="mscrm"?null:[n[0],n[1],"*",...n.slice(3)].join(".")}function $s(e,t,n,o={}){const i=new Map,r=new Map;for(const a of t){const c=fi(a,n);i.has(c)||i.set(c,a);const d=Ns(a,n);d&&!r.has(d)&&r.set(d,a)}const l=new Map;for(const a of e){if(a.disabled&&!o.includeDisabled)continue;const c=Hh(a,n),d=c.map(p=>i.get(fi(p,n))).find(Boolean)??c.map(p=>Ns(p,n)).map(p=>p?r.get(p):void 0).find(Boolean);if(!d)continue;const u=l.get(d)??[];u.push({buttonId:d,command:a,effect:a.hidden?"hidden":"replaced"}),l.set(d,u)}return l}function Gh(e,t,n){const o=l=>l.toLowerCase(),i=`mscrm.${o(t)}.${o(n)}.maintab`,r=e.find(l=>l.id==="Mscrm.GlobalTab")?.id;return t==="Application"&&r?r:e.find(l=>o(l.id)===i)?.id??e.find(l=>/maintab$/i.test(l.id)&&!/\.allentities\./i.test(l.id))?.id??r??e[0]?.id}function Pa(e){return(e.menu?.sections??[]).flatMap(t=>t.controls.flatMap(n=>[n,...Pa(n)]))}function Wh(e){const{commands:t,tabs:n,location:o,entityLogicalName:i}=e,r=n.flatMap(y=>y.groups.flatMap(C=>C.buttons)),l=[...r,...r.flatMap(Pa)].map(y=>y.id),a=new Map(t.map(y=>[y.id,y])),c=new Set([...$s(t,l,i,{includeDisabled:!0}).values()].flat().map(y=>y.command.id)),d=new Map,u=(y,C=new Set)=>{const w=d.get(y.id);if(w!==void 0)return w;let h=y.parentId?a.get(y.parentId):void 0;for(const $=new Set;h?.type==="group"&&!c.has(h.id)&&!$.has(h.id);)$.add(h.id),h=h.parentId?a.get(h.parentId):void 0;const I=c.has(y.id)&&(!h||!C.has(h.id)&&u(h,C.add(y.id)));return d.set(y.id,I),I},f=(y=>{for(const[C,w]of y){const h=w.filter(I=>u(I.command));h.length>0?y.set(C,h):y.delete(C)}return y})($s(t,l,i)),S=new Set([...f.values()].flat().map(y=>y.command.id)),v=y=>{const C=new Set;for(let w=y.parentId;w&&!C.has(w);w=a.get(w)?.parentId??null){C.add(w);const h=a.get(w);if(h&&u(h))return w}},x=new Map,g=[];for(const y of t){const C=v(y);if(!C){u(y)||g.push(y);continue}if(S.has(y.id))continue;const w=x.get(C)??[];w.push(y),x.set(C,w)}for(const y of f.values())for(const C of y){const w=x.get(C.command.id);w&&(C.items=[...w].sort(pi))}return{commandBarTabId:Gh(n,o,i),nodes:Ea(g),overrides:f,unmatchedMigrated:g.filter(y=>y.origin!=="default")}}function Uh(e,t){const n=new Map,o=[];for(const i of t){const r=e.find(a=>a.sequence>i.command.sequence);if(!r){o.push(i);continue}const l=n.get(r.id)??[];l.push(i),n.set(r.id,l)}return{before:n,trailing:o}}function Ts(e){if(!e)return;const t=[e.componentName,e.functionName].filter(Boolean).join("."),n=e.componentLibrary?` (component library ${e.componentLibrary})`:"";return`${t||"Power Fx formula"}${n}`}function Xh(e,t){if(!t)return e;const n=new Set([...t].map(o=>o.toLowerCase()));return e.filter(o=>o.appModuleId===null||n.has(o.appModuleId))}function Vh(e,t,n){const o=new Map(t.map(r=>[r.id.toLowerCase(),r])),i=new Map;for(const r of n??[]){const l=o.get(r.toLowerCase());l&&i.set(l.id.toLowerCase(),l)}if(n)return[...i.values()].sort((r,l)=>r.name.localeCompare(l.name)||r.id.localeCompare(l.id));for(const r of e)!r.appModuleId||i.has(r.appModuleId)||i.set(r.appModuleId,o.get(r.appModuleId)??{id:r.appModuleId,name:r.appName??r.appModuleId});return[...i.values()].sort((r,l)=>r.name.localeCompare(l.name)||r.id.localeCompare(l.id))}function xn(e,t){return e.appModuleId===null?"All apps":t?.get(e.appModuleId)??e.appName??e.appModuleId}function _i(e,t){const n=xn(e.command,t),o=e.command.appModuleId===null?"in all apps":`in ${n}`,i=e.effect==="hidden"?`Hidden by modern command ${e.command.label} ${o}`:`Rendered as modern command ${e.command.label} ${o} (migrated)`;return e.items?.length?`${i}; its menu also has ${e.items.map(r=>r.label).join(", ")}`:i}function Fa(e,t){if(!e?.length)return"";const n=e.find(o=>o.effect==="hidden");return n?` — ${_i(n,t).replace(/^Hidden/,"hidden")}`:" — modern (migrated)"}const Jh={button:"Command",dropdown:"Dropdown",split:"Split button",group:"Group"},Kh={default:"Command designer",migrated:"Migrated from classic",enhancedMigrated:"Enhanced migrated from classic"};function _a(e,t){const n=[{label:"App",value:xn(e,t)},{label:"Location",value:`${Ba[e.location]??`Location ${e.location}`}${e.scope==="all"?" (all tables)":""}`},{label:"Type",value:Jh[e.type]},{label:"Order",value:String(e.sequence)},{label:"Origin",value:Kh[e.origin]}];if(e.hidden?n.push({label:"Status",value:"Hidden"}):e.disabled&&n.push({label:"Status",value:e.origin==="default"?"Disabled":"Disabled — the classic (ribbon) equivalent is shown"}),e.visibility==="formula")n.push({label:"Visible (Power Fx)",value:Ts(e.visibilityFormula)??"Power Fx formula"});else if(e.visibility==="classicRules"){const o=e.classicRules.filter(i=>i.kind==="display").map(i=>i.name);n.push({label:"Visibility",value:o.length?`Classic rules: ${o.join(", ")}`:"Classic rules"})}if(e.action==="formula")n.push({label:"OnSelect (Power Fx)",value:Ts(e.onSelectFormula)??"Power Fx formula"});else if(e.action==="javascript"){const o=e.jsWebResourceName??e.jsWebResourceId,i=e.jsFunctionName??"(no function)";n.push({label:"Action (JavaScript)",value:o?`${i} in ${o}`:i}),e.jsParameters&&n.push({label:"Parameters",value:e.jsParameters})}return n}function Yh(){return window.dataverseAPI}const Sn=e=>e instanceof Error?e.message:String(e);async function eo(e){const t=[],n=new Set;let o=e;for(;o&&!n.has(o);){n.add(o);const i=await Yh().queryData(o);t.push(...i.value??[]);const r=i["@odata.nextLink"];o=r?r.replace(/^.*\/api\/data\/v[\d.]+\//,""):void 0}return t}function qa(e){return/\b40[13]\b|0x80040220|prvRead|privilege|unauthori[sz]ed|forbidden|not have permission/i.test(Sn(e))}const Ha=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function ks(e,t){const n=[`contextvalue eq '${e.logicalName.replace(/'/g,"''")}'`];e.metadataId&&Ha.test(e.metadataId)&&n.push(`_contextentity_value eq ${e.metadataId}`);const o=`statecode eq 0 and (context eq 0 or ${n.join(" or ")}) and (location eq 0 or location eq 1 or location eq 2 or location eq 3 or location eq 5)`,i=t?`&$expand=${Oa}($select=appactionruleid,name,uniquename,type)`:"";return`appactions?$select=${kh.join(",")}&$filter=${o}${i}`}async function Zh(e){const t=oe.getState();let n;try{n=await eo(ks(e,!0))}catch(o){if(qa(o))throw o;t.logInfo("dataverse",`Modern commands: classic rules couldn't be expanded (${Sn(o)}); retrying without them.`),n=await eo(ks(e,!1))}return Mh(n)}async function Qh(e){const t=oe.getState(),n="appmodules?$select=appmoduleid,appmoduleidunique,name,uniquename",o=e.metadataId&&Ha.test(e.metadataId)?`appmodulecomponents?$select=_appmoduleidunique_value&$filter=componenttype eq 1 and objectid eq ${e.metadataId}`:null,[i,r]=await Promise.all([eo(n),o?eo(o).catch(d=>(t.logInfo("dataverse",`Modern commands: couldn't resolve which apps contain ${e.logicalName} (${Sn(d)}).`),null)):Promise.resolve(null)]),l=i,a=l.filter(d=>!!d.appmoduleid).map(d=>({id:String(d.appmoduleid).toLowerCase(),name:d.name?.trim()||d.uniquename||String(d.appmoduleid),uniqueName:d.uniquename}));let c=null;if(r){const d=new Set(r.map(u=>u._appmoduleidunique_value).filter(u=>typeof u=="string").map(u=>u.toLowerCase()));c=new Set(l.filter(u=>u.appmoduleid&&u.appmoduleidunique&&d.has(u.appmoduleidunique.toLowerCase())).map(u=>String(u.appmoduleid).toLowerCase()))}return{apps:a,containingAppIds:c}}async function eg(e){const t=oe.getState(),[n,o]=await Promise.allSettled([Zh(e),Qh(e)]);if(n.status==="rejected"){const a=Sn(n.reason);return t.logWarn("dataverse",qa(n.reason)?`No permission to read modern commands (appaction) for ${e.logicalName}; the canvas shows classic commands only. (${a})`:`Modern commands unavailable for ${e.logicalName}: ${a}`),{commands:[],apps:[],error:a}}o.status==="rejected"&&t.logInfo("dataverse",`Modern commands: app list unavailable (${Sn(o.reason)}); showing app ids from the commands.`);const{apps:i,containingAppIds:r}=o.status==="fulfilled"?o.value:{apps:[],containingAppIds:null},l=Xh(n.value,r);return t.logInfo("dataverse",`Loaded ${l.length} modern command${l.length===1?"":"s"} for ${e.logicalName}.`),{commands:l,apps:Vh(l,i,r)}}function tg(){const e=ie(n=>n.activeEntity?.logicalName),t=ie(n=>n.activeEntity?.metadataId);M.useEffect(()=>{const n=ge.getState();if(!e||typeof window.dataverseAPI>"u"){n.reset();return}const o=n.beginLoad(e);eg({logicalName:e,metadataId:t}).then(i=>ge.getState().finishLoad(o,i))},[e,t])}function Zt(){const e=ge(n=>n.apps),t=ge(n=>n.commands);return M.useMemo(()=>{const n=new Map;for(const o of t)o.appModuleId&&o.appName&&n.set(o.appModuleId,o.appName);for(const o of e)n.set(o.id,o.name);return n},[e,t])}function Ga(e){const t=ge(r=>r.commands),n=ge(r=>r.appFilter),o=ie(r=>r.activeEntity?.logicalName),i=ie(r=>r.activeEntity?.metadataId);return M.useMemo(()=>o?_h(t,{location:e,appFilter:n,table:{logicalName:o,metadataId:i}}):[],[t,n,e,o,i])}const As=new Set;function qi(e){const t=Ga(e),n=ie(u=>u.activeEntity?.logicalName)??"",o=D(u=>u.ribbons[e]?.tabs),i=D(u=>u.ribbons[e]?.entityLogicalName??""),r=ge(u=>u.status==="loaded"?u.tableLogicalName:null),l=(o?.length??0)>0&&(e==="Application"||i.toLowerCase()===n.toLowerCase()),a=M.useMemo(()=>Wh({commands:t,tabs:l?o??[]:[],location:e,entityLogicalName:n}),[t,o,l,e,n]),d=!!n&&r===n&&l?a.unmatchedMigrated.map(u=>u.uniqueName).join(", "):"";return M.useEffect(()=>{const u=`${n}|${e}|${d}`;!d||As.has(u)||(As.add(u),oe.getState().logInfo("ribbon",`Migrated modern commands without a classic control in ${n} ${e}: ${d}`))},[d,n,e]),a}function Hi(e,t){const n=qi(e);return M.useMemo(()=>{const o=t.groups.flatMap(r=>r.buttons.map(l=>({id:l.id,sequence:l.sequence}))),i=t.id===n.commandBarTabId?n.nodes:[];return{nodes:i,placement:Uh(o,i),overrides:n.overrides}},[n,t])}function ng(e,t){const{overrides:n}=qi(e);return t&&n.get(t)||og}const og=[];function ig(){const e=ge(i=>i.selectedCommandId),t=Z(i=>i.selectedButtonId),n=Z(i=>i.location),o=Ga(n);return M.useMemo(()=>{if(!e||t)return null;const i=o.find(l=>l.id===e);if(!i)return null;let r;for(const l of Ea(o))if(r=Wa(l,e),r)break;return{command:i,children:r?Ma(r.children):[]}},[e,t,o])}function Wa(e,t){if(e.command.id===t)return e;for(const n of e.children){const o=Wa(n,t);if(o)return o}}const Ua=le({chip:{display:"flex",alignItems:"center",gap:m.spacingHorizontalXS,height:"32px",padding:`0 ${m.spacingHorizontalS}`,borderRadius:m.borderRadiusMedium,border:`1px dashed ${m.colorPaletteBerryBorderActive}`,backgroundColor:m.colorPaletteBerryBackground1,color:m.colorNeutralForeground1,cursor:"default",whiteSpace:"nowrap",flexShrink:0,userSelect:"none",":hover":{backgroundColor:m.colorPaletteBerryBackground2},":focus-visible":{outline:`2px solid ${m.colorBrandStroke1}`,outlineOffset:"2px"}},selected:{border:`1px solid ${m.colorPaletteBerryForeground2}`,backgroundColor:m.colorPaletteBerryBackground2},muted:{opacity:.5},hidden:{textDecoration:"line-through"},tooltip:{display:"flex",flexDirection:"column",gap:"2px",maxWidth:"360px"},tooltipRow:{fontSize:m.fontSizeBase200,overflowWrap:"anywhere"}});function Xa({node:e,appNames:t}){const n=Ua(),o=e.command;return s.jsxs("div",{className:n.tooltip,children:[s.jsx(q,{weight:"semibold",children:o.label}),s.jsx(q,{className:n.tooltipRow,children:"Modern command — read-only in CBS; edit it in the command designer."}),_a(o,t).map(i=>s.jsxs(q,{className:n.tooltipRow,children:[s.jsxs("b",{children:[i.label,":"]})," ",i.value]},i.label)),e.children.length>0&&s.jsxs(q,{className:n.tooltipRow,children:[s.jsx("b",{children:"Items:"})," ",e.children.map(i=>i.command.label).join(", ")]})]})}function sg({node:e,appNames:t,showApp:n,onDragRejected:o}){const i=Ua(),r=e.command,l=ge(v=>v.selectedCommandId),a=ge(v=>v.selectCommand),c=Z(v=>v.selectedButtonId),d=l===r.id&&!c,u=r.type==="dropdown"||r.type==="split"||e.children.length>0,p=r.fontIcon&&!r.fontIcon.startsWith("$")?r.fontIcon:"apps_add_in",f=`${r.hidden?" — hidden":""}${r.disabled?" — disabled":""}`,S=v=>{v.preventDefault(),v.stopPropagation(),v.dataTransfer.dropEffect="none",o?.()};return s.jsx(ke,{content:s.jsx(Xa,{node:e,appNames:t}),relationship:"description",children:s.jsxs("button",{type:"button",draggable:!1,className:Ft(i.chip,d&&i.selected,(r.hidden||r.disabled)&&i.muted,r.hidden&&i.hidden),"aria-pressed":d,"aria-label":`${r.label} — modern command (read-only), ${xn(r,t)}${f}`,onClick:()=>a(r.id),onDragStart:v=>v.preventDefault(),onDragOver:S,onDrop:S,onContextMenu:v=>{v.preventDefault(),a(r.id)},children:[s.jsx(jt,{name:p,size:16}),s.jsx(q,{size:200,children:r.label}),u&&s.jsx(gt,{fontSize:12,"aria-hidden":!0}),r.hidden&&s.jsx(Ye,{fontSize:12,"aria-hidden":!0}),s.jsx(ae,{size:"extra-small",appearance:"tint",color:"important",icon:s.jsx(wt,{}),children:"Modern"}),n&&s.jsx(ae,{size:"extra-small",appearance:"outline",color:"informative",children:xn(r,t)})]})})}function Gi({overrides:e,appNames:t}){if(!e?.length)return null;const n=e.some(i=>i.effect==="hidden"),o=e.map(i=>_i(i,t)).join(`
|
|
135
135
|
`);return s.jsx(ae,{size:"extra-small",appearance:"tint",color:n?"warning":"important",title:o,"aria-label":o,children:n?"Hidden by modern":"Modern (migrated)"})}const Dn="application/x-rw-btn",Ds="application/x-rw-se",rg=le({root:{display:"flex",alignItems:"center",gap:m.spacingHorizontalXS,padding:`${m.spacingHorizontalS} 0`,minHeight:"48px"},scrollRow:{display:"flex",alignItems:"center",gap:m.spacingHorizontalXS,flex:1,minWidth:0,overflowX:"auto",overflowY:"hidden",paddingBottom:m.spacingHorizontalXS},button:{display:"flex",alignItems:"center",gap:m.spacingHorizontalXS,height:"32px",padding:`0 ${m.spacingHorizontalS}`,borderRadius:m.borderRadiusMedium,border:"1px solid transparent",cursor:"pointer",backgroundColor:"transparent",color:m.colorNeutralForeground1,whiteSpace:"nowrap",position:"relative",userSelect:"none",":hover":{backgroundColor:m.colorNeutralBackground3,border:`1px solid ${m.colorNeutralStroke1}`},":focus-visible":{outline:`2px solid ${m.colorBrandStroke1}`,outlineOffset:"2px"}},buttonSelected:{backgroundColor:m.colorBrandBackground2,border:`1px solid ${m.colorBrandStroke1}`},buttonHidden:{opacity:.4,textDecoration:"line-through"},buttonCustom:{border:`1px solid ${m.colorBrandStroke2}`},lockIcon:{position:"absolute",top:"4px",left:"4px",color:m.colorNeutralForeground3,pointerEvents:"none"},dropLine:{width:"2px",height:"24px",backgroundColor:m.colorBrandStroke1,borderRadius:"2px",flexShrink:0},overflowBtn:{display:"flex",alignItems:"center",gap:m.spacingHorizontalXS,height:"32px",padding:`0 ${m.spacingHorizontalS}`,borderRadius:m.borderRadiusMedium,border:`1px solid ${m.colorNeutralStroke2}`,backgroundColor:m.colorNeutralBackground2,cursor:"pointer",color:m.colorNeutralForeground3,flexShrink:0},trailingControls:{display:"flex",alignItems:"center",gap:m.spacingHorizontalXS,flexShrink:0,paddingLeft:m.spacingHorizontalS,borderLeft:`1px solid ${m.colorNeutralStroke2}`,marginLeft:m.spacingHorizontalXS}});function ag({tab:e,location:t}){const n=rg(),o=Z(b=>b.selectedButtonId),i=Z(b=>b.selectButtonInContext),r=D(b=>b.moveButton),l=D(b=>b.deleteButton),a=D(b=>b.baseline),c=D(b=>b.duplicateButton),d=D(b=>b.hideOobButton),u=D(b=>b.setButtonProp),p=D(b=>b.customizeOobButton),f=D(b=>b.locLabels),S=D(b=>b.baseLanguageCode),v=(b,A)=>ce(b,f,S)||A,x=Y(b=>b.openIconPicker),g=Y(b=>b.openLocalizationEditor),y=Y(b=>b.openNewButton),[C,w]=M.useState(null),[h,I]=M.useState(null),[$,R]=M.useState(null),[B,T]=M.useState(null),H=Hi(t,e),k=Zt(),P=ge(b=>b.appFilter==="all"),j=b=>s.jsx(sg,{node:b,appNames:k,showApp:P,onDragRejected:()=>w(null)},b.command.id),E=b=>Fa(H.overrides.get(b.id),k),N=b=>t==="Application"&&e.id==="Mscrm.GlobalTab"&&b.oob&&!b.custom,W=b=>Ze(b.kind),U=b=>W(b)?` (${qn[b.kind]}, read-only)`:"",V=e.groups.flatMap(b=>b.buttons.map(A=>({button:A,groupId:b.id})));function ee(b,A,X){b.dataTransfer.setData(Dn,JSON.stringify({groupId:A,buttonId:X})),b.dataTransfer.effectAllowed="move",I(X)}function _(){I(null),w(null)}function L(b,A){const X=Array.from(b.dataTransfer.types??[]);!X.includes(Dn)&&!X.includes(Ds)||(b.preventDefault(),b.dataTransfer.dropEffect=X.includes(Dn)?"move":"copy",w({beforeButtonId:A}))}const O=D(b=>b.createButton);function F(b,A,X){b.preventDefault(),b.stopPropagation();const re=b.dataTransfer.getData(Dn);if(re){try{const Ee=JSON.parse(re);if(Ee?.buttonId){const Ce=r({groupId:Ee.groupId,buttonId:Ee.buttonId,tabId:e.id,location:t},{groupId:A,beforeButtonId:X??void 0,tabId:e.id,location:t});Ce&&Ce!==Ee.buttonId&&i(t,e.id,A,Ce)}}catch{}w(null),I(null);return}const me=b.dataTransfer.getData(Ds);if(me){try{const Ce=JSON.parse(me)?.button;if(Ce){const He=`_copy_${Date.now()}`;O({location:t,tabId:e.id,groupId:A,button:{...Un(Ce,`${Ce.id}${He}`),label:Ce.label??"New Button",kind:Ce.kind??"button",sequence:50,templateAlias:Ce.templateAlias??"o1",commandId:Ce.commandId??"",hidden:!1,oob:!1,custom:!0,managed:!1}})}}catch{}w(null),I(null);return}w(null),I(null)}return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:n.root,children:[s.jsxs("div",{className:n.scrollRow,onDragOver:b=>{b.preventDefault()},onDrop:b=>F(b,e.groups[0]?.id??"",null),children:[V.map(({button:b,groupId:A})=>s.jsxs(Ue.Fragment,{children:[H.placement.before.get(b.id)?.map(j),C?.beforeButtonId===b.id&&s.jsx("div",{className:n.dropLine,"aria-hidden":!0}),s.jsx(ke,{content:N(b)?"OOB global command bar buttons cannot be customized.":`${ce(b.label,f)}${U(b)}${b.hidden?" — hidden":""}${E(b)}`,relationship:"label",children:s.jsxs("button",{type:"button",className:[n.button,o===b.id?n.buttonSelected:"",b.hidden?n.buttonHidden:"",b.custom?n.buttonCustom:""].filter(Boolean).join(" "),"aria-selected":o===b.id,"aria-label":`${ce(b.label,f)}${U(b)}${b.hidden?" — hidden":""}${E(b)}`,onClick:()=>i(t,e.id,A,b.id),onContextMenu:X=>{X.preventDefault(),i(t,e.id,A,b.id),R({button:b,groupId:A,x:X.clientX,y:X.clientY})},draggable:!b.managed&&!N(b),onDragStart:X=>ee(X,A,b.id),onDragEnd:_,onDragOver:X=>L(X,b.id),onDrop:X=>F(X,A,b.id),style:{opacity:h===b.id?.3:void 0},children:[s.jsx(jt,{name:b.icon||"apps_add_in",size:16}),s.jsx(q,{size:200,children:ce(b.label,f)}),W(b)&&s.jsx(ae,{size:"extra-small",appearance:"outline",color:"informative",children:qn[b.kind]}),b.menu&&s.jsx(gt,{fontSize:12,"aria-label":"Has a menu"}),b.hidden&&s.jsx(Ye,{fontSize:12,"aria-hidden":!0}),b.custom&&s.jsx(ae,{size:"extra-small",color:"brand",appearance:"tint","aria-label":"Custom",children:"NEW"}),s.jsx(Gi,{overrides:H.overrides.get(b.id),appNames:k}),N(b)&&s.jsx("span",{className:n.lockIcon,title:"OOB global command bar buttons cannot be customized.",children:s.jsx(wt,{fontSize:12})})]})})]},b.id)),H.placement.trailing.map(j)]}),s.jsx("div",{className:n.trailingControls,children:(()=>{const b=e.groups[0];return b?s.jsx(ke,{content:`Add a new button to "${v(b.label,b.id)}"`,relationship:"label",children:s.jsxs("button",{type:"button",className:n.overflowBtn,onClick:()=>y(b.id),"aria-label":"Add a new button",children:[s.jsx(Te,{fontSize:14})," Add"]})}):s.jsx(ke,{content:'No groups in this tab yet. Switch to "Classic ribbon" view to add a group first.',relationship:"label",children:s.jsxs("button",{type:"button",className:n.overflowBtn,disabled:!0,children:[s.jsx(Te,{fontSize:14})," Add"]})})})()})]}),$&&s.jsxs(Fo,{open:!0,onOpenChange:(b,A)=>!A.open&&R(null),positioning:{position:"below",align:"start",target:{getBoundingClientRect:()=>({x:$.x,y:$.y,top:$.y,left:$.x,right:$.x,bottom:$.y,width:0,height:0,toJSON:()=>({})})}},children:[s.jsx(_o,{disableButtonEnhancement:!0,children:s.jsx("span",{style:{display:"none"}})}),s.jsx(qo,{children:s.jsxs(Ho,{children:[N($.button)&&s.jsx(pe,{disabled:!0,children:"OOB global command bar buttons cannot be customized."}),N($.button)&&s.jsx(pt,{}),s.jsx(pe,{icon:s.jsx(no,{}),onClick:()=>{i(t,e.id,$.groupId,$.button.id),R(null)},children:"Edit properties"}),s.jsx(pe,{icon:s.jsx(Pn,{}),disabled:N($.button)||W($.button),onClick:()=>{i(t,e.id,$.groupId,$.button.id),x(),R(null)},children:"Change icon…"}),s.jsx(pe,{icon:s.jsx(mr,{}),disabled:N($.button)||W($.button),onClick:()=>{g($.button.id),R(null)},children:"Edit labels…"}),s.jsx(pt,{}),$.button.hidden?s.jsx(pe,{icon:s.jsx(Ct,{}),disabled:N($.button),onClick:()=>{u(t,e.id,$.groupId,$.button.id,{hidden:!1}),R(null)},children:"Show button"}):s.jsx(pe,{icon:s.jsx(Ye,{}),disabled:N($.button),onClick:()=>{$.button.oob?T($):u(t,e.id,$.groupId,$.button.id,{hidden:!0}),R(null)},children:"Hide button"}),($.button.origin==="oob"||$.button.origin==="managed")&&s.jsx(pe,{icon:s.jsx(Pt,{}),disabled:N($.button)||W($.button),onClick:()=>{p(t,e.id,$.groupId,$.button.id),R(null)},children:"Create override…"}),s.jsx(Ta,{location:t,tabId:e.id,groupId:$.groupId,button:$.button,onDone:()=>R(null)}),s.jsx(pt,{}),s.jsx(pe,{icon:s.jsx(mn,{}),disabled:N($.button),onClick:()=>{c(t,e.id,$.groupId,$.button.id),R(null)},children:"Duplicate"}),In($.button,a[t])&&s.jsx(pe,{icon:s.jsx(Lt,{}),disabled:N($.button),onClick:()=>{l(t,e.id,$.groupId,$.button.id),R(null)},children:"Delete"}),ka(e,$.groupId,$.button.id,f,S).map(b=>s.jsxs(pe,{icon:s.jsx(pr,{}),disabled:N($.button),onClick:()=>{const A=r({groupId:$.groupId,buttonId:$.button.id,tabId:e.id,location:t},{groupId:b.groupId,tabId:e.id,location:t});A&&i(t,e.id,b.groupId,A),R(null)},children:["Move to: ",b.text]},b.groupId))]})})]}),B&&s.jsx(Pi,{open:!0,buttonLabel:ce(B.button.label,f),onConfirmHide:()=>{d(t,e.id,B.groupId,B.button.id),T(null)},commandId:B.button.commandId,onConfirmDisplayRule:()=>{D.getState().hideWithDisplayRules(B.button.commandId),T(null)},onCancel:()=>T(null)})]})}const lg=e=>(Ru({...e,renderRow:()=>null}),e),Va=M.createContext(void 0),cg=void 0,dg=()=>{var e;return(e=M.useContext(Va))!=null?e:cg},ug=Va.Provider,Ja=M.createContext({current:null}),mg={current:null},Ka=()=>{var e;return(e=M.useContext(Ja))!=null?e:mg},pg=Ja.Provider,Ya=M.createContext({current:null}),fg={current:null},Za=()=>{var e;return(e=M.useContext(Ya))!=null?e:fg},hg=Ya.Provider,gg=(e,t)=>{const{height:n,itemSize:o,width:i="100%",ariaRowIndexStart:r=2,children:l,listProps:a}=e,c=Ka(),d=Za(),p=ju({...e,children:l},t),f=M.useCallback(({data:x,index:g,style:y,isScrolling:C})=>{const w=x[g];return M.createElement(ug,{value:r+g},M.createElement(Nu,{value:w.rowId},l(w,y,g,C)))},[r,l]),S=M.useCallback(()=>{c.current&&d.current&&d.current.scroll({left:c.current.scrollLeft,behavior:"instant"})},[]),v=M.useCallback(x=>{var g;(g=c.current)==null||g.removeEventListener("scroll",S),c.current=x,x&&x.addEventListener("scroll",S)},[]);return{...p,itemSize:o,height:n,virtualizedRow:f,width:i,ariaRowIndexStart:r,listProps:a,outerRef:v}};function hi(){return hi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)({}).hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},hi.apply(null,arguments)}function zs(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function gi(e,t){return gi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},gi(e,t)}function bg(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,gi(e,t)}var Bs=Number.isNaN||function(t){return typeof t=="number"&&t!==t};function yg(e,t){return!!(e===t||Bs(e)&&Bs(t))}function xg(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(!yg(e[n],t[n]))return!1;return!0}function Oo(e,t){t===void 0&&(t=xg);var n,o=[],i,r=!1;function l(){for(var a=[],c=0;c<arguments.length;c++)a[c]=arguments[c];return r&&n===this&&t(a,o)||(i=e.apply(this,a),r=!0,n=this,o=a),i}return l}var Sg=typeof performance=="object"&&typeof performance.now=="function",Os=Sg?function(){return performance.now()}:function(){return Date.now()};function Es(e){cancelAnimationFrame(e.id)}function vg(e,t){var n=Os();function o(){Os()-n>=t?e.call(null):i.id=requestAnimationFrame(o)}var i={id:requestAnimationFrame(o)};return i}var Eo=-1;function Ms(e){if(e===void 0&&(e=!1),Eo===-1||e){var t=document.createElement("div"),n=t.style;n.width="50px",n.height="50px",n.overflow="scroll",document.body.appendChild(t),Eo=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return Eo}var Dt=null;function Ls(e){if(e===void 0&&(e=!1),Dt===null||e){var t=document.createElement("div"),n=t.style;n.width="50px",n.height="50px",n.overflow="scroll",n.direction="rtl";var o=document.createElement("div"),i=o.style;return i.width="100px",i.height="100px",t.appendChild(o),document.body.appendChild(t),t.scrollLeft>0?Dt="positive-descending":(t.scrollLeft=1,t.scrollLeft===0?Dt="negative":Dt="positive-ascending"),document.body.removeChild(t),Dt}return Dt}var Cg=150,wg=function(t,n){return t};function Ig(e){var t,n=e.getItemOffset,o=e.getEstimatedTotalSize,i=e.getItemSize,r=e.getOffsetForIndexAndAlignment,l=e.getStartIndexForOffset,a=e.getStopIndexForStartIndex,c=e.initInstanceProps,d=e.shouldResetStyleCacheOnItemSizeChange,u=e.validateProps;return t=(function(p){bg(f,p);function f(v){var x;return x=p.call(this,v)||this,x._instanceProps=c(x.props,zs(x)),x._outerRef=void 0,x._resetIsScrollingTimeoutId=null,x.state={instance:zs(x),isScrolling:!1,scrollDirection:"forward",scrollOffset:typeof x.props.initialScrollOffset=="number"?x.props.initialScrollOffset:0,scrollUpdateWasRequested:!1},x._callOnItemsRendered=void 0,x._callOnItemsRendered=Oo(function(g,y,C,w){return x.props.onItemsRendered({overscanStartIndex:g,overscanStopIndex:y,visibleStartIndex:C,visibleStopIndex:w})}),x._callOnScroll=void 0,x._callOnScroll=Oo(function(g,y,C){return x.props.onScroll({scrollDirection:g,scrollOffset:y,scrollUpdateWasRequested:C})}),x._getItemStyle=void 0,x._getItemStyle=function(g){var y=x.props,C=y.direction,w=y.itemSize,h=y.layout,I=x._getItemStyleCache(d&&w,d&&h,d&&C),$;if(I.hasOwnProperty(g))$=I[g];else{var R=n(x.props,g,x._instanceProps),B=i(x.props,g,x._instanceProps),T=C==="horizontal"||h==="horizontal",H=C==="rtl",k=T?R:0;I[g]=$={position:"absolute",left:H?void 0:k,right:H?k:void 0,top:T?0:R,height:T?"100%":B,width:T?B:"100%"}}return $},x._getItemStyleCache=void 0,x._getItemStyleCache=Oo(function(g,y,C){return{}}),x._onScrollHorizontal=function(g){var y=g.currentTarget,C=y.clientWidth,w=y.scrollLeft,h=y.scrollWidth;x.setState(function(I){if(I.scrollOffset===w)return null;var $=x.props.direction,R=w;if($==="rtl")switch(Ls()){case"negative":R=-w;break;case"positive-descending":R=h-C-w;break}return R=Math.max(0,Math.min(R,h-C)),{isScrolling:!0,scrollDirection:I.scrollOffset<R?"forward":"backward",scrollOffset:R,scrollUpdateWasRequested:!1}},x._resetIsScrollingDebounced)},x._onScrollVertical=function(g){var y=g.currentTarget,C=y.clientHeight,w=y.scrollHeight,h=y.scrollTop;x.setState(function(I){if(I.scrollOffset===h)return null;var $=Math.max(0,Math.min(h,w-C));return{isScrolling:!0,scrollDirection:I.scrollOffset<$?"forward":"backward",scrollOffset:$,scrollUpdateWasRequested:!1}},x._resetIsScrollingDebounced)},x._outerRefSetter=function(g){var y=x.props.outerRef;x._outerRef=g,typeof y=="function"?y(g):y!=null&&typeof y=="object"&&y.hasOwnProperty("current")&&(y.current=g)},x._resetIsScrollingDebounced=function(){x._resetIsScrollingTimeoutId!==null&&Es(x._resetIsScrollingTimeoutId),x._resetIsScrollingTimeoutId=vg(x._resetIsScrolling,Cg)},x._resetIsScrolling=function(){x._resetIsScrollingTimeoutId=null,x.setState({isScrolling:!1},function(){x._getItemStyleCache(-1,null)})},x}f.getDerivedStateFromProps=function(x,g){return Rg(x,g),u(x),null};var S=f.prototype;return S.scrollTo=function(x){x=Math.max(0,x),this.setState(function(g){return g.scrollOffset===x?null:{scrollDirection:g.scrollOffset<x?"forward":"backward",scrollOffset:x,scrollUpdateWasRequested:!0}},this._resetIsScrollingDebounced)},S.scrollToItem=function(x,g){g===void 0&&(g="auto");var y=this.props,C=y.itemCount,w=y.layout,h=this.state.scrollOffset;x=Math.max(0,Math.min(x,C-1));var I=0;if(this._outerRef){var $=this._outerRef;w==="vertical"?I=$.scrollWidth>$.clientWidth?Ms():0:I=$.scrollHeight>$.clientHeight?Ms():0}this.scrollTo(r(this.props,x,g,h,this._instanceProps,I))},S.componentDidMount=function(){var x=this.props,g=x.direction,y=x.initialScrollOffset,C=x.layout;if(typeof y=="number"&&this._outerRef!=null){var w=this._outerRef;g==="horizontal"||C==="horizontal"?w.scrollLeft=y:w.scrollTop=y}this._callPropsCallbacks()},S.componentDidUpdate=function(){var x=this.props,g=x.direction,y=x.layout,C=this.state,w=C.scrollOffset,h=C.scrollUpdateWasRequested;if(h&&this._outerRef!=null){var I=this._outerRef;if(g==="horizontal"||y==="horizontal")if(g==="rtl")switch(Ls()){case"negative":I.scrollLeft=-w;break;case"positive-ascending":I.scrollLeft=w;break;default:var $=I.clientWidth,R=I.scrollWidth;I.scrollLeft=R-$-w;break}else I.scrollLeft=w;else I.scrollTop=w}this._callPropsCallbacks()},S.componentWillUnmount=function(){this._resetIsScrollingTimeoutId!==null&&Es(this._resetIsScrollingTimeoutId)},S.render=function(){var x=this.props,g=x.children,y=x.className,C=x.direction,w=x.height,h=x.innerRef,I=x.innerElementType,$=x.innerTagName,R=x.itemCount,B=x.itemData,T=x.itemKey,H=T===void 0?wg:T,k=x.layout,P=x.outerElementType,j=x.outerTagName,E=x.style,N=x.useIsScrolling,W=x.width,U=this.state.isScrolling,V=C==="horizontal"||k==="horizontal",ee=V?this._onScrollHorizontal:this._onScrollVertical,_=this._getRangeToRender(),L=_[0],O=_[1],F=[];if(R>0)for(var b=L;b<=O;b++)F.push(M.createElement(g,{data:B,key:H(b,B),index:b,isScrolling:N?U:void 0,style:this._getItemStyle(b)}));var A=o(this.props,this._instanceProps);return M.createElement(P||j||"div",{className:y,onScroll:ee,ref:this._outerRefSetter,style:hi({position:"relative",height:w,width:W,overflow:"auto",WebkitOverflowScrolling:"touch",willChange:"transform",direction:C},E)},M.createElement(I||$||"div",{children:F,ref:h,style:{height:V?"100%":A,pointerEvents:U?"none":void 0,width:V?A:"100%"}}))},S._callPropsCallbacks=function(){if(typeof this.props.onItemsRendered=="function"){var x=this.props.itemCount;if(x>0){var g=this._getRangeToRender(),y=g[0],C=g[1],w=g[2],h=g[3];this._callOnItemsRendered(y,C,w,h)}}if(typeof this.props.onScroll=="function"){var I=this.state,$=I.scrollDirection,R=I.scrollOffset,B=I.scrollUpdateWasRequested;this._callOnScroll($,R,B)}},S._getRangeToRender=function(){var x=this.props,g=x.itemCount,y=x.overscanCount,C=this.state,w=C.isScrolling,h=C.scrollDirection,I=C.scrollOffset;if(g===0)return[0,0,0,0];var $=l(this.props,I,this._instanceProps),R=a(this.props,$,I,this._instanceProps),B=!w||h==="backward"?Math.max(1,y):1,T=!w||h==="forward"?Math.max(1,y):1;return[Math.max(0,$-B),Math.max(0,Math.min(g-1,R+T)),$,R]},f})(M.PureComponent),t.defaultProps={direction:"ltr",itemData:void 0,layout:"vertical",overscanCount:2,useIsScrolling:!1},t}var Rg=function(t,n){t.children,t.direction,t.height,t.layout,t.innerTagName,t.outerTagName,t.width,n.instance},jg=Ig({getItemOffset:function(t,n){var o=t.itemSize;return n*o},getItemSize:function(t,n){var o=t.itemSize;return o},getEstimatedTotalSize:function(t){var n=t.itemCount,o=t.itemSize;return o*n},getOffsetForIndexAndAlignment:function(t,n,o,i,r,l){var a=t.direction,c=t.height,d=t.itemCount,u=t.itemSize,p=t.layout,f=t.width,S=a==="horizontal"||p==="horizontal",v=S?f:c,x=Math.max(0,d*u-v),g=Math.min(x,n*u),y=Math.max(0,n*u-v+u+l);switch(o==="smart"&&(i>=y-v&&i<=g+v?o="auto":o="center"),o){case"start":return g;case"end":return y;case"center":{var C=Math.round(y+(g-y)/2);return C<Math.ceil(v/2)?0:C>x+Math.floor(v/2)?x:C}default:return i>=y&&i<=g?i:i<y?y:g}},getStartIndexForOffset:function(t,n){var o=t.itemCount,i=t.itemSize;return Math.max(0,Math.min(o-1,Math.floor(n/i)))},getStopIndexForStartIndex:function(t,n,o){var i=t.direction,r=t.height,l=t.itemCount,a=t.itemSize,c=t.layout,d=t.width,u=i==="horizontal"||c==="horizontal",p=n*a,f=u?d:r,S=Math.ceil((f+o-p)/a);return Math.max(0,Math.min(l-1,n+S-1))},initInstanceProps:function(t){},shouldResetStyleCacheOnItemSizeChange:!0,validateProps:function(t){t.itemSize}});const Ng=e=>{const{slots:t,slotProps:n}=$u(e),{dir:o}=fr();return M.createElement(t.root,n.root,M.createElement(jg,{itemSize:e.itemSize,width:e.width,itemData:e.rows,height:e.height,itemCount:e.rows.length,direction:o,outerRef:e.outerRef,...e.listProps},e.virtualizedRow))},Wi=M.forwardRef((e,t)=>{const n=gg(e,t);return lg(n),Ng(n)});Wi.displayName="DataGridBody";const $g=(e,t)=>{var n;const{targetDocument:o}=fr(),i=Tu({targetDocument:o}),r=M.useRef(null),l=M.useRef(null);let a=e.containerWidthOffset;a===void 0&&(a=e.selectionMode?-44:0,a-=i||0);const c=ku({...e,"aria-rowcount":e.items.length,containerWidthOffset:a},t);return e.resizableColumns&&((n=e.resizableColumnsOptions)==null?void 0:n.autoFitColumns)===!1&&c.root.style&&(c.root.style.minWidth="auto"),{...c,headerRef:r,bodyRef:l}},Tg=(e,t)=>M.createElement(hg,{value:e.headerRef},M.createElement(pg,{value:e.bodyRef},Au(e,t))),Ui=M.forwardRef((e,t)=>{const n=$g(e,t);return Du(n),Tg(n,zu(n))});Ui.displayName="DataGrid";const kg=(e,t)=>{const n=dg();return Bu({...e,"aria-rowindex":n},t)},Ag=le({root:{minWidth:"fit-content"}}),Dg=e=>{const t=Ag();return e.root.className=Ft(t.root,e.root.className),Ou(e),e},vn=M.forwardRef((e,t)=>{const n=kg(e,t);return Dg(n),Eu(n)});vn.displayName="DataGridRow";const zg=(e,t)=>{const n=Ka(),o=Za(),i=M.useCallback(()=>{n.current&&o.current&&n.current.scroll({left:o.current.scrollLeft,behavior:"instant"})},[]),r=M.useCallback(a=>{var c;(c=o.current)==null||c.removeEventListener("scroll",i),o.current=a,a&&a.addEventListener("scroll",i)},[]),l=Mu(e,t);return l.root.ref=Lu(l.root.ref,r),l},Bg=le({root:{overflowX:"auto",scrollbarWidth:"none","::-webkit-scrollbar":{width:0,height:0}}}),Og=e=>{const t=Bg();return e.root.className=Ft(t.root,e.root.className),Pu(e),e},Xi=M.forwardRef((e,t)=>{const n=zg(e,t);return Og(n),Fu(n)});Xi.displayName="DataGridHeader";const Eg=le({root:{marginTop:m.spacingVerticalM,display:"flex",flexDirection:"column",gap:m.spacingVerticalXS},header:{display:"flex",alignItems:"center",gap:m.spacingHorizontalS},row:{cursor:"pointer",backgroundColor:m.colorPaletteBerryBackground1,":hover":{backgroundColor:m.colorPaletteBerryBackground2}},rowSelected:{backgroundColor:m.colorPaletteBerryBackground2,outline:`1px solid ${m.colorPaletteBerryBorderActive}`},hidden:{opacity:.55,textDecoration:"line-through"},mono:{fontFamily:m.fontFamilyMonospace,color:m.colorNeutralForeground3}}),Mg={button:"command",dropdown:"dropdown",split:"split",group:"group"};function Lg({tab:e,location:t}){const n=Eg(),{nodes:o}=Hi(t,e),i=Zt(),r=ge(u=>u.selectedCommandId),l=ge(u=>u.selectCommand),a=Z(u=>u.selectedButtonId);if(o.length===0)return null;const c=[],d=(u,p)=>{for(const f of u)c.push({node:f,depth:p}),d(f.children,p+1)};return d(o,0),s.jsxs("section",{className:n.root,"aria-label":"Modern commands",children:[s.jsxs("div",{className:n.header,children:[s.jsx(q,{weight:"semibold",size:200,children:"Modern commands"}),s.jsx(ae,{size:"small",appearance:"tint",color:"important",children:"read-only"}),s.jsx(q,{size:100,style:{color:m.colorNeutralForeground3},children:"Built with the command designer (appaction). Edit them in the command designer."})]}),s.jsxs(_u,{size:"small","aria-label":"Modern commands (read-only)",children:[s.jsx(qu,{children:s.jsxs(Ki,{children:[s.jsx($t,{style:{width:56},children:"#"}),s.jsx($t,{children:"Label"}),s.jsx($t,{children:"App"}),s.jsx($t,{children:"Location"}),s.jsx($t,{style:{width:90},children:"Type"}),s.jsx($t,{children:"Unique name"})]})}),s.jsx(Hu,{children:c.map(({node:u,depth:p})=>{const f=u.command,S=r===f.id&&!a;return s.jsxs(Ki,{className:Ft(n.row,S&&n.rowSelected),"aria-selected":S,tabIndex:0,onClick:()=>l(f.id),onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),l(f.id))},children:[s.jsx(Tt,{children:f.sequence}),s.jsx(Tt,{children:s.jsx(ke,{content:s.jsx(Xa,{node:u,appNames:i}),relationship:"description",children:s.jsxs("span",{className:f.hidden||f.disabled?n.hidden:void 0,style:{paddingLeft:p*16,display:"inline-flex",gap:4,alignItems:"center"},children:[f.label,f.hidden&&s.jsx(Ye,{fontSize:12,"aria-label":"hidden"}),s.jsx(ae,{size:"extra-small",appearance:"tint",color:"important",children:"Modern"})]})})}),s.jsx(Tt,{children:xn(f,i)}),s.jsx(Tt,{children:Ba[f.location]??f.location}),s.jsx(Tt,{children:s.jsx(ae,{size:"small",appearance:"outline",children:Mg[f.type]})}),s.jsx(Tt,{children:s.jsx("span",{className:n.mono,title:f.uniqueName,children:f.uniqueName})})]},f.id)})})]})]})}const Pg=le({root:{width:"100%"},gridWrap:{height:"min(560px, calc(100vh - 320px))",minHeight:"260px"},row:{cursor:"pointer",":hover":{backgroundColor:m.colorNeutralBackground3}},rowSelected:{backgroundColor:m.colorBrandBackground2},iconCell:{width:"20px",height:"20px",borderRadius:"3px",backgroundColor:m.colorNeutralBackground4,display:"flex",alignItems:"center",justifyContent:"center",fontSize:m.fontSizeBase100,color:m.colorNeutralForeground3},clip:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"100%"}});function Fg({tab:e,location:t}){const n=Pg(),o=Z(y=>y.selectedButtonId),i=Z(y=>y.selectButtonInContext),r=D(y=>y.setButtonProp),l=D(y=>y.locLabels),a=D(y=>y.baseLanguageCode),c=y=>t==="Application"&&e.id==="Mscrm.GlobalTab"&&y.oob&&!y.custom,[d,u]=M.useState(""),{overrides:p}=Hi(t,e),f=Zt(),S=e.groups.flatMap(y=>y.buttons.map(C=>({button:C,label:ce(C.label,l),groupId:y.id,groupLabel:ce(y.label,l,a)}))),v=M.useMemo(()=>{const y=d.toLowerCase().trim();return y?S.filter(({button:C,label:w,groupLabel:h})=>C.id.toLowerCase().includes(y)||C.label.toLowerCase().includes(y)||w.toLowerCase().includes(y)||(C.commandId??"").toLowerCase().includes(y)||h.toLowerCase().includes(y)):S},[S,d]),x={seq:{defaultWidth:56,minWidth:48,idealWidth:56},icon:{defaultWidth:48,minWidth:40,idealWidth:48},label:{defaultWidth:260,minWidth:140,idealWidth:260},id:{defaultWidth:280,minWidth:160,idealWidth:280},kind:{defaultWidth:90,minWidth:72,idealWidth:90},group:{defaultWidth:160,minWidth:100,idealWidth:160},command:{defaultWidth:280,minWidth:160,idealWidth:280},visible:{defaultWidth:80,minWidth:64,idealWidth:80}},g=[rt({columnId:"seq",renderHeaderCell:()=>s.jsx(q,{size:200,weight:"semibold",children:"#"}),renderCell:({button:y})=>s.jsx(q,{size:200,children:y.sequence})}),rt({columnId:"icon",renderHeaderCell:()=>s.jsx(q,{size:200,weight:"semibold",children:"Icon"}),renderCell:({button:y})=>s.jsx("div",{className:n.iconCell,children:s.jsx(jt,{name:y.icon||"apps_add_in",size:16})})}),rt({columnId:"label",renderHeaderCell:()=>s.jsx(q,{size:200,weight:"semibold",children:"Label"}),renderCell:({button:y,label:C})=>s.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4,minWidth:0},children:[s.jsx(q,{size:200,className:n.clip,title:C,children:C}),s.jsx(Gi,{overrides:p.get(y.id),appNames:f})]})}),rt({columnId:"id",renderHeaderCell:()=>s.jsx(q,{size:200,weight:"semibold",children:"ID"}),renderCell:({button:y})=>s.jsx(q,{size:200,font:"monospace",className:n.clip,title:y.id,style:{color:m.colorNeutralForeground3},children:y.id})}),rt({columnId:"kind",renderHeaderCell:()=>s.jsx(q,{size:200,weight:"semibold",children:"Kind"}),renderCell:({button:y})=>s.jsx(ae,{size:"small",appearance:"outline",children:y.kind})}),rt({columnId:"group",renderHeaderCell:()=>s.jsx(q,{size:200,weight:"semibold",children:"Group"}),renderCell:({groupLabel:y})=>s.jsx(q,{size:200,className:n.clip,title:y,children:y})}),rt({columnId:"command",renderHeaderCell:()=>s.jsx(q,{size:200,weight:"semibold",children:"Command"}),renderCell:({button:y})=>s.jsx(q,{size:200,font:"monospace",className:n.clip,title:y.commandId||"",style:{color:m.colorNeutralForeground3},children:y.commandId||"—"})}),rt({columnId:"visible",renderHeaderCell:()=>s.jsx(q,{size:200,weight:"semibold",children:"Visible"}),renderCell:({button:y,label:C,groupId:w})=>s.jsx(yi,{checked:!y.hidden,label:y.hidden?s.jsx(Ye,{fontSize:14}):void 0,disabled:c(y),title:c(y)?"OOB global command bar buttons cannot be customized.":void 0,"aria-label":`Toggle visibility of ${C}`,onChange:(h,I)=>r(t,e.id,w,y.id,{hidden:!I.checked})})})];return s.jsxs("div",{className:n.root,children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:m.spacingHorizontalS,padding:`${m.spacingVerticalXS} 0`},children:[s.jsx(_e,{size:"small",contentBefore:s.jsx(ft,{}),placeholder:`Filter ${S.length} button${S.length!==1?"s":""}…`,value:d,onChange:(y,C)=>u(C.value),style:{minWidth:0,flex:1,maxWidth:480}}),d&&s.jsxs(q,{size:100,style:{color:m.colorNeutralForeground3},children:[v.length," match",v.length!==1?"es":""]})]}),s.jsxs(Ui,{className:n.gridWrap,items:v,columns:g,columnSizingOptions:x,resizableColumns:!0,getRowId:y=>y.button.id,focusMode:"composite",sortable:!0,selectionMode:"single",selectedItems:o?new Set([o]):new Set,onSelectionChange:(y,C)=>{const w=[...C.selectedItems][0],h=v.find(I=>I.button.id===w);h&&i(t,e.id,h.groupId,h.button.id)},children:[s.jsx(Xi,{children:s.jsx(vn,{children:({renderHeaderCell:y})=>s.jsx(hr,{children:y()})})}),s.jsx(Wi,{itemSize:42,height:420,listProps:{width:"100%"},children:({item:y,rowId:C},w)=>s.jsx(vn,{style:w,className:o===y.button.id?n.rowSelected:n.row,children:({renderCell:h})=>s.jsx(gr,{children:h(y)})},C)})]}),s.jsx(Lg,{tab:e,location:t})]})}const Qa=le({root:{marginTop:m.spacingVerticalM,border:`1px solid ${m.colorNeutralStroke2}`,borderRadius:m.borderRadiusMedium,backgroundColor:m.colorNeutralBackground1,maxWidth:"520px"},header:{display:"flex",alignItems:"center",gap:m.spacingHorizontalS,padding:`${m.spacingVerticalS} ${m.spacingHorizontalM}`,borderBottom:`1px solid ${m.colorNeutralStroke2}`},spacer:{flex:1},body:{display:"flex",flexDirection:"column",gap:m.spacingVerticalS,padding:m.spacingHorizontalS},section:{display:"flex",flexDirection:"column",gap:"2px"},sectionHeader:{display:"flex",alignItems:"center",gap:m.spacingHorizontalXS,padding:`2px ${m.spacingHorizontalXS}`,color:m.colorNeutralForeground3},item:{display:"flex",alignItems:"center",gap:m.spacingHorizontalS,width:"100%",minHeight:"28px",padding:`0 ${m.spacingHorizontalS}`,border:"1px solid transparent",borderRadius:m.borderRadiusMedium,backgroundColor:"transparent",color:m.colorNeutralForeground1,cursor:"pointer",textAlign:"left",":hover":{backgroundColor:m.colorNeutralBackground3},":focus-visible":{outline:`2px solid ${m.colorBrandStroke1}`}},itemSelected:{backgroundColor:m.colorBrandBackground2,border:`1px solid ${m.colorBrandStroke1}`},itemHidden:{opacity:.45,textDecoration:"line-through"},itemRow:{display:"flex",alignItems:"center",gap:"2px"},nested:{marginLeft:m.spacingHorizontalL,paddingLeft:m.spacingHorizontalS,borderLeft:`1px dashed ${m.colorNeutralStroke2}`},empty:{padding:`2px ${m.spacingHorizontalS}`,color:m.colorNeutralForeground3}});function _g({tab:e,location:t}){const n=Qa(),o=Z(I=>I.selectedButtonId),i=Z(I=>I.selectedGroupId),r=Z(I=>I.selectButtonInContext),l=D(I=>I.baseline),a=D(I=>I.locLabels),c=D(I=>I.addMenuSection),d=D(I=>I.setMenuSectionProp),u=D(I=>I.deleteMenuSection),{overrides:p}=qi(t),f=Zt(),S=e.groups.find(I=>I.id===i),v=Xm(S,o),x=M.useMemo(()=>{const I=new Set;for(const $ of l[t]?.tabs??[])for(const R of $.groups)for(const B of je(R))I.add(B.id);return I},[l,t]);if(!S||!v||!v.menu&&!Ot(v.kind))return null;const g=S.id,y=I=>ce(I.label,a),C=I=>I.source?.attributes.PopulateDynamically?.toLowerCase()==="true"?I.source.attributes.PopulateQueryCommand??"a command":null,w=I=>{const $=[...I.menu?.sections??[]].sort((T,H)=>T.sequence-H.sequence),R=!x.has(I.id),B=C(I);return s.jsxs(s.Fragment,{children:[B&&s.jsxs(Oe,{className:n.empty,children:["Populated when the menu opens, by ",B,". Static items below are kept as they are."]}),$.map(T=>s.jsx(qg,{section:T,parent:I,editable:R,onTitle:H=>d(t,e.id,g,I.id,T.id,{title:H}),onDisplayMode:H=>d(t,e.id,g,I.id,T.id,{displayMode:H}),onDelete:()=>u(t,e.id,g,I.id,T.id),renderItem:h},T.id)),$.length===0&&!B&&s.jsx(Oe,{className:n.empty,children:"No menu sections yet."}),R&&s.jsx("div",{children:s.jsx(K,{size:"small",appearance:"subtle",icon:s.jsx(Te,{}),onClick:()=>c(t,e.id,g,I.id,""),children:"Add section"})})]})},h=I=>{const $=I.id===o,R=p.get(I.id);return s.jsxs("div",{children:[s.jsxs("div",{className:n.itemRow,children:[s.jsxs("button",{type:"button",className:[n.item,$?n.itemSelected:"",I.hidden?n.itemHidden:""].filter(Boolean).join(" "),"aria-pressed":$,"aria-label":`Menu item ${y(I)}${I.hidden?" — hidden":""}${Fa(R,f)}`,onClick:()=>r(t,e.id,g,I.id),children:[s.jsx(jt,{name:I.icon||"apps_add_in",size:16}),s.jsx(q,{size:200,children:y(I)}),I.menu&&s.jsx(gt,{fontSize:12,"aria-hidden":!0}),s.jsx(Gi,{overrides:R,appNames:f}),I.custom&&!x.has(I.id)&&s.jsx(ae,{size:"extra-small",color:"brand",appearance:"tint",children:"NEW"})]}),$&&s.jsx(Gg,{item:I,location:t,tabId:e.id,groupId:g,onDeleted:()=>r(t,e.id,g,v.id)})]}),I.menu&&s.jsx("div",{className:n.nested,children:w(I)})]},I.id)};return s.jsxs("section",{className:n.root,"aria-label":`Menu of ${y(v)}`,children:[s.jsxs("div",{className:n.header,children:[s.jsx(gt,{"aria-hidden":!0}),s.jsx(q,{weight:"semibold",size:300,children:y(v)}),s.jsx(ae,{size:"small",appearance:"outline",children:v.kind==="splitButton"?"Split button menu":"Flyout menu"}),s.jsx("span",{className:n.spacer}),s.jsxs(Oe,{children:[vt(v).length," item(s)"]})]}),s.jsx("div",{className:n.body,children:w(v)})]})}function qg({section:e,parent:t,editable:n,onTitle:o,onDisplayMode:i,onDelete:r,renderItem:l}){const a=Qa(),c=D(u=>u.locLabels),d=[...e.controls].sort((u,p)=>u.sequence-p.sequence);return s.jsxs("div",{className:a.section,children:[s.jsx("div",{className:a.sectionHeader,children:n?s.jsxs(s.Fragment,{children:[s.jsx(_e,{size:"small",placeholder:"Section title (optional)",value:e.title??"","aria-label":"Menu section title",onChange:(u,p)=>o(p.value)}),s.jsxs(dt,{size:"small","aria-label":"Menu section display mode",value:e.displayMode??"Menu16",onChange:(u,p)=>i(p.value),children:[s.jsx("option",{value:"Menu16",children:"16 px icons"}),s.jsx("option",{value:"Menu32",children:"32 px icons"}),s.jsx("option",{value:"Menu",children:"Text only"})]}),s.jsx(ke,{content:"Delete section and its items",relationship:"label",children:s.jsx(K,{size:"small",appearance:"subtle",icon:s.jsx(Lt,{}),onClick:r})})]}):s.jsx(Oe,{children:ce(e.title,c)||e.id})}),d.map(u=>l(u)),e.rawContent!==void 0&&s.jsx(Oe,{className:a.empty,children:"Gallery / dynamic content (kept as is)"}),(e.rawControls?.length??0)>0&&s.jsxs(Oe,{className:a.empty,children:[e.rawControls.length," other control(s) CBS doesn't edit (kept as they are)"]}),e.rawContent===void 0&&s.jsx(Hg,{parent:t,section:e})]})}function Hg({parent:e,section:t}){const n=Z(f=>f.location),o=Z(f=>f.tabId),i=Z(f=>f.selectedGroupId),r=Z(f=>f.selectButtonInContext),l=D(f=>f.addMenuItem),a=D(f=>f.upsertCommand),c=ie(f=>f.activeSolution),d=ie(f=>f.publisherPrefix),u=ie(f=>f.activeEntity),p=()=>{if(!i)return;const{ribbons:f,commands:S}=D.getState(),v=new Set(S.map(C=>C.id));for(const C of Object.values(f))for(const w of C.tabs)for(const h of w.groups)for(const I of je(h))v.add(I.id);const x=c?.publisherPrefix?.trim()||d?.trim()||"new",{id:g,commandId:y}=oa(x,u?.logicalName??"global",n,"MenuItem",v);l({location:n,tabId:o,groupId:i,parentId:e.id,sectionId:t.id,item:{id:g,label:"Menu item",commandId:y}}),a({id:y,enableRules:[],displayRules:[],actions:[]}),r(n,o,i,g)};return s.jsx("div",{children:s.jsx(K,{size:"small",appearance:"subtle",icon:s.jsx(Te,{}),onClick:p,children:"Add item"})})}function Gg({item:e,location:t,tabId:n,groupId:o,onDeleted:i}){const r=D(c=>c.setButtonProp),l=D(c=>c.deleteButton),a=D(c=>c.baseline[t]);return s.jsxs(s.Fragment,{children:[s.jsx(ke,{content:e.hidden?"Show item":"Hide item",relationship:"label",children:s.jsx(K,{size:"small",appearance:"subtle",icon:e.hidden?s.jsx(Ct,{}):s.jsx(Ye,{}),onClick:()=>r(t,n,o,e.id,{hidden:!e.hidden})})}),In(e,a)&&s.jsx(ke,{content:"Delete item",relationship:"label",children:s.jsx(K,{size:"small",appearance:"subtle",icon:s.jsx(Lt,{}),onClick:()=>{l(t,n,o,e.id),i()}})})]})}function Wg(){const e=ge(l=>l.status),t=ge(l=>l.apps),n=ge(l=>l.appFilter),o=ge(l=>l.setAppFilter),i=ge(l=>l.commands.length),r=ge(l=>l.error);return e==="idle"?null:e==="loading"?s.jsx(xi,{size:"extra-tiny","aria-label":"Loading modern commands"}):e==="unavailable"?s.jsx(ke,{content:`Modern commands couldn't be read: ${r??"unknown error"}`,relationship:"label",children:s.jsx(q,{size:100,style:{color:m.colorNeutralForeground3},children:"Modern: n/a"})}):s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:m.spacingHorizontalS},children:[s.jsx(q,{size:100,style:{color:m.colorNeutralForeground3},children:"App:"}),s.jsx(ke,{content:`${i} modern command${i===1?"":"s"} for this table (read-only). Pick an app to see its command bar.`,relationship:"description",children:s.jsxs(dt,{value:n,onChange:(l,a)=>o(a.value),size:"small","aria-label":"App for modern commands",style:{height:"26px",width:"170px"},children:[s.jsx("option",{value:"all",children:"All apps"}),t.map(l=>s.jsx("option",{value:l.id,children:l.name},l.id))]})})]})}const Ug=le({root:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden",backgroundColor:m.colorNeutralBackground1},locationRow:{display:"flex",alignItems:"center",gap:0,padding:`0 ${m.spacingHorizontalM}`,borderBottom:`1px solid ${m.colorNeutralStroke2}`,backgroundColor:m.colorNeutralBackground2,flexShrink:0,height:"36px"},locationTab:{height:"36px",padding:`0 ${m.spacingHorizontalM}`,display:"flex",alignItems:"center",gap:m.spacingHorizontalXS,cursor:"pointer",borderBottom:"2px solid transparent",fontSize:m.fontSizeBase200,color:m.colorNeutralForeground2,":hover":{color:m.colorNeutralForeground1,backgroundColor:m.colorNeutralBackground3}},locationTabActive:{color:m.colorBrandForeground1,borderBottomColor:m.colorBrandStroke1,fontWeight:m.fontWeightSemibold},spacer:{flex:1},tabStrip:{display:"flex",alignItems:"center",gap:0,padding:`0 ${m.spacingHorizontalM}`,borderBottom:`1px solid ${m.colorNeutralStroke2}`,backgroundColor:m.colorNeutralBackground1,flexShrink:0,height:"32px"},ribbonTab:{height:"32px",padding:`0 ${m.spacingHorizontalM}`,display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",cursor:"pointer",borderBottom:"2px solid transparent",":hover":{backgroundColor:m.colorNeutralBackground3}},ribbonTabActive:{borderBottomColor:m.colorBrandStroke1},ribbonTabLabel:{fontSize:m.fontSizeBase200,fontWeight:m.fontWeightSemibold,lineHeight:1.2},ribbonTabMeta:{fontSize:m.fontSizeBase100,color:m.colorNeutralForeground3,lineHeight:1.2},addTabBtn:{height:"24px",width:"24px",minWidth:"24px",marginLeft:m.spacingHorizontalXS,borderRadius:m.borderRadiusMedium,border:`1px dashed ${m.colorNeutralStroke2}`,backgroundColor:"transparent",color:m.colorNeutralForeground3,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",":hover":{border:`1px solid ${m.colorNeutralStroke1}`,backgroundColor:m.colorNeutralBackground2}},inlineTabInput:{height:"28px",fontSize:m.fontSizeBase200,fontWeight:m.fontWeightSemibold,minWidth:"60px",maxWidth:"140px"},canvas:{flex:1,overflow:"auto",padding:m.spacingHorizontalM}}),Xg=le({root:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px",gap:m.spacingHorizontalM,color:m.colorNeutralForeground3}}),Vg=[{value:"HomepageGrid",label:"Home Grid",icon:s.jsx(lr,{}),desc:"Mscrm.HomepageGrid.{entity}"},{value:"SubGrid",label:"Sub Grid",icon:s.jsx(mu,{}),desc:"Mscrm.SubGrid.{entity}"},{value:"Form",label:"Form",icon:s.jsx(to,{}),desc:"Mscrm.Form.{entity}"},{value:"Application",label:"Application",icon:s.jsx(cr,{}),desc:"applicationRibbon.xml"}];function Jg({isLoadingRibbon:e=!1,ribbonLoadError:t=null,onRetryRibbonLoad:n}){const o=Ug(),i=Z(O=>O.location),r=Z(O=>O.tabId),l=Z(O=>O.setLocation),a=Z(O=>O.setTabId),c=D(O=>O.ribbons),d=D(O=>O.renameTab),u=D(O=>O.deleteTab),p=D(O=>O.locLabels),f=D(O=>O.baseLanguageCode),S=D(O=>O.baseline),v=D(O=>O.layers),x=D(O=>O.orphans.entity.filter(F=>!O.pendingOrphanDeletes.entity.includes(F.id)&&!F.recentPublish?.published).length),g=Z(O=>O.clearSelection),y=D(O=>O.reorderTabs),C=Y(O=>O.ribbonViewStyle),w=Y(O=>O.setRibbonViewStyle),h=Y(O=>O.openXmlDrawer),I=Y(O=>O.openTabDisplayRules),$=Y(O=>O.openNewGroup),R=Y(O=>O.openNewTab),[B,T]=M.useState(null),[H,k]=M.useState(""),P=M.useRef(null),[j,E]=M.useState(null),N=j?c[i].tabs.find(O=>O.id===j):void 0;M.useEffect(()=>{B&&P.current&&P.current.focus()},[B]);function W(){const O=c[i].tabs.find(F=>F.id===B);O&&H.trim()&&H.trim()!==ce(O.label,p,f)&&d(i,O.id,H.trim()),T(null)}function U(O){return ea(O,S[i],Jn({layers:v},i))}const V=br(_n(xr,{activationConstraint:{distance:5}}),_n(yr)),ee=M.useCallback(O=>{const{active:F,over:b}=O;if(!b||F.id===b.id)return;const A=c[i].tabs.map(me=>me.id),X=A.indexOf(String(F.id)),re=A.indexOf(String(b.id));X<0||re<0||y(i,Zu(A,X,re))},[i,c,y]),_=c[i],L=_.tabs.find(O=>O.id===r)??_.tabs.find(O=>O.id===dn(_.tabs));return M.useEffect(()=>{if(!_.tabs.length)return;if(!_.tabs.some(F=>F.id===r)){const F=dn(_.tabs);F&&a(F)}},[_.tabs,r,a]),s.jsxs("main",{className:o.root,"aria-label":"Ribbon canvas",children:[s.jsxs("div",{className:o.locationRow,role:"tablist","aria-label":"Ribbon location",children:[Vg.map(O=>s.jsxs("div",{role:"tab","aria-selected":i===O.value,className:`${o.locationTab} ${i===O.value?o.locationTabActive:""}`,onClick:()=>{l(O.value);const F=dn(c[O.value].tabs);F&&a(F)},title:O.desc,tabIndex:i===O.value?0:-1,children:[O.icon,s.jsx(q,{size:200,children:O.label})]},O.value)),s.jsx("div",{className:o.spacer}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:m.spacingHorizontalS},children:[s.jsx(Wg,{}),s.jsx(q,{size:100,style:{color:m.colorNeutralForeground3},children:"View as:"}),s.jsxs(dt,{value:C,onChange:(O,F)=>w(F.value),size:"small",style:{height:"26px",width:"170px"},children:[s.jsx("option",{value:"classic",children:"Classic ribbon"}),s.jsx("option",{value:"modern",children:"Modern command bar"}),s.jsx("option",{value:"list",children:"List view"})]}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(Ht,{}),onClick:h,children:"XML"})]})]}),i==="Form"&&s.jsx(Ie,{intent:"info",style:{flexShrink:0},children:s.jsx(Re,{children:"Form ribbon customizations target the legacy web client. On Unified Interface, form commands render in a flat command bar — tab layout and scaling are ignored, but button visibility and command actions work as configured (same behaviour as Ribbon Workbench). Microsoft does not officially support the tabbed ribbon UI on Unified Interface."})}),i==="SubGrid"&&s.jsx(Ie,{intent:"info",style:{flexShrink:0},children:s.jsx(Re,{children:"Subgrid ribbons support only 3 native controls: Add, Show List, and Delete. Their icons cannot be changed."})}),i==="Application"&&s.jsx(Ie,{intent:"info",style:{flexShrink:0},children:s.jsx(Re,{children:"Buttons added to GlobalTab appear in the persistent global command bar at the top of every page. OOB GlobalTab buttons are read-only and cannot be customized."})}),L&&!/^(Mscrm|Microsoft)\./.test(L.id)&&s.jsx(Ie,{intent:"info",style:{flexShrink:0},children:s.jsx(Re,{children:Na})}),L&&po(L.id)&&s.jsx(Ie,{intent:"warning",style:{flexShrink:0},children:s.jsx(Re,{children:"Unified Interface doesn't show this tab's buttons on the command bar, and they don't come back when the table is reloaded. Add buttons to the table's main tab instead."})}),i!=="Application"&&x>0&&s.jsxs(Ie,{intent:"warning",style:{flexShrink:0},children:[s.jsxs(Re,{children:[x," element",x!==1?"s":""," of your customizations for this table",x!==1?" aren't":" isn't"," on the canvas: the ribbon doesn't return"," ",x!==1?"them":"it",". See ",s.jsx("strong",{children:"Orphaned customizations"})," in the Properties pane to delete ",x!==1?"them":"it","."]}),s.jsx(Fn,{children:s.jsx(K,{size:"small",onClick:g,children:"Show"})})]}),s.jsx(Sr,{sensors:V,onDragEnd:ee,children:s.jsx(Qu,{items:_.tabs.map(O=>O.id),strategy:em,children:s.jsxs("div",{className:o.tabStrip,role:"tablist","aria-label":"Ribbon tabs",children:[_.tabs.map(O=>s.jsx(Yg,{tab:O,isActive:L?.id===O.id,isEditing:B===O.id,editValue:H,inputRef:O.id===B?P:void 0,onSelect:()=>{B!==O.id&&a(O.id)},onDoubleClick:()=>{a(O.id),T(O.id),k(ce(O.label,p,f))},onF2:()=>{T(O.id),k(ce(O.label,p,f))},onDelete:L?.id===O.id&&U(O)?()=>E(O.id):void 0,onEditChange:k,onEditCommit:W,onEditCancel:()=>T(null),styles:o},O.id)),s.jsx("button",{type:"button",className:o.addTabBtn,title:"Add tab","aria-label":"Add tab",onClick:R,children:s.jsx(Te,{fontSize:12})}),s.jsx("div",{className:o.spacer}),s.jsxs(K,{appearance:"subtle",size:"small",icon:s.jsx(Ct,{}),onClick:I,children:["Tab rules",L&&L.tabDisplayRules.length>0&&s.jsx(ae,{size:"small",appearance:"tint",color:"brand",style:{marginLeft:4},children:L.tabDisplayRules.length})]})]})})}),s.jsx("div",{className:o.canvas,children:e?s.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:s.jsx(xi,{label:"Loading ribbon definition..."})}):t?s.jsxs(Ie,{intent:"error",children:[s.jsxs(Re,{children:["Failed to load ribbon definition. ",t]}),n&&s.jsx(Fn,{containerAction:s.jsx(K,{appearance:"primary",size:"small",onClick:n,children:"Retry"})})]}):L?s.jsxs(s.Fragment,{children:[C==="classic"?s.jsx($h,{tab:L,location:i}):C==="modern"?s.jsx(ag,{tab:L,location:i}):s.jsx(Fg,{tab:L,location:i}),s.jsx(_g,{tab:L,location:i})]}):s.jsx(Kg,{onAddGroup:$})}),N&&s.jsxs(Fi,{open:!0,title:"Delete tab",confirmLabel:"Delete tab",destructive:!0,onConfirm:()=>{u(i,N.id),E(null)},onCancel:()=>E(null),children:["Delete the tab “",ce(N.label,p,f),"” and its groups and buttons?"]})]})}function Kg({onAddGroup:e}){const t=Xg();return s.jsxs("div",{className:t.root,children:[s.jsx(to,{fontSize:32,style:{opacity:.4}}),s.jsx(q,{size:300,children:"This tab has no groups yet"}),s.jsx(K,{appearance:"primary",size:"small",icon:s.jsx(Te,{}),onClick:e,children:"Add first group"})]})}function Yg({tab:e,isActive:t,isEditing:n,editValue:o,inputRef:i,onSelect:r,onDoubleClick:l,onF2:a,onEditChange:c,onEditCommit:d,onEditCancel:u,onDelete:p,styles:f}){const{attributes:S,listeners:v,setNodeRef:x,transform:g,transition:y,isDragging:C}=tm({id:e.id}),w=D(R=>R.locLabels),h=D(R=>R.baseLanguageCode),I=ce(e.label,w,h),$={transform:nm.Transform.toString(g),transition:y,opacity:C?.5:1,touchAction:"none"};return s.jsx("div",{ref:x,style:$,...S,...v,className:`${f.ribbonTab} ${t?f.ribbonTabActive:""}`,role:"tab","aria-selected":t,tabIndex:t?0:-1,onClick:r,onDoubleClick:l,onKeyDown:R=>{R.key==="F2"&&a()},children:n?s.jsx(_e,{ref:i,className:f.inlineTabInput,value:o,onChange:(R,B)=>c(B.value),onBlur:d,onKeyDown:R=>{R.key==="Enter"&&(R.preventDefault(),d()),R.key==="Escape"&&(R.preventDefault(),u()),R.stopPropagation()},onClick:R=>R.stopPropagation(),size:"small","aria-label":"Rename tab"}):s.jsxs(s.Fragment,{children:[s.jsx(q,{className:f.ribbonTabLabel,children:I}),s.jsx(q,{className:f.ribbonTabMeta,children:e.id}),p&&s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(bi,{}),"aria-label":`Delete tab ${I}`,title:"Delete this tab and everything in it",onPointerDown:R=>R.stopPropagation(),onClick:R=>{R.stopPropagation(),p()}})]})})}let ln=null;const Ps={set(e){ln=e},invoke(e){const t=ln;ln=null,t?.(e)},clear(){ln=null},hasPending(){return ln!==null}},Zg=["button","flyout","splitButton","textBox","comboBox","checkBox"],Qg=le({root:{padding:`${m.spacingHorizontalM}`,display:"flex",flexDirection:"column",gap:m.spacingHorizontalS},sectionLabel:{color:m.colorNeutralForeground3,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:m.spacingHorizontalXS,marginTop:m.spacingHorizontalS},row:{display:"flex",alignItems:"center",gap:m.spacingHorizontalS},localeChips:{display:"flex",flexWrap:"wrap",gap:m.spacingHorizontalXS,alignItems:"center"},iconPreview:{width:"32px",height:"32px",borderRadius:"6px",backgroundColor:m.colorNeutralBackground4,color:m.colorNeutralForeground1,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${m.colorNeutralStroke2}`,flexShrink:0},webResLink:{fontFamily:m.fontFamilyMonospace,fontSize:m.fontSizeBase200,cursor:"pointer",color:m.colorBrandForeground1,textDecoration:"underline",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:1,border:"none",background:"transparent",textAlign:"left"}});function eb({button:e,location:t,tabId:n,groupId:o}){const i=Qg(),r=D(C=>C.setButtonProp),l=D(C=>C.locLabels),a=D(C=>C.baseLanguageCode),c=Y(C=>C.openIconPicker),d=Y(C=>C.openLocalizationEditor),u=Y(C=>C.openWebResourceBrowser),p=D(C=>C.customizeOobButton),f=D(C=>C.customiseButton),S=ie(C=>C.activeSolution),v=ie(C=>C.publisherPrefix),x=Z(C=>C.selectButtonInContext);function g(C){r(t,n,o,e.id,C)}const y=Wm(e,l,a);return s.jsxs("div",{className:i.root,children:[(e.origin==="oob"||e.origin==="managed")&&s.jsx(Ie,{intent:"warning",children:s.jsx(Re,{children:s.jsxs(q,{size:200,children:[e.origin==="oob"?s.jsxs(s.Fragment,{children:["This is an ",s.jsx("strong",{children:"out-of-the-box"})," (system) button. To change it, create an override."]}):s.jsxs(s.Fragment,{children:["This button comes from a ",s.jsx("strong",{children:"managed solution"}),e.solutionName?s.jsxs(s.Fragment,{children:[" ","(",s.jsx("strong",{children:e.solutionName}),")"]}):null,e.publisherName?s.jsxs(s.Fragment,{children:[" by ",e.publisherName]}):null,". You can't edit it directly — create an override to change it."]})," ",s.jsx(K,{size:"small",appearance:"subtle",onClick:()=>p(t,n,o,e.id),children:"Create override"}),Bi(t,n,e)&&s.jsx(K,{size:"small",appearance:"subtle",title:"Copy the button into your solution and hide the original, so the copy can be changed and moved",onClick:()=>{const C=S?.publisherPrefix?.trim()||v?.trim()||"new",w=f(t,n,o,e.id,C);w&&x(t,n,o,w)},children:"Customise button"})]})})}),s.jsx(q,{size:100,weight:"semibold",className:i.sectionLabel,children:"Identity"}),s.jsx(De,{label:"Label",children:s.jsx(_e,{value:e.label,onChange:(C,w)=>g({label:w.value})})}),s.jsx(De,{label:"Translations",children:s.jsxs("div",{className:i.localeChips,children:[y.map(C=>s.jsx(ae,{appearance:"filled",color:"informative",style:{cursor:"pointer"},onClick:()=>d(e.id),children:C===1033?"en-US":String(C)},C)),y.length===0&&s.jsx(ae,{appearance:"outline",color:"informative",children:"en-US (default)"}),s.jsx(K,{size:"small",appearance:"subtle",icon:s.jsx(Te,{}),onClick:()=>d(e.id),children:"Add language…"})]})}),s.jsx(De,{label:"Tooltip title",children:s.jsx(_e,{value:e.tooltipTitle??"",onChange:(C,w)=>g({tooltipTitle:w.value})})}),s.jsx(De,{label:"Tooltip body",children:s.jsx(Gu,{value:e.tooltipBody??"",onChange:(C,w)=>g({tooltipBody:w.value}),resize:"vertical"})}),s.jsx(Ve,{}),s.jsx(De,{label:"Icon",children:s.jsxs("div",{className:i.row,children:[s.jsx("div",{className:i.iconPreview,children:e.icon?s.jsx(jt,{name:e.icon,size:20}):s.jsx(Pn,{style:{color:m.colorNeutralForeground3}})}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(Pn,{}),onClick:c,children:"Change…"})]})}),e.icon&&s.jsx(De,{label:"ModernImage (auto)",children:s.jsx(_e,{value:Ni(e)??"(none)",readOnly:!0,contentAfter:s.jsx(q,{size:100,style:{color:m.colorNeutralForeground3},children:"auto"})})}),e.image16&&s.jsx(De,{label:"Image16",children:s.jsx("div",{className:i.row,children:s.jsx("button",{type:"button",className:i.webResLink,onClick:()=>{Ps.set(C=>{g({image16:`$webresource:${C.name}`,icon:C.name.split("/").pop()?.replace(/\..*$/,"")})}),u()},title:e.image16,children:e.image16})})}),e.image32&&s.jsx(De,{label:"Image32",children:s.jsx("div",{className:i.row,children:s.jsx("button",{type:"button",className:i.webResLink,onClick:()=>{Ps.set(C=>{g({image32:`$webresource:${C.name}`})}),u()},title:e.image32,children:e.image32})})}),s.jsx(Ve,{}),s.jsx(De,{label:"Kind",children:s.jsx(dt,{value:e.kind,onChange:(C,w)=>g({kind:w.value}),children:Zg.map(C=>s.jsx("option",{value:C,children:C},C))})}),s.jsxs("div",{className:i.row,style:{justifyContent:"space-between"},children:[s.jsx(q,{size:200,children:"Visible"}),s.jsx(yi,{checked:!e.hidden,"aria-label":"Toggle button visibility",onChange:(C,w)=>g({hidden:!w.checked})})]}),s.jsx(De,{label:"Sequence",children:s.jsx(Wu,{value:e.sequence,step:10,min:0,onChange:(C,w)=>g({sequence:Number(w.value??e.sequence)})})}),s.jsx(De,{label:"Template alias",children:s.jsx(_e,{value:e.templateAlias,onChange:(C,w)=>g({templateAlias:w.value})})})]})}const tb=le({row:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:m.spacingHorizontalS}}),nb={oob:"informative",customising:"warning",customised:"brand",uncustomising:"danger",custom:"success",reloadRequired:"danger"};function zn(e){return e.scope==="application"?"the application ribbon's layer (every table)":e.sharedWithApplication?"this table's layer only (the application ribbon keeps the original)":"this table's layer"}function ob({commandId:e,compact:t=!1}){const n=tb(),o=$a(e),i=D(g=>g.customiseCommand),r=D(g=>g.uncustomiseCommand),l=D(g=>g.discardCommandChanges),a=D(g=>{const y=g.commands.find(w=>w.id===e),C=g.baselineCommands.find(w=>w.id===e);return!!y&&!!C&&JSON.stringify(y)!==JSON.stringify(C)}),[c,d]=M.useState(null);if(!o)return null;const u=(g,y,C)=>{a?d({what:g,confirmLabel:y,run:C}):C()},p=c&&s.jsxs(Fi,{open:!0,title:"Discard unpublished changes?",confirmLabel:c.confirmLabel,destructive:!0,onConfirm:()=>{c.run(),d(null)},onCancel:()=>d(null),children:[c.what," discards your unpublished changes to ",s.jsx("code",{children:e}),"."]}),{provenance:f}=o,S=f==="oob"?s.jsx(K,{size:"small",appearance:"outline",onClick:()=>i(e),children:"Customise command"}):f==="customising"?s.jsx(K,{size:"small",appearance:"subtle",onClick:()=>u("Discarding the customisation","Discard customisation",()=>l(e)),children:"Discard customisation"}):f==="customised"?s.jsx(K,{size:"small",appearance:"subtle",onClick:()=>u("Uncustomising","Uncustomise",()=>r(e,o.scope)),children:"Uncustomise"}):f==="uncustomising"?s.jsx(K,{size:"small",appearance:"subtle",onClick:()=>l(e),children:"Undo uncustomise"}):null,v=s.jsx(ae,{appearance:f==="oob"?"outline":"filled",color:nb[f],size:"small",children:xh[f]});if(t)return s.jsxs("div",{className:n.row,children:[v,S,p]});const x={oob:`Defined out of the box or by another solution. Customise it to copy the command — its actions, parameters and rule references — into ${zn(o)}, where you can change it without touching its buttons. Editing it customises it too.`,customising:`On publish, this command is copied into ${zn(o)} and replaces the original there. Rules keep their ids; a rule you edit is written to the layer as well.`,customised:`${zn(o).replace(/^./,g=>g.toUpperCase())} has a copy of this command that replaces the original. Uncustomise to remove the copy so the original applies again.`,uncustomising:`On publish, the copy of this command in ${zn(o)} is removed (with rules only it used) and the original applies again. Reload the table after publishing to see the original definition.`,custom:"Your own command.",reloadRequired:"Your layer's copy of this command was removed, so the original applies. What is shown here is the removed copy: reload the table to load the original before changing or customising it again."};return s.jsx(Ie,{intent:f==="uncustomising"||f==="reloadRequired"?"warning":"info",children:s.jsxs(Re,{children:[s.jsxs("div",{className:n.row,children:[v,s.jsx(q,{size:200,children:x[f]}),S]}),p]})})}const ib=le({root:{padding:`${m.spacingHorizontalM}`,display:"flex",flexDirection:"column",gap:m.spacingHorizontalS},sectionLabel:{color:m.colorNeutralForeground3,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:m.spacingHorizontalXS},commandRow:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:m.spacingHorizontalS,padding:`${m.spacingHorizontalXS} ${m.spacingHorizontalS}`,borderRadius:m.borderRadiusMedium,border:`1px solid ${m.colorNeutralStroke2}`,backgroundColor:m.colorNeutralBackground3},commandId:{fontFamily:m.fontFamilyMonospace,fontSize:m.fontSizeBase200,color:m.colorNeutralForeground1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}});function sb({button:e,groupId:t,tabId:n,location:o}){const i=ib(),r=D(x=>x.commands),l=D(x=>x.upsertCommand),a=D(x=>x.setButtonProp),c=D(x=>x.batch),d=Y(x=>x.openCommandEditor),[u,p]=Ue.useState(""),f=r.find(x=>x.id===e.commandId),S=()=>{const x=new Set(r.map(y=>y.id)),g=ki("New","Command",x);c(()=>{l({id:g,enableRules:[],displayRules:[],actions:[]}),a(o,n,t,e.id,{commandId:g})}),d(g)},v=()=>{u&&(a(o,n,t,e.id,{commandId:u}),p(""))};return s.jsxs("div",{className:i.root,children:[s.jsx(Ve,{}),s.jsx(q,{size:100,weight:"semibold",className:i.sectionLabel,children:"Command"}),f?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:i.commandRow,children:[s.jsx(q,{className:i.commandId,children:f.id}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(Ht,{}),onClick:()=>d(f.id),children:"Edit"})]}),s.jsx(ob,{commandId:f.id,compact:!0}),f.actions.length>0&&s.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:f.actions.map((x,g)=>s.jsx(go,{size:"extra-small",appearance:"outline",children:x.kind==="javascript"?`JS: ${x.functionName}`:x.kind==="url"?`URL: ${x.address}`:x.kind==="powerFx"?`Fx: ${x.expression}`:x.kind==="customApi"?`API: ${x.actionName}`:x.kind==="outlookCommand"?`Outlook: ${x.actionType}`:`XML: ${x.tagName}`},g))}),f.enableRules.length>0&&s.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[s.jsx(q,{size:100,style:{color:m.colorNeutralForeground3},children:"Enable rules:"}),f.enableRules.map(x=>s.jsx(go,{size:"extra-small",appearance:"outline",color:"success",children:x},x))]}),f.displayRules.length>0&&s.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[s.jsx(q,{size:100,style:{color:m.colorNeutralForeground3},children:"Display rules:"}),f.displayRules.map(x=>s.jsx(go,{size:"extra-small",appearance:"outline",color:"informative",children:x},x))]})]}):e.commandId?s.jsx("div",{className:i.commandRow,children:s.jsxs(q,{className:i.commandId,style:{color:m.colorStatusWarningForeground3},children:[e.commandId," (not found)"]})}):s.jsxs(s.Fragment,{children:[s.jsx(De,{label:"Bind existing command",style:{width:"100%",minWidth:0},children:s.jsxs(dt,{size:"small",value:u,onChange:(x,g)=>p(g.value),style:{width:"100%",minWidth:0},children:[s.jsx("option",{value:"",children:"Select command…"}),r.map(x=>s.jsx("option",{value:x.id,children:x.id},x.id))]})}),s.jsxs("div",{style:{display:"flex",gap:m.spacingHorizontalXS},children:[s.jsx(K,{appearance:"outline",size:"small",onClick:v,children:"Bind selected"}),s.jsx(K,{appearance:"outline",size:"small",icon:s.jsx(Te,{}),onClick:S,children:"Create and bind"})]})]})]})}const rb=le({section:{display:"flex",flexDirection:"column",gap:m.spacingHorizontalXS},header:{display:"flex",alignItems:"center",gap:m.spacingHorizontalXS},pillList:{display:"flex",flexWrap:"wrap",gap:m.spacingHorizontalXS,maxWidth:"100%",minWidth:0},pill:{display:"inline-flex",alignItems:"center",gap:"4px",padding:`2px ${m.spacingHorizontalXS}`,border:`1px solid ${m.colorNeutralStroke2}`,borderRadius:m.borderRadiusCircular,fontSize:m.fontSizeBase200,fontFamily:m.fontFamilyMonospace,cursor:"pointer",backgroundColor:m.colorNeutralBackground2,maxWidth:"100%",minWidth:0,":hover":{backgroundColor:m.colorNeutralBackground3}},pillLabel:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},addBtn:{alignSelf:"flex-start"},note:{fontSize:m.fontSizeBase100,color:m.colorNeutralForeground3,fontStyle:"italic"}}),el=({kind:e})=>{const t=rb(),n=Z(j=>j.location),o=Z(j=>j.tabId),i=Z(j=>j.selectedGroupId),r=Z(j=>j.selectedButtonId),l=D(j=>j.commands),a=D(j=>j.displayRules),c=D(j=>j.enableRules),d=D(j=>j.upsertCommand),u=D(j=>j.upsertDisplayRule),p=D(j=>j.upsertEnableRule),f=D(j=>j.batch),S=Y(j=>j.openRuleEditor),y=D(j=>j.ribbons)[n].tabs.find(j=>j.id===o)?.groups.find(j=>j.id===i),C=Yt(y,r),w=l.find(j=>j.id===C?.commandId),h=e==="display"?w?.displayRules??[]:w?.enableRules??[],I=e==="display"?a:c,[$,R]=Ue.useState(""),B=I.filter(j=>!h.includes(j.id)),T=j=>{if(!w)return;const E=h.filter(N=>N!==j);d(e==="display"?{...w,displayRules:E}:{...w,enableRules:E})},H=e==="display"?"Display rules (ALL must pass)":"Enable rules (ALL must pass)",k=()=>{if(!w)return;if(e==="display"){const N=new Set(a.map(U=>U.id)),W=hn(ds(w.id),"Display",N);f(()=>{u({id:W,steps:[]}),d({...w,displayRules:[...w.displayRules,W]})}),S(W,"display");return}const j=new Set(c.map(N=>N.id)),E=hn(ds(w.id),"Enable",j);f(()=>{p({id:E,steps:[]}),d({...w,enableRules:[...w.enableRules,E]})}),S(E,"enable")},P=()=>{!w||!$||(d(e==="display"?{...w,displayRules:[...w.displayRules,$]}:{...w,enableRules:[...w.enableRules,$]}),R(""))};return s.jsxs("div",{className:t.section,children:[s.jsxs("div",{className:t.header,children:[s.jsx(q,{size:200,weight:"semibold",children:H}),h.length>0&&s.jsx(ae,{appearance:"tint",size:"small",color:"informative",children:h.length})]}),!w&&s.jsx(q,{className:t.note,children:"Bind a command first to manage rules."}),s.jsx("div",{className:t.pillList,children:h.map(j=>{const E=I.find(N=>N.id===j);return s.jsxs("div",{className:t.pill,children:[s.jsx("span",{className:t.pillLabel,onClick:()=>S(j,e==="display"?"display":"enable"),title:`${j} — ${E?.steps.length??0} step(s)`,children:j}),s.jsx("button",{style:{background:"none",border:"none",cursor:"pointer",padding:0,display:"flex",color:m.colorNeutralForeground3},onClick:()=>T(j),"aria-label":`Remove rule ${j}`,children:s.jsx(bi,{style:{fontSize:12}})})]},j)})}),w&&s.jsxs(s.Fragment,{children:[s.jsx(De,{label:`Bind existing ${e} rule`,style:{width:"100%",minWidth:0},children:s.jsxs(dt,{size:"small",value:$,onChange:(j,E)=>R(E.value),style:{width:"100%",minWidth:0},children:[s.jsx("option",{value:"",children:"Select rule…"}),B.map(j=>s.jsx("option",{value:j.id,children:j.id},j.id))]})}),s.jsxs("div",{style:{display:"flex",gap:m.spacingHorizontalXS},children:[s.jsx(K,{className:t.addBtn,appearance:"subtle",size:"small",onClick:P,disabled:!$,children:"Bind selected"}),s.jsxs(K,{className:t.addBtn,appearance:"subtle",size:"small",icon:s.jsx(Te,{}),onClick:k,children:["Create new ",e," rule"]})]})]}),e==="enable"&&s.jsxs(q,{className:t.note,children:["Note: Disabled buttons are ",s.jsx("strong",{children:"hidden"})," in the modern command bar (Unified Interface). In the classic ribbon (Legacy client), disabled buttons remain visible but do not respond to clicks."]})]})},ab=()=>s.jsx(el,{kind:"display"}),lb=()=>s.jsx(el,{kind:"enable"}),cb=le({section:{display:"flex",flexDirection:"column",gap:m.spacingHorizontalXS},header:{display:"flex",alignItems:"center",gap:m.spacingHorizontalXS},stepRow:{display:"flex",flexDirection:"column",gap:"8px",padding:`${m.spacingVerticalXS} ${m.spacingHorizontalXS}`,border:`1px solid ${m.colorNeutralStroke2}`,borderRadius:m.borderRadiusMedium,backgroundColor:m.colorNeutralBackground2},stepBadge:{alignSelf:"flex-start"},note:{fontSize:m.fontSizeBase100,color:m.colorNeutralForeground3,fontStyle:"italic"},warningNote:{fontSize:m.fontSizeBase100,color:m.colorStatusWarningForeground1,backgroundColor:m.colorStatusWarningBackground1,padding:`2px ${m.spacingHorizontalXS}`,borderRadius:m.borderRadiusSmall}}),db=()=>{const e=cb(),t=Y(c=>c.openScalingEditor),n=Z(c=>c.location),o=Z(c=>c.tabId),l=D(c=>c.ribbons)[n].tabs.find(c=>c.id===o),a=l?.groups.length??0;return s.jsxs("div",{className:e.section,children:[s.jsxs("div",{className:e.header,children:[s.jsx(q,{size:200,weight:"semibold",children:"Scaling"}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(no,{}),onClick:t,children:"Edit scaling"})]}),s.jsx("div",{className:e.warningNote,children:"⚠ Scaling applies only to the Classic ribbon (Legacy client / Outlook list views). The modern command bar (Unified Interface) ignores scaling."}),l?s.jsxs(q,{size:100,className:e.note,children:["Tab ",s.jsx("strong",{children:l.label})," has ",a," group(s). Open the Scaling Editor to configure MaxSize and Scale steps."]}):s.jsx(q,{size:100,className:e.note,children:"Select a tab to configure scaling."})]})},ub=le({section:{display:"flex",flexDirection:"column",gap:m.spacingHorizontalXS},row:{display:"flex",alignItems:"center",gap:m.spacingHorizontalS},note:{fontSize:m.fontSizeBase100,color:m.colorNeutralForeground3}}),mb=[{label:"Show on Unified Interface (Refresh)",value:"Refresh"},{label:"Show on Classic ribbon (Legacy)",value:"Legacy"},{label:"Show on Tablets (Modern)",value:"Modern"}],pb=()=>{const e=ub(),t=Z(N=>N.location),n=Z(N=>N.tabId),o=Z(N=>N.selectedGroupId),i=Z(N=>N.selectedButtonId),r=D(N=>N.ribbons),l=D(N=>N.upsertCommand),a=D(N=>N.upsertDisplayRule),c=D(N=>N.batch),d=D(N=>N.commands),u=D(N=>N.displayRules),p=Y(N=>N.openCommandEditor),f=D(N=>N.setOpenRecordOverride),S=Z(N=>N.clearSelection),v=ie(N=>N.activeSolution),x=ie(N=>N.publisherPrefix),g=r[t],C=g.tabs.find(N=>N.id===n)?.groups.find(N=>N.id===o),w=Yt(C,i),h=ia.includes(t),I=ra(g),$=I.length>0,R=I.map(N=>aa(N)),B=R.includes("theirs"),T=!B&&R.includes("unknown"),H=!$&&!la(g),k=zi(g).filter(N=>!sa(N.button)),P=N=>{const W=v?.publisherPrefix?.trim()||x?.trim()||"new";!N&&I.some(U=>U.button.id===i)&&S(),!(!f(t,N,W)||!N)&&p(Be)},j=()=>{if(w?.commandId)return d.find(N=>N.id===w.commandId)},E=N=>{const W=j();if(!W)return;let V=u.find(L=>L.steps.length===1&&L.steps[0].kind==="CommandClientTypeRule"&&L.steps[0].type===N)?.id,ee;if(!V){const L=`${W.id}.${N}.DisplayRule`;V=L;let O=1;for(;u.some(b=>b.id===V);)V=`${L}.${O}`,O+=1;ee={id:V,steps:[{kind:"CommandClientTypeRule",type:N}]}}const _=V;c(()=>{ee&&a(ee),W.displayRules.includes(_)||l({...W,displayRules:[...W.displayRules,_]})})};return s.jsxs("div",{className:e.section,children:[s.jsx(q,{size:200,weight:"semibold",children:"Advanced"}),w&&s.jsx("div",{children:s.jsxs(q,{size:100,className:e.note,children:["Tab: ",s.jsx("code",{style:{fontFamily:m.fontFamilyMonospace},children:n})]})}),h&&s.jsxs("div",{children:[s.jsx(yi,{label:`Override default record open behavior on the ${t==="SubGrid"?"sub-grid":"home grid"} (Mscrm.OpenRecordItem)`,checked:$,disabled:B||T||H,onChange:(N,W)=>P(W.checked)}),s.jsxs(q,{size:100,className:e.note,children:[`When enabled, the table gets a CommandDefinition with Id="Mscrm.OpenRecordItem" whose action runs instead of opening the record when a user double-clicks a row of this table's `,t==="SubGrid"?"sub-grids (on any form)":"home grid",`, selects its primary column link or presses Enter on it. As in Microsoft's recipe, an "Open record" button using the command is added to this location's command bar — the override only reaches a grid through a button there; don't hide that button. `,s.jsx("strong",{children:"Unified Interface only."})," The Command Editor will open so you can set the real web resource and function name; Publish is blocked until you do. Turning it off removes that button, and the command once no button uses it."]}),B&&s.jsx(q,{size:100,className:e.note,children:`The "Open record" button here comes from another solution, so the override can't be turned off from your customizations.`}),T&&s.jsx(q,{size:100,className:e.note,children:`CBS doesn't know yet which solution the "Open record" button here comes from (its solution layers haven't loaded), so it isn't removed — reload the table if this doesn't clear.`}),k.length>0&&s.jsxs(q,{size:100,className:e.note,children:["Also using Mscrm.OpenRecordItem here:"," ",k.map(N=>N.button.id).join(", "),". Turning the override off keeps ",k.length===1?"it":"them"," and the command."]}),H&&s.jsx(q,{size:100,className:e.note,children:"This location has no group to put the button in."})]}),t==="Form"&&s.jsx(q,{size:100,className:e.note,children:"Form command bar changes apply to every main form of this table (ImportExportXml/Entities/Entity/RibbonDiffXml). Form-specific ribbons (systemform/form/RibbonDiffXml) aren't supported on Unified Interface, so CBS doesn't write them (#14)."}),s.jsxs("div",{children:[s.jsx(q,{size:100,weight:"semibold",className:e.note,children:"Client type filter (adds a CommandClientTypeRule):"}),s.jsxs(q,{size:100,className:e.note,children:[s.jsx("strong",{children:"Refresh"})," = Unified Interface web client | ",s.jsx("strong",{children:"Legacy"})," = Classic ribbon / Outlook | ",s.jsx("strong",{children:"Modern"})," = Dynamics 365 for tablets"]}),s.jsx("div",{className:e.row,style:{marginTop:"4px"},children:mb.map(N=>s.jsx(ae,{appearance:"outline",style:{cursor:"pointer"},title:`Add CommandClientTypeRule: ${N.value}`,onClick:()=>E(N.value),children:N.label},N.value))})]})]})},fb=le({banner:{marginBottom:m.spacingHorizontalXS}}),hb=()=>{const e=fb(),t=Z(y=>y.selectedButtonId),n=Z(y=>y.selectedGroupId),o=Z(y=>y.location),i=Z(y=>y.tabId),r=D(y=>y.conflicts),l=D(y=>y.ribbons),a=Y(y=>y.openConflictDrawer),u=l[o].tabs.find(y=>y.id===i)?.groups.find(y=>y.id===n),p=Yt(u,t),f=r.find(y=>y.elementId===t),S=p?.origin==="managed";if(!t||!S&&!f)return null;const v=p?.solutionName??f?.solutions[0]?.solutionName,x=p?.publisherName??f?.solutions[0]?.publisher,g=f?.solutions.length??(S?1:0);return s.jsxs(Ie,{intent:"warning",className:e.banner,children:[s.jsx(Re,{children:s.jsx(q,{children:g>1?`This button is customized by ${g} solutions. The last imported solution wins.`:`This button belongs to a managed solution${v?` “${v}”`:""}${x?` by ${x}`:""}. Customizing it will create an unmanaged override.`})}),s.jsx(Fn,{children:s.jsx(K,{appearance:"transparent",size:"small",onClick:()=>t&&a(t),children:"View solution layers"})})]})},gb=le({root:{display:"flex",flexDirection:"column",gap:m.spacingVerticalXS,padding:`${m.spacingVerticalS} ${m.spacingHorizontalM}`,textAlign:"left",width:"100%",boxSizing:"border-box"},row:{display:"flex",alignItems:"center",gap:m.spacingHorizontalS,minWidth:0},id:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:m.fontFamilyMonospace,fontSize:m.fontSizeBase200},pending:{textDecoration:"line-through",color:m.colorNeutralForeground3}});function bb(){const e=gb(),t=D(r=>r.layers),n=D(r=>r.pendingUnhides),o=D(r=>r.setLayerHideUnhidden),i=["entity","application"].flatMap(r=>(t[r]?.hides??[]).map(l=>({scope:r,...l})));return i.length===0?null:s.jsxs("section",{className:e.root,"aria-label":"Hidden by customizations",children:[s.jsx(It,{children:"Hidden by customizations"}),s.jsx(Oe,{children:"Hidden by a HideCustomAction in your unmanaged customizations, so they aren't on the canvas. Un-hiding takes effect when you publish; reload afterwards to see them."}),i.map(r=>{const l=n[r.scope].includes(r.location);return s.jsxs("div",{className:e.row,children:[s.jsx(Ye,{}),s.jsx(ke,{content:`${r.location} (${r.scope==="entity"?"this table":"application ribbon"})`,relationship:"description",children:s.jsx(q,{className:`${e.id} ${l?e.pending:""}`,children:r.location})}),s.jsx(K,{size:"small",appearance:l?"subtle":"secondary",onClick:()=>o(r.scope,r.location,!l),children:l?"Keep hidden":"Unhide"})]},`${r.scope}:${r.location}`)})]})}const yb=le({root:{display:"flex",flexDirection:"column",gap:m.spacingVerticalXS,padding:`${m.spacingVerticalS} ${m.spacingHorizontalM}`,textAlign:"left",width:"100%",boxSizing:"border-box"},row:{display:"flex",alignItems:"flex-start",gap:m.spacingHorizontalS,minWidth:0},icon:{flexShrink:0,marginTop:"2px",color:m.colorPaletteMarigoldForeground1},text:{display:"flex",flexDirection:"column",flex:1,minWidth:0},mono:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:m.fontFamilyMonospace,fontSize:m.fontSizeBase200},why:{color:m.colorNeutralForeground3},pending:{textDecoration:"line-through",color:m.colorNeutralForeground3}});function xb(){const e=yb(),t=D(a=>a.orphans),n=D(a=>a.pendingOrphanDeletes),o=D(a=>a.setOrphanDeleted),[i,r]=M.useState(null),l=["entity","application"].flatMap(a=>t[a].map(c=>({scope:a,...c})));return l.length===0?null:s.jsxs("section",{className:e.root,"aria-label":"Orphaned customizations",children:[s.jsx(It,{children:"Orphaned customizations"}),s.jsx(Oe,{children:"In your unmanaged customizations, but the ribbon doesn't return them, so they aren't on the canvas (and, except for tabs, Unified Interface doesn't show them either). Publishing keeps them unless you delete them. For a while after a publish the ribbon can still be the one from before it (10 minutes or more), so what you just published can show up here: don't delete it, reload later."}),l.map(a=>{const c=n[a.scope].includes(a.id),d=a.label&&a.label!==a.id?`“${a.label}” `:"",u=`${a.scope}:${a.id}`,p=!!a.recentPublish?.published,f=c?s.jsx(K,{size:"small",appearance:"subtle","aria-label":`Keep ${a.id}`,onClick:()=>o(a.scope,a.id,!1),children:"Keep"}):p?s.jsx(ke,{content:"Published from here moments ago: reload later — it most likely isn't loaded yet",relationship:"description",children:s.jsx(K,{size:"small",disabledFocusable:!0,"aria-label":`Delete ${a.id}`,children:"Delete"})}):a.recentPublish&&i!==u?s.jsx(K,{size:"small",appearance:"secondary","aria-label":`Delete ${a.id}`,onClick:()=>r(u),children:"Delete…"}):a.recentPublish?s.jsx(K,{size:"small",appearance:"primary","aria-label":`Delete ${a.id} anyway`,onClick:()=>{r(null),o(a.scope,a.id,!0)},children:"Delete anyway"}):s.jsx(K,{size:"small",appearance:"secondary","aria-label":`Delete ${a.id}`,onClick:()=>o(a.scope,a.id,!0),children:"Delete"});return s.jsxs("div",{className:e.row,children:[s.jsx(pu,{className:e.icon}),s.jsxs("div",{className:e.text,children:[s.jsx(ke,{content:`${a.element} ${a.id} — CustomAction ${a.customActionId} at ${a.location}`,relationship:"description",children:s.jsxs(q,{className:Ft(e.mono,c&&e.pending),children:[d,a.id]})}),s.jsx(Oe,{className:Ft(e.mono,e.why),children:a.location}),s.jsx(Oe,{className:e.why,children:a.why})]}),f]},u)})]})}const Sb=le({root:{display:"flex",flexDirection:"column",gap:m.spacingVerticalS,padding:`${m.spacingVerticalS} ${m.spacingHorizontalM}`},title:{display:"flex",alignItems:"center",gap:m.spacingHorizontalXS},field:{display:"flex",flexDirection:"column",gap:"2px",minWidth:0},mono:{fontFamily:m.fontFamilyMonospace,fontSize:m.fontSizeBase200,overflowWrap:"anywhere"},xml:{margin:0,maxHeight:"240px",overflow:"auto",padding:m.spacingHorizontalS,borderRadius:m.borderRadiusMedium,backgroundColor:m.colorNeutralBackground3,fontFamily:m.fontFamilyMonospace,fontSize:m.fontSizeBase100,whiteSpace:"pre-wrap",overflowWrap:"anywhere"}});function vb({button:e,location:t,tabId:n,groupId:o}){const i=Sb(),r=D(v=>v.locLabels),l=D(v=>v.setButtonProp),a=D(v=>v.hideOobButton),c=D(v=>v.hideWithDisplayRules),[d,u]=M.useState(!1),p=t==="Application"&&n==="Mscrm.GlobalTab"&&e.oob&&!e.custom,f=qn[e.kind],S=(v,x)=>x?s.jsxs("div",{className:i.field,children:[s.jsx(Oe,{children:v}),s.jsx(q,{className:i.mono,children:x})]}):null;return s.jsxs("section",{className:i.root,"aria-label":`${f} (read-only)`,children:[s.jsxs("div",{className:i.title,children:[s.jsx(wt,{"aria-hidden":!0}),s.jsx(It,{children:f})]}),s.jsxs(Oe,{children:["Command Bar Studio shows this <",pn[e.kind],"> but doesn't edit it. You can hide it, and move or delete it when your customizations add it; its XML is published as it was loaded."]}),S("Label",ce(e.label,r)),S("Id",e.id),S("Command",e.commandId||void 0),s.jsx("div",{children:s.jsx(K,{size:"small",disabled:p,icon:e.hidden?s.jsx(Ct,{}):s.jsx(Ye,{}),onClick:()=>!e.hidden&&e.oob?u(!0):l(t,n,o,e.id,{hidden:!e.hidden}),children:e.hidden?"Unhide":"Hide"})}),d&&s.jsx(Pi,{open:!0,buttonLabel:e.label,commandId:e.commandId,onConfirmHide:()=>{a(t,n,o,e.id),u(!1)},onConfirmDisplayRule:()=>{c(e.commandId),u(!1)},onCancel:()=>u(!1)}),e.source?.xml&&s.jsxs("div",{className:i.field,children:[s.jsx(Oe,{children:"XML"}),s.jsx("pre",{className:i.xml,children:e.source.xml})]})]})}const Vi=le({root:{display:"flex",flexDirection:"column",gap:m.spacingVerticalS,padding:`${m.spacingVerticalS} ${m.spacingHorizontalM}`},title:{display:"flex",alignItems:"center",gap:m.spacingHorizontalS,flexWrap:"wrap"},grid:{display:"grid",gridTemplateColumns:"max-content 1fr",columnGap:m.spacingHorizontalM,rowGap:m.spacingVerticalXS,alignItems:"baseline"},key:{color:m.colorNeutralForeground3,fontSize:m.fontSizeBase200},value:{fontSize:m.fontSizeBase200,overflowWrap:"anywhere",minWidth:0},mono:{fontFamily:m.fontFamilyMonospace},list:{display:"flex",flexDirection:"column",gap:m.spacingVerticalXXS}});function st({label:e,value:t,mono:n}){const o=Vi();return t?s.jsxs(s.Fragment,{children:[s.jsx(q,{className:o.key,children:e}),s.jsx(q,{className:`${o.value} ${n?o.mono:""}`,children:t})]}):null}function Cb({command:e,items:t}){const n=Vi(),o=Zt(),i=ge(a=>a.selectCommand),r=ge(a=>e.parentId?a.commands.find(c=>c.id===e.parentId):void 0),l=e.visibility==="formula"||e.action==="formula";return s.jsxs("section",{className:n.root,"aria-label":"Modern command properties",children:[s.jsxs("div",{className:n.title,children:[s.jsx(It,{children:e.label}),s.jsx(ae,{appearance:"tint",color:"important",children:"Modern"}),e.managed&&s.jsx(ae,{appearance:"outline",color:"informative",children:"Managed"})]}),s.jsx(Ie,{intent:"info",children:s.jsx(Re,{children:"Modern commands are read-only in Command Bar Studio and are never published from here. Edit them in the command designer."})}),s.jsxs("div",{className:n.grid,children:[_a(e,o).map(a=>s.jsx(st,{label:a.label,value:a.value},a.label)),s.jsx(st,{label:"Tooltip title",value:e.tooltipTitle}),s.jsx(st,{label:"Tooltip text",value:e.tooltipDescription}),s.jsx(st,{label:"Accessibility text",value:e.accessibilityText}),s.jsx(st,{label:"Icon",value:e.fontIcon??e.iconWebResourceName??e.iconWebResourceId}),s.jsx(st,{label:"Group title",value:e.groupTitle}),s.jsx(st,{label:"Name",value:e.name}),s.jsx(st,{label:"Unique name",value:e.uniqueName,mono:!0}),s.jsx(st,{label:"Id",value:e.id,mono:!0})]}),l&&s.jsx(Oe,{children:"Power Fx formulas are stored in the app's command component library, not on the command, so only the function reference is shown here."}),r&&s.jsxs(s.Fragment,{children:[s.jsx(Ve,{}),s.jsx(q,{className:n.key,children:"Inside"}),s.jsx(Go,{onClick:()=>i(r.id),children:r.label})]}),t.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(Ve,{}),s.jsxs(q,{className:n.key,children:["Items (",t.length,")"]}),s.jsx("div",{className:n.list,children:t.map(a=>s.jsxs(Go,{onClick:()=>i(a.id),children:[a.label,a.hidden?" (hidden)":""]},a.id))})]}),e.classicRules.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(Ve,{}),s.jsxs(q,{className:n.key,children:["Classic rules (",e.classicRules.length,")"]}),s.jsx("div",{className:n.list,children:e.classicRules.map(a=>s.jsxs(q,{className:`${n.value} ${n.mono}`,children:[a.kind==="enable"?"Enable":"Display",":"," ",a.uniqueName??a.name]},a.id))})]})]})}function wb({overrides:e}){const t=Vi(),n=Zt(),o=ge(r=>r.selectCommand);if(e.length===0)return null;const i=e.some(r=>r.effect==="hidden");return s.jsx("section",{className:t.root,"aria-label":"Modern command overrides",children:s.jsx(Ie,{intent:i?"warning":"info",children:s.jsx(Re,{children:s.jsxs("div",{className:t.list,children:[e.map(r=>s.jsxs("span",{children:[_i(r,n),"."," ",s.jsx(Go,{inline:!0,onClick:()=>o(r.command.id),children:"View"})]},r.command.id)),s.jsx(Oe,{children:"Matched by the migrated command's unique name. Unified Interface may show the modern command instead of this button."})]})})})})}const Ib=le({root:{display:"flex",flexDirection:"column",height:"100%",overflowY:"auto",backgroundColor:m.colorNeutralBackground2,borderLeft:`1px solid ${m.colorNeutralStroke2}`},header:{padding:`${m.spacingHorizontalS} ${m.spacingHorizontalM}`,borderBottom:`1px solid ${m.colorNeutralStroke2}`,flexShrink:0},empty:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:1,gap:m.spacingHorizontalM,color:m.colorNeutralForeground3,padding:m.spacingHorizontalXL,textAlign:"center"},section:{padding:`${m.spacingHorizontalS} ${m.spacingHorizontalM}`}});function Rb(){const e=Ib(),t=Z(v=>v.selectedButtonId),n=Z(v=>v.selectedGroupId),o=Z(v=>v.location),i=Z(v=>v.tabId),c=D(v=>v.ribbons)[o].tabs.find(v=>v.id===i)?.groups.find(v=>v.id===n),d=Yt(c,t),u=c&&d?Wn(c,d.id):void 0,p=D(v=>v.locLabels),f=ig(),S=ng(o,d?.id);return s.jsxs("aside",{className:e.root,"aria-label":"Properties",children:[s.jsx("div",{className:e.header,children:s.jsx(It,{children:"Properties"})}),!d&&f?s.jsx(Cb,{command:f.command,items:f.children}):d?s.jsxs(s.Fragment,{children:[s.jsx(hb,{}),s.jsx(wb,{overrides:S}),u&&s.jsx("div",{className:e.section,children:s.jsxs(Oe,{children:["Menu item of “",ce(u.parent.label,p),"”",u.section.title?` — section “${u.section.title}”`:""]})}),Ze(d.kind)?s.jsx(vb,{button:d,location:o,tabId:i,groupId:n}):s.jsxs(s.Fragment,{children:[s.jsx(eb,{button:d,location:o,tabId:i,groupId:n}),s.jsx(Ve,{}),s.jsx("div",{className:e.section,children:s.jsx(sb,{button:d,groupId:n,tabId:i,location:o})}),s.jsx(Ve,{}),s.jsx("div",{className:e.section,children:s.jsx(ab,{})}),s.jsx(Ve,{}),s.jsx("div",{className:e.section,children:s.jsx(lb,{})}),s.jsx(Ve,{}),s.jsx("div",{className:e.section,children:s.jsx(db,{})}),s.jsx(Ve,{}),s.jsx("div",{className:e.section,children:s.jsx(pb,{})})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:e.empty,children:[s.jsx(fu,{fontSize:32,style:{opacity:.4}}),s.jsx(q,{size:300,children:"Select a button to view its properties"})]}),s.jsx(bb,{}),s.jsx(xb,{})]})]})}const tl=le({root:{display:"flex",flexDirection:"column",borderTop:`1px solid ${m.colorNeutralStroke2}`,backgroundColor:m.colorNeutralBackground2,flexShrink:0},tabRow:{display:"flex",alignItems:"center",borderBottom:`1px solid ${m.colorNeutralStroke2}`,gap:0,paddingRight:m.spacingHorizontalS,flexShrink:0},content:{flex:1,overflowY:"auto",padding:`${m.spacingHorizontalXS} ${m.spacingHorizontalM}`},toolbar:{display:"flex",alignItems:"center",gap:m.spacingHorizontalXS,paddingBottom:m.spacingHorizontalXS,borderBottom:`1px solid ${m.colorNeutralStroke3}`,marginBottom:m.spacingHorizontalXS},table:{width:"100%",borderCollapse:"collapse",fontSize:m.fontSizeBase200},th:{textAlign:"left",padding:`4px ${m.spacingHorizontalS}`,fontWeight:m.fontWeightSemibold,color:m.colorNeutralForeground3,fontSize:m.fontSizeBase100,borderBottom:`1px solid ${m.colorNeutralStroke2}`,whiteSpace:"nowrap"},td:{padding:`4px ${m.spacingHorizontalS}`,borderBottom:`1px solid ${m.colorNeutralStroke3}`,verticalAlign:"middle"},mono:{fontFamily:m.fontFamilyMonospace,fontSize:m.fontSizeBase200,cursor:"pointer",color:m.colorBrandForeground1,":hover":{textDecoration:"underline"}},chip:{display:"inline-flex",alignItems:"center",padding:"1px 6px",borderRadius:m.borderRadiusMedium,fontSize:m.fontSizeBase100,border:`1px solid ${m.colorNeutralStroke2}`,backgroundColor:m.colorNeutralBackground3,marginRight:"3px",fontFamily:m.fontFamilyMonospace},historyRow:{display:"flex",alignItems:"flex-start",gap:m.spacingHorizontalS,padding:`${m.spacingHorizontalXS} 0`,borderBottom:`1px solid ${m.colorNeutralStroke3}`},historyAvatar:{width:"24px",height:"24px",borderRadius:"50%",backgroundColor:m.colorBrandBackground2,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginTop:"2px"},historyContent:{flex:1,minWidth:0},consoleRow:{padding:"2px 0",fontFamily:m.fontFamilyMonospace,fontSize:m.fontSizeBase200,display:"flex",gap:m.spacingHorizontalS},consoleTs:{color:m.colorNeutralForeground4,flexShrink:0,fontSize:m.fontSizeBase100}});function jb(){const e=tl(),t=Y(b=>b.activeBottomTab),n=Y(b=>b.setActiveBottomTab),o=Y(b=>b.bottomPanelHeight),i=Y(b=>b.bottomCollapsed),r=Y(b=>b.setBottomCollapsed),l=D(b=>b.commands),a=D(b=>b.displayRules),c=D(b=>b.enableRules),d=D(b=>b.past),u=D(b=>b.ribbons),p=D(b=>b.restore),f=ie(b=>b.currentUserName),S=oe(b=>b.entries),v=oe(b=>b.clear),x=Y(b=>b.openCommandEditor),g=Y(b=>b.openRuleEditor),y=Y(b=>b.openDiffViewer),C=D(b=>b.upsertCommand),w=D(b=>b.upsertEnableRule),h=D(b=>b.upsertDisplayRule),[I,$]=M.useState(""),[R,B]=M.useState(""),[T,H]=M.useState(""),[k,P]=M.useState(""),j=M.useMemo(()=>{const b=I.toLowerCase().trim();return b?l.filter(A=>A.id.toLowerCase().includes(b)||A.enableRules.some(X=>X.toLowerCase().includes(b))||A.displayRules.some(X=>X.toLowerCase().includes(b))):l},[l,I]),E=M.useMemo(()=>{const b=R.toLowerCase().trim();return b?a.filter(A=>A.id.toLowerCase().includes(b)||A.steps.some(X=>X.kind.toLowerCase().includes(b))):a},[a,R]),N=M.useMemo(()=>{const b=T.toLowerCase().trim();return b?c.filter(A=>A.id.toLowerCase().includes(b)||A.steps.some(X=>X.kind.toLowerCase().includes(b))):c},[c,T]),W=M.useMemo(()=>{const b=k.toLowerCase().trim();return b?d.filter(A=>A.op.toLowerCase().includes(b)||A.target.toLowerCase().includes(b)||A.detail.toLowerCase().includes(b)||A.userName.toLowerCase().includes(b)):d},[d,k]),U=()=>{const b=new Set(l.map(X=>X.id)),A=ki("New","Command",b);C({id:A,enableRules:[],displayRules:[],actions:[]}),x(A)},V=()=>{const b=new Set(c.map(X=>X.id)),A=hn("New","Enable",b);w({id:A,steps:[]}),g(A,"enable")},ee=()=>{const b=new Set(a.map(X=>X.id)),A=hn("New","Display",b);h({id:A,steps:[]}),g(A,"display")},_=M.useMemo(()=>{const b={};for(const A of Object.values(u))for(const X of A.tabs)for(const re of X.groups)for(const me of je(re))me.commandId&&(b[me.commandId]=(b[me.commandId]??0)+1);return b},[u]),L=M.useMemo(()=>{const b={};for(const A of l)for(const X of[...A.enableRules,...A.displayRules])b[X]=(b[X]??0)+1;return b},[l]),O=i?32:o;function F(b){return b.userName&&b.userName!=="You"?b.userName:f||"You"}return s.jsxs("div",{className:e.root,style:{height:O},children:[s.jsxs("div",{className:e.tabRow,children:[s.jsxs(Si,{selectedValue:t,onTabSelect:(b,A)=>n(A.value),size:"small",style:{flex:1},children:[s.jsxs(Je,{value:"commands",children:["Commands (",l.length,")"]}),s.jsxs(Je,{value:"displayRules",children:["Display rules (",a.length,")"]}),s.jsxs(Je,{value:"enableRules",children:["Enable rules (",c.length,")"]}),s.jsxs(Je,{value:"history",children:["History (",d.length,")"]}),s.jsx(Je,{value:"console",children:"Console"})]}),s.jsx(K,{appearance:"subtle",size:"small",icon:i?s.jsx(ur,{}):s.jsx(gt,{}),onClick:()=>r(!i),"aria-label":i?"Expand panel":"Collapse panel"})]}),!i&&s.jsxs("div",{className:e.content,children:[t==="commands"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:e.toolbar,children:[s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(Te,{}),onClick:U,children:"New command"}),s.jsx(_e,{size:"small",contentBefore:s.jsx(ft,{}),placeholder:`Filter ${l.length} command${l.length!==1?"s":""}…`,value:I,onChange:(b,A)=>$(A.value),style:{minWidth:0,flex:1,maxWidth:360}}),I&&s.jsxs(q,{size:100,style:{color:m.colorNeutralForeground3},children:[j.length," match",j.length!==1?"es":""]})]}),s.jsxs("table",{className:e.table,children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{className:e.th,children:"Command"}),s.jsx("th",{className:e.th,children:"Actions"}),s.jsx("th",{className:e.th,children:"Enable rules"}),s.jsx("th",{className:e.th,children:"Display rules"}),s.jsx("th",{className:e.th,children:"Refs"}),s.jsx("th",{className:e.th})]})}),s.jsx("tbody",{children:j.map(b=>s.jsxs("tr",{children:[s.jsx("td",{className:e.td,children:s.jsx("span",{className:e.mono,onClick:()=>x(b.id),role:"button",tabIndex:0,onKeyDown:A=>A.key==="Enter"&&x(b.id),children:b.id})}),s.jsxs("td",{className:e.td,children:[b.actions.map((A,X)=>s.jsx("span",{className:e.chip,children:A.kind==="javascript"?"JS":A.kind==="url"?"URL":A.kind==="powerFx"?"Fx":A.kind==="customApi"?"API":A.kind==="outlookCommand"?"Outlook":"XML"},X)),b.actions.length===0&&s.jsx(q,{size:100,style:{color:m.colorNeutralForeground3},children:"—"})]}),s.jsx("td",{className:e.td,children:b.enableRules.map(A=>s.jsx(ke,{content:A,relationship:"label",children:s.jsx("span",{className:e.chip,style:{cursor:"pointer",color:m.colorBrandForeground1},onClick:()=>g(A,"enable"),children:A.split(".").pop()})},A))}),s.jsx("td",{className:e.td,children:b.displayRules.map(A=>s.jsx(ke,{content:A,relationship:"label",children:s.jsx("span",{className:e.chip,style:{cursor:"pointer",color:m.colorBrandForeground1},onClick:()=>g(A,"display"),children:A.split(".").pop()})},A))}),s.jsx("td",{className:e.td,children:s.jsx(ae,{size:"small",appearance:"tint",color:_[b.id]?"brand":"informative",children:_[b.id]??0})}),s.jsx("td",{className:e.td,children:s.jsx(K,{appearance:"subtle",size:"small",onClick:()=>x(b.id),children:"Edit"})})]},b.id))})]})]}),t==="displayRules"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:e.toolbar,children:[s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(Te,{}),onClick:ee,children:"New display rule"}),s.jsx(_e,{size:"small",contentBefore:s.jsx(ft,{}),placeholder:`Filter ${a.length} display rule${a.length!==1?"s":""}…`,value:R,onChange:(b,A)=>B(A.value),style:{minWidth:0,flex:1,maxWidth:360}}),R&&s.jsxs(q,{size:100,style:{color:m.colorNeutralForeground3},children:[E.length," match",E.length!==1?"es":""]})]}),s.jsx(Fs,{rules:E,kind:"display",ruleRefs:L,onEdit:b=>g(b,"display"),styles:e})]}),t==="enableRules"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:e.toolbar,children:[s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(Te,{}),onClick:V,children:"New enable rule"}),s.jsx(_e,{size:"small",contentBefore:s.jsx(ft,{}),placeholder:`Filter ${c.length} enable rule${c.length!==1?"s":""}…`,value:T,onChange:(b,A)=>H(A.value),style:{minWidth:0,flex:1,maxWidth:360}}),T&&s.jsxs(q,{size:100,style:{color:m.colorNeutralForeground3},children:[N.length," match",N.length!==1?"es":""]})]}),s.jsx(Fs,{rules:N,kind:"enable",ruleRefs:L,onEdit:b=>g(b,"enable"),styles:e})]}),t==="history"&&s.jsxs(s.Fragment,{children:[d.length>0&&s.jsxs("div",{className:e.toolbar,children:[s.jsx(_e,{size:"small",contentBefore:s.jsx(ft,{}),placeholder:`Filter ${d.length} entr${d.length!==1?"ies":"y"}…`,value:k,onChange:(b,A)=>P(A.value),style:{minWidth:0,flex:1,maxWidth:360}}),k&&s.jsxs(q,{size:100,style:{color:m.colorNeutralForeground3},children:[W.length," match",W.length!==1?"es":""]})]}),d.length===0?s.jsx(q,{size:200,style:{color:m.colorNeutralForeground3},children:"No history yet — make a change to see it here."}):W.slice().reverse().map((b,A)=>{const X=d.indexOf(b);return s.jsxs("div",{className:e.historyRow,children:[s.jsx("div",{className:e.historyAvatar,"aria-hidden":!0,children:s.jsx(dr,{fontSize:12,style:{color:m.colorBrandForeground1}})}),s.jsxs("div",{className:e.historyContent,children:[s.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[s.jsx(q,{size:200,weight:"semibold",children:b.op}),s.jsxs(q,{size:200,children:["— ",s.jsx("strong",{children:b.target})]}),b.detail&&s.jsx(q,{size:100,style:{color:m.colorNeutralForeground3},children:b.detail})]}),s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:2},children:[s.jsxs(q,{size:100,style:{color:m.colorNeutralForeground3},children:[F(b)," ·"," ",new Date(b.ts).toLocaleTimeString()]}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(sr,{}),onClick:()=>y("history"),children:"View diff"}),s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(ar,{}),title:"Undo this change and every later one (redo brings them back)",onClick:()=>p(X),children:"Undo from here"})]})]})]},A)})]}),t==="console"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:e.toolbar,children:[s.jsx(K,{appearance:"subtle",size:"small",icon:s.jsx(mn,{}),disabled:S.length===0,onClick:()=>{const b=S.slice().reverse().map(A=>{const X=new Date(A.ts).toLocaleTimeString();return`${A.scope} ${X}
|
|
136
136
|
[${A.level.toUpperCase()}]
|
|
137
137
|
${A.message}`}).join(`
|