efficient-easel 11.2.0 → 11.8.0

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.
Files changed (121) hide show
  1. package/README.md +20 -41
  2. package/dist/{canvas-typing-DvoqQINU.d.ts → canvas-typing-CC0wA-ys.d.ts} +16 -105
  3. package/dist/chrome/chrome.css +5 -5
  4. package/dist/{chunk-66LWADFP.js → chunk-2XMHLXMA.js} +1 -1
  5. package/dist/chunk-33C6ALT5.js +1 -0
  6. package/dist/{chunk-XJCMEEBH.js → chunk-36LVP5WD.js} +7 -7
  7. package/dist/{chunk-SJPKSE5G.js → chunk-5IUS6PM6.js} +12 -12
  8. package/dist/{chunk-FPAVNX3Y.js → chunk-5XUMLKQF.js} +3 -3
  9. package/dist/{chunk-PPL7GB7D.js → chunk-62VPYC7F.js} +1 -1
  10. package/dist/chunk-643PVCEG.js +1 -0
  11. package/dist/{chunk-TWFM6GNK.js → chunk-6IT5H37Y.js} +1 -1
  12. package/dist/{chunk-AFSSKGTD.js → chunk-6TJ2CIMY.js} +1 -1
  13. package/dist/{chunk-4ACVXF5V.js → chunk-7BRKNQF7.js} +1 -1
  14. package/dist/chunk-A6PY6C3C.js +1 -0
  15. package/dist/{chunk-XWK7WZQS.js → chunk-ATF2T5CI.js} +1 -1
  16. package/dist/chunk-AYWN5NRH.js +1 -0
  17. package/dist/chunk-DE35IQ4T.js +57 -0
  18. package/dist/{chunk-PPHUWGLZ.js → chunk-EC2I7SIY.js} +1 -1
  19. package/dist/{chunk-DGAXQTDW.js → chunk-FHLYUIJJ.js} +1 -1
  20. package/dist/{chunk-65Z5FSAW.js → chunk-G3GWAP5R.js} +5 -5
  21. package/dist/{chunk-2FZJWH24.js → chunk-H4UMY7QF.js} +1 -1
  22. package/dist/chunk-H6IXH4A3.js +1 -0
  23. package/dist/{chunk-EXKKLTXH.js → chunk-HRUMNRYI.js} +1 -1
  24. package/dist/chunk-JHYKRGRA.js +5 -0
  25. package/dist/chunk-JRRYFSCY.js +5 -0
  26. package/dist/chunk-KEWQZYUF.js +7 -0
  27. package/dist/{chunk-IFS5P7CO.js → chunk-LZS7JZK5.js} +1 -1
  28. package/dist/{chunk-FGJSCWUN.js → chunk-NY7HHUGB.js} +2 -2
  29. package/dist/chunk-PS5BWS4I.js +2 -0
  30. package/dist/{chunk-47RGVCPH.js → chunk-QFVRMARS.js} +12 -12
  31. package/dist/chunk-TBF5CVPA.js +1 -0
  32. package/dist/{chunk-26GHWMNN.js → chunk-UBAYMWCX.js} +19 -19
  33. package/dist/chunk-UMDQ6CLQ.js +2 -0
  34. package/dist/{chunk-ZXGQT75B.js → chunk-URC5Y5G2.js} +1 -1
  35. package/dist/chunk-VVPZMWJE.js +1 -0
  36. package/dist/chunk-WRFD4EXD.js +1 -0
  37. package/dist/chunk-YHZSBL2N.js +1 -0
  38. package/dist/copy/copy.css +8 -108
  39. package/dist/copy/index.d.ts +39 -9
  40. package/dist/copy/index.js +18 -19
  41. package/dist/drag/drag.css +8 -8
  42. package/dist/drag/index.js +1 -1
  43. package/dist/easel/index.d.ts +3 -3
  44. package/dist/easel/index.js +1 -1
  45. package/dist/fields/fields.css +8 -8
  46. package/dist/fields/index.js +1 -1
  47. package/dist/gold/index.d.ts +3 -3
  48. package/dist/gold/index.js +1 -1
  49. package/dist/{host-Ud6rLpph.d.ts → host-GOlVK3LX.d.ts} +9 -0
  50. package/dist/icons/index.d.ts +1 -0
  51. package/dist/markup/index.d.ts +1 -629
  52. package/dist/markup/index.js +1 -1
  53. package/dist/menu/menu.css +1 -1
  54. package/dist/panel/index.js +1 -1
  55. package/dist/panel/panel.css +12 -12
  56. package/dist/pick/index.js +1 -1
  57. package/dist/pick/pick.css +7 -7
  58. package/dist/screen/components/AddBlockRow.js +1 -1
  59. package/dist/screen/components/AddSidePanel.js +1 -1
  60. package/dist/screen/components/MediaSidePanel.d.ts +1 -1
  61. package/dist/screen/components/MediaSidePanel.js +1 -1
  62. package/dist/screen/components/NodeContextMenu.d.ts +1 -1
  63. package/dist/screen/components/NodeContextMenu.js +1 -1
  64. package/dist/screen/components/PageEditGuardNotices.js +1 -1
  65. package/dist/screen/components/PanelToggleIcon.d.ts +6 -5
  66. package/dist/screen/components/PanelToggleIcon.js +1 -1
  67. package/dist/screen/components/SaveControls.d.ts +1 -1
  68. package/dist/screen/components/ScreenChrome.js +1 -1
  69. package/dist/screen/components/ScreenDocumentContext.d.ts +1 -1
  70. package/dist/screen/components/ScreenDocumentContext.js +1 -1
  71. package/dist/screen/components/ScreenMount.d.ts +1 -1
  72. package/dist/screen/components/ScreenMount.js +1 -1
  73. package/dist/screen/components/ScreenStoreProvider.d.ts +1 -1
  74. package/dist/screen/components/ScreenStoreProvider.js +1 -1
  75. package/dist/screen/components/SectionScreenShell.js +16 -16
  76. package/dist/screen/components/SidePanelHead.js +1 -1
  77. package/dist/screen/components/usePartBridge.d.ts +1 -1
  78. package/dist/screen/components/usePartBridge.js +1 -1
  79. package/dist/screen/index.d.ts +1 -1
  80. package/dist/screen/index.js +1 -1
  81. package/dist/screen/lib/document-addressing.d.ts +1 -1
  82. package/dist/screen/lib/host.d.ts +1 -1
  83. package/dist/screen/lib/key-scope.js +1 -1
  84. package/dist/screen/lib/media-panel.d.ts +1 -1
  85. package/dist/screen/lib/media-picker.d.ts +1 -1
  86. package/dist/screen/lib/puck/device-fields.js +1 -1
  87. package/dist/screen/lib/puck/slot-child-name.js +1 -1
  88. package/dist/screen/lib/puck/style-clipboard.d.ts +1 -1
  89. package/dist/screen/lib/puck/style-clipboard.js +1 -1
  90. package/dist/screen/lib/puck/use-section-ops.js +1 -1
  91. package/dist/screen/lib/screen-parts.d.ts +1 -1
  92. package/dist/screen/lib/screen-parts.js +1 -1
  93. package/dist/screen/screen.css +16 -16
  94. package/dist/screen/words.js +1 -1
  95. package/dist/shell/shell.css +10 -8
  96. package/dist/strings/catalogue.d.ts +2 -2
  97. package/dist/strings/catalogue.js +1 -1
  98. package/dist/strings/index.d.ts +2 -2
  99. package/dist/strings/index.js +1 -1
  100. package/dist/text-styles/index.d.ts +4 -231
  101. package/dist/text-styles/index.js +35 -35
  102. package/dist/text-styles/model.d.ts +259 -0
  103. package/dist/text-styles/model.js +1 -0
  104. package/dist/text-styles/text-styles.css +6 -6
  105. package/dist/{words-dsex49Jh.d.ts → words-CiuKuiy0.d.ts} +12 -6
  106. package/package.json +6 -1
  107. package/dist/chunk-546BBOPE.js +0 -1
  108. package/dist/chunk-AZOCY74V.js +0 -57
  109. package/dist/chunk-BHRC3ASL.js +0 -1
  110. package/dist/chunk-BPFPM3L4.js +0 -7
  111. package/dist/chunk-DD7A6RRL.js +0 -5
  112. package/dist/chunk-EQFBUNEB.js +0 -1
  113. package/dist/chunk-FAAZZXIS.js +0 -1
  114. package/dist/chunk-FFYXVAAL.js +0 -1
  115. package/dist/chunk-GCCBEY2W.js +0 -2
  116. package/dist/chunk-GG4FGBFR.js +0 -1
  117. package/dist/chunk-KQMML6JM.js +0 -4
  118. package/dist/chunk-Q6AM43CA.js +0 -1
  119. package/dist/chunk-U7KFFC7N.js +0 -5
  120. package/dist/chunk-VWXUMVCD.js +0 -1
  121. package/dist/chunk-ZAOM6PFH.js +0 -1
@@ -1,35 +1,35 @@
1
- import{hexReadout as e,ColourWindow as n,typedHex as t}from"../chunk-FPAVNX3Y.js";import{DEFAULT_TEXT_STYLES_WORDS as s}from"../chunk-OGH6CC3E.js";export{DEFAULT_TEXT_STYLES_WORDS}from"../chunk-OGH6CC3E.js";import"../chunk-ZAOM6PFH.js";import{FieldSlider as a}from"../chunk-XWFH2NHZ.js";import{FieldSelect as i}from"../chunk-65Z5FSAW.js";import"../chunk-FFYXVAAL.js";import{useWords as l}from"../chunk-MFIRYGHW.js";import{withTip as r}from"../chunk-P2VEMZH5.js";import{hsvToHex as o,Tooltip as d,ColorSwatch as c,IconButton as u}from"efficient-shell/ui";import{useState as m,useRef as f,useId as h,useEffect as p,Fragment as v}from"react";import{TrashIcon as g,ChevronIcon as y,BoldIcon as k,ItalicIcon as b,CaseLowerIcon as x,CaseCapitalizedIcon as w,CaseUpperIcon as S,CaseNormalIcon as N}from"efficient-shell/icons/efficient";import{jsxs as C,jsx as z,Fragment as O}from"react/jsx-runtime";var M=["font","color","size","weight","emphasis","lineSpacing","letterSpacing","paragraphSpacing","letterCase","largestSize"],$=["font","color","size","weight","lineSpacing","letterSpacing","paragraphSpacing","letterCase"],A=["heading","body"],j=7,F={heading:3,body:5},E={min:5,max:void 0,sliderMin:12,sliderMax:72,step:1,shiftStep:10,unit:"px"},W={size:E,weight:{min:100,max:900,sliderMin:300,sliderMax:900,step:100,shiftStep:100,unit:""},lineSpacing:{min:50,max:250,sliderMin:50,sliderMax:250,step:1,shiftStep:10,unit:"%"},letterSpacing:{min:-10,max:void 0,sliderMin:-5,sliderMax:10,step:.1,shiftStep:1,unit:"px"},paragraphSpacing:{min:0,max:void 0,sliderMin:0,sliderMax:48,step:1,shiftStep:10,unit:"px"},largestSize:E},H=(e,n)=>`${"heading"===e?"Heading":"Body"} ${n}`;function L(e=({kind:e,n:n})=>H(e,n)){return A.flatMap(n=>Array.from({length:F[n]},(t,s)=>({id:`${n}-${s+1}`,kind:n,name:e({kind:n,n:s+1}),values:{}})))}function B(e,n,t=j){return e.filter(e=>e.kind===n).length<t}function D(e,n){const t=new RegExp(`^${n}-([1-9]\\d*)$`).exec(e);return t?Number(t[1]):void 0}function I(e){const n=D(e.id,e.kind);return void 0!==n&&n<=F[e.kind]}function R(e,n,t={}){const{max:s=j,name:a=({kind:e,n:n})=>H(e,n),make:i}=t;if(!B(e,n,s))return null;const l=e.filter(e=>e.kind===n);let r=l.length+1;const o=new Set(e.map(e=>e.name));for(;o.has(a({kind:n,n:r}));)r+=1;const d=new Set(e.map(e=>e.id));let c=Math.max(r,...l.map(e=>(D(e.id,n)??0)+1));for(;d.has(`${n}-${c}`);)c+=1;const u=l.at(-1),m=i?i(n,r):{id:`${n}-${c}`,kind:n,name:a({kind:n,n:r}),values:{...u?.values??{}}},f=u?e.indexOf(u)+1:"heading"===n?0:e.length;return{styles:[...e.slice(0,f),m,...e.slice(f)],added:m}}function T(e,n,t={}){const{name:s=({kind:e,n:n})=>H(e,n)}=t,a=e.find(e=>e.id===n);if(!a||I(a))return null;const i=e.filter(e=>e.kind===a.kind),l=i.indexOf(a),r=/* @__PURE__ */new Map;return i.forEach((e,n)=>{n>l&&e.name===s({kind:e.kind,n:n+1})&&r.set(e,s({kind:e.kind,n:n}))}),{styles:e.filter(e=>e!==a).map(e=>r.has(e)?{...e,name:r.get(e)}:e),removed:a}}function V(e,n){const t=e.find(e=>e.id===n);if(t)return t;for(const t of A){const s=D(n,t);if(void 0===s)continue;let a;for(const n of e){const e=n.kind===t?D(n.id,t):void 0;void 0!==e&&e<s&&(!a||e>a.n)&&(a={n:e,style:n})}return a?.style}}function X(e,n,t){return e.map(e=>{if(e.id!==n)return e;const s={...e.values};for(const[e,n]of Object.entries(t))void 0===n?delete s[e]:s[e]=n;return{...e,values:s}})}function Y(e){return Math.min(20,Math.max(12,Math.round(.5*e+6)))}function Z(e,n){const t=n.weights;return[t.thin,t.extraLight,t.light,t.regular,t.medium,t.semibold,t.bold,t.extraBold,t.black][Math.min(8,Math.max(0,Math.round(e/100)-1))]}function q(e,n,t,s={}){const a=n.find(n=>n.value===e.font)?.label??e.font??"",i=void 0===e.size?s.autoSize?t.auto:"":t.px({n:e.size});return t.summary({font:a,size:i,weight:Z(e.weight??400,t)})}var G=`conic-gradient(${[0,60,120,180,240,300,0].map(e=>o({h:e,s:1,v:1})).join(", ")})`;function P({value:t,hex:s,colours:a,label:i,followsWord:l,anyWord:r,onChange:o,readOnly:u=!1}){const[v,g]=m(!1),y=f(null),k=f(null),b=h(),x=void 0!==t&&a.some(e=>e.key===t),w=void 0!==t&&!x;return p(()=>{if(!v)return;const e=y.current?.ownerDocument;if(!e)return;const n=e=>{y.current&&!y.current.contains(e.target)&&g(!1)};return e.addEventListener("click",n,!0),()=>e.removeEventListener("click",n,!0)},[v]),/* @__PURE__ */C("div",{ref:y,className:"es-ts-set","data-ts-setting":"color",children:[
2
- /* @__PURE__ */C("div",{className:"es-ts-top",children:[
3
- /* @__PURE__ */z("span",{className:"es-ts-sub",children:i}),
4
- /* @__PURE__ */z("span",{className:"es-ts-colour-read",children:s?e(s):l})]}),
5
- /* @__PURE__ */C("div",{className:"es-ts-swatches",role:"group","aria-label":i,children:[a.map(n=>/* @__PURE__ */z(d,{content:`${n.name} · ${e(n.value)}`,children:/* @__PURE__ */z(c,{color:n.value,size:"sm",className:"es-ts-swatch","aria-label":n.name,selected:t===n.key,disabled:u,onClick:()=>o(n.key)})},n.key)),
6
- /* @__PURE__ */z(d,{content:r,children:/* @__PURE__ */z(c,{ref:k,color:G,size:"sm",className:"es-ts-swatch es-ts-swatch--any","aria-label":r,selected:w,"aria-expanded":v,"aria-controls":v?b:void 0,disabled:u,onClick:()=>g(e=>!e)})})]}),v?/* @__PURE__ */z(n,{id:b,value:s??"",onChange:e=>o(e),label:i,readOnly:u,onClose:()=>{g(!1),k.current?.focus()}}):null]})}function _({styles:e,onChange:n,fonts:t,colours:a=[],settings:i=$,auto:o=[],fallback:d,sample:c,openId:u,defaultOpenId:v=null,onOpenChange:y,onAdd:k,rowActions:b,onRemove:x,max:w=j,readOnly:S=!1}){const N=l("textStyles",s),M=h(),[F,E]=m(v),W=void 0!==u?u:F,H=e=>{void 0===u&&E(e),y?.(e)},L=f(null),[D,V]=m(null);p(()=>{if(!D||!L.current)return;const e=[...L.current.querySelectorAll(".es-ts-item")].find(e=>e.dataset.tsId===D.id),n=e?e.querySelector(".es-ts-row"):L.current.querySelector(`.es-ts-add[data-ts-kind="${D.kind}"]`);n?.focus(),V(null)},[D]);/* @__PURE__ */
7
- return z("div",{className:"es-ts",ref:L,children:A.map(s=>{const l=e.filter(e=>e.kind===s),u=!B(e,s,w),m=!S&&!u;/* @__PURE__ */
8
- return C(U,{label:N.groups[s],children:[l.map(s=>{const l=b?.(s),u=null!=l&&!1!==l,m=Boolean(x)&&!S&&!I(s);/* @__PURE__ */
9
- return z(K,{style:s,fonts:t,colours:a,settings:i,auto:o,fallback:d,sample:c,readOnly:S,open:W===s.id,onOpenChange:e=>H(e?s.id:null),onChange:t=>n(e.map(e=>e.id===t.id?t:e)),actions:m||u?/* @__PURE__ */C(O,{children:[m?r(N.remove,/* @__PURE__ */z("button",{type:"button",className:"es-ts-del","aria-label":N.removeNamed({name:s.name}),onClick:()=>(t=>{if(S||!x)return;const s=T(e,t.id,{name:N.styleName});if(!s)return;const a=e.filter(e=>e.kind===t.kind),i=a[a.indexOf(t)+1];W===t.id&&H(null),n(s.styles),x(s.removed),V({id:i?.id??null,kind:t.kind})})(s),children:/* @__PURE__ */z(g,{size:14,"aria-hidden":"true"})})):null,u?l:null]}):null},s.id)}),r(!S&&u?N.full({kind:s,max:w}):void 0,/* @__PURE__ */C("button",{type:"button",className:"es-ts-add","data-ts-kind":s,disabled:S,"aria-disabled":!(S||!u)||void 0,"aria-describedby":!S&&u?`${M}-full-${s}`:void 0,onClick:()=>{m&&(t=>{if(S)return;const s=R(e,t,{max:w,name:N.styleName,make:k});s&&n(s.styles)})(s)},children:[
10
- /* @__PURE__ */z("span",{className:"es-ts-add-word",children:N.add[s]}),
11
- /* @__PURE__ */z("span",{className:"es-ts-count",children:N.count({n:l.length,max:w})})]})),S||!u?null:/* @__PURE__ */z("span",{id:`${M}-full-${s}`,className:"es-vh",children:N.full({kind:s,max:w})})]},s)})})}function U({label:e,children:n}){const t=h();/* @__PURE__ */
12
- return C("section",{className:"es-ts-section","aria-labelledby":t,children:[
13
- /* @__PURE__ */z("div",{className:"es-ts-group",id:t,children:e}),n]})}function K({style:e,fonts:n,colours:t=[],settings:a=$,auto:i=[],fallback:r,sample:o,open:d,onOpenChange:c,onChange:u,actions:m,readOnly:f=!1}){const p=l("textStyles",s),g=`${h()}-open-${e.id}`,k=new Set(i),b=M.filter(e=>a.includes(e)),x={...r?.(e)??{},...e.values},w=n.find(e=>e.value===x.font),S={fontFamily:w?.family,fontSize:`${Y(x.size??16)}px`,fontWeight:x.weight,fontStyle:x.italic?"italic":void 0};/* @__PURE__ */
14
- return C(v,{children:[
15
- /* @__PURE__ */C("div",{className:"es-ts-item","data-ts-id":e.id,children:[
16
- /* @__PURE__ */C("button",{type:"button",className:"es-ts-row","aria-expanded":d,"aria-controls":d?g:void 0,onClick:()=>c(!d),children:[
17
- /* @__PURE__ */z("span",{className:"es-ts-chev","aria-hidden":"true",children:/* @__PURE__ */z(y,{size:12})}),
18
- /* @__PURE__ */z("span",{className:"es-ts-name",style:S,children:e.name}),
19
- /* @__PURE__ */z("span",{className:"es-ts-meta",children:q(x,n,p,{autoSize:k.has("size")&&void 0===e.values.size})})]}),m?/* @__PURE__ */z("div",{className:"es-ts-actions",children:m}):null]}),d?/* @__PURE__ */z("div",{className:"es-ts-open",id:g,children:/* @__PURE__ */z(ee,{style:e,values:x,fonts:n,colours:t,settings:b,autoSet:k,sample:o??p.sample,words:p,readOnly:f,set:n=>u(X([e],e.id,n)[0])})}):null]})}var J={none:N,upper:S,capitalize:w,lower:x},Q={none:"none",upper:"uppercase",capitalize:"capitalize",lower:"lowercase"};function ee({style:e,values:n,fonts:s,colours:i,settings:l,autoSet:o,sample:d,words:c,readOnly:m,set:f}){const h=e.values,p=s.find(e=>e.value===n.font),v=function(e,n){return e?n.find(n=>n.key===e)?.value??t(e)??void 0:void 0}(n.color,i),g=e=>"largestSize"===e||o.has(e),y=e=>g(e)?h[e]:n[e],x=y("size"),w=y("lineSpacing"),S=y("letterSpacing"),N=g("letterCase")?h.letterCase:n.letterCase,M={fontFamily:p?.family,fontSize:void 0===x?void 0:`${x}px`,fontWeight:n.weight,fontStyle:n.italic?"italic":void 0,lineHeight:void 0===w?void 0:String(w/100),letterSpacing:void 0===S?void 0:`${S}px`,color:v,textTransform:N?Q[N]:void 0},$=e=>{const t=W[e],s=g(e);/* @__PURE__ */
20
- return z("div",{className:"es-ts-slider","data-ts-setting":e,children:/* @__PURE__ */z(a,{label:c.settings[e],value:h[e],onChange:n=>f({[e]:n}),min:t.min,max:t.max,step:t.step,shiftStep:t.shiftStep,sliderMin:t.sliderMin,sliderMax:t.sliderMax,unit:t.unit||void 0,styleValue:s?void 0:n[e],auto:s?c.auto:void 0,readOnly:m})},e)};/* @__PURE__ */
21
- return C(O,{children:[
22
- /* @__PURE__ */z("div",{className:"es-ts-preview",style:M,"aria-label":c.preview,children:d}),l.map(t=>{switch(t){case"font":/* @__PURE__ */
23
- return z(ne,{value:h.font,fonts:s,words:c,readOnly:m,set:f},t);case"color":/* @__PURE__ */
24
- return z(te,{value:h.color,hex:v,colours:i,words:c,readOnly:m,set:f},t);case"emphasis":{const e=(n.weight??400)>=600,s=!1!==p?.italic;/* @__PURE__ */
25
- return C("div",{className:"es-ts-set","data-ts-setting":t,children:[
26
- /* @__PURE__ */z("span",{className:"es-ts-sub",children:c.settings.emphasis}),
27
- /* @__PURE__ */C("div",{className:"es-ts-icons",children:[r(c.bold,/* @__PURE__ */z(u,{className:"es-ts-icon","aria-label":c.bold,"aria-pressed":e,disabled:m,onClick:()=>f({weight:e?400:700}),children:/* @__PURE__ */z(k,{size:16})})),m||s?r(c.italic,/* @__PURE__ */z(u,{className:"es-ts-icon","aria-label":c.italic,"aria-pressed":Boolean(n.italic),disabled:m,onClick:()=>f({italic:!n.italic||void 0}),children:/* @__PURE__ */z(b,{size:16})})):/* @__PURE__ */z(u,{className:"es-ts-icon","aria-label":c.italic,"aria-pressed":Boolean(n.italic),"aria-disabled":!0,disabledReason:c.italicMissing,children:/* @__PURE__ */z(b,{size:16})})]})]},t)}case"letterCase":/* @__PURE__ */
28
- return z(se,{value:h.letterCase??n.letterCase,auto:g("letterCase"),words:c,readOnly:m,set:f},t);case"largestSize":return"heading"===e.kind?$(t):null;default:return $(t)}})]})}function ne({value:e,fonts:n,words:t,readOnly:s,set:a}){const l=h();/* @__PURE__ */
29
- return C("div",{className:"es-ts-set","data-ts-setting":"font",children:[
30
- /* @__PURE__ */z("span",{className:"es-ts-sub",id:l,children:t.settings.font}),
31
- /* @__PURE__ */z(i,{value:e,options:n.map(e=>({label:e.label,value:e.value})),onChange:e=>a({font:e}),ariaLabelledBy:l,readOnly:s})]})}function te({value:e,hex:n,colours:t,words:s,readOnly:a,set:i}){/* @__PURE__ */
32
- return z(P,{value:e,hex:n,colours:t,label:s.settings.color,followsWord:s.colour.follows,anyWord:s.colour.any,readOnly:a,onChange:e=>i({color:e})})}function se({value:e,auto:n,words:t,readOnly:s,set:a}){const i=n?["auto","none","upper","capitalize","lower"]:["none","upper","capitalize","lower"],l=e??(n?"auto":"none"),o=f([]),d=e=>a({letterCase:"auto"===e?void 0:e});/* @__PURE__ */
33
- return C("div",{className:"es-ts-set","data-ts-setting":"letterCase",children:[
34
- /* @__PURE__ */z("span",{className:"es-ts-sub",children:t.settings.letterCase}),
35
- /* @__PURE__ */z("div",{className:"es-ts-icons",role:"radiogroup","aria-label":t.settings.letterCase,onKeyDown:e=>{const n="ArrowRight"===e.key||"ArrowDown"===e.key?1:"ArrowLeft"===e.key||"ArrowUp"===e.key?-1:0;if(!n||s)return;e.preventDefault();const t=(i.indexOf(l)+n+i.length)%i.length;d(i[t]),o.current[t]?.focus()},children:i.map((e,n)=>{const a=e===l;if("auto"===e)return r(t.case.autoTitle,/* @__PURE__ */z(u,{ref:e=>{o.current[n]=e},role:"radio",pressed:a,className:"es-ts-icon es-ts-icon--word","aria-checked":a,"aria-label":t.case.auto,tabIndex:a?0:-1,disabled:s,onClick:()=>d(e),children:t.case.auto},e));const i=J[e];return r(t.case[e],/* @__PURE__ */z(u,{ref:e=>{o.current[n]=e},role:"radio",pressed:a,className:"es-ts-icon","aria-checked":a,"aria-label":t.case[e],tabIndex:a?0:-1,disabled:s,onClick:()=>d(e),children:/* @__PURE__ */z(i,{size:16})},e))})})]})}export{$ as CAMPAIGN_TEXT_STYLE_SETTINGS,P as ColourSwatchRow,F as TEXT_STYLE_DEFAULT_COUNT,A as TEXT_STYLE_KINDS,j as TEXT_STYLE_MAX,W as TEXT_STYLE_RANGES,M as TEXT_STYLE_SETTINGS,K as TextStyleItem,U as TextStylesGroup,_ as TextStylesList,R as addTextStyle,B as canAddTextStyle,L as defaultTextStyles,q as describeTextStyle,I as isDefaultTextStyle,T as removeTextStyle,V as resolveTextStyle,Y as textStyleRowSize,X as updateTextStyle,Z as weightWord};
1
+ import{hexReadout as e,ColourWindow as s,typedHex as t}from"../chunk-5XUMLKQF.js";import{DEFAULT_TEXT_STYLES_WORDS as a}from"../chunk-OGH6CC3E.js";export{DEFAULT_TEXT_STYLES_WORDS}from"../chunk-OGH6CC3E.js";import"../chunk-643PVCEG.js";import{FieldSlider as l}from"../chunk-XWFH2NHZ.js";import{TEXT_STYLE_KINDS as n,canAddTextStyle as i,TEXT_STYLE_MAX as r,isDefaultTextStyle as o,CAMPAIGN_TEXT_STYLE_SETTINGS as c,TEXT_STYLE_SETTINGS as d,textStyleRowSize as u,describeTextStyle as m,updateTextStyle as h,textStyleCaseCss as f,TEXT_STYLE_CASES as p,addTextStyle as v,removeTextStyle as y,TEXT_STYLE_RANGES as S}from"../chunk-YHZSBL2N.js";export{CAMPAIGN_TEXT_STYLE_SETTINGS,TEXT_STYLE_CASES,TEXT_STYLE_CASE_CSS,TEXT_STYLE_DEFAULT_COUNT,TEXT_STYLE_KINDS,TEXT_STYLE_MAX,TEXT_STYLE_RANGES,TEXT_STYLE_SETTINGS,addTextStyle,canAddTextStyle,defaultTextStyles,describeTextStyle,isDefaultTextStyle,isTextStyleCase,removeTextStyle,resolveTextStyle,textStyleCaseCss,textStyleCaseOfCss,textStyleRowSize,updateTextStyle,weightWord}from"../chunk-YHZSBL2N.js";import{FieldSelect as g}from"../chunk-G3GWAP5R.js";import"../chunk-WRFD4EXD.js";import{useWords as b}from"../chunk-MFIRYGHW.js";import{withTip as N}from"../chunk-P2VEMZH5.js";import{hsvToHex as k,Tooltip as C,ColorSwatch as T,IconButton as x}from"efficient-shell/ui";import{useState as w,useRef as E,useId as O,useEffect as _,Fragment as z}from"react";import{TrashIcon as L,ChevronIcon as A,BoldIcon as j,ItalicIcon as X,CaseLowerIcon as $,CaseCapitalizedIcon as W,CaseUpperIcon as Y,CaseNormalIcon as D}from"efficient-shell/icons/efficient";import{jsxs as G,jsx as I,Fragment as M}from"react/jsx-runtime";var F=`conic-gradient(${[0,60,120,180,240,300,0].map(e=>k({h:e,s:1,v:1})).join(", ")})`;function H({value:t,hex:a,colours:l,label:n,followsWord:i,anyWord:r,onChange:o,readOnly:c=!1}){const[d,u]=w(!1),m=E(null),h=E(null),f=O(),p=void 0!==t&&l.some(e=>e.key===t),v=void 0!==t&&!p;return _(()=>{if(!d)return;const e=m.current?.ownerDocument;if(!e)return;const s=e=>{m.current&&!m.current.contains(e.target)&&u(!1)};return e.addEventListener("click",s,!0),()=>e.removeEventListener("click",s,!0)},[d]),/* @__PURE__ */G("div",{ref:m,className:"es-ts-set","data-ts-setting":"color",children:[
2
+ /* @__PURE__ */G("div",{className:"es-ts-top",children:[
3
+ /* @__PURE__ */I("span",{className:"es-ts-sub",children:n}),
4
+ /* @__PURE__ */I("span",{className:"es-ts-colour-read",children:a?e(a):i})]}),
5
+ /* @__PURE__ */G("div",{className:"es-ts-swatches",role:"group","aria-label":n,children:[l.map(s=>/* @__PURE__ */I(C,{content:`${s.name} · ${e(s.value)}`,children:/* @__PURE__ */I(T,{color:s.value,size:"sm",className:"es-ts-swatch","aria-label":s.name,selected:t===s.key,disabled:c,onClick:()=>o(s.key)})},s.key)),
6
+ /* @__PURE__ */I(C,{content:r,children:/* @__PURE__ */I(T,{ref:h,color:F,size:"sm",className:"es-ts-swatch es-ts-swatch--any","aria-label":r,selected:v,"aria-expanded":d,"aria-controls":d?f:void 0,disabled:c,onClick:()=>u(e=>!e)})})]}),d?/* @__PURE__ */I(s,{id:f,value:a??"",onChange:e=>o(e),label:n,readOnly:c,onClose:()=>{u(!1),h.current?.focus()}}):null]})}function R({styles:e,onChange:s,fonts:t,colours:l=[],settings:d=c,auto:u=[],fallback:m,sample:h,openId:f,defaultOpenId:p=null,onOpenChange:S,onAdd:g,rowActions:k,onRemove:C,max:T=r,readOnly:x=!1}){const z=b("textStyles",a),A=O(),[j,X]=w(p),$=void 0!==f?f:j,W=e=>{void 0===f&&X(e),S?.(e)},Y=E(null),[D,F]=w(null);_(()=>{if(!D||!Y.current)return;const e=[...Y.current.querySelectorAll(".es-ts-item")].find(e=>e.dataset.tsId===D.id),s=e?e.querySelector(".es-ts-row"):Y.current.querySelector(`.es-ts-add[data-ts-kind="${D.kind}"]`);s?.focus(),F(null)},[D]);/* @__PURE__ */
7
+ return I("div",{className:"es-ts",ref:Y,children:n.map(a=>{const n=e.filter(e=>e.kind===a),r=!i(e,a,T),c=!x&&!r;/* @__PURE__ */
8
+ return G(B,{label:z.groups[a],children:[n.map(a=>{const n=k?.(a),i=null!=n&&!1!==n,r=Boolean(C)&&!x&&!o(a);/* @__PURE__ */
9
+ return I(U,{style:a,fonts:t,colours:l,settings:d,auto:u,fallback:m,sample:h,readOnly:x,open:$===a.id,onOpenChange:e=>W(e?a.id:null),onChange:t=>s(e.map(e=>e.id===t.id?t:e)),actions:r||i?/* @__PURE__ */G(M,{children:[r?N(z.remove,/* @__PURE__ */I("button",{type:"button",className:"es-ts-del","aria-label":z.removeNamed({name:a.name}),onClick:()=>(t=>{if(x||!C)return;const a=y(e,t.id,{name:z.styleName});if(!a)return;const l=e.filter(e=>e.kind===t.kind),n=l[l.indexOf(t)+1];$===t.id&&W(null),s(a.styles),C(a.removed),F({id:n?.id??null,kind:t.kind})})(a),children:/* @__PURE__ */I(L,{size:14,"aria-hidden":"true"})})):null,i?n:null]}):null},a.id)}),N(!x&&r?z.full({kind:a,max:T}):void 0,/* @__PURE__ */G("button",{type:"button",className:"es-ts-add","data-ts-kind":a,disabled:x,"aria-disabled":!(x||!r)||void 0,"aria-describedby":!x&&r?`${A}-full-${a}`:void 0,onClick:()=>{c&&(t=>{if(x)return;const a=v(e,t,{max:T,name:z.styleName,make:g});a&&s(a.styles)})(a)},children:[
10
+ /* @__PURE__ */I("span",{className:"es-ts-add-word",children:z.add[a]}),
11
+ /* @__PURE__ */I("span",{className:"es-ts-count",children:z.count({n:n.length,max:T})})]})),x||!r?null:/* @__PURE__ */I("span",{id:`${A}-full-${a}`,className:"es-vh",children:z.full({kind:a,max:T})})]},a)})})}function B({label:e,children:s}){const t=O();/* @__PURE__ */
12
+ return G("section",{className:"es-ts-section","aria-labelledby":t,children:[
13
+ /* @__PURE__ */I("div",{className:"es-ts-group",id:t,children:e}),s]})}function U({style:e,fonts:s,colours:t=[],settings:l=c,auto:n=[],fallback:i,sample:r,open:o,onOpenChange:f,onChange:p,actions:v,readOnly:y=!1}){const S=b("textStyles",a),g=`${O()}-open-${e.id}`,N=new Set(n),k=d.filter(e=>l.includes(e)),C={...i?.(e)??{},...e.values},T=s.find(e=>e.value===C.font),x={fontFamily:T?.family,fontSize:`${u(C.size??16)}px`,fontWeight:C.weight,fontStyle:C.italic?"italic":void 0};/* @__PURE__ */
14
+ return G(z,{children:[
15
+ /* @__PURE__ */G("div",{className:"es-ts-item","data-ts-id":e.id,children:[
16
+ /* @__PURE__ */G("button",{type:"button",className:"es-ts-row","aria-expanded":o,"aria-controls":o?g:void 0,onClick:()=>f(!o),children:[
17
+ /* @__PURE__ */I("span",{className:"es-ts-chev","aria-hidden":"true",children:/* @__PURE__ */I(A,{size:12})}),
18
+ /* @__PURE__ */I("span",{className:"es-ts-name",style:x,children:e.name}),
19
+ /* @__PURE__ */I("span",{className:"es-ts-meta",children:m(C,s,S,{autoSize:N.has("size")&&void 0===e.values.size})})]}),v?/* @__PURE__ */I("div",{className:"es-ts-actions",children:v}):null]}),o?/* @__PURE__ */I("div",{className:"es-ts-open",id:g,children:/* @__PURE__ */I(Z,{style:e,values:C,fonts:s,colours:t,settings:k,autoSet:N,sample:r??S.sample,words:S,readOnly:y,set:s=>p(h([e],e.id,s)[0])})}):null]})}var P={none:D,upper:Y,capitalize:W,lower:$};function Z({style:e,values:s,fonts:a,colours:n,settings:i,autoSet:r,sample:o,words:c,readOnly:d,set:u}){const m=e.values,h=a.find(e=>e.value===s.font),p=function(e,s){return e?s.find(s=>s.key===e)?.value??t(e)??void 0:void 0}(s.color,n),v=e=>"largestSize"===e||r.has(e),y=e=>v(e)?m[e]:s[e],g=y("size"),b=y("lineSpacing"),k=y("letterSpacing"),C=v("letterCase")?m.letterCase:s.letterCase,T={fontFamily:h?.family,fontSize:void 0===g?void 0:`${g}px`,fontWeight:s.weight,fontStyle:s.italic?"italic":void 0,lineHeight:void 0===b?void 0:String(b/100),letterSpacing:void 0===k?void 0:`${k}px`,color:p,textTransform:f(C)},w=e=>{const t=S[e],a=v(e);/* @__PURE__ */
20
+ return I("div",{className:"es-ts-slider","data-ts-setting":e,children:/* @__PURE__ */I(l,{label:c.settings[e],value:m[e],onChange:s=>u({[e]:s}),min:t.min,max:t.max,step:t.step,shiftStep:t.shiftStep,sliderMin:t.sliderMin,sliderMax:t.sliderMax,unit:t.unit||void 0,styleValue:a?void 0:s[e],auto:a?c.auto:void 0,readOnly:d})},e)};/* @__PURE__ */
21
+ return G(M,{children:[
22
+ /* @__PURE__ */I("div",{className:"es-ts-preview",style:T,"aria-label":c.preview,children:o}),i.map(t=>{switch(t){case"font":/* @__PURE__ */
23
+ return I(q,{value:m.font,fonts:a,words:c,readOnly:d,set:u},t);case"color":/* @__PURE__ */
24
+ return I(K,{value:m.color,hex:p,colours:n,words:c,readOnly:d,set:u},t);case"emphasis":{const e=(s.weight??400)>=600,a=!1!==h?.italic;/* @__PURE__ */
25
+ return G("div",{className:"es-ts-set","data-ts-setting":t,children:[
26
+ /* @__PURE__ */I("span",{className:"es-ts-sub",children:c.settings.emphasis}),
27
+ /* @__PURE__ */G("div",{className:"es-ts-icons",children:[N(c.bold,/* @__PURE__ */I(x,{className:"es-ts-icon","aria-label":c.bold,"aria-pressed":e,disabled:d,onClick:()=>u({weight:e?400:700}),children:/* @__PURE__ */I(j,{size:16})})),d||a?N(c.italic,/* @__PURE__ */I(x,{className:"es-ts-icon","aria-label":c.italic,"aria-pressed":Boolean(s.italic),disabled:d,onClick:()=>u({italic:!s.italic||void 0}),children:/* @__PURE__ */I(X,{size:16})})):/* @__PURE__ */I(x,{className:"es-ts-icon","aria-label":c.italic,"aria-pressed":Boolean(s.italic),"aria-disabled":!0,disabledReason:c.italicMissing,children:/* @__PURE__ */I(X,{size:16})})]})]},t)}case"letterCase":/* @__PURE__ */
28
+ return I(V,{value:m.letterCase??s.letterCase,auto:v("letterCase"),words:c,readOnly:d,set:u},t);case"largestSize":return"heading"===e.kind?w(t):null;default:return w(t)}})]})}function q({value:e,fonts:s,words:t,readOnly:a,set:l}){const n=O();/* @__PURE__ */
29
+ return G("div",{className:"es-ts-set","data-ts-setting":"font",children:[
30
+ /* @__PURE__ */I("span",{className:"es-ts-sub",id:n,children:t.settings.font}),
31
+ /* @__PURE__ */I(g,{value:e,options:s.map(e=>({label:e.label,value:e.value})),onChange:e=>l({font:e}),ariaLabelledBy:n,readOnly:a})]})}function K({value:e,hex:s,colours:t,words:a,readOnly:l,set:n}){/* @__PURE__ */
32
+ return I(H,{value:e,hex:s,colours:t,label:a.settings.color,followsWord:a.colour.follows,anyWord:a.colour.any,readOnly:l,onChange:e=>n({color:e})})}function V({value:e,auto:s,words:t,readOnly:a,set:l}){const n=s?["auto",...p]:p,i=e??(s?"auto":"none"),r=E([]),o=e=>l({letterCase:"auto"===e?void 0:e});/* @__PURE__ */
33
+ return G("div",{className:"es-ts-set","data-ts-setting":"letterCase",children:[
34
+ /* @__PURE__ */I("span",{className:"es-ts-sub",children:t.settings.letterCase}),
35
+ /* @__PURE__ */I("div",{className:"es-ts-icons",role:"radiogroup","aria-label":t.settings.letterCase,onKeyDown:e=>{const s="ArrowRight"===e.key||"ArrowDown"===e.key?1:"ArrowLeft"===e.key||"ArrowUp"===e.key?-1:0;if(!s||a)return;e.preventDefault();const t=(n.indexOf(i)+s+n.length)%n.length;o(n[t]),r.current[t]?.focus()},children:n.map((e,s)=>{const l=e===i;if("auto"===e)return N(t.case.autoTitle,/* @__PURE__ */I(x,{ref:e=>{r.current[s]=e},role:"radio",pressed:l,className:"es-ts-icon es-ts-icon--word","aria-checked":l,"aria-label":t.case.auto,tabIndex:l?0:-1,disabled:a,onClick:()=>o(e),children:t.case.auto},e));const n=P[e];return N(t.case[e],/* @__PURE__ */I(x,{ref:e=>{r.current[s]=e},role:"radio",pressed:l,className:"es-ts-icon","aria-checked":l,"aria-label":t.case[e],tabIndex:l?0:-1,disabled:a,onClick:()=>o(e),children:/* @__PURE__ */I(n,{size:16})},e))})})]})}export{H as ColourSwatchRow,U as TextStyleItem,B as TextStylesGroup,R as TextStylesList};
@@ -0,0 +1,259 @@
1
+ import { T as TextStylesWords } from '../words-gIDCeRv3.js';
2
+
3
+ /**
4
+ * The text styles as data (plan step E6): what a style is, the list both
5
+ * editors start from, the design's ranges, and the pure changes the list
6
+ * makes. No React and no browser global, so P3 and S2 can use it where they
7
+ * read and write their own storage.
8
+ *
9
+ * What this does NOT know is where a host keeps its styles, or what its old
10
+ * values were called. Turning an email's "Label" into Body 5, or the website's
11
+ * "Tight" into 95 % / −0.01 em, is the host's (P3, S2). The units here are the
12
+ * panel's: px, and % for line spacing.
13
+ */
14
+
15
+ type TextStyleKind = 'heading' | 'body';
16
+ /**
17
+ * The letter cases, in the panel's order: As typed · Uppercase · Capitalized ·
18
+ * Lowercase (Lewis 2026-10-15, S4: Capitalized is kept in both editors). This
19
+ * is the ONE list of them: the text styles, the text part panel and every host
20
+ * read it, so a case cannot be offered in one place and dropped in another.
21
+ * No value on a style = Auto where the host offers it, As typed where not.
22
+ */
23
+ declare const TEXT_STYLE_CASES: readonly ["none", "upper", "capitalize", "lower"];
24
+ type TextStyleCase = (typeof TEXT_STYLE_CASES)[number];
25
+ /**
26
+ * The CSS `text-transform` each case draws. `none` is a real declaration, so a
27
+ * case can beat a built-in uppercase class. A host that stores the CSS word
28
+ * itself (the campaign designer's boxes) turns it back with
29
+ * {@link textStyleCaseOfCss}; it never keeps a table of its own.
30
+ */
31
+ declare const TEXT_STYLE_CASE_CSS: {
32
+ readonly none: "none";
33
+ readonly upper: "uppercase";
34
+ readonly capitalize: "capitalize";
35
+ readonly lower: "lowercase";
36
+ };
37
+ type TextStyleCaseCss = (typeof TEXT_STYLE_CASE_CSS)[TextStyleCase];
38
+ /** True for one of the four cases, and for nothing else a document may hold. */
39
+ declare function isTextStyleCase(value: unknown): value is TextStyleCase;
40
+ /** The `text-transform` a case draws, or `undefined` for no case (or a word
41
+ * that is not one of the four). */
42
+ declare function textStyleCaseCss(value: unknown): TextStyleCaseCss | undefined;
43
+ /** The case a `text-transform` word is, or `undefined` for anything else
44
+ * (`full-width`, an empty string, junk). */
45
+ declare function textStyleCaseOfCss(css: unknown): TextStyleCase | undefined;
46
+ /**
47
+ * One style's own settings. A missing key has nothing of its own: it is Auto
48
+ * where the host offers Auto for that setting, and otherwise shows the host's
49
+ * `fallback`, grey.
50
+ */
51
+ interface TextStyleValues {
52
+ /** A font's `value`, from the host's list. */
53
+ font?: string;
54
+ /** A theme colour's `key`, or a `#rrggbb`. */
55
+ color?: string;
56
+ /** px. */
57
+ size?: number;
58
+ /** 100–900. */
59
+ weight?: number;
60
+ italic?: boolean;
61
+ /** % of the font size; below 100 is tighter than the type. */
62
+ lineSpacing?: number;
63
+ /** px; may be negative. */
64
+ letterSpacing?: number;
65
+ /** px. */
66
+ paragraphSpacing?: number;
67
+ letterCase?: TextStyleCase;
68
+ /** px; headings only — the largest a heading is drawn anywhere on the site. */
69
+ largestSize?: number;
70
+ }
71
+ interface TextStyle {
72
+ /** The host's, stable: the list never renames an id. */
73
+ id: string;
74
+ kind: TextStyleKind;
75
+ /** Stored, so the host's words: "Heading 1", "Body 5". */
76
+ name: string;
77
+ values: TextStyleValues;
78
+ }
79
+ /** A font the host offers. */
80
+ interface TextStyleFont {
81
+ value: string;
82
+ label: string;
83
+ /** The CSS `font-family` the list draws the name and the preview in. */
84
+ family: string;
85
+ /** `false` when this font has no italic loaded: the Italic button is off. */
86
+ italic?: boolean;
87
+ }
88
+ /** A theme colour the host offers, stored by its key. */
89
+ interface TextStyleColour {
90
+ key: string;
91
+ name: string;
92
+ /** `#rrggbb`. */
93
+ value: string;
94
+ }
95
+ /** Every setting an open style can show, in the order it shows them. */
96
+ declare const TEXT_STYLE_SETTINGS: readonly ["font", "color", "size", "weight", "emphasis", "lineSpacing", "letterSpacing", "paragraphSpacing", "letterCase", "largestSize"];
97
+ type TextStyleSetting = (typeof TEXT_STYLE_SETTINGS)[number];
98
+ /** The settings an Email styles list shows — the campaign design page. */
99
+ declare const CAMPAIGN_TEXT_STYLE_SETTINGS: readonly TextStyleSetting[];
100
+ /** The settings that may be Auto, when the host says so (Site styles). */
101
+ type TextStyleAuto = 'size' | 'lineSpacing' | 'letterSpacing' | 'letterCase';
102
+ /** The kinds, in the order the list draws them. */
103
+ declare const TEXT_STYLE_KINDS: readonly TextStyleKind[];
104
+ /** At most this many of EACH kind (Lewis, 2026-10-02). */
105
+ declare const TEXT_STYLE_MAX = 7;
106
+ /** How many of each the list starts with: Heading 1–3, Body 1–5. */
107
+ declare const TEXT_STYLE_DEFAULT_COUNT: Readonly<Record<TextStyleKind, number>>;
108
+ /** A number setting's slider: its travel, the typed limits, the steps and the unit. */
109
+ interface TextStyleRange {
110
+ /** The lowest a typed value may be; `undefined` = no limit. */
111
+ min: number | undefined;
112
+ /** The highest a typed value may be; `undefined` = no limit. */
113
+ max: number | undefined;
114
+ sliderMin: number;
115
+ sliderMax: number;
116
+ step: number;
117
+ shiftStep: number;
118
+ unit: string;
119
+ }
120
+ /**
121
+ * The design's numbers (campaign page, "the three boxes' rules" and the slider
122
+ * ranges; website page §5). A typed value may go past the slider; only `min`
123
+ * and `max` hold it. Line spacing down to 50 % and letter spacing down to
124
+ * −10 px are Lewis's (2026-10-06).
125
+ */
126
+ declare const TEXT_STYLE_RANGES: {
127
+ readonly size: TextStyleRange;
128
+ readonly weight: {
129
+ readonly min: 100;
130
+ readonly max: 900;
131
+ readonly sliderMin: 300;
132
+ readonly sliderMax: 900;
133
+ readonly step: 100;
134
+ readonly shiftStep: 100;
135
+ readonly unit: "";
136
+ };
137
+ readonly lineSpacing: {
138
+ readonly min: 50;
139
+ readonly max: 250;
140
+ readonly sliderMin: 50;
141
+ readonly sliderMax: 250;
142
+ readonly step: 1;
143
+ readonly shiftStep: 10;
144
+ readonly unit: "%";
145
+ };
146
+ readonly letterSpacing: {
147
+ readonly min: -10;
148
+ readonly max: undefined;
149
+ readonly sliderMin: -5;
150
+ readonly sliderMax: 10;
151
+ readonly step: 0.1;
152
+ readonly shiftStep: 1;
153
+ readonly unit: "px";
154
+ };
155
+ readonly paragraphSpacing: {
156
+ readonly min: 0;
157
+ readonly max: undefined;
158
+ readonly sliderMin: 0;
159
+ readonly sliderMax: 48;
160
+ readonly step: 1;
161
+ readonly shiftStep: 10;
162
+ readonly unit: "px";
163
+ };
164
+ readonly largestSize: TextStyleRange;
165
+ };
166
+ type TextStyleNumber = keyof typeof TEXT_STYLE_RANGES;
167
+ /** Heading 1–3 then Body 1–5, ids `heading-1` … `body-5`, no values: the host fills them. */
168
+ declare function defaultTextStyles(name?: (v: {
169
+ kind: TextStyleKind;
170
+ n: number;
171
+ }) => string): TextStyle[];
172
+ /** Whether another style of this kind fits under the cap. */
173
+ declare function canAddTextStyle(styles: readonly TextStyle[], kind: TextStyleKind, max?: number): boolean;
174
+ /**
175
+ * Whether a style is one the list starts with (Heading 1–3, Body 1–5), which
176
+ * can never be deleted. Decided by the fixed id (`heading-1` … `body-5`),
177
+ * never by the name: a host's words name the styles.
178
+ */
179
+ declare function isDefaultTextStyle(style: TextStyle): boolean;
180
+ /**
181
+ * A new style of `kind`, after the last one of that kind: a copy of that
182
+ * one's values, named the next free number ("Heading 4"). `null` at the cap.
183
+ * The list given is not changed.
184
+ *
185
+ * The name and the id are chosen apart. The name is the next number after
186
+ * the styles of its kind, skipping a name already taken, so after a delete
187
+ * the names have no gap. The id is above every id of its kind
188
+ * (`heading-7` when `heading-6` is there), and the name's number when that
189
+ * is higher. So an id freed by a delete is used again only when it was the
190
+ * highest of its kind, and then the new style is a copy of the one that
191
+ * id's text was already drawn as (`resolveTextStyle`): nothing on the page
192
+ * jumps.
193
+ *
194
+ * `make` lets a host build the new style itself (its own ids); it gets the
195
+ * kind and the number the new style is called.
196
+ */
197
+ declare function addTextStyle(styles: readonly TextStyle[], kind: TextStyleKind, options?: {
198
+ max?: number;
199
+ name?: (v: {
200
+ kind: TextStyleKind;
201
+ n: number;
202
+ }) => string;
203
+ make?: (kind: TextStyleKind, n: number) => TextStyle;
204
+ }): {
205
+ styles: TextStyle[];
206
+ added: TextStyle;
207
+ } | null;
208
+ /**
209
+ * The list without one ADDED style. `null` for a default (they are never
210
+ * deleted) or an id not in the list. The list given is not changed.
211
+ *
212
+ * The styles of its kind after it close the gap by NAME — "Heading 5" becomes
213
+ * "Heading 4" — when their name is still the number of their place. Their
214
+ * ids never change, so text on them stays on them. Text on the deleted one
215
+ * is not rewritten: `resolveTextStyle` draws it as the nearest earlier style
216
+ * of its kind.
217
+ *
218
+ * `name` is the host's words for a style's name, as `addTextStyle` takes it.
219
+ */
220
+ declare function removeTextStyle(styles: readonly TextStyle[], id: string, options?: {
221
+ name?: (v: {
222
+ kind: TextStyleKind;
223
+ n: number;
224
+ }) => string;
225
+ }): {
226
+ styles: TextStyle[];
227
+ removed: TextStyle;
228
+ } | null;
229
+ /**
230
+ * The style text on `id` draws as: that style, or — when it was deleted —
231
+ * the nearest EARLIER style of its kind still in the list (`heading-5` gone:
232
+ * Heading 4's id, else `heading-3`). The defaults are never deleted, so an
233
+ * id the model made always finds one. `undefined` for an id the model did
234
+ * not make (a host's own, through `make`): that host resolves its own.
235
+ *
236
+ * Read every stored style id through this, so a deleted style's text keeps
237
+ * drawing — in a saved page and in a sent email alike — and nothing stored
238
+ * is rewritten.
239
+ */
240
+ declare function resolveTextStyle(styles: readonly TextStyle[], id: string): TextStyle | undefined;
241
+ /**
242
+ * The list with one style's values changed. A key given as `undefined` is
243
+ * removed: the setting has nothing of its own again. Nothing is changed in
244
+ * place, and the other styles are the same objects.
245
+ */
246
+ declare function updateTextStyle(styles: readonly TextStyle[], id: string, patch: Partial<TextStyleValues>): TextStyle[];
247
+ /** The size a style's NAME is drawn at in the list: half its size plus 6, kept within 12–20 px. */
248
+ declare function textStyleRowSize(px: number): number;
249
+ /** A weight's name, by the hundred it is nearest. */
250
+ declare function weightWord(weight: number, words: TextStylesWords): string;
251
+ /**
252
+ * A row's grey line, "Playfair Display · 28 px · Semibold". `autoSize`: a
253
+ * size with no number reads the Auto word. A weight with none is Regular.
254
+ */
255
+ declare function describeTextStyle(values: TextStyleValues, fonts: readonly TextStyleFont[], words: TextStylesWords, options?: {
256
+ autoSize?: boolean;
257
+ }): string;
258
+
259
+ export { CAMPAIGN_TEXT_STYLE_SETTINGS, TEXT_STYLE_CASES, TEXT_STYLE_CASE_CSS, TEXT_STYLE_DEFAULT_COUNT, TEXT_STYLE_KINDS, TEXT_STYLE_MAX, TEXT_STYLE_RANGES, TEXT_STYLE_SETTINGS, type TextStyle, type TextStyleAuto, type TextStyleCase, type TextStyleCaseCss, type TextStyleColour, type TextStyleFont, type TextStyleKind, type TextStyleNumber, type TextStyleRange, type TextStyleSetting, type TextStyleValues, addTextStyle, canAddTextStyle, defaultTextStyles, describeTextStyle, isDefaultTextStyle, isTextStyleCase, removeTextStyle, resolveTextStyle, textStyleCaseCss, textStyleCaseOfCss, textStyleRowSize, updateTextStyle, weightWord };
@@ -0,0 +1 @@
1
+ export{CAMPAIGN_TEXT_STYLE_SETTINGS,TEXT_STYLE_CASES,TEXT_STYLE_CASE_CSS,TEXT_STYLE_DEFAULT_COUNT,TEXT_STYLE_KINDS,TEXT_STYLE_MAX,TEXT_STYLE_RANGES,TEXT_STYLE_SETTINGS,addTextStyle,canAddTextStyle,defaultTextStyles,describeTextStyle,isDefaultTextStyle,isTextStyleCase,removeTextStyle,resolveTextStyle,textStyleCaseCss,textStyleCaseOfCss,textStyleRowSize,updateTextStyle,weightWord}from"../chunk-YHZSBL2N.js";
@@ -37,7 +37,7 @@
37
37
 
38
38
  .es-ts-group {
39
39
  margin: 0 0 var(--es-space-4, 4px);
40
- font-size: 11px;
40
+ font-size: var(--text-2xs, 11px);
41
41
  font-weight: 600;
42
42
  letter-spacing: 0.06em;
43
43
  text-transform: uppercase;
@@ -151,7 +151,7 @@
151
151
  overflow: hidden;
152
152
  text-overflow: ellipsis;
153
153
  white-space: nowrap;
154
- font-size: 12px;
154
+ font-size: var(--text-xs, 12px);
155
155
  line-height: 1.4;
156
156
  color: var(--es-muted, var(--ink-faint));
157
157
  }
@@ -196,7 +196,7 @@
196
196
  overflow: hidden;
197
197
  text-overflow: ellipsis;
198
198
  white-space: nowrap;
199
- font-size: 12px;
199
+ font-size: var(--text-xs, 12px);
200
200
  font-weight: 500;
201
201
  color: var(--es-text-secondary, var(--ink));
202
202
  }
@@ -240,7 +240,7 @@
240
240
  .es-ts-icon--word {
241
241
  width: auto;
242
242
  padding: 0 var(--es-space-8, 8px);
243
- font-size: 14px;
243
+ font-size: var(--text-sm, 14px);
244
244
  font-weight: 500;
245
245
  }
246
246
 
@@ -262,7 +262,7 @@
262
262
  justify-content: space-between;
263
263
  gap: var(--es-space-8, 8px);
264
264
  padding: var(--es-space-12, 12px) 0 0;
265
- font-size: 14px;
265
+ font-size: var(--text-sm, 14px);
266
266
  font-weight: 500;
267
267
  color: var(--es-accent, var(--accent-600, var(--submit-bg)));
268
268
  cursor: pointer;
@@ -271,7 +271,7 @@
271
271
  .es-ts-add:disabled,
272
272
  .es-ts-add[aria-disabled='true'] { color: var(--es-disabled, var(--ink-faintest)); cursor: not-allowed; }
273
273
  .es-ts-count {
274
- font-size: 12px;
274
+ font-size: var(--text-xs, 12px);
275
275
  font-weight: 400;
276
276
  color: var(--es-field-placeholder, var(--ink-faintest));
277
277
  }
@@ -1,4 +1,4 @@
1
- import { MarkStyle, MarkPlaceholders } from './markup/index.js';
1
+ import { MarkStyle, MarkPlaceholders } from 'efficient-shell/markup';
2
2
  import { ReactNode } from 'react';
3
3
 
4
4
  /**
@@ -100,7 +100,7 @@ declare function copyAlignOptions(allow: readonly CopyAlign[], labels?: Record<C
100
100
  * catalogue's (`ShellStringsProvider`, `link`).
101
101
  *
102
102
  * NO REACT here, and no import but the grammar: the marks' names, tooltips and
103
- * placeholders are READ from `efficient-easel/markup` (`MARKUP_TOOLS`,
103
+ * placeholders are READ from `efficient-shell/markup` (`MARKUP_TOOLS`,
104
104
  * `MARK_PLACEHOLDERS`) rather than typed a second time, so the English lives
105
105
  * once, in the grammar, where the campaign designer's own toolbar reads it too.
106
106
  */
@@ -117,6 +117,10 @@ type CopyWords = {
117
117
  * `name` is what the button is called; `title` its tooltip, which also says
118
118
  * what the mark writes and its shortcut. A host's own descriptors
119
119
  * (`MarkupTool[]`) are used as given and never read these.
120
+ *
121
+ * @deprecated Read by nothing since the copy box's one bar became the shell's
122
+ * `TextToolbar`, which names its buttons in the shell catalogue
123
+ * (`ShellStringsProvider`, `textToolbar`). Removed in 12.0.0.
120
124
  */
121
125
  marks: Record<MarkStyle, {
122
126
  name: string;
@@ -128,11 +132,13 @@ type CopyWords = {
128
132
  * (E5a). Optional, so a host's words from before still type; English when
129
133
  * left out. */
130
134
  showMarks?: string;
131
- /** Clear changes (was "Clear style"; one text panel v3, 2026-10-15: one
132
- * word, the same one the Style list says), on the line under the box (owner
133
- * ruling 2026-10-07), and its tooltip while nothing is selected. Optional, so a host's words from
134
- * before still type; English when left out. */
135
+ /** "Clear changes": the Style list's item in the one text panel
136
+ * (`TextPartPanel`). It was also a button on the line under the box until
137
+ * Lewis took that out (2026-10-19). Optional, so a host's words from before
138
+ * still type; English when left out. */
135
139
  clearStyle?: string;
140
+ /** @deprecated The tooltip of the button under the box, which is gone
141
+ * (2026-10-19). Read by nothing; removed in 12.0.0. */
136
142
  clearStyleEmpty?: string;
137
143
  /** The colour window: its name, the theme row's label, and Remove. */
138
144
  colors?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efficient-easel",
3
- "version": "11.2.0",
3
+ "version": "11.8.0",
4
4
  "description": "Efficient Easel: the EFFICIENT editors' shared engine and chrome: the saved document as pure functions, the published renderer, and the editor frame, panels, Layers tree, text grammar and type-in-place box. Published as editor-shell up to 0.66.0 and as efficient-editor up to 0.95.0.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Efficient Pty Ltd",
@@ -102,6 +102,11 @@
102
102
  "import": "./dist/text-styles/index.js",
103
103
  "default": "./dist/text-styles/index.js"
104
104
  },
105
+ "./text-styles/model": {
106
+ "types": "./dist/text-styles/model.d.ts",
107
+ "import": "./dist/text-styles/model.js",
108
+ "default": "./dist/text-styles/model.js"
109
+ },
105
110
  "./text-styles.css": "./dist/text-styles/text-styles.css",
106
111
  "./easel": {
107
112
  "types": "./dist/easel/index.d.ts",
@@ -1 +0,0 @@
1
- var e={bold:{open:"**",close:"**",placeholder:"bold text"},italic:{open:"_",close:"_",placeholder:"italic text"},strike:{open:"~~",close:"~~",placeholder:"struck out"},code:{open:"`",close:"`",placeholder:"code"},highlight:{open:"==",close:"==",placeholder:"highlighted text"},quiet:{open:"^^",close:"^^",placeholder:"quiet text"},underline:{open:"[",close:"]{underline}",placeholder:"underlined text"},sup:{open:"[",close:"]{sup}",placeholder:"superscript"},sub:{open:"[",close:"]{sub}",placeholder:"subscript"}};function t(e){return/^[a-z][a-z0-9-]*$/.test(e)}function n(e){return t(e)||/^#[0-9a-fA-F]{6}$/.test(e)}function l(e){return n(e)?e.startsWith("#")?e.toLowerCase():e:null}function r(e,t){const n=/^\{(underline|sup|sub|color=([a-z][a-z0-9-]*|#[0-9a-fA-F]{6}))\}/.exec(e.slice(t,t+64));return n?void 0===n[2]?{kind:n[1],length:n[0].length}:{kind:"color",color:n[2],length:n[0].length}:null}var s={bold:e.bold.placeholder,italic:e.italic.placeholder,strike:e.strike.placeholder,code:e.code.placeholder,highlight:e.highlight.placeholder,quiet:e.quiet.placeholder,link:"link text",underline:e.underline.placeholder,sup:e.sup.placeholder,sub:e.sub.placeholder,color:"colored text"},i={bullet:()=>"- ",number:e=>`${e+1}. `,quote:()=>"> "};function o(t,n,l,r,o=k,c=s){if("clear"===r)return N(t,n,l,o);const u=t.slice(n,l);if("link"===r){const e=u||c.link,r=`[${e}](https://)`;return{text:t.slice(0,n)+r+t.slice(l),selectionStart:n+e.length+3,selectionEnd:n+r.length-1}}const h=i[r];if(h){const e=t.lastIndexOf("\n",Math.max(n-1,0))+1,r=t.indexOf("\n",l),s=-1===r?t.length:r,i=t.slice(e,s).split("\n"),o=i.every((e,t)=>e.startsWith(h(t))),c=i.map((e,t)=>o?e.slice(h(t).length):h(t)+e).join("\n");return{text:t.slice(0,e)+c+t.slice(s),selectionStart:e,selectionEnd:e+c.length}}const{open:f,close:d}=e[r],m=r,p=c[m]??s[m];if(a(t,n,l,r))return{text:t.slice(0,n-f.length)+u+t.slice(l+d.length),selectionStart:n-f.length,selectionEnd:n-f.length+u.length};const b=u||p;return{text:t.slice(0,n)+f+b+d+t.slice(l),selectionStart:n+f.length,selectionEnd:n+f.length+b.length}}function c(e,t,n,i,o=s){const c={text:e,selectionStart:t,selectionEnd:n};if(null!==i){const e=l(i);if(null===e)return c;i=e}const a=e.slice(t,n),u=t>=1&&"["===e[t-1]&&"]"===e[n]?r(e,n+1):null;if("color"===u?.kind){const l=t-1,r=e.slice(n+1+u.length);return null===i?{text:e.slice(0,l)+a+r,selectionStart:l,selectionEnd:l+a.length}:{text:`${e.slice(0,n)}]{color=${i}}${r}`,selectionStart:t,selectionEnd:n}}if(null===i)return c;const h=a||(o.color??s.color);return{text:`${e.slice(0,t)}[${h}]{color=${i}}${e.slice(n)}`,selectionStart:t+1,selectionEnd:t+1+h.length}}function a(t,n,l,r){const s=e[r];if(!s)return!1;const{open:i,close:o}=s;return n>=i.length&&t.slice(n-i.length,n)===i&&t.slice(l,l+o.length)===o}function u(e,t,n){const l=0===t?0:e.lastIndexOf("\n",t-1)+1;for(let r=e.lastIndexOf("[",t);r>=l;r=0===r?-1:e.lastIndexOf("[",r-1)){const t=B(e,r);if(t&&n<=t.end)return{start:r,end:t.end,label:t.label,href:t.href}}return null}function h(e,t,n,l){const r=u(e,t,n),s=r?r.start:t,i=r?r.end:n,o=`[${r?r.label:e.slice(t,n)||l}](${l})`,c=s+o.length;return{text:e.slice(0,s)+o+e.slice(i),selectionStart:c,selectionEnd:c}}function f(e,t){return{text:e.slice(0,t.start)+t.label+e.slice(t.end),selectionStart:t.start,selectionEnd:t.start+t.label.length}}var d=[{style:"bold",label:"B",name:"Strong",title:"Strong · **words** · ⌘B",shortcut:"b"},{style:"italic",label:"I",name:"Italic",title:"Italic · _words_ · ⌘I",shortcut:"i"},{style:"strike",label:"S",name:"Strikethrough",title:"Strikethrough · ~~words~~"},{style:"highlight",label:"◆",name:"Emphasis",title:"Emphasis · ==words=="},{style:"quiet",label:"a",name:"Quiet",title:"Quiet · ^^words^^"},{style:"code",label:"‹›",name:"Code",title:"Code"},{style:"link",label:"🔗",name:"Link",title:"Link · [words](https://…) · ⌘K",shortcut:"k"},{style:"bullet",label:"•",name:"Bulleted list",title:"Bulleted list"},{style:"number",label:"1.",name:"Numbered list",title:"Numbered list"},{style:"quote",label:"❝",name:"Quote",title:"Quote"},{style:"clear",label:"T×",name:"Clear marks",title:"Clear marks · ⌘⇧X",shortcut:"shift+x"}],m={bold:"Strong",highlight:"Emphasis",quiet:"Quiet"};function p(e){return d.filter(t=>e.includes(t.style))}var k=[{open:"**",close:"**",kind:"bold"},{open:"==",close:"==",kind:"highlight"},{open:"~~",close:"~~",kind:"strike"},{open:"_",close:"_",kind:"italic",wordBoundary:!0},{open:"^^",close:"^^",kind:"quiet"},{open:"@@",close:"@@",kind:"highlight"},{open:"++",close:"++",kind:"bold"}],b=["highlight","quiet"],g=d.map(e=>e.style).filter(e=>k.some(t=>t.kind===e)).filter(e=>!b.includes(e)),x=[...k,{open:"*",close:"*",kind:"accent"}],S=[...k,{open:"*",close:"*",kind:"accent"},{open:"#",close:"#",kind:"bold",notBefore:"0123456789"},{open:"[",close:"]",kind:"italic",notBefore:"(",notBeforeBlock:!0}];function v(e){return!/\s/.test(e)&&!/[!-\/:-@[-`{-~]/.test(e)}function w(e,t){const n=[];let l="",r=0;for(;r<e.length;){const s=E(e,r,t);s?(n.push({kind:"text",text:l}),l="",n.push({kind:s.rule.kind,text:s.inner}),r=s.end):(l+=e[r],r+=1)}return n.push({kind:"text",text:l}),n}function E(e,t,n){for(const l of n){if(!e.startsWith(l.open,t))continue;if(l.wordBoundary&&t>0&&v(e[t-1]))continue;const n=t+l.open.length,s=e.indexOf(l.close,n);if(s<n+1)continue;const i=e.slice(n,s);if(i.includes(l.close[0]))continue;if(i.includes("\n"))continue;const o=s+l.close.length,c=e[o];if((!l.notBefore||void 0===c||!l.notBefore.includes(c))&&!(l.notBeforeBlock&&r(e,o)||l.wordBoundary&&void 0!==c&&v(c)))return{rule:l,inner:i,end:o}}return null}function y(e,t){return w(e,t).map(e=>e.text).join("")}var M=["http","https","mailto","tel"];function $(e){if(""===e||/[\s\u0000-\u001f\u007f]/.test(e))return!1;const t=/^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(e);return!t||M.includes(t[1].toLowerCase())}function B(e,t){if("["!==e[t])return null;const n=e.indexOf("]",t+1);if(n<t+2||"("!==e[n+1])return null;const l=e.slice(t+1,n);if(l.includes("["))return null;const r=e.indexOf(")",n+2);if(-1===r)return null;const s=e.slice(n+2,r);return $(s)?{label:l,href:s,end:r+1}:null}function z(e,t){if("["!==e[t])return null;let n=0;for(let l=t;l<e.length;l+=1){const s=e[l];if("\n"===s)return null;if("["===s)n+=1;else if("]"===s){if(n-=1,n>0)continue;if(l===t+1)return null;const s=r(e,l+1);return s?{kind:s.kind,color:s.color,label:e.slice(t+1,l),close:e.slice(l,l+1+s.length),end:l+1+s.length}:null}}return null}var q=4;function I(e,t,n){const l=[];let r="";const s=()=>{r&&l.push({kind:"text",text:r}),r=""},i=e=>n+1<q?I(e,t,n+1):[{kind:"text",text:e}];let o=0;for(;o<e.length;){const n=B(e,o);if(n){s(),l.push({kind:"link",href:n.href,children:i(n.label)}),o=n.end;continue}const c=z(e,o);if(c){s(),l.push({kind:c.kind,open:"[",close:c.close,...void 0===c.color?{}:{color:c.color},children:i(c.label)}),o=c.end;continue}const a=E(e,o,t);a?(s(),l.push({kind:a.rule.kind,open:a.rule.open,close:a.rule.close,children:i(a.inner)}),o=a.end):(r+=e[o],o+=1)}return s(),l}function O(e,t){return e.split("\n").map(e=>{const{bullet:n,number:l,rest:r}=function(e){if(e.startsWith("- ")&&""!==e.slice(2).trim())return{bullet:!0,number:null,rest:e.slice(2)};const t=/^([0-9]{1,3})\. /.exec(e);return t&&""!==e.slice(t[0].length).trim()?{bullet:!1,number:t[1],rest:e.slice(t[0].length)}:{bullet:!1,number:null,rest:e}}(e);return{bullet:n,number:l,children:I(r,t,0)}})}function C(e){return null!=e.number?`${e.number}. `:e.bullet?"- ":""}function _(e){return e.map(e=>"text"===e.kind?e.text:"link"===e.kind?`[${_(e.children)}](${e.href})`:e.open+_(e.children)+e.close).join("")}function j(e){return e.map(e=>C(e)+_(e.children)).join("\n")}function Q(t,n,r){if("link"===n)return void 0===r?null:{id:t,kind:"link",open:"[",close:`](${r})`,href:r};if("color"===n){const e=void 0===r?null:l(r);return null===e?null:{id:t,kind:"color",open:"[",close:`]{color=${e}}`,color:e}}const s=e[n];return s&&"code"!==n?{id:t,kind:n,open:s.open,close:s.close}:null}function A(e,t){let n=0,l=0;return e.split("\n").map(e=>{const[r]=O(e,t);let s=l+C(r).length;l+=e.length+1;const i=[],o=(e,t)=>{for(const l of e){if("text"===l.kind){for(const e of l.text)i.push({ch:e,marks:t,at:s}),s+=e.length;continue}const e="link"===l.kind?Q(++n,"link",l.href):{id:++n,kind:l.kind,open:l.open,close:l.close,...void 0===l.color?{}:{color:l.color}};s+=e.open.length,o(l.children,[...t,e]),s+=e.close.length}};return o(r.children,[]),{bullet:r.bullet,number:r.number??null,chars:i}})}function L(e){let t="";const n=[];return e.forEach((e,l)=>{l>0&&(t+="\n"),t+=C(e);const r=[],s=[];for(const n of e.chars){let e=0;for(;e<r.length&&e<n.marks.length&&r[e].id===n.marks[e].id;)e+=1;for(;r.length>e;)t+=r.pop().close;for(let l=e;l<n.marks.length;l+=1)t+=n.marks[l].open,r.push(n.marks[l]);s.push(t.length),t+=n.ch}for(;r.length>0;)t+=r.pop().close;n.push(s)}),{text:t,at:n}}function W(e,t){return e.length===t.length&&e.every((e,n)=>{const l=t[n];return e.bullet===l.bullet&&(e.number??null)===(l.number??null)&&(e.chars.length===l.chars.length&&e.chars.every((e,t)=>{const n=l.chars[t];return e.ch===n.ch&&e.marks.length===n.marks.length&&e.marks.every((e,t)=>e.kind===n.marks[t].kind&&e.href===n.marks[t].href&&e.color===n.marks[t].color)}))})}function N(e,t,n,l=k){const r=A(e,l),s=r.flatMap(e=>e.chars),i={text:e,selectionStart:t,selectionEnd:n},o=e=>r.map(t=>({bullet:t.bullet,number:t.number,chars:t.chars.map(t=>({...t,marks:t.marks.filter(n=>"link"===n.kind||!e(t,n))}))})),c=e=>{const t=L(e);return W(e,A(t.text,l))?t:null},a=(e,t)=>{let n=s.indexOf(t);for(let t=0;t<e.at.length;t+=1){if(n<e.at[t].length)return e.at[t][n];n-=e.at[t].length}return 0};if(t===n){const e=[...s].reverse().find(e=>e.at<t),n=s.find(e=>e.at>=t),l=new Set([...e?.marks??[],...n?.marks??[]].map(e=>e.id));if(![...l].some(e=>s.some(t=>t.marks.some(t=>t.id===e&&"link"!==t.kind))))return i;const r=c(o((e,t)=>l.has(t.id)));if(!r)return i;const u=n?a(r,n):e?a(r,e)+e.ch.length:0;return{text:r.text,selectionStart:u,selectionEnd:u}}const u=new Set(s.filter(e=>e.at>=t&&e.at<n));if(0===u.size)return i;const h=new Set([...u].flatMap(e=>e.marks.map(e=>e.id))),f=c(T(o(e=>u.has(e)),h))??c(o((e,t)=>h.has(t.id)));if(!f)return i;const d=s.find(e=>u.has(e)),m=[...s].reverse().find(e=>u.has(e));return{text:f.text,selectionStart:a(f,d),selectionEnd:a(f,m)+m.ch.length}}function F(e,t,n,l=k){if(t===n)return{text:e,selectionStart:t,selectionEnd:n};const r=A(e,l),s=r.flatMap(e=>e.chars),i=new Set(s.filter(e=>e.at>=t&&e.at<n)),o=e=>"link"!==e.kind,c=new Set([...i].flatMap(e=>e.marks.filter(o).map(e=>e.id)));if(0===c.size)return{text:e,selectionStart:t,selectionEnd:n};const a=e=>r.map(t=>({bullet:t.bullet,number:t.number,chars:t.chars.map(t=>({...t,marks:e(t)}))})),u=a(e=>i.has(e)?e.marks.filter(e=>!o(e)):e.marks);u.forEach((e,t)=>{const n=e.chars,l=r[t].chars.map(e=>i.has(e)),s=e=>{n[e].marks=n[e].marks.filter(e=>!c.has(e.id))};n.forEach((e,t)=>{if(l[t]){if(0===t||!l[t-1])for(let e=t-1;e>=0&&/\s/.test(n[e].ch);e-=1)s(e);if(t===n.length-1||!l[t+1])for(let e=t+1;e<n.length&&/\s/.test(n[e].ch);e+=1)s(e)}})});const h=K(u,l)??K(a(e=>e.marks.filter(e=>!c.has(e.id))),l);return G(e,s,i,h,t,n)}function Z(e){return e.at.flat()}function K(e,t){const n=L(e);return W(e,A(n.text,t))?n:null}function T(e,t){return e.map(e=>{const n=e.chars.map(e=>({...e}));for(const e of t){const t=t=>t.marks.some(t=>t.id===e),l=n.flatMap((e,n)=>t(e)?[n]:[]),r=t=>{n[t].marks=n[t].marks.filter(t=>t.id!==e)};for(let e=0;e<l.length&&/\s/.test(n[l[e]].ch);e+=1)r(l[e]);for(let e=l.length-1;e>=0&&/\s/.test(n[l[e]].ch)&&t(n[l[e]]);e-=1)r(l[e])}return{bullet:e.bullet,number:e.number,chars:n}})}function X(e,t){return t.kind===e||"highlight"===e&&"accent"===t.kind}function D(e,t,n){const l=e.findIndex(e=>n(e.id));return-1===l?[...e,t]:[...e.slice(0,l),t,...e.slice(l)]}function G(e,t,n,l,r,s){if(!l)return{text:e,selectionStart:r,selectionEnd:s};const i=Z(l),o=t.flatMap((e,t)=>n.has(e)?[t]:[]),c=o[0],a=o[o.length-1];return{text:l.text,selectionStart:i[c],selectionEnd:i[a]+t[a].ch.length}}function H(e,t,n,l,r=k){if(t===n||!Q(0,l))return o(e,t,n,l,r);const s=A(e,r),i=s.flatMap(e=>e.chars),c=new Set(i.filter(e=>e.at>=t&&e.at<n));if(0===c.size)return{text:e,selectionStart:t,selectionEnd:n};const a=e=>s.map(t=>({bullet:t.bullet,number:t.number,chars:t.chars.map(t=>({...t,marks:e(t)}))}));if([...c].every(e=>e.marks.some(e=>X(l,e)))){const s=new Set([...c].flatMap(e=>e.marks.filter(e=>X(l,e)).map(e=>e.id))),o=K(T(a(e=>c.has(e)?e.marks.filter(e=>!X(l,e)):e.marks),s),r)??K(a(e=>e.marks.filter(e=>!s.has(e.id))),r);return G(e,i,c,o,t,n)}const u=new Set([...c].flatMap(e=>e.marks.filter(e=>X(l,e)).map(e=>e.id))),h=new Set(i.filter(e=>c.has(e)||e.marks.some(e=>u.has(e.id)))),f=Math.max(0,...i.flatMap(e=>e.marks.map(e=>e.id)))+1,d=Q(f,l),m=e=>i.every(t=>!t.marks.some(t=>t.id===e)||h.has(t)),p=K(T(a(e=>h.has(e)?D(e.marks.filter(e=>!X(l,e)),d,m):e.marks),/* @__PURE__ */new Set([f])),r);return G(e,i,c,p,t,n)}function J(e,t,n,l=k){const r=A(e,l).flatMap(e=>e.chars);let s;if(t===n){const n=[...r].reverse().find(n=>n.at<t&&!e.slice(n.at,t).includes("\n"));s=n?[n]:[]}else s=r.filter(e=>e.at>=t&&e.at<n);if(0===s.length)/* @__PURE__ */return new Set;const i=s.map(e=>new Set(e.marks.map(e=>e.kind)));return new Set([...i[0]].filter(e=>i.every(t=>t.has(e))))}function P(e,t,n){const l=t===n?[[...e].reverse().find(e=>e.at<t),e.find(e=>e.at>=t)]:e.filter(e=>e.at>=t&&e.at<n);for(const e of l){const t=e?.marks.find(e=>"link"===e.kind);if(t)return t.id}return null}function R(e,t,n,l,r=k){const s=A(e,r),i=s.flatMap(e=>e.chars),o=e=>s.map(t=>({bullet:t.bullet,number:t.number,chars:t.chars.map(t=>({...t,marks:e(t)}))})),c=(e,t,n)=>{const l=Z(e),r=i.reduce((e,n,l)=>t(n)?l:e,-1),s=l[r]+i[r].ch.length+n.close.length;return{text:e.text,selectionStart:s,selectionEnd:s}};if(t===n){const s=P(i,t,n);if(null===s)return h(e,t,n,l);const a=Q(s,"link",l),u=K(o(e=>e.marks.map(e=>e.id===s?a:e)),r);return u?c(u,e=>e.marks.some(e=>e.id===s),a):{text:e,selectionStart:t,selectionEnd:n}}const a=new Set(i.filter(e=>e.at>=t&&e.at<n));if(0===a.size)return h(e,t,n,l);const u=Q(Math.max(0,...i.flatMap(e=>e.marks.map(e=>e.id)))+1,"link",l),f=e=>i.every(t=>!t.marks.some(t=>t.id===e)||a.has(t)),d=K(o(e=>a.has(e)?D(e.marks.filter(e=>"link"!==e.kind),u,f):e.marks),r);return d?c(d,e=>a.has(e),u):{text:e,selectionStart:t,selectionEnd:n}}function U(e,t,n,l=k){const r=A(e,l),s=r.flatMap(e=>e.chars),i=P(s,t,n);if(null===i)return{text:e,selectionStart:t,selectionEnd:n};const o=new Set(s.filter(e=>e.marks.some(e=>e.id===i)));return G(e,s,o,K(r.map(e=>({bullet:e.bullet,number:e.number,chars:e.chars.map(e=>({...e,marks:e.marks.filter(e=>e.id!==i)}))})),l),t,n)}function V(e,t,l,r,s=k){const i={text:e,selectionStart:t,selectionEnd:l};if(t===l||null!==r&&!n(r))return i;const o=A(e,s),c=o.flatMap(e=>e.chars),a=new Set(c.filter(e=>e.at>=t&&e.at<l));if(0===a.size)return i;const u=e=>o.map(t=>({bullet:t.bullet,number:t.number,chars:t.chars.map(t=>({...t,marks:e(t)}))})),h=new Set([...a].flatMap(e=>e.marks.filter(e=>"color"===e.kind).map(e=>e.id)));if(null===r){const n=K(T(u(e=>a.has(e)?e.marks.filter(e=>"color"!==e.kind):e.marks),h),s)??K(u(e=>e.marks.filter(e=>!h.has(e.id))),s);return G(e,c,a,n,t,l)}const f=Math.max(0,...c.flatMap(e=>e.marks.map(e=>e.id)))+1,d=Q(f,"color",r),m=e=>c.every(t=>!t.marks.some(t=>t.id===e)||a.has(t)),p=K(T(u(e=>a.has(e)?D(e.marks.filter(e=>"color"!==e.kind),d,m):e.marks),/* @__PURE__ */new Set([f,...h])),s);return G(e,c,a,p,t,l)}function Y(e,t,n,l=k){const r=A(e,l).flatMap(e=>e.chars),s=t===n?[[...r].reverse().find(n=>n.at<t&&!e.slice(n.at,t).includes("\n"))].filter(e=>void 0!==e):r.filter(e=>e.at>=t&&e.at<n);if(0===s.length)return null;const i=e=>e.marks.filter(e=>"color"===e.kind).pop()?.color??null,o=i(s[0]);return null!==o&&s.every(e=>i(e)===o)?o:null}var ee=/^(?:- |([0-9]{1,3})\. )$/;function te(e,t,n){const l=e.split("\n"),r=[];let s=0;for(const e of l)r.push(s),s+=e.length+1;const i=e=>{let t=0;for(;t+1<r.length&&r[t+1]<=e;)t+=1;return t};return{first:i(t),last:i(Math.max(t,n)),starts:r}}function ne(e,t){if(null!=t.number)return"number";if(t.bullet)return"bullet";const n=ee.exec(e);return n?void 0===n[1]?"bullet":"number":null}function le(e,t,n,l,r=k){const s=e.split("\n"),i=A(e,r),{first:o,last:c}=te(e,t,n),a=i.map((e,t)=>null===ne(s[t],e)||e.bullet||null!=e.number?{bullet:e.bullet,number:e.number??null,chars:e.chars}:{bullet:!1,number:null,chars:[]});let u=0;if("number"===l&&o>0&&"number"===ne(s[o-1],i[o-1])){const e=i[o-1].number??ee.exec(s[o-1])?.[1]??"0";u=Number(e)}const h=L(a.map((e,t)=>t<o||t>c?e:"bullet"===l?{bullet:!0,number:null,chars:e.chars}:"number"===l?{bullet:!1,number:String(u+=1),chars:e.chars}:{bullet:!1,number:null,chars:e.chars})).text.split("\n").map((e,t)=>t<o||t>c?s[t]:e),f=h.join("\n"),{starts:d}=te(e,0,0),m=t=>{const{first:n}=te(e,t,t);let l=0;for(let e=0;e<n;e+=1)l+=h[e].length-s[e].length;const r=null===ne(s[o=n],i[o])||i[o].bullet||null!=i[o].number?C(i[o]).length:s[o].length;var o;const c=h[n].length-(s[n].length-r),a=t-d[n];return d[n]+l+(a<r?c:a-r+c)};return{text:f,selectionStart:m(t),selectionEnd:m(n)}}function re(e,t,n,l=k){const r=e.split("\n"),s=A(e,l),{first:i,last:o}=te(e,t,n),c=new Set(s.slice(i,o+1).map((e,t)=>ne(r[i+t],e)));return 1===c.size?[...c][0]:null}export{S as CAMPAIGN_MARKUP,g as COPY_FIELD_TOOLS,d as MARKUP_TOOLS,m as MARK_NAMES,s as MARK_PLACEHOLDERS,b as RETIRED_MARKS,k as STANDARD_MARKUP,x as STOREFRONT_MARKUP,c as applyColor,o as applyMark,N as clearMarks,F as clearStyle,Y as colorIn,V as colorOver,u as findLink,t as isColorName,n as isColorValue,$ as isSafeLinkHref,R as linkOver,re as listIn,a as markedAt,A as markedLines,J as marksIn,p as markupTools,O as parseMarkup,f as removeLink,W as sameMarks,j as serializeMarkup,le as setList,Q as spanFor,y as stripInline,H as toggleMark,w as tokenizeInline,U as unlinkAt,h as writeLink,L as writeMarkedLines};