@tempots/beatui 0.85.0 → 0.86.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Yu=require("../_commonjsHelpers-DKOUU3wS.cjs"),w=require("@tempots/dom"),wc=require("../link-portal-_tiDFZqh.cjs"),vc=require("../theme-DogY9oT1.cjs"),z_=require("../toolbar-D3ZsC0g_.cjs"),ct=require("../editor-toolbar-group-_V1rDM-1.cjs"),nr=require("../translations-gVgMyNno.cjs"),qu=require("../menu-q8xJaBIb.cjs"),U_=require("../input-container-CSi72GI1.cjs");function L(n,...e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const i of e)r.append("v",i);throw t.search=r.toString(),Error(`Minified Lexical error #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function $h(n,...e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const i of e)r.append("v",i);t.search=r.toString(),console.warn(`Minified Lexical warning #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const Lt=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,K_=Lt&&"documentMode"in document?document.documentMode:null,Nt=Lt&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),$n=Lt&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),oo=!(!Lt||!("InputEvent"in window)||K_)&&"getTargetRanges"in new window.InputEvent("input"),_s=Lt&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),si=Lt&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,W_=Lt&&/Android/.test(navigator.userAgent),Ih=Lt&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Zu=Lt&&W_&&Ih,ys=Lt&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&Nt&&!Ih,j_=0,H_=1,J_=2,G_=1,V_=2,Y_=4,q_=8,Z_=16,X_=32,Q_=64,Ec=128,ey=2047,ty=1,ny=2,ry=3,iy=4,sy=5,oy=6,jo=_s||si||ys?" ":"​",Ho=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Yu=require("../_commonjsHelpers-DKOUU3wS.cjs"),w=require("@tempots/dom"),wc=require("../link-portal-_tiDFZqh.cjs"),vc=require("../theme-DogY9oT1.cjs"),z_=require("../toolbar-D3ZsC0g_.cjs"),ct=require("../editor-toolbar-group-_V1rDM-1.cjs"),nr=require("../translations-gVgMyNno.cjs"),qu=require("../menu-De_-sGeb.cjs"),U_=require("../input-container-CSi72GI1.cjs");function L(n,...e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const i of e)r.append("v",i);throw t.search=r.toString(),Error(`Minified Lexical error #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function $h(n,...e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const i of e)r.append("v",i);t.search=r.toString(),console.warn(`Minified Lexical warning #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const Lt=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,K_=Lt&&"documentMode"in document?document.documentMode:null,Nt=Lt&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),$n=Lt&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),oo=!(!Lt||!("InputEvent"in window)||K_)&&"getTargetRanges"in new window.InputEvent("input"),_s=Lt&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),si=Lt&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,W_=Lt&&/Android/.test(navigator.userAgent),Ih=Lt&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Zu=Lt&&W_&&Ih,ys=Lt&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&Nt&&!Ih,j_=0,H_=1,J_=2,G_=1,V_=2,Y_=4,q_=8,Z_=16,X_=32,Q_=64,Ec=128,ey=2047,ty=1,ny=2,ry=3,iy=4,sy=5,oy=6,jo=_s||si||ys?" ":"​",Ho=`
2
2
 
3
3
  `,ly=$n?" ":jo,Fh="֑-߿יִ-﷽ﹰ-ﻼ",Dh="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",ay=new RegExp("^[^"+Dh+"]*["+Fh+"]"),cy=new RegExp("^[^"+Fh+"]*["+Dh+"]"),Pe={bold:1,capitalize:1024,code:16,highlight:Ec,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},uy={directionless:1,unmergeable:2},Xu={center:2,end:6,justify:4,left:1,right:3,start:5},dy={[ny]:"center",[oy]:"end",[iy]:"justify",[ty]:"left",[ry]:"right",[sy]:"start"},fy={normal:0,segmented:2,token:1},hy={[j_]:"normal",[J_]:"segmented",[H_]:"token"},gy="$",Qu="$config";function Lh(n,e,t,r,i,s){let o=n.getFirstChild();for(;o!==null;){const l=o.__key;o.__parent===e&&(A(o)&&Lh(o,l,t,r,i,s),t.has(l)||s.delete(l),i.push(l)),o=o.getNextSibling()}}let Ma=!1,kc=0;function py(n){kc=n.timeStamp}function Yl(n,e,t){const r=n.nodeName==="BR",i=e.__lexicalLineBreak;return i&&(n===i||r&&n.previousSibling===i)||r&&cl(n,t)!==void 0}function my(n,e,t){const r=kt(Et(t));let i=null,s=null;r!==null&&r.anchorNode===n&&(i=r.anchorOffset,s=r.focusOffset);const o=n.nodeValue;o!==null&&Zc(e,o,i,s,!1)}function _y(n,e,t){if(N(n)){const r=n.anchor.getNode();if(r.is(t)&&n.format!==r.getFormat())return!1}return qt(e)&&t.isAttached()}function yy(n,e,t,r){for(let i=n;i&&!jg(i);i=vs(i)){const s=cl(i,e);if(s!==void 0){const o=q(s,t);if(o)return V(o)||!re(i)?void 0:[i,o]}else if(i===r)return[r,Mg(t)]}}function Rh(n,e,t){Ma=!0;const r=performance.now()-kc>100;try{Wt(n,()=>{const i=O()||(function(f){return f.getEditorState().read(()=>{const h=O();return h!==null?h.clone():null})})(n),s=new Map,o=n.getRootElement(),l=n._editorState,a=n._blockCursorElement;let c=!1,u="";for(let f=0;f<e.length;f++){const h=e[f],g=h.type,p=h.target,m=yy(p,n,l,o);if(!m)continue;const[b,_]=m;if(g==="characterData")r&&D(_)&&qt(p)&&_y(i,p,_)&&my(p,_,n);else if(g==="childList"){c=!0;const y=h.addedNodes;for(let x=0;x<y.length;x++){const v=y[x],k=Vc(v),E=v.parentNode;if(E!=null&&v!==a&&k===null&&!Yl(v,E,n)){if($n){const M=(re(v)?v.innerText:null)||v.nodeValue;M&&(u+=M)}E.removeChild(v)}}const S=h.removedNodes,C=S.length;if(C>0){let x=0;for(let v=0;v<C;v++){const k=S[v];(Yl(k,p,n)||a===k)&&(p.appendChild(k),x++)}C!==x&&s.set(b,_)}}}if(s.size>0)for(const[f,h]of s)h.reconcileObservedMutation(f,n);const d=t.takeRecords();if(d.length>0){for(let f=0;f<d.length;f++){const h=d[f],g=h.addedNodes,p=h.target;for(let m=0;m<g.length;m++){const b=g[m],_=b.parentNode;_==null||b.nodeName!=="BR"||Yl(b,p,n)||_.removeChild(b)}}t.takeRecords()}i!==null&&(c&&Fe(i),$n&&Lg(n)&&i.insertRawText(u))})}finally{Ma=!1}}function Ph(n){const e=n._observer;e!==null&&Rh(n,e.takeRecords(),e)}function Bh(n){(function(e){kc===0&&Et(e).addEventListener("textInput",py,!0)})(n),n._observer=new MutationObserver((e,t)=>{Rh(n,e,t)})}let by=class{key;parse;unparse;isEqual;defaultValue;constructor(e,t){this.key=e,this.parse=t.parse.bind(t),this.unparse=(t.unparse||Cy).bind(t),this.isEqual=(t.isEqual||Object.is).bind(t),this.defaultValue=this.parse(void 0)}};function Tc(n,e){return new by(n,e)}function qi(n,e,t="latest"){const r=(t==="latest"?n.getLatest():n).__state;return r?r.getValue(e):e.defaultValue}function xy(n,e,t){const r=qi(n,t,"direct"),i=qi(e,t,"direct");return t.isEqual(r,i)?null:[r,i]}function Ys(n,e,t){let r;if(Oe(),typeof t=="function"){const s=n.getLatest(),o=qi(s,e);if(r=t(o),e.isEqual(o,r))return s}else r=t;const i=n.getWritable();return Jo(i).updateFromKnown(e,r),i}function zh(n){const e=new Map,t=new Set;for(let r=typeof n=="function"?n:n.replace;r.prototype&&r.prototype.getType!==void 0;r=Object.getPrototypeOf(r)){const{ownNodeConfig:i}=Es(r);if(i&&i.stateConfigs)for(const s of i.stateConfigs){let o;"stateConfig"in s?(o=s.stateConfig,s.flat&&t.add(o.key)):o=s,e.set(o.key,o)}}return{flatKeys:t,sharedConfigMap:e}}let Sy=class Uh{node;knownState;unknownState;sharedNodeState;size;constructor(e,t,r=void 0,i=new Map,s=void 0){this.node=e,this.sharedNodeState=t,this.unknownState=r,this.knownState=i;const{sharedConfigMap:o}=this.sharedNodeState,l=s!==void 0?s:(function(a,c,u){let d=u.size;if(c)for(const f in c){const h=a.get(f);h&&u.has(h)||d++}return d})(o,r,i);this.size=l}getValue(e){const t=this.knownState.get(e);if(t!==void 0)return t;this.sharedNodeState.sharedConfigMap.set(e.key,e);let r=e.defaultValue;if(this.unknownState&&e.key in this.unknownState){const i=this.unknownState[e.key];i!==void 0&&(r=e.parse(i)),this.updateFromKnown(e,r)}return r}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){const e={...this.unknownState},t={};for(const[r,i]of this.knownState)r.isEqual(i,r.defaultValue)?delete e[r.key]:e[r.key]=r.unparse(i);for(const r of this.sharedNodeState.flatKeys)r in e&&(t[r]=e[r],delete e[r]);return ed(e)&&(t.$=e),t}getWritable(e){if(this.node===e)return this;const{sharedNodeState:t,unknownState:r}=this,i=new Map(this.knownState);return new Uh(e,t,(function(s,o,l){let a;if(l)for(const[c,u]of Object.entries(l)){const d=s.get(c);d?o.has(d)||o.set(d,d.parse(u)):(a=a||{},a[c]=u)}return a})(t.sharedConfigMap,i,r),i,this.size)}updateFromKnown(e,t){const r=e.key;this.sharedNodeState.sharedConfigMap.set(r,e);const{knownState:i,unknownState:s}=this;i.has(e)||s&&r in s||(s&&(delete s[r],this.unknownState=ed(s)),this.size++),i.set(e,t)}updateFromUnknown(e,t){const r=this.sharedNodeState.sharedConfigMap.get(e);r?this.updateFromKnown(r,r.parse(t)):(this.unknownState=this.unknownState||{},e in this.unknownState||this.size++,this.unknownState[e]=t)}updateFromJSON(e){const{knownState:t}=this;for(const r of t.keys())t.set(r,r.defaultValue);if(this.size=t.size,this.unknownState=void 0,e)for(const[r,i]of Object.entries(e))this.updateFromUnknown(r,i)}};function Jo(n){const e=n.getWritable(),t=e.__state?e.__state.getWritable(e):new Sy(e,Kh(e));return e.__state=t,t}function Kh(n){return n.__state?n.__state.sharedNodeState:Hc(mi(),n.getType()).sharedNodeState}function ed(n){if(n)for(const e in n)return n}function Cy(n){return n}function td(n,e,t){for(const[r,i]of e.knownState){if(n.has(r.key))continue;n.add(r.key);const s=t?t.getValue(r):r.defaultValue;if(s!==i&&!r.isEqual(s,i))return!0}return!1}function nd(n,e,t){const{unknownState:r}=e,i=t?t.unknownState:void 0;if(r){for(const[s,o]of Object.entries(r))if(!n.has(s)&&(n.add(s),o!==(i?i[s]:void 0)))return!0}return!1}function rd(n,e){const t=n.__state;return t&&t.node===n?t.getWritable(e):t}function id(n,e){const t=n.__mode,r=n.__format,i=n.__style,s=e.__mode,o=e.__format,l=e.__style,a=n.__state,c=e.__state;return(t===null||t===s)&&(r===null||r===o)&&(i===null||i===l)&&(n.__state===null||a===c||(function(u,d){if(u===d)return!0;if(u&&d&&u.size!==d.size)return!1;const f=new Set;return!(u&&td(f,u,d)||d&&td(f,d,u)||u&&nd(f,u,d)||d&&nd(f,d,u))})(a,c))}function sd(n,e){const t=n.mergeWithSibling(e),r=ie()._normalizedNodes;return r.add(n.__key),r.add(e.__key),t}function od(n){let e,t,r=n;if(r.__text!==""||!r.isSimpleText()||r.isUnmergeable()){for(;(e=r.getPreviousSibling())!==null&&D(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(e.__text!==""){if(id(e,r)){r=sd(e,r);break}break}e.remove()}for(;(t=r.getNextSibling())!==null&&D(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==""){if(id(r,t)){r=sd(r,t);break}break}t.remove()}}else r.remove()}function In(n){return ld(n.anchor),ld(n.focus),n}function ld(n){for(;n.type==="element";){const e=n.getNode(),t=n.offset;let r,i;if(t===e.getChildrenSize()?(r=e.getChildAtIndex(t-1),i=!0):(r=e.getChildAtIndex(t),i=!1),D(r)){n.set(r.__key,i?r.getTextContentSize():0,"text",!0);break}if(!A(r))break;n.set(r.__key,i?r.getChildrenSize():0,"element",!0)}}let lr,Ge,Zi,Go,$a,Ia,ar,At,Fa,Xi,ke="",Pt=null,qn=null,Ur=!1,lo=!1;function ao(n,e){const t=ar.get(n);if(e!==null){const r=Pa(n);r.parentNode===e&&e.removeChild(r)}if(At.has(n)||Ge._keyToDOMMap.delete(n),A(t)){const r=uo(t,ar);Da(r,0,r.length-1,null)}t!==void 0&&Qc(Xi,Zi,Go,t,"destroyed")}function Da(n,e,t,r){for(let i=e;i<=t;++i){const s=n[i];s!==void 0&&ao(s,r)}}function Vn(n,e){n.setProperty("text-align",e)}const wy="40px";function Wh(n,e){const t=lr.theme.indent;if(typeof t=="string"){const i=n.classList.contains(t);e>0&&!i?n.classList.add(t):e<1&&i&&n.classList.remove(t)}const r=getComputedStyle(n).getPropertyValue("--lexical-indent-base-value")||wy;n.style.setProperty("padding-inline-start",e===0?"":`calc(${e} * ${r})`)}function jh(n,e){const t=n.style;e===0?Vn(t,""):e===1?Vn(t,"left"):e===2?Vn(t,"center"):e===3?Vn(t,"right"):e===4?Vn(t,"justify"):e===5?Vn(t,"start"):e===6&&Vn(t,"end")}function La(n,e){const t=(function(r){const i=r.__dir;if(i!==null)return i;if(be(r))return null;const s=r.getParentOrThrow();return be(s)&&s.__dir===null?"auto":null})(e);t!==null?n.dir=t:n.removeAttribute("dir")}function co(n,e){const t=At.get(n);t===void 0&&L(60);const r=t.createDOM(lr,Ge);if((function(i,s,o){const l=o._keyToDOMMap;(function(a,c,u){const d=`__lexicalKey_${c._key}`;a[d]=u})(s,o,i),l.set(i,s)})(n,r,Ge),D(t)?r.setAttribute("data-lexical-text","true"):V(t)&&r.setAttribute("data-lexical-decorator","true"),A(t)){const i=t.__indent,s=t.__size;if(La(r,t),i!==0&&Wh(r,i),s!==0){const l=s-1;Ra(uo(t,At),t,0,l,t.getDOMSlot(r))}const o=t.__format;o!==0&&jh(r,o),t.isInline()||Hh(null,t,r)}else{const i=t.getTextContent();if(V(t)){const s=t.decorate(Ge,lr);s!==null&&Jh(n,s),r.contentEditable="false"}ke+=i}return e!==null&&e.insertChild(r),Qc(Xi,Zi,Go,t,"created"),r}function Ra(n,e,t,r,i){const s=ke;ke="";let o=t;for(;o<=r;++o){co(n[o],i);const l=At.get(n[o]);l!==null&&D(l)?Pt===null&&(Pt=l.getFormat(),qn=l.getStyle()):A(l)&&o<r&&!l.isInline()&&(ke+=Ho)}i.element.__lexicalTextContent=ke,ke=s+ke}function ad(n,e){if(n){const t=n.__last;if(t){const r=e.get(t);if(r)return ue(r)?"line-break":V(r)&&r.isInline()?"decorator":null}return"empty"}return null}function Hh(n,e,t){const r=ad(n,ar),i=ad(e,At);r!==i&&e.getDOMSlot(t).setManagedLineBreak(i)}function vy(n,e,t){var r;Pt=null,qn=null,(function(i,s,o){const l=ke,a=i.__size,c=s.__size;ke="";const u=o.element;if(a===1&&c===1){const d=i.__first,f=s.__first;if(d===f)qs(d,u);else{const g=Pa(d),p=co(f,null);try{u.replaceChild(p,g)}catch(m){if(typeof m=="object"&&m!=null){const b=`${m.toString()} Parent: ${u.tagName}, new child: {tag: ${p.tagName} key: ${f}}, old child: {tag: ${g.tagName}, key: ${d}}.`;throw new Error(b)}throw m}ao(d,null)}const h=At.get(f);D(h)&&Pt===null&&(Pt=h.getFormat(),qn=h.getStyle())}else{const d=uo(i,ar),f=uo(s,At);if(d.length!==a&&L(227),f.length!==c&&L(228),a===0)c!==0&&Ra(f,0,0,c-1,o);else if(c===0){if(a!==0){const h=o.after==null&&o.before==null&&o.element.__lexicalLineBreak==null;Da(d,0,a-1,h?null:u),h&&(u.textContent="")}}else(function(h,g,p,m,b,_){const y=m-1,S=b-1;let C,x,v=_.getFirstChild(),k=0,E=0;for(;k<=y&&E<=S;){const I=g[k],K=p[E];if(I===K)v=ql(qs(K,_.element)),k++,E++;else{if(x===void 0&&(x=cd(p,E)),C===void 0)C=cd(g,k);else if(!C.has(I)){k++;continue}if(!x.has(I)){v=ql(Pa(I)),ao(I,_.element),k++,C.delete(I);continue}if(C.has(K)){const R=hr(Ge,K);R!==v&&_.withBefore(v).insertChild(R),v=ql(qs(K,_.element)),k++,E++}else co(K,_.withBefore(v)),E++}const $=At.get(K);$!==null&&D($)?Pt===null&&(Pt=$.getFormat(),qn=$.getStyle()):A($)&&E<=S&&!$.isInline()&&(ke+=Ho)}const M=k>y,T=E>S;if(M&&!T){const I=p[S+1],K=I===void 0?null:Ge.getElementByKey(I);Ra(p,0,E,S,_.withBefore(K))}else T&&!M&&Da(g,k,y,_.element)})(0,d,f,a,c,o)}u.__lexicalTextContent=ke,ke=l+ke})(n,e,e.getDOMSlot(t)),r=e,Pt==null||Pt===r.__textFormat||lo||r.setTextFormat(Pt),(function(i){qn==null||qn===i.__textStyle||lo||i.setTextStyle(qn)})(e)}function uo(n,e){const t=[];let r=n.__first;for(;r!==null;){const i=e.get(r);i===void 0&&L(101),t.push(r),r=i.__next}return t}function qs(n,e){const t=ar.get(n);let r=At.get(n);t!==void 0&&r!==void 0||L(61);const i=Ur||Ia.has(n)||$a.has(n),s=hr(Ge,n);if(t===r&&!i){let o;if(A(t)){const l=s.__lexicalTextContent;typeof l=="string"?o=l:(o=t.getTextContent(),s.__lexicalTextContent=o)}else o=t.getTextContent();return ke+=o,s}if(t!==r&&i&&Qc(Xi,Zi,Go,r,"updated"),r.updateDOM(t,s,lr)){const o=co(n,null);return e===null&&L(62),e.replaceChild(o,s),ao(n,null),o}if(A(t)){A(r)||L(334,n);const o=r.__indent;(Ur||o!==t.__indent)&&Wh(s,o);const l=r.__format;if((Ur||l!==t.__format)&&jh(s,l),i)vy(t,r,s),be(r)||r.isInline()||Hh(t,r,s);else{const a=s.__lexicalTextContent;let c;typeof a=="string"?c=a:(c=t.getTextContent(),s.__lexicalTextContent=c),ke+=c}if((Ur||r.__dir!==t.__dir)&&(La(s,r),be(r)&&!Ur))for(const a of r.getChildren())A(a)&&La(hr(Ge,a.getKey()),a)}else{const o=r.getTextContent();if(V(r)){const l=r.decorate(Ge,lr);l!==null&&Jh(n,l)}ke+=o}if(!lo&&be(r)&&r.__cachedText!==ke){const o=r.getWritable();o.__cachedText=ke,r=o}return s}function Jh(n,e){let t=Ge._pendingDecorators;const r=Ge._decorators;if(t===null){if(r[n]===e)return;t=Og(Ge)}t[n]=e}function ql(n){let e=n.nextSibling;return e!==null&&e===Ge._blockCursorElement&&(e=e.nextSibling),e}function cd(n,e){const t=new Set;for(let r=e;r<n.length;r++)t.add(n[r]);return t}function Ey(n,e,t,r,i,s){ke="",Ur=r===2,Ge=t,lr=t._config,Zi=t._nodes,Go=Ge._listeners.mutation,$a=i,Ia=s,ar=n._nodeMap,At=e._nodeMap,lo=e._readOnly,Fa=new Map(t._keyToDOMMap);const o=new Map;return Xi=o,qs("root",null),Ge=void 0,Zi=void 0,$a=void 0,Ia=void 0,ar=void 0,At=void 0,lr=void 0,Fa=void 0,Xi=void 0,o}function Pa(n){const e=Fa.get(n);return e===void 0&&L(75,n),e}function z(n){return{type:n}}const oi=z("SELECTION_CHANGE_COMMAND"),Nc=z("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),br=z("CLICK_COMMAND"),Ac=z("BEFORE_INPUT_COMMAND"),Oc=z("INPUT_COMMAND"),Mc=z("COMPOSITION_START_COMMAND"),$c=z("COMPOSITION_END_COMMAND"),Ot=z("DELETE_CHARACTER_COMMAND"),cn=z("INSERT_LINE_BREAK_COMMAND"),Fn=z("INSERT_PARAGRAPH_COMMAND"),An=z("CONTROLLED_TEXT_INSERTION_COMMAND"),li=z("PASTE_COMMAND"),Qi=z("REMOVE_TEXT_COMMAND"),cr=z("DELETE_WORD_COMMAND"),ur=z("DELETE_LINE_COMMAND"),ve=z("FORMAT_TEXT_COMMAND"),ai=z("UNDO_COMMAND"),ci=z("REDO_COMMAND"),Ic=z("KEYDOWN_COMMAND"),Vo=z("KEY_ARROW_RIGHT_COMMAND"),fo=z("MOVE_TO_END"),bs=z("KEY_ARROW_LEFT_COMMAND"),es=z("MOVE_TO_START"),dn=z("KEY_ARROW_UP_COMMAND"),dr=z("KEY_ARROW_DOWN_COMMAND"),Dn=z("KEY_ENTER_COMMAND"),Yo=z("KEY_SPACE_COMMAND"),qo=z("KEY_BACKSPACE_COMMAND"),ui=z("KEY_ESCAPE_COMMAND"),Zo=z("KEY_DELETE_COMMAND"),xs=z("KEY_TAB_COMMAND"),ho=z("INSERT_TAB_COMMAND"),Ut=z("INDENT_CONTENT_COMMAND"),sn=z("OUTDENT_CONTENT_COMMAND"),Xo=z("DROP_COMMAND"),Fc=z("FORMAT_ELEMENT_COMMAND"),Qo=z("DRAGSTART_COMMAND"),Dc=z("DRAGOVER_COMMAND"),Gh=z("DRAGEND_COMMAND"),xr=z("COPY_COMMAND"),di=z("CUT_COMMAND"),Xr=z("SELECT_ALL_COMMAND"),Lc=z("CLEAR_EDITOR_COMMAND"),Vh=z("CLEAR_HISTORY_COMMAND"),Fi=z("CAN_REDO_COMMAND"),Di=z("CAN_UNDO_COMMAND"),Rc=z("FOCUS_COMMAND"),fi=z("BLUR_COMMAND"),Yh=z("KEY_MODIFIER_COMMAND"),Xt=Object.freeze({}),Ba=[["keydown",function(n,e){ts=n.timeStamp,qh=n.key,!e.isComposing()&&P(e,Ic,n)}],["pointerdown",function(n,e){const t=n.target,r=n.pointerType;jn(t)&&r!=="touch"&&r!=="pen"&&n.button===0&&Wt(e,()=>{Tg(t)||(Ka=!0)})}],["compositionstart",function(n,e){P(e,Mc,n)}],["compositionend",function(n,e){$n?Li=!0:si||!_s&&!ys?P(e,$c,n):(Wa=!0,ja=n.data)}],["input",function(n,e){n.stopPropagation(),Wt(e,()=>{e.dispatchCommand(Oc,n)},{event:n}),Kr=null}],["click",function(n,e){Wt(e,()=>{const t=O(),r=kt(Et(e)),i=bn();if(r){if(N(t)){const s=t.anchor,o=s.getNode();if(s.type==="element"&&s.offset===0&&t.isCollapsed()&&!be(o)&&fe().getChildrenSize()===1&&o.getTopLevelElementOrThrow().isEmpty()&&i!==null&&t.is(i))r.removeAllRanges(),t.dirty=!0;else if(n.detail===3&&!t.isCollapsed()&&o!==t.focus.getNode()){const l=le(o,a=>A(a)&&!a.isInline());A(l)&&l.select(0)}}else if(n.pointerType==="touch"||n.pointerType==="pen"){const s=r.anchorNode;(re(s)||qt(s))&&Fe(tl(i,r,e,n))}}P(e,br,n)})}],["cut",Xt],["copy",Xt],["dragstart",Xt],["dragover",Xt],["dragend",Xt],["paste",Xt],["focus",Xt],["blur",Xt],["drop",Xt]];oo&&Ba.push(["beforeinput",(n,e)=>(function(t,r){const i=t.inputType;i==="deleteCompositionText"||$n&&Lg(r)||i!=="insertCompositionText"&&P(r,Ac,t)})(n,e)]);let ts=0,qh=null,Zh=0,Kr=null;const za=new WeakMap,go=new WeakMap;let Ua=!1,Ka=!1,Ki=!1,Li=!1,Wa=!1,ja="",Xn=null,Xh=[0,"",0,"root",0];function Qh(n,e,t,r,i){const s=n.anchor,o=n.focus,l=s.getNode(),a=ie(),c=kt(Et(a)),u=c!==null?c.anchorNode:null,d=s.key,f=a.getElementByKey(d),h=t.length;return d!==o.key||!D(l)||(!i&&(!oo||Zh<r+50)||l.isDirty()&&h<2||$g(t))&&s.offset!==o.offset&&!l.isComposing()||Tt(l)||l.isDirty()&&h>1||(i||!oo)&&f!==null&&!l.isComposing()&&u!==fr(f)||c!==null&&e!==null&&(!e.collapsed||e.startContainer!==c.anchorNode||e.startOffset!==c.anchorOffset)||l.getFormat()!==n.format||l.getStyle()!==n.style||(function(g,p){if(p.isSegmented())return!0;if(!g.isCollapsed())return!1;const m=g.anchor.offset,b=p.getParentOrThrow(),_=On(p);return m===0?!p.canInsertTextBefore()||!b.canInsertTextBefore()&&!p.isComposing()||_||(function(y){const S=y.getPreviousSibling();return(D(S)||A(S)&&S.isInline())&&!S.canInsertTextAfter()})(p):m===p.getTextContentSize()&&(!p.canInsertTextAfter()||!b.canInsertTextAfter()&&!p.isComposing()||_)})(n,l)}function ud(n,e){return qt(n)&&n.nodeValue!==null&&e!==0&&e!==n.nodeValue.length}function dd(n,e,t){const{anchorNode:r,anchorOffset:i,focusNode:s,focusOffset:o}=n;Ua&&(Ua=!1,ud(r,i)&&ud(s,o)&&!Xn)||Wt(e,()=>{if(!t)return void Fe(null);if(!pi(e,r,s))return;let l=O();if(Xn&&N(l)&&l.isCollapsed()){const a=l.anchor,c=Xn.anchor;(a.key===c.key&&a.offset===c.offset+1||a.offset===1&&c.getNode().is(a.getNode().getPreviousSibling()))&&(l=Xn.clone(),Fe(l))}if(Xn=null,N(l)){const a=l.anchor,c=a.getNode();if(l.isCollapsed()){n.type==="Range"&&n.anchorNode===n.focusNode&&(l.dirty=!0);const u=Et(e).event,d=u?u.timeStamp:performance.now(),[f,h,g,p,m]=Xh,b=fe(),_=e.isComposing()===!1&&b.getTextContent()==="";if(d<m+200&&a.offset===g&&a.key===p)Zs(l,f,h);else if(a.type==="text")D(c)||L(141),eg(l,c);else if(a.type==="element"&&!_){A(c)||L(259);const y=a.getNode();y.isEmpty()?(function(S,C){const x=C.getTextFormat(),v=C.getTextStyle();Zs(S,x,v)})(l,y):Zs(l,0,"")}}else{const u=a.key,d=l.focus.key,f=l.getNodes(),h=f.length,g=l.isBackward(),p=g?o:i,m=g?i:o,b=g?d:u,_=g?u:d;let y=2047,S=!1;for(let C=0;C<h;C++){const x=f[C],v=x.getTextContentSize();if(D(x)&&v!==0&&!(C===0&&x.__key===b&&p===v||C===h-1&&x.__key===_&&m===0)&&(S=!0,y&=x.getFormat(),y===0))break}l.format=S?y:0}}P(e,oi,void 0)})}function Zs(n,e,t){n.format===e&&n.style===t||(n.format=e,n.style=t,n.dirty=!0)}function eg(n,e){Zs(n,e.getFormat(),e.getStyle())}function tg(n){if(!n.getTargetRanges)return null;const e=n.getTargetRanges();return e.length===0?null:e[0]}function ky(n){const e=n.inputType,t=tg(n),r=ie(),i=O();if(e==="deleteContentBackward"){if(i===null){const d=bn();if(!N(d))return!0;Fe(d.clone())}if(N(i)){const d=i.anchor.key===i.focus.key;if(s=n.timeStamp,qh==="MediaLast"&&s<ts+30&&r.isComposing()&&d){if(Me(null),ts=0,setTimeout(()=>{Wt(r,()=>{Me(null)})},30),N(i)){const f=i.anchor.getNode();f.markDirty(),D(f)||L(142),eg(i,f)}}else{Me(null),n.preventDefault();const f=i.anchor.getNode(),h=f.getTextContent(),g=f.canInsertTextAfter(),p=i.anchor.offset===0&&i.focus.offset===h.length;let m=Zu&&d&&!p&&g;if(m&&i.isCollapsed()&&(m=!V(vo(i.anchor,!0))),!m){P(r,Ot,!0);const b=O();Zu&&N(b)&&b.isCollapsed()&&(Xn=b,setTimeout(()=>Xn=null))}}return!0}}var s;if(!N(i))return!0;const o=n.data;Kr!==null&&qc(!1,r,Kr),i.dirty&&Kr===null||!i.isCollapsed()||be(i.anchor.getNode())||t===null||i.applyDOMRange(t),Kr=null;const l=i.anchor,a=i.focus,c=l.getNode(),u=a.getNode();if(e==="insertText"||e==="insertTranspose"){if(o===`
4
4
  `)n.preventDefault(),P(r,cn,!1);else if(o===Ho)n.preventDefault(),P(r,Fn,void 0);else if(o==null&&n.dataTransfer){const d=n.dataTransfer.getData("text/plain");n.preventDefault(),i.insertRawText(d)}else o!=null&&Qh(i,t,o,n.timeStamp,!0)?(n.preventDefault(),P(r,An,o)):Kr=o;return Zh=n.timeStamp,!0}switch(n.preventDefault(),e){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":P(r,An,n);break;case"insertFromComposition":Me(null),P(r,An,n);break;case"insertLineBreak":Me(null),P(r,cn,!1);break;case"insertParagraph":Me(null),Ki&&!si?(Ki=!1,P(r,cn,!1)):P(r,Fn,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":P(r,li,n);break;case"deleteByComposition":(function(d,f){return d!==f||A(d)||A(f)||!On(d)||!On(f)})(c,u)&&P(r,Qi,n);break;case"deleteByDrag":case"deleteByCut":P(r,Qi,n);break;case"deleteContent":P(r,Ot,!1);break;case"deleteWordBackward":P(r,cr,!0);break;case"deleteWordForward":P(r,cr,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":P(r,ur,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":P(r,ur,!1);break;case"formatStrikeThrough":P(r,ve,"strikethrough");break;case"formatBold":P(r,ve,"bold");break;case"formatItalic":P(r,ve,"italic");break;case"formatUnderline":P(r,ve,"underline");break;case"historyUndo":P(r,ai,void 0);break;case"historyRedo":P(r,ci,void 0)}return!0}function Ty(n){if(re(n.target)&&Tg(n.target))return!0;const e=ie(),t=O(),r=n.data,i=tg(n);if(r!=null&&N(t)&&Qh(t,i,r,n.timeStamp,!1)){Li&&(po(e,r),Li=!1);const s=t.anchor.getNode(),o=kt(Et(e));if(o===null)return!0;const l=t.isBackward(),a=l?t.anchor.offset:t.focus.offset,c=l?t.focus.offset:t.anchor.offset;oo&&!t.isCollapsed()&&D(s)&&o.anchorNode!==null&&s.getTextContent().slice(0,a)+r+s.getTextContent().slice(a+c)===Fg(o.anchorNode)||P(e,An,r);const u=r.length;$n&&u>1&&n.inputType==="insertCompositionText"&&!e.isComposing()&&(t.anchor.offset-=u),_s||si||ys||!e.isComposing()||(ts=0,Me(null))}else qc(!1,e,r!==null?r:void 0),Li&&(po(e,r||void 0),Li=!1);return(function(){Oe();const s=ie();Ph(s)})(),!0}function Ny(n){const e=ie(),t=O();if(N(t)&&!e.isComposing()){const r=t.anchor,i=t.anchor.getNode();Me(r.key),(n.timeStamp<ts+30||r.type==="element"||!t.isCollapsed()||i.getFormat()!==t.format||D(i)&&i.getStyle()!==t.style)&&P(e,An,ly)}return!0}function Ay(n){return po(ie(),n.data),!0}function po(n,e){const t=n._compositionKey;if(Me(null),t!==null&&e!=null){if(e===""){const r=q(t),i=fr(n.getElementByKey(t));return void(i!==null&&i.nodeValue!==null&&D(r)&&Zc(r,i.nodeValue,null,null,!0))}if(e[e.length-1]===`
@@ -5,7 +5,7 @@ import { T as Ec } from "../theme-BzpMLdvH.js";
5
5
  import { b as j_ } from "../toolbar-CjQG7l7X.js";
6
6
  import { E as H_, a as vt } from "../editor-toolbar-group-BslfdazC.js";
7
7
  import { B as Vo, I as Aa } from "../translations-BGblCUBj.js";
8
- import { M as J_, b as G_ } from "../menu-DMAhcoJ2.js";
8
+ import { M as J_, b as G_ } from "../menu-Ui4lUPHM.js";
9
9
  import { I as V_ } from "../input-container-Nx0gMAzS.js";
10
10
  function D(n, ...e) {
11
11
  const t = new URL("https://lexical.dev/docs/error"), r = new URLSearchParams();
@@ -0,0 +1 @@
1
+ "use strict";const e=require("@tempots/dom"),q=require("@tempots/ui"),_=require("./timer-BJHOsuS6.cjs"),W=require("./use-animated-toggle-DrqK7nUS.cjs"),S=require("./session-id-B5lJMzbB.cjs");function K(c){const l={fade:!0,scale:!0};return c.startsWith("top")?(l.slide="down",l.transformOrigin="bottom"):c.startsWith("bottom")?(l.slide="up",l.transformOrigin="top"):c.startsWith("left")?(l.slide="right",l.transformOrigin="right"):c.startsWith("right")&&(l.slide="left",l.transformOrigin="left"),l}function M(c){const{content:l,placement:I="top",showDelay:D=250,hideDelay:L=500,mainAxisOffset:E=8,crossAxisOffset:V=0,showOn:f="hover-focus",closable:g=!0,arrow:w,role:p,hasPopup:T="dialog"}=c;return q.PopOver((v,b)=>{const r=W.useAnimatedElementToggle({initialStatus:"closed"}),O=S.sessionId("flyout"),m=e.prop(!1);let h=null,d=null,F=!1,y;function P(){t!=null&&(clearTimeout(t),t=null),a!=null&&(clearTimeout(a),a=null),d&&(d(),d=null),h&&(document.removeEventListener("keydown",h),h=null),m.set(!1),F=!1}function x(){e.Value.get(g)&&(h=i=>{i.key==="Escape"&&s()},document.addEventListener("keydown",h)),F=!0,m.set(!0),v({placement:I??"top",mainAxisOffset:E,crossAxisOffset:V,arrow:w,content:e.WithElement(i=>{r.setElement(i);const o=typeof f=="function"?null:e.Value.get(f);(o==="hover"||o==="hover-focus")&&(i.addEventListener("mouseenter",()=>n()),i.addEventListener("mouseleave",()=>s())),d=_.g(()=>{r.open(),d=null});const u=A=>{e.Value.get(g)&&A.key==="Escape"&&(A.preventDefault(),A.stopPropagation(),s(),m.set(!1))};document.addEventListener("keydown",u,!0);let k=null;return e.Value.get(g)&&(k=A=>{const C=A.target;!i.contains(C)&&!y?.contains(C)&&s()},document.addEventListener("click",k)),e.Fragment(e.OnDispose(()=>{k&&(document.removeEventListener("click",k),k=null),P(),document.removeEventListener("keydown",u,!0)}),e.attr.class("bc-flyout-container"),W.AnimatedToggleClass({animation:e.Value.map(I,K),status:r.status}),e.attr.id(O),e.attr.tabindex(-1),e.html.div(e.attr.class("bc-flyout"),p?e.attr.role(p):e.attr.role("dialog"),l()))})})}let t=null;function n(){if(t!=null&&(clearTimeout(t),t=null),a!=null&&(clearTimeout(a),a=null),r.isOpened.value||r.isOpening.value||r.isStartOpening.value)return;if(r.isClosing.value||r.isStartClosing.value){r.open();return}const i=e.Value.get(D);t=setTimeout(()=>{t=null,x()},i)}let a=null;function s(){if(t!=null&&(clearTimeout(t),t=null),a!=null&&(clearTimeout(a),a=null),m.set(!1),d&&(d(),d=null,F)){b(),P();return}const i=e.Value.get(L);a=setTimeout(()=>{a=null,r.close(),r.listenOnClosed(()=>{b(),P()})},i)}return e.WithElement(i=>{y=i;const o=()=>{n(),m.set(!0)},u=()=>{s(),m.set(!1)},k=e.Fragment(e.aria.expanded(m),e.aria.controls(O),e.aria.haspopup(T));if(typeof f=="function")return e.Fragment(k,f(o,u));const A=f;return e.Fragment(k,e.OneOfValue(A,{"hover-focus":()=>e.Fragment(e.on.mouseenter(()=>o()),e.on.mouseleave(()=>u()),e.on.focus(()=>o()),e.on.blur(()=>u())),hover:()=>e.Fragment(e.on.mouseenter(()=>o()),e.on.mouseleave(()=>u())),focus:()=>e.Fragment(e.on.focus(()=>o()),e.on.blur(()=>u())),click:()=>{function C(){document.removeEventListener("click",$)}function $(){C(),u()}return e.Fragment(e.OnDispose(C),e.on.click(()=>{o(),_.g(()=>{document.addEventListener("click",$,{once:!0})})}))},never:()=>null}))})})}function H(c){const{items:l,placement:I="bottom-start",showDelay:D=0,hideDelay:L=100,mainAxisOffset:E=4,crossAxisOffset:V=0,showOn:f="click",closable:g=!0,onClose:w,onAction:p,ariaLabel:T,ariaLabelledBy:v}=c,b=S.sessionId("menu"),r=e.prop(-1),O=e.prop([]);let m=null;return M({content:()=>e.WithElement(h=>{m=document.activeElement;const d=(t,n,a)=>{if(n.length===0)return-1;let s=t+a,i=0;for(;i<n.length;){s>=n.length&&(s=0),s<0&&(s=n.length-1);const o=n[s];if(o&&o.getAttribute("aria-disabled")!=="true")return s;s+=a,i++}return t},F=t=>{const n=O.value,a=r.value;switch(t.key){case"ArrowDown":t.preventDefault(),t.stopPropagation();const s=d(a,n,1);y(s,n);break;case"ArrowUp":t.preventDefault(),t.stopPropagation();const i=d(a,n,-1);y(i,n);break;case"Enter":case" ":if(t.preventDefault(),t.stopPropagation(),a>=0&&n[a]){const o=n[a];if(o.getAttribute("aria-disabled")==="true")return;const u=o.getAttribute("data-key");u&&p&&p(u),o.click(),w?.()}break;case"Escape":w?.();break;case"Home":t.preventDefault(),t.stopPropagation(),n.length>0&&y(0,n);break;case"End":t.preventDefault(),t.stopPropagation(),n.length>0&&y(n.length-1,n);break;case"ArrowRight":if(t.preventDefault(),t.stopPropagation(),a>=0&&n[a]){const o=n[a];o.classList.contains("bc-menu-item--has-submenu")&&o.dispatchEvent(new Event("mouseenter"))}break;case"ArrowLeft":t.preventDefault(),t.stopPropagation(),w?.();break}},y=(t,n)=>{r.value>=0&&n[r.value]&&(n[r.value].classList.remove("bc-menu-item--focused"),n[r.value].removeAttribute("aria-selected")),t>=0&&n[t]&&(n[t].classList.add("bc-menu-item--focused"),n[t].setAttribute("aria-selected","true"),r.set(t),typeof n[t].scrollIntoView=="function"&&n[t].scrollIntoView({block:"nearest"}))},P=()=>{const t=Array.from(h.querySelectorAll('[role="menuitem"]'));if(O.set(t),t.length>0){const n=t.findIndex(a=>a.getAttribute("aria-disabled")!=="true");n>=0&&y(n,t)}},x=new MutationObserver(P);return x.observe(h,{childList:!0,subtree:!0}),setTimeout(()=>{P(),h.focus()},0),document.addEventListener("keydown",F,!0),e.Fragment(e.OnDispose(()=>{x.disconnect(),document.removeEventListener("keydown",F,!0),m&&m.focus()}),e.attr.class("bc-menu"),e.attr.id(b),e.attr.role("menu"),e.attr.tabindex(-1),e.aria.orientation("vertical"),T?e.aria.label(T):e.Empty,v?e.aria.labelledby(v):e.Empty,e.aria.activedescendant(r.map(t=>{const n=O.value;return t>=0&&n[t]?n[t].id||`${b}-item-${t}`:""})),e.on.click(t=>{const a=t.target.closest('[role="menuitem"]');if(a&&a.getAttribute("aria-disabled")!=="true"){const s=a.getAttribute("data-key");s&&p&&p(s)}}),e.html.div(e.attr.class("sr-only"),e.aria.live("polite"),e.aria.atomic(!0),r.map(t=>{const n=O.value;if(t>=0&&n[t]){const a=n[t].textContent||"";return n[t].getAttribute("aria-disabled")==="true"?`${a}, disabled`:`${a}, ${t+1} of ${n.length}`}return""})),...l())}),placement:I,showDelay:D,hideDelay:L,mainAxisOffset:E,crossAxisOffset:V,showOn:f,closable:g,role:"menu"})}function z(c){const{key:l,content:I,startContent:D,endContent:L,disabled:E=!1,onClick:V,ariaLabel:f,submenu:g,submenuPlacement:w="right-start"}=c,p=l??S.sessionId("menu-item"),T=`menu-item-${p}`,v=g!=null;return e.html.div(e.attr.class(e.computedOf(E)(b=>`bc-menu-item ${b?"bc-menu-item--disabled":""} ${v?"bc-menu-item--has-submenu":""}`)),e.attr.id(T),e.attr.role("menuitem"),e.attr.tabindex(-1),e.dataAttr.key(p),e.aria.disabled(E),e.aria.selected(!1),v?e.aria.expanded(!1):e.Empty,f?e.aria.label(f):e.Empty,e.on.click(b=>{if(e.Value.get(E)){b.preventDefault(),b.stopPropagation();return}V?.()}),D&&e.html.span(e.attr.class("bc-menu-item__start"),D),e.html.span(e.attr.class("bc-menu-item__content"),I),L&&e.html.span(e.attr.class("bc-menu-item__end"),L),v&&g?M({content:()=>e.Fragment(e.attr.class("bc-menu bc-submenu"),e.attr.role("menu"),...g()),placement:w,showOn:"hover",hasPopup:"menu",showDelay:100,hideDelay:300,mainAxisOffset:0,crossAxisOffset:0,role:"menu"}):e.Empty)}function B(c={}){const{label:l}=c;return e.html.div(e.attr.class("bc-menu-separator"),e.attr.role("separator"),e.aria.orientation("horizontal"),l&&e.html.span(e.attr.class("bc-menu-separator__label"),l))}exports.Flyout=M;exports.Menu=H;exports.MenuItem=z;exports.MenuSeparator=B;
@@ -0,0 +1,373 @@
1
+ import { prop as H, WithElement as q, Fragment as v, aria as u, OneOfValue as j, OnDispose as z, on as p, Value as E, attr as s, html as D, Empty as W, computedOf as G, dataAttr as J } from "@tempots/dom";
2
+ import { PopOver as Q } from "@tempots/ui";
3
+ import { g as R } from "./timer-Rd2sKnvH.js";
4
+ import { u as X, A as Y } from "./use-animated-toggle-89fKlXxy.js";
5
+ import { s as B } from "./session-id-3KiilioY.js";
6
+ function Z(m) {
7
+ const l = { fade: !0, scale: !0 };
8
+ return m.startsWith("top") ? (l.slide = "down", l.transformOrigin = "bottom") : m.startsWith("bottom") ? (l.slide = "up", l.transformOrigin = "top") : m.startsWith("left") ? (l.slide = "right", l.transformOrigin = "right") : m.startsWith("right") && (l.slide = "left", l.transformOrigin = "left"), l;
9
+ }
10
+ function U(m) {
11
+ const {
12
+ content: l,
13
+ placement: P = "top",
14
+ showDelay: x = 250,
15
+ hideDelay: C = 500,
16
+ mainAxisOffset: I = 8,
17
+ crossAxisOffset: V = 0,
18
+ showOn: b = "hover-focus",
19
+ closable: y = !0,
20
+ arrow: L,
21
+ role: g,
22
+ hasPopup: S = "dialog"
23
+ } = m;
24
+ return Q((w, h) => {
25
+ const o = X({
26
+ initialStatus: "closed"
27
+ }), T = B("flyout"), f = H(!1);
28
+ let k = null, d = null, $ = !1, A;
29
+ function _() {
30
+ e != null && (clearTimeout(e), e = null), n != null && (clearTimeout(n), n = null), d && (d(), d = null), k && (document.removeEventListener("keydown", k), k = null), f.set(!1), $ = !1;
31
+ }
32
+ function K() {
33
+ E.get(y) && (k = (i) => {
34
+ i.key === "Escape" && a();
35
+ }, document.addEventListener("keydown", k)), $ = !0, f.set(!0), w({
36
+ placement: P ?? "top",
37
+ mainAxisOffset: I,
38
+ crossAxisOffset: V,
39
+ arrow: L,
40
+ content: q((i) => {
41
+ o.setElement(i);
42
+ const r = typeof b == "function" ? null : E.get(b);
43
+ (r === "hover" || r === "hover-focus") && (i.addEventListener("mouseenter", () => t()), i.addEventListener("mouseleave", () => a())), d = R(() => {
44
+ o.open(), d = null;
45
+ });
46
+ const c = (M) => {
47
+ E.get(y) && M.key === "Escape" && (M.preventDefault(), M.stopPropagation(), a(), f.set(!1));
48
+ };
49
+ document.addEventListener("keydown", c, !0);
50
+ let O = null;
51
+ return E.get(y) && (O = (M) => {
52
+ const F = M.target;
53
+ !i.contains(F) && !A?.contains(F) && a();
54
+ }, document.addEventListener("click", O)), v(
55
+ z(() => {
56
+ O && (document.removeEventListener("click", O), O = null), _(), document.removeEventListener("keydown", c, !0);
57
+ }),
58
+ s.class("bc-flyout-container"),
59
+ Y({
60
+ animation: E.map(P, Z),
61
+ status: o.status
62
+ }),
63
+ s.id(T),
64
+ s.tabindex(-1),
65
+ // Make focusable for screen readers
66
+ D.div(
67
+ s.class("bc-flyout"),
68
+ g ? s.role(g) : s.role("dialog"),
69
+ // Default to dialog role
70
+ l()
71
+ )
72
+ );
73
+ })
74
+ });
75
+ }
76
+ let e = null;
77
+ function t() {
78
+ if (e != null && (clearTimeout(e), e = null), n != null && (clearTimeout(n), n = null), o.isOpened.value || o.isOpening.value || o.isStartOpening.value)
79
+ return;
80
+ if (o.isClosing.value || o.isStartClosing.value) {
81
+ o.open();
82
+ return;
83
+ }
84
+ const i = E.get(x);
85
+ e = setTimeout(() => {
86
+ e = null, K();
87
+ }, i);
88
+ }
89
+ let n = null;
90
+ function a() {
91
+ if (e != null && (clearTimeout(e), e = null), n != null && (clearTimeout(n), n = null), f.set(!1), d && (d(), d = null, $)) {
92
+ h(), _();
93
+ return;
94
+ }
95
+ const i = E.get(C);
96
+ n = setTimeout(() => {
97
+ n = null, o.close(), o.listenOnClosed(() => {
98
+ h(), _();
99
+ });
100
+ }, i);
101
+ }
102
+ return q((i) => {
103
+ A = i;
104
+ const r = () => {
105
+ t(), f.set(!0);
106
+ }, c = () => {
107
+ a(), f.set(!1);
108
+ }, O = v(
109
+ u.expanded(f),
110
+ u.controls(T),
111
+ u.haspopup(
112
+ S
113
+ )
114
+ );
115
+ return typeof b == "function" ? v(
116
+ O,
117
+ b(r, c)
118
+ ) : v(
119
+ O,
120
+ j(b, {
121
+ "hover-focus": () => v(
122
+ p.mouseenter(() => r()),
123
+ p.mouseleave(() => c()),
124
+ p.focus(() => r()),
125
+ p.blur(() => c())
126
+ ),
127
+ hover: () => v(
128
+ p.mouseenter(() => r()),
129
+ p.mouseleave(() => c())
130
+ ),
131
+ focus: () => v(
132
+ p.focus(() => r()),
133
+ p.blur(() => c())
134
+ ),
135
+ click: () => {
136
+ function F() {
137
+ document.removeEventListener("click", N);
138
+ }
139
+ function N() {
140
+ F(), c();
141
+ }
142
+ return v(
143
+ z(F),
144
+ p.click(() => {
145
+ r(), R(() => {
146
+ document.addEventListener("click", N, {
147
+ once: !0
148
+ });
149
+ });
150
+ })
151
+ );
152
+ },
153
+ never: () => null
154
+ })
155
+ );
156
+ });
157
+ });
158
+ }
159
+ function ae(m) {
160
+ const {
161
+ items: l,
162
+ placement: P = "bottom-start",
163
+ showDelay: x = 0,
164
+ hideDelay: C = 100,
165
+ mainAxisOffset: I = 4,
166
+ crossAxisOffset: V = 0,
167
+ showOn: b = "click",
168
+ closable: y = !0,
169
+ onClose: L,
170
+ onAction: g,
171
+ ariaLabel: S,
172
+ ariaLabelledBy: w
173
+ } = m, h = B("menu"), o = H(-1), T = H([]);
174
+ let f = null;
175
+ return U({
176
+ content: () => q((k) => {
177
+ f = document.activeElement;
178
+ const d = (e, t, n) => {
179
+ if (t.length === 0) return -1;
180
+ let a = e + n, i = 0;
181
+ for (; i < t.length; ) {
182
+ a >= t.length && (a = 0), a < 0 && (a = t.length - 1);
183
+ const r = t[a];
184
+ if (r && r.getAttribute("aria-disabled") !== "true")
185
+ return a;
186
+ a += n, i++;
187
+ }
188
+ return e;
189
+ }, $ = (e) => {
190
+ const t = T.value, n = o.value;
191
+ switch (e.key) {
192
+ case "ArrowDown":
193
+ e.preventDefault(), e.stopPropagation();
194
+ const a = d(n, t, 1);
195
+ A(a, t);
196
+ break;
197
+ case "ArrowUp":
198
+ e.preventDefault(), e.stopPropagation();
199
+ const i = d(n, t, -1);
200
+ A(i, t);
201
+ break;
202
+ case "Enter":
203
+ case " ":
204
+ if (e.preventDefault(), e.stopPropagation(), n >= 0 && t[n]) {
205
+ const r = t[n];
206
+ if (r.getAttribute("aria-disabled") === "true")
207
+ return;
208
+ const c = r.getAttribute("data-key");
209
+ c && g && g(c), r.click(), L?.();
210
+ }
211
+ break;
212
+ case "Escape":
213
+ L?.();
214
+ break;
215
+ case "Home":
216
+ e.preventDefault(), e.stopPropagation(), t.length > 0 && A(0, t);
217
+ break;
218
+ case "End":
219
+ e.preventDefault(), e.stopPropagation(), t.length > 0 && A(t.length - 1, t);
220
+ break;
221
+ case "ArrowRight":
222
+ if (e.preventDefault(), e.stopPropagation(), n >= 0 && t[n]) {
223
+ const r = t[n];
224
+ r.classList.contains(
225
+ "bc-menu-item--has-submenu"
226
+ ) && r.dispatchEvent(new Event("mouseenter"));
227
+ }
228
+ break;
229
+ case "ArrowLeft":
230
+ e.preventDefault(), e.stopPropagation(), L?.();
231
+ break;
232
+ }
233
+ }, A = (e, t) => {
234
+ o.value >= 0 && t[o.value] && (t[o.value].classList.remove(
235
+ "bc-menu-item--focused"
236
+ ), t[o.value].removeAttribute("aria-selected")), e >= 0 && t[e] && (t[e].classList.add("bc-menu-item--focused"), t[e].setAttribute("aria-selected", "true"), o.set(e), typeof t[e].scrollIntoView == "function" && t[e].scrollIntoView({ block: "nearest" }));
237
+ }, _ = () => {
238
+ const e = Array.from(
239
+ k.querySelectorAll('[role="menuitem"]')
240
+ );
241
+ if (T.set(e), e.length > 0) {
242
+ const t = e.findIndex(
243
+ (n) => n.getAttribute("aria-disabled") !== "true"
244
+ );
245
+ t >= 0 && A(t, e);
246
+ }
247
+ }, K = new MutationObserver(_);
248
+ return K.observe(k, { childList: !0, subtree: !0 }), setTimeout(() => {
249
+ _(), k.focus();
250
+ }, 0), document.addEventListener("keydown", $, !0), v(
251
+ z(() => {
252
+ K.disconnect(), document.removeEventListener("keydown", $, !0), f && f.focus();
253
+ }),
254
+ s.class("bc-menu"),
255
+ s.id(h),
256
+ s.role("menu"),
257
+ s.tabindex(-1),
258
+ u.orientation("vertical"),
259
+ S ? u.label(S) : W,
260
+ w ? u.labelledby(w) : W,
261
+ u.activedescendant(
262
+ o.map((e) => {
263
+ const t = T.value;
264
+ return e >= 0 && t[e] ? t[e].id || `${h}-item-${e}` : "";
265
+ })
266
+ ),
267
+ p.click((e) => {
268
+ const n = e.target.closest('[role="menuitem"]');
269
+ if (n && n.getAttribute("aria-disabled") !== "true") {
270
+ const a = n.getAttribute("data-key");
271
+ a && g && g(a);
272
+ }
273
+ }),
274
+ // Live region for screen reader announcements
275
+ D.div(
276
+ s.class("sr-only"),
277
+ u.live("polite"),
278
+ u.atomic(!0),
279
+ o.map((e) => {
280
+ const t = T.value;
281
+ if (e >= 0 && t[e]) {
282
+ const n = t[e].textContent || "";
283
+ return t[e].getAttribute("aria-disabled") === "true" ? `${n}, disabled` : `${n}, ${e + 1} of ${t.length}`;
284
+ }
285
+ return "";
286
+ })
287
+ ),
288
+ ...l()
289
+ );
290
+ }),
291
+ placement: P,
292
+ showDelay: x,
293
+ hideDelay: C,
294
+ mainAxisOffset: I,
295
+ crossAxisOffset: V,
296
+ showOn: b,
297
+ closable: y,
298
+ role: "menu"
299
+ });
300
+ }
301
+ function re(m) {
302
+ const {
303
+ key: l,
304
+ content: P,
305
+ startContent: x,
306
+ endContent: C,
307
+ disabled: I = !1,
308
+ onClick: V,
309
+ ariaLabel: b,
310
+ submenu: y,
311
+ submenuPlacement: L = "right-start"
312
+ } = m, g = l ?? B("menu-item"), S = `menu-item-${g}`, w = y != null;
313
+ return D.div(
314
+ s.class(
315
+ G(I)(
316
+ (h) => `bc-menu-item ${h ? "bc-menu-item--disabled" : ""} ${w ? "bc-menu-item--has-submenu" : ""}`
317
+ )
318
+ ),
319
+ s.id(S),
320
+ s.role("menuitem"),
321
+ s.tabindex(-1),
322
+ J.key(g),
323
+ u.disabled(I),
324
+ u.selected(!1),
325
+ // Will be updated by focus management
326
+ w ? u.expanded(!1) : W,
327
+ b ? u.label(b) : W,
328
+ p.click((h) => {
329
+ if (E.get(I)) {
330
+ h.preventDefault(), h.stopPropagation();
331
+ return;
332
+ }
333
+ V?.();
334
+ }),
335
+ // Start content
336
+ x && D.span(s.class("bc-menu-item__start"), x),
337
+ // Main content
338
+ D.span(s.class("bc-menu-item__content"), P),
339
+ // End content
340
+ C && D.span(s.class("bc-menu-item__end"), C),
341
+ // Submenu (if present)
342
+ w && y ? U({
343
+ content: () => v(
344
+ s.class("bc-menu bc-submenu"),
345
+ s.role("menu"),
346
+ ...y()
347
+ ),
348
+ placement: L,
349
+ showOn: "hover",
350
+ hasPopup: "menu",
351
+ showDelay: 100,
352
+ hideDelay: 300,
353
+ mainAxisOffset: 0,
354
+ crossAxisOffset: 0,
355
+ role: "menu"
356
+ }) : W
357
+ );
358
+ }
359
+ function le(m = {}) {
360
+ const { label: l } = m;
361
+ return D.div(
362
+ s.class("bc-menu-separator"),
363
+ s.role("separator"),
364
+ u.orientation("horizontal"),
365
+ l && D.span(s.class("bc-menu-separator__label"), l)
366
+ );
367
+ }
368
+ export {
369
+ U as F,
370
+ ae as M,
371
+ le as a,
372
+ re as b
373
+ };
@@ -1,4 +1,4 @@
1
- import { Value } from '@tempots/dom';
1
+ import { Renderable, Value } from '@tempots/dom';
2
2
  import { InputOptions } from './input-options';
3
3
  import { DropdownOption } from './option';
4
4
  import { BaseControllerOptions, ControllerOptions } from '../control';
@@ -51,7 +51,7 @@ export type ComboboxTagsOptions<T> = {
51
51
  * })
52
52
  * ```
53
53
  */
54
- export declare function ComboboxTagsInput<T>(options: ComboboxTagsOptions<T>): import("@tempots/dom").Renderable;
54
+ export declare function ComboboxTagsInput<T>(options: ComboboxTagsOptions<T>): Renderable;
55
55
  /**
56
56
  * A base form control wrapper for {@link ComboboxTagsInput} using a raw controller.
57
57
  *
@@ -67,4 +67,4 @@ export declare function BaseComboboxTagsControl<T>(options: BaseControllerOption
67
67
  * @param options - Controller options for the combobox tags control.
68
68
  * @returns A renderable form control component with wrapper.
69
69
  */
70
- export declare function ComboboxTagsControl<T>(options: ControllerOptions<T[], ComboboxTagsOptions<T>>): import("@tempots/dom").Renderable;
70
+ export declare function ComboboxTagsControl<T>(options: ControllerOptions<T[], ComboboxTagsOptions<T>>): Renderable;
@@ -1 +1 @@
1
- "use strict";const t=require("@tempots/dom"),F=require("./deep-merge-UghuPcyW.cjs"),ct=require("./string-B9vVyfq3.cjs"),D=require("./input-container-CSi72GI1.cjs"),S=require("./text-input-8v79fzEy.cjs"),N=require("./translations-gVgMyNno.cjs"),ut=require("@tempots/ui"),z=require("./notice-Bc1L4Zpr.cjs"),pt=require("./session-id-B5lJMzbB.cjs"),dt=require("./utils-DIUEhA-Z.cjs");function q(e){if(typeof e!="string")return!1;const n=e.startsWith("#")?e.slice(1):e;return/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(n)}function X(e){if(typeof e!="string")return!1;const n=/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i,r=e.match(n);if(!r)return!1;const[,a,o,s]=r,l=parseInt(a,10),i=parseInt(o,10),c=parseInt(s,10);return l>=0&&l<=255&&i>=0&&i<=255&&c>=0&&c<=255}function Y(e){if(typeof e!="string")return!1;const n=/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0?\.\d+)\s*\)$/i,r=e.match(n);if(!r)return!1;const[,a,o,s,l]=r,i=parseInt(a,10),c=parseInt(o,10),u=parseInt(s,10),p=parseFloat(l);return i>=0&&i<=255&&c>=0&&c<=255&&u>=0&&u<=255&&p>=0&&p<=1}function G(e){if(typeof e!="string")return!1;const n=/^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/i,r=e.match(n);if(!r)return!1;const[,a,o,s]=r,l=parseInt(a,10),i=parseInt(o,10),c=parseInt(s,10);return l>=0&&l<=360&&i>=0&&i<=100&&c>=0&&c<=100}function gt(e){return q(e)||X(e)||Y(e)||G(e)}function K(e){if(!q(e))return null;let n=e.startsWith("#")?e.slice(1):e;return n.length===3&&(n=n.split("").map(r=>r+r).join("")),`#${n.toLowerCase()}`}function W(e,n,r){const a=o=>{const s=Math.round(Math.max(0,Math.min(255,o))).toString(16);return s.length===1?"0"+s:s};return`#${a(e)}${a(n)}${a(r)}`}function E(e){const n=K(e);if(!n)return null;const r=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return r?{r:parseInt(r[1],16),g:parseInt(r[2],16),b:parseInt(r[3],16)}:null}function ht(e,n){const r=E(e),a=E(n);if(!r||!a)return null;const o=(u,p,h)=>{const[m,d,b]=[u,p,h].map(I=>(I=I/255,I<=.03928?I/12.92:Math.pow((I+.055)/1.055,2.4)));return .2126*m+.7152*d+.0722*b},s=o(r.r,r.g,r.b),l=o(a.r,a.g,a.b),i=Math.max(s,l),c=Math.min(s,l);return(i+.05)/(c+.05)}function Q(e){if(!e)return[0,0,0,1];const r=e.trim().match(/^#?([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/);if(r){const u=r[1];if(u.length===8){const p=parseInt(u.slice(0,2),16),h=parseInt(u.slice(2,4),16),m=parseInt(u.slice(4,6),16),d=parseInt(u.slice(6,8),16)/255;return[p,h,m,d]}if(u.length===6)return[parseInt(u.slice(0,2),16),parseInt(u.slice(2,4),16),parseInt(u.slice(4,6),16),1];if(u.length===4){const p=parseInt(u[0]+u[0],16),h=parseInt(u[1]+u[1],16),m=parseInt(u[2]+u[2],16),d=parseInt(u[3]+u[3],16)/255;return[p,h,m,d]}if(u.length===3){const p=parseInt(u[0]+u[0],16),h=parseInt(u[1]+u[1],16),m=parseInt(u[2]+u[2],16);return[p,h,m,1]}}const a=e.match(/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0?\.\d+)\s*\)$/i);if(a)return[parseInt(a[1],10),parseInt(a[2],10),parseInt(a[3],10),parseFloat(a[4])];const o=e.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i);if(o)return[parseInt(o[1],10),parseInt(o[2],10),parseInt(o[3],10),1];const s=e.match(/^hsla?\(\s*([+-]?[\d.]+)(?:deg)?\s*[ ,]?\s*([\d.]+)%\s*[ ,]?\s*([\d.]+)%\s*(?:[/,]\s*(\d?(?:\.\d+)?))?\s*\)$/i);if(s){const u=parseFloat(s[1]),p=parseFloat(s[2]),h=parseFloat(s[3]),m=s[4]!=null?parseFloat(s[4]):1,[d,b,I]=j(u,p/100,h/100);return[d,b,I,m]}const l=e.match(/^hwb\(\s*([+-]?[\d.]+)(?:deg)?\s*[, ]\s*([\d.]+)%\s*[, ]\s*([\d.]+)%\s*(?:[/]\s*(\d?(?:\.\d+)?))?\s*\)$/i);if(l){const u=parseFloat(l[1]),p=parseFloat(l[2])/100,h=parseFloat(l[3])/100,m=l[4]!=null?parseFloat(l[4]):1,[d,b,I]=tt(u,p,h);return[d,b,I,m]}const i=e.match(/^oklch\(\s*([+-]?[\d.]+%?)\s+([\d.]+)\s+([+-]?[\d.]+)(?:deg)?(?:\s*\/\s*(\d?(?:\.\d+)?))?\s*\)$/i);if(i){const u=i[1],p=parseFloat(i[2]),h=parseFloat(i[3]),m=i[4]!=null?parseFloat(i[4]):1,d=u.endsWith("%")?Math.max(0,Math.min(1,parseFloat(u)/100)):Math.max(0,Math.min(1,parseFloat(u))),[b,I,V]=nt(d,p,h);return[b,I,V,m]}const c=E(e);return c?[c.r,c.g,c.b,1]:[0,0,0,1]}function Z(e,n,r,a){return`rgba(${Math.round(e)}, ${Math.round(n)}, ${Math.round(r)}, ${Math.max(0,Math.min(1,Math.round(a*100)/100))})`}function J(e){let n=e+1831565813;return function(){return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function j(e,n,r){e=(e%360+360)%360;const a=(1-Math.abs(2*r-1))*n,o=a*(1-Math.abs(e/60%2-1)),s=r-a/2;let l=0,i=0,c=0;return 0<=e&&e<60?[l,i,c]=[a,o,0]:60<=e&&e<120?[l,i,c]=[o,a,0]:120<=e&&e<180?[l,i,c]=[0,a,o]:180<=e&&e<240?[l,i,c]=[0,o,a]:240<=e&&e<300?[l,i,c]=[o,0,a]:[l,i,c]=[a,0,o],[Math.round((l+s)*255),Math.round((i+s)*255),Math.round((c+s)*255)]}function tt(e,n,r){e=(e%360+360)%360;const a=n+r;a>1&&(n/=a,r/=a);const[o,s,l]=j(e,1,.5).map(h=>h/255),i=1-n-r,c=o*i+n,u=s*i+n,p=l*i+n;return[Math.round(c*255),Math.round(u*255),Math.round(p*255)]}function H(e,n,r){e/=255,n/=255,r/=255;const a=Math.max(e,n,r),o=Math.min(e,n,r);let s=0,l=0;const i=(a+o)/2,c=a-o;if(c!==0){switch(l=i>.5?c/(2-a-o):c/(a+o),a){case e:s=(n-r)/c+(n<r?6:0);break;case n:s=(r-e)/c+2;break;default:s=(e-n)/c+4}s*=60}return[Math.round(s),Math.round(l*100),Math.round(i*100)]}function et(e,n,r){const[a]=H(e,n,r),o=e/255,s=n/255,l=r/255,i=Math.min(o,s,l),c=1-Math.max(o,s,l);return[a,Math.round(i*100),Math.round(c*100)]}function O(e){const n=e/255;return n<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function U(e){const n=e<=.0031308?12.92*e:1.055*Math.pow(e,.4166666666666667)-.055;return Math.round(Math.max(0,Math.min(1,n))*255)}function nt(e,n,r){const a=r*Math.PI/180,o=Math.cos(a)*n,s=Math.sin(a)*n,l=e+.3963377774*o+.2158037573*s,i=e-.1055613458*o-.0638541728*s,c=e-.0894841775*o-1.291485548*s,u=l*l*l,p=i*i*i,h=c*c*c,m=4.0767416621*u-3.3077115913*p+.2309699292*h,d=-1.2684380046*u+2.6097574011*p-.3413193965*h,b=-.0041960863*u-.7034186147*p+1.707614701*h;return[U(m),U(d),U(b)]}function at(e,n,r){const a=O(e),o=O(n),s=O(r),l=.4122214708*a+.5363325363*o+.0514459929*s,i=.2119034982*a+.6806995451*o+.1073969566*s,c=.0883024619*a+.2817188376*o+.6299787005*s,u=Math.cbrt(l),p=Math.cbrt(i),h=Math.cbrt(c),m=.2104542553*u+.793617785*p-.0040720468*h,d=1.9779984951*u-2.428592205*p+.4505937099*h,b=.0259040371*u+.7827717662*p-.808675766*h,I=Math.sqrt(d*d+b*b);let V=Math.atan2(b,d)*180/Math.PI;return V<0&&(V+=360),[m,I,V]}function R(e,n,r,a,o,s){switch(o){case"hex":if(s){const l=c=>c.toString(16).padStart(2,"0"),i=Math.max(0,Math.min(255,Math.round(a*255)));return`#${l(e)}${l(n)}${l(r)}${l(i)}`}return W(e,n,r);case"rgb":return`rgb(${e}, ${n}, ${r})`;case"rgba":return`rgba(${e}, ${n}, ${r}, ${Math.round(a*100)/100})`;case"hsl":{const[l,i,c]=H(e,n,r);return`hsl(${l}, ${i}%, ${c}%)`}case"hsla":{const[l,i,c]=H(e,n,r);return`hsla(${l}, ${i}%, ${c}%, ${Math.round(a*100)/100})`}case"hwb":{const[l,i,c]=et(e,n,r);return a<1?`hwb(${l} ${i}% ${c}% / ${Math.round(a*100)/100})`:`hwb(${l} ${i}% ${c}%)`}case"oklch":{const[l,i,c]=at(e,n,r),u=(Math.round(l*1e3)/1e3).toFixed(3),p=(Math.round(i*1e3)/1e3).toFixed(3),h=(Math.round(c*10)/10).toFixed(1),m=Math.round(a*100)/100;return s||a<1?`oklch(${u} ${p} ${h} / ${m})`:`oklch(${u} ${p} ${h})`}}}function v(e,n){return n?e==="rgb"?"rgba":e==="hsl"?"hsla":e:e==="rgba"?"rgb":e==="hsla"?"hsl":e}async function rt(e){return new Promise((n,r)=>{const a=new FileReader;a.readAsDataURL(e),a.onload=()=>{const o=a.result;n(o.split(",")[1])},a.onerror=o=>r(o)})}function mt(e){return Promise.all(e.map(rt))}function ft(e){if(e.length>=4){if(e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71)return"image/png";if(e[0]===255&&e[1]===216)return"image/jpeg";if(e[0]===71&&e[1]===73&&e[2]===70)return"image/gif";if(e[0]===82&&e[1]===73&&e[2]===70&&e[3]===70&&e.length>=12&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80)return"image/webp"}try{if(new TextDecoder("utf-8").decode(e.slice(0,256)).includes("<svg"))return"image/svg+xml"}catch{}return"application/octet-stream"}function bt(e){const n=ct.$t(e??""),r=n.length,a=new Uint8Array(r);for(let o=0;o<r;o++)a[o]=n.charCodeAt(o);return a}function st(e){const{value:n,onChange:r,onInput:a,...o}=e,s=new Map,l=t.Value.toSignal(n).map(p=>p.map((h,m)=>{const d=s.get(h),b=bt(h??""),I=d?.type||ft(b),V=d?.name??`file-${m}`,y=b.buffer.slice(b.byteOffset,b.byteOffset+b.byteLength),f=new Blob([y],{type:I});return new File([f],V,{type:I})})),i=p=>h=>{p&&mt(h).then(m=>{for(const[d,b]of m.entries())s.set(b,{name:h[d].name,type:h[d].type});p(m)})},c=i(r),u=i(a);return F.FilesInput({...o,value:l,onChange:c,onInput:u})}function yt(e){const{value:n,onInput:r,onChange:a,...o}=e;return st({...o,maxFiles:1,value:t.Value.map(n,s=>s==null?[]:[s]),onChange:s=>{a?.(s[0])},onInput:s=>{r?.(s[0])}})}function It(e,n){const[r,a,o]=e,s=r<<16^a<<8^o,l=J(s),i=6+Math.floor(l()*5),c=.18+l()*.06,u=[];for(let d=0;d<i;d++){const b=d/i*Math.PI*2,I=n*(1+(l()*2-1)*c),V=Math.cos(b)*I,y=Math.sin(b)*I;u.push({x:V,y})}const p=(u[0].x+u[i-1].x)/2,h=(u[0].y+u[i-1].y)/2;let m=`M ${p.toFixed(3)} ${h.toFixed(3)}`;for(let d=0;d<i;d++){const b=u[d],I=u[(d+1)%i],V=(b.x+I.x)/2,y=(b.y+I.y)/2;m+=` Q ${b.x.toFixed(3)} ${b.y.toFixed(3)} ${V.toFixed(3)} ${y.toFixed(3)}`}return m+=" Z",m}const wt=e=>{const{value:n,onBlur:r,onChange:a,onInput:o,displayValue:s,size:l,withAlpha:i}=e,c=t.Value.map(l??32,g=>g),u=t.Value.map(n,g=>Q(g??"#000000")),p=t.Value.map(u,([g,w,$])=>[g,w,$]),h=t.Value.map(u,([,,,g])=>g),m=t.prop(t.Value.get(h)??1),d=t.Value.map(i??!1,g=>g),b=t.Value.map(e.colorTextFormat??"rgb",g=>g),I=t.computedOf(p,m,b,d)(([g,w,$],C,A,T)=>R(g,w,$,C??1,v(A,T),T)),V=t.Value.map(e.colorTextFormat??"hex",g=>g),y=t.Value.map(c,g=>`${-g/2} ${-g/2} ${g} ${g}`),f=t.computedOf(p,c)((g,w)=>It(g,w/2)),M=t.computedOf(p,m,d)(([g,w,$],C,A)=>A||C<1?Z(g,w,$,C):W(g,w,$)),_=t.html.div(t.attr.class("bc-color-swatch-input__control"),t.attr.class(t.Value.map(d,g=>g?"bc-color-swatch-input__control--alpha":"")),t.attr.style(t.computedOf(c)(g=>`min-width:${g+2}px;height:${g+2}px`)),t.svg.svg(t.attr.class("bc-color-swatch-input__svg"),t.svgAttr.viewBox(y),t.svg.path(t.svgAttr.d(f),t.svgAttr.fill(M))),t.html.input(t.attr.type("color"),S.CommonInputAttributes(e),t.attr.value(t.Value.map(p,([g,w,$])=>W(g,w,$))),t.attr.class("bc-input bc-color-swatch-input bc-color-swatch-input__native"),r!=null?t.on.blur(r):t.Empty,a!=null?t.on.change(g=>{const w=g.target.value;if(!a)return;const{r:$,g:C,b:A}=E(w)??{r:0,g:0,b:0},T=t.Value.get(m)??1,k=v(t.Value.get(V),t.Value.get(d)),L=R($,C,A,T,k,t.Value.get(d));a(L)}):t.Empty,o!=null?t.on.input(g=>{const w=g.target.value;if(!o)return;const{r:$,g:C,b:A}=E(w)??{r:0,g:0,b:0},T=t.Value.get(m)??1,k=v(t.Value.get(V),t.Value.get(d)),L=R($,C,A,T,k,t.Value.get(d));o(L)}):t.Empty)),x=t.When(d,()=>t.html.input(t.attr.type("range"),t.attr.class("bc-color-swatch-input__alpha"),t.attr.min(0),t.attr.max(1),t.attr.step(.01),t.attr.value(t.Value.map(m,g=>String(g??1))),t.attr.disabled(e.disabled),t.on.input(g=>{const w=parseFloat(g.target.value);m.set(w);const[$,C,A]=t.Value.get(p),T=v(t.Value.get(V),t.Value.get(d)),k=R($,C,A,w,T,t.Value.get(d));o?.(k)}),t.on.change(g=>{const w=parseFloat(g.target.value);m.set(w);const[$,C,A]=t.Value.get(p),T=v(t.Value.get(V),t.Value.get(d)),k=R($,C,A,w,T,t.Value.get(d));a?.(k)})));return D.InputContainer({baseContainer:!0,...e,growInput:!1,input:_,after:t.Fragment(t.When(s??!1,()=>t.html.span(t.attr.class("bc-color-swatch-input__rgb"),I)),x,e.after)})},Vt=({startEditing:e,value:n,onChange:r,placeholder:a,disabled:o})=>{const s=t.Value.deriveProp(e??!1),l=t.prop(!1),i=t.Value.map(o??!1,c=>c);return t.html.div(t.attr.class("bc-editable-text"),t.attr.class(t.Value.map(i,c=>c?"bc-editable-text--disabled":"")),t.aria.disabled(i),t.When(s,()=>t.html.input(t.attr.placeholder(a),t.attr.value(n),t.attr.class("bc-editable-text__input"),ut.AutoSelect(),t.on.keydown(c=>{c.key==="Enter"?s.set(!1):c.key==="Escape"&&(l.set(!0),s.set(!1))}),t.on.blur(t.emitValue(c=>{if(s.set(!1),l.value){l.set(!1);return}r(c)}))),()=>t.html.span(t.on.click(()=>{t.Value.get(i)||s.set(!0)}),t.attr.class("bc-editable-text__display"),t.When(t.Value.map(n,c=>c!=null&&c.trim()!==""),()=>t.html.span(t.attr.class("bc-editable-text__text"),n),()=>t.html.span(t.attr.class("bc-editable-text__placeholder"),a)),t.When(t.Value.map(i,c=>!c),()=>t.html.button(t.attr.type("button"),t.attr.class("bc-editable-text__edit-button"),t.Use(N.BeatUII18n,c=>t.aria.label(c.$.editLabel)),t.on.click(()=>s.set(!0)),N.Icon({icon:"line-md/pencil",color:"neutral"}))))))},Mt=e=>{const{value:n,onBlur:r,onChange:a,onInput:o,after:s,disabled:l}=e,i=F.NullableResetAfter(n,l,a??o);return D.InputContainer({...e,input:t.input.date(S.CommonInputAttributes(e),t.attr.valueAsDate(n),t.attr.class("bc-input"),r!=null?t.on.blur(t.emitValue(r)):t.Empty,a!=null?t.on.change(t.emitValueAsNullableDate(a)):t.Empty,o!=null?t.on.input(t.emitValueAsNullableDate(o)):t.Empty),after:s!=null?t.Fragment(i,s):i})},$t=e=>{const n=e.getFullYear(),r=e.getMonth()+1,a=e.getDate(),o=e.getHours(),s=e.getMinutes(),l=e.getSeconds();return`${n}-${r.toString().padStart(2,"0")}-${a.toString().padStart(2,"0")}T${o.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}:${l.toString().padStart(2,"0")}`},xt=e=>{const{value:n,onBlur:r,onChange:a,onInput:o,after:s,disabled:l}=e,i=t.Value.map(n,u=>u!=null?$t(u):null),c=F.NullableResetAfter(n,l,a??o);return D.InputContainer({...e,input:t.input["datetime-local"](S.CommonInputAttributes(e),t.attr.value(t.Value.map(i,u=>u??null)),t.attr.class("bc-input"),r!=null?t.on.blur(t.emitValue(r)):t.Empty,a!=null?t.on.change(t.emitValueAsNullableDateTime(a)):t.Empty,o!=null?t.on.input(t.emitValueAsNullableDateTime(o)):t.Empty),after:s!=null?t.Fragment(c,s):c})},P=e=>typeof e=="string"&&e.trim()===""?null:e,ot=e=>e??"";function B(e){return n=>{const{value:r,onBlur:a,onChange:o,onInput:s,after:l,disabled:i,...c}=n,u=F.NullableResetAfter(r,i,o??s);return e({...c,disabled:i,value:t.Value.map(r,ot),onChange:o!=null?p=>o(P(p)):void 0,onInput:s!=null?p=>s(P(p)):void 0,onBlur:a,after:l!=null?t.Fragment(u,l):u})}}const _t=B(z.EmailInput),Ct=B(S.TextInput),At=B(z.PasswordInput),Tt=B(F.TextArea),Ft=({value:e,onChange:n,onInput:r,onBlur:a,offLabel:o,onLabel:s,disabled:l=!1,size:i="md",id:c,color:u="primary",tabIndex:p=0,matchInputHeight:h=!0})=>{const m=c??pt.sessionId("switch");function d(y,f){const M=["bc-switch",`bc-switch--size-${f}`,`bc-switch--${f}`];return h&&M.push("bc-switch--match-input"),y&&M.push("bc-switch--disabled"),M.join(" ")}function b(y){const f=y??"primary",M=new Map,_=N.backgroundValue(f,"solid","light"),x=N.backgroundValue(f,"solid","dark");return M.set("--switch-track-on-bg",_.backgroundColor),M.set("--switch-track-on-label",_.textColor),M.set("--switch-track-on-bg-dark",x.backgroundColor),M.set("--switch-track-on-label-dark",x.textColor),M.set("--switch-track-on-border-dark",N.borderColorValue(f,"dark")),Array.from(M.entries()).map(([g,w])=>`${g}: ${w}`).join("; ")}const I=()=>{t.Value.get(l)||(n?.(!t.Value.get(e)),r?.(!t.Value.get(e)))},V=y=>{t.Value.get(l)||(y.key===" "||y.key==="Enter")&&(y.preventDefault(),I())};return t.html.div(t.attr.class(t.computedOf(l??!1,i)((y,f)=>d(y??!1,f??"md"))),t.attr.style(t.computedOf(u)(y=>b(y))),t.attr.id(m),t.attr.role("switch"),t.attr.tabindex(t.computedOf(l??!1,p)((y,f)=>y?-1:f??0)),t.aria.checked(e),t.aria.disabled(l),t.on.click(I),t.on.keydown(V),a!=null?t.on.blur(a):null,t.html.div(t.attr.class("bc-switch__track"),t.attr.class(t.Value.map(e,y=>y?"bc-switch__track--on":"bc-switch__track--off")),o!=null?t.html.div(t.aria.hidden(!0),t.attr.class("bc-switch__track-label bc-switch__track-label--off"),t.attr.class(t.Value.map(e,y=>y?"bc-switch__track-label--hidden":"bc-switch__track-label--visible")),o):null,s!=null?t.html.div(t.attr.class("bc-switch__track-label bc-switch__track-label--on"),t.attr.class(t.Value.map(e,y=>y?"bc-switch__track-label--visible":"bc-switch__track-label--hidden")),s):null,t.html.div(t.attr.class("bc-switch__thumb"),t.attr.class(t.Value.map(e,y=>y?"bc-switch__thumb--on":"bc-switch__thumb--off")))))},kt=B(F.UUIDInput),Nt="line-md:star-alt-filled",St="line-md:star-alt",lt=e=>{const{value:n,onChange:r,disabled:a,max:o=5,fullColor:s="yellow",emptyColor:l="neutral",fullIcon:i=Nt,emptyIcon:c=St,size:u="md",onBlur:p,rounding:h=1}=e,m=()=>{const f=t.Value.get(h);return f>0?f:1},d=f=>Math.min(Math.max(f,0),t.Value.get(o)),b=(f,M)=>{if(t.Value.get(a??!1))return;const x=f.currentTarget.getBoundingClientRect(),g=(f.clientX-x.left)/x.width,w=M-1+g,$=m(),C=Math.ceil(w/$)*$,A=d(C);r?.(A)},I=f=>{if(t.Value.get(a??!1))return;const M=m(),_=t.Value.get(n)??0;let x;switch(f.key){case"ArrowRight":case"ArrowUp":x=d(_+M);break;case"ArrowLeft":case"ArrowDown":x=d(_-M);break;case"Home":x=0;break;case"End":x=t.Value.get(o);break;default:return}f.preventDefault(),r?.(x)},V=t.Value.map(u,f=>`bc-icon--${f}`),y=({index:f,counter:M})=>t.html.span(t.attr.class("bc-rating-input__icon-container"),t.attr.class(V),N.Icon({icon:c,size:u,color:l,tone:"soft"},t.attr.class("bc-rating-input__icon-empty")),t.html.span(t.attr.class("bc-rating-input__icon-clipper"),t.attr.class(V),t.style.width(t.Value.map(n,_=>{const x=Math.floor(_);return x>f?"100%":x<f?"0%":`${(_-f)*100}%`})),N.Icon({icon:i,size:u,color:s,tone:"soft"},t.attr.class("bc-rating-input__icon-full"))),t.on.click(t.emit(_=>b(_,M),{preventDefault:!0,stopPropagation:!0})));return D.InputContainer({baseContainer:!0,growInput:!1,focusableSelector:'[role="slider"]',...e,input:t.html.div(S.CommonInputAttributes(e),t.attr.class("bc-rating-input"),t.attr.role("slider"),t.attr.tabindex(t.Value.map(a??!1,f=>f?-1:0)),t.aria.disabled(a??!1),t.aria.valuemin(0),t.aria.valuemax(t.Value.map(o,f=>f??0)),t.aria.valuenow(t.Value.map(n,f=>f??0)),t.aria.valuetext(t.computedOf(n,o)((f,M)=>{const _=f??0,x=M??0;return`${String(_)} / ${String(x)}`})),t.on.keydown(I),p!=null?t.on.blur(p):null,t.Repeat(o,y))})},Rt=e=>{const{value:n,onChange:r,onInput:a,onBlur:o,after:s,disabled:l,...i}=e,c=F.NullableResetAfter(n,l,r??a);return lt({...i,value:t.Value.map(n,u=>u??0),onChange:r,onInput:a,onBlur:o,after:s!=null?t.Fragment(c,s):c})},vt=e=>{const{value:n,step:r,min:a,max:o,onBlur:s,onChange:l,onInput:i}=e;return D.InputContainer({...e,focusableSelector:'input[type="range"]',input:t.html.input(t.attr.type("range"),S.CommonInputAttributes(e),t.attr.min(a),t.attr.max(o),t.attr.step(r),t.attr.valueAsNumber(n),t.attr.class("bc-input bc-slider-input"),s!=null?t.on.blur(t.emitValueAsNumber(s)):t.Empty,l!=null?t.on.change(t.emitValueAsNumber(l)):t.Empty,i!=null?t.on.input(t.emitValueAsNumber(i)):t.Empty)})},Et=e=>{const{value:n,step:r,min:a,max:o,onBlur:s,onChange:l,onInput:i}=e,c=t.Value.map(n,p=>{if(p!=null)return p;const h=a!=null?t.Value.get(a):void 0;return typeof h=="number"?h:0}),u=F.NullableResetAfter(n,e.disabled,l??i);return D.InputContainer({...e,focusableSelector:'input[type="range"]',after:u,input:t.html.input(t.attr.type("range"),S.CommonInputAttributes(e),t.attr.min(a),t.attr.max(o),t.attr.step(r),t.attr.valueAsNumber(c),t.attr.class("bc-input bc-slider-input"),s!=null?t.on.blur(t.emitValueAsNumber(s)):t.Empty,l!=null?t.on.change(t.emitValueAsNumber(p=>{l(p)})):t.Empty,i!=null?t.on.input(t.emitValueAsNumber(p=>{i(p)})):t.Empty)},t.Fragment())},Dt=B(F.UrlInput);class it{widgets=new Map;typeMapping=new Map;register(n,r){if(this.widgets.set(n,r),r.supportedTypes)for(const a of r.supportedTypes)this.typeMapping.has(a)||this.typeMapping.set(a,[]),this.typeMapping.get(a).push(n),this.typeMapping.get(a).sort((o,s)=>{const l=this.widgets.get(o)?.priority||0;return(this.widgets.get(s)?.priority||0)-l})}unregister(n){const r=this.widgets.get(n);if(r&&(this.widgets.delete(n),r.supportedTypes))for(const a of r.supportedTypes){const o=this.typeMapping.get(a);if(o){const s=o.indexOf(n);s>=0&&o.splice(s,1),o.length===0&&this.typeMapping.delete(a)}}}get(n){return this.widgets.get(n)}getAll(){return new Map(this.widgets)}getForType(n){return(this.typeMapping.get(n)||[]).map(a=>this.widgets.get(a)).filter(Boolean)}findBestWidget(n){const r=dt.resolveWidget(n.definition,n.name);if(r?.widget){const o=this.widgets.get(r.widget);if(o)return{name:r.widget,registration:o,resolved:r}}const a=[];for(const[o,s]of this.widgets.entries())if(s.matcher)try{s.matcher(n)&&a.push({name:o,registration:s,priority:s.priority??0})}catch(l){console.warn(`Error in matcher for widget "${o}":`,l)}if(a.length>0){a.sort((s,l)=>l.priority-s.priority);const o=a[0];return{name:o.name,registration:o.registration,resolved:{widget:o.name,source:"heuristics"}}}if(typeof n.definition=="object"&&n.definition.type){const o=Array.isArray(n.definition.type)?n.definition.type[0]:n.definition.type,s=this.getForType(o);if(s.length>0){const l=this.typeMapping.get(o)[0];return{name:l,registration:s[0],resolved:{widget:l,source:"type-fallback"}}}}return null}}const Bt=new it;function Ot(e,n,r){return{factory:n,matcher:a=>{const s=a.definition["x:ui"];return s===e||typeof s=="object"&&s!==null&&s.widget===e},displayName:r?.displayName??e,priority:r?.priority??100,...r}}function Ut(e,n,r){return{factory:n,matcher:a=>a.definition.format===e,displayName:r?.displayName??`${e} widget`,priority:r?.priority??75,...r}}function Wt(e,n,r,a){return{factory:r,matcher:o=>{const s=o.definition;return s.type===e&&s.format===n},displayName:a?.displayName??`${e}:${n} widget`,priority:a?.priority??80,...a}}function Ht(e){const n=e?.logPrefix??"WIDGET_DIAG",r=e?.filterFn??(()=>!0);return{factory:()=>null,displayName:"Diagnostic Widget (never matches)",priority:-1e3,matcher:a=>{if(!r(a))return!1;const o=a.definition,s={name:a.name,path:a.path.map(String),type:o?.type,hasRegistry:a.widgetRegistry!==void 0,definition:o};return console.log(`[${n}] name="${s.name??"ROOT"}" path=[${s.path.join(", ")}] type="${s.type??"unknown"}" hasRegistry=${s.hasRegistry}`),e?.onProcess?.(s),!1}}}exports.Base64Input=yt;exports.Base64sInput=st;exports.ColorSwatchInput=wt;exports.EditableText=Vt;exports.NullableDateInput=Mt;exports.NullableDateTimeInput=xt;exports.NullableEmailInput=_t;exports.NullablePasswordInput=At;exports.NullableRatingInput=Rt;exports.NullableSliderInput=Et;exports.NullableTextArea=Tt;exports.NullableTextInput=Ct;exports.NullableUUIDInput=kt;exports.NullableUrlInput=Dt;exports.RatingInput=lt;exports.SliderInput=vt;exports.Switch=Ft;exports.WidgetRegistry=it;exports.createDiagnosticWidget=Ht;exports.emptyToNull=P;exports.fileToBase64=rt;exports.forFormat=Ut;exports.forTypeAndFormat=Wt;exports.forXUI=Ot;exports.formatColor=R;exports.getContrastRatio=ht;exports.globalWidgetRegistry=Bt;exports.hexToRgb=E;exports.hslToRgb=j;exports.hwbToRgb=tt;exports.isValidColor=gt;exports.isValidHexColor=q;exports.isValidHslColor=G;exports.isValidRgbColor=X;exports.isValidRgbaColor=Y;exports.linearToSrgb=U;exports.mulberry32=J;exports.normalizeHexColor=K;exports.nullToEmpty=ot;exports.oklchToRgb=nt;exports.parseAnyColor=Q;exports.resolveEffectiveFormat=v;exports.rgbToHex=W;exports.rgbToHsl=H;exports.rgbToHwb=et;exports.rgbToOklch=at;exports.srgbToLinear=O;exports.toRgbaString=Z;
1
+ "use strict";const t=require("@tempots/dom"),k=require("./deep-merge-UghuPcyW.cjs"),ct=require("./string-B9vVyfq3.cjs"),D=require("./input-container-CSi72GI1.cjs"),S=require("./text-input-8v79fzEy.cjs"),N=require("./translations-gVgMyNno.cjs"),ut=require("@tempots/ui"),z=require("./notice-Bc1L4Zpr.cjs"),pt=require("./session-id-B5lJMzbB.cjs"),dt=require("./utils-DIUEhA-Z.cjs");function q(e){if(typeof e!="string")return!1;const n=e.startsWith("#")?e.slice(1):e;return/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(n)}function X(e){if(typeof e!="string")return!1;const n=/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i,r=e.match(n);if(!r)return!1;const[,a,o,s]=r,l=parseInt(a,10),i=parseInt(o,10),c=parseInt(s,10);return l>=0&&l<=255&&i>=0&&i<=255&&c>=0&&c<=255}function Y(e){if(typeof e!="string")return!1;const n=/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0?\.\d+)\s*\)$/i,r=e.match(n);if(!r)return!1;const[,a,o,s,l]=r,i=parseInt(a,10),c=parseInt(o,10),u=parseInt(s,10),p=parseFloat(l);return i>=0&&i<=255&&c>=0&&c<=255&&u>=0&&u<=255&&p>=0&&p<=1}function G(e){if(typeof e!="string")return!1;const n=/^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/i,r=e.match(n);if(!r)return!1;const[,a,o,s]=r,l=parseInt(a,10),i=parseInt(o,10),c=parseInt(s,10);return l>=0&&l<=360&&i>=0&&i<=100&&c>=0&&c<=100}function gt(e){return q(e)||X(e)||Y(e)||G(e)}function K(e){if(!q(e))return null;let n=e.startsWith("#")?e.slice(1):e;return n.length===3&&(n=n.split("").map(r=>r+r).join("")),`#${n.toLowerCase()}`}function W(e,n,r){const a=o=>{const s=Math.round(Math.max(0,Math.min(255,o))).toString(16);return s.length===1?"0"+s:s};return`#${a(e)}${a(n)}${a(r)}`}function E(e){const n=K(e);if(!n)return null;const r=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return r?{r:parseInt(r[1],16),g:parseInt(r[2],16),b:parseInt(r[3],16)}:null}function ht(e,n){const r=E(e),a=E(n);if(!r||!a)return null;const o=(u,p,h)=>{const[m,d,b]=[u,p,h].map(I=>(I=I/255,I<=.03928?I/12.92:Math.pow((I+.055)/1.055,2.4)));return .2126*m+.7152*d+.0722*b},s=o(r.r,r.g,r.b),l=o(a.r,a.g,a.b),i=Math.max(s,l),c=Math.min(s,l);return(i+.05)/(c+.05)}function Q(e){if(!e)return[0,0,0,1];const r=e.trim().match(/^#?([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/);if(r){const u=r[1];if(u.length===8){const p=parseInt(u.slice(0,2),16),h=parseInt(u.slice(2,4),16),m=parseInt(u.slice(4,6),16),d=parseInt(u.slice(6,8),16)/255;return[p,h,m,d]}if(u.length===6)return[parseInt(u.slice(0,2),16),parseInt(u.slice(2,4),16),parseInt(u.slice(4,6),16),1];if(u.length===4){const p=parseInt(u[0]+u[0],16),h=parseInt(u[1]+u[1],16),m=parseInt(u[2]+u[2],16),d=parseInt(u[3]+u[3],16)/255;return[p,h,m,d]}if(u.length===3){const p=parseInt(u[0]+u[0],16),h=parseInt(u[1]+u[1],16),m=parseInt(u[2]+u[2],16);return[p,h,m,1]}}const a=e.match(/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0?\.\d+)\s*\)$/i);if(a)return[parseInt(a[1],10),parseInt(a[2],10),parseInt(a[3],10),parseFloat(a[4])];const o=e.match(/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i);if(o)return[parseInt(o[1],10),parseInt(o[2],10),parseInt(o[3],10),1];const s=e.match(/^hsla?\(\s*([+-]?[\d.]+)(?:deg)?\s*[ ,]?\s*([\d.]+)%\s*[ ,]?\s*([\d.]+)%\s*(?:[/,]\s*(\d?(?:\.\d+)?))?\s*\)$/i);if(s){const u=parseFloat(s[1]),p=parseFloat(s[2]),h=parseFloat(s[3]),m=s[4]!=null?parseFloat(s[4]):1,[d,b,I]=j(u,p/100,h/100);return[d,b,I,m]}const l=e.match(/^hwb\(\s*([+-]?[\d.]+)(?:deg)?\s*[, ]\s*([\d.]+)%\s*[, ]\s*([\d.]+)%\s*(?:[/]\s*(\d?(?:\.\d+)?))?\s*\)$/i);if(l){const u=parseFloat(l[1]),p=parseFloat(l[2])/100,h=parseFloat(l[3])/100,m=l[4]!=null?parseFloat(l[4]):1,[d,b,I]=tt(u,p,h);return[d,b,I,m]}const i=e.match(/^oklch\(\s*([+-]?[\d.]+%?)\s+([\d.]+)\s+([+-]?[\d.]+)(?:deg)?(?:\s*\/\s*(\d?(?:\.\d+)?))?\s*\)$/i);if(i){const u=i[1],p=parseFloat(i[2]),h=parseFloat(i[3]),m=i[4]!=null?parseFloat(i[4]):1,d=u.endsWith("%")?Math.max(0,Math.min(1,parseFloat(u)/100)):Math.max(0,Math.min(1,parseFloat(u))),[b,I,V]=nt(d,p,h);return[b,I,V,m]}const c=E(e);return c?[c.r,c.g,c.b,1]:[0,0,0,1]}function Z(e,n,r,a){return`rgba(${Math.round(e)}, ${Math.round(n)}, ${Math.round(r)}, ${Math.max(0,Math.min(1,Math.round(a*100)/100))})`}function J(e){let n=e+1831565813;return function(){return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}function j(e,n,r){e=(e%360+360)%360;const a=(1-Math.abs(2*r-1))*n,o=a*(1-Math.abs(e/60%2-1)),s=r-a/2;let l=0,i=0,c=0;return 0<=e&&e<60?[l,i,c]=[a,o,0]:60<=e&&e<120?[l,i,c]=[o,a,0]:120<=e&&e<180?[l,i,c]=[0,a,o]:180<=e&&e<240?[l,i,c]=[0,o,a]:240<=e&&e<300?[l,i,c]=[o,0,a]:[l,i,c]=[a,0,o],[Math.round((l+s)*255),Math.round((i+s)*255),Math.round((c+s)*255)]}function tt(e,n,r){e=(e%360+360)%360;const a=n+r;a>1&&(n/=a,r/=a);const[o,s,l]=j(e,1,.5).map(h=>h/255),i=1-n-r,c=o*i+n,u=s*i+n,p=l*i+n;return[Math.round(c*255),Math.round(u*255),Math.round(p*255)]}function H(e,n,r){e/=255,n/=255,r/=255;const a=Math.max(e,n,r),o=Math.min(e,n,r);let s=0,l=0;const i=(a+o)/2,c=a-o;if(c!==0){switch(l=i>.5?c/(2-a-o):c/(a+o),a){case e:s=(n-r)/c+(n<r?6:0);break;case n:s=(r-e)/c+2;break;default:s=(e-n)/c+4}s*=60}return[Math.round(s),Math.round(l*100),Math.round(i*100)]}function et(e,n,r){const[a]=H(e,n,r),o=e/255,s=n/255,l=r/255,i=Math.min(o,s,l),c=1-Math.max(o,s,l);return[a,Math.round(i*100),Math.round(c*100)]}function O(e){const n=e/255;return n<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function U(e){const n=e<=.0031308?12.92*e:1.055*Math.pow(e,.4166666666666667)-.055;return Math.round(Math.max(0,Math.min(1,n))*255)}function nt(e,n,r){const a=r*Math.PI/180,o=Math.cos(a)*n,s=Math.sin(a)*n,l=e+.3963377774*o+.2158037573*s,i=e-.1055613458*o-.0638541728*s,c=e-.0894841775*o-1.291485548*s,u=l*l*l,p=i*i*i,h=c*c*c,m=4.0767416621*u-3.3077115913*p+.2309699292*h,d=-1.2684380046*u+2.6097574011*p-.3413193965*h,b=-.0041960863*u-.7034186147*p+1.707614701*h;return[U(m),U(d),U(b)]}function at(e,n,r){const a=O(e),o=O(n),s=O(r),l=.4122214708*a+.5363325363*o+.0514459929*s,i=.2119034982*a+.6806995451*o+.1073969566*s,c=.0883024619*a+.2817188376*o+.6299787005*s,u=Math.cbrt(l),p=Math.cbrt(i),h=Math.cbrt(c),m=.2104542553*u+.793617785*p-.0040720468*h,d=1.9779984951*u-2.428592205*p+.4505937099*h,b=.0259040371*u+.7827717662*p-.808675766*h,I=Math.sqrt(d*d+b*b);let V=Math.atan2(b,d)*180/Math.PI;return V<0&&(V+=360),[m,I,V]}function R(e,n,r,a,o,s){switch(o){case"hex":if(s){const l=c=>c.toString(16).padStart(2,"0"),i=Math.max(0,Math.min(255,Math.round(a*255)));return`#${l(e)}${l(n)}${l(r)}${l(i)}`}return W(e,n,r);case"rgb":return`rgb(${e}, ${n}, ${r})`;case"rgba":return`rgba(${e}, ${n}, ${r}, ${Math.round(a*100)/100})`;case"hsl":{const[l,i,c]=H(e,n,r);return`hsl(${l}, ${i}%, ${c}%)`}case"hsla":{const[l,i,c]=H(e,n,r);return`hsla(${l}, ${i}%, ${c}%, ${Math.round(a*100)/100})`}case"hwb":{const[l,i,c]=et(e,n,r);return a<1?`hwb(${l} ${i}% ${c}% / ${Math.round(a*100)/100})`:`hwb(${l} ${i}% ${c}%)`}case"oklch":{const[l,i,c]=at(e,n,r),u=(Math.round(l*1e3)/1e3).toFixed(3),p=(Math.round(i*1e3)/1e3).toFixed(3),h=(Math.round(c*10)/10).toFixed(1),m=Math.round(a*100)/100;return s||a<1?`oklch(${u} ${p} ${h} / ${m})`:`oklch(${u} ${p} ${h})`}}}function v(e,n){return n?e==="rgb"?"rgba":e==="hsl"?"hsla":e:e==="rgba"?"rgb":e==="hsla"?"hsl":e}async function rt(e){return new Promise((n,r)=>{const a=new FileReader;a.readAsDataURL(e),a.onload=()=>{const o=a.result;n(o.split(",")[1])},a.onerror=o=>r(o)})}function mt(e){return Promise.all(e.map(rt))}function ft(e){if(e.length>=4){if(e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71)return"image/png";if(e[0]===255&&e[1]===216)return"image/jpeg";if(e[0]===71&&e[1]===73&&e[2]===70)return"image/gif";if(e[0]===82&&e[1]===73&&e[2]===70&&e[3]===70&&e.length>=12&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80)return"image/webp"}try{if(new TextDecoder("utf-8").decode(e.slice(0,256)).includes("<svg"))return"image/svg+xml"}catch{}return"application/octet-stream"}function bt(e){const n=ct.$t(e??""),r=n.length,a=new Uint8Array(r);for(let o=0;o<r;o++)a[o]=n.charCodeAt(o);return a}function st(e){const{value:n,onChange:r,onInput:a,...o}=e,s=new Map,l=t.Value.toSignal(n).map(p=>p.map((h,m)=>{const d=s.get(h),b=bt(h??""),I=d?.type||ft(b),V=d?.name??`file-${m}`,y=b.buffer.slice(b.byteOffset,b.byteOffset+b.byteLength),f=new Blob([y],{type:I});return new File([f],V,{type:I})})),i=p=>h=>{p&&mt(h).then(m=>{for(const[d,b]of m.entries())s.set(b,{name:h[d].name,type:h[d].type});p(m)})},c=i(r),u=i(a);return k.FilesInput({...o,value:l,onChange:c,onInput:u})}function yt(e){const{value:n,onInput:r,onChange:a,...o}=e;return st({...o,maxFiles:1,value:t.Value.map(n,s=>s==null?[]:[s]),onChange:s=>{a?.(s[0])},onInput:s=>{r?.(s[0])}})}function It(e,n){const[r,a,o]=e,s=r<<16^a<<8^o,l=J(s),i=6+Math.floor(l()*5),c=.18+l()*.06,u=[];for(let d=0;d<i;d++){const b=d/i*Math.PI*2,I=n*(1+(l()*2-1)*c),V=Math.cos(b)*I,y=Math.sin(b)*I;u.push({x:V,y})}const p=(u[0].x+u[i-1].x)/2,h=(u[0].y+u[i-1].y)/2;let m=`M ${p.toFixed(3)} ${h.toFixed(3)}`;for(let d=0;d<i;d++){const b=u[d],I=u[(d+1)%i],V=(b.x+I.x)/2,y=(b.y+I.y)/2;m+=` Q ${b.x.toFixed(3)} ${b.y.toFixed(3)} ${V.toFixed(3)} ${y.toFixed(3)}`}return m+=" Z",m}const wt=e=>{const{value:n,onBlur:r,onChange:a,onInput:o,displayValue:s,size:l,withAlpha:i}=e,c=t.Value.map(l??32,g=>g),u=t.Value.map(n,g=>Q(g??"#000000")),p=t.Value.map(u,([g,w,$])=>[g,w,$]),h=t.Value.map(u,([,,,g])=>g),m=t.prop(t.Value.get(h)??1),d=t.Value.map(i??!1,g=>g),b=t.Value.map(e.colorTextFormat??"rgb",g=>g),I=t.computedOf(p,m,b,d)(([g,w,$],C,A,T)=>R(g,w,$,C??1,v(A,T),T)),V=t.Value.map(e.colorTextFormat??"hex",g=>g),y=t.Value.map(c,g=>`${-g/2} ${-g/2} ${g} ${g}`),f=t.computedOf(p,c)((g,w)=>It(g,w/2)),M=t.computedOf(p,m,d)(([g,w,$],C,A)=>A||C<1?Z(g,w,$,C):W(g,w,$)),_=t.html.div(t.attr.class("bc-color-swatch-input__control"),t.attr.class(t.Value.map(d,g=>g?"bc-color-swatch-input__control--alpha":"")),t.attr.style(t.computedOf(c)(g=>`min-width:${g+2}px;height:${g+2}px`)),t.svg.svg(t.attr.class("bc-color-swatch-input__svg"),t.svgAttr.viewBox(y),t.svg.path(t.svgAttr.d(f),t.svgAttr.fill(M))),t.html.input(t.attr.type("color"),S.CommonInputAttributes(e),t.attr.value(t.Value.map(p,([g,w,$])=>W(g,w,$))),t.attr.class("bc-input bc-color-swatch-input bc-color-swatch-input__native"),r!=null?t.on.blur(r):t.Empty,a!=null?t.on.change(g=>{const w=g.target.value;if(!a)return;const{r:$,g:C,b:A}=E(w)??{r:0,g:0,b:0},T=t.Value.get(m)??1,F=v(t.Value.get(V),t.Value.get(d)),L=R($,C,A,T,F,t.Value.get(d));a(L)}):t.Empty,o!=null?t.on.input(g=>{const w=g.target.value;if(!o)return;const{r:$,g:C,b:A}=E(w)??{r:0,g:0,b:0},T=t.Value.get(m)??1,F=v(t.Value.get(V),t.Value.get(d)),L=R($,C,A,T,F,t.Value.get(d));o(L)}):t.Empty)),x=t.When(d,()=>t.html.input(t.attr.type("range"),t.attr.class("bc-color-swatch-input__alpha"),t.attr.min(0),t.attr.max(1),t.attr.step(.01),t.attr.value(t.Value.map(m,g=>String(g??1))),t.attr.disabled(e.disabled),t.on.input(g=>{const w=parseFloat(g.target.value);m.set(w);const[$,C,A]=t.Value.get(p),T=v(t.Value.get(V),t.Value.get(d)),F=R($,C,A,w,T,t.Value.get(d));o?.(F)}),t.on.change(g=>{const w=parseFloat(g.target.value);m.set(w);const[$,C,A]=t.Value.get(p),T=v(t.Value.get(V),t.Value.get(d)),F=R($,C,A,w,T,t.Value.get(d));a?.(F)})));return D.InputContainer({baseContainer:!0,...e,growInput:!1,input:_,after:t.Fragment(t.When(s??!1,()=>t.html.span(t.attr.class("bc-color-swatch-input__rgb"),I)),x,e.after)})},Vt=({startEditing:e,value:n,onChange:r,placeholder:a,disabled:o})=>{const s=t.Value.deriveProp(e??!1),l=t.prop(!1),i=t.Value.map(o??!1,c=>c);return t.html.div(t.attr.class("bc-editable-text"),t.attr.class(t.Value.map(i,c=>c?"bc-editable-text--disabled":"")),t.aria.disabled(i),t.When(s,()=>t.html.input(t.attr.placeholder(a),t.attr.value(n),t.attr.class("bc-editable-text__input"),ut.AutoSelect(),t.on.keydown(c=>{c.key==="Enter"?s.set(!1):c.key==="Escape"&&(l.set(!0),s.set(!1))}),t.on.blur(t.emitValue(c=>{if(s.set(!1),l.value){l.set(!1);return}r(c)}))),()=>t.html.span(t.on.click(()=>{t.Value.get(i)||s.set(!0)}),t.attr.class("bc-editable-text__display"),t.When(t.Value.map(n,c=>c!=null&&c.trim()!==""),()=>t.html.span(t.attr.class("bc-editable-text__text"),n),()=>t.html.span(t.attr.class("bc-editable-text__placeholder"),a)),t.When(t.Value.map(i,c=>!c),()=>t.html.button(t.attr.type("button"),t.attr.class("bc-editable-text__edit-button"),t.Use(N.BeatUII18n,c=>t.aria.label(c.$.editLabel)),t.on.click(()=>s.set(!0)),N.Icon({icon:"line-md/pencil",color:"neutral"}))))))},Mt=e=>{const{value:n,onBlur:r,onChange:a,onInput:o,after:s,disabled:l}=e,i=k.NullableResetAfter(n,l,a??o);return D.InputContainer({...e,input:t.input.date(S.CommonInputAttributes(e),t.attr.valueAsDate(n),t.attr.class("bc-input"),r!=null?t.on.blur(t.emitValue(r)):t.Empty,a!=null?t.on.change(t.emitValueAsNullableDate(a)):t.Empty,o!=null?t.on.input(t.emitValueAsNullableDate(o)):t.Empty),after:s!=null?t.Fragment(i,s):i})},$t=e=>{const n=e.getFullYear(),r=e.getMonth()+1,a=e.getDate(),o=e.getHours(),s=e.getMinutes(),l=e.getSeconds();return`${n}-${r.toString().padStart(2,"0")}-${a.toString().padStart(2,"0")}T${o.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}:${l.toString().padStart(2,"0")}`},xt=e=>{const{value:n,onBlur:r,onChange:a,onInput:o,after:s,disabled:l}=e,i=t.Value.map(n,u=>u!=null?$t(u):null),c=k.NullableResetAfter(n,l,a??o);return D.InputContainer({...e,input:t.input["datetime-local"](S.CommonInputAttributes(e),t.attr.value(t.Value.map(i,u=>u??null)),t.attr.class("bc-input"),r!=null?t.on.blur(t.emitValue(r)):t.Empty,a!=null?t.on.change(t.emitValueAsNullableDateTime(a)):t.Empty,o!=null?t.on.input(t.emitValueAsNullableDateTime(o)):t.Empty),after:s!=null?t.Fragment(c,s):c})},P=e=>typeof e=="string"&&e.trim()===""?null:e,ot=e=>e??"";function B(e){return n=>{const{value:r,onBlur:a,onChange:o,onInput:s,after:l,disabled:i,...c}=n,u=k.NullableResetAfter(r,i,o??s);return e({...c,disabled:i,value:t.Value.map(r,ot),onChange:o!=null?p=>o(P(p)):void 0,onInput:s!=null?p=>s(P(p)):void 0,onBlur:a,after:l!=null?t.Fragment(u,l):u})}}const _t=B(z.EmailInput),Ct=B(S.TextInput),At=B(z.PasswordInput),Tt=B(k.TextArea),kt=({value:e,onChange:n,onInput:r,onBlur:a,offLabel:o,onLabel:s,disabled:l=!1,size:i="md",id:c,color:u="primary",tabIndex:p=0,matchInputHeight:h=!0})=>{const m=c??pt.sessionId("switch");function d(y,f){const M=["bc-switch",`bc-switch--size-${f}`,`bc-switch--${f}`];return h&&M.push("bc-switch--match-input"),y&&M.push("bc-switch--disabled"),M.join(" ")}function b(y){const f=y??"primary",M=new Map,_=N.backgroundValue(f,"solid","light"),x=N.backgroundValue(f,"solid","dark");return M.set("--switch-track-on-bg",_.backgroundColor),M.set("--switch-track-on-label",_.textColor),M.set("--switch-track-on-bg-dark",x.backgroundColor),M.set("--switch-track-on-label-dark",x.textColor),M.set("--switch-track-on-border-dark",N.borderColorValue(f,"dark")),Array.from(M.entries()).map(([g,w])=>`${g}: ${w}`).join("; ")}const I=()=>{t.Value.get(l)||(n?.(!t.Value.get(e)),r?.(!t.Value.get(e)))},V=y=>{t.Value.get(l)||(y.key===" "||y.key==="Enter")&&(y.preventDefault(),I())};return t.html.div(t.attr.class(t.computedOf(l??!1,i)((y,f)=>d(y??!1,f??"md"))),t.attr.style(t.computedOf(u)(y=>b(y))),t.attr.id(m),t.attr.role("switch"),t.attr.tabindex(t.computedOf(l??!1,p)((y,f)=>y?-1:f??0)),t.aria.checked(e),t.aria.disabled(l),t.on.click(I),t.on.keydown(V),a!=null?t.on.blur(a):null,t.html.div(t.attr.class("bc-switch__track"),t.attr.class(t.Value.map(e,y=>y?"bc-switch__track--on":"bc-switch__track--off")),o!=null?t.html.div(t.aria.hidden(!0),t.attr.class("bc-switch__track-label bc-switch__track-label--off"),t.attr.class(t.Value.map(e,y=>y?"bc-switch__track-label--hidden":"bc-switch__track-label--visible")),o):null,s!=null?t.html.div(t.attr.class("bc-switch__track-label bc-switch__track-label--on"),t.attr.class(t.Value.map(e,y=>y?"bc-switch__track-label--visible":"bc-switch__track-label--hidden")),s):null,t.html.div(t.attr.class("bc-switch__thumb"),t.attr.class(t.Value.map(e,y=>y?"bc-switch__thumb--on":"bc-switch__thumb--off")))))},Ft=B(k.UUIDInput),Nt="line-md:star-alt-filled",St="line-md:star-alt",lt=e=>{const{value:n,onChange:r,disabled:a,max:o=5,fullColor:s="yellow",emptyColor:l="neutral",fullIcon:i=Nt,emptyIcon:c=St,size:u="md",onBlur:p,rounding:h=1}=e,m=()=>{const f=t.Value.get(h);return f>0?f:1},d=f=>Math.min(Math.max(f,0),t.Value.get(o)),b=(f,M)=>{if(t.Value.get(a??!1))return;const x=f.currentTarget.getBoundingClientRect(),g=(f.clientX-x.left)/x.width,w=M-1+g,$=m(),C=Math.ceil(w/$)*$,A=d(C);r?.(A)},I=f=>{if(t.Value.get(a??!1))return;const M=m(),_=t.Value.get(n)??0;let x;switch(f.key){case"ArrowRight":case"ArrowUp":x=d(_+M);break;case"ArrowLeft":case"ArrowDown":x=d(_-M);break;case"Home":x=0;break;case"End":x=t.Value.get(o);break;default:return}f.preventDefault(),r?.(x)},V=t.Value.map(u,f=>`bc-icon--${f}`),y=({index:f,counter:M})=>t.html.span(t.attr.class("bc-rating-input__icon-container"),t.attr.class(V),N.Icon({icon:c,size:u,color:l,tone:"soft"},t.attr.class("bc-rating-input__icon-empty")),t.html.span(t.attr.class("bc-rating-input__icon-clipper"),t.attr.class(V),t.style.width(t.Value.map(n,_=>{const x=Math.floor(_);return x>f?"100%":x<f?"0%":`${(_-f)*100}%`})),N.Icon({icon:i,size:u,color:s,tone:"soft"},t.attr.class("bc-rating-input__icon-full"))),t.on.click(t.emit(_=>b(_,M),{preventDefault:!0,stopPropagation:!0})));return D.InputContainer({baseContainer:!0,growInput:!1,focusableSelector:'[role="slider"]',...e,input:t.html.div(S.CommonInputAttributes(e),t.attr.class("bc-rating-input"),t.attr.role("slider"),t.attr.tabindex(t.Value.map(a??!1,f=>f?-1:0)),t.aria.disabled(a??!1),t.aria.valuemin(0),t.aria.valuemax(t.Value.map(o,f=>f??0)),t.aria.valuenow(t.Value.map(n,f=>f??0)),t.aria.valuetext(t.computedOf(n,o)((f,M)=>{const _=f??0,x=M??0;return`${String(_)} / ${String(x)}`})),t.on.keydown(I),p!=null?t.on.blur(p):null,t.Repeat(o,y))})},Rt=e=>{const{value:n,onChange:r,onInput:a,onBlur:o,after:s,disabled:l,...i}=e,c=k.NullableResetAfter(n,l,r??a);return lt({...i,value:t.Value.map(n,u=>u??0),onChange:r,onInput:a,onBlur:o,after:s!=null?t.Fragment(c,s):c})},vt=e=>{const{value:n,step:r,min:a,max:o,onBlur:s,onChange:l,onInput:i}=e;return D.InputContainer({...e,focusableSelector:'input[type="range"]',input:t.html.input(t.attr.type("range"),S.CommonInputAttributes(e),t.attr.min(a),t.attr.max(o),t.attr.step(r),t.attr.valueAsNumber(n),t.attr.class("bc-input bc-slider-input"),s!=null?t.on.blur(t.emitValueAsNumber(s)):t.Empty,l!=null?t.on.change(t.emitValueAsNumber(l)):t.Empty,i!=null?t.on.input(t.emitValueAsNumber(i)):t.Empty)})},Et=e=>{const{value:n,step:r,min:a,max:o,onBlur:s,onChange:l,onInput:i}=e,c=t.Value.map(n,p=>{if(p!=null)return p;const h=a!=null?t.Value.get(a):void 0;return typeof h=="number"?h:0}),u=k.NullableResetAfter(n,e.disabled,l??i);return D.InputContainer({...e,focusableSelector:'input[type="range"]',after:u,input:t.html.input(t.attr.type("range"),S.CommonInputAttributes(e),t.attr.min(a),t.attr.max(o),t.attr.step(r),t.attr.valueAsNumber(c),t.attr.class("bc-input bc-slider-input"),s!=null?t.on.blur(t.emitValueAsNumber(s)):t.Empty,l!=null?t.on.change(t.emitValueAsNumber(p=>{l(p)})):t.Empty,i!=null?t.on.input(t.emitValueAsNumber(p=>{i(p)})):t.Empty)})},Dt=B(k.UrlInput);class it{widgets=new Map;typeMapping=new Map;register(n,r){if(this.widgets.set(n,r),r.supportedTypes)for(const a of r.supportedTypes)this.typeMapping.has(a)||this.typeMapping.set(a,[]),this.typeMapping.get(a).push(n),this.typeMapping.get(a).sort((o,s)=>{const l=this.widgets.get(o)?.priority||0;return(this.widgets.get(s)?.priority||0)-l})}unregister(n){const r=this.widgets.get(n);if(r&&(this.widgets.delete(n),r.supportedTypes))for(const a of r.supportedTypes){const o=this.typeMapping.get(a);if(o){const s=o.indexOf(n);s>=0&&o.splice(s,1),o.length===0&&this.typeMapping.delete(a)}}}get(n){return this.widgets.get(n)}getAll(){return new Map(this.widgets)}getForType(n){return(this.typeMapping.get(n)||[]).map(a=>this.widgets.get(a)).filter(Boolean)}findBestWidget(n){const r=dt.resolveWidget(n.definition,n.name);if(r?.widget){const o=this.widgets.get(r.widget);if(o)return{name:r.widget,registration:o,resolved:r}}const a=[];for(const[o,s]of this.widgets.entries())if(s.matcher)try{s.matcher(n)&&a.push({name:o,registration:s,priority:s.priority??0})}catch(l){console.warn(`Error in matcher for widget "${o}":`,l)}if(a.length>0){a.sort((s,l)=>l.priority-s.priority);const o=a[0];return{name:o.name,registration:o.registration,resolved:{widget:o.name,source:"heuristics"}}}if(typeof n.definition=="object"&&n.definition.type){const o=Array.isArray(n.definition.type)?n.definition.type[0]:n.definition.type,s=this.getForType(o);if(s.length>0){const l=this.typeMapping.get(o)[0];return{name:l,registration:s[0],resolved:{widget:l,source:"type-fallback"}}}}return null}}const Bt=new it;function Ot(e,n,r){return{factory:n,matcher:a=>{const s=a.definition["x:ui"];return s===e||typeof s=="object"&&s!==null&&s.widget===e},displayName:r?.displayName??e,priority:r?.priority??100,...r}}function Ut(e,n,r){return{factory:n,matcher:a=>a.definition.format===e,displayName:r?.displayName??`${e} widget`,priority:r?.priority??75,...r}}function Wt(e,n,r,a){return{factory:r,matcher:o=>{const s=o.definition;return s.type===e&&s.format===n},displayName:a?.displayName??`${e}:${n} widget`,priority:a?.priority??80,...a}}function Ht(e){const n=e?.logPrefix??"WIDGET_DIAG",r=e?.filterFn??(()=>!0);return{factory:()=>null,displayName:"Diagnostic Widget (never matches)",priority:-1e3,matcher:a=>{if(!r(a))return!1;const o=a.definition,s={name:a.name,path:a.path.map(String),type:o?.type,hasRegistry:a.widgetRegistry!==void 0,definition:o};return console.log(`[${n}] name="${s.name??"ROOT"}" path=[${s.path.join(", ")}] type="${s.type??"unknown"}" hasRegistry=${s.hasRegistry}`),e?.onProcess?.(s),!1}}}exports.Base64Input=yt;exports.Base64sInput=st;exports.ColorSwatchInput=wt;exports.EditableText=Vt;exports.NullableDateInput=Mt;exports.NullableDateTimeInput=xt;exports.NullableEmailInput=_t;exports.NullablePasswordInput=At;exports.NullableRatingInput=Rt;exports.NullableSliderInput=Et;exports.NullableTextArea=Tt;exports.NullableTextInput=Ct;exports.NullableUUIDInput=Ft;exports.NullableUrlInput=Dt;exports.RatingInput=lt;exports.SliderInput=vt;exports.Switch=kt;exports.WidgetRegistry=it;exports.createDiagnosticWidget=Ht;exports.emptyToNull=P;exports.fileToBase64=rt;exports.forFormat=Ut;exports.forTypeAndFormat=Wt;exports.forXUI=Ot;exports.formatColor=R;exports.getContrastRatio=ht;exports.globalWidgetRegistry=Bt;exports.hexToRgb=E;exports.hslToRgb=j;exports.hwbToRgb=tt;exports.isValidColor=gt;exports.isValidHexColor=q;exports.isValidHslColor=G;exports.isValidRgbColor=X;exports.isValidRgbaColor=Y;exports.linearToSrgb=U;exports.mulberry32=J;exports.normalizeHexColor=K;exports.nullToEmpty=ot;exports.oklchToRgb=nt;exports.parseAnyColor=Q;exports.resolveEffectiveFormat=v;exports.rgbToHex=W;exports.rgbToHsl=H;exports.rgbToHwb=et;exports.rgbToOklch=at;exports.srgbToLinear=O;exports.toRgbaString=Z;