1import{Children as Dt,Component as It,Fragment as Ot,Profiler as xt,PureComponent as Kt,StrictMode as At,Suspense as jt,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED as Pt,cloneElement as Tt,createContext as Lt,createElement as Mt,createFactory as Wt,createRef as Bt,forwardRef as Z,isValidElement as Vt,lazy as zt,memo as ue,startTransition as Nt,unstable_act as $t,useCallback as U,useContext as le,useDebugValue as Ut,useDeferredValue as Ft,useEffect as K,useId as qt,useImperativeHandle as Ht,useInsertionEffect as Jt,useLayoutEffect as Yt,useMemo as Gt,useReducer as Xt,useRef as S,useState as A,useSyncExternalStore as Qt,useTransition as Zt,version as en}from"../../../frontend-js-react-web/__liferay__/exports/react.js";import Ve from"../../../frontend-js-react-web/__liferay__/exports/react.js";var k=Ve;import{array as on,bool as sn,func as an,number as cn,object as un,string as ln,symbol as dn,any as fn,arrayOf as hn,element as mn,elementType as yn,instanceOf as gn,node as pn,objectOf as En,oneOf as bn,oneOfType as Cn,shape as wn,exact as _n,checkPropTypes as Rn,resetWarningCache as vn,PropTypes as kn}from"../../../frontend-js-react-web/__liferay__/exports/prop-types.js";import ze from"../../../frontend-js-react-web/__liferay__/exports/prop-types.js";var _=ze;function de(){let e={resolve:null,promise:null};return e.promise=new Promise(t=>{e.resolve=t}),e}function Ne(e,{timeOutAfter:t=500,retryAfter:n=100}={}){return new Promise((r,o)=>{let a=Date.now(),i=null,s=setTimeout(()=>{o(i??new Error("Timeout"))},t),c=async()=>{try{let d=await e();clearTimeout(s),r(d)}catch(d){i=d,Date.now()-a>t?o(d):setTimeout(c,n)}};c()})}var F=new Map;function fe(e,{attributes:t}={}){if(F.has(e))return F.get(e);let n=document.querySelector(`script[src="${e}"]`);n&&(console.warn(`Script with "${e}" src is already present in DOM!`),n.remove());let r=new Promise((o,a)=>{let i=document.createElement("script");i.onerror=a,i.onload=()=>{o()};for(let[c,d]of Object.entries(t||{}))i.setAttribute(c,d);i.setAttribute("data-injected-by","ckeditor-integration"),i.type="text/javascript",i.async=!0,i.src=e,document.head.appendChild(i);let s=new MutationObserver(c=>{c.flatMap(y=>Array.from(y.removedNodes)).includes(i)&&(F.delete(e),s.disconnect())});s.observe(document.head,{childList:!0,subtree:!0})});return F.set(e,r),r}async function he(e,t){await Promise.all(e.map(n=>fe(n,t)))}var q=new Map;function $e({href:e,placementInHead:t="start",attributes:n={}}){if(q.has(e))return q.get(e);let r=document.querySelector(`link[href="${e}"][rel="stylesheet"]`);r&&(console.warn(`Stylesheet with "${e}" href is already present in DOM!`),r.remove());let o=i=>{let s=Array.from(document.head.querySelectorAll('link[data-injected-by="ckeditor-integration"]'));switch(t){case"start":s.length?s.slice(-1)[0].after(i):document.head.insertBefore(i,document.head.firstChild);break;case"end":document.head.appendChild(i);break}},a=new Promise((i,s)=>{let c=document.createElement("link");for(let[y,R]of Object.entries(n||{}))c.setAttribute(y,R);c.setAttribute("data-injected-by","ckeditor-integration"),c.rel="stylesheet",c.href=e,c.onerror=s,c.onload=()=>{i()},o(c);let d=new MutationObserver(y=>{y.flatMap(v=>Array.from(v.removedNodes)).includes(c)&&(q.delete(e),d.disconnect())});d.observe(document.head,{childList:!0,subtree:!0})});return q.set(e,a),a}function me(){return typeof window>"u"}function ye(e){let t=null;return(...n)=>(t||(t={current:e(...n)}),t.current)}function ee(e,t){return t.length=0,t.push(...e),t}function B(e,t){for(let n of Object.getOwnPropertyNames(t))delete t[n];for(let[n,r]of Object.entries(e))r!==t&&n!=="prototype"&&n!=="__proto__"&&(t[n]=r);return t}function Ue(e,{attributes:t}={}){if(document.head.querySelector(`link[href="${e}"][rel="preload"]`))return;let n=document.createElement("link");for(let[r,o]of Object.entries(t||{}))n.setAttribute(r,o);n.setAttribute("data-injected-by","ckeditor-integration"),n.rel="preload",n.as=Fe(e),n.href=e,document.head.insertBefore(n,document.head.firstChild)}function Fe(e){switch(!0){case/\.css$/.test(e):return"style";case/\.js$/.test(e):return"script";default:return"fetch"}}function ge(e,t){if(e===t)return!0;
1if(!e||!t)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}var b=new Array(256).fill("").map((e,t)=>("0"+t.toString(16)).slice(-2));function H(){let[e,t,n,r]=crypto.getRandomValues(new Uint32Array(4));return"e"+b[e>>0&255]+b[e>>8&255]+b[e>>16&255]+b[e>>24&255]+b[t>>0&255]+b[t>>8&255]+b[t>>16&255]+b[t>>24&255]+b[n>>0&255]+b[n>>8&255]+b[n>>16&255]+b[n>>24&255]+b[r>>0&255]+b[r>>8&255]+b[r>>16&255]+b[r>>24&255]}function W(e){return Array.from(new Set(e))}async function J(e,t){let n=()=>e.map(r=>window[r]).filter(Boolean)[0];return Ne(()=>{let r=n();if(!r)throw new Error(`Window entry "${e.join(",")}" not found.`);return r},t)}function qe(e,t){let n=Object.entries(e).filter(([r,o])=>t(o,r));return Object.fromEntries(n)}function He(e){return qe(e,t=>t!=null)}function pe(e,t){let n=Object.entries(e).map(([r,o])=>[r,t(o,r)]);return Object.fromEntries(n)}function te(e,t){return t.filter(n=>!e.includes(n))}function ne(e){return!!e&&/^\d+\.\d+\.\d+/.test(e)}function Y(e){return e?["nightly","alpha","internal"].some(t=>e.includes(t)):!1}function Je(e){return ne(e)||Y(e)}function Ee(e){if(!ne(e))throw new Error(`Invalid semantic version: ${e||"<blank>"}.`);let[t,n,r]=e.split(".");return{major:Number.parseInt(t,10),minor:Number.parseInt(n,10),patch:Number.parseInt(r,10)}}function Ye(e){if(Y(e))return 3;let{major:t}=Ee(e);switch(!0){case t>=44:return 3;case t>=38:return 2;default:return 1}}function Ge(){let{CKEDITOR_VERSION:e,CKEDITOR:t}=window;return Je(e)?{source:t?"cdn":"npm",version:e}:null}var Xe="https://cdn.ckeditor.com";function be(e,t,n){return`${Xe}/${e}/${n}/${t}`}var Qe="https://cdn.ckbox.io";function Ze(e,t,n){return`${Qe}/${e}/${n}/${t}`}var et="https://ckeditor.com/docs/ckeditor5";function tt(e,t="latest"){return`${et}/${t}/${e}`}function nt({version:e,translations:t,createCustomCdnUrl:n=be}){let r={scripts:[n("ckeditor5","ckeditor5.umd.js",e),...te(["en"],t||[]).map(o=>n("ckeditor5",`translations/${o}.umd.js`,e))],stylesheets:[n("ckeditor5","ckeditor5.css",e)]};return{preload:[...r.stylesheets,...r.scripts],scripts:[async o=>he(r.scripts,o)],stylesheets:r.stylesheets,checkPluginLoaded:async()=>J(["CKEDITOR"]),beforeInject:()=>{let o=Ge();switch(o?.source){case"npm":throw new Error("CKEditor 5 is already loaded from npm. Check the migration guide for more details: "+tt("updating/migration-to-cdn/vanilla-js.html"));case"cdn":if(o.version!==e)throw new Error(`CKEditor 5 is already loaded from CDN in version ${o.version}. Remove the old <script> and <link> tags loading CKEditor 5 to allow loading the ${e} version.`);break}}}}function rt({version:e,translations:t,createCustomCdnUrl:n=be}){let r={scripts:[n("ckeditor5-premium-features","ckeditor5-premium-features.umd.js",e),...te(["en"],t||[]).map(o=>n("ckeditor5-premium-features",`translations/${o}.umd.js`,e))],stylesheets:[n("ckeditor5-premium-features","ckeditor5-premium-features.css",e)]};return{preload:[...r.stylesheets,...r.scripts],scripts:[async o=>he(r.scripts,o)],stylesheets:r.stylesheets,checkPluginLoaded:async()=>J(["CKEDITOR_PREMIUM_FEATURES"])}}async function ot(e){let{htmlAttributes:t={},scripts:n=[],stylesheets:r=[],preload:o,beforeInject:a,checkPluginLoaded:i}=re(e);a?.(),o||(o=W([...r.filter(s=>typeof s=="string"),...n.filter(s=>typeof s=="string")]));for(let s of o)Ue(s,{attributes:t});await Promise.all(W(r).map(s=>$e({href:s,attributes:t,placementInHead:"start"})));for(let s of W(n)){let c={attributes:t};typeof s=="string"?await fe(s,c):await s(c)}return i?.()}function re(e){return Array.isArray(e)?{scripts:e.filter(t=>typeof t=="function"||t.endsWith(".js")),stylesheets:e.filter(t=>t.endsWith(".css"))}:typeof e=="function"?{checkPluginLoaded:e}:e}function Ce(e){let t=pe(He(e),re);return{...Object.values(t).reduce((a,i)=>(a.scripts.push(...i.scripts??[]),a.stylesheets.push(...i.stylesheets??[]),a.preload.push(...i.preload??[]),a),{preload:[],scripts:[],stylesheets:[]}),beforeInject:()=>{for(let a of Object.values(t))a.beforeInject?.()},checkPluginLoaded:async()=>{let a=Object.create(null);for(let[i,s]of Object.entries(t))a[i]=await s?.checkPluginLoaded?.();return a}}}function it(){let e=window.CKBox?.version;return ne(e)?{source:"cdn",version:e}:null}function st({version:e,theme:t="lark",translations:n,createCustomCdnUrl:r=Ze}){return{scripts:[r("ckbox","ckbox.js",e),...te(["en"],n||[]).map(o=>r("ckbox",`translations/${o}.js`,e))],...t&&{stylesheets:[r("ckbox",`styles/themes/${t}.css`,e)]},checkPluginLoaded:async()=>J(["CKBox"]),beforeInject:()=>{let o=it();if(o&&o.version!==e)throw new Error(`CKBox is already loaded from CDN in version ${o.version}. Remove the old <script> and <link> tags loading CKBox to allow loading the ${e} version.`)}}}function at(e){if(Y(e))return!0;let{major:t}=Ee(e);switch(Ye(e)){case 3:return!0;default:return t===43}}function ct(e){let t=pe(e,(n,r)=>{if(!n)return;let o=re(n);return{checkPluginLoaded:async()=>J([r]),...o}});return Ce(t)}function G(e){let{version:t,translations:n,plugins:r,premium:o,ckbox:a,createCustomCdnUrl:i,injectedHtmlElementsAttributes:s={crossorigin:"anonymous"}}=e;ut(t);let c=Ce({CKEditor:nt({version:t,translations:n,createCustomCdnUrl:i}),...o&&{CKEditorPremiumFeatures:rt({version:t,translations:n,createCustomCdnUrl:i})},...a&&{CKBox:st(a)},loadedPlugins:ct(r??{})});return ot({...c,htmlAttributes:s})}function ut(e){if(Y(e)&&console.warn("You are using a testing version of CKEditor 5. Please remember that it is not suitable for production environments."),!at(e))throw new Error(`The CKEditor 5 CDN can't be used with the given editor version: ${e}. Please make sure you are using at least the CKEditor 5 version 44.`)}
1var lt=Object.defineProperty,dt=(e,t,n)=>t in e?lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,C=(e,t,n)=>dt(e,typeof t!="symbol"?t+"":t,n);var Re=class ve{constructor(t,n){C(this,"_lifecycle"),C(this,"_element"),C(this,"_releaseLock",null),C(this,"_value",null),C(this,"_afterMountCallbacks",[]),C(this,"_state",{destroyedBeforeInitialization:!1,mountingInProgress:null}),C(this,"release",ye(()=>{let{_releaseLock:r,_state:o,_element:a,_lifecycle:i}=this;o.mountingInProgress?o.mountingInProgress.then(()=>i.unmount({element:a,mountResult:this.value})).catch(s=>{console.error("Semaphore unmounting error:",s)}).then(r.resolve).then(()=>{this._value=null}):(o.destroyedBeforeInitialization=!0,r.resolve())})),this._element=t,this._lifecycle=n,this._lock()}get value(){return this._value}unsafeSetValue(t){this._value=t,this._afterMountCallbacks.forEach(n=>n(t)),this._afterMountCallbacks=[]}runAfterMount(t){let{_value:n,_afterMountCallbacks:r}=this;n?t(n):r.push(t)}_lock(){let{_semaphores:t}=ve,{_state:n,_element:r,_lifecycle:o}=this,a=t.get(r)||Promise.resolve(null),i=de();this._releaseLock=i;let s=a.then(()=>n.destroyedBeforeInitialization?Promise.resolve(void 0):(n.mountingInProgress=o.mount().then(c=>(c&&this.unsafeSetValue(c),c)),n.mountingInProgress)).then(async c=>{c&&o.afterMount&&await o.afterMount({element:r,mountResult:c})}).then(()=>i.promise).catch(c=>{console.error("Semaphore mounting error:",c)}).then(()=>{t.get(r)===s&&t.delete(r)});t.set(r,s)}};C(Re,"_semaphores",new Map);var ke=Re;var Se="$__CKEditorReactContextMetadata";function ft(e,t){return{...t,[Se]:e}}function ht(e){return e.get(Se)}var mt=()=>{let e=S(!1);return K(()=>(e.current=!0,()=>{e.current=!1}),[]),e};var T=e=>{let t=S();return t.current=e,U((...n)=>t.current(...n),[])};var yt=({currentContextWatchdog:e,onChangeInitializedEditors:t})=>{let n=T(t||(()=>{}));K(()=>{var r;if(e.status!=="initialized")return;let{watchdog:o}=e,a=(r=o?.context)==null?void 0:r.editors;if(!a)return;let i=()=>[...a].reduce((d,y)=>{var R;if(y.state!=="ready")return d;let v=ht(y.config),D=(R=v?.name)!=null?R:y.id;return d[D]={instance:y,metadata:v},d},Object.create({})),s=()=>{n(i(),o)},c=(d,y)=>{y.once("ready",s,{priority:"lowest"}),y.once("destroy",s,{priority:"lowest"})};return a.on("add",c),()=>{a.off("add",c)}},[e])};var ae=k.createContext(null),gt=e=>{let{id:t,context:n,watchdogConfig:r,children:o,config:a,onReady:i,contextWatchdog:s,isLayoutReady:c=!0,onChangeInitializedEditors:d,onError:y=(I,w)=>console.error(I,w)}=e,R=mt(),v=S(null),[D,L]=A({status:"initializing"});K(()=>{c?z():L({status:"initializing"})},[t,c]),K(()=>()=>{D.status==="initialized"&&D.watchdog.destroy()},[D]),yt({currentContextWatchdog:D,onChangeInitializedEditors:d});function Q(){return v.current=H(),v.current}function j(I){return v.current===I&&R.current}function z(){let I=Q(),w=new s(n,r);return w.on("error",(M,N)=>{j(I)&&y(N.error,{phase:"runtime",willContextRestart:N.causesRestart})}),w.on("stateChange",()=>{i&&w.state==="ready"&&j(I)&&i(w.context,w)}),w.create(a).then(()=>{j(I)?L({status:"initialized",watchdog:w}):w.destroy()}).catch(M=>{j(I)&&(y(M,{phase:"initialization",willContextRestart:!1}),L({status:"error",error:M}))}),w}return k.createElement(ae.Provider,{value:D},o)},pt=e=>!!e&&typeof e=="object"&&"status"in e&&["initializing","initialized","error"].includes(e.status),De=e=>t=>pt(t)&&t.status===e,we=De("initializing"),se=e=>De("initialized")(e)&&e.watchdog.state==="ready";var oe="Lock from React integration (@ckeditor/ckeditor5-react)",V=class extends k.Component{constructor(t){super(t),C(this,"domContainer",k.createRef()),C(this,"editorSemaphore",null),this._checkVersion()}_checkVersion(){let{CKEDITOR_VERSION:t}=window;if(!t)return console.warn('Cannot find the "CKEDITOR_VERSION" in the "window" scope.');let[n]=t.split(".").map(Number);n>=42||t.startsWith("0.0.0")||console.warn("The <CKEditor> component requires using CKEditor 5 in version 42+ or nightly build.")}get _semaphoreValue(){let{editorSemaphore:t}=this;return t?t.value:null}get watchdog(){let{_semaphoreValue:t}=this;return t?t.watchdog:null}get editor(){let{_semaphoreValue:t}=this;return t?t.instance:null}shouldComponentUpdate(t){let{props:n,editorSemaphore:r}=this;return t.id!==n.id||t.disableWatchdog!==n.disableWatchdog?!0:(r&&(r.runAfterMount(({instance:o})=>{this._shouldUpdateEditorData(n,t,o)&&o.data.set(t.data)}),"disabled"in t&&r.runAfterMount(({instance:o})=>{t.disabled?o.enableReadOnlyMode(oe):o.disableReadOnlyMode(oe)}
1)),!1)}componentDidMount(){we(this.context)||this._initLifeCycleSemaphore()}componentDidUpdate(){we(this.context)||this._initLifeCycleSemaphore()}componentWillUnmount(){this._unlockLifeCycleSemaphore()}_unlockLifeCycleSemaphore(){this.editorSemaphore&&(this.editorSemaphore.release(),this.editorSemaphore=null)}_initLifeCycleSemaphore(){this._unlockLifeCycleSemaphore(),this.editorSemaphore=new ke(this.domContainer.current,{mount:async()=>this._initializeEditor(),afterMount:({mountResult:t})=>{let{onReady:n}=this.props;n&&this.domContainer.current!==null&&n(t.instance)},unmount:async({element:t,mountResult:n})=>{let{onAfterDestroy:r}=this.props;try{await this._destroyEditor(n),t.innerHTML=""}finally{r&&r(n.instance)}}})}render(){return k.createElement("div",{ref:this.domContainer})}async _initializeEditor(){if(this.props.disableWatchdog)return{instance:await this._createEditor(this.domContainer.current,this._getConfig()),watchdog:null};let t=se(this.context)?new X(this.context.watchdog):new this.props.editor.EditorWatchdog(this.props.editor,this.props.watchdogConfig),n={current:0};return t.setCreator(async(r,o)=>{var a;let{editorSemaphore:i}=this,{onAfterDestroy:s}=this.props;n.current>0&&s&&((a=i?.value)!=null&&a.instance)&&s(i.value.instance);let c=await this._createEditor(r,o);return i&&n.current>0&&(i.unsafeSetValue({instance:c,watchdog:t}),setTimeout(()=>{this.props.onReady&&this.props.onReady(t.editor)})),n.current++,c}),t.on("error",(r,{error:o,causesRestart:a})=>{(this.props.onError||console.error)(o,{phase:"runtime",willEditorRestart:a})}),await t.create(this.domContainer.current,this._getConfig()).catch(r=>{(this.props.onError||console.error)(r,{phase:"initialization",willEditorRestart:!1})}),{watchdog:t,instance:t.editor}}_createEditor(t,n){let{contextItemMetadata:r}=this.props;return r&&(n=ft(r,n)),this.props.editor.create(t,n).then(o=>{if("disabled"in this.props){this.props.disabled&&o.enableReadOnlyMode(oe)}let a=o.model.document,i=o.editing.view.document;return a.on("change:data",s=>{this.props.onChange&&this.props.onChange(s,o)}),i.on("focus",s=>{this.props.onFocus&&this.props.onFocus(s,o)}),i.on("blur",s=>{this.props.onBlur&&this.props.onBlur(s,o)}),o})}async _destroyEditor(t){let{watchdog:n,instance:r}=t;return new Promise((o,a)=>{setTimeout(async()=>{try{if(n)return await n.destroy(),o();if(r)return await r.destroy(),o();o()}catch(i){console.error(i),a(i)}})})}_shouldUpdateEditorData(t,n,r){return!(t.data===n.data||r.data.get()===n.data)}_getConfig(){let t=this.props.config||{};return this.props.data&&t.initialData&&console.warn("Editor data should be provided either using `config.initialData` or `content` property. The config value takes precedence over `content` property and will be used when both are specified."),{...t,initialData:t.initialData||this.props.data||""}}};C(V,"contextType",ae);C(V,"propTypes",{editor:_.func.isRequired,data:_.string,config:_.object,disableWatchdog:_.bool,watchdogConfig:_.object,onChange:_.func,onReady:_.func,onFocus:_.func,onBlur:_.func,onError:_.func,disabled:_.bool,id:_.any});var X=class{constructor(t){C(this,"_contextWatchdog"),C(this,"_id"),C(this,"_creator"),this._contextWatchdog=t,this._id=H()}setCreator(t){this._creator=t}create(t,n){return this._contextWatchdog.add({sourceElementOrData:t,config:n,creator:this._creator,id:this._id,type:"editor"})}on(t,n){this._contextWatchdog.on("itemError",(r,{itemId:o,error:a})=>{o===this._id&&n(null,{error:a,causesRestart:void 0})})}destroy(){return this._contextWatchdog.state==="ready"?this._contextWatchdog.remove(this._id):Promise.resolve()}get editor(){return this._contextWatchdog.getItem(this._id)}};var Et=()=>{let e=S(null),[t,n]=A(()=>Date.now()),r=()=>{n(Date.now())},o=(d=!0)=>{e.current&&(e.current.release(),e.current=null),d&&n(Date.now())},a=d=>{var y;(y=e.current)==null||y.unsafeSetValue(d),r()},i=d=>{e.current&&e.current.runAfterMount(d)};return{get current(){return e.current},revision:t,createAttributeRef:d=>({get current(){return!e.current||!e.current.value?null:e.current.value[d]}}),unsafeSetValue:a,release:o,replace:d=>{o(!1),e.current=d(),r(),i(r)},runAfterMount:i}};function Ie(...e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var Oe=(e,t)=>
1{let[n,r]=A(null);ge(n,t)||(e(),r([...t]))};var _e=(e,t,n)=>{Oe(()=>{e&&e.runAfterMount(t)},[e,...n])};var ie="Lock from React integration (@ckeditor/ckeditor5-react)",bt=e=>{let t=S(e.semaphoreElement||null),n=Et(),r={watchdog:n.createAttributeRef("watchdog"),instance:n.createAttributeRef("instance")},o=le(ae),[a,i]=A(()=>Object.keys(e.data)),[s,c]=A({...e.data}),[d,y]=A({...e.rootsAttributes}),R=S(!0),v=()=>{let u=r.instance.current;if(!u)return;let g=l=>{l.name&&!u.editing.view.getDomRoot(l.name)&&u.editing.view.attachDomRoot(document.createElement("div"),l.name)};Object.values(u.ui.view.editables).forEach(g)};K(()=>{let u=t.current;if(!(o&&!se(o))&&!(!u||e.isLayoutReady===!1))return n.replace(()=>new ke(u,{mount:w,afterMount:({mountResult:g})=>{let{onReady:l}=e;l&&t.current!==null&&l(g.instance)},unmount:async({element:g,mountResult:l})=>{let{onAfterDestroy:f}=e;try{await I(l),g.innerHTML=""}finally{f&&f(l.instance)}}})),()=>{v(),n.release(!1)}},[e.id,e.isLayoutReady,o?.status]);let D=()=>{let u=e.config||{};return e.data&&u.initialData&&console.warn("Editor data should be provided either using `config.initialData` or `data` property. The config value takes precedence over `data` property and will be used when both are specified."),{...u,rootsAttributes:d}},L=T((u,g)=>{let l=u.model.document;if(!e.disableTwoWayDataBinding){let f={},h={};
1l.differ.getChanges().forEach(m=>{let p;if(m.type=="insert"||m.type=="remove"?p=m.position.root:p=m.range.root,!p.isAttached())return;let{rootName:O}=p;f[O]=u.getData({rootName:O})}),l.differ.getChangedRoots().forEach(m=>{if(m.state){f[m.name]!==void 0&&delete f[m.name];return}let p=m.name;h[p]=u.getRootAttributes(p)}),Object.keys(f).length&&c(m=>({...m,...f})),Object.keys(h).length&&y(m=>({...m,...h}))}e.onChange&&e.onChange(g,u)}),Q=T((u,g,l)=>{let f=l.rootName;e.disableTwoWayDataBinding||(c(h=>({...h,[f]:u.getData({rootName:f})})),y(h=>({...h,[f]:u.getRootAttributes(f)}))),i(h=>W([...h,l.rootName]))}),j=T((u,g,l)=>{let f=l.rootName;e.disableTwoWayDataBinding||(c(h=>{let{[f]:m,...p}=h;return{...p}}),y(h=>{let{[f]:m,...p}=h;return{...p}})),i(h=>h.filter(m=>m!==f))}),z=T((u,g)=>(B({...e.rootsAttributes},d),B({...e.data},s),ee(Object.keys(e.data),a),e.editor.create(u,g).then(l=>{let f=l.getFullData();if(B({...f},s),B({...l.getRootsAttributes()},d),ee(Object.keys(f),a),e.disabled){l.enableReadOnlyMode(ie)}let h=l.model.document,m=l.editing.view.document;return h.on("change:data",p=>L(l,p)),l.on("addRoot",(p,O)=>Q(l,p,O)),l.on("detachRoot",(p,O)=>j(l,p,O)),m.on("focus",p=>{e.onFocus&&e.onFocus(p,l)}),m.on("blur",p=>{e.onBlur&&e.onBlur(p,l)}),l}
1))),I=u=>{let{watchdog:g,instance:l}=u;return new Promise((f,h)=>{setTimeout(async()=>{try{if(g)return await g.destroy(),f();if(l)return await l.destroy(),f();f()}catch(m){console.error(m),h(m)}})})},w=async()=>{if(e.disableWatchdog)return{instance:await z(e.data,D()),watchdog:null};let u=se(o)?new X(o.watchdog):new e.editor.EditorWatchdog(e.editor,e.watchdogConfig),g={current:0};return u.setCreator(async(l,f)=>{let{onAfterDestroy:h}=e;g.current>0&&h&&r.instance.current&&h(r.instance.current);let m=await z(s,f);return g.current>0&&(n.unsafeSetValue({instance:m,watchdog:u}),setTimeout(()=>{e.onReady&&e.onReady(u.editor)})),g.current++,m}),u.on("error",(l,{error:f,causesRestart:h})=>{(e.onError||console.error)(f,{phase:"runtime",willEditorRestart:h})}),await u.create(s,D()).catch(l=>{throw(e.onError||console.error)(l,{phase:"initialization",willEditorRestart:!1}),l}),{watchdog:u,instance:u.editor}},M=(u,g)=>{let l=Object.keys(u),f=Object.keys(g);return{addedKeys:f.filter(h=>!l.includes(h)),removedKeys:l.filter(h=>!f.includes(h))}},N=U(u=>{n.runAfterMount(()=>{R.current=!0,c(u)})},[c]),je=U(u=>{n.runAfterMount(()=>{R.current=!0,y(u)})},[y]),Pe=k.createElement(Ke,{ref:t,editor:r.instance.current});_e(n.current,({instance:u})=>{e.disabled?u.enableReadOnlyMode(ie):u.disableReadOnlyMode(ie)},[e.disabled]),_e(n.current,({instance:u})=>{if(R.current){R.current=!1;let g=Object.keys(s),l=Object.keys(d);if(!g.every(E=>l.includes(E)))throw console.error("`data` and `attributes` objects must have the same keys (roots)."),new Error("`data` and `attributes` objects must have the same keys (roots).");let f=u.getFullData(),h=u.getRootsAttributes(),{addedKeys:m,removedKeys:p}=M(f,s||{}),O=g.filter(E=>f[E]!==void 0&&JSON.stringify(f[E])!==JSON.stringify(s[E])),ce=l.filter(E=>JSON.stringify(h[E])!==JSON.stringify(d[E])),Le=E=>{E.forEach(x=>{u.addRoot(x,{data:s[x]||"",attributes:d?.[x]||{},isUndoable:!0})})},Me=E=>{E.forEach(x=>{u.detachRoot(x,!0)})},We=E=>{let x=E.reduce((P,$)=>({...P,[$]:s[$]}),Object.create(null));u.data.set(x,{suppressErrorInCollaboration:!0})},Be=(E,x)=>{x.forEach(P=>{Object.keys(d[P]).forEach($=>{u.registerRootAttribute($)}),E.clearAttributes(u.model.document.getRoot(P)),E.setAttributes(d[P],u.model.document.getRoot(P))})};setTimeout(()=>{u.model.change(E=>{Le(m),Me(p),O.length&&We(O),ce.length&&Be(E,ce)})})}},[s,d]);let Te=a.map(u=>k.createElement(xe,{key:u,id:u,rootName:u,semaphore:n}));return{editor:r.instance.current,editableElements:Te,toolbarElement:Pe,data:s,setData:N,attributes:d,setAttributes:je}},xe=ue(Z(({id:e,semaphore:t,rootName:n},r)=>{let o=S(null);return K(()=>{let a,i;return t.runAfterMount(({instance:s})=>{if(!o.current)return;i=s;let{ui:c,model:d}=i,y=d.document.getRoot(n);y&&i.ui.getEditableElement(n)&&i.detachEditable(y),a=c.view.createEditable(n,o.current),c.addEditable(a),s.editing.view.forceRender()}),()=>{if(i&&i.state!=="destroyed"&&o.current){let s=i.model.document.getRoot(n);s&&i.detachEditable(s)}}},[t.revision]),k.createElement("div",{key:t.revision,id:e,ref:Ie(r,o)})}));xe.displayName="EditorEditable";var Ke=Z(({editor:e},t)=>{let n=S(null);return K(()=>{let r=n.current;if(!e||!r)return;let o=e.ui.view.toolbar.element;return r.appendChild(o),()=>{r.contains(o)&&r.removeChild(o)}},[e&&e.id]),k.createElement("div",{ref:Ie(n,t)})});Ke.displayName="EditorToolbarWrapper";var Ct=()=>{let e=S(!1);return K(()=>(e.current=!1,()=>{e.current=!0}),[]),e};var wt=e=>{let[t,n]=A({status:"idle"}),r=Ct(),o=S(null);return[T(async(...i)=>{if(r.current||me())return null;let s=H();o.current=s;try{t.status!=="loading"&&n({status:"loading"});let c=await e(...i);return!r.current&&o.current===s&&n({status:"success",data:c}),c}catch(c){console.error(c),!r.current&&o.current===s&&n({status:"error",error:c})}return null}),t]};var _t=(e,t)=>{let[n,r]=wt(e);return Oe(n,t),r.status==="idle"?{status:"loading"}:r};function Ae(e){let t=JSON.stringify(e),n=_t(async()=>G(e),[t]);return n.status==="success"?{...n.data,status:"success"}:n}var Rt=e=>t=>{let n=r=>{var o,a;let i=Ae(e.cloud);switch(i.status){case"error":return e.renderError?e.renderError(i.error):"Unable to load CKEditor Cloud data!";case"success":return k.createElement(t,{...r,cloud:i});default:return(a=(o=e.renderLoader)==null?void 0:o.call(e))!=null?a:null}};return n.displayName="ComponentWithCKEditorCloud",n};export{V as CKEditor,gt as CKEditorContext,G as loadCKEditorCloud,Ae as useCKEditorCloud,bt as useMultiRootEditor,Rt as withCKEditorCloud}; 2/*! Bundled license information: 3 4@ckeditor/ckeditor5-integrations-common/dist/index.js: 5 (** 6 * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. 7 * For licensing, see LICENSE.md. 8 *) 9 10@ckeditor/ckeditor5-integrations-common/dist/index.js: 11 (** 12 * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. 13 * For licensing, see LICENSE.md. 14 *) 15 16@ckeditor/ckeditor5-integrations-common/dist/index.js: 17 (** 18 * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. 19 * For licensing, see LICENSE.md. 20 *) 21 22@ckeditor/ckeditor5-integrations-common/dist/index.js: 23 (** 24 * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. 25 * For licensing, see LICENSE.md. 26 *) 27 28@ckeditor/ckeditor5-integrations-common/dist/index.js: 29 (** 30 * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. 31 * For licensing, see LICENSE.md. 32 *) 33 34@ckeditor/ckeditor5-react/dist/index.js: 35 (** 36 * @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. 37 * For licensing, see LICENSE.md. 38 *) 39 (* istanbul ignore else -- @preserve *)
40 (* istanbul ignore next -- @preserve *) 41*/ 42//# sourceMappingURL=@ckeditor$ckeditor5-react.(4TUX2MN7).js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.