/*! This file is auto-generated */ (()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{store:()=>j});var n={};e.r(n),e.d(n,{__experimentalGetAllAnnotationsForBlock:()=>b,__experimentalGetAnnotations:()=>O,__experimentalGetAnnotationsForBlock:()=>T,__experimentalGetAnnotationsForRichText:()=>N});var r={};e.r(r),e.d(r,{__experimentalAddAnnotation:()=>U,__experimentalRemoveAnnotation:()=>F,__experimentalRemoveAnnotationsBySource:()=>V,__experimentalUpdateAnnotationRange:()=>G});const o=window.wp.richText,a=window.wp.i18n,i="core/annotations",l="core/annotation",s="annotation-text-";const c={name:l,title:(0,a.__)("Annotation"),tagName:"mark",className:"annotation-text",attributes:{className:"class",id:"id"},edit:()=>null,__experimentalGetPropsForEditableTreePreparation:(e,{richTextIdentifier:t,blockClientId:n})=>({annotations:e(i).__experimentalGetAnnotationsForRichText(n,t)}),__experimentalCreatePrepareEditableTree:({annotations:e})=>(t,n)=>{if(0===e.length)return t;let r={formats:t,text:n};return r=function(e,t=[]){return t.forEach((t=>{let{start:n,end:r}=t;n>e.text.length&&(n=e.text.length),r>e.text.length&&(r=e.text.length);const a=s+t.source,i=s+t.id;e=(0,o.applyFormat)(e,{type:l,attributes:{className:a,id:i}},n,r)})),e}(r,e),r.formats},__experimentalGetPropsForEditableTreeChangeHandler:e=>({removeAnnotation:e(i).__experimentalRemoveAnnotation,updateAnnotationRange:e(i).__experimentalUpdateAnnotationRange}),__experimentalCreateOnChangeEditableValue:e=>t=>{const n=function(e){const t={};return e.forEach(((e,n)=>{(e=(e=e||[]).filter((e=>e.type===l))).forEach((e=>{let{id:r}=e.attributes;r=r.replace(s,""),t.hasOwnProperty(r)||(t[r]={start:n}),t[r].end=n+1}))})),t}(t),{removeAnnotation:r,updateAnnotationRange:o,annotations:a}=e;!function(e,t,{removeAnnotation:n,updateAnnotationRange:r}){e.forEach((e=>{const o=t[e.id];if(!o)return void n(e.id);const{start:a,end:i}=e;a===o.start&&i===o.end||r(e.id,o.start,o.end)}))}(a,n,{removeAnnotation:r,updateAnnotationRange:o})}},{name:u,...d}=c;(0,o.registerFormatType)(u,d);const p=window.wp.hooks,f=window.wp.data;function m(e,t){const n=e.filter(t);return e.length===n.length?e:n}(0,p.addFilter)("editor.BlockListBlock","core/annotations",(e=>(0,f.withSelect)(((e,{clientId:t,className:n})=>({className:e(i).__experimentalGetAnnotationsForBlock(t).map((e=>"is-annotated-by-"+e.source)).concat(n).filter(Boolean).join(" ")})))(e)));const g=(e,t)=>Object.entries(e).reduce(((e,[n,r])=>({...e,[n]:t(r)})),{});const h=function(e={},t){var n;switch(t.type){case"ANNOTATION_ADD":const r=t.blockClientId,o={id:t.id,blockClientId:r,richTextIdentifier:t.richTextIdentifier,source:t.source,selector:t.selector,range:t.range};if("range"===o.selector&&!function(e){return"number"==typeof e.start&&"number"==typeof e.end&&e.start<=e.end}(o.range))return e;const a=null!==(n=e?.[r])&&void 0!==n?n:[];return{...e,[r]:[...a,o]};case"ANNOTATION_REMOVE":return g(e,(e=>m(e,(e=>e.id!==t.annotationId))));case"ANNOTATION_UPDATE_RANGE":return g(e,(e=>{let n=!1;const r=e.map((e=>e.id===t.annotationId?(n=!0,{...e,range:{start:t.start,end:t.end}}):e));return n?r:e}));case"ANNOTATION_REMOVE_SOURCE":return g(e,(e=>m(e,(e=>e.source!==t.source))))}return e};var v={};function _(e){return[e]}function A(e,t,n){var r;if(e.length!==t.length)return!1;for(r=n;r{var n;return(null!==(n=e?.[t])&&void 0!==n?n:[]).filter((e=>"block"===e.selector))}),((e,t)=>{var n;return[null!==(n=e?.[t])&&void 0!==n?n:x]}));function b(e,t){var n;return null!==(n=e?.[t])&&void 0!==n?n:x}const N=y(((e,t,n)=>{var r;return(null!==(r=e?.[t])&&void 0!==r?r:[]).filter((e=>"range"===e.selector&&n===e.richTextIdentifier)).map((e=>{const{range:t,...n}=e;return{...t,...n}}))}),((e,t)=>{var n;return[null!==(n=e?.[t])&&void 0!==n?n:x]}));function O(e){return Object.values(e).flat()}var w,I=new Uint8Array(16);function R(){if(!w&&!(w="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return w(I)}const E=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;const k=function(e){return"string"==typeof e&&E.test(e)};for(var C=[],D=0;D<256;++D)C.push((D+256).toString(16).substr(1));const S=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(C[e[t+0]]+C[e[t+1]]+C[e[t+2]]+C[e[t+3]]+"-"+C[e[t+4]]+C[e[t+5]]+"-"+C[e[t+6]]+C[e[t+7]]+"-"+C[e[t+8]]+C[e[t+9]]+"-"+C[e[t+10]]+C[e[t+11]]+C[e[t+12]]+C[e[t+13]]+C[e[t+14]]+C[e[t+15]]).toLowerCase();if(!k(n))throw TypeError("Stringified UUID is invalid");return n};const P=function(e,t,n){var r=(e=e||{}).random||(e.rng||R)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(var o=0;o<16;++o)t[n+o]=r[o];return t}return S(r)};function U({blockClientId:e,richTextIdentifier:t=null,range:n=null,selector:r="range",source:o="default",id:a=P()}){const i={type:"ANNOTATION_ADD",id:a,blockClientId:e,richTextIdentifier:t,source:o,selector:r};return"range"===r&&(i.range=n),i}function F(e){return{type:"ANNOTATION_REMOVE",annotationId:e}}function G(e,t,n){return{type:"ANNOTATION_UPDATE_RANGE",annotationId:e,start:t,end:n}}function V(e){return{type:"ANNOTATION_REMOVE_SOURCE",source:e}}const j=(0,f.createReduxStore)(i,{reducer:h,selectors:n,actions:r});(0,f.register)(j),(window.wp=window.wp||{}).annotations=t})();