@solibo/solibo-ui 2.1.1 → 2.1.2

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.
@@ -1 +1 @@
1
- ._object_xxgm1_1{height:100dvh;width:100%}
1
+ ._object_18i7r_1{display:block;height:100%;width:100%}
@@ -52,5 +52,5 @@ vulnerable to XSS attacks. Please remove it from \`allowedTags\`.
52
52
  Or, to disable this warning, add the \`allowVulnerableTags\` option
53
53
  and ensure you are accounting for this risk.
54
54
 
55
- `)});const u=e.nonTextTags||["script","style","textarea","option"];let a,l;e.allowedAttributes&&(a={},l={},xr(e.allowedAttributes,function(w,L){a[L]=[];const I=[];w.forEach(function(U){typeof U=="string"&&U.indexOf("*")>=0?I.push(zd(U).replace(/\\\*/g,".*")):a[L].push(U)}),I.length&&(l[L]=new RegExp("^("+I.join("|")+")$"))}));const c={},h={},f={};xr(e.allowedClasses,function(w,L){if(a&&(Yt(a,L)||(a[L]=[]),a[L].push("class")),c[L]=w,Array.isArray(w)){const I=[];c[L]=[],f[L]=[],w.forEach(function(U){typeof U=="string"&&U.indexOf("*")>=0?I.push(zd(U).replace(/\\\*/g,".*")):U instanceof RegExp?f[L].push(U):c[L].push(U)}),I.length&&(h[L]=new RegExp("^("+I.join("|")+")$"))}});const d={};let g;xr(e.transformTags,function(w,L){let I;typeof w=="function"?I=w:typeof w=="string"&&(I=Wi.simpleTransform(w)),L==="*"?g=I:d[L]=I});let b,m,p,y,_,x,S=!1;A();const C=new C3.Parser({onopentag:function(w,L){if(e.onOpenTag&&e.onOpenTag(w,L),e.enforceHtmlBoundary&&w==="html"&&A(),_){x++;return}const I=new s(w,L);m.push(I);let U=!1;const H=!!I.text;let V;if(Yt(d,w)&&(V=d[w](w,L),I.attribs=L=V.attribs,V.text!==void 0&&(I.innerText=V.text),w!==V.tagName&&(I.name=w=V.tagName,y[b]=V.tagName)),g&&(V=g(w,L),I.attribs=L=V.attribs,w!==V.tagName&&(I.name=w=V.tagName,y[b]=V.tagName)),(!o(w)||e.disallowedTagsMode==="recursiveEscape"&&!O3(p)||e.nestingLimit!=null&&b>=e.nestingLimit)&&(U=!0,p[b]=!0,(e.disallowedTagsMode==="discard"||e.disallowedTagsMode==="completelyDiscard")&&u.indexOf(w)!==-1&&(_=!0,x=1)),b++,U){if(e.disallowedTagsMode==="discard"||e.disallowedTagsMode==="completelyDiscard"){if(I.innerText&&!H){const j=O(I.innerText);e.textFilter?r+=e.textFilter(j,w):r+=j,S=!0}return}i=r,r=""}r+="<"+w,w==="script"&&(e.allowedScriptHostnames||e.allowedScriptDomains)&&(I.innerText=""),U&&(e.disallowedTagsMode==="escape"||e.disallowedTagsMode==="recursiveEscape")&&e.preserveEscapedAttributes?xr(L,function(j,$){r+=" "+$+'="'+O(j||"",!0)+'"'}):(!a||Yt(a,w)||a["*"])&&xr(L,function(j,$){if(!I3.test($)){delete I.attribs[$];return}if(j===""&&!e.allowedEmptyAttributes.includes($)&&(e.nonBooleanAttributes.includes($)||e.nonBooleanAttributes.includes("*"))){delete I.attribs[$];return}let G=!1;if(!a||Yt(a,w)&&a[w].indexOf($)!==-1||a["*"]&&a["*"].indexOf($)!==-1||Yt(l,w)&&l[w].test($)||l["*"]&&l["*"].test($))G=!0;else if(a&&a[w]){for(const X of a[w])if(T3(X)&&X.name&&X.name===$){G=!0;let Z="";if(X.multiple===!0){const Ce=j.split(" ");for(const Ae of Ce)X.values.indexOf(Ae)!==-1&&(Z===""?Z=Ae:Z+=" "+Ae)}else X.values.indexOf(j)>=0&&(Z=j);j=Z}}if(G){if(e.allowedSchemesAppliedToAttributes.indexOf($)!==-1&&D(w,j)){delete I.attribs[$];return}if(w==="script"&&$==="src"){let X=!0;try{const Z=k(j);if(e.allowedScriptHostnames||e.allowedScriptDomains){const Ce=(e.allowedScriptHostnames||[]).find(function(ve){return ve===Z.url.hostname}),Ae=(e.allowedScriptDomains||[]).find(function(ve){return Z.url.hostname===ve||Z.url.hostname.endsWith(`.${ve}`)});X=Ce||Ae}}catch{X=!1}if(!X){delete I.attribs[$];return}}if(w==="iframe"&&$==="src"){let X=!0;try{const Z=k(j);if(Z.isRelativeUrl)X=Yt(e,"allowIframeRelativeUrls")?e.allowIframeRelativeUrls:!e.allowedIframeHostnames&&!e.allowedIframeDomains;else if(e.allowedIframeHostnames||e.allowedIframeDomains){const Ce=(e.allowedIframeHostnames||[]).find(function(ve){return ve===Z.url.hostname}),Ae=(e.allowedIframeDomains||[]).find(function(ve){return Z.url.hostname===ve||Z.url.hostname.endsWith(`.${ve}`)});X=Ce||Ae}}catch{X=!1}if(!X){delete I.attribs[$];return}}if($==="srcset")try{let X=E3(j);if(X.forEach(function(Z){D("srcset",Z.url)&&(Z.evil=!0)}),X=Kd(X,function(Z){return!Z.evil}),X.length)j=D3(Kd(X,function(Z){return!Z.evil})),I.attribs[$]=j;else{delete I.attribs[$];return}}catch{delete I.attribs[$];return}if($==="class"){const X=c[w],Z=c["*"],Ce=h[w],Ae=f[w],ve=f["*"],ii=h["*"],dn=[Ce,ii].concat(Ae,ve).filter(function(hn){return hn});if(X&&Z?j=R(j,qd(X,Z),dn):j=R(j,X||Z,dn),!j.length){delete I.attribs[$];return}}if($==="style"){if(e.parseStyleAttributes)try{const X=N3(w+" {"+j+"}",{map:!1}),Z=v(X,e.allowedStyles);if(j=E(Z),j.length===0){delete I.attribs[$];return}}catch{typeof window<"u"&&console.warn('Failed to parse "'+w+" {"+j+`}", If you're running this in a browser, we recommend to disable style parsing: options.parseStyleAttributes: false, since this only works in a node environment due to a postcss dependency, More info: https://github.com/apostrophecms/sanitize-html/issues/547`),delete I.attribs[$];return}else if(e.allowedStyles)throw new Error("allowedStyles option cannot be used together with parseStyleAttributes: false.")}r+=" "+$,j&&j.length?r+='="'+O(j,!0)+'"':e.allowedEmptyAttributes.includes($)&&(r+='=""')}else delete I.attribs[$]}),e.selfClosing.indexOf(w)!==-1?r+=" />":(r+=">",I.innerText&&!H&&!e.textFilter&&(r+=O(I.innerText),S=!0)),U&&(r=i+O(r),i=""),I.openingTagLength=r.length-I.tagPosition},ontext:function(w){if(_)return;const L=m[m.length-1];let I;if(L&&(I=L.tag,w=L.innerText!==void 0?L.innerText:w),e.disallowedTagsMode==="completelyDiscard"&&!o(I))w="";else if((e.disallowedTagsMode==="discard"||e.disallowedTagsMode==="completelyDiscard")&&(I==="script"||I==="style"))r+=w;else if(!S){const U=O(w,!1);e.textFilter?r+=e.textFilter(U,I):r+=U}if(m.length){const U=m[m.length-1];U.text+=w}},onclosetag:function(w,L){if(e.onCloseTag&&e.onCloseTag(w,L),_)if(x--,!x)_=!1;else return;const I=m.pop();if(!I)return;if(I.tag!==w){m.push(I);return}_=e.enforceHtmlBoundary?w==="html":!1,b--;const U=p[b];if(U){if(delete p[b],e.disallowedTagsMode==="discard"||e.disallowedTagsMode==="completelyDiscard"){I.updateParentNodeText();return}i=r,r=""}if(y[b]&&(w=y[b],delete y[b]),e.exclusiveFilter){const H=e.exclusiveFilter(I);if(H==="excludeTag"){U&&(r=i,i=""),r=r.substring(0,I.tagPosition)+r.substring(I.tagPosition+I.openingTagLength);return}else if(H){r=r.substring(0,I.tagPosition);return}}if(I.updateParentNodeMediaChildren(),I.updateParentNodeText(),e.selfClosing.indexOf(w)!==-1||L&&!o(w)&&["escape","recursiveEscape"].indexOf(e.disallowedTagsMode)>=0){U&&(r=i,i="");return}r+="</"+w+">",U&&(r=i+O(r),i=""),S=!1}},e.parser);if(C.write(n),C.end(),e.disallowedTagsMode==="escape"||e.disallowedTagsMode==="recursiveEscape"){const w=C.endIndex;if(w!=null&&w>=0&&w<n.length){const L=n.substring(w);r+=O(L)}else(w==null||w<0)&&n.length>0&&r===""&&(r=O(n))}return r;function A(){r="",b=0,m=[],p={},y={},_=!1,x=0}function O(w,L){return typeof w!="string"&&(w=w+""),e.parser.decodeEntities&&(w=w.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),L&&(w=w.replace(/"/g,"&quot;"))),w=w.replace(/&(?![a-zA-Z0-9#]{1,20};)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),L&&(w=w.replace(/"/g,"&quot;")),w}function D(w,L){for(L=L.replace(/[\x00-\x20]+/g,"");;){const H=L.indexOf("<!--");if(H===-1)break;const V=L.indexOf("-->",H+4);if(V===-1)break;L=L.substring(0,H)+L.substring(V+3)}const I=L.match(/^([a-zA-Z][a-zA-Z0-9.\-+]*):/);if(!I)return L.match(/^[/\\]{2}/)?!e.allowProtocolRelative:!1;const U=I[1].toLowerCase();return Yt(e.allowedSchemesByTag,w)?e.allowedSchemesByTag[w].indexOf(U)===-1:!e.allowedSchemes||e.allowedSchemes.indexOf(U)===-1}function k(w){if(w=w.replace(/^(\w+:)?\s*[\\/]\s*[\\/]/,"$1//"),w.startsWith("relative:"))throw new Error("relative: exploit attempt");let L="relative://relative-site";for(let H=0;H<100;H++)L+=`/${H}`;const I=new URL(w,L);return{isRelativeUrl:I&&I.hostname==="relative-site"&&I.protocol==="relative:",url:I}}function v(w,L){if(!L)return w;const I=w.nodes[0];let U;return L[I.selector]&&L["*"]?U=qd(L[I.selector],L["*"]):U=L[I.selector]||L["*"],U&&(w.nodes[0].nodes=I.nodes.reduce(N(U),[])),w}function E(w){return w.nodes[0].nodes.reduce(function(L,I){return L.push(`${I.prop}:${I.value}${I.important?" !important":""}`),L},[]).join(";")}function N(w){return function(L,I){return Yt(w,I.prop)&&w[I.prop].some(function(H){return H.test(I.value)})&&L.push(I),L}}function R(w,L,I){return L?(w=w.split(/\s+/),w.filter(function(U){return L.indexOf(U)!==-1||I.some(function(H){return H.test(U)})}).join(" ")):w}}const P3={decodeEntities:!0};Wi.defaults={allowedTags:["address","article","aside","footer","header","h1","h2","h3","h4","h5","h6","hgroup","main","nav","section","blockquote","dd","div","dl","dt","figcaption","figure","hr","li","menu","ol","p","pre","ul","a","abbr","b","bdi","bdo","br","cite","code","data","dfn","em","i","kbd","mark","q","rb","rp","rt","rtc","ruby","s","samp","small","span","strong","sub","sup","time","u","var","wbr","caption","col","colgroup","table","tbody","td","tfoot","th","thead","tr"],nonBooleanAttributes:["abbr","accept","accept-charset","accesskey","action","allow","alt","as","autocapitalize","autocomplete","blocking","charset","cite","class","color","cols","colspan","content","contenteditable","coords","crossorigin","data","datetime","decoding","dir","dirname","download","draggable","enctype","enterkeyhint","fetchpriority","for","form","formaction","formenctype","formmethod","formtarget","headers","height","hidden","high","href","hreflang","http-equiv","id","imagesizes","imagesrcset","inputmode","integrity","is","itemid","itemprop","itemref","itemtype","kind","label","lang","list","loading","low","max","maxlength","media","method","min","minlength","name","nonce","optimum","pattern","ping","placeholder","popover","popovertarget","popovertargetaction","poster","preload","referrerpolicy","rel","rows","rowspan","sandbox","scope","shape","size","sizes","slot","span","spellcheck","src","srcdoc","srclang","srcset","start","step","style","tabindex","target","title","translate","type","usemap","value","width","wrap","onauxclick","onafterprint","onbeforematch","onbeforeprint","onbeforeunload","onbeforetoggle","onblur","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextlost","oncontextmenu","oncontextrestored","oncopy","oncuechange","oncut","ondblclick","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","onformdata","onhashchange","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onlanguagechange","onload","onloadeddata","onloadedmetadata","onloadstart","onmessage","onmessageerror","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onoffline","ononline","onpagehide","onpageshow","onpaste","onpause","onplay","onplaying","onpopstate","onprogress","onratechange","onreset","onresize","onrejectionhandled","onscroll","onscrollend","onsecuritypolicyviolation","onseeked","onseeking","onselect","onslotchange","onstalled","onstorage","onsubmit","onsuspend","ontimeupdate","ontoggle","onunhandledrejection","onunload","onvolumechange","onwaiting","onwheel"],disallowedTagsMode:"discard",allowedAttributes:{a:["href","name","target"],img:["src","srcset","alt","title","width","height","loading"]},allowedEmptyAttributes:["alt"],selfClosing:["img","br","hr","area","base","basefont","input","link","meta"],allowedSchemes:["http","https","ftp","mailto","tel"],allowedSchemesByTag:{},allowedSchemesAppliedToAttributes:["href","src","cite"],allowProtocolRelative:!0,enforceHtmlBoundary:!1,parseStyleAttributes:!0,preserveEscapedAttributes:!1};Wi.simpleTransform=function(n,e,t){return t=t===void 0?!0:t,e=e||{},function(r,i){let s;if(t)for(s in e)i[s]=e[s];else i=e;return{tagName:n,attribs:i}}};const Ku=c2(M3),tm=J();class fs extends cl{constructor(t,r,i,s,o,u,a){super(o);M(this,"__src");M(this,"__alt");M(this,"__width");M(this,"__height");M(this,"__soliboDocumentId");M(this,"__soliboDocumentSlot");this.__src=t,this.__alt=r,this.__width=i,this.__height=s,this.__soliboDocumentId=u,this.__soliboDocumentSlot=a}static getType(){return"image"}static clone(t){return new fs(t.__src,t.__alt,t.__width,t.__height,t.__key,t.__soliboDocumentId,t.__soliboDocumentSlot)}static importJSON(t){return jo({alt:t.alt,height:t.height,soliboDocumentId:t.soliboDocumentId,soliboDocumentSlot:t.soliboDocumentSlot,src:t.src,width:t.width})}exportJSON(){return{alt:this.__alt,height:this.__height,...this.__soliboDocumentId?{soliboDocumentId:this.__soliboDocumentId}:void 0,...this.__soliboDocumentSlot?{soliboDocumentSlot:this.__soliboDocumentSlot}:void 0,src:this.__src,type:"image",version:1,width:this.__width}}static importDOM(){return{img:t=>({conversion:r=>{if(!(r instanceof HTMLImageElement))return null;const i=r.getAttribute("src")??"";if(!i)return null;const s=r.getAttribute("width"),o=r.getAttribute("height");return{node:jo({alt:r.getAttribute("alt")??"",height:o?Number(o):void 0,soliboDocumentId:r.getAttribute("data-solibo-document-id")??void 0,soliboDocumentSlot:r.getAttribute("data-solibo-document-slot")??void 0,src:i,width:s?Number(s):void 0})}},priority:0})}}exportDOM(){const t=document.createElement("img");return this.__soliboDocumentSlot||t.setAttribute("src",this.__src),this.__soliboDocumentId&&t.setAttribute("data-solibo-document-id",this.__soliboDocumentId),this.__soliboDocumentSlot&&t.setAttribute("data-solibo-document-slot",this.__soliboDocumentSlot),this.__alt&&t.setAttribute("alt",this.__alt),this.__width&&t.setAttribute("width",String(this.__width)),this.__height&&t.setAttribute("height",String(this.__height)),{element:t}}createDOM(){return document.createElement("span")}updateDOM(){return!1}isInline(){return!0}getSrc(){return this.__src}setSrc(t){const r=this.getWritable();return r.__src=t,r}setWidth(t){const r=this.getWritable();return r.__width=t,r.__height=void 0,r}decorate(t){return K.jsx("img",{alt:this.__alt,height:this.__height,"data-solibo-document-id":this.__soliboDocumentId,"data-solibo-document-slot":this.__soliboDocumentSlot,onClick:r=>{r.preventDefault(),t.dispatchCommand(tm,{key:this.getKey(),soliboDocumentSlot:this.__soliboDocumentSlot,src:this.__src,width:this.__width})},src:this.__src,width:this.__width})}}function jo({alt:n="",height:e,soliboDocumentId:t,soliboDocumentSlot:r,src:i,width:s}){return Kt(new fs(i,n,s,e,void 0,t,r))}function Wu(n){return n instanceof fs}const L3=({createImages:n})=>{const[e]=bt();return q.useEffect(()=>e.registerCommand(Ji,t=>{var o;if(!("clipboardData"in t))return!1;const r=t,i=Array.from(((o=r.clipboardData)==null?void 0:o.items)??[]).flatMap(u=>{if(u.kind!=="file"||!u.type.startsWith("image/"))return[];const a=u.getAsFile();return a?[a]:[]});if(i.length===0)return!1;r.preventDefault();const s=n(i);return e.update(()=>{Ho(s.map(u=>jo(u)))}),!0},Z1),[n,e]),null},R3=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/,F3=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,B3=[n=>{const e=R3.exec(n);return e!=null&&e.length?{index:e.index,length:e[0].length,text:e[0],url:`mailto:${e[0]}`}:null},n=>{const e=F3.exec(n);return e!=null&&e.length?{index:e.index,length:e[0].length,text:e[0],url:e[0].startsWith("http")?e[0]:`https://${e[0]}`}:null}];function Va(n){try{const e=new URL(n);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}const j3="_field_1mb0i_3",$3="_editor_1mb0i_8",U3="_invalid_1mb0i_46",z3="_error_1mb0i_50",q3="_dragging_1mb0i_56",K3="_content_1mb0i_60",W3="_files_1mb0i_66",H3="_placeholder_1mb0i_74",V3="_fill_1mb0i_82",G3="_meta_1mb0i_105",J3="_active_1mb0i_114",X3="_submit_1mb0i_133",Y3="_bold_1mb0i_137",Q3="_italic_1mb0i_141",Z3="_underline_1mb0i_145",e6="_link_1mb0i_149",t6="_list_1mb0i_155",n6="_paragraph_1mb0i_156",Ne={field:j3,editor:$3,"has-files":"_has-files_1mb0i_42",invalid:U3,error:z3,dragging:q3,content:K3,files:W3,placeholder:H3,fill:V3,"fill-editor":"_fill-editor_1mb0i_89",meta:G3,active:J3,"image-sizes":"_image-sizes_1mb0i_126",submit:X3,bold:Y3,italic:Q3,underline:Z3,link:e6,list:t6,paragraph:n6},r6=[{label:"Small",width:320},{label:"Medium",width:640},{label:"Large",width:960},{label:"Original",width:void 0}],i6=({disabled:n=!1,isSubmitting:e=!1,onFilesSelected:t,onInlineImageRemove:r,onSubmit:i,submitLabel:s="Submit"})=>{const[o]=bt(),[u,a]=q.useState(!1),[l,c]=q.useState(!1),[h,f]=q.useState(!1),[d,g]=q.useState(!1),[b,m]=q.useState(!1),[p,y]=q.useState(!1),[_,x]=q.useState(""),[S,C]=q.useState(null),[A,O]=q.useState(null),[D,k]=q.useState(void 0),[v,E]=q.useState(""),N=Va(v.trim()),R=q.useRef(null),w=q.useRef(null),L=q.useRef(null),I=q.useRef(null),U=q.useRef(!1),H=W=>W.preventDefault(),V=q.useCallback(W=>{I.current=F(W)?W.clone():null},[]),te=q.useCallback(W=>{o.update(()=>{I.current&&Me(I.current),W()}),I.current=null},[o]),ge=W=>{U.current=!0,W.preventDefault()},j=()=>{if(U.current){U.current=!1;return}Ae()},$=q.useCallback(()=>{c(!1),x(""),C(null),O(null),k(void 0)},[]),G=q.useCallback(()=>{m(!1),E("")},[]),X=q.useCallback(W=>{c(!0),x((W==null?void 0:W.src)??""),C((W==null?void 0:W.key)??null),O((W==null?void 0:W.soliboDocumentSlot)??null),k(W==null?void 0:W.width),G(),W!=null&&W.soliboDocumentSlot||setTimeout(()=>{var Q;return(Q=w.current)==null?void 0:Q.focus()},0)},[G]),Z=q.useCallback(W=>{o.getEditorState().read(()=>{V(z())}),m(!0),E(W),$(),setTimeout(()=>{var Q;return(Q=L.current)==null?void 0:Q.focus()},0)},[$,o,V]),Ce=q.useCallback(()=>{const W=v.trim();Va(W)&&(te(()=>{o.dispatchCommand(Dr,{url:W,target:"_blank"});const Q=z();if(!F(Q))return;const be=Q.getNodes().at(-1)??null,Le=(be==null?void 0:be.getParent())??null,Fe=Je(be)?be:Je(Le)?Le:null;if(Fe){const it=Fe.getLastChild();if(B(it)){const ic=it.getTextContent(),sc=ic.replace(/\s+$/,"");sc!==ic&&it.setTextContent(sc)}const mr=Fe.getNextSibling();if(B(mr)&&/^\s/.test(mr.getTextContent())){mr.select(1,1);return}const Nt=Xe(" ");Fe.insertAfter(Nt),Nt.selectEnd()}}),G())},[G,o,v,te]),Ae=q.useCallback(()=>{const W=_.trim();if(!W){$();return}o.update(()=>{if(S){const Q=he(S);Wu(Q)&&Q.setSrc(W);return}Ho([jo({src:W})])}),$()},[$,o,S,_]),ve=q.useCallback(()=>{if(!S){$();return}o.update(()=>{const W=he(S);if(Wu(W)){const Q=W.getParent();Zi(Q)&&Q.getChildrenSize()===1?Q.remove():W.remove(),A&&(r==null||r(A))}}),$()},[$,o,S,A,r]),ii=q.useCallback(W=>{S&&(o.update(()=>{const Q=he(S);Wu(Q)&&Q.setWidth(W)}),k(W))},[o,S]),dn=q.useCallback(()=>{te(()=>{o.dispatchCommand(Dr,null)}),G()},[G,o,te]),hn=q.useCallback(()=>{const W=z();if(!F(W)){if(_e(W)){const Le=W.getNodes(),Fe=Le[0]??null,it=(Fe==null?void 0:Fe.getParent())??null;a(Le.some(Nt=>B(Nt)&&Nt.hasFormat("bold"))),f(Le.some(Nt=>B(Nt)&&Nt.hasFormat("italic"))),g(Le.some(Nt=>B(Nt)&&Nt.hasFormat("underline"))),y(ne(it)||ue(it)||ne(Fe)||ue(Fe));const mr=Je(Fe)?Fe:Je(it)?it:null;if(mr){m(!0),E(mr.getURL());return}m(!1),E(""),I.current=null;return}a(!1),f(!1),g(!1),y(!1),m(!1),E(""),I.current=null;return}const[Q]=W.getNodes(),be=(Q==null?void 0:Q.getParent())??null;if(a(W.hasFormat("bold")),f(W.hasFormat("italic")),g(W.hasFormat("underline")),y(ne(be)||ue(be)),Je(be)){m(!0),E(be.getURL()),V(W);return}m(!1),E(""),I.current=null},[V]);return q.useEffect(()=>mt(o.registerUpdateListener(({editorState:W})=>{W.read(()=>{hn()})}),o.registerCommand(tm,W=>(X(W),!0),Zt),o.registerCommand(zo,()=>(o.getEditorState().read(()=>{hn()}),!1),Zt)),[o,X,hn]),K.jsxs(sm.Toolbar,{variant:"editor","data-component":"editortoolbar",children:[K.jsx(yt.Button,{"aria-label":"Bold","data-active":u,onClick:()=>{o.dispatchCommand(Ot,"bold")},title:"Bold",variant:"tertiary",children:K.jsx(Lt.Icon,{name:"TextB"})}),K.jsx(yt.Button,{"aria-label":"Italic","data-active":h,onClick:()=>{o.dispatchCommand(Ot,"italic")},title:"Italic",variant:"tertiary",children:K.jsx(Lt.Icon,{name:"TextItalic"})}),K.jsx(yt.Button,{"aria-label":"Underline","data-active":d,onClick:()=>{o.dispatchCommand(Ot,"underline")},title:"Underline",variant:"tertiary",children:K.jsx(Lt.Icon,{name:"TextUnderline"})}),K.jsx(yt.Button,{"aria-label":"List","data-active":p,onClick:()=>{p?o.dispatchCommand(Dg,void 0):o.dispatchCommand(Og,void 0)},title:"List",variant:"tertiary",children:K.jsx(Lt.Icon,{name:"ListBullets"})}),K.jsx(yt.Button,{"aria-label":"Link","data-active":b,onClick:()=>{b?Z(v):(o.dispatchCommand(Dr,{url:"https://"}),Z("https://"))},title:"Link",variant:"tertiary",children:K.jsx(Lt.Icon,{name:"Link"})}),t&&K.jsxs(K.Fragment,{children:[K.jsx("input",{hidden:!0,multiple:!0,onChange:W=>{W.target.files&&t(W.target.files),W.target.value=""},ref:R,type:"file"}),K.jsx(yt.Button,{"aria-label":"Upload files",onClick:()=>{var W;return(W=R.current)==null?void 0:W.click()},title:"Upload files",variant:"tertiary",children:K.jsx(Lt.Icon,{name:"Paperclip"})})]}),i&&K.jsx(yt.Button,{"aria-label":s,className:Ne.submit,"data-cy":"toolbar-submit-button",disabled:n,icon:"PaperPlaneTilt",isLoading:e,onClick:()=>i(),variant:"primary",children:K.jsx("span",{children:s})}),K.jsxs("div",{className:hi.t(Ne.meta,b||l?Ne.active:""),children:[b&&K.jsxs(K.Fragment,{children:[K.jsx(oc.Input,{"aria-invalid":!N,onBlur:()=>Ce(),onChange:W=>E(W.target.value),onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),Ce())},ref:L,value:v}),K.jsx(yt.Button,{"aria-label":"Apply link",disabled:!N,onClick:()=>{Ce()},onMouseDown:H,variant:"tertiary",children:K.jsx(Lt.Icon,{name:"Check"})}),K.jsx(yt.Button,{"aria-label":"Remove link",onClick:()=>dn(),onMouseDown:H,variant:"tertiary",children:K.jsx(Lt.Icon,{name:"Trash",variant:"danger"})})]}),l&&K.jsxs(K.Fragment,{children:[!A&&K.jsxs(K.Fragment,{children:[K.jsx(oc.Input,{className:hi.t(Ne.active),onBlur:j,onChange:W=>x(W.target.value),onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),U.current=!0,Ae())},ref:w,value:_}),K.jsx(yt.Button,{"aria-label":"Apply image",onClick:()=>Ae(),onMouseDown:ge,variant:"tertiary",children:K.jsx(Lt.Icon,{name:"Check"})})]}),K.jsx("div",{className:Ne["image-sizes"],children:r6.map(({label:W,width:Q})=>K.jsx(yt.Button,{"aria-label":`${W} image`,"data-active":D===Q,onClick:()=>ii(Q),onMouseDown:H,variant:"tertiary",children:W},W))}),K.jsx(yt.Button,{"aria-label":"Remove image",onClick:()=>ve(),onMouseDown:ge,variant:"tertiary",children:K.jsx(Lt.Icon,{name:"Trash",variant:"danger"})})]})]})]})},s6={name:"solibo-editor",namespace:"Editor",nodes:[ru,rr,is,ni,fs],onError(n){throw n},theme:{link:Ne.link,list:{ol:Ne.list,ul:Ne.list},paragraph:Ne.paragraph,text:{bold:Ne.bold,italic:Ne.italic,underline:Ne.underline}}};function o6({autofocus:n,content:e="",lastEmittedContentRef:t}){const[r]=bt();return q.useEffect(()=>{t.current!==e&&r.update(()=>{const s=new DOMParser().parseFromString(e,"text/html"),o=pg(r,s),u=we();u.clear().select(),Ho(o),n?u.selectEnd():Me(null)})},[n,e,r,t]),null}const u6=({autofocus:n=!1,autolink:e=!1,content:t,disabled:r=!1,errorMessage:i,fill:s=!1,files:o,inline:u=!1,inlineImages:a,invalid:l=!1,isSubmitting:c=!1,maxRows:h=12,minRows:f=1,onChange:d,onFilesChange:g,onInlineImagesChange:b,onSubmit:m,onUpload:p,placeholder:y,required:_=!1,submitLabel:x})=>{const S=q.useId(),C=q.useRef(void 0),[A,O]=q.useState(!1),[D,k]=q.useState([]),[v,E]=q.useState([]),N=q.useRef(new Map),R=o??D,w=a??v,L=j=>{o===void 0&&k(j),g==null||g(j)},I=q.useCallback(j=>{a===void 0&&E(j),b==null||b(j)},[a,b]),U=q.useCallback(j=>{const $=j.map(G=>{const X=`pasted-${crypto.randomUUID()}`,Z=URL.createObjectURL(G);return N.current.set(X,Z),{image:{alt:G.name,soliboDocumentSlot:X,src:Z},pending:{file:G,slot:X}}});return I([...w,...$.map(({pending:G})=>G)]),$.map(({image:G})=>G)},[w,I]),H=q.useCallback(j=>{I(w.filter(G=>G.slot!==j));const $=N.current.get(j);$&&URL.revokeObjectURL($),N.current.delete(j)},[w,I]);q.useEffect(()=>()=>{N.current.forEach(j=>URL.revokeObjectURL(j)),N.current.clear()},[]),q.useEffect(()=>{const j=new Set(w.map($=>$.slot));N.current.forEach(($,G)=>{j.has(G)||(URL.revokeObjectURL($),N.current.delete(G))})},[w]);const V=j=>{if(typeof DataTransfer<"u"){const $=new DataTransfer;return j.forEach(G=>$.items.add(G)),$.files}return Object.assign([...j],{item:$=>j[$]??null})},te=async()=>{try{R.length>0&&await(p==null?void 0:p(V(R))),await(m==null?void 0:m()),R.length>0&&L([])}catch{return}},ge=j=>{j.preventDefault(),j.stopPropagation()};return K.jsxs("div",{className:hi.t(Ne.field,s&&Ne.fill),"data-component":"editor","data-max-rows":h,"data-min-rows":f,onDragEnter:j=>{ge(j),O(!!g)},onDragOver:j=>{ge(j),O(!!g)},onDragLeave:j=>{ge(j),O(!1)},onDrop:j=>{var G;j.preventDefault();const $=(G=j.dataTransfer)==null?void 0:G.files;$&&(g==null||g(Array.from($))),O(!1)},children:[K.jsx("div",{className:hi.t(Ne.editor,s&&Ne["fill-editor"],l&&Ne.invalid,R.length>0&&Ne["has-files"]),style:{"--editor-max-height":`calc(${h*1.25}em + (2 * var(--scale-8)))`,"--editor-min-height":`calc(${f*1.25}em + (2 * var(--scale-8)))`},children:K.jsxs(w_,{contentEditable:null,extension:s6,children:[!u&&K.jsx(i6,{disabled:r,isSubmitting:c,onInlineImageRemove:H,onFilesSelected:p||g?j=>{L([...R,...Array.from(j)])}:void 0,onSubmit:m?()=>void te():void 0,submitLabel:x}),K.jsx("div",{className:hi.t(Ne.content,A&&Ne.dragging),children:K.jsx(a2,{contentEditable:K.jsx(Pg,{"aria-placeholder":y??"",ariaErrorMessage:l&&i?S:void 0,ariaInvalid:l||void 0,ariaRequired:_||void 0,placeholder:()=>y?K.jsx("div",{className:Ne.placeholder,children:y}):null}),ErrorBoundary:Lg})}),R.length>0&&K.jsx("div",{"aria-label":"Files to upload",className:Ne.files,role:"region",children:R.map((j,$)=>K.jsx(im.File,{deleteAccessibleLabel:`Remove ${j.name} from upload queue`,name:j.name,onDelete:()=>L(R.filter((G,X)=>X!==$))},`${j.name}-${j.size}-${j.lastModified}-${$}`))}),n&&K.jsx(f_,{}),e&&K.jsx(d_,{matchers:B3}),K.jsx(N_,{}),b&&K.jsx(L3,{createImages:U}),t!==void 0&&K.jsx(o6,{autofocus:n,content:t,lastEmittedContentRef:C}),K.jsx(k_,{validateUrl:Va}),K.jsx(A_,{}),d&&K.jsx(D_,{onChange:(j,$)=>{j.read(()=>{const G=mg($,null),X=Ku(G,{allowedAttributes:{...Ku.defaults.allowedAttributes,img:[...Ku.defaults.allowedAttributes.img??[],"data-solibo-document-id","data-solibo-document-slot"]},allowedTags:["a","b","br","i","img","li","ol","p","u","ul"]});C.current=X,d(X)})}})]})}),l&&i&&K.jsx("div",{className:Ne.error,id:S,children:i})]})};exports.Editor=u6;
55
+ `)});const u=e.nonTextTags||["script","style","textarea","option"];let a,l;e.allowedAttributes&&(a={},l={},xr(e.allowedAttributes,function(w,L){a[L]=[];const I=[];w.forEach(function(U){typeof U=="string"&&U.indexOf("*")>=0?I.push(zd(U).replace(/\\\*/g,".*")):a[L].push(U)}),I.length&&(l[L]=new RegExp("^("+I.join("|")+")$"))}));const c={},h={},f={};xr(e.allowedClasses,function(w,L){if(a&&(Yt(a,L)||(a[L]=[]),a[L].push("class")),c[L]=w,Array.isArray(w)){const I=[];c[L]=[],f[L]=[],w.forEach(function(U){typeof U=="string"&&U.indexOf("*")>=0?I.push(zd(U).replace(/\\\*/g,".*")):U instanceof RegExp?f[L].push(U):c[L].push(U)}),I.length&&(h[L]=new RegExp("^("+I.join("|")+")$"))}});const d={};let g;xr(e.transformTags,function(w,L){let I;typeof w=="function"?I=w:typeof w=="string"&&(I=Wi.simpleTransform(w)),L==="*"?g=I:d[L]=I});let b,m,p,y,_,x,S=!1;A();const C=new C3.Parser({onopentag:function(w,L){if(e.onOpenTag&&e.onOpenTag(w,L),e.enforceHtmlBoundary&&w==="html"&&A(),_){x++;return}const I=new s(w,L);m.push(I);let U=!1;const H=!!I.text;let V;if(Yt(d,w)&&(V=d[w](w,L),I.attribs=L=V.attribs,V.text!==void 0&&(I.innerText=V.text),w!==V.tagName&&(I.name=w=V.tagName,y[b]=V.tagName)),g&&(V=g(w,L),I.attribs=L=V.attribs,w!==V.tagName&&(I.name=w=V.tagName,y[b]=V.tagName)),(!o(w)||e.disallowedTagsMode==="recursiveEscape"&&!O3(p)||e.nestingLimit!=null&&b>=e.nestingLimit)&&(U=!0,p[b]=!0,(e.disallowedTagsMode==="discard"||e.disallowedTagsMode==="completelyDiscard")&&u.indexOf(w)!==-1&&(_=!0,x=1)),b++,U){if(e.disallowedTagsMode==="discard"||e.disallowedTagsMode==="completelyDiscard"){if(I.innerText&&!H){const j=O(I.innerText);e.textFilter?r+=e.textFilter(j,w):r+=j,S=!0}return}i=r,r=""}r+="<"+w,w==="script"&&(e.allowedScriptHostnames||e.allowedScriptDomains)&&(I.innerText=""),U&&(e.disallowedTagsMode==="escape"||e.disallowedTagsMode==="recursiveEscape")&&e.preserveEscapedAttributes?xr(L,function(j,$){r+=" "+$+'="'+O(j||"",!0)+'"'}):(!a||Yt(a,w)||a["*"])&&xr(L,function(j,$){if(!I3.test($)){delete I.attribs[$];return}if(j===""&&!e.allowedEmptyAttributes.includes($)&&(e.nonBooleanAttributes.includes($)||e.nonBooleanAttributes.includes("*"))){delete I.attribs[$];return}let G=!1;if(!a||Yt(a,w)&&a[w].indexOf($)!==-1||a["*"]&&a["*"].indexOf($)!==-1||Yt(l,w)&&l[w].test($)||l["*"]&&l["*"].test($))G=!0;else if(a&&a[w]){for(const X of a[w])if(T3(X)&&X.name&&X.name===$){G=!0;let Z="";if(X.multiple===!0){const Ce=j.split(" ");for(const Ae of Ce)X.values.indexOf(Ae)!==-1&&(Z===""?Z=Ae:Z+=" "+Ae)}else X.values.indexOf(j)>=0&&(Z=j);j=Z}}if(G){if(e.allowedSchemesAppliedToAttributes.indexOf($)!==-1&&D(w,j)){delete I.attribs[$];return}if(w==="script"&&$==="src"){let X=!0;try{const Z=k(j);if(e.allowedScriptHostnames||e.allowedScriptDomains){const Ce=(e.allowedScriptHostnames||[]).find(function(ve){return ve===Z.url.hostname}),Ae=(e.allowedScriptDomains||[]).find(function(ve){return Z.url.hostname===ve||Z.url.hostname.endsWith(`.${ve}`)});X=Ce||Ae}}catch{X=!1}if(!X){delete I.attribs[$];return}}if(w==="iframe"&&$==="src"){let X=!0;try{const Z=k(j);if(Z.isRelativeUrl)X=Yt(e,"allowIframeRelativeUrls")?e.allowIframeRelativeUrls:!e.allowedIframeHostnames&&!e.allowedIframeDomains;else if(e.allowedIframeHostnames||e.allowedIframeDomains){const Ce=(e.allowedIframeHostnames||[]).find(function(ve){return ve===Z.url.hostname}),Ae=(e.allowedIframeDomains||[]).find(function(ve){return Z.url.hostname===ve||Z.url.hostname.endsWith(`.${ve}`)});X=Ce||Ae}}catch{X=!1}if(!X){delete I.attribs[$];return}}if($==="srcset")try{let X=E3(j);if(X.forEach(function(Z){D("srcset",Z.url)&&(Z.evil=!0)}),X=Kd(X,function(Z){return!Z.evil}),X.length)j=D3(Kd(X,function(Z){return!Z.evil})),I.attribs[$]=j;else{delete I.attribs[$];return}}catch{delete I.attribs[$];return}if($==="class"){const X=c[w],Z=c["*"],Ce=h[w],Ae=f[w],ve=f["*"],ii=h["*"],dn=[Ce,ii].concat(Ae,ve).filter(function(hn){return hn});if(X&&Z?j=R(j,qd(X,Z),dn):j=R(j,X||Z,dn),!j.length){delete I.attribs[$];return}}if($==="style"){if(e.parseStyleAttributes)try{const X=N3(w+" {"+j+"}",{map:!1}),Z=v(X,e.allowedStyles);if(j=E(Z),j.length===0){delete I.attribs[$];return}}catch{typeof window<"u"&&console.warn('Failed to parse "'+w+" {"+j+`}", If you're running this in a browser, we recommend to disable style parsing: options.parseStyleAttributes: false, since this only works in a node environment due to a postcss dependency, More info: https://github.com/apostrophecms/sanitize-html/issues/547`),delete I.attribs[$];return}else if(e.allowedStyles)throw new Error("allowedStyles option cannot be used together with parseStyleAttributes: false.")}r+=" "+$,j&&j.length?r+='="'+O(j,!0)+'"':e.allowedEmptyAttributes.includes($)&&(r+='=""')}else delete I.attribs[$]}),e.selfClosing.indexOf(w)!==-1?r+=" />":(r+=">",I.innerText&&!H&&!e.textFilter&&(r+=O(I.innerText),S=!0)),U&&(r=i+O(r),i=""),I.openingTagLength=r.length-I.tagPosition},ontext:function(w){if(_)return;const L=m[m.length-1];let I;if(L&&(I=L.tag,w=L.innerText!==void 0?L.innerText:w),e.disallowedTagsMode==="completelyDiscard"&&!o(I))w="";else if((e.disallowedTagsMode==="discard"||e.disallowedTagsMode==="completelyDiscard")&&(I==="script"||I==="style"))r+=w;else if(!S){const U=O(w,!1);e.textFilter?r+=e.textFilter(U,I):r+=U}if(m.length){const U=m[m.length-1];U.text+=w}},onclosetag:function(w,L){if(e.onCloseTag&&e.onCloseTag(w,L),_)if(x--,!x)_=!1;else return;const I=m.pop();if(!I)return;if(I.tag!==w){m.push(I);return}_=e.enforceHtmlBoundary?w==="html":!1,b--;const U=p[b];if(U){if(delete p[b],e.disallowedTagsMode==="discard"||e.disallowedTagsMode==="completelyDiscard"){I.updateParentNodeText();return}i=r,r=""}if(y[b]&&(w=y[b],delete y[b]),e.exclusiveFilter){const H=e.exclusiveFilter(I);if(H==="excludeTag"){U&&(r=i,i=""),r=r.substring(0,I.tagPosition)+r.substring(I.tagPosition+I.openingTagLength);return}else if(H){r=r.substring(0,I.tagPosition);return}}if(I.updateParentNodeMediaChildren(),I.updateParentNodeText(),e.selfClosing.indexOf(w)!==-1||L&&!o(w)&&["escape","recursiveEscape"].indexOf(e.disallowedTagsMode)>=0){U&&(r=i,i="");return}r+="</"+w+">",U&&(r=i+O(r),i=""),S=!1}},e.parser);if(C.write(n),C.end(),e.disallowedTagsMode==="escape"||e.disallowedTagsMode==="recursiveEscape"){const w=C.endIndex;if(w!=null&&w>=0&&w<n.length){const L=n.substring(w);r+=O(L)}else(w==null||w<0)&&n.length>0&&r===""&&(r=O(n))}return r;function A(){r="",b=0,m=[],p={},y={},_=!1,x=0}function O(w,L){return typeof w!="string"&&(w=w+""),e.parser.decodeEntities&&(w=w.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),L&&(w=w.replace(/"/g,"&quot;"))),w=w.replace(/&(?![a-zA-Z0-9#]{1,20};)/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),L&&(w=w.replace(/"/g,"&quot;")),w}function D(w,L){for(L=L.replace(/[\x00-\x20]+/g,"");;){const H=L.indexOf("<!--");if(H===-1)break;const V=L.indexOf("-->",H+4);if(V===-1)break;L=L.substring(0,H)+L.substring(V+3)}const I=L.match(/^([a-zA-Z][a-zA-Z0-9.\-+]*):/);if(!I)return L.match(/^[/\\]{2}/)?!e.allowProtocolRelative:!1;const U=I[1].toLowerCase();return Yt(e.allowedSchemesByTag,w)?e.allowedSchemesByTag[w].indexOf(U)===-1:!e.allowedSchemes||e.allowedSchemes.indexOf(U)===-1}function k(w){if(w=w.replace(/^(\w+:)?\s*[\\/]\s*[\\/]/,"$1//"),w.startsWith("relative:"))throw new Error("relative: exploit attempt");let L="relative://relative-site";for(let H=0;H<100;H++)L+=`/${H}`;const I=new URL(w,L);return{isRelativeUrl:I&&I.hostname==="relative-site"&&I.protocol==="relative:",url:I}}function v(w,L){if(!L)return w;const I=w.nodes[0];let U;return L[I.selector]&&L["*"]?U=qd(L[I.selector],L["*"]):U=L[I.selector]||L["*"],U&&(w.nodes[0].nodes=I.nodes.reduce(N(U),[])),w}function E(w){return w.nodes[0].nodes.reduce(function(L,I){return L.push(`${I.prop}:${I.value}${I.important?" !important":""}`),L},[]).join(";")}function N(w){return function(L,I){return Yt(w,I.prop)&&w[I.prop].some(function(H){return H.test(I.value)})&&L.push(I),L}}function R(w,L,I){return L?(w=w.split(/\s+/),w.filter(function(U){return L.indexOf(U)!==-1||I.some(function(H){return H.test(U)})}).join(" ")):w}}const P3={decodeEntities:!0};Wi.defaults={allowedTags:["address","article","aside","footer","header","h1","h2","h3","h4","h5","h6","hgroup","main","nav","section","blockquote","dd","div","dl","dt","figcaption","figure","hr","li","menu","ol","p","pre","ul","a","abbr","b","bdi","bdo","br","cite","code","data","dfn","em","i","kbd","mark","q","rb","rp","rt","rtc","ruby","s","samp","small","span","strong","sub","sup","time","u","var","wbr","caption","col","colgroup","table","tbody","td","tfoot","th","thead","tr"],nonBooleanAttributes:["abbr","accept","accept-charset","accesskey","action","allow","alt","as","autocapitalize","autocomplete","blocking","charset","cite","class","color","cols","colspan","content","contenteditable","coords","crossorigin","data","datetime","decoding","dir","dirname","download","draggable","enctype","enterkeyhint","fetchpriority","for","form","formaction","formenctype","formmethod","formtarget","headers","height","hidden","high","href","hreflang","http-equiv","id","imagesizes","imagesrcset","inputmode","integrity","is","itemid","itemprop","itemref","itemtype","kind","label","lang","list","loading","low","max","maxlength","media","method","min","minlength","name","nonce","optimum","pattern","ping","placeholder","popover","popovertarget","popovertargetaction","poster","preload","referrerpolicy","rel","rows","rowspan","sandbox","scope","shape","size","sizes","slot","span","spellcheck","src","srcdoc","srclang","srcset","start","step","style","tabindex","target","title","translate","type","usemap","value","width","wrap","onauxclick","onafterprint","onbeforematch","onbeforeprint","onbeforeunload","onbeforetoggle","onblur","oncancel","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextlost","oncontextmenu","oncontextrestored","oncopy","oncuechange","oncut","ondblclick","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","onformdata","onhashchange","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onlanguagechange","onload","onloadeddata","onloadedmetadata","onloadstart","onmessage","onmessageerror","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onoffline","ononline","onpagehide","onpageshow","onpaste","onpause","onplay","onplaying","onpopstate","onprogress","onratechange","onreset","onresize","onrejectionhandled","onscroll","onscrollend","onsecuritypolicyviolation","onseeked","onseeking","onselect","onslotchange","onstalled","onstorage","onsubmit","onsuspend","ontimeupdate","ontoggle","onunhandledrejection","onunload","onvolumechange","onwaiting","onwheel"],disallowedTagsMode:"discard",allowedAttributes:{a:["href","name","target"],img:["src","srcset","alt","title","width","height","loading"]},allowedEmptyAttributes:["alt"],selfClosing:["img","br","hr","area","base","basefont","input","link","meta"],allowedSchemes:["http","https","ftp","mailto","tel"],allowedSchemesByTag:{},allowedSchemesAppliedToAttributes:["href","src","cite"],allowProtocolRelative:!0,enforceHtmlBoundary:!1,parseStyleAttributes:!0,preserveEscapedAttributes:!1};Wi.simpleTransform=function(n,e,t){return t=t===void 0?!0:t,e=e||{},function(r,i){let s;if(t)for(s in e)i[s]=e[s];else i=e;return{tagName:n,attribs:i}}};const Ku=c2(M3),tm=J();class fs extends cl{constructor(t,r,i,s,o,u,a){super(o);M(this,"__src");M(this,"__alt");M(this,"__width");M(this,"__height");M(this,"__soliboDocumentId");M(this,"__soliboDocumentSlot");this.__src=t,this.__alt=r,this.__width=i,this.__height=s,this.__soliboDocumentId=u,this.__soliboDocumentSlot=a}static getType(){return"image"}static clone(t){return new fs(t.__src,t.__alt,t.__width,t.__height,t.__key,t.__soliboDocumentId,t.__soliboDocumentSlot)}static importJSON(t){return jo({alt:t.alt,height:t.height,soliboDocumentId:t.soliboDocumentId,soliboDocumentSlot:t.soliboDocumentSlot,src:t.src,width:t.width})}exportJSON(){return{alt:this.__alt,height:this.__height,...this.__soliboDocumentId?{soliboDocumentId:this.__soliboDocumentId}:void 0,...this.__soliboDocumentSlot?{soliboDocumentSlot:this.__soliboDocumentSlot}:void 0,src:this.__src,type:"image",version:1,width:this.__width}}static importDOM(){return{img:t=>({conversion:r=>{if(!(r instanceof HTMLImageElement))return null;const i=r.getAttribute("src")??"";if(!i)return null;const s=r.getAttribute("width"),o=r.getAttribute("height");return{node:jo({alt:r.getAttribute("alt")??"",height:o?Number(o):void 0,soliboDocumentId:r.getAttribute("data-solibo-document-id")??void 0,soliboDocumentSlot:r.getAttribute("data-solibo-document-slot")??void 0,src:i,width:s?Number(s):void 0})}},priority:0})}}exportDOM(){const t=document.createElement("img");return this.__soliboDocumentSlot||t.setAttribute("src",this.__src),this.__soliboDocumentId&&t.setAttribute("data-solibo-document-id",this.__soliboDocumentId),this.__soliboDocumentSlot&&t.setAttribute("data-solibo-document-slot",this.__soliboDocumentSlot),this.__alt&&t.setAttribute("alt",this.__alt),this.__width&&t.setAttribute("width",String(this.__width)),this.__height&&t.setAttribute("height",String(this.__height)),{element:t}}createDOM(){return document.createElement("span")}updateDOM(){return!1}isInline(){return!0}getSrc(){return this.__src}setSrc(t){const r=this.getWritable();return r.__src=t,r}setWidth(t){const r=this.getWritable();return r.__width=t,r.__height=void 0,r}decorate(t){return K.jsx("img",{alt:this.__alt,height:this.__height,"data-solibo-document-id":this.__soliboDocumentId,"data-solibo-document-slot":this.__soliboDocumentSlot,onClick:r=>{r.preventDefault(),t.dispatchCommand(tm,{key:this.getKey(),soliboDocumentSlot:this.__soliboDocumentSlot,src:this.__src,width:this.__width})},src:this.__src,width:this.__width})}}function jo({alt:n="",height:e,soliboDocumentId:t,soliboDocumentSlot:r,src:i,width:s}){return Kt(new fs(i,n,s,e,void 0,t,r))}function Wu(n){return n instanceof fs}const L3=({createImages:n})=>{const[e]=bt();return q.useEffect(()=>e.registerCommand(Ji,t=>{var o;if(!("clipboardData"in t))return!1;const r=t,i=Array.from(((o=r.clipboardData)==null?void 0:o.items)??[]).flatMap(u=>{if(u.kind!=="file"||!u.type.startsWith("image/"))return[];const a=u.getAsFile();return a?[a]:[]});if(i.length===0)return!1;r.preventDefault();const s=n(i);return e.update(()=>{Ho(s.map(u=>jo(u)))}),!0},Z1),[n,e]),null},R3=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/,F3=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,B3=[n=>{const e=R3.exec(n);return e!=null&&e.length?{index:e.index,length:e[0].length,text:e[0],url:`mailto:${e[0]}`}:null},n=>{const e=F3.exec(n);return e!=null&&e.length?{index:e.index,length:e[0].length,text:e[0],url:e[0].startsWith("http")?e[0]:`https://${e[0]}`}:null}];function Va(n){try{const e=new URL(n);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}}const j3="_field_1mb0i_3",$3="_editor_1mb0i_8",U3="_invalid_1mb0i_46",z3="_error_1mb0i_50",q3="_dragging_1mb0i_56",K3="_content_1mb0i_60",W3="_files_1mb0i_66",H3="_placeholder_1mb0i_74",V3="_fill_1mb0i_82",G3="_meta_1mb0i_105",J3="_active_1mb0i_114",X3="_submit_1mb0i_133",Y3="_bold_1mb0i_137",Q3="_italic_1mb0i_141",Z3="_underline_1mb0i_145",e6="_link_1mb0i_149",t6="_list_1mb0i_155",n6="_paragraph_1mb0i_156",Ne={field:j3,editor:$3,"has-files":"_has-files_1mb0i_42",invalid:U3,error:z3,dragging:q3,content:K3,files:W3,placeholder:H3,fill:V3,"fill-editor":"_fill-editor_1mb0i_89",meta:G3,active:J3,"image-sizes":"_image-sizes_1mb0i_126",submit:X3,bold:Y3,italic:Q3,underline:Z3,link:e6,list:t6,paragraph:n6},r6=[{label:"Small",width:320},{label:"Medium",width:640},{label:"Large",width:960},{label:"Original",width:void 0}],i6=({disabled:n=!1,isSubmitting:e=!1,onFilesSelected:t,onInlineImageRemove:r,onSubmit:i,submitLabel:s="Submit"})=>{const[o]=bt(),[u,a]=q.useState(!1),[l,c]=q.useState(!1),[h,f]=q.useState(!1),[d,g]=q.useState(!1),[b,m]=q.useState(!1),[p,y]=q.useState(!1),[_,x]=q.useState(""),[S,C]=q.useState(null),[A,O]=q.useState(null),[D,k]=q.useState(void 0),[v,E]=q.useState(""),N=Va(v.trim()),R=q.useRef(null),w=q.useRef(null),L=q.useRef(null),I=q.useRef(null),U=q.useRef(!1),H=W=>W.preventDefault(),V=q.useCallback(W=>{I.current=F(W)?W.clone():null},[]),te=q.useCallback(W=>{o.update(()=>{I.current&&Me(I.current),W()}),I.current=null},[o]),ge=W=>{U.current=!0,W.preventDefault()},j=()=>{if(U.current){U.current=!1;return}Ae()},$=q.useCallback(()=>{c(!1),x(""),C(null),O(null),k(void 0)},[]),G=q.useCallback(()=>{m(!1),E("")},[]),X=q.useCallback(W=>{c(!0),x((W==null?void 0:W.src)??""),C((W==null?void 0:W.key)??null),O((W==null?void 0:W.soliboDocumentSlot)??null),k(W==null?void 0:W.width),G(),W!=null&&W.soliboDocumentSlot||setTimeout(()=>{var Q;return(Q=w.current)==null?void 0:Q.focus()},0)},[G]),Z=q.useCallback(W=>{o.getEditorState().read(()=>{V(z())}),m(!0),E(W),$(),setTimeout(()=>{var Q;return(Q=L.current)==null?void 0:Q.focus()},0)},[$,o,V]),Ce=q.useCallback(()=>{const W=v.trim();Va(W)&&(te(()=>{o.dispatchCommand(Dr,{url:W,target:"_blank"});const Q=z();if(!F(Q))return;const be=Q.getNodes().at(-1)??null,Le=(be==null?void 0:be.getParent())??null,Fe=Je(be)?be:Je(Le)?Le:null;if(Fe){const it=Fe.getLastChild();if(B(it)){const ic=it.getTextContent(),sc=ic.replace(/\s+$/,"");sc!==ic&&it.setTextContent(sc)}const mr=Fe.getNextSibling();if(B(mr)&&/^\s/.test(mr.getTextContent())){mr.select(1,1);return}const Nt=Xe(" ");Fe.insertAfter(Nt),Nt.selectEnd()}}),G())},[G,o,v,te]),Ae=q.useCallback(()=>{const W=_.trim();if(!W){$();return}o.update(()=>{if(S){const Q=he(S);Wu(Q)&&Q.setSrc(W);return}Ho([jo({src:W})])}),$()},[$,o,S,_]),ve=q.useCallback(()=>{if(!S){$();return}o.update(()=>{const W=he(S);if(Wu(W)){const Q=W.getParent();Zi(Q)&&Q.getChildrenSize()===1?Q.remove():W.remove(),A&&(r==null||r(A))}}),$()},[$,o,S,A,r]),ii=q.useCallback(W=>{S&&(o.update(()=>{const Q=he(S);Wu(Q)&&Q.setWidth(W)}),k(W))},[o,S]),dn=q.useCallback(()=>{te(()=>{o.dispatchCommand(Dr,null)}),G()},[G,o,te]),hn=q.useCallback(()=>{const W=z();if(!F(W)){if(_e(W)){const Le=W.getNodes(),Fe=Le[0]??null,it=(Fe==null?void 0:Fe.getParent())??null;a(Le.some(Nt=>B(Nt)&&Nt.hasFormat("bold"))),f(Le.some(Nt=>B(Nt)&&Nt.hasFormat("italic"))),g(Le.some(Nt=>B(Nt)&&Nt.hasFormat("underline"))),y(ne(it)||ue(it)||ne(Fe)||ue(Fe));const mr=Je(Fe)?Fe:Je(it)?it:null;if(mr){m(!0),E(mr.getURL());return}m(!1),E(""),I.current=null;return}a(!1),f(!1),g(!1),y(!1),m(!1),E(""),I.current=null;return}const[Q]=W.getNodes(),be=(Q==null?void 0:Q.getParent())??null;if(a(W.hasFormat("bold")),f(W.hasFormat("italic")),g(W.hasFormat("underline")),y(ne(be)||ue(be)),Je(be)){m(!0),E(be.getURL()),V(W);return}m(!1),E(""),I.current=null},[V]);return q.useEffect(()=>mt(o.registerUpdateListener(({editorState:W})=>{W.read(()=>{hn()})}),o.registerCommand(tm,W=>(X(W),!0),Zt),o.registerCommand(zo,()=>(o.getEditorState().read(()=>{hn()}),!1),Zt)),[o,X,hn]),K.jsxs(sm.Toolbar,{variant:"editor","data-component":"editortoolbar",children:[K.jsx(yt.Button,{"aria-label":"Bold","data-active":u,onClick:()=>{o.dispatchCommand(Ot,"bold")},title:"Bold",variant:"tertiary",children:K.jsx(Lt.Icon,{name:"TextB"})}),K.jsx(yt.Button,{"aria-label":"Italic","data-active":h,onClick:()=>{o.dispatchCommand(Ot,"italic")},title:"Italic",variant:"tertiary",children:K.jsx(Lt.Icon,{name:"TextItalic"})}),K.jsx(yt.Button,{"aria-label":"Underline","data-active":d,onClick:()=>{o.dispatchCommand(Ot,"underline")},title:"Underline",variant:"tertiary",children:K.jsx(Lt.Icon,{name:"TextUnderline"})}),K.jsx(yt.Button,{"aria-label":"List","data-active":p,onClick:()=>{p?o.dispatchCommand(Dg,void 0):o.dispatchCommand(Og,void 0)},title:"List",variant:"tertiary",children:K.jsx(Lt.Icon,{name:"ListBullets"})}),K.jsx(yt.Button,{"aria-label":"Link","data-active":b,onClick:()=>{b?Z(v):(o.dispatchCommand(Dr,{url:"https://"}),Z("https://"))},title:"Link",variant:"tertiary",children:K.jsx(Lt.Icon,{name:"Link"})}),t&&K.jsxs(K.Fragment,{children:[K.jsx("input",{hidden:!0,multiple:!0,onChange:W=>{W.target.files&&t(W.target.files),W.target.value=""},ref:R,type:"file"}),K.jsx(yt.Button,{"aria-label":"Upload files",onClick:()=>{var W;return(W=R.current)==null?void 0:W.click()},title:"Upload files",variant:"tertiary",children:K.jsx(Lt.Icon,{name:"Paperclip"})})]}),i&&K.jsx(yt.Button,{"aria-label":s,className:Ne.submit,"data-cy":"toolbar-submit-button",disabled:n,icon:"PaperPlaneTilt",isLoading:e,onClick:()=>i(),variant:"primary",children:K.jsx("span",{children:s})}),K.jsxs("div",{className:hi.t(Ne.meta,b||l?Ne.active:""),children:[b&&K.jsxs(K.Fragment,{children:[K.jsx(oc.Input,{"aria-invalid":!N,onBlur:()=>Ce(),onChange:W=>E(W.target.value),onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),Ce())},ref:L,value:v}),K.jsx(yt.Button,{"aria-label":"Apply link",disabled:!N,onClick:()=>{Ce()},onMouseDown:H,variant:"tertiary",children:K.jsx(Lt.Icon,{name:"Check"})}),K.jsx(yt.Button,{"aria-label":"Remove link",onClick:()=>dn(),onMouseDown:H,variant:"tertiary",children:K.jsx(Lt.Icon,{name:"Trash",variant:"danger"})})]}),l&&K.jsxs(K.Fragment,{children:[!A&&K.jsxs(K.Fragment,{children:[K.jsx(oc.Input,{className:hi.t(Ne.active),onBlur:j,onChange:W=>x(W.target.value),onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),U.current=!0,Ae())},ref:w,value:_}),K.jsx(yt.Button,{"aria-label":"Apply image",onClick:()=>Ae(),onMouseDown:ge,variant:"tertiary",children:K.jsx(Lt.Icon,{name:"Check"})})]}),K.jsx("div",{className:Ne["image-sizes"],children:r6.map(({label:W,width:Q})=>K.jsx(yt.Button,{"aria-label":`${W} image`,"data-active":D===Q,onClick:()=>ii(Q),onMouseDown:H,variant:"tertiary",children:W},W))}),K.jsx(yt.Button,{"aria-label":"Remove image",onClick:()=>ve(),onMouseDown:ge,variant:"tertiary",children:K.jsx(Lt.Icon,{name:"Trash",variant:"danger"})})]})]})]})},s6={name:"solibo-editor",namespace:"Editor",nodes:[ru,rr,is,ni,fs],onError(n){throw n},theme:{link:Ne.link,list:{ol:Ne.list,ul:Ne.list},paragraph:Ne.paragraph,text:{bold:Ne.bold,italic:Ne.italic,underline:Ne.underline}}};function o6({autofocus:n,content:e="",lastEmittedContentRef:t}){const[r]=bt();return q.useEffect(()=>{t.current!==e&&r.update(()=>{const s=new DOMParser().parseFromString(e,"text/html"),o=pg(r,s),u=we();u.clear().select(),Ho(o),n?u.selectEnd():Me(null)})},[n,e,r,t]),null}const u6=({autofocus:n=!1,autolink:e=!1,content:t,disabled:r=!1,errorMessage:i,fill:s=!1,files:o,inline:u=!1,inlineImages:a,invalid:l=!1,isSubmitting:c=!1,maxRows:h=12,minRows:f=1,onChange:d,onFilesChange:g,onInlineImagesChange:b,onSubmit:m,onUpload:p,placeholder:y,required:_=!1,submitLabel:x})=>{const S=q.useId(),C=q.useRef(void 0),[A,O]=q.useState(!1),[D,k]=q.useState([]),[v,E]=q.useState([]),N=q.useRef(new Map),R=o??D,w=a??v,L=j=>{o===void 0&&k(j),g==null||g(j)},I=q.useCallback(j=>{a===void 0&&E(j),b==null||b(j)},[a,b]),U=q.useCallback(j=>{const $=j.map(G=>{const X=`pasted-${crypto.randomUUID()}`,Z=URL.createObjectURL(G);return N.current.set(X,Z),{image:{alt:G.name,soliboDocumentSlot:X,src:Z},pending:{file:G,slot:X}}});return I([...w,...$.map(({pending:G})=>G)]),$.map(({image:G})=>G)},[w,I]),H=q.useCallback(j=>{I(w.filter(G=>G.slot!==j));const $=N.current.get(j);$&&URL.revokeObjectURL($),N.current.delete(j)},[w,I]);q.useEffect(()=>()=>{N.current.forEach(j=>URL.revokeObjectURL(j)),N.current.clear()},[]),q.useEffect(()=>{const j=new Set(w.map($=>$.slot));N.current.forEach(($,G)=>{j.has(G)||(URL.revokeObjectURL($),N.current.delete(G))})},[w]);const V=j=>{if(typeof DataTransfer<"u"){const $=new DataTransfer;return j.forEach(G=>$.items.add(G)),$.files}return Object.assign([...j],{item:$=>j[$]??null})},te=async()=>{try{R.length>0&&await(p==null?void 0:p(V(R))),await(m==null?void 0:m()),R.length>0&&L([])}catch{return}},ge=j=>{j.preventDefault(),j.stopPropagation()};return K.jsxs("div",{className:hi.t(Ne.field,s&&Ne.fill),"data-component":"editor","data-max-rows":h,"data-min-rows":f,onDragEnter:j=>{ge(j),O(!!g)},onDragOver:j=>{ge(j),O(!!g)},onDragLeave:j=>{ge(j),O(!1)},onDropCapture:j=>{var G;const $=(G=j.dataTransfer)==null?void 0:G.files;$!=null&&$.length&&(ge(j),(g||p)&&L([...R,...Array.from($)]),O(!1))},onDrop:j=>{j.preventDefault(),O(!1)},children:[K.jsx("div",{className:hi.t(Ne.editor,s&&Ne["fill-editor"],l&&Ne.invalid,R.length>0&&Ne["has-files"]),style:{"--editor-max-height":`calc(${h*1.25}em + (2 * var(--scale-8)))`,"--editor-min-height":`calc(${f*1.25}em + (2 * var(--scale-8)))`},children:K.jsxs(w_,{contentEditable:null,extension:s6,children:[!u&&K.jsx(i6,{disabled:r,isSubmitting:c,onInlineImageRemove:H,onFilesSelected:p||g?j=>{L([...R,...Array.from(j)])}:void 0,onSubmit:m?()=>void te():void 0,submitLabel:x}),K.jsx("div",{className:hi.t(Ne.content,A&&Ne.dragging),children:K.jsx(a2,{contentEditable:K.jsx(Pg,{"aria-placeholder":y??"",ariaErrorMessage:l&&i?S:void 0,ariaInvalid:l||void 0,ariaRequired:_||void 0,placeholder:()=>y?K.jsx("div",{className:Ne.placeholder,children:y}):null}),ErrorBoundary:Lg})}),R.length>0&&K.jsx("div",{"aria-label":"Files to upload",className:Ne.files,role:"region",children:R.map((j,$)=>K.jsx(im.File,{deleteAccessibleLabel:`Remove ${j.name} from upload queue`,name:j.name,onDelete:()=>L(R.filter((G,X)=>X!==$))},`${j.name}-${j.size}-${j.lastModified}-${$}`))}),n&&K.jsx(f_,{}),e&&K.jsx(d_,{matchers:B3}),K.jsx(N_,{}),b&&K.jsx(L3,{createImages:U}),t!==void 0&&K.jsx(o6,{autofocus:n,content:t,lastEmittedContentRef:C}),K.jsx(k_,{validateUrl:Va}),K.jsx(A_,{}),d&&K.jsx(D_,{onChange:(j,$)=>{j.read(()=>{const G=mg($,null),X=Ku(G,{allowedAttributes:{...Ku.defaults.allowedAttributes,img:[...Ku.defaults.allowedAttributes.img??[],"data-solibo-document-id","data-solibo-document-slot"]},allowedTags:["a","b","br","i","img","li","ol","p","u","ul"]});C.current=X,d(X)})}})]})}),l&&i&&K.jsx("div",{className:Ne.error,id:S,children:i})]})};exports.Editor=u6;
56
56
  //# sourceMappingURL=index.cjs.map