@mohsinonxrm/pptb-commandbar-studio 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{BulkPublishModal-_JCQ9G-Z.js → BulkPublishModal-DlglMah4.js} +1 -1
- package/dist/assets/{CommandEditorPanel-BfdeUs_f.js → CommandEditorPanel-4pYnil3i.js} +1 -1
- package/dist/assets/{CommandPalette-D2Kh5NZ1.js → CommandPalette-iYxzI2G_.js} +1 -1
- package/dist/assets/{ConflictDrawer-BLiuWHeb.js → ConflictDrawer-DBPRRkoa.js} +1 -1
- package/dist/assets/{DiffViewer-BVDCd534.js → DiffViewer-DFBJPZKA.js} +1 -1
- package/dist/assets/{IconPickerModal-BAiIRU4A.js → IconPickerModal-Bg0Zc8UZ.js} +1 -1
- package/dist/assets/{ImportXmlModal-D-Ns-mYi.js → ImportXmlModal-BccMoaDv.js} +1 -1
- package/dist/assets/{LocalizationEditor-C-TZ2Vqd.js → LocalizationEditor-DVZy2uLy.js} +1 -1
- package/dist/assets/{MonacoEditor-5dvTziHE.js → MonacoEditor-DFYisBG6.js} +1 -1
- package/dist/assets/{NewButtonModal-DOTUaBiJ.js → NewButtonModal-D5Hz1yx4.js} +1 -1
- package/dist/assets/{NewGroupModal-CXy9X9y5.js → NewGroupModal-BgTVG-VJ.js} +1 -1
- package/dist/assets/{NewTabModal-DiGzXYTp.js → NewTabModal-7-ZPcPi-.js} +1 -1
- package/dist/assets/{RuleEditorPanel-DT_uPW8s.js → RuleEditorPanel-BwQzOQBe.js} +1 -1
- package/dist/assets/{ScalingEditorPanel-BFnC7t_K.js → ScalingEditorPanel-B221zNLL.js} +1 -1
- package/dist/assets/{TabDisplayRulesPanel-CdKjedy-.js → TabDisplayRulesPanel-drKzEO_E.js} +1 -1
- package/dist/assets/{UrlComposerModal-DFtXdVW3.js → UrlComposerModal-Bnifp4oB.js} +1 -1
- package/dist/assets/{WebResourceBrowser-FvaNo4rt.js → WebResourceBrowser-qtcNTNge.js} +1 -1
- package/dist/assets/{XmlDrawer-BXAxH3A8.js → XmlDrawer-CN941TbU.js} +1 -1
- package/dist/assets/editor.worker-CdQrwHl8.js +26 -0
- package/dist/assets/index-DjHxPFpB.js +6 -0
- package/dist/index.html +1 -1
- package/dist/stats.html +1 -1
- package/npm-shrinkwrap.json +3 -2
- package/package.json +20 -2
- package/dist/assets/index-G361fmC5.js +0 -6
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mohsinonxrm/pptb-commandbar-studio",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@mohsinonxrm/pptb-commandbar-studio",
|
|
9
|
-
"version": "0.5.
|
|
9
|
+
"version": "0.5.1",
|
|
10
|
+
"license": "AGPL-3.0-only",
|
|
10
11
|
"dependencies": {
|
|
11
12
|
"@dnd-kit/core": "^6.3.1",
|
|
12
13
|
"@dnd-kit/sortable": "^10.0.0",
|
package/package.json
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mohsinonxrm/pptb-commandbar-studio",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"displayName": "Command Bar Studio",
|
|
5
5
|
"description": "Visual designer for Dataverse classic ribbon / command bar customizations — the spiritual successor to Ribbon Workbench, built for Power Platform ToolBox",
|
|
6
6
|
"author": "Mohsin On xRM",
|
|
7
|
+
"license": "AGPL-3.0-only",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"dataverse",
|
|
10
|
+
"power-platform",
|
|
11
|
+
"power-apps",
|
|
12
|
+
"dynamics-365",
|
|
13
|
+
"ribbon",
|
|
14
|
+
"command-bar",
|
|
15
|
+
"ribbon-workbench",
|
|
16
|
+
"ribbon-customization",
|
|
17
|
+
"ribbondiffxml",
|
|
18
|
+
"studio",
|
|
19
|
+
"pptb",
|
|
20
|
+
"toolbox",
|
|
21
|
+
"crm",
|
|
22
|
+
"xrm",
|
|
23
|
+
"microsoft"
|
|
24
|
+
],
|
|
7
25
|
"main": "index.html",
|
|
8
26
|
"icon": "icons/command-bar-studio.svg",
|
|
9
27
|
"repository": {
|
|
@@ -49,7 +67,7 @@
|
|
|
49
67
|
"test:watch": "vitest",
|
|
50
68
|
"test:coverage": "vitest run --coverage",
|
|
51
69
|
"test:ui": "vitest --ui",
|
|
52
|
-
"validate": "
|
|
70
|
+
"validate": "pptb-validate",
|
|
53
71
|
"finalize-package": "npm run validate && npm run build && npm shrinkwrap",
|
|
54
72
|
"release": "release-it",
|
|
55
73
|
"release:dry": "release-it --dry-run",
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/XmlDrawer-BXAxH3A8.js","assets/fluent-icons-DiKr_qRE.js","assets/monaco-BLZnQb2P.js","assets/monaco-Dvl_Svmm.css","assets/xmlGenerator-DEaVrfZJ.js","assets/webResourceService-Ck07E3GN.js","assets/MonacoEditor-5dvTziHE.js","assets/fluent-ui-kUA2U4Gr.js","assets/dnd-DHB99ZH7.js","assets/CommandEditorPanel-BfdeUs_f.js","assets/RuleEditorPanel-DT_uPW8s.js","assets/BulkPublishModal-_JCQ9G-Z.js","assets/NewButtonModal-DOTUaBiJ.js","assets/NewGroupModal-CXy9X9y5.js","assets/NewTabModal-DiGzXYTp.js","assets/ImportXmlModal-D-Ns-mYi.js","assets/CommandPalette-D2Kh5NZ1.js","assets/LocalizationEditor-C-TZ2Vqd.js","assets/IconPickerModal-BAiIRU4A.js","assets/TabDisplayRulesPanel-CdKjedy-.js","assets/ScalingEditorPanel-BFnC7t_K.js","assets/ConflictDrawer-BLiuWHeb.js","assets/WebResourceBrowser-FvaNo4rt.js","assets/UrlComposerModal-DFtXdVW3.js","assets/DiffViewer-BVDCd534.js","assets/server.browser-DfdiBs1P.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{cx as ne,cw as n,a0 as $t,ap as Ro,bL as ze,v as Sn,o as jn,r as wn,bP as Rn,bD as Cn,bJ as In,ad as Co,aH as Ye,ah as Ke,F as Nn,cn as kn,e as Io,f as zn,ae as No,af as ko,b0 as zo,b1 as Bo,by as Ao,bz as To,Q as Eo,R as Do,an as Fo,ao as Oo,D as Po,E as $o,b2 as _o,b3 as Mo,ch as Lo,ci as Ho,bU as Wo,bV as Go,bG as qo,bH as Uo,bM as Vo,bN as Xo,bA as Yo,bB as Ko,n as Jo,u as Zo,s as Qo,t as er,c as tr,d as nr,b_ as or,b$ as rr,bm as ir,bn as ar,bw as sr,bx as lr,I as cr,J as dr,ag as ur,c3 as pr,c4 as mr,c0 as gr,c1 as Bn,b6 as fr,b7 as br,aS as hr,aT as xr,aO as yr,aP as vr,be as Sr,bf as jr,cq as wr,cr as Rr,co as Cr,cp as Ir,aF as Nr,aG as Pe,aE as kr,ca as zr,cb as Br,cc as Ar,cd as Tr,aU as Er,aV as Dr,bY as Fr,bZ as Or,ce as Pr,cf as $r,ab as _r,ac as Mr,M as Lr,N as Hr,bk as Wr,bl as Gr,b4 as qr,b5 as Ur,aQ as Vr,aR as An,y as Xr,z as Yr,i as Kr,j as Jr,B as Zr,C as Qr,aL as ei,aM as ti,aK as ni,aN as oi,ax as ri,ay as ii,az as ai,aA as ct,c5 as si,c6 as li,O as ci,P as di,cj as ui,ck as pi,bg as mi,bh as gi,G as fi,H as bi,K as hi,L as xi,bq as yi,br as vi,bo as Si,bp as ji,bs as wi,bt as Tn,bS as Ri,bT as Ci,ba as Ii,bb as Ni,b8 as ki,b9 as Je,bC as zi,av as Bi,aw as En,Y as Ai,Z as Ti,cm as Ei,a_ as Di,a$ as Fi,bO as Oi,aW as Pi,aX as $i,bi as _i,bj as Mi,a6 as Li,a7 as Dn,$ as Hi,g as Wi,h as Gi,w as qi,x as Ui,p as Vi,q as Xi,k as Yi,l as Ki,aI as Ji,aJ as Zi,bK as Qi,bu as ea,bv as ta,S as na,T as oa,bc as ra,bd as ia,bQ as aa,bR as sa,a9 as la,aa as ca,al as da,am as ua,ai as pa,aj as qe,bI as ma,aC as ga,aD as dt,aq as fa,ar as at,A as ba,a as ce,b as $e,aZ as st,cg as Fn,m as On,bF as ha,cy as Pn,c2 as xa,ak as ya,aB as va}from"./fluent-icons-DiKr_qRE.js";import{f as Sa,m as ja,b as de,_ as re,r as z}from"./monaco-BLZnQb2P.js";import{a0 as wa,a2 as Ra,Q as F,P as Ca,z as Ia,a as W,B as oe,a1 as s,y as Na,F as se,b as ka,S as Ae,O as za,u as be,w as he,v as ut,d as Ba,h as Aa,i as Ta,f as Ea,g as Da,e as Fa,V as Be,M as wt,t as Rt,s as Ct,r as It,q as Q,p as Ne,a3 as Oa,a4 as Pa,L as $a,X as _a,ac as $n,ae as Ma,ab as La,$ as Ha,aa as Wa,a5 as Ga,a9 as qa,a8 as Ua,_ as Va,a7 as Xa,ad as Ya,a6 as Ka,Z as Ja,W as Re,J as _t,I as xe,c as _n,D as Mn,G as Ln,R as Za,j as ke,E as Qa,N as ft,H as Mt,K as Lt,T as fe,o as es,af as ts,ag as ns}from"./fluent-ui-kUA2U4Gr.js";import{u as os,f as Hn,e as lt,K as Wn,P as Gn,D as qn,c as rs,a as is,d as Un,b as as,S as ss,h as ls,g as cs,C as ds}from"./dnd-DHB99ZH7.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"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function o(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=o(i);fetch(i.href,a)}})();Sa.config({monaco:ja});var ot={},Kt;function us(){if(Kt)return ot;Kt=1;var e=wa();return ot.createRoot=e.createRoot,ot.hydrateRoot=e.hydrateRoot,ot}var ps=us();const Jt=e=>{let t;const o=new Set,r=(h,m)=>{const u=typeof h=="function"?h(t):h;if(!Object.is(u,t)){const S=t;t=m??(typeof u!="object"||u===null)?u:Object.assign({},t,u),o.forEach(I=>I(t,S))}},i=()=>t,c={setState:r,getState:i,getInitialState:()=>d,subscribe:h=>(o.add(h),()=>o.delete(h))},d=t=e(r,i,c);return c},ms=(e=>e?Jt(e):Jt),gs=e=>e;function fs(e,t=gs){const o=de.useSyncExternalStore(e.subscribe,de.useCallback(()=>t(e.getState()),[e,t]),de.useCallback(()=>t(e.getInitialState()),[e,t]));return de.useDebugValue(o),o}const bs=e=>{const t=ms(e),o=r=>fs(t,r);return Object.assign(o,t),o},Ze=(e=>bs),Y=Ze()(e=>({connectionUrl:"",connectionName:"",environment:"Dev",publisherPrefix:"new",solutions:[],activeSolution:null,entities:[],activeEntity:null,solutionEntityIds:null,solutionRibbonComponentIds:null,currentUserId:"",currentUserName:"",formRibbonScope:"entity",entityForms:[],selectedFormId:"",setConnection:(t,o,r)=>e({connectionUrl:t,connectionName:o,environment:r}),setSolutions:t=>e({solutions:t}),setActiveSolution:t=>{re(async()=>{const{useRuntimeLogStore:o}=await Promise.resolve().then(()=>ws);return{useRuntimeLogStore:o}},void 0).then(({useRuntimeLogStore:o})=>{o.getState().logInfo("dataverse",`Active solution: "${t.friendlyName||t.uniqueName}" — publisher="${t.publisherUniqueName||"(empty)"}", prefix="${t.publisherPrefix||"(empty)"}"`),(!t.publisherPrefix||t.publisherPrefix==="new"||/^defaultpublisher/i.test(t.publisherUniqueName??""))&&o.getState().logWarn("dataverse",`Solution "${t.friendlyName||t.uniqueName}" uses the org's default publisher (prefix="${t.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.`)}),e({activeSolution:t,publisherPrefix:t.publisherPrefix||"new",activeEntity:null,solutionEntityIds:null,solutionRibbonComponentIds:null})},setEntities:t=>e({entities:t}),setActiveEntity:t=>e({activeEntity:t}),setSolutionEntityIds:t=>e({solutionEntityIds:t}),setSolutionRibbonComponentIds:t=>e({solutionRibbonComponentIds:t}),setCurrentUser:(t,o)=>e({currentUserId:t,currentUserName:o}),setPublisherPrefix:t=>e({publisherPrefix:t}),setFormRibbonScope:t=>e({formRibbonScope:t}),setEntityForms:t=>e(o=>{const r=t.some(i=>i.formId===o.selectedFormId)?o.selectedFormId:t[0]?.formId??"";return{entityForms:t,selectedFormId:r}}),setSelectedFormId:t=>e({selectedFormId:t})})),hs=e=>(t,o,r)=>{const i=r.subscribe;return r.subscribe=((l,c,d)=>{let h=l;if(c){const m=d?.equalityFn||Object.is;let u=l(r.getState());h=S=>{const I=l(S);if(!m(u,I)){const g=u;c(u=I,g)}},d?.fireImmediately&&c(u,u)}return i(h)}),e(t,o,r)},xs=hs;function ys(e,t){let o;try{o=e()}catch{return}return{getItem:i=>{var a;const l=d=>d===null?null:JSON.parse(d,void 0),c=(a=o.getItem(i))!=null?a:null;return c instanceof Promise?c.then(l):l(c)},setItem:(i,a)=>o.setItem(i,JSON.stringify(a,void 0)),removeItem:i=>o.removeItem(i)}}const Nt=e=>t=>{try{const o=e(t);return o instanceof Promise?o:{then(r){return Nt(r)(o)},catch(r){return this}}}catch(o){return{then(r){return this},catch(r){return Nt(r)(o)}}}},vs=(e,t)=>(o,r,i)=>{let a={storage:ys(()=>window.localStorage),partialize:b=>b,version:0,merge:(b,v)=>({...v,...b}),...t},l=!1,c=0;const d=new Set,h=new Set;let m=a.storage;if(!m)return e((...b)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),o(...b)},r,i);const u=()=>{const b=a.partialize({...r()});return m.setItem(a.name,{state:b,version:a.version})},S=i.setState;i.setState=(b,v)=>(S(b,v),u());const I=e((...b)=>(o(...b),u()),r,i);i.getInitialState=()=>I;let g;const f=()=>{var b,v;if(!m)return;const x=++c;l=!1,d.forEach(p=>{var w;return p((w=r())!=null?w:I)});const y=((v=a.onRehydrateStorage)==null?void 0:v.call(a,(b=r())!=null?b:I))||void 0;return Nt(m.getItem.bind(m))(a.name).then(p=>{if(p)if(typeof p.version=="number"&&p.version!==a.version){if(a.migrate){const w=a.migrate(p.state,p.version);return w instanceof Promise?w.then(A=>[!0,A]):[!0,w]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,p.state];return[!1,void 0]}).then(p=>{var w;if(x!==c)return;const[A,T]=p;if(g=a.merge(T,(w=r())!=null?w:I),o(g,!0),A)return u()}).then(()=>{x===c&&(y?.(r(),void 0),g=r(),l=!0,h.forEach(p=>p(g)))}).catch(p=>{x===c&&y?.(void 0,p)})};return i.persist={setOptions:b=>{a={...a,...b},b.storage&&(m=b.storage)},clearStorage:()=>{m?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>f(),hasHydrated:()=>l,onHydrate:b=>(d.add(b),()=>{d.delete(b)}),onFinishHydration:b=>(h.add(b),()=>{h.delete(b)})},a.skipHydration||f(),g||I},Ss=vs,js=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,conflictDrawerOpen:!1,conflictElementId:null,webResourceBrowserOpen:!1,urlComposerOpen:!1,diffViewerOpen:!1,diffViewerMode:"compare",tabDisplayRulesOpen:!1,scalingEditorOpen:!1,commandPaletteOpen:!1,newTabOpen:!1,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,o)=>e({ruleEditorOpen:!0,ruleEditorId:t,ruleEditorKind:o}),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:()=>e({importXmlOpen:!0}),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}),announce:t=>e({announcement:t})}),M=Ze()(Ss(js,{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})})),J=Ze()((e,t)=>({entries:[],append:o=>{const i={id:`${Date.now()}-${t().entries.length+1}`,ts:new Date().toISOString(),...o};e({entries:[...t().entries,i].slice(-400)})},logInfo:(o,r)=>t().append({scope:o,level:"info",message:r}),logWarn:(o,r)=>t().append({scope:o,level:"warn",message:r}),logError:(o,r)=>t().append({scope:o,level:"error",message:r}),clear:()=>e({entries:[]})})),ws=Object.freeze(Object.defineProperty({__proto__:null,useRuntimeLogStore:J},Symbol.toStringTag,{value:"Module"}));function ue(e){return JSON.parse(JSON.stringify(e))}function ie(e,t,o){const r=ue(e.ribbons);t(r);const i={...o,snapshot:{...e}},a=[...e.past,i].slice(-80);return{ribbons:r,past:a,future:[],mutationsSincePublish:e.mutationsSincePublish+1}}const Zt={HomepageGrid:{location:"HomepageGrid",entityLogicalName:"",tabs:[]},SubGrid:{location:"SubGrid",entityLogicalName:"",tabs:[]},Form:{location:"Form",entityLogicalName:"",tabs:[]},Application:{location:"Application",entityLogicalName:"",tabs:[]}};function De(e,t,o){return e==="Application"&&t==="Mscrm.GlobalTab"&&o.oob===!0&&o.custom!==!0}const O=Ze()(xs((e,t)=>({ribbons:ue(Zt),baseline:ue(Zt),commands:[],displayRules:[],enableRules:[],locLabels:[],templates:[],conflicts:[],mutationsSincePublish:0,past:[],future:[],loadRibbons(o){e({ribbons:ue(o),baseline:ue(o),mutationsSincePublish:0,past:[],future:[]})},setConflicts(o){e({conflicts:o})},loadWorkspace(o){const r=ue(o.ribbons);e({ribbons:r,baseline:ue(r),commands:[...o.commands],displayRules:[...o.displayRules],enableRules:[...o.enableRules],locLabels:[...o.locLabels],templates:[...o.templates??[]],conflicts:[...o.conflicts??[]],mutationsSincePublish:0,past:[],future:[]})},undo(){const{past:o,future:r,ribbons:i}=t();if(o.length===0)return;const a=o[o.length-1];e({ribbons:a.snapshot.ribbons,past:o.slice(0,-1),future:[{...a,snapshot:{...t(),ribbons:i}},...r],mutationsSincePublish:Math.max(0,t().mutationsSincePublish-1)})},redo(){const{future:o,ribbons:r}=t();if(o.length===0)return;const[i,...a]=o;e({ribbons:i.snapshot.ribbons,past:[...t().past,{...i,snapshot:{...t(),ribbons:r}}],future:a,mutationsSincePublish:t().mutationsSincePublish+1})},restore(o){const{past:r}=t();if(o<0||o>=r.length)return;const i=r[o],a={ribbons:ue(t().ribbons),baseline:ue(t().baseline),commands:[...t().commands],displayRules:[...t().displayRules],enableRules:[...t().enableRules],locLabels:[...t().locLabels],templates:[...t().templates],conflicts:[...t().conflicts],mutationsSincePublish:t().mutationsSincePublish,past:[...t().past],future:[...t().future]};e({ribbons:ue(i.snapshot.ribbons),baseline:ue(i.snapshot.baseline),commands:[...i.snapshot.commands],displayRules:[...i.snapshot.displayRules],enableRules:[...i.snapshot.enableRules],locLabels:[...i.snapshot.locLabels],templates:[...i.snapshot.templates],conflicts:[...i.snapshot.conflicts],mutationsSincePublish:i.snapshot.mutationsSincePublish,past:r.slice(0,o+1),future:[{ts:new Date().toISOString(),userId:"",userName:"You",op:"restored",target:i.target,detail:"from history",icon:"clock_arrow_counterclockwise",color:"info",snapshot:a},...t().future]})},moveButton(o,r){e(i=>ie(i,a=>{const l=a[o.location].tabs.find(I=>I.id===o.tabId);if(!l)return;const c=l.groups.find(I=>I.id===o.groupId);if(!c)return;const d=c.buttons.findIndex(I=>I.id===o.buttonId);if(d===-1||De(o.location,o.tabId,c.buttons[d]))return;const[h]=c.buttons.splice(d,1),m=o.tabId===r.tabId&&o.location===r.location?l:a[r.location].tabs.find(I=>I.id===r.tabId);if(!m)return;const u=m.groups.find(I=>I.id===r.groupId);if(!u)return;const S=r.beforeButtonId?u.buttons.findIndex(I=>I.id===r.beforeButtonId):u.buttons.length;u.buttons.splice(S<0?u.buttons.length:S,0,h)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"moved",target:o.buttonId,detail:`to ${r.groupId}`,icon:"arrow_move",color:"info"}))},setButtonProp(o,r,i,a,l){e(c=>ie(c,d=>{const u=d[o].tabs.find(S=>S.id===r)?.groups.find(S=>S.id===i)?.buttons.find(S=>S.id===a);u&&(De(o,r,u)||Object.assign(u,l))},{ts:new Date().toISOString(),userId:"",userName:"You",op:"edited",target:l.label??a,detail:Object.keys(l).join(", "),icon:"edit",color:"info"}))},deleteButton(o,r,i,a){e(l=>ie(l,c=>{const h=c[o].tabs.find(u=>u.id===r)?.groups.find(u=>u.id===i);if(!h)return;const m=h.buttons.find(u=>u.id===a);m&&(De(o,r,m)||(h.buttons=h.buttons.filter(u=>u.id!==a)))},{ts:new Date().toISOString(),userId:"",userName:"You",op:"deleted",target:a,detail:i,icon:"delete",color:"danger"}))},duplicateButton(o,r,i,a){e(l=>ie(l,c=>{const h=c[o].tabs.find(u=>u.id===r)?.groups.find(u=>u.id===i),m=h?.buttons.find(u=>u.id===a);if(m&&h){if(De(o,r,m))return;const u={...m,id:`${m.id}_copy_${Date.now()}`,label:`${m.label} (copy)`,custom:!0,oob:!1,managed:!1,origin:"unmanaged",sequence:m.sequence+5},S=h.buttons.findIndex(I=>I.id===a);h.buttons.splice(S+1,0,u)}},{ts:new Date().toISOString(),userId:"",userName:"You",op:"duplicated",target:a,detail:i,icon:"copy",color:"info"}))},createButton({tabId:o,groupId:r,location:i,button:a}){e(l=>ie(l,c=>{const h=c[i].tabs.find(m=>m.id===o)?.groups.find(m=>m.id===r);if(h){const m={...a,id:a.id??`new_${Date.now()}`,label:a.label??"New Button",kind:a.kind??"button",sequence:a.sequence??(h.buttons.length+1)*10,templateAlias:a.templateAlias??"o1",commandId:a.commandId??"",hidden:a.hidden??!1,oob:!1,custom:!0,managed:!1,origin:"unmanaged"};h.buttons.push(m)}},{ts:new Date().toISOString(),userId:"",userName:"You",op:"added",target:a.label??"New Button",detail:r,icon:"add",color:"success"}))},createGroup({tabId:o,location:r,group:i}){e(a=>ie(a,l=>{const c=l[r].tabs.find(d=>d.id===o);if(c){const d={id:i.id??`grp_${Date.now()}`,label:i.label??"New Group",sequence:i.sequence??(c.groups.length+1)*10,template:i.template??"Flexible2",buttons:i.buttons??[]};c.groups.push(d)}},{ts:new Date().toISOString(),userId:"",userName:"You",op:"added",target:i.label??"New Group",detail:o,icon:"add",color:"success"}))},renameGroup(o,r,i,a){e(l=>ie(l,c=>{const h=c[o].tabs.find(m=>m.id===r)?.groups.find(m=>m.id===i);h&&(h.label=a)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"renamed",target:i,detail:a,icon:"edit",color:"info"}))},duplicateGroup(o,r,i){e(a=>ie(a,l=>{const c=l[o].tabs.find(S=>S.id===r);if(!c)return;const d=c.groups.find(S=>S.id===i);if(!d)return;const h=`_copy_${Date.now()}`,m={...JSON.parse(JSON.stringify(d)),id:`${d.id}${h}`,label:`${d.label} (copy)`,sequence:d.sequence+5,buttons:d.buttons.map(S=>({...S,id:`${S.id}${h}`,custom:!0,oob:!1,managed:!1,origin:"unmanaged"}))},u=c.groups.findIndex(S=>S.id===i);c.groups.splice(u+1,0,m)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"duplicated",target:i,detail:r,icon:"copy",color:"info"}))},setGroupTemplate(o,r,i,a){e(l=>ie(l,c=>{const h=c[o].tabs.find(m=>m.id===r)?.groups.find(m=>m.id===i);h&&(h.template=a)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"edited",target:i,detail:`template → ${a}`,icon:"edit",color:"info"}))},deleteGroup(o,r,i){e(a=>ie(a,l=>{const c=l[o].tabs.find(d=>d.id===r);c&&(c.groups=c.groups.filter(d=>d.id!==i))},{ts:new Date().toISOString(),userId:"",userName:"You",op:"deleted",target:i,detail:r,icon:"delete",color:"danger"}))},createTab(o,r){e(i=>ie(i,a=>{const l=a[o],c={id:r.id??`tab_${Date.now()}`,label:r.label??"New Tab",sequence:r.sequence??(l.tabs.length+1)*10,tabDisplayRules:[],groups:[]};l.tabs.push(c)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"added",target:r.label??"New Tab",detail:o,icon:"add",color:"success"}))},renameTab(o,r,i){e(a=>ie(a,l=>{const c=l[o].tabs.find(d=>d.id===r);c&&(c.label=i)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"renamed",target:r,detail:i,icon:"edit",color:"info"}))},deleteTab(o,r){e(i=>ie(i,a=>{a[o].tabs=a[o].tabs.filter(l=>l.id!==r)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"deleted",target:r,detail:o,icon:"delete",color:"danger"}))},reorderTabs(o,r){e(i=>ie(i,a=>{const l=a[o].tabs;a[o].tabs=r.map(c=>l.find(d=>d.id===c)).filter(c=>c!==void 0)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"reordered",target:"Tabs",detail:o,icon:"arrow_sort",color:"info"}))},setTabDisplayRules(o,r,i){e(a=>ie(a,l=>{const c=l[o].tabs.find(d=>d.id===r);c&&(c.tabDisplayRules=i)},{ts:new Date().toISOString(),userId:"",userName:"You",op:"edited",target:`${r} display rules`,detail:`${i.length} rule(s)`,icon:"eye",color:"info"}))},setScaling(o,r,i){e(a=>ie(a,l=>{const c=l[o];c.scalingByTab=c.scalingByTab??{},c.scalingByTab[r]={tabId:r,maxSizes:[...i.maxSizes],scales:[...i.scales]}},{ts:new Date().toISOString(),userId:"",userName:"You",op:"edited",target:`${r} scaling`,detail:`${i.maxSizes.length} MaxSize, ${i.scales.length} Scale`,icon:"resize",color:"info"}))},hideOobButton(o,r,i,a){e(l=>ie(l,c=>{const m=c[o].tabs.find(u=>u.id===r)?.groups.find(u=>u.id===i)?.buttons.find(u=>u.id===a);m&&(De(o,r,m)||(m.hidden=!0))},{ts:new Date().toISOString(),userId:"",userName:"You",op:"hid",target:a,detail:i,icon:"eye_off",color:"warn"}))},customizeOobButton(o,r,i,a){e(l=>ie(l,c=>{const m=c[o].tabs.find(u=>u.id===r)?.groups.find(u=>u.id===i)?.buttons.find(u=>u.id===a);if(m){if(De(o,r,m))return;m.oob=!1,m.custom=!0,m.managed=!1,m.origin="unmanaged"}},{ts:new Date().toISOString(),userId:"",userName:"You",op:"customized",target:a,detail:"OOB override",icon:"edit",color:"info"}))},upsertCommand(o){e(r=>{const i=r.commands.findIndex(l=>l.id===o.id);return{commands:i>=0?r.commands.map((l,c)=>c===i?o:l):[...r.commands,o],mutationsSincePublish:r.mutationsSincePublish+1}})},renameCommandId(o,r){const i=t();return!o||!r||o===r?!0:i.commands.some(a=>a.id===r)?!1:(e(a=>{const l=ue(a.ribbons);for(const h of Object.keys(l))for(const m of l[h].tabs)for(const u of m.groups)for(const S of u.buttons)S.commandId===o&&(S.commandId=r);const c=a.commands.map(h=>h.id===o?{...h,id:r}:h),d={ts:new Date().toISOString(),userId:"",userName:"You",op:"renamed",target:o,detail:`command -> ${r}`,icon:"edit",color:"info",snapshot:{...a}};return{ribbons:l,commands:c,past:[...a.past,d].slice(-80),future:[],mutationsSincePublish:a.mutationsSincePublish+1}}),!0)},upsertDisplayRule(o){e(r=>{const i=r.displayRules.findIndex(l=>l.id===o.id);return{displayRules:i>=0?r.displayRules.map((l,c)=>c===i?o:l):[...r.displayRules,o],mutationsSincePublish:r.mutationsSincePublish+1}})},renameDisplayRuleId(o,r){const i=t();return!o||!r||o===r?!0:i.displayRules.some(a=>a.id===r)?!1:(e(a=>{const l=a.displayRules.map(h=>h.id===o?{...h,id:r}:h),c=a.commands.map(h=>({...h,displayRules:h.displayRules.map(m=>m===o?r:m)})),d={ts:new Date().toISOString(),userId:"",userName:"You",op:"renamed",target:o,detail:`display rule -> ${r}`,icon:"edit",color:"info",snapshot:{...a}};return{displayRules:l,commands:c,past:[...a.past,d].slice(-80),future:[],mutationsSincePublish:a.mutationsSincePublish+1}}),!0)},upsertEnableRule(o){e(r=>{const i=r.enableRules.findIndex(l=>l.id===o.id);return{enableRules:i>=0?r.enableRules.map((l,c)=>c===i?o:l):[...r.enableRules,o],mutationsSincePublish:r.mutationsSincePublish+1}})},renameEnableRuleId(o,r){const i=t();return!o||!r||o===r?!0:i.enableRules.some(a=>a.id===r)?!1:(e(a=>{const l=a.enableRules.map(h=>h.id===o?{...h,id:r}:h),c=a.commands.map(h=>({...h,enableRules:h.enableRules.map(m=>m===o?r:m)})),d={ts:new Date().toISOString(),userId:"",userName:"You",op:"renamed",target:o,detail:`enable rule -> ${r}`,icon:"edit",color:"info",snapshot:{...a}};return{enableRules:l,commands:c,past:[...a.past,d].slice(-80),future:[],mutationsSincePublish:a.mutationsSincePublish+1}}),!0)},upsertLocLabel(o){e(r=>{const i=r.locLabels.findIndex(l=>l.id===o.id);return{locLabels:i>=0?r.locLabels.map((l,c)=>c===i?o:l):[...r.locLabels,o]}})},markPublished(){e(o=>({baseline:ue(o.ribbons),mutationsSincePublish:0}))}}))),Rs=ne({root:{height:"40px",display:"flex",alignItems:"center",gap:s.spacingHorizontalS,padding:`0 ${s.spacingHorizontalM}`,backgroundColor:s.colorNeutralBackground3,borderBottom:`1px solid ${s.colorNeutralStroke2}`,flexShrink:0},brand:{display:"flex",alignItems:"center",gap:s.spacingHorizontalS,marginRight:s.spacingHorizontalS},brandMark:{width:"24px",height:"24px",borderRadius:"4px",backgroundColor:s.colorBrandBackground,display:"flex",alignItems:"center",justifyContent:"center"},spacer:{flex:1},sep:{width:"1px",height:"20px",backgroundColor:s.colorNeutralStroke2,margin:`0 ${s.spacingHorizontalXS}`},paletteButton:{height:"28px",minWidth:"260px",display:"flex",alignItems:"center",gap:s.spacingHorizontalS,padding:`0 ${s.spacingHorizontalS}`,border:`1px solid ${s.colorNeutralStroke1}`,borderRadius:s.borderRadiusMedium,backgroundColor:s.colorNeutralBackground1,cursor:"pointer",color:s.colorNeutralForeground3,fontSize:s.fontSizeBase200,"&:hover":{border:`1px solid ${s.colorNeutralStroke1Hover}`,backgroundColor:s.colorNeutralBackground1Hover}},kbd:{padding:"1px 4px",border:`1px solid ${s.colorNeutralStroke2}`,borderRadius:"3px",fontSize:s.fontSizeBase100,backgroundColor:s.colorNeutralBackground2},solutionPickerSurface:{padding:s.spacingHorizontalM,minWidth:"360px",display:"flex",flexDirection:"column",gap:s.spacingVerticalS},solutionPickerHint:{color:s.colorNeutralForeground3}});function Cs(){const e=Rs(),[t,o]=z.useState("Loaded"),r=O(p=>p.past),i=O(p=>p.future),a=O(p=>p.undo),l=O(p=>p.redo),c=Y(p=>p.solutions),d=Y(p=>p.activeSolution),h=Y(p=>p.setActiveSolution),m=M(p=>p.openBulkPublish),u=M(p=>p.openXmlDrawer),S=M(p=>p.setCommandPaletteOpen),[I,g]=z.useState(!1),[f,b]=z.useState(""),v=z.useMemo(()=>c.filter(p=>!p.isManaged).map(p=>({value:p.id,children:p.friendlyName||p.uniqueName,searchText:`${p.friendlyName??""} ${p.uniqueName??""}`.toLowerCase(),solution:p})),[c]),x=Ra(f,v,{optionToText:p=>p.searchText,filter:(p,w)=>p.includes(w.toLowerCase()),optionToReactKey:p=>p.value,renderOption:p=>n.jsx(za,{value:p.value,text:p.solution.friendlyName??p.solution.uniqueName,children:n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2,minWidth:0},children:[n.jsx(F,{size:200,weight:"semibold",children:p.solution.friendlyName||p.solution.uniqueName}),n.jsxs(F,{size:100,style:{color:s.colorNeutralForeground3},children:[p.solution.uniqueName," · v",p.solution.version,p.solution.publisherName?` · ${p.solution.publisherName}`:""]})]})},p.value),noOptionsMessage:c.length===0?"Loading solutions…":"No solutions match the filter."}),y=(p,w)=>{const A=c.find(T=>T.id===w.optionValue);A&&(h(A),g(!1),b(""))};return n.jsxs("header",{className:e.root,children:[n.jsxs("div",{className:e.brand,children:[n.jsx("div",{className:e.brandMark,children:n.jsx(F,{size:100,weight:"bold",style:{color:"white",lineHeight:1},children:"CBS"})}),n.jsx(F,{weight:"semibold",size:300,children:"Command Bar Studio"})]}),n.jsx("div",{className:e.sep}),n.jsxs(Ca,{open:I,onOpenChange:(p,w)=>g(w.open),positioning:"below-start",trapFocus:!0,children:[n.jsx(Ia,{disableButtonEnhancement:!0,children:n.jsxs(W,{appearance:d?"subtle":"primary",size:"small",icon:n.jsx(Ro,{}),iconPosition:"before","aria-label":"Select solution",children:[n.jsx(F,{size:200,children:"Solution: "}),n.jsx(F,{size:200,weight:"semibold",children:d?.friendlyName??"Select solution…"}),d&&n.jsxs(n.Fragment,{children:[n.jsx(oe,{appearance:"tint",color:d.isManaged?"informative":"success",size:"small",style:{marginLeft:s.spacingHorizontalXS},children:d.isManaged?"Managed":"Unmanaged"}),(()=>{const p=d.publisherPrefix||"new",w=p==="new"||/^defaultpublisher/i.test(d.publisherUniqueName??"");return n.jsxs(oe,{appearance:"tint",color:w?"warning":"informative",size:"small",title:w?`Imports will land under the org's default publisher "${p}". To use your own publisher, create a new solution in maker.powerapps.com bound to it.`:`Publisher: ${d.publisherName||d.publisherUniqueName||p}`,style:{marginLeft:s.spacingHorizontalXS},children:[p,"_"]})})()]}),n.jsx($t,{fontSize:12,style:{marginLeft:s.spacingHorizontalXS,color:s.colorNeutralForeground3}})]})}),n.jsxs(Na,{className:e.solutionPickerSurface,children:[n.jsx(F,{size:200,weight:"semibold",children:"Select an unmanaged solution"}),n.jsx(se,{label:"Solution",children:n.jsx(ka,{placeholder:c.length===0?"Loading solutions…":"Search by display name or unique name",value:f,onChange:p=>b(p.target.value),onOptionSelect:y,freeform:!0,clearable:!0,children:x})}),n.jsxs(F,{size:100,className:e.solutionPickerHint,children:[v.length," unmanaged solution",v.length!==1?"s":""," available"]})]})]}),n.jsx("div",{className:e.spacer}),n.jsxs("button",{type:"button",className:e.paletteButton,onClick:()=>S(!0),"aria-label":"Search buttons, commands, rules (Ctrl+K)",children:[n.jsx(ze,{fontSize:14}),n.jsx("span",{style:{flex:1,textAlign:"left"},children:"Search buttons, commands, rules…"}),n.jsx("kbd",{className:e.kbd,children:"Ctrl"}),n.jsx("kbd",{className:e.kbd,children:"K"})]}),n.jsx("div",{className:e.sep}),n.jsx(W,{appearance:"subtle",size:"small",icon:n.jsx(Sn,{}),disabled:r.length===0,onClick:a,title:"Undo (Ctrl+Z)","aria-label":"Undo"}),n.jsx(W,{appearance:"subtle",size:"small",icon:n.jsx(jn,{}),disabled:i.length===0,onClick:l,title:"Redo (Ctrl+Shift+Z)","aria-label":"Redo"}),n.jsx("div",{className:e.sep}),n.jsxs(Ae,{value:t,onChange:(p,w)=>o(w.value),size:"small",title:"State simulator","aria-label":"State simulator",children:[n.jsx("option",{value:"Loaded",children:"Loaded"}),n.jsx("option",{value:"Empty",children:"Empty"}),n.jsx("option",{value:"Error",children:"Error"}),n.jsx("option",{value:"Publishing",children:"Publishing"})]}),n.jsx(W,{appearance:"subtle",size:"small",icon:n.jsx(wn,{}),onClick:()=>{u()},title:"Import / Export RibbonDiffXml","aria-label":"Import/Export"}),n.jsx(W,{appearance:"subtle",size:"small",icon:n.jsx(Rn,{}),title:"Settings","aria-label":"Settings"}),n.jsx(W,{appearance:"subtle",size:"small",icon:n.jsx(Cn,{}),title:"Help","aria-label":"Help"}),n.jsx("div",{className:e.sep}),n.jsx(W,{appearance:"secondary",size:"small",icon:n.jsx(In,{}),children:"Save"}),n.jsx(W,{appearance:"primary",size:"small",icon:n.jsx(Co,{}),onClick:m,children:"Publish All"})]})}const Is=ne({root:{height:"36px",display:"flex",alignItems:"center",gap:s.spacingHorizontalS,padding:`0 ${s.spacingHorizontalM}`,backgroundColor:s.colorNeutralBackground2,borderBottom:`1px solid ${s.colorNeutralStroke2}`,flexShrink:0,position:"relative"},breadcrumb:{display:"flex",alignItems:"center",gap:s.spacingHorizontalXS,color:s.colorNeutralForeground3,fontSize:s.fontSizeBase200},separator:{color:s.colorNeutralForeground4},activeSegment:{color:s.colorNeutralForeground1,fontWeight:s.fontWeightSemibold},spacer:{flex:1}});function Ns(){const e=Is(),t=O(u=>u.mutationsSincePublish),o=Y(u=>u.activeSolution),r=Y(u=>u.activeEntity),i=Y(u=>u.connectionUrl),a=M(u=>u.openXmlDrawer),l=M(u=>u.openImportXml),c=M(u=>u.openDiffViewer),d=M(u=>u.rightPaneMode),h=M(u=>u.setRightPaneMode);async function m(){if(!i||!r?.logicalName)return;const u=`${i.replace(/\/$/,"")}/main.aspx?pagetype=entitylist&etn=${encodeURIComponent(r.logicalName)}`;await window.toolboxAPI?.utils.openInConnectionBrowser(u,"primary")}return n.jsxs("div",{className:e.root,children:[n.jsxs("nav",{"aria-label":"Breadcrumb",className:e.breadcrumb,children:[n.jsx("span",{children:"Solutions"}),n.jsx("span",{className:e.separator,children:"›"}),n.jsx("span",{children:o?.friendlyName??"—"}),n.jsx("span",{className:e.separator,children:"›"}),n.jsx("span",{children:"Tables"}),n.jsx("span",{className:e.separator,children:"›"}),n.jsx("span",{className:e.activeSegment,children:r?.displayName??"Select a table"})]}),n.jsx("div",{className:e.spacer}),t>0&&n.jsxs(oe,{appearance:"tint",color:"warning",children:[t," change",t!==1?"s":""," since publish"]}),n.jsx(W,{appearance:"subtle",size:"small",icon:n.jsx(Ye,{}),onClick:()=>{m()},disabled:!r?.logicalName,children:"Preview in app"}),n.jsx(W,{appearance:"subtle",size:"small",icon:n.jsx(Ke,{}),onClick:a,children:"RibbonDiffXml"}),n.jsx(W,{appearance:"subtle",size:"small",icon:n.jsx(wn,{}),onClick:l,children:"Import / Export"}),n.jsx(W,{appearance:"subtle",size:"small",icon:n.jsx(Nn,{}),onClick:()=>c("compare"),children:"Compare"}),n.jsxs(Ae,{size:"small",value:d,onChange:(u,S)=>h(S.value),"aria-label":"Properties pane mode",children:[n.jsx("option",{value:"docked",children:"Properties: Docked"}),n.jsx("option",{value:"floating",children:"Properties: Floating"}),n.jsx("option",{value:"hidden",children:"Properties: Hidden"})]})]})}const q=Ze()(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,o){e({selectedGroupId:t,selectedButtonId:o})},selectButtonInContext(t,o,r,i){e({location:t,tabId:o,selectedGroupId:r,selectedButtonId:i})},clearSelection(){e({selectedButtonId:null,selectedGroupId:null})}}));function ks(){const e=M(x=>x.setCommandPaletteOpen),t=M(x=>x.openBulkPublish),o=M(x=>x.announce),r=O(x=>x.undo),i=O(x=>x.redo),a=O(x=>x.past),l=O(x=>x.future),c=q(x=>x.selectedButtonId),d=q(x=>x.selectedGroupId),h=q(x=>x.tabId),m=q(x=>x.location),u=O(x=>x.duplicateButton),S=O(x=>x.deleteButton),I=O(x=>x.moveButton),g=O(x=>x.ribbons),f=q(x=>x.selectButtonInContext),b=q(x=>x.selectGroup),v=z.useRef(null);z.useEffect(()=>{const x=p=>p.tagName==="INPUT"||p.tagName==="TEXTAREA"||p.isContentEditable,y=p=>{const A=navigator.platform.toUpperCase().includes("MAC")?p.metaKey:p.ctrlKey,T=p.target;if(A&&p.key==="k"){p.preventDefault(),e(!0),o("Command palette opened");return}if(A&&p.key==="s"){p.preventDefault(),t(),o("Bulk publish dialog opened");return}if(A&&p.key==="z"&&!p.shiftKey&&a.length>0){p.preventDefault(),r(),o("Undo");return}if(A&&p.key==="y"||A&&p.shiftKey&&p.key==="z"){p.preventDefault(),l.length>0&&(i(),o("Redo"));return}if(A&&p.key==="d"){c&&d&&h&&m&&(p.preventDefault(),u(m,h,d,c),o("Button duplicated"));return}if(A&&p.key.toLowerCase()==="x"){!x(T)&&c&&d&&h&&m&&(p.preventDefault(),v.current={location:m,tabId:h,groupId:d,buttonId:c},o("Button cut. Focus a destination group, then press paste."));return}if(A&&p.key.toLowerCase()==="v"){const P=v.current;!x(T)&&P&&d&&h&&m&&(p.preventDefault(),I({groupId:P.groupId,buttonId:P.buttonId,tabId:P.tabId,location:P.location},{groupId:d,tabId:h,location:m}),requestAnimationFrame(()=>{f(m,h,d,P.buttonId),document.querySelector(`[data-ribbon-btn-id="${P.buttonId}"]`)?.focus()}),v.current=null,o("Button pasted to destination group."));return}if((p.key==="Delete"||p.key==="Backspace")&&c&&d&&h&&m&&!x(T)){const D=g[m].tabs.find($=>$.id===h)?.groups.flatMap($=>$.buttons.map(C=>({groupId:$.id,buttonId:C.id})))??[],L=D.findIndex($=>$.buttonId===c),B=D[L+1]??D[L-1]??null,j=d;p.preventDefault(),S(m,h,d,c),requestAnimationFrame(()=>{if(B){f(m,h,B.groupId,B.buttonId),document.querySelector(`[data-ribbon-btn-id="${B.buttonId}"]`)?.focus();return}j&&(b(j),document.querySelector(`[data-add-btn-group-id="${j}"]`)?.focus())}),o("Button deleted")}p.key==="Escape"&&e(!1)};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[e,t,o,r,i,a.length,l.length,c,d,h,m,u,S,I,g,f,b])}const zs=ne({handleV:{width:"4px",cursor:"col-resize",backgroundColor:"transparent",flexShrink:0,":hover":{backgroundColor:s.colorNeutralStroke2},":active":{backgroundColor:s.colorBrandStroke1},userSelect:"none"},handleH:{height:"4px",cursor:"row-resize",backgroundColor:"transparent",flexShrink:0,":hover":{backgroundColor:s.colorNeutralStroke2},":active":{backgroundColor:s.colorBrandStroke1},userSelect:"none"}});function bt({direction:e,onResize:t,"aria-label":o=`Resize ${e} pane`}){const r=zs(),i=z.useRef(0),a=z.useCallback(c=>{c.currentTarget.setPointerCapture(c.pointerId),i.current=e==="vertical"?c.clientX:c.clientY},[e]),l=z.useCallback(c=>{if(!c.currentTarget.hasPointerCapture(c.pointerId))return;const d=e==="vertical"?c.clientX:c.clientY,h=d-i.current;i.current=d,t(h)},[e,t]);return n.jsx("div",{className:e==="vertical"?r.handleV:r.handleH,role:"separator","aria-orientation":e==="vertical"?"vertical":"horizontal","aria-label":o,onPointerDown:a,onPointerMove:l})}class Le extends de.Component{state={hasError:!1,error:null};static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,o){console.error("[CBS ErrorBoundary]",this.props.label??"panel",t,o)}handleRetry=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError?this.props.fallback?this.props.fallback:n.jsxs(be,{intent:"error",style:{margin:8},children:[n.jsxs(he,{children:[n.jsx("strong",{children:this.props.label??"Panel"})," encountered an error:"," ",this.state.error?.message??"Unknown error"]}),n.jsx(ut,{children:n.jsx(W,{size:"small",onClick:this.handleRetry,children:"Retry"})})]}):this.props.children}}const Bs=z.lazy(()=>re(()=>import("./XmlDrawer-BXAxH3A8.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8]))),As=z.lazy(()=>re(()=>import("./CommandEditorPanel-BfdeUs_f.js"),__vite__mapDeps([9,1,2,3,7,6,5,8]))),Ts=z.lazy(()=>re(()=>import("./RuleEditorPanel-DT_uPW8s.js"),__vite__mapDeps([10,1,2,3,7,8]))),Es=z.lazy(()=>re(()=>import("./BulkPublishModal-_JCQ9G-Z.js"),__vite__mapDeps([11,1,2,3,4,7,8]))),Ds=z.lazy(()=>re(()=>import("./NewButtonModal-DOTUaBiJ.js"),__vite__mapDeps([12,1,2,3,7,8]))),Fs=z.lazy(()=>re(()=>import("./NewGroupModal-CXy9X9y5.js"),__vite__mapDeps([13,1,2,3,7,8]))),Os=z.lazy(()=>re(()=>import("./NewTabModal-DiGzXYTp.js"),__vite__mapDeps([14,1,2,3,7,8]))),Ps=z.lazy(()=>re(()=>import("./ImportXmlModal-D-Ns-mYi.js"),__vite__mapDeps([15,1,2,3,6,7,8]))),$s=z.lazy(()=>re(()=>import("./CommandPalette-D2Kh5NZ1.js"),__vite__mapDeps([16,1,2,3,7,8]))),_s=z.lazy(()=>re(()=>import("./LocalizationEditor-C-TZ2Vqd.js"),__vite__mapDeps([17,1,2,3,7,8]))),Ms=z.lazy(()=>re(()=>import("./IconPickerModal-BAiIRU4A.js"),__vite__mapDeps([18,1,2,3,5,7,8]))),Ls=z.lazy(()=>re(()=>import("./TabDisplayRulesPanel-CdKjedy-.js"),__vite__mapDeps([19,1,2,3,7,8]))),Hs=z.lazy(()=>re(()=>import("./ScalingEditorPanel-BFnC7t_K.js"),__vite__mapDeps([20,1,2,3,7,8]))),Ws=z.lazy(()=>re(()=>import("./ConflictDrawer-BLiuWHeb.js"),__vite__mapDeps([21,1,2,3,7,8]))),Gs=z.lazy(()=>re(()=>import("./WebResourceBrowser-FvaNo4rt.js"),__vite__mapDeps([22,1,2,3,5,7,8]))),qs=z.lazy(()=>re(()=>import("./UrlComposerModal-DFtXdVW3.js"),__vite__mapDeps([23,1,2,3,7,8]))),Us=z.lazy(()=>re(()=>import("./DiffViewer-BVDCd534.js"),__vite__mapDeps([24,2,3,1,4,7,8]))),Vs=ne({root:{display:"flex",flexDirection:"column",height:"100vh",overflow:"hidden",backgroundColor:s.colorNeutralBackground1,color:s.colorNeutralForeground1,fontFamily:s.fontFamilyBase},body:{display:"flex",flex:1,overflow:"hidden",position:"relative"},leftPane:{flexShrink:0,overflow:"hidden",borderRight:`1px solid ${s.colorNeutralStroke2}`},rightPane:{flexShrink:0,overflow:"hidden",borderLeft:`1px solid ${s.colorNeutralStroke2}`},bottomPanel:{flexShrink:0}});function Xs({children:e,leftPane:t,rightPane:o,bottomPanel:r}){const i=Vs(),a=M(p=>p.leftPaneWidth),l=M(p=>p.rightPaneWidth),c=M(p=>p.rightPaneMode),d=M(p=>p.setLeftPaneWidth),h=M(p=>p.setRightPaneWidth),m=M(p=>p.bottomPanelHeight),u=M(p=>p.bottomCollapsed),S=M(p=>p.setBottomPanelHeight),I=M(p=>p.announcement),g=M(p=>p.xmlDrawerOpen||p.commandEditorOpen||p.ruleEditorOpen||p.bulkPublishOpen||p.newButtonGroupId!==null||p.newGroupOpen||p.newTabOpen||p.importXmlOpen||p.commandPaletteOpen||p.localizationEditorOpen||p.iconPickerOpen||p.tabDisplayRulesOpen||p.scalingEditorOpen||p.conflictDrawerOpen||p.webResourceBrowserOpen||p.urlComposerOpen||p.diffViewerOpen),f=z.useRef(null),b=z.useRef(!1);ks(),z.useEffect(()=>{if(g&&!b.current){const p=document.activeElement;f.current=p instanceof HTMLElement?p:null}if(!g&&b.current){const p=f.current;requestAnimationFrame(()=>{!p||!p.isConnected||p.focus()})}b.current=g},[g]);const v=z.useCallback(p=>{d(Math.max(160,Math.min(500,a+p)))},[a,d]),x=z.useCallback(p=>{h(Math.max(200,Math.min(600,l-p)))},[l,h]),y=z.useCallback(p=>{const w=m-p;S(Math.max(120,Math.min(520,w)))},[m,S]);return n.jsxs("div",{className:i.root,children:[n.jsx(Cs,{}),n.jsx(Ns,{}),n.jsxs("div",{className:i.body,children:[n.jsx("div",{className:i.leftPane,style:{width:a},children:n.jsx(Le,{label:"Left pane",children:t})}),n.jsx(bt,{direction:"vertical",onResize:v,"aria-label":"Resize left pane"}),n.jsx(Le,{label:"Ribbon canvas",children:e}),c==="docked"&&n.jsxs(n.Fragment,{children:[n.jsx(bt,{direction:"vertical",onResize:x,"aria-label":"Resize right pane"}),n.jsx("div",{className:i.rightPane,style:{width:l},children:n.jsx(Le,{label:"Properties pane",children:o})})]}),c==="floating"&&n.jsx("div",{style:{position:"absolute",right:8,top:8,bottom:8,width:l,maxWidth:"90vw",border:`1px solid ${s.colorNeutralStroke2}`,backgroundColor:s.colorNeutralBackground1,boxShadow:s.shadow16,borderRadius:s.borderRadiusMedium,overflow:"hidden",zIndex:10},children:n.jsx(Le,{label:"Properties pane",children:o})})]}),!u&&n.jsx(bt,{direction:"horizontal",onResize:y,"aria-label":"Resize bottom panel"}),n.jsx("div",{className:i.bottomPanel,children:n.jsx(Le,{label:"Bottom panel",children:r})}),n.jsxs(z.Suspense,{fallback:null,children:[n.jsx(Bs,{}),n.jsx(As,{}),n.jsx(Ts,{}),n.jsx(Es,{}),n.jsx(Ds,{}),n.jsx(Fs,{}),n.jsx(Os,{}),n.jsx(Ps,{}),n.jsx($s,{}),n.jsx(_s,{}),n.jsx(Ms,{}),n.jsx(Ls,{}),n.jsx(Hs,{}),n.jsx(Ws,{}),n.jsx(Gs,{}),n.jsx(qs,{}),n.jsx(Us,{})]}),n.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:I})]})}function ye(e,t,o=1033){if(!e)return"";const r=e.match(/^\$LocLabels:(.+)$/);if(r){const a=r[1],l=t.find(c=>c.id===a);if(l){const c=l.titles.find(m=>m.languageCode===o),d=l.titles.find(m=>m.languageCode===1033),h=l.titles[0];return c?.description??d?.description??h?.description??a}return a}const i=e.match(/^\$Resources:(.+)$/);return i?i[1]:e}const Vn=({open:e,buttonLabel:t,onConfirmHide:o,onConfirmDisplayRule:r,onCancel:i})=>n.jsx(Ba,{open:e,onOpenChange:()=>i(),children:n.jsxs(Aa,{style:{maxWidth:"560px"},children:[n.jsxs(Ta,{children:[n.jsx(kn,{style:{marginRight:"8px",color:"var(--colorStatusWarningForeground1)"}}),'Hide "',t,'"']}),n.jsxs(Ea,{children:[n.jsxs(Da,{children:[n.jsx(be,{intent:"warning",children:n.jsxs(he,{children:[n.jsx(F,{weight:"semibold",children:"⚠ HideCustomAction cannot be undone with a patch."})," ","Removing this element requires creating a new updated solution version."]})}),n.jsxs(F,{style:{display:"block",marginTop:"12px"},children:["Consider using a DisplayRule with conflicting rules (e.g."," ",n.jsx("code",{children:"Mscrm.HideOnModern"})," + ",n.jsx("code",{children:"Mscrm.ShowOnlyOnModern"}),") to effectively hide a button without permanently removing it from the definition."]})]}),n.jsxs(Fa,{children:[n.jsx(W,{appearance:"secondary",onClick:i,children:"Cancel"}),n.jsx(W,{appearance:"secondary",onClick:r,children:"Use DisplayRule (recommended — reversible)"}),n.jsx(W,{appearance:"primary",onClick:o,children:"Use HideCustomAction (permanent)"})]})]})]})});function Xn(e){const r=({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 r?r.includes("_")?r.toLowerCase():r.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").toLowerCase():"apps_add_in"}const Yn={add:{regular:ce,filled:ba},delete:{regular:at,filled:fa},edit:{regular:dt,filled:ga},save:{regular:In,filled:ma},copy:{regular:qe,filled:pa},cut:{regular:ua,filled:da},clipboardpaste:{regular:ca,filled:la},share:{regular:sa,filled:aa},mail:{regular:ia,filled:ra},chat:{regular:oa,filled:na},phone:{regular:ta,filled:ea},search:{regular:ze,filled:Qi},filter:{regular:Zi,filled:Ji},arrowleft:{regular:Ki,filled:Yi},arrowright:{regular:Xi,filled:Vi},arrowup:{regular:Ui,filled:qi},arrowdown:{regular:Gi,filled:Wi},chevrondown:{regular:$t,filled:Hi},chevronup:{regular:Dn,filled:Li},navigation:{regular:Mi,filled:_i},home:{regular:$i,filled:Pi},settings:{regular:Rn,filled:Oi},info:{regular:Fi,filled:Di},warning:{regular:kn,filled:Ei},checkmark:{regular:Ti,filled:Ai},dismiss:{regular:En,filled:Bi},questioncircle:{regular:Cn,filled:zi},lockclosed:{regular:Je,filled:ki},lockopen:{regular:Ni,filled:Ii},shield:{regular:Ci,filled:Ri},person:{regular:Tn,filled:wi},people:{regular:ji,filled:Si},personadd:{regular:vi,filled:yi},building:{regular:xi,filled:hi},briefcase:{regular:bi,filled:fi},money:{regular:gi,filled:mi},creditcard:{regular:pi,filled:ui},cart:{regular:di,filled:ci},tag:{regular:li,filled:si},document:{regular:ct,filled:ai},documentbulletlist:{regular:ii,filled:ri},folder:{regular:oi,filled:ni},folderopen:{regular:ti,filled:ei},attach:{regular:Qr,filled:Zr},arrowdownload:{regular:Jr,filled:Kr},arrowupload:{regular:Yr,filled:Xr},globe:{regular:An,filled:Vr},link:{regular:Ur,filled:qr},open:{regular:Gr,filled:Wr},calendar:{regular:Hr,filled:Lr},clock:{regular:Mr,filled:_r},timer:{regular:$r,filled:Pr},star:{regular:Or,filled:Fr},heart:{regular:Dr,filled:Er},thumblike:{regular:Tr,filled:Ar},thumbdislike:{regular:Br,filled:zr},eye:{regular:Ye,filled:kr},eyeoff:{regular:Pe,filled:Nr},zoomin:{regular:Ir,filled:Cr},zoomout:{regular:Rr,filled:wr},maximize:{regular:jr,filled:Sr},minimize:{regular:vr,filled:yr},grid:{regular:xr,filled:hr},list:{regular:br,filled:fr},table:{regular:Bn,filled:gr},tablesimple:{regular:mr,filled:pr},code:{regular:Ke,filled:ur},bug:{regular:dr,filled:cr},play:{regular:lr,filled:sr},pause:{regular:ar,filled:ir},stop:{regular:rr,filled:or},refresh:{regular:nr,filled:tr},arrowsync:{regular:er,filled:Qo},arrowundo:{regular:Sn,filled:Zo},arrowredo:{regular:jn,filled:Jo},printer:{regular:Ko,filled:Yo},send:{regular:Xo,filled:Vo},rocket:{regular:Uo,filled:qo},sparkle:{regular:Go,filled:Wo},trophy:{regular:Ho,filled:Lo},lightbulb:{regular:Mo,filled:_o},bot:{regular:$o,filled:Po},databar:{regular:Oo,filled:Fo},chartmultiple:{regular:Do,filled:Eo},poll:{regular:To,filled:Ao},layoutcolumntwo:{regular:Bo,filled:zo},codeblock:{regular:ko,filled:No},clockarrowcounterclockwise:{regular:zn,filled:Io}},Qe=({name:e,size:t=20,variant:o="regular",style:r,className:i,"aria-hidden":a=!0})=>{const l=Xn(e).replace(/_/g,""),c=Yn[l],d=o==="filled"?c?.filled??c?.regular??$e:c?.regular??$e;return n.jsx(d,{fontSize:t,"aria-hidden":a,className:i,style:{display:"inline-block",verticalAlign:"middle",flexShrink:0,color:s.colorNeutralForeground1,...r}})};async function ud(e,t=32,o="regular"){const r=Xn(e).replace(/_/g,""),i=Yn[r],a=o==="filled"?i?.filled??i?.regular:i?.regular;if(!a)return null;const{renderToStaticMarkup:l}=await re(async()=>{const{renderToStaticMarkup:d}=await import("./server.browser-DfdiBs1P.js").then(h=>h.s);return{renderToStaticMarkup:d}},__vite__mapDeps([25,2,3]));let c=l(de.createElement(a,{fontSize:t}));return c.includes("<svg")?(c.includes("xmlns")||(c=c.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"')),c=c.replace(/width="1em"/,`width="${t}"`).replace(/height="1em"/,`height="${t}"`),c):null}const Kn="__end__";function Ys(e,t){return`slot::${e}::${t??Kn}`}function Ks(e){return`group::${e}`}function Qt(e){if(e.startsWith("slot::")){const[,t,o]=e.split("::");return{kind:"slot",groupId:t,beforeButtonId:o===Kn?null:o}}return e.startsWith("group::")?{kind:"group",groupId:e.slice(7)}:null}const Fe={root:{display:"flex",gap:s.spacingHorizontalM,flexWrap:"wrap",alignItems:"flex-start",minHeight:"120px",padding:`${s.spacingVerticalS} ${s.spacingHorizontalM}`},groupButtons:{display:"flex",gap:s.spacingHorizontalXS,flexWrap:"wrap",minHeight:"72px",alignItems:"flex-start",padding:s.spacingHorizontalXS},groupLabel:{textAlign:"center",fontSize:s.fontSizeBase100,color:s.colorNeutralForeground3,borderTop:`1px solid ${s.colorNeutralStroke2}`,paddingTop:s.spacingVerticalXS,paddingBottom:s.spacingVerticalXS,marginTop:"auto"},emptyTab:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:s.spacingVerticalM,minHeight:"160px",color:s.colorNeutralForeground3,flex:1,padding:"48px",textAlign:"center"},addGroupBtn:{minHeight:"96px",width:"40px",display:"flex",alignItems:"center",justifyContent:"center",border:`1px dashed ${s.colorNeutralStroke2}`,borderRadius:s.borderRadiusMedium,cursor:"pointer",color:s.colorNeutralForeground3,backgroundColor:"transparent"},addButtonGhost:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"60px",minHeight:"72px",borderRadius:s.borderRadiusMedium,border:`1px dashed ${s.colorNeutralStroke2}`,backgroundColor:"transparent",cursor:"pointer",color:s.colorNeutralForeground3}};function Js({button:e}){const t=O(i=>i.locLabels),o=ye(e.label,t),r=e.icon||"apps_add_in";return n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"4px",width:"60px",minHeight:"72px",padding:"4px",borderRadius:s.borderRadiusMedium,border:`1px solid ${s.colorBrandStroke1}`,backgroundColor:s.colorNeutralBackground1,boxShadow:s.shadow16,opacity:.9,cursor:"grabbing",pointerEvents:"none",color:e.custom?s.colorBrandForeground1:s.colorNeutralForeground1},children:[n.jsx(Qe,{name:r,size:24}),n.jsx("span",{style:{fontSize:s.fontSizeBase100,textAlign:"center",lineHeight:"1.2",maxWidth:"56px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:s.colorNeutralForeground1},children:o})]})}function Zs({group:e,isDropTarget:t,children:o,...r}){const{setNodeRef:i,isOver:a}=Un({id:Ks(e.id),data:{type:"group",groupId:e.id}});return n.jsx("div",{ref:i,style:{display:"flex",flexDirection:"column",minWidth:"80px",border:`1px solid ${a||t?s.colorBrandStroke1:s.colorNeutralStroke2}`,borderRadius:s.borderRadiusMedium,backgroundColor:a||t?s.colorBrandBackground2:s.colorNeutralBackground2,padding:`${s.spacingVerticalXS} ${s.spacingHorizontalXS}`,transition:"border-color 0.1s, background-color 0.1s"},...r,children:o})}function en({groupId:e,beforeButtonId:t}){const o=Ys(e,t),{setNodeRef:r,isOver:i}=Un({id:o,data:{type:"slot",groupId:e,beforeButtonId:t}});return n.jsx("div",{ref:r,style:{width:i?"2px":"0px",minHeight:"72px",backgroundColor:s.colorBrandStroke1,borderRadius:"2px",flexShrink:0,transition:"width 0.1s"},"aria-hidden":!0})}function Qs({tab:e,location:t}){const o=O(k=>k.moveButton),r=O(k=>k.createGroup),i=O(k=>k.deleteButton),a=O(k=>k.duplicateButton),l=O(k=>k.duplicateGroup),c=O(k=>k.setGroupTemplate),d=O(k=>k.hideOobButton),h=O(k=>k.customizeOobButton),m=O(k=>k.setButtonProp),u=O(k=>k.renameGroup),S=O(k=>k.deleteGroup),I=M(k=>k.openNewButton),g=M(k=>k.openNewGroup),f=M(k=>k.openIconPicker),b=M(k=>k.openLocalizationEditor),v=q(k=>k.selectButtonInContext),x=q(k=>k.selectGroup),[y,p]=z.useState(null),[w,A]=z.useState(null),[T,P]=z.useState(null),[D,L]=z.useState(null),[B,j]=z.useState(null),$=z.useMemo(()=>{if(!D)return null;for(const k of e.groups){const H=k.buttons.find(G=>G.id===D);if(H)return{button:H,groupId:k.id}}return null},[D,e.groups]),C=Hn(lt(Gn,{activationConstraint:{distance:5}}),lt(Wn)),N=k=>t==="Application"&&e.id==="Mscrm.GlobalTab"&&k.oob&&!k.custom;function _(k){L(String(k.active.id))}function U(k){const H=k.over;if(!H){j(null);return}const G=Qt(String(H.id));j(G?G.groupId:null)}function V(k){const{active:H,over:G}=k;if(L(null),j(null),!G||!H)return;let ee=null;for(const R of e.groups)if(R.buttons.some(E=>E.id===H.id)){ee=R.id;break}if(!ee)return;const K=Qt(String(G.id));K&&(K.kind==="slot"?o({groupId:ee,buttonId:String(H.id),tabId:e.id,location:t},{groupId:K.groupId,beforeButtonId:K.beforeButtonId??void 0,tabId:e.id,location:t}):K.kind==="group"&&K.groupId!==ee&&o({groupId:ee,buttonId:String(H.id),tabId:e.id,location:t},{groupId:K.groupId,tabId:e.id,location:t}))}return e.groups.length===0?n.jsxs("div",{style:Fe.emptyTab,children:[n.jsx(ct,{fontSize:36,"aria-hidden":!0}),n.jsx(F,{children:"This tab has no groups yet"}),n.jsxs("button",{type:"button",style:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"6px 16px",background:s.colorBrandBackground,color:s.colorNeutralForegroundInverted,border:"none",borderRadius:s.borderRadiusMedium,cursor:"pointer",fontSize:s.fontSizeBase300},onClick:()=>g(),children:[n.jsx(ce,{fontSize:12})," Add first group"]})]}):n.jsxs(n.Fragment,{children:[t==="SubGrid"&&n.jsx(be,{intent:"info",style:{margin:`${s.spacingVerticalS} ${s.spacingHorizontalM} 0`},children:n.jsxs(he,{children:["Subgrid ribbons support only 3 native controls: ",n.jsx("strong",{children:"Add"}),","," ",n.jsx("strong",{children:"Show List"}),", and ",n.jsx("strong",{children:"Delete"}),". Their icons cannot be changed."]})}),n.jsxs(qn,{sensors:C,collisionDetection:rs,onDragStart:_,onDragOver:U,onDragEnd:V,children:[n.jsxs("div",{style:Fe.root,role:"treegrid","aria-label":"Ribbon canvas","data-ribbon-canvas-root":"1",children:[e.groups.map(k=>n.jsxs(Zs,{group:k,isDropTarget:B===k.id,role:"rowgroup","aria-label":k.label,tabIndex:0,"data-ribbon-group-id":k.id,onContextMenu:H=>{H.target.closest("[data-btn]")||(H.preventDefault(),A({group:k,x:H.clientX,y:H.clientY}))},onFocus:()=>x(k.id),onKeyDown:H=>{if((H.key==="Enter"||H.key===" ")&&k.buttons.length>0){H.preventDefault();const G=k.buttons[0];if(!G)return;v(t,e.id,k.id,G.id),document.querySelector(`[data-ribbon-btn-id="${G.id}"]`)?.focus()}},children:[n.jsxs("div",{style:Fe.groupButtons,children:[k.buttons.map(H=>n.jsxs(de.Fragment,{children:[D&&n.jsx(en,{groupId:k.id,beforeButtonId:H.id}),n.jsx(el,{button:H,groupId:k.id,tabId:e.id,location:t,activeId:D,onContextMenu:G=>p({groupId:k.id,button:H,x:G.clientX,y:G.clientY})})]},H.id)),D&&n.jsx(en,{groupId:k.id,beforeButtonId:null}),n.jsxs("button",{type:"button",style:Fe.addButtonGhost,"data-add-btn-group-id":k.id,onClick:()=>I(k.id),title:`Add button to ${k.label}`,"aria-label":`Add button to ${k.label}`,children:[n.jsx(ce,{fontSize:16}),n.jsx(F,{size:100,style:{color:"inherit"},children:"Add"})]})]}),n.jsx(Be,{content:`Template: ${k.template||"Flexible2"}`,relationship:"description",children:n.jsx("div",{style:Fe.groupLabel,children:k.label})})]},k.id)),n.jsx("button",{type:"button",style:Fe.addGroupBtn,onClick:()=>r({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:n.jsx(ce,{fontSize:16})})]}),n.jsx(is,{dropAnimation:null,children:$?n.jsx(Js,{button:$.button}):null})]}),y&&n.jsxs(wt,{open:!0,onOpenChange:(k,H)=>!H.open&&p(null),positioning:{position:"below",align:"start",target:{getBoundingClientRect:()=>({x:y.x,y:y.y,top:y.y,left:y.x,right:y.x,bottom:y.y,width:0,height:0,toJSON:()=>({})})}},children:[n.jsx(Rt,{disableButtonEnhancement:!0,children:n.jsx("span",{style:{display:"none"}})}),n.jsx(Ct,{children:n.jsxs(It,{children:[N(y.button)&&n.jsx(Q,{disabled:!0,icon:n.jsx(Je,{}),children:"OOB global command bar buttons cannot be customized."}),N(y.button)&&n.jsx(Ne,{}),n.jsx(Q,{icon:n.jsx(dt,{}),onClick:()=>{v(t,e.id,y.groupId,y.button.id),p(null)},children:"Edit properties"}),n.jsx(Q,{icon:n.jsx(st,{}),disabled:N(y.button),onClick:()=>{v(t,e.id,y.groupId,y.button.id),f(),p(null)},children:"Change icon…"}),n.jsx(Q,{icon:n.jsx(Fn,{}),disabled:N(y.button),onClick:()=>{b(y.button.id),p(null)},children:"Edit labels…"}),n.jsx(Ne,{}),y.button.hidden?n.jsx(Q,{icon:n.jsx(Ye,{}),disabled:N(y.button),onClick:()=>{m(t,e.id,y.groupId,y.button.id,{hidden:!1}),p(null)},children:"Show button"}):n.jsx(Q,{icon:n.jsx(Pe,{}),disabled:N(y.button),onClick:()=>{y.button.oob?P(y):m(t,e.id,y.groupId,y.button.id,{hidden:!0}),p(null)},children:"Hide button"}),(y.button.origin==="oob"||y.button.origin==="managed")&&n.jsx(Q,{icon:n.jsx($e,{}),disabled:N(y.button),onClick:()=>{h(t,e.id,y.groupId,y.button.id),p(null)},children:"Create override…"}),n.jsx(Ne,{}),n.jsx(Q,{icon:n.jsx(qe,{}),disabled:N(y.button),onClick:()=>{a(t,e.id,y.groupId,y.button.id),p(null)},children:"Duplicate"}),e.groups.filter(k=>k.id!==y.groupId).map(k=>n.jsxs(Q,{icon:n.jsx(On,{}),disabled:N(y.button),onClick:()=>{o({groupId:y.groupId,buttonId:y.button.id,tabId:e.id,location:t},{groupId:k.id,tabId:e.id,location:t}),p(null)},children:["Move to: ",k.label]},k.id)),y.button.origin==="unmanaged"&&n.jsxs(n.Fragment,{children:[n.jsx(Ne,{}),n.jsx(Q,{icon:n.jsx(at,{}),disabled:N(y.button),onClick:()=>{i(t,e.id,y.groupId,y.button.id),p(null)},children:"Delete"})]})]})})]}),w&&n.jsxs(wt,{open:!0,onOpenChange:(k,H)=>!H.open&&A(null),positioning:{position:"below",align:"start",target:{getBoundingClientRect:()=>({x:w.x,y:w.y,top:w.y,left:w.x,right:w.x,bottom:w.y,width:0,height:0,toJSON:()=>({})})}},children:[n.jsx(Rt,{disableButtonEnhancement:!0,children:n.jsx("span",{style:{display:"none"}})}),n.jsx(Ct,{children:n.jsxs(It,{children:[n.jsx(Q,{icon:n.jsx(ha,{}),onClick:()=>{const k=window.prompt("Rename group:",w.group.label);k?.trim()&&u(t,e.id,w.group.id,k.trim()),A(null)},children:"Rename…"}),n.jsx(Q,{icon:n.jsx(qe,{}),onClick:()=>{l(t,e.id,w.group.id),A(null)},children:"Duplicate group"}),n.jsx(Q,{icon:n.jsx($e,{}),onClick:()=>{const k=window.prompt("Change group template:",w.group.template);k?.trim()&&c(t,e.id,w.group.id,k.trim()),A(null)},children:"Change template…"}),n.jsx(Ne,{}),n.jsx(Q,{icon:n.jsx(at,{}),onClick:()=>{window.confirm(`Delete group "${w.group.label}"?`)&&S(t,e.id,w.group.id),A(null)},children:"Delete group"})]})})]}),T&&n.jsx(Vn,{open:!0,buttonLabel:T.button.label,onConfirmHide:()=>{d(t,e.id,T.groupId,T.button.id),P(null)},onConfirmDisplayRule:()=>{m(t,e.id,T.groupId,T.button.id,{hidden:!0}),P(null)},onCancel:()=>P(null)})]})}const el=de.memo(function({button:t,groupId:o,tabId:r,location:i,activeId:a,onContextMenu:l}){const c=q(w=>w.selectedButtonId),d=q(w=>w.selectButtonInContext),h=O(w=>w.locLabels),m=c===t.id,u=i==="Application"&&r==="Mscrm.GlobalTab"&&t.oob&&!t.custom,S=ye(t.label,h),{attributes:I,listeners:g,setNodeRef:f,isDragging:b}=os({id:t.id,data:{type:"button",button:t,groupId:o},disabled:t.managed||u}),v=b||a===t.id,x={display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"4px",width:"60px",minHeight:"72px",padding:"4px",borderRadius:s.borderRadiusMedium,cursor:"grab",border:m?`1px solid ${s.colorBrandStroke1}`:t.custom?`1px solid ${s.colorBrandStroke2}`:"1px solid transparent",backgroundColor:m?s.colorBrandBackground2:t.managed?s.colorNeutralBackground3:"transparent",opacity:v?.3:t.hidden?.4:1,position:"relative",userSelect:"none",color:t.custom?s.colorBrandForeground1:s.colorNeutralForeground1,transition:"opacity 0.15s, border-color 0.1s, background-color 0.1s"},y=t.icon||"apps_add_in",p=w=>{if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(w.key))return;w.preventDefault();const A=w.currentTarget.closest("[data-ribbon-canvas-root='1']");if(!A)return;const T=Array.from(A.querySelectorAll(`[data-ribbon-tab-id="${r}"][data-btn="1"]`)),P=T.findIndex(C=>C.dataset.ribbonBtnId===t.id);if(P<0||T.length===0)return;const D=w.key==="ArrowLeft"||w.key==="ArrowUp"?-1:1,L=Math.max(0,Math.min(T.length-1,P+D)),B=T[L],j=B?.dataset.ribbonGroupId,$=B?.dataset.ribbonBtnId;!B||!j||!$||(d(i,r,j,$),B.focus())};return n.jsx(Be,{content:u?"OOB global command bar buttons cannot be customized.":`${S}${t.hidden?" — hidden":""}`,relationship:"label",children:n.jsxs("button",{ref:f,type:"button","data-btn":"1","data-ribbon-tab-id":r,"data-ribbon-group-id":o,"data-ribbon-btn-id":t.id,style:x,"aria-selected":m,"aria-label":`${S}${t.hidden?" — hidden":""}${t.custom?" (custom)":""}${t.managed?" (read-only)":""}`,onClick:()=>d(i,r,o,t.id),onFocus:()=>d(i,r,o,t.id),onKeyDown:w=>{if(w.key==="Enter"||w.key===" "){w.preventDefault(),d(i,r,o,t.id);return}p(w)},onContextMenu:w=>{w.preventDefault(),w.stopPropagation(),d(i,r,o,t.id),l(w)},...I,...g,children:[n.jsx(Qe,{name:y,size:24,style:{filter:t.custom?"none":"grayscale(40%) opacity(0.85)"}}),n.jsx("span",{style:{fontSize:s.fontSizeBase100,textAlign:"center",lineHeight:"1.2",maxWidth:"56px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:s.colorNeutralForeground1},children:S}),t.hidden&&n.jsx("span",{style:{position:"absolute",top:2,right:2},"aria-hidden":!0,children:n.jsx(Pe,{fontSize:10,style:{color:s.colorNeutralForeground3}})}),t.custom&&!t.managed&&n.jsx(oe,{size:"extra-small",color:"brand",appearance:"tint",style:{position:"absolute",bottom:2,right:2},"aria-label":"Custom",children:"NEW"}),(t.managed||u)&&n.jsx("span",{style:{position:"absolute",top:2,left:2},title:u?"OOB global command bar buttons cannot be customized.":"Read-only (managed)",children:n.jsx(Je,{fontSize:10,style:{color:s.colorNeutralForeground3}})})]})})}),rt="application/x-rw-btn",tn="application/x-rw-se",tl=ne({root:{display:"flex",alignItems:"center",gap:s.spacingHorizontalXS,padding:`${s.spacingHorizontalS} 0`,minHeight:"48px"},scrollRow:{display:"flex",alignItems:"center",gap:s.spacingHorizontalXS,flex:1,minWidth:0,overflowX:"auto",overflowY:"hidden",paddingBottom:s.spacingHorizontalXS},button:{display:"flex",alignItems:"center",gap:s.spacingHorizontalXS,height:"32px",padding:`0 ${s.spacingHorizontalS}`,borderRadius:s.borderRadiusMedium,border:"1px solid transparent",cursor:"pointer",backgroundColor:"transparent",color:s.colorNeutralForeground1,whiteSpace:"nowrap",position:"relative",userSelect:"none",":hover":{backgroundColor:s.colorNeutralBackground3,border:`1px solid ${s.colorNeutralStroke1}`},":focus-visible":{outline:`2px solid ${s.colorBrandStroke1}`,outlineOffset:"2px"}},buttonSelected:{backgroundColor:s.colorBrandBackground2,border:`1px solid ${s.colorBrandStroke1}`},buttonHidden:{opacity:.4,textDecoration:"line-through"},buttonCustom:{border:`1px solid ${s.colorBrandStroke2}`},lockIcon:{position:"absolute",top:"4px",left:"4px",color:s.colorNeutralForeground3,pointerEvents:"none"},dropLine:{width:"2px",height:"24px",backgroundColor:s.colorBrandStroke1,borderRadius:"2px",flexShrink:0},overflowBtn:{display:"flex",alignItems:"center",gap:s.spacingHorizontalXS,height:"32px",padding:`0 ${s.spacingHorizontalS}`,borderRadius:s.borderRadiusMedium,border:`1px solid ${s.colorNeutralStroke2}`,backgroundColor:s.colorNeutralBackground2,cursor:"pointer",color:s.colorNeutralForeground3,flexShrink:0},trailingControls:{display:"flex",alignItems:"center",gap:s.spacingHorizontalXS,flexShrink:0,paddingLeft:s.spacingHorizontalS,borderLeft:`1px solid ${s.colorNeutralStroke2}`,marginLeft:s.spacingHorizontalXS}});function nl({tab:e,location:t}){const o=tl(),r=q(C=>C.selectedButtonId),i=q(C=>C.selectButtonInContext),a=O(C=>C.moveButton),l=O(C=>C.deleteButton),c=O(C=>C.duplicateButton),d=O(C=>C.hideOobButton),h=O(C=>C.setButtonProp),m=O(C=>C.customizeOobButton),u=O(C=>C.locLabels),S=M(C=>C.openIconPicker),I=M(C=>C.openLocalizationEditor),g=M(C=>C.openNewButton),[f,b]=z.useState(null),[v,x]=z.useState(null),[y,p]=z.useState(null),[w,A]=z.useState(null),T=C=>t==="Application"&&e.id==="Mscrm.GlobalTab"&&C.oob&&!C.custom,P=e.groups.flatMap(C=>C.buttons.map(N=>({button:N,groupId:C.id})));function D(C,N,_){C.dataTransfer.setData(rt,JSON.stringify({groupId:N,buttonId:_})),C.dataTransfer.effectAllowed="move",x(_)}function L(){x(null),b(null)}function B(C,N){const _=Array.from(C.dataTransfer.types??[]);!_.includes(rt)&&!_.includes(tn)||(C.preventDefault(),C.dataTransfer.dropEffect=_.includes(rt)?"move":"copy",b({beforeButtonId:N}))}const j=O(C=>C.createButton);function $(C,N,_){C.preventDefault();const U=C.dataTransfer.getData(rt);if(U){try{const k=JSON.parse(U);k?.buttonId&&a({groupId:k.groupId,buttonId:k.buttonId,tabId:e.id,location:t},{groupId:N,beforeButtonId:_??void 0,tabId:e.id,location:t})}catch{}b(null),x(null);return}const V=C.dataTransfer.getData(tn);if(V){try{const H=JSON.parse(V)?.button;if(H){const G=`_copy_${Date.now()}`;j({location:t,tabId:e.id,groupId:N,button:{id:`${H.id}${G}`,label:H.label??"New Button",icon:H.icon,kind:H.kind??"button",sequence:50,templateAlias:"o1",commandId:"",hidden:!1,oob:!1,custom:!0,managed:!1}})}}catch{}b(null),x(null);return}b(null),x(null)}return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:o.root,children:[n.jsx("div",{className:o.scrollRow,onDragOver:C=>{C.preventDefault()},onDrop:C=>$(C,e.groups[0]?.id??"",null),children:P.map(({button:C,groupId:N})=>n.jsxs(de.Fragment,{children:[f?.beforeButtonId===C.id&&n.jsx("div",{className:o.dropLine,"aria-hidden":!0}),n.jsx(Be,{content:T(C)?"OOB global command bar buttons cannot be customized.":`${ye(C.label,u)}${C.hidden?" — hidden":""}`,relationship:"label",children:n.jsxs("button",{type:"button",className:[o.button,r===C.id?o.buttonSelected:"",C.hidden?o.buttonHidden:"",C.custom?o.buttonCustom:""].filter(Boolean).join(" "),"aria-selected":r===C.id,"aria-label":`${ye(C.label,u)}${C.hidden?" — hidden":""}`,onClick:()=>i(t,e.id,N,C.id),onContextMenu:_=>{_.preventDefault(),i(t,e.id,N,C.id),p({button:C,groupId:N,x:_.clientX,y:_.clientY})},draggable:!C.managed&&!T(C),onDragStart:_=>D(_,N,C.id),onDragEnd:L,onDragOver:_=>B(_,C.id),onDrop:_=>$(_,N,C.id),style:{opacity:v===C.id?.3:void 0},children:[n.jsx(Qe,{name:C.icon||"apps_add_in",size:16}),n.jsx(F,{size:200,children:ye(C.label,u)}),C.hidden&&n.jsx(Pe,{fontSize:12,"aria-hidden":!0}),C.custom&&n.jsx(oe,{size:"extra-small",color:"brand",appearance:"tint","aria-label":"Custom",children:"NEW"}),T(C)&&n.jsx("span",{className:o.lockIcon,title:"OOB global command bar buttons cannot be customized.",children:n.jsx(Je,{fontSize:12})})]})})]},C.id))}),n.jsx("div",{className:o.trailingControls,children:(()=>{const C=e.groups[0];return C?n.jsx(Be,{content:`Add a new button to "${C.label}"`,relationship:"label",children:n.jsxs("button",{type:"button",className:o.overflowBtn,onClick:()=>g(C.id),"aria-label":"Add a new button",children:[n.jsx(ce,{fontSize:14})," Add"]})}):n.jsx(Be,{content:'No groups in this tab yet. Switch to "Classic ribbon" view to add a group first.',relationship:"label",children:n.jsxs("button",{type:"button",className:o.overflowBtn,disabled:!0,children:[n.jsx(ce,{fontSize:14})," Add"]})})})()})]}),y&&n.jsxs(wt,{open:!0,onOpenChange:(C,N)=>!N.open&&p(null),positioning:{position:"below",align:"start",target:{getBoundingClientRect:()=>({x:y.x,y:y.y,top:y.y,left:y.x,right:y.x,bottom:y.y,width:0,height:0,toJSON:()=>({})})}},children:[n.jsx(Rt,{disableButtonEnhancement:!0,children:n.jsx("span",{style:{display:"none"}})}),n.jsx(Ct,{children:n.jsxs(It,{children:[T(y.button)&&n.jsx(Q,{disabled:!0,children:"OOB global command bar buttons cannot be customized."}),T(y.button)&&n.jsx(Ne,{}),n.jsx(Q,{icon:n.jsx(dt,{}),onClick:()=>{i(t,e.id,y.groupId,y.button.id),p(null)},children:"Edit properties"}),n.jsx(Q,{icon:n.jsx(st,{}),disabled:T(y.button),onClick:()=>{i(t,e.id,y.groupId,y.button.id),S(),p(null)},children:"Change icon…"}),n.jsx(Q,{icon:n.jsx(Fn,{}),disabled:T(y.button),onClick:()=>{I(y.button.id),p(null)},children:"Edit labels…"}),n.jsx(Ne,{}),y.button.hidden?n.jsx(Q,{icon:n.jsx(Ye,{}),disabled:T(y.button),onClick:()=>{h(t,e.id,y.groupId,y.button.id,{hidden:!1}),p(null)},children:"Show button"}):n.jsx(Q,{icon:n.jsx(Pe,{}),disabled:T(y.button),onClick:()=>{y.button.oob?A(y):h(t,e.id,y.groupId,y.button.id,{hidden:!0}),p(null)},children:"Hide button"}),(y.button.origin==="oob"||y.button.origin==="managed")&&n.jsx(Q,{icon:n.jsx($e,{}),disabled:T(y.button),onClick:()=>{m(t,e.id,y.groupId,y.button.id),p(null)},children:"Create override…"}),n.jsx(Ne,{}),n.jsx(Q,{icon:n.jsx(qe,{}),disabled:T(y.button),onClick:()=>{c(t,e.id,y.groupId,y.button.id),p(null)},children:"Duplicate"}),y.button.origin==="unmanaged"&&n.jsx(Q,{icon:n.jsx(at,{}),disabled:T(y.button),onClick:()=>{l(t,e.id,y.groupId,y.button.id),p(null)},children:"Delete"}),e.groups.filter(C=>C.id!==y.groupId).map(C=>n.jsxs(Q,{icon:n.jsx(On,{}),disabled:T(y.button),onClick:()=>{a({groupId:y.groupId,buttonId:y.button.id,tabId:e.id,location:t},{groupId:C.id,tabId:e.id,location:t}),p(null)},children:["Move to: ",C.label]},C.id))]})})]}),w&&n.jsx(Vn,{open:!0,buttonLabel:w.button.label,onConfirmHide:()=>{d(t,e.id,w.groupId,w.button.id),A(null)},onConfirmDisplayRule:()=>{h(t,e.id,w.groupId,w.button.id,{hidden:!0}),A(null)},onCancel:()=>A(null)})]})}const ol=e=>(Oa({...e,renderRow:()=>null}),e),Jn=z.createContext(void 0),rl=void 0,il=()=>{var e;return(e=z.useContext(Jn))!=null?e:rl},al=Jn.Provider,Zn=z.createContext({current:null}),sl={current:null},Qn=()=>{var e;return(e=z.useContext(Zn))!=null?e:sl},ll=Zn.Provider,eo=z.createContext({current:null}),cl={current:null},to=()=>{var e;return(e=z.useContext(eo))!=null?e:cl},dl=eo.Provider,ul=(e,t)=>{const{height:o,itemSize:r,width:i="100%",ariaRowIndexStart:a=2,children:l,listProps:c}=e,d=Qn(),h=to(),u=Pa({...e,children:l},t),S=z.useCallback(({data:f,index:b,style:v,isScrolling:x})=>{const y=f[b];return z.createElement(al,{value:a+b},z.createElement($a,{value:y.rowId},l(y,v,b,x)))},[a,l]),I=z.useCallback(()=>{d.current&&h.current&&h.current.scroll({left:d.current.scrollLeft,behavior:"instant"})},[]),g=z.useCallback(f=>{var b;(b=d.current)==null||b.removeEventListener("scroll",I),d.current=f,f&&f.addEventListener("scroll",I)},[]);return{...u,itemSize:r,height:o,virtualizedRow:S,width:i,ariaRowIndexStart:a,listProps:c,outerRef:g}};function kt(){return kt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var r in o)({}).hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},kt.apply(null,arguments)}function nn(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function zt(e,t){return zt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(o,r){return o.__proto__=r,o},zt(e,t)}function pl(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,zt(e,t)}var on=Number.isNaN||function(t){return typeof t=="number"&&t!==t};function ml(e,t){return!!(e===t||on(e)&&on(t))}function gl(e,t){if(e.length!==t.length)return!1;for(var o=0;o<e.length;o++)if(!ml(e[o],t[o]))return!1;return!0}function ht(e,t){t===void 0&&(t=gl);var o,r=[],i,a=!1;function l(){for(var c=[],d=0;d<arguments.length;d++)c[d]=arguments[d];return a&&o===this&&t(c,r)||(i=e.apply(this,c),a=!0,o=this,r=c),i}return l}var fl=typeof performance=="object"&&typeof performance.now=="function",rn=fl?function(){return performance.now()}:function(){return Date.now()};function an(e){cancelAnimationFrame(e.id)}function bl(e,t){var o=rn();function r(){rn()-o>=t?e.call(null):i.id=requestAnimationFrame(r)}var i={id:requestAnimationFrame(r)};return i}var xt=-1;function sn(e){if(e===void 0&&(e=!1),xt===-1||e){var t=document.createElement("div"),o=t.style;o.width="50px",o.height="50px",o.overflow="scroll",document.body.appendChild(t),xt=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return xt}var Oe=null;function ln(e){if(e===void 0&&(e=!1),Oe===null||e){var t=document.createElement("div"),o=t.style;o.width="50px",o.height="50px",o.overflow="scroll",o.direction="rtl";var r=document.createElement("div"),i=r.style;return i.width="100px",i.height="100px",t.appendChild(r),document.body.appendChild(t),t.scrollLeft>0?Oe="positive-descending":(t.scrollLeft=1,t.scrollLeft===0?Oe="negative":Oe="positive-ascending"),document.body.removeChild(t),Oe}return Oe}var hl=150,xl=function(t,o){return t};function yl(e){var t,o=e.getItemOffset,r=e.getEstimatedTotalSize,i=e.getItemSize,a=e.getOffsetForIndexAndAlignment,l=e.getStartIndexForOffset,c=e.getStopIndexForStartIndex,d=e.initInstanceProps,h=e.shouldResetStyleCacheOnItemSizeChange,m=e.validateProps;return t=(function(u){pl(S,u);function S(g){var f;return f=u.call(this,g)||this,f._instanceProps=d(f.props,nn(f)),f._outerRef=void 0,f._resetIsScrollingTimeoutId=null,f.state={instance:nn(f),isScrolling:!1,scrollDirection:"forward",scrollOffset:typeof f.props.initialScrollOffset=="number"?f.props.initialScrollOffset:0,scrollUpdateWasRequested:!1},f._callOnItemsRendered=void 0,f._callOnItemsRendered=ht(function(b,v,x,y){return f.props.onItemsRendered({overscanStartIndex:b,overscanStopIndex:v,visibleStartIndex:x,visibleStopIndex:y})}),f._callOnScroll=void 0,f._callOnScroll=ht(function(b,v,x){return f.props.onScroll({scrollDirection:b,scrollOffset:v,scrollUpdateWasRequested:x})}),f._getItemStyle=void 0,f._getItemStyle=function(b){var v=f.props,x=v.direction,y=v.itemSize,p=v.layout,w=f._getItemStyleCache(h&&y,h&&p,h&&x),A;if(w.hasOwnProperty(b))A=w[b];else{var T=o(f.props,b,f._instanceProps),P=i(f.props,b,f._instanceProps),D=x==="horizontal"||p==="horizontal",L=x==="rtl",B=D?T:0;w[b]=A={position:"absolute",left:L?void 0:B,right:L?B:void 0,top:D?0:T,height:D?"100%":P,width:D?P:"100%"}}return A},f._getItemStyleCache=void 0,f._getItemStyleCache=ht(function(b,v,x){return{}}),f._onScrollHorizontal=function(b){var v=b.currentTarget,x=v.clientWidth,y=v.scrollLeft,p=v.scrollWidth;f.setState(function(w){if(w.scrollOffset===y)return null;var A=f.props.direction,T=y;if(A==="rtl")switch(ln()){case"negative":T=-y;break;case"positive-descending":T=p-x-y;break}return T=Math.max(0,Math.min(T,p-x)),{isScrolling:!0,scrollDirection:w.scrollOffset<T?"forward":"backward",scrollOffset:T,scrollUpdateWasRequested:!1}},f._resetIsScrollingDebounced)},f._onScrollVertical=function(b){var v=b.currentTarget,x=v.clientHeight,y=v.scrollHeight,p=v.scrollTop;f.setState(function(w){if(w.scrollOffset===p)return null;var A=Math.max(0,Math.min(p,y-x));return{isScrolling:!0,scrollDirection:w.scrollOffset<A?"forward":"backward",scrollOffset:A,scrollUpdateWasRequested:!1}},f._resetIsScrollingDebounced)},f._outerRefSetter=function(b){var v=f.props.outerRef;f._outerRef=b,typeof v=="function"?v(b):v!=null&&typeof v=="object"&&v.hasOwnProperty("current")&&(v.current=b)},f._resetIsScrollingDebounced=function(){f._resetIsScrollingTimeoutId!==null&&an(f._resetIsScrollingTimeoutId),f._resetIsScrollingTimeoutId=bl(f._resetIsScrolling,hl)},f._resetIsScrolling=function(){f._resetIsScrollingTimeoutId=null,f.setState({isScrolling:!1},function(){f._getItemStyleCache(-1,null)})},f}S.getDerivedStateFromProps=function(f,b){return vl(f,b),m(f),null};var I=S.prototype;return I.scrollTo=function(f){f=Math.max(0,f),this.setState(function(b){return b.scrollOffset===f?null:{scrollDirection:b.scrollOffset<f?"forward":"backward",scrollOffset:f,scrollUpdateWasRequested:!0}},this._resetIsScrollingDebounced)},I.scrollToItem=function(f,b){b===void 0&&(b="auto");var v=this.props,x=v.itemCount,y=v.layout,p=this.state.scrollOffset;f=Math.max(0,Math.min(f,x-1));var w=0;if(this._outerRef){var A=this._outerRef;y==="vertical"?w=A.scrollWidth>A.clientWidth?sn():0:w=A.scrollHeight>A.clientHeight?sn():0}this.scrollTo(a(this.props,f,b,p,this._instanceProps,w))},I.componentDidMount=function(){var f=this.props,b=f.direction,v=f.initialScrollOffset,x=f.layout;if(typeof v=="number"&&this._outerRef!=null){var y=this._outerRef;b==="horizontal"||x==="horizontal"?y.scrollLeft=v:y.scrollTop=v}this._callPropsCallbacks()},I.componentDidUpdate=function(){var f=this.props,b=f.direction,v=f.layout,x=this.state,y=x.scrollOffset,p=x.scrollUpdateWasRequested;if(p&&this._outerRef!=null){var w=this._outerRef;if(b==="horizontal"||v==="horizontal")if(b==="rtl")switch(ln()){case"negative":w.scrollLeft=-y;break;case"positive-ascending":w.scrollLeft=y;break;default:var A=w.clientWidth,T=w.scrollWidth;w.scrollLeft=T-A-y;break}else w.scrollLeft=y;else w.scrollTop=y}this._callPropsCallbacks()},I.componentWillUnmount=function(){this._resetIsScrollingTimeoutId!==null&&an(this._resetIsScrollingTimeoutId)},I.render=function(){var f=this.props,b=f.children,v=f.className,x=f.direction,y=f.height,p=f.innerRef,w=f.innerElementType,A=f.innerTagName,T=f.itemCount,P=f.itemData,D=f.itemKey,L=D===void 0?xl:D,B=f.layout,j=f.outerElementType,$=f.outerTagName,C=f.style,N=f.useIsScrolling,_=f.width,U=this.state.isScrolling,V=x==="horizontal"||B==="horizontal",k=V?this._onScrollHorizontal:this._onScrollVertical,H=this._getRangeToRender(),G=H[0],ee=H[1],K=[];if(T>0)for(var R=G;R<=ee;R++)K.push(z.createElement(b,{data:P,key:L(R,P),index:R,isScrolling:N?U:void 0,style:this._getItemStyle(R)}));var E=r(this.props,this._instanceProps);return z.createElement(j||$||"div",{className:v,onScroll:k,ref:this._outerRefSetter,style:kt({position:"relative",height:y,width:_,overflow:"auto",WebkitOverflowScrolling:"touch",willChange:"transform",direction:x},C)},z.createElement(w||A||"div",{children:K,ref:p,style:{height:V?"100%":E,pointerEvents:U?"none":void 0,width:V?E:"100%"}}))},I._callPropsCallbacks=function(){if(typeof this.props.onItemsRendered=="function"){var f=this.props.itemCount;if(f>0){var b=this._getRangeToRender(),v=b[0],x=b[1],y=b[2],p=b[3];this._callOnItemsRendered(v,x,y,p)}}if(typeof this.props.onScroll=="function"){var w=this.state,A=w.scrollDirection,T=w.scrollOffset,P=w.scrollUpdateWasRequested;this._callOnScroll(A,T,P)}},I._getRangeToRender=function(){var f=this.props,b=f.itemCount,v=f.overscanCount,x=this.state,y=x.isScrolling,p=x.scrollDirection,w=x.scrollOffset;if(b===0)return[0,0,0,0];var A=l(this.props,w,this._instanceProps),T=c(this.props,A,w,this._instanceProps),P=!y||p==="backward"?Math.max(1,v):1,D=!y||p==="forward"?Math.max(1,v):1;return[Math.max(0,A-P),Math.max(0,Math.min(b-1,T+D)),A,T]},S})(z.PureComponent),t.defaultProps={direction:"ltr",itemData:void 0,layout:"vertical",overscanCount:2,useIsScrolling:!1},t}var vl=function(t,o){t.children,t.direction,t.height,t.layout,t.innerTagName,t.outerTagName,t.width,o.instance},Sl=yl({getItemOffset:function(t,o){var r=t.itemSize;return o*r},getItemSize:function(t,o){var r=t.itemSize;return r},getEstimatedTotalSize:function(t){var o=t.itemCount,r=t.itemSize;return r*o},getOffsetForIndexAndAlignment:function(t,o,r,i,a,l){var c=t.direction,d=t.height,h=t.itemCount,m=t.itemSize,u=t.layout,S=t.width,I=c==="horizontal"||u==="horizontal",g=I?S:d,f=Math.max(0,h*m-g),b=Math.min(f,o*m),v=Math.max(0,o*m-g+m+l);switch(r==="smart"&&(i>=v-g&&i<=b+g?r="auto":r="center"),r){case"start":return b;case"end":return v;case"center":{var x=Math.round(v+(b-v)/2);return x<Math.ceil(g/2)?0:x>f+Math.floor(g/2)?f:x}default:return i>=v&&i<=b?i:i<v?v:b}},getStartIndexForOffset:function(t,o){var r=t.itemCount,i=t.itemSize;return Math.max(0,Math.min(r-1,Math.floor(o/i)))},getStopIndexForStartIndex:function(t,o,r){var i=t.direction,a=t.height,l=t.itemCount,c=t.itemSize,d=t.layout,h=t.width,m=i==="horizontal"||d==="horizontal",u=o*c,S=m?h:a,I=Math.ceil((S+r-u)/c);return Math.max(0,Math.min(l-1,o+I-1))},initInstanceProps:function(t){},shouldResetStyleCacheOnItemSizeChange:!0,validateProps:function(t){t.itemSize}});const jl=e=>{const{slots:t,slotProps:o}=_a(e),{dir:r}=$n();return z.createElement(t.root,o.root,z.createElement(Sl,{itemSize:e.itemSize,width:e.width,itemData:e.rows,height:e.height,itemCount:e.rows.length,direction:r,outerRef:e.outerRef,...e.listProps},e.virtualizedRow))},Ht=z.forwardRef((e,t)=>{const o=ul(e,t);return ol(o),jl(o)});Ht.displayName="DataGridBody";const wl=(e,t)=>{var o;const{targetDocument:r}=$n(),i=Ma({targetDocument:r}),a=z.useRef(null),l=z.useRef(null);let c=e.containerWidthOffset;c===void 0&&(c=e.selectionMode?-44:0,c-=i||0);const d=La({...e,"aria-rowcount":e.items.length,containerWidthOffset:c},t);return e.resizableColumns&&((o=e.resizableColumnsOptions)==null?void 0:o.autoFitColumns)===!1&&d.root.style&&(d.root.style.minWidth="auto"),{...d,headerRef:a,bodyRef:l}},Rl=(e,t)=>z.createElement(dl,{value:e.headerRef},z.createElement(ll,{value:e.bodyRef},Ha(e,t))),Wt=z.forwardRef((e,t)=>{const o=wl(e,t);return Wa(o),Rl(o,Ga(o))});Wt.displayName="DataGrid";const Cl=(e,t)=>{const o=il();return qa({...e,"aria-rowindex":o},t)},Il=ne({root:{minWidth:"fit-content"}}),Nl=e=>{const t=Il();return e.root.className=Pn(t.root,e.root.className),Ua(e),e},Ue=z.forwardRef((e,t)=>{const o=Cl(e,t);return Nl(o),Va(o)});Ue.displayName="DataGridRow";const kl=(e,t)=>{const o=Qn(),r=to(),i=z.useCallback(()=>{o.current&&r.current&&o.current.scroll({left:r.current.scrollLeft,behavior:"instant"})},[]),a=z.useCallback(c=>{var d;(d=r.current)==null||d.removeEventListener("scroll",i),r.current=c,c&&c.addEventListener("scroll",i)},[]),l=Xa(e,t);return l.root.ref=Ya(l.root.ref,a),l},zl=ne({root:{overflowX:"auto",scrollbarWidth:"none","::-webkit-scrollbar":{width:0,height:0}}}),Bl=e=>{const t=zl();return e.root.className=Pn(t.root,e.root.className),Ka(e),e},Gt=z.forwardRef((e,t)=>{const o=kl(e,t);return Bl(o),Ja(o)});Gt.displayName="DataGridHeader";const Al=ne({root:{width:"100%"},gridWrap:{height:"min(560px, calc(100vh - 320px))",minHeight:"260px"},row:{cursor:"pointer",":hover":{backgroundColor:s.colorNeutralBackground3}},rowSelected:{backgroundColor:s.colorBrandBackground2},iconCell:{width:"20px",height:"20px",borderRadius:"3px",backgroundColor:s.colorNeutralBackground4,display:"flex",alignItems:"center",justifyContent:"center",fontSize:s.fontSizeBase100,color:s.colorNeutralForeground3},clip:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"100%"}});function Tl({tab:e,location:t}){const o=Al(),r=q(g=>g.selectedButtonId),i=q(g=>g.selectButtonInContext),a=O(g=>g.setButtonProp),l=O(g=>g.locLabels),c=g=>t==="Application"&&e.id==="Mscrm.GlobalTab"&&g.oob&&!g.custom,[d,h]=z.useState(""),m=e.groups.flatMap(g=>g.buttons.map(f=>({button:f,groupId:g.id,groupLabel:g.label}))),u=z.useMemo(()=>{const g=d.toLowerCase().trim();return g?m.filter(({button:f,groupLabel:b})=>f.id.toLowerCase().includes(g)||f.label.toLowerCase().includes(g)||(f.commandId??"").toLowerCase().includes(g)||b.toLowerCase().includes(g)):m},[m,d]),S={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}},I=[Re({columnId:"seq",renderHeaderCell:()=>n.jsx(F,{size:200,weight:"semibold",children:"#"}),renderCell:({button:g})=>n.jsx(F,{size:200,children:g.sequence})}),Re({columnId:"icon",renderHeaderCell:()=>n.jsx(F,{size:200,weight:"semibold",children:"Icon"}),renderCell:({button:g})=>n.jsx("div",{className:o.iconCell,children:n.jsx(Qe,{name:g.icon||"apps_add_in",size:16})})}),Re({columnId:"label",renderHeaderCell:()=>n.jsx(F,{size:200,weight:"semibold",children:"Label"}),renderCell:({button:g})=>n.jsx(F,{size:200,className:o.clip,title:g.label,children:ye(g.label,l)})}),Re({columnId:"id",renderHeaderCell:()=>n.jsx(F,{size:200,weight:"semibold",children:"ID"}),renderCell:({button:g})=>n.jsx(F,{size:200,font:"monospace",className:o.clip,title:g.id,style:{color:s.colorNeutralForeground3},children:g.id})}),Re({columnId:"kind",renderHeaderCell:()=>n.jsx(F,{size:200,weight:"semibold",children:"Kind"}),renderCell:({button:g})=>n.jsx(oe,{size:"small",appearance:"outline",children:g.kind})}),Re({columnId:"group",renderHeaderCell:()=>n.jsx(F,{size:200,weight:"semibold",children:"Group"}),renderCell:({groupLabel:g})=>n.jsx(F,{size:200,className:o.clip,title:g,children:ye(g,l)})}),Re({columnId:"command",renderHeaderCell:()=>n.jsx(F,{size:200,weight:"semibold",children:"Command"}),renderCell:({button:g})=>n.jsx(F,{size:200,font:"monospace",className:o.clip,title:g.commandId||"",style:{color:s.colorNeutralForeground3},children:g.commandId||"—"})}),Re({columnId:"visible",renderHeaderCell:()=>n.jsx(F,{size:200,weight:"semibold",children:"Visible"}),renderCell:({button:g,groupId:f})=>n.jsx(_t,{checked:!g.hidden,label:g.hidden?n.jsx(Pe,{fontSize:14}):void 0,disabled:c(g),title:c(g)?"OOB global command bar buttons cannot be customized.":void 0,"aria-label":`Toggle visibility of ${g.label}`,onChange:(b,v)=>a(t,e.id,f,g.id,{hidden:!v.checked})})})];return n.jsxs("div",{className:o.root,children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:s.spacingHorizontalS,padding:`${s.spacingVerticalXS} 0`},children:[n.jsx(xe,{size:"small",contentBefore:n.jsx(ze,{}),placeholder:`Filter ${m.length} button${m.length!==1?"s":""}…`,value:d,onChange:(g,f)=>h(f.value),style:{minWidth:0,flex:1,maxWidth:480}}),d&&n.jsxs(F,{size:100,style:{color:s.colorNeutralForeground3},children:[u.length," match",u.length!==1?"es":""]})]}),n.jsxs(Wt,{className:o.gridWrap,items:u,columns:I,columnSizingOptions:S,resizableColumns:!0,getRowId:g=>g.button.id,focusMode:"composite",sortable:!0,selectionMode:"single",selectedItems:r?new Set([r]):new Set,onSelectionChange:(g,f)=>{const b=[...f.selectedItems][0],v=u.find(x=>x.button.id===b);v&&i(t,e.id,v.groupId,v.button.id)},children:[n.jsx(Gt,{children:n.jsx(Ue,{children:({renderHeaderCell:g})=>n.jsx(_n,{children:g()})})}),n.jsx(Ht,{itemSize:42,height:420,listProps:{width:"100%"},children:({item:g,rowId:f},b)=>n.jsx(Ue,{style:b,className:r===g.button.id?o.rowSelected:o.row,children:({renderCell:v})=>n.jsx(Mn,{children:v(g)})},f)})]})]})}const El=ne({root:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden",backgroundColor:s.colorNeutralBackground1},locationRow:{display:"flex",alignItems:"center",gap:0,padding:`0 ${s.spacingHorizontalM}`,borderBottom:`1px solid ${s.colorNeutralStroke2}`,backgroundColor:s.colorNeutralBackground2,flexShrink:0,height:"36px"},locationTab:{height:"36px",padding:`0 ${s.spacingHorizontalM}`,display:"flex",alignItems:"center",gap:s.spacingHorizontalXS,cursor:"pointer",borderBottom:"2px solid transparent",fontSize:s.fontSizeBase200,color:s.colorNeutralForeground2,":hover":{color:s.colorNeutralForeground1,backgroundColor:s.colorNeutralBackground3}},locationTabActive:{color:s.colorBrandForeground1,borderBottomColor:s.colorBrandStroke1,fontWeight:s.fontWeightSemibold},spacer:{flex:1},tabStrip:{display:"flex",alignItems:"center",gap:0,padding:`0 ${s.spacingHorizontalM}`,borderBottom:`1px solid ${s.colorNeutralStroke2}`,backgroundColor:s.colorNeutralBackground1,flexShrink:0,height:"32px"},ribbonTab:{height:"32px",padding:`0 ${s.spacingHorizontalM}`,display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",cursor:"pointer",borderBottom:"2px solid transparent",":hover":{backgroundColor:s.colorNeutralBackground3}},ribbonTabActive:{borderBottomColor:s.colorBrandStroke1},ribbonTabLabel:{fontSize:s.fontSizeBase200,fontWeight:s.fontWeightSemibold,lineHeight:1.2},ribbonTabMeta:{fontSize:s.fontSizeBase100,color:s.colorNeutralForeground3,lineHeight:1.2},addTabBtn:{height:"24px",width:"24px",minWidth:"24px",marginLeft:s.spacingHorizontalXS,borderRadius:s.borderRadiusMedium,border:`1px dashed ${s.colorNeutralStroke2}`,backgroundColor:"transparent",color:s.colorNeutralForeground3,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",":hover":{border:`1px solid ${s.colorNeutralStroke1}`,backgroundColor:s.colorNeutralBackground2}},inlineTabInput:{height:"28px",fontSize:s.fontSizeBase200,fontWeight:s.fontWeightSemibold,minWidth:"60px",maxWidth:"140px"},canvas:{flex:1,overflow:"auto",padding:s.spacingHorizontalM}}),Dl=ne({root:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px",gap:s.spacingHorizontalM,color:s.colorNeutralForeground3}}),Fl=[{value:"HomepageGrid",label:"Home Grid",icon:n.jsx(Bn,{}),desc:"Mscrm.HomepageGrid.{entity}"},{value:"SubGrid",label:"Sub Grid",icon:n.jsx(xa,{}),desc:"Mscrm.SubGrid.{entity}"},{value:"Form",label:"Form",icon:n.jsx(ct,{}),desc:"Mscrm.Form.{entity}"},{value:"Application",label:"Application",icon:n.jsx(An,{}),desc:"applicationRibbon.xml"}];function Ol({isLoadingRibbon:e=!1,ribbonLoadError:t=null,onRetryRibbonLoad:o}){const r=El(),i=q(B=>B.location),a=q(B=>B.tabId),l=q(B=>B.setLocation),c=q(B=>B.setTabId),d=O(B=>B.ribbons),h=O(B=>B.renameTab),m=O(B=>B.reorderTabs),u=M(B=>B.ribbonViewStyle),S=M(B=>B.setRibbonViewStyle),I=M(B=>B.openXmlDrawer),g=M(B=>B.openTabDisplayRules),f=M(B=>B.openNewGroup),b=M(B=>B.openNewTab),[v,x]=z.useState(null),[y,p]=z.useState(""),w=z.useRef(null);z.useEffect(()=>{v&&w.current&&w.current.focus()},[v]);function A(){v&&y.trim()&&h(i,v,y.trim()),x(null)}const T=Hn(lt(Gn,{activationConstraint:{distance:5}}),lt(Wn)),P=z.useCallback(B=>{const{active:j,over:$}=B;if(!$||j.id===$.id)return;const C=d[i].tabs.map(U=>U.id),N=C.indexOf(String(j.id)),_=C.indexOf(String($.id));N<0||_<0||m(i,as(C,N,_))},[i,d,m]),D=d[i],L=D.tabs.find(B=>B.id===a)??D.tabs[0];return z.useEffect(()=>{if(!D.tabs.length)return;D.tabs.some(j=>j.id===a)||c(D.tabs[0].id)},[D.tabs,a,c]),n.jsxs("main",{className:r.root,"aria-label":"Ribbon canvas",children:[n.jsxs("div",{className:r.locationRow,role:"tablist","aria-label":"Ribbon location",children:[Fl.map(B=>n.jsxs("div",{role:"tab","aria-selected":i===B.value,className:`${r.locationTab} ${i===B.value?r.locationTabActive:""}`,onClick:()=>{l(B.value);const j=d[B.value].tabs[0]?.id;j&&c(j)},title:B.desc,tabIndex:i===B.value?0:-1,children:[B.icon,n.jsx(F,{size:200,children:B.label})]},B.value)),n.jsx("div",{className:r.spacer}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:s.spacingHorizontalS},children:[n.jsx(F,{size:100,style:{color:s.colorNeutralForeground3},children:"View as:"}),n.jsxs(Ae,{value:u,onChange:(B,j)=>S(j.value),size:"small",style:{height:"26px",width:"170px"},children:[n.jsx("option",{value:"classic",children:"Classic ribbon"}),n.jsx("option",{value:"modern",children:"Modern command bar"}),n.jsx("option",{value:"list",children:"List view"})]}),n.jsx(W,{appearance:"subtle",size:"small",icon:n.jsx(Ke,{}),onClick:I,children:"XML"})]})]}),i==="Form"&&n.jsx(be,{intent:"info",style:{flexShrink:0},children:n.jsx(he,{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"&&n.jsx(be,{intent:"info",style:{flexShrink:0},children:n.jsx(he,{children:"Subgrid ribbons support only 3 native controls: Add, Show List, and Delete. Their icons cannot be changed."})}),i==="Application"&&n.jsx(be,{intent:"info",style:{flexShrink:0},children:n.jsx(he,{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."})}),n.jsx(qn,{sensors:T,onDragEnd:P,children:n.jsx(ss,{items:D.tabs.map(B=>B.id),strategy:ls,children:n.jsxs("div",{className:r.tabStrip,role:"tablist","aria-label":"Ribbon tabs",children:[D.tabs.map(B=>n.jsx($l,{tab:B,isActive:L?.id===B.id,isEditing:v===B.id,editValue:y,inputRef:B.id===v?w:void 0,onSelect:()=>{v!==B.id&&c(B.id)},onDoubleClick:()=>{c(B.id),x(B.id),p(B.label)},onF2:()=>{x(B.id),p(B.label)},onEditChange:p,onEditCommit:A,onEditCancel:()=>x(null),styles:r},B.id)),n.jsx("button",{type:"button",className:r.addTabBtn,title:"Add tab","aria-label":"Add tab",onClick:b,children:n.jsx(ce,{fontSize:12})}),n.jsx("div",{className:r.spacer}),n.jsxs(W,{appearance:"subtle",size:"small",icon:n.jsx(Ye,{}),onClick:g,children:["Tab rules",L&&L.tabDisplayRules.length>0&&n.jsx(oe,{size:"small",appearance:"tint",color:"brand",style:{marginLeft:4},children:L.tabDisplayRules.length})]}),L?.template&&n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,paddingRight:s.spacingHorizontalS,fontSize:s.fontSizeBase100,color:s.colorNeutralForeground3},children:[n.jsx("span",{children:"Template:"}),n.jsx(oe,{size:"small",appearance:"outline",children:L.template.split(".").pop()??"—"})]})]})})}),n.jsx("div",{className:r.canvas,children:e?n.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%"},children:n.jsx(Ln,{label:"Loading ribbon definition..."})}):t?n.jsxs(be,{intent:"error",children:[n.jsxs(he,{children:["Failed to load ribbon definition. ",t]}),o&&n.jsx(ut,{containerAction:n.jsx(W,{appearance:"primary",size:"small",onClick:o,children:"Retry"})})]}):L?u==="classic"?n.jsx(Qs,{tab:L,location:i}):u==="modern"?n.jsx(nl,{tab:L,location:i}):n.jsx(Tl,{tab:L,location:i}):n.jsx(Pl,{onAddGroup:f})})]})}function Pl({onAddGroup:e}){const t=Dl();return n.jsxs("div",{className:t.root,children:[n.jsx(ct,{fontSize:32,style:{opacity:.4}}),n.jsx(F,{size:300,children:"This tab has no groups yet"}),n.jsx(W,{appearance:"primary",size:"small",icon:n.jsx(ce,{}),onClick:e,children:"Add first group"})]})}function $l({tab:e,isActive:t,isEditing:o,editValue:r,inputRef:i,onSelect:a,onDoubleClick:l,onF2:c,onEditChange:d,onEditCommit:h,onEditCancel:m,styles:u}){const{attributes:S,listeners:I,setNodeRef:g,transform:f,transition:b,isDragging:v}=cs({id:e.id}),x=O(w=>w.locLabels),y=ye(e.label,x),p={transform:ds.Transform.toString(f),transition:b,opacity:v?.5:1,touchAction:"none"};return n.jsx("div",{ref:g,style:p,...S,...I,className:`${u.ribbonTab} ${t?u.ribbonTabActive:""}`,role:"tab","aria-selected":t,tabIndex:t?0:-1,onClick:a,onDoubleClick:l,onKeyDown:w=>{w.key==="F2"&&c()},children:o?n.jsx(xe,{ref:i,className:u.inlineTabInput,value:r,onChange:(w,A)=>d(A.value),onBlur:h,onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),h()),w.key==="Escape"&&(w.preventDefault(),m()),w.stopPropagation()},onClick:w=>w.stopPropagation(),size:"small","aria-label":"Rename tab"}):n.jsxs(n.Fragment,{children:[n.jsx(F,{className:u.ribbonTabLabel,children:y}),n.jsx(F,{className:u.ribbonTabMeta,children:e.id})]})})}let He=null;const cn={set(e){He=e},invoke(e){const t=He;He=null,t?.(e)},clear(){He=null},hasPending(){return He!==null}},_l=["button","flyout","splitButton","textBox","comboBox","checkBox"],Ml=ne({root:{padding:`${s.spacingHorizontalM}`,display:"flex",flexDirection:"column",gap:s.spacingHorizontalS},sectionLabel:{color:s.colorNeutralForeground3,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:s.spacingHorizontalXS,marginTop:s.spacingHorizontalS},row:{display:"flex",alignItems:"center",gap:s.spacingHorizontalS},localeChips:{display:"flex",flexWrap:"wrap",gap:s.spacingHorizontalXS,alignItems:"center"},iconPreview:{width:"32px",height:"32px",borderRadius:"6px",backgroundColor:s.colorNeutralBackground4,color:s.colorNeutralForeground1,display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${s.colorNeutralStroke2}`,flexShrink:0},webResLink:{fontFamily:s.fontFamilyMonospace,fontSize:s.fontSizeBase200,cursor:"pointer",color:s.colorBrandForeground1,textDecoration:"underline",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:1,border:"none",background:"transparent",textAlign:"left"}});function Ll({button:e,location:t,tabId:o,groupId:r}){const i=Ml(),a=O(g=>g.setButtonProp),l=O(g=>g.locLabels),c=M(g=>g.openIconPicker),d=M(g=>g.openLocalizationEditor),h=M(g=>g.openWebResourceBrowser),m=O(g=>g.customizeOobButton);function u(g){a(t,o,r,e.id,g)}const I=l.find(g=>g.id.startsWith(e.id))?.titles.map(g=>g.languageCode)??[];return n.jsxs("div",{className:i.root,children:[(e.origin==="oob"||e.origin==="managed")&&n.jsx(be,{intent:"warning",children:n.jsx(he,{children:n.jsxs(F,{size:200,children:[e.origin==="oob"?n.jsxs(n.Fragment,{children:["This is an ",n.jsx("strong",{children:"out-of-the-box"})," (system) button. To change it, create an override."]}):n.jsxs(n.Fragment,{children:["This button comes from a ",n.jsx("strong",{children:"managed solution"}),e.solutionName?n.jsxs(n.Fragment,{children:[" ","(",n.jsx("strong",{children:e.solutionName}),")"]}):null,e.publisherName?n.jsxs(n.Fragment,{children:[" by ",e.publisherName]}):null,". You can't edit it directly — create an override to change it."]})," ",n.jsx(W,{size:"small",appearance:"subtle",onClick:()=>m(t,o,r,e.id),children:"Create override"})]})})}),n.jsx(F,{size:100,weight:"semibold",className:i.sectionLabel,children:"Identity"}),n.jsx(se,{label:"Label",children:n.jsx(xe,{value:e.label,onChange:(g,f)=>u({label:f.value})})}),n.jsx(se,{label:"Translations",children:n.jsxs("div",{className:i.localeChips,children:[I.map(g=>n.jsx(oe,{appearance:"filled",color:"informative",style:{cursor:"pointer"},onClick:()=>d(e.id),children:g===1033?"en-US":String(g)},g)),I.length===0&&n.jsx(oe,{appearance:"outline",color:"informative",children:"en-US (default)"}),n.jsx(W,{size:"small",appearance:"subtle",icon:n.jsx(ce,{}),onClick:()=>d(e.id),children:"Add language…"})]})}),n.jsx(se,{label:"Tooltip title",children:n.jsx(xe,{value:e.tooltipTitle??"",onChange:(g,f)=>u({tooltipTitle:f.value})})}),n.jsx(se,{label:"Tooltip body",children:n.jsx(Za,{value:e.tooltipBody??"",onChange:(g,f)=>u({tooltipBody:f.value}),resize:"vertical"})}),n.jsx(ke,{}),n.jsx(se,{label:"Icon",children:n.jsxs("div",{className:i.row,children:[n.jsx("div",{className:i.iconPreview,children:e.icon?n.jsx(Qe,{name:e.icon,size:20}):n.jsx(st,{style:{color:s.colorNeutralForeground3}})}),n.jsx(W,{appearance:"subtle",size:"small",icon:n.jsx(st,{}),onClick:c,children:"Change…"})]})}),e.icon&&n.jsx(se,{label:"ModernImage (auto)",children:n.jsx(xe,{value:`${e.icon}_20_regular`,readOnly:!0,contentAfter:n.jsx(F,{size:100,style:{color:s.colorNeutralForeground3},children:"auto"})})}),e.image16&&n.jsx(se,{label:"Image16",children:n.jsx("div",{className:i.row,children:n.jsx("button",{type:"button",className:i.webResLink,onClick:()=>{cn.set(g=>{u({image16:`$webresource:${g.name}`,icon:g.name.split("/").pop()?.replace(/\..*$/,"")})}),h()},title:e.image16,children:e.image16})})}),e.image32&&n.jsx(se,{label:"Image32",children:n.jsx("div",{className:i.row,children:n.jsx("button",{type:"button",className:i.webResLink,onClick:()=>{cn.set(g=>{u({image32:`$webresource:${g.name}`})}),h()},title:e.image32,children:e.image32})})}),n.jsx(ke,{}),n.jsx(se,{label:"Kind",children:n.jsx(Ae,{value:e.kind,onChange:(g,f)=>u({kind:f.value}),children:_l.map(g=>n.jsx("option",{value:g,children:g},g))})}),n.jsxs("div",{className:i.row,style:{justifyContent:"space-between"},children:[n.jsx(F,{size:200,children:"Visible"}),n.jsx(_t,{checked:!e.hidden,"aria-label":"Toggle button visibility",onChange:(g,f)=>u({hidden:!f.checked})})]}),n.jsx(se,{label:"Sequence",children:n.jsx(Qa,{value:e.sequence,step:10,min:0,onChange:(g,f)=>u({sequence:Number(f.value??e.sequence)})})}),n.jsx(se,{label:"Template alias",children:n.jsx(xe,{value:e.templateAlias,onChange:(g,f)=>u({templateAlias:f.value})})})]})}function qt(e,t,o){const i=`${no()}.${Bt(e)}.${Bt(t)}.Command`;return oo(i,o)}function Ve(e,t,o){const i=`${no()}.${Bt(e)}.${t}Rule`;return oo(i,o)}function no(){try{return Y.getState().publisherPrefix||"new"}catch{return"new"}}function Bt(e){return e.replace(/[^a-zA-Z0-9._]/g,"").replace(/^[^a-zA-Z]/,"x")}function oo(e,t){if(!t.has(e))return e;let o=2;for(;t.has(`${e}${o}`);)o++;return`${e}${o}`}const Hl=ne({root:{padding:`${s.spacingHorizontalM}`,display:"flex",flexDirection:"column",gap:s.spacingHorizontalS},sectionLabel:{color:s.colorNeutralForeground3,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:s.spacingHorizontalXS},commandRow:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:s.spacingHorizontalS,padding:`${s.spacingHorizontalXS} ${s.spacingHorizontalS}`,borderRadius:s.borderRadiusMedium,border:`1px solid ${s.colorNeutralStroke2}`,backgroundColor:s.colorNeutralBackground3},commandId:{fontFamily:s.fontFamilyMonospace,fontSize:s.fontSizeBase200,color:s.colorNeutralForeground1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}});function Wl({button:e,groupId:t,tabId:o,location:r}){const i=Hl(),a=O(g=>g.commands),l=O(g=>g.upsertCommand),c=O(g=>g.setButtonProp),d=M(g=>g.openCommandEditor),[h,m]=de.useState(""),u=a.find(g=>g.id===e.commandId),S=()=>{const g=new Set(a.map(b=>b.id)),f=qt("New","Command",g);l({id:f,enableRules:[],displayRules:[],actions:[]}),c(r,o,t,e.id,{commandId:f}),d(f)},I=()=>{h&&(c(r,o,t,e.id,{commandId:h}),m(""))};return n.jsxs("div",{className:i.root,children:[n.jsx(ke,{}),n.jsx(F,{size:100,weight:"semibold",className:i.sectionLabel,children:"Command"}),u?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:i.commandRow,children:[n.jsx(F,{className:i.commandId,children:u.id}),n.jsx(W,{appearance:"subtle",size:"small",icon:n.jsx(Ke,{}),onClick:()=>d(u.id),children:"Edit"})]}),u.actions.length>0&&n.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:u.actions.map((g,f)=>n.jsx(ft,{size:"extra-small",appearance:"outline",children:g.kind==="javascript"?`JS: ${g.functionName}`:g.kind==="url"?`URL: ${g.address}`:g.kind==="powerFx"?`Fx: ${g.expression}`:`API: ${g.actionName}`},f))}),u.enableRules.length>0&&n.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[n.jsx(F,{size:100,style:{color:s.colorNeutralForeground3},children:"Enable rules:"}),u.enableRules.map(g=>n.jsx(ft,{size:"extra-small",appearance:"outline",color:"success",children:g},g))]}),u.displayRules.length>0&&n.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[n.jsx(F,{size:100,style:{color:s.colorNeutralForeground3},children:"Display rules:"}),u.displayRules.map(g=>n.jsx(ft,{size:"extra-small",appearance:"outline",color:"informative",children:g},g))]})]}):e.commandId?n.jsx("div",{className:i.commandRow,children:n.jsxs(F,{className:i.commandId,style:{color:s.colorStatusWarningForeground3},children:[e.commandId," (not found)"]})}):n.jsxs(n.Fragment,{children:[n.jsx(se,{label:"Bind existing command",style:{width:"100%",minWidth:0},children:n.jsxs(Ae,{size:"small",value:h,onChange:(g,f)=>m(f.value),style:{width:"100%",minWidth:0},children:[n.jsx("option",{value:"",children:"Select command…"}),a.map(g=>n.jsx("option",{value:g.id,children:g.id},g.id))]})}),n.jsxs("div",{style:{display:"flex",gap:s.spacingHorizontalXS},children:[n.jsx(W,{appearance:"outline",size:"small",onClick:I,children:"Bind selected"}),n.jsx(W,{appearance:"outline",size:"small",icon:n.jsx(ce,{}),onClick:S,children:"Create and bind"})]})]})]})}const Gl=ne({section:{display:"flex",flexDirection:"column",gap:s.spacingHorizontalXS},header:{display:"flex",alignItems:"center",gap:s.spacingHorizontalXS},pillList:{display:"flex",flexWrap:"wrap",gap:s.spacingHorizontalXS,maxWidth:"100%",minWidth:0},pill:{display:"inline-flex",alignItems:"center",gap:"4px",padding:`2px ${s.spacingHorizontalXS}`,border:`1px solid ${s.colorNeutralStroke2}`,borderRadius:s.borderRadiusCircular,fontSize:s.fontSizeBase200,fontFamily:s.fontFamilyMonospace,cursor:"pointer",backgroundColor:s.colorNeutralBackground2,maxWidth:"100%",minWidth:0,":hover":{backgroundColor:s.colorNeutralBackground3}},pillLabel:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},addBtn:{alignSelf:"flex-start"},note:{fontSize:s.fontSizeBase100,color:s.colorNeutralForeground3,fontStyle:"italic"}}),ro=({kind:e})=>{const t=Gl(),o=q(j=>j.location),r=q(j=>j.tabId),i=q(j=>j.selectedGroupId),a=q(j=>j.selectedButtonId),l=O(j=>j.commands),c=O(j=>j.displayRules),d=O(j=>j.enableRules),h=O(j=>j.upsertCommand),m=O(j=>j.upsertDisplayRule),u=O(j=>j.upsertEnableRule),S=M(j=>j.openRuleEditor),v=O(j=>j.ribbons)[o].tabs.find(j=>j.id===r)?.groups.find(j=>j.id===i)?.buttons.find(j=>j.id===a),x=l.find(j=>j.id===v?.commandId),y=e==="display"?x?.displayRules??[]:x?.enableRules??[],p=e==="display"?c:d,[w,A]=de.useState(""),T=p.filter(j=>!y.includes(j.id)),P=j=>{if(!x)return;const $=y.filter(C=>C!==j);h(e==="display"?{...x,displayRules:$}:{...x,enableRules:$})},D=e==="display"?"Display rules (ALL must pass)":"Enable rules (ALL must pass)",L=()=>{if(!x)return;if(e==="display"){const C=new Set(c.map(_=>_.id)),N=Ve(x.id.split(".").pop()||"Rule","Display",C);m({id:N,steps:[]}),h({...x,displayRules:[...x.displayRules,N]}),S(N,"display");return}const j=new Set(d.map(C=>C.id)),$=Ve(x.id.split(".").pop()||"Rule","Enable",j);u({id:$,steps:[]}),h({...x,enableRules:[...x.enableRules,$]}),S($,"enable")},B=()=>{!x||!w||(h(e==="display"?{...x,displayRules:[...x.displayRules,w]}:{...x,enableRules:[...x.enableRules,w]}),A(""))};return n.jsxs("div",{className:t.section,children:[n.jsxs("div",{className:t.header,children:[n.jsx(F,{size:200,weight:"semibold",children:D}),y.length>0&&n.jsx(oe,{appearance:"tint",size:"small",color:"informative",children:y.length})]}),!x&&n.jsx(F,{className:t.note,children:"Bind a command first to manage rules."}),n.jsx("div",{className:t.pillList,children:y.map(j=>{const $=p.find(C=>C.id===j);return n.jsxs("div",{className:t.pill,children:[n.jsx("span",{className:t.pillLabel,onClick:()=>S(j,e==="display"?"display":"enable"),title:`${j} — ${$?.steps.length??0} step(s)`,children:j}),n.jsx("button",{style:{background:"none",border:"none",cursor:"pointer",padding:0,display:"flex",color:s.colorNeutralForeground3},onClick:()=>P(j),"aria-label":`Remove rule ${j}`,children:n.jsx(En,{style:{fontSize:12}})})]},j)})}),x&&n.jsxs(n.Fragment,{children:[n.jsx(se,{label:`Bind existing ${e} rule`,style:{width:"100%",minWidth:0},children:n.jsxs(Ae,{size:"small",value:w,onChange:(j,$)=>A($.value),style:{width:"100%",minWidth:0},children:[n.jsx("option",{value:"",children:"Select rule…"}),T.map(j=>n.jsx("option",{value:j.id,children:j.id},j.id))]})}),n.jsxs("div",{style:{display:"flex",gap:s.spacingHorizontalXS},children:[n.jsx(W,{className:t.addBtn,appearance:"subtle",size:"small",onClick:B,disabled:!w,children:"Bind selected"}),n.jsxs(W,{className:t.addBtn,appearance:"subtle",size:"small",icon:n.jsx(ce,{}),onClick:L,children:["Create new ",e," rule"]})]})]}),e==="enable"&&n.jsxs(F,{className:t.note,children:["Note: Disabled buttons are ",n.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."]})]})},ql=()=>n.jsx(ro,{kind:"display"}),Ul=()=>n.jsx(ro,{kind:"enable"}),Vl=ne({section:{display:"flex",flexDirection:"column",gap:s.spacingHorizontalXS},header:{display:"flex",alignItems:"center",gap:s.spacingHorizontalXS},stepRow:{display:"flex",flexDirection:"column",gap:"8px",padding:`${s.spacingVerticalXS} ${s.spacingHorizontalXS}`,border:`1px solid ${s.colorNeutralStroke2}`,borderRadius:s.borderRadiusMedium,backgroundColor:s.colorNeutralBackground2},stepBadge:{alignSelf:"flex-start"},note:{fontSize:s.fontSizeBase100,color:s.colorNeutralForeground3,fontStyle:"italic"},warningNote:{fontSize:s.fontSizeBase100,color:s.colorStatusWarningForeground1,backgroundColor:s.colorStatusWarningBackground1,padding:`2px ${s.spacingHorizontalXS}`,borderRadius:s.borderRadiusSmall}}),Xl=()=>{const e=Vl(),t=M(d=>d.openScalingEditor),o=q(d=>d.location),r=q(d=>d.tabId),l=O(d=>d.ribbons)[o].tabs.find(d=>d.id===r),c=l?.groups.length??0;return n.jsxs("div",{className:e.section,children:[n.jsxs("div",{className:e.header,children:[n.jsx(F,{size:200,weight:"semibold",children:"Scaling"}),n.jsx(W,{appearance:"subtle",size:"small",icon:n.jsx(dt,{}),onClick:t,children:"Edit scaling"})]}),n.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?n.jsxs(F,{size:100,className:e.note,children:["Tab ",n.jsx("strong",{children:l.label})," has ",c," group(s). Open the Scaling Editor to configure MaxSize and Scale steps."]}):n.jsx(F,{size:100,className:e.note,children:"Select a tab to configure scaling."})]})};function io(){return window.dataverseAPI}async function Yl(e){if(e.length===0)return[];const t=io(),o=J.getState();o.logInfo("dataverse",`Loading metadata for ${e.length} solution entit${e.length===1?"y":"ies"}...`);const r="MetadataId,LogicalName,DisplayName,IsCustomEntity,IsIntersect",a=(await Promise.all(e.map(async l=>{try{const c=await t.queryData(`EntityDefinitions(${l})?$select=${r}`);return{metadataId:String(c.MetadataId??""),logicalName:String(c.LogicalName??""),displayName:c.DisplayName?.UserLocalizedLabel?.Label??String(c.LogicalName??""),isCustomEntity:!!c.IsCustomEntity,isManaged:!1,isIntersect:!!c.IsIntersect}}catch(c){return o.logWarn("dataverse",`Could not resolve entity for component ${l}: ${c instanceof Error?c.message:String(c)}`),null}}))).filter(l=>l!==null&&!l.isIntersect).sort((l,c)=>l.displayName.localeCompare(c.displayName));return o.logInfo("dataverse",`Loaded metadata for ${a.length} table(s).`),a}async function Kl(e){if(!e)return[];const t=io();J.getState().logInfo("dataverse",`Loading forms for ${e}...`);const o=`systemforms?$select=formid,name&$filter=objecttypecode eq '${e}' and type eq 2&$orderby=name asc`,a=(await t.queryData(o)).value.filter(l=>!!l.formid).map(l=>({formId:l.formid,name:l.name?.trim()||l.formid}));return J.getState().logInfo("dataverse",`Loaded ${a.length} form(s) for ${e}.`),a}const Jl=ne({section:{display:"flex",flexDirection:"column",gap:s.spacingHorizontalXS},row:{display:"flex",alignItems:"center",gap:s.spacingHorizontalS},note:{fontSize:s.fontSizeBase100,color:s.colorNeutralForeground3}}),Zl=[{label:"Show on Unified Interface (Refresh)",value:"Refresh"},{label:"Show on Classic ribbon (Legacy)",value:"Legacy"},{label:"Show on Tablets (Modern)",value:"Modern"}],Ql=()=>{const e=Jl(),t=q(N=>N.location),o=q(N=>N.tabId),r=q(N=>N.selectedGroupId),i=q(N=>N.selectedButtonId),a=O(N=>N.ribbons),l=O(N=>N.upsertCommand),c=O(N=>N.upsertDisplayRule),d=O(N=>N.commands),h=O(N=>N.displayRules),m=M(N=>N.openCommandEditor),g=a[t].tabs.find(N=>N.id===o)?.groups.find(N=>N.id===r)?.buttons.find(N=>N.id===i),f=t==="HomepageGrid"||t==="SubGrid",b=Y(N=>N.activeEntity),v=Y(N=>N.formRibbonScope),x=Y(N=>N.setFormRibbonScope),y=Y(N=>N.entityForms),p=Y(N=>N.setEntityForms),w=Y(N=>N.selectedFormId),A=Y(N=>N.setSelectedFormId),[T,P]=de.useState(!1),[D,L]=de.useState(null),B=d.some(N=>N.id==="Mscrm.OpenRecordItem"),j=N=>{N&&!B&&(l({id:"Mscrm.OpenRecordItem",enableRules:[],displayRules:[],actions:[{kind:"javascript",library:"$webresource:",functionName:"YourNamespace.openRecord",params:[{kind:"CrmParameter",value:"PrimaryControl"}]}]}),m("Mscrm.OpenRecordItem"))},$=()=>{if(g?.commandId)return d.find(N=>N.id===g.commandId)},C=N=>{const _=$();if(!_)return;let V=h.find(k=>k.steps.length===1&&k.steps[0].kind==="CommandClientTypeRule"&&k.steps[0].type===N)?.id;if(!V){const k=`${_.id}.${N}.DisplayRule`;V=k;let H=1;for(;h.some(K=>K.id===V);)V=`${k}.${H}`,H+=1;c({id:V,steps:[{kind:"CommandClientTypeRule",type:N}]})}_.displayRules.includes(V)||l({..._,displayRules:[..._.displayRules,V]})};return de.useEffect(()=>{if(t!=="Form")return;if(!b?.logicalName){p([]);return}let N=!1;return P(!0),L(null),Kl(b.logicalName).then(_=>{N||p(_)}).catch(_=>{N||(p([]),L(String(_)))}).finally(()=>{N||P(!1)}),()=>{N=!0}},[t,b?.logicalName,p]),n.jsxs("div",{className:e.section,children:[n.jsx(F,{size:200,weight:"semibold",children:"Advanced"}),g&&n.jsx("div",{children:n.jsxs(F,{size:100,className:e.note,children:["Tab: ",n.jsx("code",{style:{fontFamily:s.fontFamilyMonospace},children:o})]})}),f&&n.jsxs("div",{children:[n.jsx(_t,{label:"Override default record open behavior (Mscrm.OpenRecordItem)",checked:B,onChange:(N,_)=>j(_.checked)}),n.jsxs(F,{size:100,className:e.note,children:['When enabled, creates a CommandDefinition with Id="Mscrm.OpenRecordItem" whose JavaScript action overrides what happens when a user double-clicks a grid row or presses Enter on a selected row. ',n.jsx("strong",{children:"Unified Interface only."})," The Command Editor will open so you can set the real web resource and function name."]})]}),t==="Form"&&n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:s.spacingVerticalXS},children:[n.jsx(F,{size:100,weight:"semibold",className:e.note,children:"Form ribbon scope"}),n.jsx(se,{label:"Scope target",children:n.jsxs(Ae,{value:v,onChange:(N,_)=>x(_.value),children:[n.jsx("option",{value:"entity",children:"All forms for this table"}),n.jsx("option",{value:"form",children:"Specific form only"})]})}),v==="form"&&n.jsx(se,{label:"Form picker",hint:"Target systemform for RibbonDiffXml placement",children:n.jsxs(Ae,{value:w,onChange:(N,_)=>A(_.value),disabled:T||y.length===0,children:[y.length===0&&n.jsx("option",{value:"",children:"No forms available"}),y.map(N=>n.jsx("option",{value:N.formId,children:N.name},N.formId))]})}),T&&n.jsx(F,{size:100,className:e.note,children:"Loading forms..."}),D&&n.jsx(be,{intent:"warning",children:n.jsx(he,{children:"Unable to load forms from Dataverse. Specific-form scope requires a valid form ID."})}),n.jsx(F,{size:100,className:e.note,children:"All forms scope maps to ImportExportXml/Entities/Entity/RibbonDiffXml. Specific form scope maps to ImportExportXml/Entities/Entity/FormXml/forms/systemform/form/RibbonDiffXml."})]}),n.jsxs("div",{children:[n.jsx(F,{size:100,weight:"semibold",className:e.note,children:"Client type filter (adds a CommandClientTypeRule):"}),n.jsxs(F,{size:100,className:e.note,children:[n.jsx("strong",{children:"Refresh"})," = Unified Interface web client | ",n.jsx("strong",{children:"Legacy"})," = Classic ribbon / Outlook | ",n.jsx("strong",{children:"Modern"})," = Dynamics 365 for tablets"]}),n.jsx("div",{className:e.row,style:{marginTop:"4px"},children:Zl.map(N=>n.jsx(oe,{appearance:"outline",style:{cursor:"pointer"},title:`Add CommandClientTypeRule: ${N.value}`,onClick:()=>C(N.value),children:N.label},N.value))})]})]})},ec=ne({banner:{marginBottom:s.spacingHorizontalXS}}),tc=()=>{const e=ec(),t=q(v=>v.selectedButtonId),o=q(v=>v.selectedGroupId),r=q(v=>v.location),i=q(v=>v.tabId),a=O(v=>v.conflicts),l=O(v=>v.ribbons),c=M(v=>v.openConflictDrawer),u=l[r].tabs.find(v=>v.id===i)?.groups.find(v=>v.id===o)?.buttons.find(v=>v.id===t),S=a.find(v=>v.elementId===t),I=u?.origin==="managed";if(!t||!I&&!S)return null;const g=u?.solutionName??S?.solutions[0]?.solutionName,f=u?.publisherName??S?.solutions[0]?.publisher,b=S?.solutions.length??(I?1:0);return n.jsxs(be,{intent:"warning",className:e.banner,children:[n.jsx(he,{children:n.jsx(F,{children:b>1?`This button is customized by ${b} solutions. The last imported solution wins.`:`This button belongs to a managed solution${g?` “${g}”`:""}${f?` by ${f}`:""}. Customizing it will create an unmanaged override.`})}),n.jsx(ut,{children:n.jsx(W,{appearance:"transparent",size:"small",onClick:()=>t&&c(t),children:"View solution layers"})})]})},nc=ne({root:{display:"flex",flexDirection:"column",height:"100%",overflowY:"auto",backgroundColor:s.colorNeutralBackground2,borderLeft:`1px solid ${s.colorNeutralStroke2}`},header:{padding:`${s.spacingHorizontalS} ${s.spacingHorizontalM}`,borderBottom:`1px solid ${s.colorNeutralStroke2}`,flexShrink:0},empty:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:1,gap:s.spacingHorizontalM,color:s.colorNeutralForeground3,padding:s.spacingHorizontalXL,textAlign:"center"},section:{padding:`${s.spacingHorizontalS} ${s.spacingHorizontalM}`}});function oc(){const e=nc(),t=q(m=>m.selectedButtonId),o=q(m=>m.selectedGroupId),r=q(m=>m.location),i=q(m=>m.tabId),h=O(m=>m.ribbons)[r].tabs.find(m=>m.id===i)?.groups.find(m=>m.id===o)?.buttons.find(m=>m.id===t);return n.jsxs("aside",{className:e.root,"aria-label":"Properties",children:[n.jsx("div",{className:e.header,children:n.jsx(Mt,{children:"Properties"})}),h?n.jsxs(n.Fragment,{children:[n.jsx(tc,{}),n.jsx(Ll,{button:h,location:r,tabId:i,groupId:o}),n.jsx(ke,{}),n.jsx("div",{className:e.section,children:n.jsx(Wl,{button:h,groupId:o,tabId:i,location:r})}),n.jsx(ke,{}),n.jsx("div",{className:e.section,children:n.jsx(ql,{})}),n.jsx(ke,{}),n.jsx("div",{className:e.section,children:n.jsx(Ul,{})}),n.jsx(ke,{}),n.jsx("div",{className:e.section,children:n.jsx(Xl,{})}),n.jsx(ke,{}),n.jsx("div",{className:e.section,children:n.jsx(Ql,{})})]}):n.jsxs("div",{className:e.empty,children:[n.jsx(ya,{fontSize:32,style:{opacity:.4}}),n.jsx(F,{size:300,children:"Select a button to view its properties"})]})]})}const ao=ne({root:{display:"flex",flexDirection:"column",borderTop:`1px solid ${s.colorNeutralStroke2}`,backgroundColor:s.colorNeutralBackground2,flexShrink:0},tabRow:{display:"flex",alignItems:"center",borderBottom:`1px solid ${s.colorNeutralStroke2}`,gap:0,paddingRight:s.spacingHorizontalS,flexShrink:0},content:{flex:1,overflowY:"auto",padding:`${s.spacingHorizontalXS} ${s.spacingHorizontalM}`},toolbar:{display:"flex",alignItems:"center",gap:s.spacingHorizontalXS,paddingBottom:s.spacingHorizontalXS,borderBottom:`1px solid ${s.colorNeutralStroke3}`,marginBottom:s.spacingHorizontalXS},table:{width:"100%",borderCollapse:"collapse",fontSize:s.fontSizeBase200},th:{textAlign:"left",padding:`4px ${s.spacingHorizontalS}`,fontWeight:s.fontWeightSemibold,color:s.colorNeutralForeground3,fontSize:s.fontSizeBase100,borderBottom:`1px solid ${s.colorNeutralStroke2}`,whiteSpace:"nowrap"},td:{padding:`4px ${s.spacingHorizontalS}`,borderBottom:`1px solid ${s.colorNeutralStroke3}`,verticalAlign:"middle"},mono:{fontFamily:s.fontFamilyMonospace,fontSize:s.fontSizeBase200,cursor:"pointer",color:s.colorBrandForeground1,":hover":{textDecoration:"underline"}},chip:{display:"inline-flex",alignItems:"center",padding:"1px 6px",borderRadius:s.borderRadiusMedium,fontSize:s.fontSizeBase100,border:`1px solid ${s.colorNeutralStroke2}`,backgroundColor:s.colorNeutralBackground3,marginRight:"3px",fontFamily:s.fontFamilyMonospace},historyRow:{display:"flex",alignItems:"flex-start",gap:s.spacingHorizontalS,padding:`${s.spacingHorizontalXS} 0`,borderBottom:`1px solid ${s.colorNeutralStroke3}`},historyAvatar:{width:"24px",height:"24px",borderRadius:"50%",backgroundColor:s.colorBrandBackground2,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,marginTop:"2px"},historyContent:{flex:1,minWidth:0},consoleRow:{padding:"2px 0",fontFamily:s.fontFamilyMonospace,fontSize:s.fontSizeBase200,display:"flex",gap:s.spacingHorizontalS},consoleTs:{color:s.colorNeutralForeground4,flexShrink:0,fontSize:s.fontSizeBase100}});function rc(){const e=ao(),t=M(R=>R.activeBottomTab),o=M(R=>R.setActiveBottomTab),r=M(R=>R.bottomPanelHeight),i=M(R=>R.bottomCollapsed),a=M(R=>R.setBottomCollapsed),l=O(R=>R.commands),c=O(R=>R.displayRules),d=O(R=>R.enableRules),h=O(R=>R.past),m=O(R=>R.ribbons),u=O(R=>R.restore),S=Y(R=>R.currentUserName),I=J(R=>R.entries),g=J(R=>R.clear),f=M(R=>R.openCommandEditor),b=M(R=>R.openRuleEditor),v=M(R=>R.openDiffViewer),x=O(R=>R.upsertCommand),y=O(R=>R.upsertEnableRule),p=O(R=>R.upsertDisplayRule),[w,A]=z.useState(""),[T,P]=z.useState(""),[D,L]=z.useState(""),[B,j]=z.useState(""),$=z.useMemo(()=>{const R=w.toLowerCase().trim();return R?l.filter(E=>E.id.toLowerCase().includes(R)||E.enableRules.some(X=>X.toLowerCase().includes(R))||E.displayRules.some(X=>X.toLowerCase().includes(R))):l},[l,w]),C=z.useMemo(()=>{const R=T.toLowerCase().trim();return R?c.filter(E=>E.id.toLowerCase().includes(R)||E.steps.some(X=>X.kind.toLowerCase().includes(R))):c},[c,T]),N=z.useMemo(()=>{const R=D.toLowerCase().trim();return R?d.filter(E=>E.id.toLowerCase().includes(R)||E.steps.some(X=>X.kind.toLowerCase().includes(R))):d},[d,D]),_=z.useMemo(()=>{const R=B.toLowerCase().trim();return R?h.filter(E=>E.op.toLowerCase().includes(R)||E.target.toLowerCase().includes(R)||E.detail.toLowerCase().includes(R)||E.userName.toLowerCase().includes(R)):h},[h,B]),U=()=>{const R=new Set(l.map(X=>X.id)),E=qt("New","Command",R);x({id:E,enableRules:[],displayRules:[],actions:[]}),f(E)},V=()=>{const R=new Set(d.map(X=>X.id)),E=Ve("New","Enable",R);y({id:E,steps:[]}),b(E,"enable")},k=()=>{const R=new Set(c.map(X=>X.id)),E=Ve("New","Display",R);p({id:E,steps:[]}),b(E,"display")},H=z.useMemo(()=>{const R={};for(const E of Object.values(m))for(const X of E.tabs)for(const Ce of X.groups)for(const ve of Ce.buttons)ve.commandId&&(R[ve.commandId]=(R[ve.commandId]??0)+1);return R},[m]),G=z.useMemo(()=>{const R={};for(const E of l)for(const X of[...E.enableRules,...E.displayRules])R[X]=(R[X]??0)+1;return R},[l]),ee=i?32:r;function K(R){return R.userName&&R.userName!=="You"?R.userName:S||"You"}return n.jsxs("div",{className:e.root,style:{height:ee},children:[n.jsxs("div",{className:e.tabRow,children:[n.jsxs(Lt,{selectedValue:t,onTabSelect:(R,E)=>o(E.value),size:"small",style:{flex:1},children:[n.jsxs(fe,{value:"commands",children:["Commands (",l.length,")"]}),n.jsxs(fe,{value:"displayRules",children:["Display rules (",c.length,")"]}),n.jsxs(fe,{value:"enableRules",children:["Enable rules (",d.length,")"]}),n.jsxs(fe,{value:"history",children:["History (",h.length,")"]}),n.jsx(fe,{value:"console",children:"Console"})]}),n.jsx(W,{appearance:"subtle",size:"small",icon:i?n.jsx(Dn,{}):n.jsx($t,{}),onClick:()=>a(!i),"aria-label":i?"Expand panel":"Collapse panel"})]}),!i&&n.jsxs("div",{className:e.content,children:[t==="commands"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:e.toolbar,children:[n.jsx(W,{appearance:"subtle",size:"small",icon:n.jsx(ce,{}),onClick:U,children:"New command"}),n.jsx(xe,{size:"small",contentBefore:n.jsx(ze,{}),placeholder:`Filter ${l.length} command${l.length!==1?"s":""}…`,value:w,onChange:(R,E)=>A(E.value),style:{minWidth:0,flex:1,maxWidth:360}}),w&&n.jsxs(F,{size:100,style:{color:s.colorNeutralForeground3},children:[$.length," match",$.length!==1?"es":""]})]}),n.jsxs("table",{className:e.table,children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{className:e.th,children:"Command"}),n.jsx("th",{className:e.th,children:"Actions"}),n.jsx("th",{className:e.th,children:"Enable rules"}),n.jsx("th",{className:e.th,children:"Display rules"}),n.jsx("th",{className:e.th,children:"Refs"}),n.jsx("th",{className:e.th})]})}),n.jsx("tbody",{children:$.map(R=>n.jsxs("tr",{children:[n.jsx("td",{className:e.td,children:n.jsx("span",{className:e.mono,onClick:()=>f(R.id),role:"button",tabIndex:0,onKeyDown:E=>E.key==="Enter"&&f(R.id),children:R.id})}),n.jsxs("td",{className:e.td,children:[R.actions.map((E,X)=>n.jsx("span",{className:e.chip,children:E.kind==="javascript"?"JS":E.kind==="url"?"URL":E.kind==="powerFx"?"Fx":"API"},X)),R.actions.length===0&&n.jsx(F,{size:100,style:{color:s.colorNeutralForeground3},children:"—"})]}),n.jsx("td",{className:e.td,children:R.enableRules.map(E=>n.jsx(Be,{content:E,relationship:"label",children:n.jsx("span",{className:e.chip,style:{cursor:"pointer",color:s.colorBrandForeground1},onClick:()=>b(E,"enable"),children:E.split(".").pop()})},E))}),n.jsx("td",{className:e.td,children:R.displayRules.map(E=>n.jsx(Be,{content:E,relationship:"label",children:n.jsx("span",{className:e.chip,style:{cursor:"pointer",color:s.colorBrandForeground1},onClick:()=>b(E,"display"),children:E.split(".").pop()})},E))}),n.jsx("td",{className:e.td,children:n.jsx(oe,{size:"small",appearance:"tint",color:H[R.id]?"brand":"informative",children:H[R.id]??0})}),n.jsx("td",{className:e.td,children:n.jsx(W,{appearance:"subtle",size:"small",onClick:()=>f(R.id),children:"Edit"})})]},R.id))})]})]}),t==="displayRules"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:e.toolbar,children:[n.jsx(W,{appearance:"subtle",size:"small",icon:n.jsx(ce,{}),onClick:k,children:"New display rule"}),n.jsx(xe,{size:"small",contentBefore:n.jsx(ze,{}),placeholder:`Filter ${c.length} display rule${c.length!==1?"s":""}…`,value:T,onChange:(R,E)=>P(E.value),style:{minWidth:0,flex:1,maxWidth:360}}),T&&n.jsxs(F,{size:100,style:{color:s.colorNeutralForeground3},children:[C.length," match",C.length!==1?"es":""]})]}),n.jsx(dn,{rules:C,kind:"display",ruleRefs:G,onEdit:R=>b(R,"display"),styles:e})]}),t==="enableRules"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:e.toolbar,children:[n.jsx(W,{appearance:"subtle",size:"small",icon:n.jsx(ce,{}),onClick:V,children:"New enable rule"}),n.jsx(xe,{size:"small",contentBefore:n.jsx(ze,{}),placeholder:`Filter ${d.length} enable rule${d.length!==1?"s":""}…`,value:D,onChange:(R,E)=>L(E.value),style:{minWidth:0,flex:1,maxWidth:360}}),D&&n.jsxs(F,{size:100,style:{color:s.colorNeutralForeground3},children:[N.length," match",N.length!==1?"es":""]})]}),n.jsx(dn,{rules:N,kind:"enable",ruleRefs:G,onEdit:R=>b(R,"enable"),styles:e})]}),t==="history"&&n.jsxs(n.Fragment,{children:[h.length>0&&n.jsxs("div",{className:e.toolbar,children:[n.jsx(xe,{size:"small",contentBefore:n.jsx(ze,{}),placeholder:`Filter ${h.length} entr${h.length!==1?"ies":"y"}…`,value:B,onChange:(R,E)=>j(E.value),style:{minWidth:0,flex:1,maxWidth:360}}),B&&n.jsxs(F,{size:100,style:{color:s.colorNeutralForeground3},children:[_.length," match",_.length!==1?"es":""]})]}),h.length===0?n.jsx(F,{size:200,style:{color:s.colorNeutralForeground3},children:"No history yet — make a change to see it here."}):_.slice().reverse().map((R,E)=>{const X=h.indexOf(R);return n.jsxs("div",{className:e.historyRow,children:[n.jsx("div",{className:e.historyAvatar,"aria-hidden":!0,children:n.jsx(Tn,{fontSize:12,style:{color:s.colorBrandForeground1}})}),n.jsxs("div",{className:e.historyContent,children:[n.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[n.jsx(F,{size:200,weight:"semibold",children:R.op}),n.jsxs(F,{size:200,children:["— ",n.jsx("strong",{children:R.target})]}),R.detail&&n.jsx(F,{size:100,style:{color:s.colorNeutralForeground3},children:R.detail})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:2},children:[n.jsxs(F,{size:100,style:{color:s.colorNeutralForeground3},children:[K(R)," ·"," ",new Date(R.ts).toLocaleTimeString()]}),n.jsx(W,{appearance:"subtle",size:"small",icon:n.jsx(Nn,{}),onClick:()=>v("history"),children:"View diff"}),E<h.length-1&&n.jsx(W,{appearance:"subtle",size:"small",icon:n.jsx(zn,{}),onClick:()=>u(X),children:"Revert to here"})]})]})]},E)})]}),t==="console"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:e.toolbar,children:[n.jsx(W,{appearance:"subtle",size:"small",icon:n.jsx(qe,{}),disabled:I.length===0,onClick:()=>{const R=I.slice().reverse().map(E=>{const X=new Date(E.ts).toLocaleTimeString();return`${E.scope} ${X}
|
|
3
|
-
[${E.level.toUpperCase()}]
|
|
4
|
-
${E.message}`}).join(`
|
|
5
|
-
|
|
6
|
-
`);window.toolboxAPI?.utils.copyToClipboard(R).catch(()=>{navigator.clipboard?.writeText(R)})},title:"Copy all log entries to clipboard",children:"Copy log"}),n.jsx(W,{appearance:"subtle",size:"small",onClick:g,children:"Clear log"})]}),n.jsx("div",{children:I.length===0?n.jsx(F,{size:200,style:{color:s.colorNeutralForeground3},children:"No runtime diagnostics yet."}):I.slice().reverse().map(R=>n.jsx(ic,{ts:`${R.scope} ${new Date(R.ts).toLocaleTimeString()}`,level:R.level,message:R.message},R.id))})]})]})]})}function dn({rules:e,kind:t,ruleRefs:o,onEdit:r,styles:i}){return n.jsxs("table",{className:i.table,children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{className:i.th,children:"Rule"}),n.jsx("th",{className:i.th,children:"Steps"}),n.jsx("th",{className:i.th,children:"Used by"}),n.jsx("th",{className:i.th,children:"Type"}),n.jsx("th",{className:i.th})]})}),n.jsx("tbody",{children:e.map(a=>n.jsxs("tr",{children:[n.jsx("td",{className:i.td,children:n.jsx("span",{className:i.mono,onClick:()=>r(a.id),role:"button",tabIndex:0,onKeyDown:l=>l.key==="Enter"&&r(a.id),children:a.id})}),n.jsxs("td",{className:i.td,children:[a.steps.slice(0,3).map((l,c)=>n.jsx("span",{className:i.chip,children:l.kind.replace(/Rule$/,"")},c)),a.steps.length>3&&n.jsxs("span",{className:i.chip,style:{color:s.colorNeutralForeground3},children:["+",a.steps.length-3]}),a.steps.length===0&&n.jsx(F,{size:100,style:{color:s.colorNeutralForeground3},children:"—"})]}),n.jsx("td",{className:i.td,children:n.jsxs(oe,{size:"small",appearance:"tint",color:o[a.id]?"brand":"informative",children:[o[a.id]??0," cmd",o[a.id]!==1?"s":""]})}),n.jsx("td",{className:i.td,children:n.jsx(oe,{size:"small",appearance:"outline",color:t==="enable"?"success":"informative",children:t})}),n.jsx("td",{className:i.td,children:n.jsx(W,{appearance:"subtle",size:"small",onClick:()=>r(a.id),children:"Edit"})})]},a.id))})]})}function ic({ts:e,level:t,message:o}){const r=ao(),i=t==="error"?s.colorStatusDangerForeground1:t==="warn"?s.colorStatusWarningForeground1:s.colorNeutralForeground3;return n.jsxs("div",{className:r.consoleRow,children:[n.jsx("span",{className:r.consoleTs,children:e}),n.jsxs("span",{style:{color:i},children:["[",t.toUpperCase(),"]"]}),n.jsx("span",{style:{color:s.colorNeutralForeground1},children:o})]})}const so=ne({root:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",backgroundColor:s.colorNeutralBackground2},header:{padding:`${s.spacingHorizontalS} ${s.spacingHorizontalM}`,borderBottom:`1px solid ${s.colorNeutralStroke2}`,flexShrink:0},searchBox:{padding:`${s.spacingHorizontalXS} ${s.spacingHorizontalS}`,flexShrink:0},scrollArea:{flex:1,overflow:"hidden",padding:`0 ${s.spacingHorizontalXS} ${s.spacingHorizontalXS}`},gridWrap:{height:"100%"},sectionHeader:{padding:`${s.spacingHorizontalXS} ${s.spacingHorizontalS}`,display:"flex",alignItems:"center",gap:s.spacingHorizontalXS,cursor:"pointer",userSelect:"none",":hover":{backgroundColor:s.colorNeutralBackground3}},entityRow:{display:"flex",alignItems:"center",gap:s.spacingHorizontalS,padding:`${s.spacingHorizontalS} ${s.spacingHorizontalM}`,cursor:"pointer",borderRadius:s.borderRadiusMedium,borderLeft:"3px solid transparent",":hover":{backgroundColor:s.colorNeutralBackground3}},entityRowActive:{borderLeftColor:s.colorBrandStroke1,backgroundColor:s.colorBrandBackground2,":hover":{backgroundColor:s.colorBrandBackground2Hover}},entityName:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}});function ac(){const e=so(),t=Y(x=>x.entities),o=Y(x=>x.activeEntity),r=Y(x=>x.setActiveEntity),i=Y(x=>x.activeSolution),a=Y(x=>x.solutionEntityIds),[l,c]=z.useState(""),[d,h]=z.useState(!0),[m,u]=z.useState(!0),S=t,I=z.useMemo(()=>{const x=l.toLowerCase();return S.filter(y=>y.displayName.toLowerCase().includes(x)||y.logicalName.toLowerCase().includes(x))},[S,l]),g=I.filter(x=>x.isCustomEntity),f=I.filter(x=>!x.isCustomEntity),b=z.useMemo(()=>[...g.length>0?[{kind:"header",id:"custom-header",label:"CUSTOM",count:g.length}]:[],...d?g.map(x=>({kind:"entity",id:`custom-${x.logicalName}`,entity:x})):[],...f.length>0?[{kind:"header",id:"standard-header",label:"STANDARD",count:f.length}]:[],...m?f.map(x=>({kind:"entity",id:`std-${x.logicalName}`,entity:x})):[]],[g,d,f,m]),v=[Re({columnId:"table",renderHeaderCell:()=>n.jsx(F,{size:100,style:{color:s.colorNeutralForeground3},children:"Entity"}),renderCell:x=>{if(x.kind==="header"){const y=x.label==="CUSTOM"?d:m;return n.jsx("div",{className:e.sectionHeader,onClick:()=>x.label==="CUSTOM"?h(p=>!p):u(p=>!p),role:"button","aria-expanded":y,children:n.jsxs(F,{size:100,weight:"semibold",style:{color:s.colorNeutralForeground3},children:[y?"▾":"▸"," ",x.label," (",x.count,")"]})})}return n.jsx(sc,{entity:x.entity,isActive:o?.logicalName===x.entity.logicalName,onClick:()=>r(x.entity)})}})];return n.jsxs("div",{className:e.root,children:[n.jsx("div",{className:e.header,children:n.jsx(Mt,{children:"Tables"})}),n.jsx("div",{className:e.searchBox,children:n.jsx(xe,{contentBefore:n.jsx(ze,{}),placeholder:"Search tables…",size:"small",value:l,onChange:(x,y)=>c(y.value),style:{width:"100%"}})}),n.jsxs("div",{className:e.scrollArea,children:[!i&&n.jsx("div",{style:{padding:24,textAlign:"center"},children:n.jsx(F,{size:200,style:{color:s.colorNeutralForeground3},children:"Select a solution from the top bar to see its tables."})}),i&&a===null&&n.jsx("div",{style:{padding:24,textAlign:"center"},children:n.jsx(Ln,{size:"small",label:"Loading solution tables…"})}),i&&a!==null&&S.length===0&&n.jsx("div",{style:{padding:24,textAlign:"center"},children:n.jsxs(F,{size:200,style:{color:s.colorNeutralForeground3},children:["No tables to show for ",n.jsx("em",{children:i.friendlyName}),".",n.jsx("br",{}),n.jsx("br",{}),"Add a table to the solution in the maker portal (Solutions ›"," ",n.jsx("em",{children:i.friendlyName})," › Add existing › Table) and reload."]})}),i&&a!==null&&S.length>0&&n.jsxs(Wt,{className:e.gridWrap,items:b,columns:v,getRowId:x=>x.id,focusMode:"none",children:[n.jsx(Gt,{children:n.jsx(Ue,{children:({renderHeaderCell:x})=>n.jsx(_n,{children:x()})})}),n.jsx(Ht,{itemSize:52,height:420,listProps:{width:"100%"},children:({item:x,rowId:y},p)=>n.jsx(Ue,{style:p,children:({renderCell:w})=>n.jsx(Mn,{children:w(x)})},y)})]})]})]})}function sc({entity:e,isActive:t,onClick:o}){const r=so();return n.jsxs("div",{className:`${r.entityRow} ${t?r.entityRowActive:""}`,onClick:o,role:"button",tabIndex:0,"aria-pressed":t,onKeyDown:i=>i.key==="Enter"&&o(),children:[n.jsxs("div",{className:r.entityName,children:[n.jsx(F,{size:200,weight:t?"semibold":"regular",children:e.displayName}),n.jsx("br",{}),n.jsx(F,{size:100,style:{color:s.colorNeutralForeground3},children:e.logicalName})]}),e.isManaged&&n.jsx(Je,{fontSize:12,style:{color:s.colorNeutralForeground3},"aria-label":"Managed"})]})}const lc="application/x-rw-se",un={HomepageGrid:"Home",SubGrid:"Sub",Form:"Form",Application:"App"},cc=ne({root:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",backgroundColor:s.colorNeutralBackground2},header:{padding:`${s.spacingHorizontalS} ${s.spacingHorizontalM}`,borderBottom:`1px solid ${s.colorNeutralStroke2}`,flexShrink:0},tabs:{flexShrink:0,borderBottom:`1px solid ${s.colorNeutralStroke2}`},scrollArea:{flex:1,overflowY:"auto",padding:s.spacingHorizontalXS},item:{display:"flex",alignItems:"center",gap:s.spacingHorizontalS,padding:`${s.spacingHorizontalXS} ${s.spacingHorizontalS}`,cursor:"pointer",borderRadius:s.borderRadiusMedium,":hover":{backgroundColor:s.colorNeutralBackground3}},draggableItem:{display:"flex",alignItems:"center",gap:s.spacingHorizontalS,padding:`${s.spacingHorizontalXS} ${s.spacingHorizontalS}`,cursor:"grab",borderRadius:s.borderRadiusMedium,userSelect:"none",":hover":{backgroundColor:s.colorNeutralBackground3},":active":{cursor:"grabbing"}},itemName:{flex:1,fontFamily:s.fontFamilyMonospace,fontSize:s.fontSizeBase200,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},gripHandle:{color:s.colorNeutralForeground4,fontSize:s.fontSizeBase200,flexShrink:0,lineHeight:1}});function dc(){const e=cc(),[t,o]=z.useState("commands"),r=O(b=>b.commands),i=O(b=>b.displayRules),a=O(b=>b.enableRules),l=O(b=>b.templates),c=O(b=>b.ribbons),d=O(b=>b.baseline),h=O(b=>b.upsertCommand),m=O(b=>b.upsertEnableRule),u=M(b=>b.openCommandEditor),S=M(b=>b.openRuleEditor),I=z.useMemo(()=>{const b=[];for(const v of Object.keys(c)){const x=c[v],y=d[v];for(const p of x.tabs)for(const w of p.groups)for(const A of w.buttons){if(!A.custom)continue;const T=y.tabs.flatMap(P=>P.groups).flatMap(P=>P.buttons).some(P=>P.id===A.id);b.push({button:A,location:v,tabId:p.id,groupId:w.id,isNew:!T})}}return b},[c,d]),g=()=>{const b=new Set(r.map(x=>x.id)),v=qt("New","Command",b);h({id:v,enableRules:[],displayRules:[],actions:[]}),u(v)},f=()=>{const b=new Set([...a.map(x=>x.id),...i.map(x=>x.id)]),v=Ve("New","Enable",b);m({id:v,steps:[]}),S(v,"enable")};return n.jsxs("div",{className:e.root,children:[n.jsx("div",{className:e.header,children:n.jsx(Mt,{children:"Solution Elements"})}),n.jsxs(Lt,{className:e.tabs,selectedValue:t,onTabSelect:(b,v)=>o(v.value),size:"small",children:[n.jsxs(fe,{value:"buttons",children:["Buttons (",I.length,")"]}),n.jsxs(fe,{value:"commands",children:["Commands (",r.length,")"]}),n.jsxs(fe,{value:"rules",children:["Rules (",a.length+i.length,")"]}),n.jsxs(fe,{value:"templates",children:["Templates (",l.length,")"]})]}),n.jsxs("div",{className:e.scrollArea,children:[t==="buttons"&&n.jsxs(n.Fragment,{children:[n.jsx(F,{size:100,style:{color:s.colorNeutralForeground3,padding:`4px ${s.spacingHorizontalS}`,display:"block"},children:"Drag onto the ribbon canvas to add a button"}),I.map(({button:b,location:v,isNew:x})=>n.jsx(Be,{content:`${b.id} · ${un[v]} ribbon`,relationship:"label",children:n.jsxs("div",{className:e.draggableItem,draggable:!0,onDragStart:y=>{y.dataTransfer.setData(lc,JSON.stringify({button:{id:b.id,label:b.label,icon:b.icon,kind:b.kind}})),y.dataTransfer.effectAllowed="copy"},title:"Drag onto a ribbon group to add this button",children:[n.jsx("span",{className:e.gripHandle,children:"⋮⋮"}),n.jsx($e,{fontSize:14,style:{color:s.colorNeutralForeground3,flexShrink:0}}),n.jsx(F,{className:e.itemName,children:b.label||b.id}),n.jsx(oe,{size:"small",appearance:"outline",children:un[v]}),x&&n.jsx(oe,{size:"small",color:"brand",appearance:"tint",children:"NEW"})]})},`${v}::${b.id}`)),I.length===0&&n.jsxs(F,{size:200,style:{color:s.colorNeutralForeground3,padding:8,display:"block"},children:["No custom buttons yet. Add one from the ribbon canvas — in"," ",n.jsx("strong",{children:"Modern command bar"})," use the ",n.jsx("strong",{children:"+ Add"})," button at the end of the bar; in ",n.jsx("strong",{children:"Classic ribbon"})," use the ",n.jsx("strong",{children:"+"})," ","inside any group."]})]}),t==="commands"&&n.jsxs(n.Fragment,{children:[n.jsx(W,{appearance:"subtle",size:"small",icon:n.jsx(ce,{}),onClick:g,style:{width:"100%",justifyContent:"flex-start",marginBottom:4},children:"New command"}),r.map(b=>n.jsxs("div",{className:e.item,onClick:()=>u(b.id),role:"button",tabIndex:0,onKeyDown:v=>v.key==="Enter"&&u(b.id),children:[n.jsx(Ke,{fontSize:14,style:{color:s.colorNeutralForeground3}}),n.jsx(F,{className:e.itemName,children:b.id}),n.jsxs(F,{size:100,style:{color:s.colorNeutralForeground3},children:[b.actions.length," action",b.actions.length!==1?"s":""]})]},b.id)),r.length===0&&n.jsx(F,{size:200,style:{color:s.colorNeutralForeground3,padding:8,display:"block"},children:"No commands yet"})]}),t==="rules"&&n.jsxs(n.Fragment,{children:[n.jsx(W,{appearance:"subtle",size:"small",icon:n.jsx(ce,{}),onClick:f,style:{width:"100%",justifyContent:"flex-start",marginBottom:4},children:"New rule"}),a.map(b=>n.jsxs("div",{className:e.item,onClick:()=>S(b.id,"enable"),role:"button",tabIndex:0,onKeyDown:v=>v.key==="Enter"&&S(b.id,"enable"),children:[n.jsx(F,{className:e.itemName,children:b.id}),n.jsx(oe,{size:"small",color:"success",appearance:"tint",children:"Enable"})]},b.id)),i.map(b=>n.jsxs("div",{className:e.item,onClick:()=>S(b.id,"display"),role:"button",tabIndex:0,onKeyDown:v=>v.key==="Enter"&&S(b.id,"display"),children:[n.jsx(F,{className:e.itemName,children:b.id}),n.jsx(oe,{size:"small",color:"informative",appearance:"tint",children:"Display"})]},b.id)),a.length===0&&i.length===0&&n.jsx(F,{size:200,style:{color:s.colorNeutralForeground3,padding:8,display:"block"},children:"No rules yet"})]}),t==="templates"&&n.jsxs(n.Fragment,{children:[l.map(b=>n.jsxs("div",{className:e.item,children:[n.jsx(va,{fontSize:14,style:{color:s.colorNeutralForeground3}}),n.jsx(F,{className:e.itemName,children:b.id})]},b.id)),l.length===0&&n.jsx(F,{size:200,style:{color:s.colorNeutralForeground3,padding:8,display:"block"},children:"No templates defined"})]})]})]})}function Ut(){return window.dataverseAPI}async function uc(){const e=Ut();J.getState().logInfo("dataverse","Loading solutions...");const i=((await e.queryData("solutions?$select=solutionid,uniquename,friendlyname,version,ismanaged,versionnumber,isvisible&$expand=publisherid($select=publisherid,uniquename,friendlyname,customizationprefix)&$filter=isvisible eq true and uniquename ne 'Active'&$orderby=friendlyname asc")).value??[]).map(l=>{const c=l.publisherid??{};return{id:String(l.solutionid??""),uniqueName:String(l.uniquename??""),friendlyName:String(l.friendlyname??""),version:String(l.version??""),isManaged:!!l.ismanaged,publisherId:c.publisherid??"",publisherUniqueName:c.uniquename??"",publisherName:c.friendlyname??"",publisherPrefix:c.customizationprefix??"",versionNumber:l.versionnumber}});J.getState().logInfo("dataverse",`Loaded ${i.length} solution(s).`);const a=i.filter(l=>!l.isManaged).slice(0,5);for(const l of a)J.getState().logInfo("dataverse",` • "${l.friendlyName||l.uniqueName}" → prefix="${l.publisherPrefix||"(empty)"}" (publisher: ${l.publisherName||l.publisherUniqueName||"(empty)"})`);return i}async function pc(e){if(!e)return[];const t=Ut();J.getState().logInfo("dataverse",`Loading solution entity components for ${e}...`);const o=`solutioncomponents?$select=objectid&$filter=_solutionid_value eq ${e} and componenttype eq 1`,a=((await t.queryData(o)).value??[]).map(l=>l.objectid).filter(Boolean);return J.getState().logInfo("dataverse",`Solution contains ${a.length} table component(s).`),a}async function mc(e){if(!e)return[];const t=Ut();J.getState().logInfo("dataverse",`Loading solution ribbon components for ${e}...`);const o=`solutioncomponents?$select=objectid&$filter=_solutionid_value eq ${e} and componenttype eq 50`,a=((await t.queryData(o)).value??[]).map(l=>l.objectid).filter(Boolean);return J.getState().logInfo("dataverse",`Solution contains ${a.length} ribbon-customization component(s).`),a}var te=Uint8Array,pe=Uint16Array,Vt=Int32Array,pt=new te([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]),mt=new te([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]),At=new te([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),lo=function(e,t){for(var o=new pe(31),r=0;r<31;++r)o[r]=t+=1<<e[r-1];for(var i=new Vt(o[30]),r=1;r<30;++r)for(var a=o[r];a<o[r+1];++a)i[a]=a-o[r]<<5|r;return{b:o,r:i}},co=lo(pt,2),uo=co.b,Tt=co.r;uo[28]=258,Tt[258]=28;var po=lo(mt,0),gc=po.b,pn=po.r,Et=new pe(32768);for(var Z=0;Z<32768;++Z){var Ie=(Z&43690)>>1|(Z&21845)<<1;Ie=(Ie&52428)>>2|(Ie&13107)<<2,Ie=(Ie&61680)>>4|(Ie&3855)<<4,Et[Z]=((Ie&65280)>>8|(Ie&255)<<8)>>1}var je=(function(e,t,o){for(var r=e.length,i=0,a=new pe(t);i<r;++i)e[i]&&++a[e[i]-1];var l=new pe(t);for(i=1;i<t;++i)l[i]=l[i-1]+a[i-1]<<1;var c;if(o){c=new pe(1<<t);var d=15-t;for(i=0;i<r;++i)if(e[i])for(var h=i<<4|e[i],m=t-e[i],u=l[e[i]-1]++<<m,S=u|(1<<m)-1;u<=S;++u)c[Et[u]>>d]=h}else for(c=new pe(r),i=0;i<r;++i)e[i]&&(c[i]=Et[l[e[i]-1]++]>>15-e[i]);return c}),Te=new te(288);for(var Z=0;Z<144;++Z)Te[Z]=8;for(var Z=144;Z<256;++Z)Te[Z]=9;for(var Z=256;Z<280;++Z)Te[Z]=7;for(var Z=280;Z<288;++Z)Te[Z]=8;var Xe=new te(32);for(var Z=0;Z<32;++Z)Xe[Z]=5;var fc=je(Te,9,0),bc=je(Te,9,1),hc=je(Xe,5,0),xc=je(Xe,5,1),yt=function(e){for(var t=e[0],o=1;o<e.length;++o)e[o]>t&&(t=e[o]);return t},ge=function(e,t,o){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&o},vt=function(e,t){var o=t/8|0;return(e[o]|e[o+1]<<8|e[o+2]<<16)>>(t&7)},Xt=function(e){return(e+7)/8|0},et=function(e,t,o){return(t==null||t<0)&&(t=0),(o==null||o>e.length)&&(o=e.length),new te(e.subarray(t,o))},yc=["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"],le=function(e,t,o){var r=new Error(t||yc[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,le),!o)throw r;return r},vc=function(e,t,o,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return o||new te(0);var l=!o,c=l||t.i!=2,d=t.i;l&&(o=new te(i*3));var h=function(_e){var Me=o.length;if(_e>Me){var Ee=new te(Math.max(Me*2,_e));Ee.set(o),o=Ee}},m=t.f||0,u=t.p||0,S=t.b||0,I=t.l,g=t.d,f=t.m,b=t.n,v=i*8;do{if(!I){m=ge(e,u,1);var x=ge(e,u+1,3);if(u+=3,x)if(x==1)I=bc,g=xc,f=9,b=5;else if(x==2){var A=ge(e,u,31)+257,T=ge(e,u+10,15)+4,P=A+ge(e,u+5,31)+1;u+=14;for(var D=new te(P),L=new te(19),B=0;B<T;++B)L[At[B]]=ge(e,u+B*3,7);u+=T*3;for(var j=yt(L),$=(1<<j)-1,C=je(L,j,1),B=0;B<P;){var N=C[ge(e,u,$)];u+=N&15;var y=N>>4;if(y<16)D[B++]=y;else{var _=0,U=0;for(y==16?(U=3+ge(e,u,3),u+=2,_=D[B-1]):y==17?(U=3+ge(e,u,7),u+=3):y==18&&(U=11+ge(e,u,127),u+=7);U--;)D[B++]=_}}var V=D.subarray(0,A),k=D.subarray(A);f=yt(V),b=yt(k),I=je(V,f,1),g=je(k,b,1)}else le(1);else{var y=Xt(u)+4,p=e[y-4]|e[y-3]<<8,w=y+p;if(w>i){d&&le(0);break}c&&h(S+p),o.set(e.subarray(y,w),S),t.b=S+=p,t.p=u=w*8,t.f=m;continue}if(u>v){d&&le(0);break}}c&&h(S+131072);for(var H=(1<<f)-1,G=(1<<b)-1,ee=u;;ee=u){var _=I[vt(e,u)&H],K=_>>4;if(u+=_&15,u>v){d&&le(0);break}if(_||le(2),K<256)o[S++]=K;else if(K==256){ee=u,I=null;break}else{var R=K-254;if(K>264){var B=K-257,E=pt[B];R=ge(e,u,(1<<E)-1)+uo[B],u+=E}var X=g[vt(e,u)&G],Ce=X>>4;X||le(3),u+=X&15;var k=gc[Ce];if(Ce>3){var E=mt[Ce];k+=vt(e,u)&(1<<E)-1,u+=E}if(u>v){d&&le(0);break}c&&h(S+131072);var ve=S+R;if(S<k){var tt=a-k,nt=Math.min(k,ve);for(tt+S<0&&le(3);S<nt;++S)o[S]=r[tt+S]}for(;S<ve;++S)o[S]=o[S-k]}}t.l=I,t.p=ee,t.b=S,t.f=m,I&&(m=1,t.m=f,t.d=g,t.n=b)}while(!m);return S!=o.length&&l?et(o,0,S):o.subarray(0,S)},we=function(e,t,o){o<<=t&7;var r=t/8|0;e[r]|=o,e[r+1]|=o>>8},We=function(e,t,o){o<<=t&7;var r=t/8|0;e[r]|=o,e[r+1]|=o>>8,e[r+2]|=o>>16},St=function(e,t){for(var o=[],r=0;r<e.length;++r)e[r]&&o.push({s:r,f:e[r]});var i=o.length,a=o.slice();if(!i)return{t:go,l:0};if(i==1){var l=new te(o[0].s+1);return l[o[0].s]=1,{t:l,l:1}}o.sort(function(w,A){return w.f-A.f}),o.push({s:-1,f:25001});var c=o[0],d=o[1],h=0,m=1,u=2;for(o[0]={s:-1,f:c.f+d.f,l:c,r:d};m!=i-1;)c=o[o[h].f<o[u].f?h++:u++],d=o[h!=m&&o[h].f<o[u].f?h++:u++],o[m++]={s:-1,f:c.f+d.f,l:c,r:d};for(var S=a[0].s,r=1;r<i;++r)a[r].s>S&&(S=a[r].s);var I=new pe(S+1),g=Dt(o[m-1],I,0);if(g>t){var r=0,f=0,b=g-t,v=1<<b;for(a.sort(function(A,T){return I[T.s]-I[A.s]||A.f-T.f});r<i;++r){var x=a[r].s;if(I[x]>t)f+=v-(1<<g-I[x]),I[x]=t;else break}for(f>>=b;f>0;){var y=a[r].s;I[y]<t?f-=1<<t-I[y]++-1:++r}for(;r>=0&&f;--r){var p=a[r].s;I[p]==t&&(--I[p],++f)}g=t}return{t:new te(I),l:g}},Dt=function(e,t,o){return e.s==-1?Math.max(Dt(e.l,t,o+1),Dt(e.r,t,o+1)):t[e.s]=o},mn=function(e){for(var t=e.length;t&&!e[--t];);for(var o=new pe(++t),r=0,i=e[0],a=1,l=function(d){o[r++]=d},c=1;c<=t;++c)if(e[c]==i&&c!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)l(32754);a>2&&(l(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(l(i),--a;a>6;a-=6)l(8304);a>2&&(l(a-3<<5|8208),a=0)}for(;a--;)l(i);a=1,i=e[c]}return{c:o.subarray(0,r),n:t}},Ge=function(e,t){for(var o=0,r=0;r<t.length;++r)o+=e[r]*t[r];return o},mo=function(e,t,o){var r=o.length,i=Xt(t+2);e[i]=r&255,e[i+1]=r>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var a=0;a<r;++a)e[i+a+4]=o[a];return(i+4+r)*8},gn=function(e,t,o,r,i,a,l,c,d,h,m){we(t,m++,o),++i[256];for(var u=St(i,15),S=u.t,I=u.l,g=St(a,15),f=g.t,b=g.l,v=mn(S),x=v.c,y=v.n,p=mn(f),w=p.c,A=p.n,T=new pe(19),P=0;P<x.length;++P)++T[x[P]&31];for(var P=0;P<w.length;++P)++T[w[P]&31];for(var D=St(T,7),L=D.t,B=D.l,j=19;j>4&&!L[At[j-1]];--j);var $=h+5<<3,C=Ge(i,Te)+Ge(a,Xe)+l,N=Ge(i,S)+Ge(a,f)+l+14+3*j+Ge(T,L)+2*T[16]+3*T[17]+7*T[18];if(d>=0&&$<=C&&$<=N)return mo(t,m,e.subarray(d,d+h));var _,U,V,k;if(we(t,m,1+(N<C)),m+=2,N<C){_=je(S,I,0),U=S,V=je(f,b,0),k=f;var H=je(L,B,0);we(t,m,y-257),we(t,m+5,A-1),we(t,m+10,j-4),m+=14;for(var P=0;P<j;++P)we(t,m+3*P,L[At[P]]);m+=3*j;for(var G=[x,w],ee=0;ee<2;++ee)for(var K=G[ee],P=0;P<K.length;++P){var R=K[P]&31;we(t,m,H[R]),m+=L[R],R>15&&(we(t,m,K[P]>>5&127),m+=K[P]>>12)}}else _=fc,U=Te,V=hc,k=Xe;for(var P=0;P<c;++P){var E=r[P];if(E>255){var R=E>>18&31;We(t,m,_[R+257]),m+=U[R+257],R>7&&(we(t,m,E>>23&31),m+=pt[R]);var X=E&31;We(t,m,V[X]),m+=k[X],X>3&&(We(t,m,E>>5&8191),m+=mt[X])}else We(t,m,_[E]),m+=U[E]}return We(t,m,_[256]),m+U[256]},Sc=new Vt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),go=new te(0),jc=function(e,t,o,r,i,a){var l=a.z||e.length,c=new te(r+l+5*(1+Math.ceil(l/7e3))+i),d=c.subarray(r,c.length-i),h=a.l,m=(a.r||0)&7;if(t){m&&(d[0]=a.r>>3);for(var u=Sc[t-1],S=u>>13,I=u&8191,g=(1<<o)-1,f=a.p||new pe(32768),b=a.h||new pe(g+1),v=Math.ceil(o/3),x=2*v,y=function(gt){return(e[gt]^e[gt+1]<<v^e[gt+2]<<x)&g},p=new Vt(25e3),w=new pe(288),A=new pe(32),T=0,P=0,D=a.i||0,L=0,B=a.w||0,j=0;D+2<l;++D){var $=y(D),C=D&32767,N=b[$];if(f[C]=N,b[$]=C,B<=D){var _=l-D;if((T>7e3||L>24576)&&(_>423||!h)){m=gn(e,d,0,p,w,A,P,L,j,D-j,m),L=T=P=0,j=D;for(var U=0;U<286;++U)w[U]=0;for(var U=0;U<30;++U)A[U]=0}var V=2,k=0,H=I,G=C-N&32767;if(_>2&&$==y(D-G))for(var ee=Math.min(S,_)-1,K=Math.min(32767,D),R=Math.min(258,_);G<=K&&--H&&C!=N;){if(e[D+V]==e[D+V-G]){for(var E=0;E<R&&e[D+E]==e[D+E-G];++E);if(E>V){if(V=E,k=G,E>ee)break;for(var X=Math.min(G,E-2),Ce=0,U=0;U<X;++U){var ve=D-G+U&32767,tt=f[ve],nt=ve-tt&32767;nt>Ce&&(Ce=nt,N=ve)}}}C=N,N=f[C],G+=C-N&32767}if(k){p[L++]=268435456|Tt[V]<<18|pn[k];var _e=Tt[V]&31,Me=pn[k]&31;P+=pt[_e]+mt[Me],++w[257+_e],++A[Me],B=D+V,++T}else p[L++]=e[D],++w[e[D]]}}for(D=Math.max(D,B);D<l;++D)p[L++]=e[D],++w[e[D]];m=gn(e,d,h,p,w,A,P,L,j,D-j,m),h||(a.r=m&7|d[m/8|0]<<3,m-=7,a.h=b,a.p=f,a.i=D,a.w=B)}else{for(var D=a.w||0;D<l+h;D+=65535){var Ee=D+65535;Ee>=l&&(d[m/8|0]=h,Ee=l),m=mo(d,m+1,e.subarray(D,Ee))}a.i=l}return et(c,0,r+Xt(m)+i)},wc=(function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var o=t,r=9;--r;)o=(o&1&&-306674912)^o>>>1;e[t]=o}return e})(),Rc=function(){var e=-1;return{p:function(t){for(var o=e,r=0;r<t.length;++r)o=wc[o&255^t[r]]^o>>>8;e=o},d:function(){return~e}}},Cc=function(e,t,o,r,i){if(!i&&(i={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),l=new te(a.length+e.length);l.set(a),l.set(e,a.length),e=l,i.w=a.length}return jc(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,o,r,i)},fo=function(e,t){var o={};for(var r in e)o[r]=e[r];for(var r in t)o[r]=t[r];return o},Se=function(e,t){return e[t]|e[t+1]<<8},me=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},jt=function(e,t){return me(e,t)+me(e,t+4)*4294967296},ae=function(e,t,o){for(;o;++t)e[t]=o,o>>>=8};function Ic(e,t){return Cc(e,t||{},0,0)}function Nc(e,t){return vc(e,{i:2},t&&t.out,t&&t.dictionary)}var bo=function(e,t,o,r){for(var i in e){var a=e[i],l=t+i,c=r;Array.isArray(a)&&(c=fo(r,a[1]),a=a[0]),ArrayBuffer.isView(a)?o[l]=[a,c]:(o[l+="/"]=[new te(0),c],bo(a,l,o,r))}},fn=typeof TextEncoder<"u"&&new TextEncoder,Ft=typeof TextDecoder<"u"&&new TextDecoder,kc=0;try{Ft.decode(go,{stream:!0}),kc=1}catch{}var zc=function(e){for(var t="",o=0;;){var r=e[o++],i=(r>127)+(r>223)+(r>239);if(o+i>e.length)return{s:t,r:et(e,o-1)};i?i==3?(r=((r&15)<<18|(e[o++]&63)<<12|(e[o++]&63)<<6|e[o++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?t+=String.fromCharCode((r&31)<<6|e[o++]&63):t+=String.fromCharCode((r&15)<<12|(e[o++]&63)<<6|e[o++]&63):t+=String.fromCharCode(r)}};function bn(e,t){var o;if(fn)return fn.encode(e);for(var r=e.length,i=new te(e.length+(e.length>>1)),a=0,l=function(h){i[a++]=h},o=0;o<r;++o){if(a+5>i.length){var c=new te(a+8+(r-o<<1));c.set(i),i=c}var d=e.charCodeAt(o);d<128||t?l(d):d<2048?(l(192|d>>6),l(128|d&63)):d>55295&&d<57344?(d=65536+(d&1047552)|e.charCodeAt(++o)&1023,l(240|d>>18),l(128|d>>12&63),l(128|d>>6&63),l(128|d&63)):(l(224|d>>12),l(128|d>>6&63),l(128|d&63))}return et(i,0,a)}function Ot(e,t){if(t){for(var o="",r=0;r<e.length;r+=16384)o+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return o}else{if(Ft)return Ft.decode(e);var i=zc(e),a=i.s,o=i.r;return o.length&&le(8),a}}var Bc=function(e,t){return t+30+Se(e,t+26)+Se(e,t+28)},Ac=function(e,t,o){var r=Se(e,t+28),i=Se(e,t+30),a=Ot(e.subarray(t+46,t+46+r),!(Se(e,t+8)&2048)),l=t+46+r,c=Tc(e,l,i,o,me(e,t+20),me(e,t+24),me(e,t+42)),d=c[0],h=c[1],m=c[2];return[Se(e,t+10),d,h,a,l+i+Se(e,t+32),m]},Tc=function(e,t,o,r,i,a,l){var c=i==4294967295,d=a==4294967295,h=l==4294967295,m=t+o,u=c+d+h;if(r&&u){for(;t+4<m;t+=4+Se(e,t+2))if(Se(e,t)==1)return[c?jt(e,t+4+8*d):i,d?jt(e,t+4):a,h?jt(e,t+4+8*(d+c)):l,1];r<2&&le(13)}return[i,a,l,0]},Pt=function(e){var t=0;if(e)for(var o in e){var r=e[o].length;r>65535&&le(9),t+=r+4}return t},hn=function(e,t,o,r,i,a,l,c){var d=r.length,h=o.extra,m=c&&c.length,u=Pt(h);ae(e,t,l!=null?33639248:67324752),t+=4,l!=null&&(e[t++]=20,e[t++]=o.os),e[t]=20,t+=2,e[t++]=o.flag<<1|(a<0&&8),e[t++]=i&&8,e[t++]=o.compression&255,e[t++]=o.compression>>8;var S=new Date(o.mtime==null?Date.now():o.mtime),I=S.getFullYear()-1980;if((I<0||I>119)&&le(10),ae(e,t,I<<25|S.getMonth()+1<<21|S.getDate()<<16|S.getHours()<<11|S.getMinutes()<<5|S.getSeconds()>>1),t+=4,a!=-1&&(ae(e,t,o.crc),ae(e,t+4,a<0?-a-2:a),ae(e,t+8,o.size)),ae(e,t+12,d),ae(e,t+14,u),t+=16,l!=null&&(ae(e,t,m),ae(e,t+6,o.attrs),ae(e,t+10,l),t+=14),e.set(r,t),t+=d,u)for(var g in h){var f=h[g],b=f.length;ae(e,t,+g),ae(e,t+2,b),e.set(f,t+4),t+=4+b}return m&&(e.set(c,t),t+=m),t},Ec=function(e,t,o,r,i){ae(e,t,101010256),ae(e,t+8,o),ae(e,t+10,o),ae(e,t+12,r),ae(e,t+16,i)};function pd(e,t){t||(t={});var o={},r=[];bo(e,"",o,t);var i=0,a=0;for(var l in o){var c=o[l],d=c[0],h=c[1],m=h.level==0?0:8,u=bn(l),S=u.length,I=h.comment,g=I&&bn(I),f=g&&g.length,b=Pt(h.extra);S>65535&&le(11);var v=m?Ic(d,h):d,x=v.length,y=Rc();y.p(d),r.push(fo(h,{size:d.length,crc:y.d(),c:v,f:u,m:g,u:S!=l.length||g&&I.length!=f,o:i,compression:m})),i+=30+S+b+x,a+=76+2*(S+b)+(f||0)+x}for(var p=new te(a+22),w=i,A=a-i,T=0;T<r.length;++T){var u=r[T];hn(p,u.o,u,u.f,u.u,u.c.length);var P=30+u.f.length+Pt(u.extra);p.set(u.c,u.o+P),hn(p,i,u,u.f,u.u,u.c.length,u.o,u.m),i+=16+P+(u.m?u.m.length:0)}return Ec(p,i,r.length,A,w),p}function Dc(e,t){for(var o={},r=e.length-22;me(e,r)!=101010256;--r)(!r||e.length-r>65558)&&le(13);var i=Se(e,r+8);if(!i)return{};var a=me(e,r+16),l=me(e,r-20)==117853008;if(l){var c=me(e,r-12);l=me(e,c)==101075792,l&&(i=me(e,c+32),a=me(e,c+48))}for(var d=0;d<i;++d){var h=Ac(e,a,l),m=h[0],u=h[1],S=h[2],I=h[3],g=h[4],f=h[5],b=Bc(e,f);a=g,m?m==8?o[I]=Nc(e.subarray(b,b+u),{out:new te(S)}):le(14,"unknown compression type "+m):o[I]=et(e,b,b+u)}return o}async function ho(e){const t=atob(e),o=new Uint8Array(t.length);for(let a=0;a<t.length;a++)o[a]=t.charCodeAt(a);const r=Dc(o),i=Object.entries(r).find(([a])=>a.toLowerCase().endsWith("ribbonxml.xml"));if(!i){const a=Object.values(r)[0];if(a)return Ot(a);throw new Error("decompressRibbonZip: no RibbonXml.xml entry found in ZIP")}return Ot(i[1])}function Fc(e){return/^(Mscrm|Microsoft)\./.test(e)}function xo(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 Oc(e,t){return t?"unmanaged":Fc(e)?"oob":"unmanaged"}function Pc(e,t){if(t.size!==0)for(const o of Object.keys(e))for(const r of e[o].tabs)for(const i of r.groups)for(const a of i.buttons){const l=t.get(a.id);l&&xo(a,l)}}function yo(e,t,o){const i=new DOMParser().parseFromString(e,"application/xml"),a=i.querySelector("parsererror");if(a)throw new Error(`Ribbon XML parse error: ${a.textContent??"Unknown"}`);const l=$c(i);_c(i,l);const c=Hc(i),d=Wc(i),h=Gc(i),m=qc(i),u=new Set,S=new Set;i.querySelectorAll("CustomAction").forEach(I=>{const g=I.querySelector("CommandUIDefinition");if(g?.firstElementChild){const f=g.firstElementChild.getAttribute("Id")??"";f&&u.add(f)}}),i.querySelectorAll("HideCustomAction").forEach(I=>{const g=I.getAttribute("Location")??"";g&&S.add(g)});for(const I of l)for(const g of I.groups)for(const f of g.buttons){const b=u.has(f.id);xo(f,{origin:Oc(f.id,b)}),f.hidden=S.has(f.id),f.label=ye(f.label,m),f.tooltipTitle&&(f.tooltipTitle=ye(f.tooltipTitle,m)),f.tooltipBody&&(f.tooltipBody=ye(f.tooltipBody,m))}return{ribbon:{location:t,entityLogicalName:o,tabs:l},commands:c,displayRules:h,enableRules:d,locLabels:m}}function $c(e){const t=[];return e.querySelectorAll("Tab").forEach(o=>{const r=o.getAttribute("Id")??"";if(!r)return;const i=o.getAttribute("Title")??r,a=[];o.querySelectorAll(":scope > Groups > Group").forEach(l=>{const c=l.getAttribute("Id")??"";if(!c)return;const d=l.getAttribute("Label")??c,h=parseInt(l.getAttribute("Sequence")??"0",10),m=l.getAttribute("Template")??"",u=[];l.querySelectorAll("Button, FlyoutAnchor, SplitButton, TextBox, ComboBox, CheckBox").forEach(S=>Mc(S,u)),a.push({id:c,label:d,sequence:h,template:m,buttons:u})}),t.push({id:r,label:i,sequence:parseInt(o.getAttribute("Sequence")??"0",10),commandId:o.getAttribute("Command")??void 0,template:o.getAttribute("Template")??void 0,tabDisplayRules:[],groups:a})}),t.sort((o,r)=>o.sequence-r.sequence)}function _c(e,t){const o=new Map;for(const r of t)r.commandId&&o.set(r.commandId,r);e.querySelectorAll("RuleDefinitions > TabDisplayRules > TabDisplayRule").forEach(r=>{const i=r.getAttribute("TabCommand")??"",a=o.get(i);if(!a)return;const l=[];r.querySelectorAll("EntityRule").forEach(c=>{l.push({kind:"EntityRule",entityName:c.getAttribute("EntityName")??void 0,appliesTo:c.getAttribute("AppliesTo")??void 0,context:c.getAttribute("Context")??void 0})}),r.querySelectorAll("PageRule").forEach(c=>{l.push({kind:"PageRule",address:c.getAttribute("Address")??""})}),l.length>0&&a.tabDisplayRules.push({tabCommand:i,rules:l})})}function Mc(e,t){const o=e.getAttribute("Id")??"";if(!o)return;const r=e.tagName.toLowerCase();let i="button";r==="flyoutanchor"?i="flyout":r==="splitbutton"?i="splitButton":r==="textbox"?i="textBox":r==="combobox"?i="comboBox":r==="checkbox"&&(i="checkBox");const a=e.getAttribute("LabelText")??o,l=Lc(e.getAttribute("ModernImage")??void 0),c=parseInt(e.getAttribute("Sequence")??"0",10),d=e.getAttribute("TemplateAlias")??"",h=e.getAttribute("Command")??"";t.push({id:o,label:a,icon:l,sequence:c,templateAlias:d,commandId:h,kind:i,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})}function Lc(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()}function Hc(e){const t=[];return e.querySelectorAll("CommandDefinition").forEach(o=>{const r=o.getAttribute("Id")??"";if(!r)return;const i=[];o.querySelectorAll("EnableRule").forEach(c=>{const d=c.getAttribute("Id");d&&i.push(d)});const a=[];o.querySelectorAll("DisplayRule").forEach(c=>{const d=c.getAttribute("Id");d&&a.push(d)});const l=[];o.querySelectorAll("JavaScriptFunction").forEach(c=>{const d=c.getAttribute("Library")??"",h=c.getAttribute("FunctionName")??"",m=xn(c),u={kind:"javascript",library:d,functionName:h,params:m};l.push(u)}),o.querySelectorAll("Url").forEach(c=>{const d=c.getAttribute("Address")??"",h=c.getAttribute("PassParams")==="1"||c.getAttribute("PassParams")==="true",m=parseInt(c.getAttribute("WinMode")??"0",10),u=xn(c),S={kind:"url",address:d,passParams:h,winMode:m,params:u};l.push(S)}),t.push({id:r,enableRules:i,displayRules:a,actions:l})}),t}function xn(e){const t=[];return e.childNodes.forEach(o=>{if(o.nodeType!==Node.ELEMENT_NODE)return;const r=o;switch(r.tagName){case"CrmParameter":t.push({kind:"CrmParameter",name:r.getAttribute("Name")??void 0,value:r.getAttribute("Value")});break;case"BoolParameter":t.push({kind:"BoolParameter",name:r.getAttribute("Name")??void 0,value:r.getAttribute("Value")==="true"});break;case"IntParameter":t.push({kind:"IntParameter",name:r.getAttribute("Name")??void 0,value:parseInt(r.getAttribute("Value")??"0",10)});break;case"DecimalParameter":t.push({kind:"DecimalParameter",name:r.getAttribute("Name")??void 0,value:parseFloat(r.getAttribute("Value")??"0")});break;case"StringParameter":t.push({kind:"StringParameter",name:r.getAttribute("Name")??void 0,value:r.getAttribute("Value")??""});break}}),t}function Wc(e){const t=[];return e.querySelectorAll("EnableRules > EnableRule").forEach(o=>{const r=o.getAttribute("Id")??"";if(!r)return;const i=vo(o);t.push({id:r,steps:i})}),t}function Gc(e){const t=[];return e.querySelectorAll("DisplayRules > DisplayRule").forEach(o=>{const r=o.getAttribute("Id")??"";if(!r)return;const i=vo(o);t.push({id:r,steps:i})}),t}function vo(e){const t=[];return e.childNodes.forEach(o=>{if(o.nodeType!==Node.ELEMENT_NODE)return;const r=o,i=r.getAttribute("InvertResult")==="1"||r.getAttribute("InvertResult")==="true",a=So(r,i);a&&t.push(a)}),t}function So(e,t){switch(e.tagName){case"SelectionCountRule":return{kind:"SelectionCountRule",minimum:e.getAttribute("Minimum")?parseInt(e.getAttribute("Minimum"),10):void 0,maximum:e.getAttribute("Maximum")?parseInt(e.getAttribute("Maximum"),10):void 0,appliesTo:e.getAttribute("AppliesTo"),invertResult:t};case"EntityRule":return{kind:"EntityRule",entityName:e.getAttribute("EntityName")??void 0,context:e.getAttribute("Context")??void 0,appliesTo:e.getAttribute("AppliesTo"),invertResult:t};case"FormStateRule":return{kind:"FormStateRule",state:e.getAttribute("State"),invertResult:t};case"CommandClientTypeRule":return{kind:"CommandClientTypeRule",type:e.getAttribute("Type"),default:e.getAttribute("Default")==="true",invertResult:t};case"CustomRule":return{kind:"CustomRule",library:e.getAttribute("Library")??"",functionName:e.getAttribute("FunctionName")??"",default:e.getAttribute("Default")==="true",invertResult:t};case"OrRule":{const o=[];return e.querySelectorAll("Or").forEach(r=>{r.childNodes.forEach(i=>{if(i.nodeType===Node.ELEMENT_NODE){const a=So(i,!1);a&&o.push(a)}})}),{kind:"OrRule",rules:o}}case"MiscellaneousPrivilegeRule":return{kind:"MiscellaneousPrivilegeRule",privilegeName:e.getAttribute("PrivilegeName")??"",invertResult:t};case"CrmClientTypeRule":return{kind:"CrmClientTypeRule",type:e.getAttribute("Type"),invertResult:t};case"FormTypeRule":return{kind:"FormTypeRule",type:e.getAttribute("Type"),invertResult:t};case"ValueRule":return{kind:"ValueRule",field:e.getAttribute("Field")??"",value:e.getAttribute("Value")??"",invertResult:t};case"SkuRule":return{kind:"SkuRule",sku:e.getAttribute("Sku"),invertResult:t};case"HideForTabletExperienceRule":return{kind:"HideForTabletExperienceRule",invertResult:t};case"OrganizationSettingRule":return{kind:"OrganizationSettingRule",setting:e.getAttribute("Setting"),invertResult:t};case"EntityPrivilegeRule":return{kind:"EntityPrivilegeRule",entityName:e.getAttribute("EntityName")??void 0,appliesTo:e.getAttribute("AppliesTo")??void 0,privilegeType:e.getAttribute("PrivilegeType"),privilegeDepth:e.getAttribute("PrivilegeDepth")??"Basic",invertResult:t};case"EntityPropertyRule":return{kind:"EntityPropertyRule",entityName:e.getAttribute("EntityName")??void 0,appliesTo:e.getAttribute("AppliesTo")??void 0,propertyName:e.getAttribute("PropertyName"),propertyValue:e.getAttribute("PropertyValue")==="true"||e.getAttribute("PropertyValue")==="1",invertResult:t};case"DeviceTypeRule":return{kind:"DeviceTypeRule",type:e.getAttribute("Type"),invertResult:t};case"OptionSetRule":return{kind:"OptionSetRule",optionSet:e.getAttribute("OptionSet")??"",stateCode:e.getAttribute("StateCode")??"",objectTypeCode:e.getAttribute("ObjectTypeCode")??"",invertResult:t};case"RecordPrivilegeRule":return{kind:"RecordPrivilegeRule",privilegeType:e.getAttribute("PrivilegeType"),appliesTo:e.getAttribute("AppliesTo")??void 0,invertResult:t};case"FormEntityContextRule":return{kind:"FormEntityContextRule",entityName:e.getAttribute("EntityName")??"",invertResult:t};case"PageRule":return{kind:"PageRule",address:e.getAttribute("Address")??"",invertResult:t};case"RelationshipTypeRule":return{kind:"RelationshipTypeRule",appliesTo:"SelectedEntity",relationshipType:e.getAttribute("RelationshipType")??void 0,allowCustomRelationship:e.hasAttribute("AllowCustomRelationship")?e.getAttribute("AllowCustomRelationship")!=="false":void 0,allowSystemRelationship:e.hasAttribute("AllowSystemRelationship")?e.getAttribute("AllowSystemRelationship")!=="false":void 0,invertResult:t};case"ReferencingAttributeRequiredRule":return{kind:"ReferencingAttributeRequiredRule",invertResult:t};case"ShowOnQuickActionRule":return{kind:"ShowOnQuickActionRule"};case"ShowOnGridAndQuickActionRule":return{kind:"ShowOnGridAndQuickActionRule"};case"ShowOnGridRule":return{kind:"ShowOnGridRule"};case"OutlookItemTrackingRule":return{kind:"OutlookItemTrackingRule",trackedInCrm:e.getAttribute("TrackedInCrm")==="true"||e.getAttribute("TrackedInCrm")==="1",appliesTo:e.getAttribute("AppliesTo")??void 0,invertResult:t};case"OutlookRenderTypeRule":return{kind:"OutlookRenderTypeRule",type:e.getAttribute("Type"),invertResult:t};case"OutlookVersionRule":return{kind:"OutlookVersionRule",version:e.getAttribute("Version"),invertResult:t};case"CrmOfflineAccessStateRule":return{kind:"CrmOfflineAccessStateRule",state:e.getAttribute("State"),invertResult:t};case"CrmOutlookClientTypeRule":return{kind:"CrmOutlookClientTypeRule",type:e.getAttribute("Type"),invertResult:t};case"CrmOutlookClientVersionRule":return{kind:"CrmOutlookClientVersionRule",major:parseInt(e.getAttribute("Major")??"0",10),minor:e.hasAttribute("Minor")?parseInt(e.getAttribute("Minor"),10):void 0,build:e.hasAttribute("Build")?parseInt(e.getAttribute("Build"),10):void 0,revision:e.hasAttribute("Revision")?parseInt(e.getAttribute("Revision"),10):void 0,invertResult:t};default:return null}}function qc(e){const t=[];return e.querySelectorAll("LocLabel").forEach(o=>{const r=o.getAttribute("Id")??"";if(!r)return;const i=[];o.querySelectorAll("Title").forEach(a=>{const l=parseInt(a.getAttribute("languagecode")??"1033",10),c=a.getAttribute("description")??"";i.push({languageCode:l,description:c})}),t.push({id:r,titles:i})}),t}const jo=window.dataverseAPI;function it(e){const t=new Set,o=[];for(const r of e)t.has(r.id)||(t.add(r.id),o.push(r));return o}function Uc(e,t){const o={HomepageGrid:[],SubGrid:[],Form:[]};for(const r of e)r.id.startsWith("Mscrm.Form.")?o.Form.push(r):r.id.startsWith("Mscrm.SubGrid.")?o.SubGrid.push(r):(r.id.startsWith("Mscrm.HomepageGrid."),o.HomepageGrid.push(r));return{HomepageGrid:{location:"HomepageGrid",entityLogicalName:t,tabs:o.HomepageGrid},SubGrid:{location:"SubGrid",entityLogicalName:t,tabs:o.SubGrid},Form:{location:"Form",entityLogicalName:t,tabs:o.Form}}}const Vc="Microsoft.Dynamics.CRM.RibbonLocationFilters'All'";async function Xc(e){J.getState().logInfo("dataverse",`RetrieveEntityRibbon(${e}, All)`);const t=await jo.execute({operationName:"RetrieveEntityRibbon",operationType:"function",parameters:{EntityName:e,RibbonLocationFilter:Vc}}),o=await ho(t.CompressedEntityXml),r=yo(o,"HomepageGrid",e),i=Uc(r.ribbon.tabs,e);return J.getState().logInfo("dataverse",`RetrieveEntityRibbon succeeded for ${e} (Form=${i.Form.tabs.length}, HomepageGrid=${i.HomepageGrid.tabs.length}, SubGrid=${i.SubGrid.tabs.length})`),{ribbons:i,commands:r.commands,displayRules:r.displayRules,enableRules:r.enableRules,locLabels:r.locLabels}}async function Yc(){J.getState().logInfo("dataverse","RetrieveApplicationRibbon()");const e=await jo.execute({operationName:"RetrieveApplicationRibbon",operationType:"function"}),t=await ho(e.CompressedApplicationRibbonXml);return J.getState().logInfo("dataverse","RetrieveApplicationRibbon succeeded"),yo(t,"Application","{!EntityLogicalName}")}async function Kc(e){const[t,o]=await Promise.all([Xc(e),Yc()]);return{ribbons:{HomepageGrid:t.ribbons.HomepageGrid,SubGrid:t.ribbons.SubGrid,Form:t.ribbons.Form,Application:o.ribbon},commands:it([...t.commands,...o.commands]),displayRules:it([...t.displayRules,...o.displayRules]),enableRules:it([...t.enableRules,...o.enableRules]),locLabels:it([...t.locLabels,...o.locLabels])}}const yn=window.dataverseAPI,vn="Active";function Jc(e){if(!e||!e.includes("<"))return[];try{const t=new DOMParser().parseFromString(e,"application/xml");if(t.querySelector("parsererror"))return[];const o=new Set;return t.querySelectorAll("CustomAction").forEach(r=>{const a=r.querySelector("CommandUIDefinition")?.firstElementChild?.getAttribute("Id");a&&o.add(a)}),[...o]}catch{return[]}}async function Zc(e){const t=J.getState(),o=new Map;if(!e||e==="{!EntityLogicalName}")return o;try{const r=e.replace(/'/g,"''"),a=((await yn.queryData(`ribboncustomizations?$select=ribboncustomizationid&$filter=entity eq '${r}'`)).value??[]).map(d=>d.ribboncustomizationid).filter(d=>!!d);if(a.length===0)return t.logInfo("provenance",`No RibbonCustomization for ${e} — buttons resolve via heuristic (OOB vs custom).`),o;const l=new Map,c=new Set;for(const d of a){const m=(await yn.queryData(`msdyn_componentlayers?$select=msdyn_componentjson,msdyn_changes,msdyn_solutionname,msdyn_publishername,msdyn_order&$filter=msdyn_componentid eq '${d}'&$orderby=msdyn_order asc`)).value??[];t.logInfo("provenance",`RibbonCustomization ${d}: ${m.length} solution layer(s).`);for(const u of m){const S=u.msdyn_componentjson||u.msdyn_changes||"",I=Jc(S),g=(u.msdyn_solutionname??"")===vn;for(const f of I)g?c.add(f):l.has(f)||l.set(f,{origin:"managed",solutionName:u.msdyn_solutionname,publisherName:u.msdyn_publishername})}}for(const[d,h]of l)c.has(d)||o.set(d,h);for(const d of c)o.set(d,{origin:"unmanaged",solutionName:vn});t.logInfo("provenance",`Resolved solution-layer provenance for ${o.size} button(s) of ${e}.`)}catch(r){t.logWarn("provenance",`Solution-layer provenance unavailable for ${e} (${r instanceof Error?r.message:String(r)}); using heuristic. This is non-fatal.`)}return o}function Qc(){return window.dataverseAPI}async function ed(){const e=Qc();J.getState().logInfo("dataverse","Resolving current user via WhoAmI...");const t=await e.execute({operationName:"WhoAmI",operationType:"function"}),o=typeof t.UserId=="string"?t.UserId:"";if(!o)return J.getState().logWarn("dataverse","WhoAmI returned no user id."),{id:"",name:""};const i=(await e.retrieve("systemuser",o,["fullname"])).fullname?.trim(),a={id:o,name:i&&i.length>0?i:"Current User"};return J.getState().logInfo("dataverse",`Current user resolved: ${a.name}.`),a}function Yt(e,t){return`cbs:ribbon:${e.replace(/\/+$/,"").replace(/[^a-zA-Z0-9.-]/g,"_")}:${t||"global"}`}function td(e,t){try{const o=Yt(e,t),r=localStorage.getItem(o);return r?JSON.parse(r):null}catch{return null}}function wo(e,t){const o=Yt(e,t);localStorage.removeItem(o)}function nd(){const e=Y(i=>i.connectionUrl),o=Y(i=>i.activeEntity)?.logicalName??"",r=z.useRef(-1);z.useEffect(()=>e?O.subscribe(a=>a.mutationsSincePublish,a=>{if(a===0||a===r.current)return;r.current=a;const l=O.getState(),c={ribbons:l.ribbons,commands:l.commands,displayRules:l.displayRules,enableRules:l.enableRules,locLabels:l.locLabels,savedAt:new Date().toISOString()};try{const d=Yt(e,o);localStorage.setItem(d,JSON.stringify(c))}catch{}}):void 0,[e,o]),z.useEffect(()=>e?O.subscribe(a=>a.mutationsSincePublish,a=>{a===0&&(wo(e,o),r.current=0)}):void 0,[e,o])}const od=ne({leftPaneTabs:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},tabList:{flexShrink:0,borderBottom:`1px solid ${s.colorNeutralStroke2}`},tabContent:{flex:1,overflow:"hidden"}});function rd(){const e=od(),[t,o]=z.useState("tables");return n.jsxs("div",{className:e.leftPaneTabs,children:[n.jsxs(Lt,{className:e.tabList,selectedValue:t,onTabSelect:(r,i)=>o(i.value),size:"small",children:[n.jsx(fe,{value:"tables",children:"Tables"}),n.jsx(fe,{value:"elements",children:"Solution"})]}),n.jsx("div",{className:e.tabContent,children:t==="tables"?n.jsx(ac,{}):n.jsx(dc,{})})]})}function id(){const e=Y(j=>j.setSolutions),t=Y(j=>j.setEntities),o=Y(j=>j.setCurrentUser),r=Y(j=>j.setSolutionEntityIds),i=Y(j=>j.setSolutionRibbonComponentIds),a=Y(j=>j.connectionUrl),l=Y(j=>j.activeSolution),c=Y(j=>j.activeEntity),d=O(j=>j.loadWorkspace),h=O(j=>j.loadRibbons),m=q(j=>j.setTabId),u=M(j=>j.themeMode),S=J(j=>j.logInfo),I=J(j=>j.logWarn),g=J(j=>j.logError);nd();const[f,b]=z.useState(!1),[v,x]=z.useState(null),[y,p]=z.useState("idle"),[w,A]=z.useState(null),[T,P]=z.useState(0);z.useEffect(()=>{S("runtime","Loading solutions and current user..."),uc().then(j=>{e(j),S("runtime",`Loaded ${j.length} solution(s). Pick one to load its tables.`)}).catch(j=>{g("runtime",`Failed to load solutions: ${j instanceof Error?j.message:String(j)}`)}),ed().then(j=>{j.id&&(o(j.id,j.name),S("runtime",`Current user: ${j.name}.`))}).catch(j=>{I("runtime",`Failed to resolve current user: ${j instanceof Error?j.message:String(j)}`)})},[e,o,S,I,g]),z.useEffect(()=>{if(!l){r(null),i(null),t([]);return}let j=!1;return(async()=>{try{const[$,C]=await Promise.all([pc(l.id),mc(l.id)]);if(j)return;if(r($),i(C),$.length===0){t([]);return}const N=await Yl($);if(j)return;t(N)}catch($){if(j)return;g("runtime",`Failed to load solution tables: ${$ instanceof Error?$.message:String($)}`),r([]),i([]),t([])}})(),()=>{j=!0}},[l,t,r,i,g]),z.useEffect(()=>{if(!c?.logicalName)return;let j=!1;return p("loading"),A(null),S("ribbon",`Loading ribbon workspace for ${c.logicalName}...`),Promise.all([Kc(c.logicalName),Zc(c.logicalName).catch(()=>new Map)]).then(([$,C])=>{if(j)return;Pc($.ribbons,C);const N=[],_=new Set;for(const G of Object.values($.ribbons))for(const ee of G.tabs)for(const K of ee.groups)for(const R of K.buttons)R.origin==="managed"&&!_.has(R.id)&&(_.add(R.id),N.push({elementId:R.id,elementKind:"button",solutions:[{solutionId:"",solutionName:R.solutionName??"Managed Solution",publisher:R.publisherName??"",managed:!0,wins:!0,importedOn:void 0}]}));O.getState().setConflicts(N),d({ribbons:$.ribbons,commands:$.commands,displayRules:$.displayRules,enableRules:$.enableRules,locLabels:$.locLabels});const{location:U,tabId:V}=q.getState(),k=$.ribbons[U]?.tabs??[];if(!k.some(G=>G.id===V)){const G=k[0]?.id;G&&m(G)}p("idle"),S("ribbon",`Ribbon workspace loaded for ${c.logicalName}.`)}).catch($=>{if(j)return;const C=$ instanceof Error?$.message:"Failed to load ribbon";p("error"),A(C),g("ribbon",`Ribbon load failed for ${c.logicalName}: ${C}`)}),()=>{j=!0}},[c?.logicalName,d,T,m,S,g]),z.useEffect(()=>{if(!a)return;const j=c?.logicalName??"",$=td(a,j);$?(x($),b(!0)):(b(!1),x(null))},[a,c?.logicalName]);function D(){v&&(h(v.ribbons),b(!1),x(null))}function L(){a&&wo(a,c?.logicalName??""),b(!1),x(null)}function B(){P(j=>j+1)}return n.jsx(es,{theme:u==="dark"?ts:ns,children:n.jsxs(Xs,{leftPane:n.jsx(rd,{}),rightPane:n.jsx(oc,{}),bottomPanel:n.jsx(rc,{}),children:[f&&v&&n.jsxs(be,{intent:"warning",style:{position:"absolute",top:0,left:0,right:0,zIndex:1e3},children:[n.jsxs(he,{children:["You have unsaved changes from a previous session (saved"," ",new Date(v.savedAt).toLocaleString(),")."]}),n.jsx(ut,{containerAction:n.jsx(W,{size:"small",appearance:"subtle",onClick:L,children:"Discard"}),children:n.jsx(W,{size:"small",appearance:"primary",onClick:D,children:"Restore"})})]}),n.jsx(Ol,{isLoadingRibbon:y==="loading",ribbonLoadError:w,onRetryRibbonLoad:B})]})})}async function ad(){const e=J.getState().logInfo,t=window.toolboxAPI,o=window.dataverseAPI;if(!t||!o)throw new Error("PPTB host APIs are required. toolboxAPI/dataverseAPI were not found.");e("startup","Connected to PPTB host runtime.");const r=await t.utils.getCurrentTheme(),i=r==="dark";e("startup",`Host theme loaded: ${r}.`);const a=await t.connections.getActiveConnection();if(!a)throw new Error("No active connection available from toolboxAPI");const{setConnection:l}=Y.getState(),{setThemeMode:c}=M.getState();l(a.url,a.name,a.environment),c(i?"dark":"light"),e("startup",`Connected to ${a.name} (${a.environment}).`),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&t.utils.getCurrentTheme().then(m=>{M.getState().setThemeMode(m==="dark"?"dark":"light")}).catch(m=>{J.getState().logWarn("startup",`Theme refresh failed: ${m instanceof Error?m.message:String(m)}`)})});const d=document.getElementById("root");if(!d)throw new Error("No #root element found");ps.createRoot(d).render(n.jsx(z.StrictMode,{children:n.jsx(id,{})}))}ad().catch(e=>{J.getState().logError("startup",e instanceof Error?e.message:String(e)),console.error(e)});export{Wt as D,Qe as F,Ht as a,Gt as b,Ue as c,J as d,q as e,ud as f,Ve as g,Y as h,M as i,bn as s,O as u,cn as w,pd as z};
|