"use strict";var wp;(wp||={}).richText=(()=>{var Cr=Object.create;var gt=Object.defineProperty;var Lr=Object.getOwnPropertyDescriptor;var Rr=Object.getOwnPropertyNames;var _r=Object.getPrototypeOf,Sr=Object.prototype.hasOwnProperty;var $=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ot=(e,t)=>{for(var r in t)gt(e,r,{get:t[r],enumerable:!0})},Zt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Rr(t))!Sr.call(e,o)&&o!==r&&gt(e,o,{get:()=>t[o],enumerable:!(n=Lr(t,o))||n.enumerable});return e};var b=(e,t,r)=>(r=e!=null?Cr(_r(e)):{},Zt(t||!e||!e.__esModule?gt(r,"default",{value:e,enumerable:!0}):r,e)),Or=e=>Zt(gt({},"__esModule",{value:!0}),e);var V=$((Rn,Yt)=>{Yt.exports=window.wp.data});var ne=$((Bn,re)=>{re.exports=window.wp.escapeHtml});var xe=$((jo,we)=>{we.exports=window.wp.a11y});var Fe=$((Uo,Te)=>{Te.exports=window.wp.i18n});var Le=$((Jo,Ce)=>{Ce.exports=window.wp.privateApis});var Y=$((Qo,Se)=>{Se.exports=window.wp.element});var Nt=$((Io,Oe)=>{Oe.exports=window.wp.compose});var qt=$((ti,De)=>{De.exports=window.wp.deprecated});var Xt=$((mi,Ze)=>{Ze.exports=window.wp.keycodes});var br=$((Ji,Er)=>{Er.exports=window.wp.dom});var Cn={};Ot(Cn,{RichTextData:()=>j,__experimentalRichText:()=>An,__unstableCreateElement:()=>B,__unstableToDom:()=>jt,__unstableUseRichText:()=>hr,applyFormat:()=>vt,concat:()=>fe,create:()=>C,getActiveFormat:()=>ot,getActiveFormats:()=>X,getActiveObject:()=>me,getTextContent:()=>nt,insert:()=>at,insertObject:()=>ge,isCollapsed:()=>Z,isEmpty:()=>le,join:()=>pe,privateApis:()=>Gt,registerFormatType:()=>de,remove:()=>wt,removeFormat:()=>st,replace:()=>he,slice:()=>xt,split:()=>ye,store:()=>F,toHTMLString:()=>G,toggleFormat:()=>Ne,unregisterFormatType:()=>Ae,useAnchor:()=>Tr,useAnchorRef:()=>vr});var yt=b(V(),1);var Qt=b(V(),1);function Dr(e={},t){switch(t.type){case"ADD_FORMAT_TYPES":return{...e,...t.formatTypes.reduce((r,n)=>({...r,[n.name]:n}),{})};case"REMOVE_FORMAT_TYPES":return Object.fromEntries(Object.entries(e).filter(([r])=>!t.names.includes(r)))}return e}var It=(0,Qt.combineReducers)({formatTypes:Dr});var Mt={};Ot(Mt,{getFormatType:()=>Mr,getFormatTypeForBareElement:()=>Hr,getFormatTypeForClassName:()=>kr,getFormatTypes:()=>Dt});var te=b(V(),1),Dt=(0,te.createSelector)(e=>Object.values(e.formatTypes),e=>[e.formatTypes]);function Mr(e,t){return e.formatTypes[t]}function Hr(e,t){let r=Dt(e);return r.find(({className:n,tagName:o})=>n===null&&t===o)||r.find(({className:n,tagName:o})=>n===null&&o==="*")}function kr(e,t){return Dt(e).find(({className:r})=>r===null?!1:` ${t} `.indexOf(` ${r} `)>=0)}var Ht={};Ot(Ht,{addFormatTypes:()=>Pr,removeFormatTypes:()=>$r});function Pr(e){return{type:"ADD_FORMAT_TYPES",formatTypes:Array.isArray(e)?e:[e]}}function $r(e){return{type:"REMOVE_FORMAT_TYPES",names:Array.isArray(e)?e:[e]}}var Vr="core/rich-text",F=(0,yt.createReduxStore)(Vr,{reducer:It,selectors:Mt,actions:Ht});(0,yt.register)(F);function tt(e,t){if(e===t)return!0;if(!e||!t||e.type!==t.type)return!1;let r=e.attributes,n=t.attributes;if(r===n)return!0;if(!r||!n)return!1;let o=Object.keys(r),s=Object.keys(n);if(o.length!==s.length)return!1;let a=o.length;for(let i=0;i<a;i++){let c=o[i];if(r[c]!==n[c])return!1}return!0}function _(e){let t=e.formats.slice();return t.forEach((r,n)=>{let o=t[n-1];if(o){let s=r.slice();s.forEach((a,i)=>{let c=o[i];tt(a,c)&&(s[i]=c)}),t[n]=s}}),{...e,formats:t}}function ee(e,t,r){return e=e.slice(),e[t]=r,e}function vt(e,t,r=e.start,n=e.end){let{formats:o,activeFormats:s}=e,a=o.slice();if(r===n){let i=a[r]?.find(({type:c})=>c===t.type);if(i){let c=a[r].indexOf(i);for(;a[r]&&a[r][c]===i;)a[r]=ee(a[r],c,t),r--;for(n++;a[n]&&a[n][c]===i;)a[n]=ee(a[n],c,t),n++}}else{let i=1/0;for(let c=r;c<n;c++)if(a[c]){a[c]=a[c].filter(({type:f})=>f!==t.type);let u=a[c].length;u<i&&(i=u)}else a[c]=[],i=0;for(let c=r;c<n;c++)a[c].splice(i,0,t)}return _({...e,formats:a,activeFormats:[...s?.filter(({type:i})=>i!==t.type)||[],t]})}var Pt=b(V(),1);function B({implementation:e},t){return B.body||(B.body=e.createHTMLDocument("").body),B.body.innerHTML=t,B.body}var R="\uFFFC",mt="\uFEFF";var rt=b(ne(),1);function X(e,t=[]){let{formats:r,start:n,end:o,activeFormats:s}=e;if(n===void 0)return t;if(n===o){if(s)return s;let u=r[n-1]||t,f=r[n]||t;return u.length<f.length?u:f}if(!r[n])return t;let a=r.slice(n,o),i=[...a[0]],c=a.length;for(;c--;){let u=a[c];if(!u)return t;let f=i.length;for(;f--;){let m=i[f];u.find(l=>tt(m,l))||i.splice(f,1)}if(i.length===0)return t}return i||t}var oe=b(V(),1);function kt(e){return(0,oe.select)(F).getFormatType(e)}function ie(e,t){if(t)return e;let r={};for(let n in e){let o=n;n.startsWith("data-disable-rich-text-")&&(o=n.slice(23)),r[o]=e[n]}return r}function Et({type:e,tagName:t,attributes:r,unregisteredAttributes:n,object:o,boundaryClass:s,isEditableTree:a}){let i=kt(e),c={};if(s&&a&&(c["data-rich-text-format-boundary"]="true"),!i)return r&&(c={...r,...c}),{type:e,attributes:ie(c,a),object:o};c={...n,...c};for(let u in r){let f=i.attributes?i.attributes[u]:!1;f?c[f]=r[u]:c[u]=r[u]}return i.className&&(c.class?c.class=`${i.className} ${c.class}`:c.class=i.className),{type:t||i.tagName,object:i.object,attributes:ie(c,a)}}function Br(e,t,r){do if(e[r]!==t[r])return!1;while(r--);return!0}function bt({value:e,preserveWhiteSpace:t,createEmpty:r,append:n,getLastChild:o,getParent:s,isText:a,getText:i,remove:c,appendText:u,onStartIndex:f,onEndIndex:m,isEditableTree:l,placeholder:y}){let{formats:w,replacements:d,text:h,start:v,end:x}=e,g=w.length+1,L=r(),k=X(e),U=k[k.length-1],q,W;n(L,"");for(let T=0;T<g;T++){let E=h.charAt(T),A=l&&(!W||W===`
`),O=w[T],p=o(L);if(O&&O.forEach((D,P)=>{if(p&&q&&Br(O,q,P)){p=o(p);return}let{type:Q,tagName:I,attributes:St,unregisteredAttributes:ht}=D,Fr=l&&D===U,Nr=s(p),Ar=n(Nr,Et({type:Q,tagName:I,attributes:St,unregisteredAttributes:ht,boundaryClass:Fr,isEditableTree:l}));a(p)&&i(p).length===0&&c(p),p=n(Ar,"")}),T===0&&(f&&v===0&&f(L,p),m&&x===0&&m(L,p)),E===R){let D=d[T];if(!D)continue;let{type:P,attributes:Q,innerHTML:I}=D,St=kt(P);if(l&&P==="#comment")p=n(s(p),{type:"span",attributes:{contenteditable:"false","data-rich-text-comment":Q["data-rich-text-comment"]}}),n(n(p,{type:"span"}),Q["data-rich-text-comment"].trim());else if(!l&&P==="script")p=n(s(p),Et({type:"script",isEditableTree:l})),n(p,{html:decodeURIComponent(Q["data-rich-text-script"])});else if(St?.contentEditable===!1){if(I||l){if(p=s(p),l){let ht={contenteditable:"false","data-rich-text-bogus":!0};v===T&&x===T+1&&(ht["data-rich-text-format-boundary"]=!0),p=n(p,{type:"span",attributes:ht}),l&&T+1===h.length&&n(s(p),mt)}p=n(p,Et({...D,isEditableTree:l})),I&&n(p,{html:I})}}else p=n(s(p),Et({...D,object:!0,isEditableTree:l}));p=n(s(p),"")}else!t&&E===`
`?(p=n(s(p),{type:"br",attributes:l?{"data-rich-text-line-break":"true"}:void 0,object:!0}),p=n(s(p),"")):a(p)?u(p,E):p=n(s(p),E);f&&v===T+1&&f(L,p),m&&x===T+1&&m(L,p),A&&T===h.length&&(n(s(p),mt),y&&h.length===0&&n(s(p),{type:"span",attributes:{"data-rich-text-placeholder":y,style:"pointer-events:none;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;"}})),q=O,W=E}return L}function G({value:e,preserveWhiteSpace:t}){let r=bt({value:e,preserveWhiteSpace:t,createEmpty:jr,append:qr,getLastChild:Ur,getParent:Kr,isText:zr,getText:Xr,remove:Gr,appendText:Wr});return se(r.children)}function jr(){return{}}function Ur({children:e}){return e&&e[e.length-1]}function qr(e,t){return typeof t=="string"&&(t={text:t}),t.parent=e,e.children=e.children||[],e.children.push(t),t}function Wr(e,t){e.text+=t}function Kr({parent:e}){return e}function zr({text:e}){return typeof e=="string"}function Xr({text:e}){return e}function Gr(e){let t=e.parent.children.indexOf(e);return t!==-1&&e.parent.children.splice(t,1),e}function Jr({type:e,attributes:t,object:r,children:n}){if(e==="#comment")return`<!--${t["data-rich-text-comment"]}-->`;let o="";for(let s in t)(0,rt.isValidAttributeName)(s)&&(o+=` ${s}="${(0,rt.escapeAttribute)(t[s])}"`);return r?`<${e}${o}>`:`<${e}${o}>${se(n)}</${e}>`}function se(e=[]){return e.map(t=>t.html!==void 0?t.html:t.text===void 0?Jr(t):(0,rt.escapeEditableHTML)(t.text)).join("")}function nt({text:e}){return e.replace(R,"")}function et(){return{formats:[],replacements:[],text:""}}function Zr({tagName:e,attributes:t}){let r;if(t&&t.class&&(r=(0,Pt.select)(F).getFormatTypeForClassName(t.class),r&&(t.class=` ${t.class} `.replace(` ${r.className} `," ").trim(),t.class||delete t.class)),r||(r=(0,Pt.select)(F).getFormatTypeForBareElement(e)),!r)return t?{type:e,attributes:t}:{type:e};if(r.__experimentalCreatePrepareEditableTree&&!r.__experimentalCreateOnChangeEditableValue)return null;if(!t)return{formatType:r,type:r.name,tagName:e};let n={},o={},s={...t};for(let a in r.attributes){let i=r.attributes[a];n[a]=s[i],delete s[i],typeof n[a]>"u"&&delete n[a]}for(let a in s)o[a]=t[a];return r.contentEditable===!1&&delete o.contenteditable,{formatType:r,type:r.name,tagName:e,attributes:n,unregisteredAttributes:o}}var j=class lt{#t;static empty(){return new lt}static fromPlainText(t){return new lt(C({text:t}))}static fromHTMLString(t){return new lt(C({html:t}))}static fromHTMLElement(t,r={}){let{preserveWhiteSpace:n=!1}=r,o=n?t:ce(t),s=new lt(C({element:o}));return Object.defineProperty(s,"originalHTML",{value:t.innerHTML}),s}constructor(t=et()){this.#t=t}toPlainText(){return nt(this.#t)}toHTMLString({preserveWhiteSpace:t}={}){return this.originalHTML||G({value:this.#t,preserveWhiteSpace:t})}valueOf(){return this.toHTMLString()}toString(){return this.toHTMLString()}toJSON(){return this.toHTMLString()}get length(){return this.text.length}get formats(){return this.#t.formats}get replacements(){return this.#t.replacements}get text(){return this.#t.text}};for(let e of Object.getOwnPropertyNames(String.prototype))j.prototype.hasOwnProperty(e)||Object.defineProperty(j.prototype,e,{value(...t){return this.toHTMLString()[e](...t)}});function C({element:e,text:t,html:r,range:n,__unstableIsEditableTree:o}={}){return r instanceof j?{text:r.text,formats:r.formats,replacements:r.replacements}:typeof t=="string"&&t.length>0?{formats:Array(t.length),replacements:Array(t.length),text:t}:(typeof r=="string"&&r.length>0&&(e=B(document,r)),typeof e!="object"?et():ue({element:e,range:n,isEditableTree:o}))}function J(e,t,r,n){if(!r)return;let{parentNode:o}=t,{startContainer:s,startOffset:a,endContainer:i,endOffset:c}=r,u=e.text.length;n.start!==void 0?e.start=u+n.start:t===s&&t.nodeType===t.TEXT_NODE?e.start=u+a:o===s&&t===s.childNodes[a]?e.start=u:o===s&&t===s.childNodes[a-1]?e.start=u+n.text.length:t===s&&(e.start=u),n.end!==void 0?e.end=u+n.end:t===i&&t.nodeType===t.TEXT_NODE?e.end=u+c:o===i&&t===i.childNodes[c-1]?e.end=u+n.text.length:o===i&&t===i.childNodes[c]?e.end=u:t===i&&(e.end=u+c)}function Yr(e,t,r){if(!t)return;let{startContainer:n,endContainer:o}=t,{startOffset:s,endOffset:a}=t;return e===n&&(s=r(e.nodeValue.slice(0,s)).length),e===o&&(a=r(e.nodeValue.slice(0,a)).length),{startContainer:n,startOffset:s,endContainer:o,endOffset:a}}function ce(e,t=!0,r=!1,n=!1){let o=e.cloneNode(!0);return o.normalize(),Array.from(o.childNodes).forEach((s,a,i)=>{if(s.nodeType===s.TEXT_NODE){let c=s.nodeValue;/[\n\t\r\f]/.test(c)&&(c=c.replace(/[\n\t\r\f]+/g," ")),c.indexOf("  ")!==-1&&(c=c.replace(/ {2,}/g," ")),a===0&&c.startsWith(" ")&&(t||r)&&(c=c.slice(1)),a===i.length-1&&c.endsWith(" ")&&(t||n)&&(c=c.slice(0,-1)),s.nodeValue=c}else if(s.nodeType===s.ELEMENT_NODE){let{previousSibling:c,nextSibling:u}=s,f=c?.textContent.endsWith(" "),m=u?.textContent.startsWith(" ");s.replaceWith(ce(s,!1,c?f:t||r,u?m:t||n))}}),o}var Qr="\r";function ae(e){return e.replace(new RegExp(`[${mt}${R}${Qr}]`,"gu"),"")}function ue({element:e,range:t,isEditableTree:r}){let n=et();if(!e)return n;if(!e.hasChildNodes())return J(n,e,t,et()),n;let o=e.childNodes.length;for(let a=0;a<o;a++){let i=e.childNodes[a],c=i.nodeName.toLowerCase();if(i.nodeType===i.TEXT_NODE){let m=ae(i.nodeValue);t=Yr(i,t,ae),J(n,i,t,{text:m}),n.formats.length+=m.length,n.replacements.length+=m.length,n.text+=m;continue}if(i.nodeType===i.COMMENT_NODE||i.nodeType===i.ELEMENT_NODE&&i.tagName==="SPAN"&&i.hasAttribute("data-rich-text-comment")){let m={formats:[,],replacements:[{type:"#comment",attributes:{"data-rich-text-comment":i.nodeType===i.COMMENT_NODE?i.nodeValue:i.getAttribute("data-rich-text-comment")}}],text:R};J(n,i,t,m),K(n,m);continue}if(i.nodeType!==i.ELEMENT_NODE)continue;if(r&&c==="br"&&!i.getAttribute("data-rich-text-line-break")){J(n,i,t,et());continue}if(c==="script"){let m={formats:[,],replacements:[{type:c,attributes:{"data-rich-text-script":i.getAttribute("data-rich-text-script")||encodeURIComponent(i.innerHTML)}}],text:R};J(n,i,t,m),K(n,m);continue}if(c==="br"){J(n,i,t,et()),K(n,C({text:`
`}));continue}let u=Zr({tagName:c,attributes:Ir({element:i})});if(u?.formatType?.contentEditable===!1){delete u.formatType,J(n,i,t,et()),K(n,{formats:[,],replacements:[{...u,innerHTML:i.innerHTML}],text:R});continue}u&&delete u.formatType;let f=ue({element:i,range:t,isEditableTree:r});if(J(n,i,t,f),!u||i.getAttribute("data-rich-text-placeholder")||i.getAttribute("data-rich-text-bogus"))K(n,f);else if(f.text.length===0)u.attributes&&K(n,{formats:[,],replacements:[u],text:R});else{let m=function(l){if(m.formats===l)return m.newFormats;let y=l?[u,...l]:[u];return m.formats=l,m.newFormats=y,y};var s=m;m.newFormats=[u],K(n,{...f,formats:Array.from(f.formats,m)})}}return n}function Ir({element:e}){if(!e.hasAttributes())return;let t=e.attributes.length,r;for(let n=0;n<t;n++){let{name:o,value:s}=e.attributes[n];if(o.indexOf("data-rich-text-")===0)continue;let a=/^on/i.test(o)?"data-disable-rich-text-"+o:o;r=r||{},r[a]=s}return r}function K(e,t){return e.formats=e.formats.concat(t.formats),e.replacements=e.replacements.concat(t.replacements),e.text+=t.text,e}function fe(...e){return _(e.reduce(K,C()))}function ot(e,t){return X(e).find(({type:r})=>r===t)}function me({start:e,end:t,replacements:r,text:n}){if(!(e+1!==t||n[e]!==R))return r[e]}function Z({start:e,end:t}){if(!(e===void 0||t===void 0))return e===t}function le({text:e}){return e.length===0}function pe(e,t=""){return typeof t=="string"&&(t=C({text:t})),_(e.reduce((r,{formats:n,replacements:o,text:s})=>({formats:r.formats.concat(t.formats,n),replacements:r.replacements.concat(t.replacements,o),text:r.text+t.text+s})))}var it=b(V(),1);function de(e,t){if(t={name:e,...t},typeof t.name!="string"){window.console.error("Format names must be strings.");return}if(!/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/.test(t.name)){window.console.error("Format names must contain a namespace prefix, include only lowercase alphanumeric characters or dashes, and start with a letter. Example: my-plugin/my-custom-format");return}if((0,it.select)(F).getFormatType(t.name)){window.console.error('Format "'+t.name+'" is already registered.');return}if(typeof t.tagName!="string"||t.tagName===""){window.console.error("Format tag names must be a string.");return}if((typeof t.className!="string"||t.className==="")&&t.className!==null){window.console.error("Format class names must be a string, or null to handle bare elements.");return}if(!/^[_a-zA-Z]+[a-zA-Z0-9_-]*$/.test(t.className)){window.console.error("A class name must begin with a letter, followed by any number of hyphens, underscores, letters, or numbers.");return}if(t.className===null){let r=(0,it.select)(F).getFormatTypeForBareElement(t.tagName);if(r&&r.name!=="core/unknown"){window.console.error(`Format "${r.name}" is already registered to handle bare tag name "${t.tagName}".`);return}}else{let r=(0,it.select)(F).getFormatTypeForClassName(t.className);if(r){window.console.error(`Format "${r.name}" is already registered to handle class name "${t.className}".`);return}}if(!("title"in t)||t.title===""){window.console.error('The format "'+t.name+'" must have a title.');return}if("keywords"in t&&t.keywords.length>3){window.console.error('The format "'+t.name+'" can have a maximum of 3 keywords.');return}if(typeof t.title!="string"){window.console.error("Format titles must be strings.");return}return(0,it.dispatch)(F).addFormatTypes(t),t}function st(e,t,r=e.start,n=e.end){let{formats:o,activeFormats:s}=e,a=o.slice();if(r===n){let i=a[r]?.find(({type:c})=>c===t);if(i){for(;a[r]?.find(c=>c===i);)$t(a,r,t),r--;for(n++;a[n]?.find(c=>c===i);)$t(a,n,t),n++}}else for(let i=r;i<n;i++)a[i]&&$t(a,i,t);return _({...e,formats:a,activeFormats:s?.filter(({type:i})=>i!==t)||[]})}function $t(e,t,r){let n=e[t].filter(({type:o})=>o!==r);n.length?e[t]=n:delete e[t]}function at(e,t,r=e.start,n=e.end){let{formats:o,replacements:s,text:a}=e;typeof t=="string"&&(t=C({text:t}));let i=r+t.text.length;return _({formats:o.slice(0,r).concat(t.formats,o.slice(n)),replacements:s.slice(0,r).concat(t.replacements,s.slice(n)),text:a.slice(0,r)+t.text+a.slice(n),start:i,end:i})}function wt(e,t,r){return at(e,C(),t,r)}function he({formats:e,replacements:t,text:r,start:n,end:o},s,a){return r=r.replace(s,(i,...c)=>{let u=c[c.length-2],f=a,m,l;return typeof f=="function"&&(f=a(i,...c)),typeof f=="object"?(m=f.formats,l=f.replacements,f=f.text):(m=Array(f.length),l=Array(f.length),e[u]&&(m=m.fill(e[u]))),e=e.slice(0,u).concat(m,e.slice(u+i.length)),t=t.slice(0,u).concat(l,t.slice(u+i.length)),n&&(n=o=u+f.length),f}),_({formats:e,replacements:t,text:r,start:n,end:o})}function ge(e,t,r,n){return at(e,{formats:[,],replacements:[t],text:R},r,n)}function xt(e,t=e.start,r=e.end){let{formats:n,replacements:o,text:s}=e;return t===void 0||r===void 0?{...e}:{formats:n.slice(t,r),replacements:o.slice(t,r),text:s.slice(t,r)}}function ye({formats:e,replacements:t,text:r,start:n,end:o},s){if(typeof s!="string")return tn(...arguments);let a=0;return r.split(s).map(i=>{let c=a,u={formats:e.slice(c,c+i.length),replacements:t.slice(c,c+i.length),text:i};return a+=s.length+i.length,n!==void 0&&o!==void 0&&(n>=c&&n<a?u.start=n-c:n<c&&o>c&&(u.start=0),o>=c&&o<a?u.end=o-c:n<a&&o>a&&(u.end=i.length)),u})}function tn({formats:e,replacements:t,text:r,start:n,end:o},s=n,a=o){if(n===void 0||o===void 0)return;let i={formats:e.slice(0,s),replacements:t.slice(0,s),text:r.slice(0,s)},c={formats:e.slice(a),replacements:t.slice(a),text:r.slice(a),start:0,end:0};return[i,c]}function Tt(e,t){return e===t||e&&t&&e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset}var Vt="http://www.w3.org/1998/Math/MathML";function Bt(e,t,r){let n=e.parentNode,o=0;for(;e=e.previousSibling;)o++;return r=[o,...r],n!==t&&(r=Bt(n,t,r)),r}function ve(e,t){for(t=[...t];e&&t.length>1;)e=e.childNodes[t.shift()];return{node:e,offset:t[0]}}function en(e,t){if(t.html!==void 0)return e.innerHTML+=t.html;typeof t=="string"&&(t=e.ownerDocument.createTextNode(t));let{type:r,attributes:n}=t;if(r)if(r==="#comment")t=e.ownerDocument.createComment(n["data-rich-text-comment"]);else{let o=e.namespaceURI;r==="math"?t=e.ownerDocument.createElementNS(Vt,r):o===Vt?e.tagName==="MTEXT"?t=e.ownerDocument.createElement(r):t=e.ownerDocument.createElementNS(Vt,r):t=e.ownerDocument.createElement(r);for(let s in n)t.setAttribute(s,n[s])}return e.appendChild(t)}function rn(e,t){e.appendData(t)}function nn({lastChild:e}){return e}function on({parentNode:e}){return e}function sn(e){return e.nodeType===e.TEXT_NODE}function an({nodeValue:e}){return e}function cn(e){return e.parentNode.removeChild(e)}function jt({value:e,prepareEditableTree:t,isEditableTree:r=!0,placeholder:n,doc:o=document}){let s=[],a=[];return t&&(e={...e,formats:t(e)}),{body:bt({value:e,createEmpty:()=>B(o,""),append:en,getLastChild:nn,getParent:on,isText:sn,getText:an,remove:cn,appendText:rn,onStartIndex(u,f){s=Bt(f,u,[f.nodeValue.length])},onEndIndex(u,f){a=Bt(f,u,[f.nodeValue.length])},isEditableTree:r,placeholder:n}),selection:{startPath:s,endPath:a}}}function Ee({value:e,current:t,prepareEditableTree:r,__unstableDomOnly:n,placeholder:o}){let{body:s,selection:a}=jt({value:e,prepareEditableTree:r,placeholder:o,doc:t.ownerDocument});be(s,t),e.start!==void 0&&!n&&un(a,t)}function be(e,t){let r=0,n;for(;n=e.firstChild;){let o=t.childNodes[r];if(!o)t.appendChild(n);else if(o.isEqualNode(n))e.removeChild(n);else if(o.nodeName!==n.nodeName||o.nodeType===o.TEXT_NODE&&o.data!==n.data)t.replaceChild(n,o);else{let s=o.attributes,a=n.attributes;if(s){let i=s.length;for(;i--;){let{name:c}=s[i];n.getAttribute(c)||o.removeAttribute(c)}}if(a)for(let i=0;i<a.length;i++){let{name:c,value:u}=a[i];o.getAttribute(c)!==u&&o.setAttribute(c,u)}be(n,o),e.removeChild(n)}r++}for(;t.childNodes[r];)t.removeChild(t.childNodes[r])}function un({startPath:e,endPath:t},r){let{node:n,offset:o}=ve(r,e),{node:s,offset:a}=ve(r,t),{ownerDocument:i}=r,{defaultView:c}=i,u=c.getSelection(),f=i.createRange();f.setStart(n,o),f.setEnd(s,a);let{activeElement:m}=i;if(u.rangeCount>0){if(Tt(f,u.getRangeAt(0)))return;u.removeAllRanges()}u.addRange(f),m!==i.activeElement&&m instanceof c.HTMLElement&&m.focus()}var Ut=b(xe(),1),ct=b(Fe(),1);function Ne(e,t){return ot(e,t.type)?(t.title&&(0,Ut.speak)((0,ct.sprintf)((0,ct.__)("%s removed."),t.title),"assertive"),st(e,t.type)):(t.title&&(0,Ut.speak)((0,ct.sprintf)((0,ct.__)("%s applied."),t.title),"assertive"),vt(e,t))}var Ft=b(V(),1);function Ae(e){let t=(0,Ft.select)(F).getFormatType(e);if(!t){window.console.error(`Format ${e} is not registered.`);return}return(0,Ft.dispatch)(F).removeFormatTypes(e),t}var Re=b(Le(),1),{lock:_e,unlock:Zo}=(0,Re.__dangerousOptInToUnstableAPIsOnlyForCoreModules)("I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.","@wordpress/rich-text");var H=b(Y(),1),Rt=b(Nt(),1),mr=b(V(),1),lr=b(qt(),1);var Me=b(Y(),1),fn="pre-wrap";function He(){return(0,Me.useCallback)(e=>{e&&(e.style.whiteSpace=fn)},[])}var mn={grad:.9,turn:360,rad:360/(2*Math.PI)},z=function(e){return typeof e=="string"?e.length>0:typeof e=="number"},N=function(e,t,r){return t===void 0&&(t=0),r===void 0&&(r=Math.pow(10,t)),Math.round(r*e)/r+0},S=function(e,t,r){return t===void 0&&(t=0),r===void 0&&(r=1),e>r?r:e>t?e:t},We=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},ke=function(e){return{r:S(e.r,0,255),g:S(e.g,0,255),b:S(e.b,0,255),a:S(e.a)}},Wt=function(e){return{r:N(e.r),g:N(e.g),b:N(e.b),a:N(e.a,3)}},ln=/^#([0-9a-f]{3,8})$/i,At=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},Ke=function(e){var t=e.r,r=e.g,n=e.b,o=e.a,s=Math.max(t,r,n),a=s-Math.min(t,r,n),i=a?s===t?(r-n)/a:s===r?2+(n-t)/a:4+(t-r)/a:0;return{h:60*(i<0?i+6:i),s:s?a/s*100:0,v:s/255*100,a:o}},ze=function(e){var t=e.h,r=e.s,n=e.v,o=e.a;t=t/360*6,r/=100,n/=100;var s=Math.floor(t),a=n*(1-r),i=n*(1-(t-s)*r),c=n*(1-(1-t+s)*r),u=s%6;return{r:255*[n,i,a,a,c,n][u],g:255*[c,n,n,i,a,a][u],b:255*[a,a,c,n,n,i][u],a:o}},Pe=function(e){return{h:We(e.h),s:S(e.s,0,100),l:S(e.l,0,100),a:S(e.a)}},$e=function(e){return{h:N(e.h),s:N(e.s),l:N(e.l),a:N(e.a,3)}},Ve=function(e){return ze((r=(t=e).s,{h:t.h,s:(r*=((n=t.l)<50?n:100-n)/100)>0?2*r/(n+r)*100:0,v:n+r,a:t.a}));var t,r,n},pt=function(e){return{h:(t=Ke(e)).h,s:(o=(200-(r=t.s))*(n=t.v)/100)>0&&o<200?r*n/100/(o<=100?o:200-o)*100:0,l:o/2,a:t.a};var t,r,n,o},pn=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,dn=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,hn=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,gn=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Be={string:[[function(e){var t=ln.exec(e);return t?(e=t[1]).length<=4?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:e.length===4?N(parseInt(e[3]+e[3],16)/255,2):1}:e.length===6||e.length===8?{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:e.length===8?N(parseInt(e.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(e){var t=hn.exec(e)||gn.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:ke({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(e){var t=pn.exec(e)||dn.exec(e);if(!t)return null;var r,n,o=Pe({h:(r=t[1],n=t[2],n===void 0&&(n="deg"),Number(r)*(mn[n]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Ve(o)},"hsl"]],object:[[function(e){var t=e.r,r=e.g,n=e.b,o=e.a,s=o===void 0?1:o;return z(t)&&z(r)&&z(n)?ke({r:Number(t),g:Number(r),b:Number(n),a:Number(s)}):null},"rgb"],[function(e){var t=e.h,r=e.s,n=e.l,o=e.a,s=o===void 0?1:o;if(!z(t)||!z(r)||!z(n))return null;var a=Pe({h:Number(t),s:Number(r),l:Number(n),a:Number(s)});return Ve(a)},"hsl"],[function(e){var t=e.h,r=e.s,n=e.v,o=e.a,s=o===void 0?1:o;if(!z(t)||!z(r)||!z(n))return null;var a=(function(i){return{h:We(i.h),s:S(i.s,0,100),v:S(i.v,0,100),a:S(i.a)}})({h:Number(t),s:Number(r),v:Number(n),a:Number(s)});return ze(a)},"hsv"]]},je=function(e,t){for(var r=0;r<t.length;r++){var n=t[r][0](e);if(n)return[n,t[r][1]]}return[null,void 0]},yn=function(e){return typeof e=="string"?je(e.trim(),Be.string):typeof e=="object"&&e!==null?je(e,Be.object):[null,void 0]};var Kt=function(e,t){var r=pt(e);return{h:r.h,s:S(r.s+100*t,0,100),l:r.l,a:r.a}},zt=function(e){return(299*e.r+587*e.g+114*e.b)/1e3/255},Ue=function(e,t){var r=pt(e);return{h:r.h,s:r.s,l:S(r.l+100*t,0,100),a:r.a}},qe=(function(){function e(t){this.parsed=yn(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return e.prototype.isValid=function(){return this.parsed!==null},e.prototype.brightness=function(){return N(zt(this.rgba),2)},e.prototype.isDark=function(){return zt(this.rgba)<.5},e.prototype.isLight=function(){return zt(this.rgba)>=.5},e.prototype.toHex=function(){return t=Wt(this.rgba),r=t.r,n=t.g,o=t.b,a=(s=t.a)<1?At(N(255*s)):"","#"+At(r)+At(n)+At(o)+a;var t,r,n,o,s,a},e.prototype.toRgb=function(){return Wt(this.rgba)},e.prototype.toRgbString=function(){return t=Wt(this.rgba),r=t.r,n=t.g,o=t.b,(s=t.a)<1?"rgba("+r+", "+n+", "+o+", "+s+")":"rgb("+r+", "+n+", "+o+")";var t,r,n,o,s},e.prototype.toHsl=function(){return $e(pt(this.rgba))},e.prototype.toHslString=function(){return t=$e(pt(this.rgba)),r=t.h,n=t.s,o=t.l,(s=t.a)<1?"hsla("+r+", "+n+"%, "+o+"%, "+s+")":"hsl("+r+", "+n+"%, "+o+"%)";var t,r,n,o,s},e.prototype.toHsv=function(){return t=Ke(this.rgba),{h:N(t.h),s:N(t.s),v:N(t.v),a:N(t.a,3)};var t},e.prototype.invert=function(){return M({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},e.prototype.saturate=function(t){return t===void 0&&(t=.1),M(Kt(this.rgba,t))},e.prototype.desaturate=function(t){return t===void 0&&(t=.1),M(Kt(this.rgba,-t))},e.prototype.grayscale=function(){return M(Kt(this.rgba,-1))},e.prototype.lighten=function(t){return t===void 0&&(t=.1),M(Ue(this.rgba,t))},e.prototype.darken=function(t){return t===void 0&&(t=.1),M(Ue(this.rgba,-t))},e.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},e.prototype.alpha=function(t){return typeof t=="number"?M({r:(r=this.rgba).r,g:r.g,b:r.b,a:t}):N(this.rgba.a,3);var r},e.prototype.hue=function(t){var r=pt(this.rgba);return typeof t=="number"?M({h:t,s:r.s,l:r.l,a:r.a}):N(r.h)},e.prototype.isEqual=function(t){return this.toHex()===M(t).toHex()},e})(),M=function(e){return e instanceof qe?e:new qe(e)};var Ct=b(Y(),1);function Xe({record:e}){let t=(0,Ct.useRef)(),{activeFormats:r=[],replacements:n,start:o}=e.current,s=n[o];return(0,Ct.useEffect)(()=>{if((!r||!r.length)&&!s)return;let a="*[data-rich-text-format-boundary]",i=t.current.querySelector(a);if(!i)return;let{ownerDocument:c}=i,{defaultView:u}=c,f=u.getComputedStyle(i),m=M(f.color).alpha(.2).toRgbString(),l=`.rich-text:focus ${a}`,y=`background-color: ${m}`,w=`${l} {${y}}`,d="rich-text-boundary-style",h=c.getElementById(d);h||(h=c.createElement("style"),h.id=d,c.head.appendChild(h)),h.innerHTML!==w&&(h.innerHTML=w)},[r,s]),t}var ft=b(Y(),1),sr=b(Nt(),1);var Ge=e=>t=>{function r(o){let{record:s}=e.current,{ownerDocument:a}=t;if(Z(s.current)||!t.contains(a.activeElement))return;let i=xt(s.current),c=nt(i),u=G({value:i});o.clipboardData.setData("text/plain",c),o.clipboardData.setData("text/html",u),o.clipboardData.setData("rich-text","true"),o.preventDefault(),o.type==="cut"&&a.execCommand ("delete")}let{defaultView:n}=t.ownerDocument;return n.addEventListener("copy",r),n.addEventListener("cut",r),()=>{n.removeEventListener("copy",r),n.removeEventListener("cut",r)}};var Je=()=>e=>{function t(n){let{target:o}=n;if(o===e||o.textContent&&o.isContentEditable)return;let{ownerDocument:s}=o,{defaultView:a}=s,i=a.getSelection();if(i.containsNode(o))return;let c=s.createRange(),u=o.isContentEditable?o:o.closest("[contenteditable]");c.selectNode(u),i.removeAllRanges(),i.addRange(c),n.preventDefault()}function r(n){n.relatedTarget&&!e.contains(n.relatedTarget)&&n.relatedTarget.tagName==="A"&&t(n)}return e.addEventListener("click",t),e.addEventListener("focusin",r),()=>{e.removeEventListener("click",t),e.removeEventListener("focusin",r)}};var ut=b(Xt(),1);var Ye=[],Qe=e=>t=>{function r(n){let{keyCode:o,shiftKey:s,altKey:a,metaKey:i,ctrlKey:c}=n;if(s||a||i||c||o!==ut.LEFT&&o!==ut.RIGHT)return;let{record:u,applyRecord:f,forceRender:m}=e.current,{text:l,formats:y,start:w,end:d,activeFormats:h=[]}=u.current,v=Z(u.current),{ownerDocument:x}=t,{defaultView:g}=x,{direction:L}=g.getComputedStyle(t),k=L==="rtl"?ut.RIGHT:ut.LEFT,U=n.keyCode===k;if(v&&h.length===0&&(w===0&&U||d===l.length&&!U)||!v)return;let q=y[w-1]||Ye,W=y[w]||Ye,T=U?q:W,E=h.every((Q,I)=>Q===T[I]),A=h.length;if(E?A<T.length&&A++:A--,A===h.length){u.current._newActiveFormats=T;return}n.preventDefault();let D=(E?T:U?W:q).slice(0,A),P={...u.current,activeFormats:D};u.current=P,f(P),m()}return t.addEventListener("keydown",r),()=>{t.removeEventListener("keydown",r)}};var Lt=b(Xt(),1);var Ie=e=>t=>{function r(n){let{keyCode:o}=n,{createRecord:s,handleChange:a}=e.current;if(n.defaultPrevented||o!==Lt.DELETE&&o!==Lt.BACKSPACE)return;let i=s(),{start:c,end:u,text:f}=i;c===0&&u!==0&&u===f.length&&(a(wt(i)),n.preventDefault())}return t.addEventListener("keydown",r),()=>{t.removeEventListener("keydown",r)}};function tr({value:e,start:t,end:r,formats:n}){let o=Math.min(t,r),s=Math.max(t,r),a=e.formats[o-1]||[],i=e.formats[s]||[];for(e.activeFormats=n.map((c,u)=>{if(a[u]){if(tt(c,a[u]))return a[u]}else if(i[u]&&tt(c,i[u]))return i[u];return c});--r>=t;)e.activeFormats.length>0?e.formats[r]=e.activeFormats:delete e.formats[r];return e}var vn=new Set(["insertParagraph","insertOrderedList","insertUnorderedList","insertHorizontalRule","insertLink"]),er=[],rr="data-rich-text-placeholder";function En(e){let t=e.getSelection(),{anchorNode:r,anchorOffset:n}=t;if(r.nodeType!==r.ELEMENT_NODE)return;let o=r.childNodes[n];!o||o.nodeType!==o.ELEMENT_NODE||!o.hasAttribute(rr)||t.collapseToStart()}var nr=e=>t=>{let{ownerDocument:r}=t,{defaultView:n}=r,o=!1;function s(f){if(o)return;let m;f&&(m=f.inputType);let{record:l,applyRecord:y,createRecord:w,handleChange:d}=e.current;if(m&&(m.indexOf("format")===0||vn.has(m))){y(l.current);return}let h=w(),{start:v,activeFormats:x=[]}=l.current,g=!Z(l.current)&&h.start<=v,L=tr({value:h,start:v,end:h.start,formats:g?[]:x});d(L)}function a(){let{record:f,applyRecord:m,createRecord:l,onSelectionChange:y}=e.current;if(t.contentEditable!=="true")return;if(r.activeElement!==t){r.removeEventListener("selectionchange",a);return}if(o)return;let{start:w,end:d,text:h}=l(),v=f.current;if(h!==v.text){s();return}if(w===v.start&&d===v.end){v.text.length===0&&w===0&&En(n);return}let x={...v,start:w,end:d,activeFormats:v._newActiveFormats,_newActiveFormats:void 0},g=X(x,er);x.activeFormats=g,f.current=x,m(x,{domOnly:!0}),y(w,d)}function i(){o=!0,r.removeEventListener("selectionchange",a),t.querySelector(`[${rr}]`)?.remove()}function c(){o=!1,s({inputType:"insertText"}),r.addEventListener("selectionchange",a)}function u(){let{record:f,isSelected:m,onSelectionChange:l,applyRecord:y}=e.current;t.parentElement.closest('[contenteditable="true"]')||(m?y(f.current,{domOnly:!0}):f.current={...f.current,start:void 0,end:void 0,activeFormats:er},l(f.current.start,f.current.end),window.queueMicrotask(a),r.addEventListener("selectionchange",a))}return t.addEventListener("input",s),t.addEventListener("compositionstart",i),t.addEventListener("compositionend",c),t.addEventListener("focus",u),()=>{t.removeEventListener("input",s),t.removeEventListener("compositionstart",i),t.removeEventListener("compositionend",c),t.removeEventListener("focus",u)}};var or=()=>e=>{let{ownerDocument:t}=e,{defaultView:r}=t,n=r?.getSelection(),o;function s(){return n.rangeCount?n.getRangeAt(0):null}function a(i){let c=i.type==="keydown"?"keyup":"pointerup";function u(){t.removeEventListener(c,f),t.removeEventListener("selectionchange",u),t.removeEventListener("input",u)}function f(){u(),!Tt(o,s())&&t.dispatchEvent(new Event("selectionchange"))}t.addEventListener(c,f),t.addEventListener("selectionchange",u),t.addEventListener("input",u),o=s()}return e.addEventListener("pointerdown",a),e.addEventListener("keydown",a),()=>{e.removeEventListener("pointerdown",a),e.removeEventListener("keydown",a)}};function ir(){return e=>{let{ownerDocument:t}=e,{defaultView:r}=t,n=null;function o(a){a.defaultPrevented||a.target!==e&&a.target.contains(e)&&(n=e.getAttribute("contenteditable"),e.setAttribute("contenteditable","false"),r.getSelection().removeAllRanges())}function s(){n!==null&&(e.setAttribute("contenteditable",n),n=null)}return r.addEventListener("pointerdown",o),r.addEventListener("pointerup",s),()=>{r.removeEventListener("pointerdown",o),r.removeEventListener("pointerup",s)}}}var bn=[Ge,Je,Qe,Ie,nr,or,ir];function ar(e){let t=(0,ft.useRef)(e);(0,ft.useInsertionEffect)(()=>{t.current=e});let r=(0,ft.useMemo)(()=>bn.map(n=>n(t)),[t]);return(0,sr.useRefEffect)(n=>{let o=r.map(s=>s(n));return()=>{o.forEach(s=>s())}},[r])}var ur=b(Y(),1),dt=b(V(),1);function wn(e){return e(F).getFormatTypes()}var xn=new Set(["a","audio","button","details","embed","iframe","input","label","select","textarea","video"]);function Tn(e,t){return typeof e!="object"?{[t]:e}:Object.fromEntries(Object.entries(e).map(([r,n])=>[`${t}.${r}`,n]))}function cr(e,t){return e[t]?e[t]:Object.keys(e).filter(r=>r.startsWith(t+".")).reduce((r,n)=>(r[n.slice(t.length+1)]=e[n],r),{})}function fr({allowedFormats:e,withoutInteractiveFormatting:t,__unstableFormatTypeHandlerContext:r}){let n=(0,dt.useSelect)(wn,[]),o=(0,ur.useMemo)(()=>n.filter(({name:m,interactive:l,tagName:y})=>!(e&&!e.includes(m)||t&&(l||xn.has(y)))),[n,e,t]),s=(0,dt.useSelect)(m=>o.reduce((l,y)=>!y.__experimentalGetPropsForEditableTreePreparation||!r?l:{...l,...Tn(y.__experimentalGetPropsForEditableTreePreparation(m,r),y.name)},{}),[o,r]),a=(0,dt.useDispatch)(),i=[],c=[],u=[],f=[];for(let m in s)f.push(s[m]);return o.forEach(m=>{if(m.__experimentalCreatePrepareEditableTree&&r){let l=m.__experimentalCreatePrepareEditableTree(cr(s,m.name),r);m.__experimentalCreateOnChangeEditableValue?c.push(l):i.push(l)}if(m.__experimentalCreateOnChangeEditableValue&&r){let l={};m.__experimentalGetPropsForEditableTreeChangeHandler&&(l=m.__experimentalGetPropsForEditableTreeChangeHandler(a,r));let y=cr(s,m.name);u.push(m.__experimentalCreateOnChangeEditableValue({...typeof y=="object"?y:{},...l},r))}}),{formatTypes:o,prepareHandlers:i,valueHandlers:c,changeHandlers:u,dependencies:f}}function pr({value:e="",selectionStart:t,selectionEnd:r,placeholder:n,onSelectionChange:o,preserveWhiteSpace:s,onChange:a,__unstableDisableFormats:i,__unstableIsSelected:c,__unstableDependencies:u=[],__unstableAfterParse:f,__unstableBeforeSerialize:m,__unstableAddInvisibleFormats:l}){let y=(0,mr.useRegistry)(),[,w]=(0,H.useReducer)(()=>({})),d=(0,H.useRef)();function h(){let{ownerDocument:{defaultView:E}}=d.current,A=E.getSelection(),O=A.rangeCount>0?A.getRangeAt(0):null;return C({element:d.current,range:O,__unstableIsEditableTree:!0})}function v(E,{domOnly:A}={}){Ee({value:E,current:d.current,prepareEditableTree:l,__unstableDomOnly:A,placeholder:n})}let x=(0,H.useRef)(e),g=(0,H.useRef)();function L(){let E=g.current?.activeFormats;x.current=e,g.current=e,e instanceof j||(g.current=e?j.fromHTMLString(e,{preserveWhiteSpace:s}):j.empty()),g.current={text:g.current.text,formats:g.current.formats,replacements:g.current.replacements,activeFormats:E},i&&(g.current.formats=Array(e.length),g.current.replacements=Array(e.length)),f&&(g.current.formats=f(g.current)),g.current.start=t,g.current.end=r}let k=(0,H.useRef)(!1);g.current?(t!==g.current.start||r!==g.current.end)&&(k.current=c,g.current={...g.current,start:t,end:r,activeFormats:void 0}):(k.current=c,L());function U(E){if(g.current=E,v(E),i)x.current=E.text;else{let P=m?m(E):E.formats;E={...E,formats:P},typeof e=="string"?x.current=G({value:E,preserveWhiteSpace:s}):x.current=new j(E)}let{start:A,end:O,formats:p,text:D}=g.current;y.batch(()=>{o(A,O),a(x.current,{__unstableFormats:p,__unstableText:D})}),w()}function q(){let E=x.current;L();let A=E&&typeof E=="string"&&typeof e=="string"&&E.length!==e.length,O=d.current?.contains(d.current.ownerDocument.activeElement),p=A&&!O;v(g.current,{domOnly:p})}let W=(0,H.useRef)(!1);(0,H.useLayoutEffect)(()=>{W.current&&e!==x.current&&(q(),w())},[e]),(0,H.useLayoutEffect)(()=>{k.current&&(d.current.ownerDocument.activeElement!==d.current&&d.current.focus(),v(g.current),k.current=!1)},[k.current]);let T=(0,Rt.useMergeRefs)([d,He(),Xe({record:g}),ar({record:g,handleChange:U,applyRecord:v,createRecord:h,isSelected:c,onSelectionChange:o,forceRender:w}),(0,Rt.useRefEffect)(()=>{q(),W.current=!0},[n,...u])]);return{value:g.current,getValue:()=>g.current,onChange:U,ref:T}}function dr({allowedFormats:e,withoutInteractiveFormatting:t,onChange:r,__unstableDependencies:n=[],__unstableFormatTypeHandlerContext:o,...s}){let{formatTypes:a,prepareHandlers:i,valueHandlers:c,changeHandlers:u,dependencies:f}=fr({allowedFormats:e,withoutInteractiveFormatting:t,__unstableFormatTypeHandlerContext:o});function m(d){return c.reduce((h,v)=>v(h,d.text),d.formats)}function l(d){return a.forEach(h=>{h.__experimentalCreatePrepareEditableTree&&(d=st(d,h.name,0,d.text.length))}),d.formats}function y(d){return i.reduce((h,v)=>v(h,d.text),d.formats)}return{...pr({...s,onChange(d,{__unstableFormats:h,__unstableText:v}){r(d,{__unstableFormats:h,__unstableText:v}),Object.values(u).forEach(x=>{x(h,v)})},__unstableDependencies:[...f,...n],__unstableAfterParse:m,__unstableBeforeSerialize:l,__unstableAddInvisibleFormats:y}),formatTypes:a}}function hr(e){return(0,lr.default)("`__unstableUseRichText` hook",{since:"7.0"}),pr(e)}var Gt={};_e(Gt,{useRichText:dr});var gr=b(Y(),1),yr=b(qt(),1);function vr({ref:e,value:t,settings:r={}}){(0,yr.default)("`useAnchorRef` hook",{since:"6.1",alternative:"`useAnchor` hook"});let{tagName:n,className:o,name:s}=r,a=s?ot(t,s):void 0;return(0,gr.useMemo)(()=>{if(!e.current)return;let{ownerDocument:{defaultView:i}}=e.current,c=i.getSelection();if(!c.rangeCount)return;let u=c.getRangeAt(0);if(!a)return u;let f=u.startContainer;for(f=f.nextElementSibling||f;f.nodeType!==f.ELEMENT_NODE;)f=f.parentNode;return f.closest(n+(o?"."+o:""))},[a,t.start,t.end,n,o])}var wr=b(Nt(),1),_t=b(Y(),1),xr=b(br(),1);function Fn(e,t,r,n){let o=e.startContainer;if(o.nodeType===o.TEXT_NODE&&e.startOffset===o.length&&o.nextSibling)for(o=o.nextSibling;o.firstChild;)o=o.firstChild;if(o.nodeType!==o.ELEMENT_NODE&&(o=o.parentElement),!o||o===t||!t.contains(o))return;let s=r+(n?"."+n:"");for(;o!==t;){if(o.matches(s))return o;o=o.parentElement}}function Nn(e,t){return{contextElement:t,getBoundingClientRect(){return t.contains(e.startContainer)?(0,xr.getRectangleFromRange)(e)??e.getBoundingClientRect():t.getBoundingClientRect()}}}function Jt(e,t,r){if(!e)return;let{ownerDocument:n}=e,{defaultView:o}=n,s=o.getSelection();if(!s||!s.rangeCount)return;let a=s.getRangeAt(0);if(!a||!a.startContainer)return;let i=Fn(a,e,t,r);return i||Nn(a,e)}function Tr({editableContentElement:e,settings:t={}}){let{tagName:r,className:n,isActive:o}=t,[s,a]=(0,_t.useState)(()=>Jt(e,r,n)),i=(0,wr.usePrevious)(o);return(0,_t.useLayoutEffect)(()=>{if(!e)return;function c(){a(Jt(e,r,n))}function u(){m.addEventListener("selectionchange",c)}function f(){m.removeEventListener("selectionchange",c)}let{ownerDocument:m}=e;return(e===m.activeElement||!i&&o||i&&!o)&&(a(Jt(e,r,n)),u()),e.addEventListener("focusin",u),e.addEventListener("focusout",f),()=>{f(),e.removeEventListener("focusin",u),e.removeEventListener("focusout",f)}},[e,r,n,o,i]),s}function An(){}return Or(Cn);})();