@tempots/beatui 0.76.0 → 0.77.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.
Files changed (27) hide show
  1. package/dist/auth/index.cjs.js +1 -1
  2. package/dist/auth/index.es.js +3 -3
  3. package/dist/beatui.css +11 -2
  4. package/dist/beatui.tailwind.css +11 -2
  5. package/dist/deep-merge-DBUbjJYt.cjs +1 -0
  6. package/dist/{deep-merge-CQQCMLwG.js → deep-merge-E6b9KE6l.js} +221 -223
  7. package/dist/{duration-input-D-SIoDoo.cjs → duration-input-CsygvJJ_.cjs} +1 -1
  8. package/dist/{duration-input-DKxZ6OCa.js → duration-input-j7bVks-S.js} +2 -2
  9. package/dist/index.cjs.js +2 -2
  10. package/dist/index.es.js +238 -237
  11. package/dist/json-schema/index.cjs.js +1 -1
  12. package/dist/json-schema/index.es.js +5 -5
  13. package/dist/json-structure/index.cjs.js +1 -1
  14. package/dist/json-structure/index.es.js +3 -3
  15. package/dist/{modal-MofsfmAe.js → modal--5-j6x0s.js} +1 -1
  16. package/dist/{modal-5P9mU_a4.cjs → modal-rLbLQYhb.cjs} +1 -1
  17. package/dist/{notice-DP209Ed8.cjs → notice-BGaJ4k0O.cjs} +1 -1
  18. package/dist/{notice-Cqq8g17n.js → notice-BvS1_9Va.js} +1 -1
  19. package/dist/types/components/form/controller/controller-validation.d.ts +41 -0
  20. package/dist/types/components/json-schema/widgets/widget-customization.d.ts +7 -7
  21. package/dist/use-form-B4D58mxd.cjs +2 -0
  22. package/dist/{use-form-B7A865EM.js → use-form-DzA1RSrN.js} +115 -88
  23. package/dist/{widget-customization-GaZB6sLP.cjs → widget-customization-DKlfR6Qb.cjs} +1 -1
  24. package/dist/{widget-customization-CobH7Rj_.js → widget-customization-DfBf7gGp.js} +3 -3
  25. package/package.json +1 -1
  26. package/dist/deep-merge-DZxfgKqX.cjs +0 -1
  27. package/dist/use-form-DVJXMMoN.cjs +0 -2
@@ -1 +1 @@
1
- "use strict";const e=require("@tempots/dom"),k=require("./deep-merge-DZxfgKqX.cjs"),$=require("./translations-hMQlZmD4.cjs"),X=require("@tempots/ui"),q=require("./notice-DP209Ed8.cjs"),pt=require("./use-form-DVJXMMoN.cjs");function P(t){if(typeof t!="string")return!1;const n=t.startsWith("#")?t.slice(1):t;return/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(n)}function z(t){if(typeof t!="string")return!1;const n=/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i,a=t.match(n);if(!a)return!1;const[,r,o,s]=a,l=parseInt(r,10),c=parseInt(o,10),i=parseInt(s,10);return l>=0&&l<=255&&c>=0&&c<=255&&i>=0&&i<=255}function Y(t){if(typeof t!="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,a=t.match(n);if(!a)return!1;const[,r,o,s,l]=a,c=parseInt(r,10),i=parseInt(o,10),u=parseInt(s,10),p=parseFloat(l);return c>=0&&c<=255&&i>=0&&i<=255&&u>=0&&u<=255&&p>=0&&p<=1}function G(t){if(typeof t!="string")return!1;const n=/^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/i,a=t.match(n);if(!a)return!1;const[,r,o,s]=a,l=parseInt(r,10),c=parseInt(o,10),i=parseInt(s,10);return l>=0&&l<=360&&c>=0&&c<=100&&i>=0&&i<=100}function gt(t){return P(t)||z(t)||Y(t)||G(t)}function K(t){if(!P(t))return null;let n=t.startsWith("#")?t.slice(1):t;return n.length===3&&(n=n.split("").map(a=>a+a).join("")),`#${n.toLowerCase()}`}function B(t,n,a){const r=o=>{const s=Math.round(Math.max(0,Math.min(255,o))).toString(16);return s.length===1?"0"+s:s};return`#${r(t)}${r(n)}${r(a)}`}function R(t){const n=K(t);if(!n)return null;const a=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return a?{r:parseInt(a[1],16),g:parseInt(a[2],16),b:parseInt(a[3],16)}:null}function mt(t,n){const a=R(t),r=R(n);if(!a||!r)return null;const o=(u,p,d)=>{const[f,g,y]=[u,p,d].map(w=>(w=w/255,w<=.03928?w/12.92:Math.pow((w+.055)/1.055,2.4)));return .2126*f+.7152*g+.0722*y},s=o(a.r,a.g,a.b),l=o(r.r,r.g,r.b),c=Math.max(s,l),i=Math.min(s,l);return(c+.05)/(i+.05)}function Q(t){if(!t)return[0,0,0,1];const a=t.trim().match(/^#?([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/);if(a){const u=a[1];if(u.length===8){const p=parseInt(u.slice(0,2),16),d=parseInt(u.slice(2,4),16),f=parseInt(u.slice(4,6),16),g=parseInt(u.slice(6,8),16)/255;return[p,d,f,g]}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),d=parseInt(u[1]+u[1],16),f=parseInt(u[2]+u[2],16),g=parseInt(u[3]+u[3],16)/255;return[p,d,f,g]}if(u.length===3){const p=parseInt(u[0]+u[0],16),d=parseInt(u[1]+u[1],16),f=parseInt(u[2]+u[2],16);return[p,d,f,1]}}const r=t.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(r)return[parseInt(r[1],10),parseInt(r[2],10),parseInt(r[3],10),parseFloat(r[4])];const o=t.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=t.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]),d=parseFloat(s[3]),f=s[4]!=null?parseFloat(s[4]):1,[g,y,w]=j(u,p/100,d/100);return[g,y,w,f]}const l=t.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,d=parseFloat(l[3])/100,f=l[4]!=null?parseFloat(l[4]):1,[g,y,w]=tt(u,p,d);return[g,y,w,f]}const c=t.match(/^oklch\(\s*([+-]?[\d.]+%?)\s+([\d.]+)\s+([+-]?[\d.]+)(?:deg)?(?:\s*\/\s*(\d?(?:\.\d+)?))?\s*\)$/i);if(c){const u=c[1],p=parseFloat(c[2]),d=parseFloat(c[3]),f=c[4]!=null?parseFloat(c[4]):1,g=u.endsWith("%")?Math.max(0,Math.min(1,parseFloat(u)/100)):Math.max(0,Math.min(1,parseFloat(u))),[y,w,b]=nt(g,p,d);return[y,w,b,f]}const i=R(t);return i?[i.r,i.g,i.b,1]:[0,0,0,1]}function Z(t,n,a,r){return`rgba(${Math.round(t)}, ${Math.round(n)}, ${Math.round(a)}, ${Math.max(0,Math.min(1,Math.round(r*100)/100))})`}function J(t){let n=t+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(t,n,a){t=(t%360+360)%360;const r=(1-Math.abs(2*a-1))*n,o=r*(1-Math.abs(t/60%2-1)),s=a-r/2;let l=0,c=0,i=0;return 0<=t&&t<60?[l,c,i]=[r,o,0]:60<=t&&t<120?[l,c,i]=[o,r,0]:120<=t&&t<180?[l,c,i]=[0,r,o]:180<=t&&t<240?[l,c,i]=[0,o,r]:240<=t&&t<300?[l,c,i]=[o,0,r]:[l,c,i]=[r,0,o],[Math.round((l+s)*255),Math.round((c+s)*255),Math.round((i+s)*255)]}function tt(t,n,a){t=(t%360+360)%360;const r=n+a;r>1&&(n/=r,a/=r);const[o,s,l]=j(t,1,.5).map(d=>d/255),c=1-n-a,i=o*c+n,u=s*c+n,p=l*c+n;return[Math.round(i*255),Math.round(u*255),Math.round(p*255)]}function L(t,n,a){t/=255,n/=255,a/=255;const r=Math.max(t,n,a),o=Math.min(t,n,a);let s=0,l=0;const c=(r+o)/2,i=r-o;if(i!==0){switch(l=c>.5?i/(2-r-o):i/(r+o),r){case t:s=(n-a)/i+(n<a?6:0);break;case n:s=(a-t)/i+2;break;default:s=(t-n)/i+4}s*=60}return[Math.round(s),Math.round(l*100),Math.round(c*100)]}function et(t,n,a){const[r]=L(t,n,a),o=t/255,s=n/255,l=a/255,c=Math.min(o,s,l),i=1-Math.max(o,s,l);return[r,Math.round(c*100),Math.round(i*100)]}function D(t){const n=t/255;return n<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function O(t){const n=t<=.0031308?12.92*t:1.055*Math.pow(t,.4166666666666667)-.055;return Math.round(Math.max(0,Math.min(1,n))*255)}function nt(t,n,a){const r=a*Math.PI/180,o=Math.cos(r)*n,s=Math.sin(r)*n,l=t+.3963377774*o+.2158037573*s,c=t-.1055613458*o-.0638541728*s,i=t-.0894841775*o-1.291485548*s,u=l*l*l,p=c*c*c,d=i*i*i,f=4.0767416621*u-3.3077115913*p+.2309699292*d,g=-1.2684380046*u+2.6097574011*p-.3413193965*d,y=-.0041960863*u-.7034186147*p+1.707614701*d;return[O(f),O(g),O(y)]}function rt(t,n,a){const r=D(t),o=D(n),s=D(a),l=.4122214708*r+.5363325363*o+.0514459929*s,c=.2119034982*r+.6806995451*o+.1073969566*s,i=.0883024619*r+.2817188376*o+.6299787005*s,u=Math.cbrt(l),p=Math.cbrt(c),d=Math.cbrt(i),f=.2104542553*u+.793617785*p-.0040720468*d,g=1.9779984951*u-2.428592205*p+.4505937099*d,y=.0259040371*u+.7827717662*p-.808675766*d,w=Math.sqrt(g*g+y*y);let b=Math.atan2(y,g)*180/Math.PI;return b<0&&(b+=360),[f,w,b]}function N(t,n,a,r,o,s){switch(o){case"hex":if(s){const l=i=>i.toString(16).padStart(2,"0"),c=Math.max(0,Math.min(255,Math.round(r*255)));return`#${l(t)}${l(n)}${l(a)}${l(c)}`}return B(t,n,a);case"rgb":return`rgb(${t}, ${n}, ${a})`;case"rgba":return`rgba(${t}, ${n}, ${a}, ${Math.round(r*100)/100})`;case"hsl":{const[l,c,i]=L(t,n,a);return`hsl(${l}, ${c}%, ${i}%)`}case"hsla":{const[l,c,i]=L(t,n,a);return`hsla(${l}, ${c}%, ${i}%, ${Math.round(r*100)/100})`}case"hwb":{const[l,c,i]=et(t,n,a);return r<1?`hwb(${l} ${c}% ${i}% / ${Math.round(r*100)/100})`:`hwb(${l} ${c}% ${i}%)`}case"oklch":{const[l,c,i]=rt(t,n,a),u=(Math.round(l*1e3)/1e3).toFixed(3),p=(Math.round(c*1e3)/1e3).toFixed(3),d=(Math.round(i*10)/10).toFixed(1),f=Math.round(r*100)/100;return s||r<1?`oklch(${u} ${p} ${d} / ${f})`:`oklch(${u} ${p} ${d})`}}}function S(t,n){return n?t==="rgb"?"rgba":t==="hsl"?"hsla":t:t==="rgba"?"rgb":t==="hsla"?"hsl":t}async function at(t){return new Promise((n,a)=>{const r=new FileReader;r.readAsDataURL(t),r.onload=()=>{const o=r.result;n(o.split(",")[1])},r.onerror=o=>a(o)})}function dt(t){return Promise.all(t.map(at))}function ht(t){if(t.length>=4){if(t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71)return"image/png";if(t[0]===255&&t[1]===216)return"image/jpeg";if(t[0]===71&&t[1]===73&&t[2]===70)return"image/gif";if(t[0]===82&&t[1]===73&&t[2]===70&&t[3]===70&&t.length>=12&&t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80)return"image/webp"}try{if(new TextDecoder("utf-8").decode(t.slice(0,256)).includes("<svg"))return"image/svg+xml"}catch{}return"application/octet-stream"}function ft(t){const n=k.$t(t??""),a=n.length,r=new Uint8Array(a);for(let o=0;o<a;o++)r[o]=n.charCodeAt(o);return r}function st(t){const{value:n,onChange:a,onInput:r,...o}=t,s=new Map,l=e.Value.toSignal(n).map(p=>p.map((d,f)=>{const g=s.get(d),y=ft(d??""),w=g?.type||ht(y),b=g?.name??`file-${f}`,x=y.buffer.slice(y.byteOffset,y.byteOffset+y.byteLength),h=new Blob([x],{type:w});return new File([h],b,{type:w})})),c=p=>d=>{p&&dt(d).then(f=>{for(const[g,y]of f.entries())s.set(y,{name:d[g].name,type:d[g].type});p(f)})},i=c(a),u=c(r);return k.FilesInput({...o,value:l,onChange:i,onInput:u})}function bt(t){const{value:n,onInput:a,onChange:r,...o}=t;return st({...o,maxFiles:1,value:e.Value.map(n,s=>s==null?[]:[s]),onChange:s=>{r?.(s[0])},onInput:s=>{a?.(s[0])}})}function yt(t,n){const[a,r,o]=t,s=a<<16^r<<8^o,l=J(s),c=6+Math.floor(l()*5),i=.18+l()*.06,u=[];for(let g=0;g<c;g++){const y=g/c*Math.PI*2,w=n*(1+(l()*2-1)*i),b=Math.cos(y)*w,x=Math.sin(y)*w;u.push({x:b,y:x})}const p=(u[0].x+u[c-1].x)/2,d=(u[0].y+u[c-1].y)/2;let f=`M ${p.toFixed(3)} ${d.toFixed(3)}`;for(let g=0;g<c;g++){const y=u[g],w=u[(g+1)%c],b=(y.x+w.x)/2,x=(y.y+w.y)/2;f+=` Q ${y.x.toFixed(3)} ${y.y.toFixed(3)} ${b.toFixed(3)} ${x.toFixed(3)}`}return f+=" Z",f}const wt=t=>{const{value:n,onBlur:a,onChange:r,onInput:o,displayValue:s,size:l,withAlpha:c}=t,i=e.Value.map(l??32,m=>m),u=e.Value.map(n,m=>Q(m??"#000000")),p=e.Value.map(u,([m,I,V])=>[m,I,V]),d=e.Value.map(u,([,,,m])=>m),f=e.prop(e.Value.get(d)??1),g=e.Value.map(c??!1,m=>m),y=e.Value.map(t.colorTextFormat??"rgb",m=>m),w=e.computedOf(p,f,y,g)(([m,I,V],_,A,F)=>N(m,I,V,_??1,S(A,F),F)),b=e.Value.map(t.colorTextFormat??"hex",m=>m),x=e.Value.map(i,m=>`${-m/2} ${-m/2} ${m} ${m}`),h=e.computedOf(p,i)((m,I)=>yt(m,I/2)),T=e.computedOf(p,f,g)(([m,I,V],_,A)=>A||_<1?Z(m,I,V,_):B(m,I,V)),C=e.html.div(e.attr.class("bc-color-swatch-input__control"),e.attr.class(e.Value.map(g,m=>m?"bc-color-swatch-input__control--alpha":"")),e.attr.style(e.computedOf(i)(m=>`min-width:${m+2}px;height:${m+2}px`)),e.svg.svg(e.attr.class("bc-color-swatch-input__svg"),e.svgAttr.viewBox(x),e.svg.path(e.svgAttr.d(h),e.svgAttr.fill(T))),e.html.input(e.attr.type("color"),$.CommonInputAttributes(t),e.attr.value(e.Value.map(p,([m,I,V])=>B(m,I,V))),e.attr.class("bc-input bc-color-swatch-input bc-color-swatch-input__native"),a!=null?e.on.blur(a):e.Empty,r!=null?e.on.change(m=>{const I=m.target.value;if(!r)return;const{r:V,g:_,b:A}=R(I)??{r:0,g:0,b:0},F=e.Value.get(f)??1,v=S(e.Value.get(b),e.Value.get(g)),U=N(V,_,A,F,v,e.Value.get(g));r(U)}):e.Empty,o!=null?e.on.input(m=>{const I=m.target.value;if(!o)return;const{r:V,g:_,b:A}=R(I)??{r:0,g:0,b:0},F=e.Value.get(f)??1,v=S(e.Value.get(b),e.Value.get(g)),U=N(V,_,A,F,v,e.Value.get(g));o(U)}):e.Empty)),M=e.When(g,()=>e.html.input(e.attr.type("range"),e.attr.class("bc-color-swatch-input__alpha"),e.attr.min(0),e.attr.max(1),e.attr.step(.01),e.attr.value(e.Value.map(f,m=>String(m??1))),e.attr.disabled(t.disabled),e.on.input(m=>{const I=parseFloat(m.target.value);f.set(I);const[V,_,A]=e.Value.get(p),F=S(e.Value.get(b),e.Value.get(g)),v=N(V,_,A,I,F,e.Value.get(g));o?.(v)}),e.on.change(m=>{const I=parseFloat(m.target.value);f.set(I);const[V,_,A]=e.Value.get(p),F=S(e.Value.get(b),e.Value.get(g)),v=N(V,_,A,I,F,e.Value.get(g));r?.(v)})));return $.InputContainer({baseContainer:!0,...t,growInput:!1,input:C,after:e.Fragment(e.When(s??!1,()=>e.html.span(e.attr.class("bc-color-swatch-input__rgb"),w)),M,t.after)})};function It(t,n,a){const r=["bc-card"];return t!=="default"&&r.push(`bc-card--${t}`),n!=="md"&&r.push(`bc-card--padding-${n}`),a!=="lg"&&r.push(`bc-card--rounded-${a}`),r.join(" ")}function xt({variant:t="default",size:n="md",roundedness:a="lg"}={},...r){return e.html.div(e.attr.class(e.computedOf(t,n,a)((o,s,l)=>It(o??"default",s??"md",l??"lg"))),...r)}const $t=({startEditing:t,value:n,onChange:a,placeholder:r,disabled:o})=>{const s=e.Value.deriveProp(t??!1),l=e.prop(!1),c=e.Value.map(o??!1,i=>i);return e.html.div(e.attr.class("bc-editable-text"),e.attr.class(e.Value.map(c,i=>i?"bc-editable-text--disabled":"")),e.aria.disabled(c),e.When(s,()=>e.html.input(e.attr.placeholder(r),e.attr.value(n),e.attr.class("bc-editable-text__input"),X.AutoSelect(),e.on.keydown(i=>{i.key==="Enter"?s.set(!1):i.key==="Escape"&&(l.set(!0),s.set(!1))}),e.on.blur(e.emitValue(i=>{if(s.set(!1),l.value){l.set(!1);return}a(i)}))),()=>e.html.span(e.on.click(()=>{e.Value.get(c)||s.set(!0)}),e.attr.class("bc-editable-text__display"),e.When(e.Value.map(n,i=>i!=null&&i.trim()!==""),()=>e.html.span(e.attr.class("bc-editable-text__text"),n),()=>e.html.span(e.attr.class("bc-editable-text__placeholder"),r)),e.When(e.Value.map(c,i=>!i),()=>e.html.button(e.attr.type("button"),e.attr.class("bc-editable-text__edit-button"),e.Use($.BeatUII18n,i=>e.aria.label(i.$.editLabel)),e.on.click(()=>s.set(!0)),$.Icon({icon:"line-md/pencil",color:"neutral"}))))))},Mt=t=>{const{value:n,onBlur:a,onChange:r,onInput:o,after:s,disabled:l}=t,c=k.NullableResetAfter(n,l,r??o);return $.InputContainer({...t,input:e.input.date($.CommonInputAttributes(t),e.attr.valueAsDate(n),e.attr.class("bc-input"),a!=null?e.on.blur(e.emitValue(a)):e.Empty,r!=null?e.on.change(e.emitValueAsNullableDate(r)):e.Empty,o!=null?e.on.input(e.emitValueAsNullableDate(o)):e.Empty),after:s!=null?e.Fragment(c,s):c})},Vt=t=>{const n=t.getFullYear(),a=t.getMonth()+1,r=t.getDate(),o=t.getHours(),s=t.getMinutes(),l=t.getSeconds();return`${n}-${a.toString().padStart(2,"0")}-${r.toString().padStart(2,"0")}T${o.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}:${l.toString().padStart(2,"0")}`},Ct=t=>{const{value:n,onBlur:a,onChange:r,onInput:o,after:s,disabled:l}=t,c=e.Value.map(n,u=>u!=null?Vt(u):null),i=k.NullableResetAfter(n,l,r??o);return $.InputContainer({...t,input:e.input["datetime-local"]($.CommonInputAttributes(t),e.attr.value(e.Value.map(c,u=>u??null)),e.attr.class("bc-input"),a!=null?e.on.blur(e.emitValue(a)):e.Empty,r!=null?e.on.change(e.emitValueAsNullableDateTime(r)):e.Empty,o!=null?e.on.input(e.emitValueAsNullableDateTime(o)):e.Empty),after:s!=null?e.Fragment(i,s):i})},H=t=>typeof t=="string"&&t.trim()===""?null:t,ot=t=>t??"";function E(t){return n=>{const{value:a,onBlur:r,onChange:o,onInput:s,after:l,disabled:c,...i}=n,u=k.NullableResetAfter(a,c,o??s);return t({...i,disabled:c,value:e.Value.map(a,ot),onChange:o!=null?p=>o(H(p)):void 0,onInput:s!=null?p=>s(H(p)):void 0,onBlur:r,after:l!=null?e.Fragment(u,l):u})}}const Tt=E(q.EmailInput),_t=E($.TextInput),At=E(q.PasswordInput),Ft=E(k.TextArea),kt=({value:t,onChange:n,onInput:a,onBlur:r,offLabel:o,onLabel:s,disabled:l=!1,size:c="md",id:i,color:u="primary",tabIndex:p=0})=>{const d=i??pt.sessionId("switch");function f(b,x){const h=["bc-switch",`bc-switch--size-${x}`,`bc-switch--${x}`];return b&&h.push("bc-switch--disabled"),h.join(" ")}function g(b){const x=b??"primary",h=new Map,T=$.backgroundValue(x,"solid","light"),C=$.backgroundValue(x,"solid","dark");return h.set("--switch-track-on-bg",T.backgroundColor),h.set("--switch-track-on-label",T.textColor),h.set("--switch-track-on-bg-dark",C.backgroundColor),h.set("--switch-track-on-label-dark",C.textColor),h.set("--switch-track-on-border-dark",$.borderColorValue(x,"dark")),Array.from(h.entries()).map(([M,m])=>`${M}: ${m}`).join("; ")}const y=()=>{e.Value.get(l)||(n?.(!e.Value.get(t)),a?.(!e.Value.get(t)))},w=b=>{e.Value.get(l)||(b.key===" "||b.key==="Enter")&&(b.preventDefault(),y())};return e.html.div(e.attr.class(e.computedOf(l??!1,c)((b,x)=>f(b??!1,x??"md"))),e.attr.style(e.computedOf(u)(b=>g(b))),e.attr.id(d),e.attr.role("switch"),e.attr.tabindex(e.computedOf(l??!1,p)((b,x)=>b?-1:x??0)),e.aria.checked(t),e.aria.disabled(l),e.on.click(y),e.on.keydown(w),r!=null?e.on.blur(r):null,e.html.div(e.attr.class("bc-switch__track"),e.attr.class(e.Value.map(t,b=>b?"bc-switch__track--on":"bc-switch__track--off")),o!=null?e.html.div(e.aria.hidden(!0),e.attr.class("bc-switch__track-label bc-switch__track-label--off"),e.attr.class(e.Value.map(t,b=>b?"bc-switch__track-label--hidden":"bc-switch__track-label--visible")),o):null,s!=null?e.html.div(e.attr.class("bc-switch__track-label bc-switch__track-label--on"),e.attr.class(e.Value.map(t,b=>b?"bc-switch__track-label--visible":"bc-switch__track-label--hidden")),s):null,X.ElementRect(b=>e.Use($.Locale,({direction:x})=>e.html.div(e.attr.class("bc-switch__thumb"),e.attr.class(e.Value.map(t,h=>h?"bc-switch__thumb--on":"bc-switch__thumb--off")),e.style.transform(e.computedOf(t,b,c,x)((h,{width:T},C,M)=>{const m=(()=>{switch(C){case"xs":return 5;case"sm":return 5.5;case"md":return 6;case"lg":return 7;case"xl":return 8}})(),I=M==="rtl"?`calc((var(--spacing-base) * ${m}) - ${T}px)`:`calc(${T}px - (var(--spacing-base) * ${m}))`;return h?`translateX(${I})`:"translateX(0)"})))))))},vt=E(k.UUIDInput),Nt="line-md:star-alt-filled",St="line-md:star-alt",lt=t=>{const{value:n,onChange:a,disabled:r,max:o=5,fullColor:s="yellow",emptyColor:l="neutral",fullIcon:c=Nt,emptyIcon:i=St,size:u="md",onBlur:p,rounding:d=1}=t,f=()=>{const h=e.Value.get(d);return h>0?h:1},g=h=>Math.min(Math.max(h,0),e.Value.get(o)),y=(h,T)=>{if(e.Value.get(r??!1))return;const M=h.currentTarget.getBoundingClientRect(),m=(h.clientX-M.left)/M.width,I=T-1+m,V=f(),_=Math.ceil(I/V)*V,A=g(_);a?.(A)},w=h=>{if(e.Value.get(r??!1))return;const T=f(),C=e.Value.get(n)??0;let M;switch(h.key){case"ArrowRight":case"ArrowUp":M=g(C+T);break;case"ArrowLeft":case"ArrowDown":M=g(C-T);break;case"Home":M=0;break;case"End":M=e.Value.get(o);break;default:return}h.preventDefault(),a?.(M)},b=e.Value.map(u,h=>`bc-icon--${h}`),x=({index:h,counter:T})=>e.html.span(e.attr.class("bc-rating-input__icon-container"),e.attr.class(b),$.Icon({icon:i,size:u,color:l,tone:"soft"},e.attr.class("bc-rating-input__icon-empty")),e.html.span(e.attr.class("bc-rating-input__icon-clipper"),e.attr.class(b),e.style.width(e.Value.map(n,C=>{const M=Math.floor(C);return M>h?"100%":M<h?"0%":`${(C-h)*100}%`})),$.Icon({icon:c,size:u,color:s,tone:"soft"},e.attr.class("bc-rating-input__icon-full"))),e.on.click(e.emit(C=>y(C,T),{preventDefault:!0,stopPropagation:!0})));return $.InputContainer({baseContainer:!0,growInput:!1,focusableSelector:'[role="slider"]',...t,input:e.html.div($.CommonInputAttributes(t),e.attr.class("bc-rating-input"),e.attr.role("slider"),e.attr.tabindex(e.Value.map(r??!1,h=>h?-1:0)),e.aria.disabled(r??!1),e.aria.valuemin(0),e.aria.valuemax(e.Value.map(o,h=>h??0)),e.aria.valuenow(e.Value.map(n,h=>h??0)),e.aria.valuetext(e.computedOf(n,o)((h,T)=>{const C=h??0,M=T??0;return`${String(C)} / ${String(M)}`})),e.on.keydown(w),p!=null?e.on.blur(p):null,e.Repeat(o,x))})},Rt=t=>{const{value:n,onChange:a,onInput:r,onBlur:o,after:s,disabled:l,...c}=t,i=k.NullableResetAfter(n,l,a??r);return lt({...c,value:e.Value.map(n,u=>u??0),onChange:a,onInput:r,onBlur:o,after:s!=null?e.Fragment(i,s):i})},Et=t=>{const{value:n,step:a,min:r,max:o,onBlur:s,onChange:l,onInput:c}=t;return $.InputContainer({...t,focusableSelector:'input[type="range"]',input:e.html.input(e.attr.type("range"),$.CommonInputAttributes(t),e.attr.min(r),e.attr.max(o),e.attr.step(a),e.attr.valueAsNumber(n),e.attr.class("bc-input bc-slider-input"),s!=null?e.on.blur(e.emitValueAsNumber(s)):e.Empty,l!=null?e.on.change(e.emitValueAsNumber(l)):e.Empty,c!=null?e.on.input(e.emitValueAsNumber(c)):e.Empty)})},Dt=t=>{const{value:n,step:a,min:r,max:o,onBlur:s,onChange:l,onInput:c}=t,i=e.Value.map(n,p=>{if(p!=null)return p;const d=r!=null?e.Value.get(r):void 0;return typeof d=="number"?d:0}),u=k.NullableResetAfter(n,t.disabled,l??c);return $.InputContainer({...t,focusableSelector:'input[type="range"]',after:u,input:e.html.input(e.attr.type("range"),$.CommonInputAttributes(t),e.attr.min(r),e.attr.max(o),e.attr.step(a),e.attr.valueAsNumber(i),e.attr.class("bc-input bc-slider-input"),s!=null?e.on.blur(e.emitValueAsNumber(s)):e.Empty,l!=null?e.on.change(e.emitValueAsNumber(p=>{l(p)})):e.Empty,c!=null?e.on.input(e.emitValueAsNumber(p=>{c(p)})):e.Empty)},e.Fragment())},Ot=E(k.UrlInput),W=["description","comment","notes","text"];function Bt(t){if(typeof t=="boolean")return W;const n=t["x:ui"];return n&&Array.isArray(n.textAreaTriggers)?[...W,...n.textAreaTriggers]:W}function ct(t){if(typeof t=="boolean")return;const n=t["x:ui"];if(n!=null&&(typeof n=="string"||typeof n=="object"&&n!==null))return n}function it(t,n){if(typeof t=="boolean")return;const a=ct(t);if(typeof a=="object"&&typeof a.widget=="string")return{widget:a.widget,source:"explicit-widget",options:a};const r=typeof a=="string"?a:typeof a=="object"&&typeof a.format=="string"?a.format:void 0;if(r)return{widget:r,source:"explicit-format",options:typeof a=="object"?a:void 0};if(typeof t.format=="string")return{widget:{datetime:"date-time",base64:"binary",bytes:"binary",iri:"uri","iri-reference":"uri-reference","idn-hostname":"hostname"}[t.format]||t.format,source:"schema-format"};if(t.contentMediaType==="text/markdown")return{widget:"markdown",source:"schema-media"};if(t.contentMediaType!=null||t.contentEncoding==="base64")return{widget:"binary",source:"schema-media",options:{mediaType:t.contentMediaType,encoding:t.contentEncoding}};if(t.enum!=null)return{widget:"enum",source:"constraints"};if(t.const!=null)return{widget:"const",source:"constraints"};if((t.type==="number"||t.type==="integer"||Array.isArray(t.type)&&t.type.some(s=>s==="number"||s==="integer"))&&t.minimum!=null&&t.maximum!=null)return t.maximum-t.minimum<=5&&t.minimum>=0&&t.minimum<=1&&(t.multipleOf==null||t.multipleOf>=1)?{widget:"rating",source:"constraints",options:{max:t.maximum}}:{widget:"slider",source:"constraints",options:{min:t.minimum,max:t.maximum,step:t.multipleOf}};if(t.type==="string"){if(t.minLength!=null&&t.minLength>20||t.maxLength!=null&&t.maxLength>100)return{widget:"textarea",source:"heuristics"};if(n){const s=n.toLowerCase();if(s.includes("password")||s.includes("secret"))return{widget:"password",source:"heuristics"};if(s.includes("email"))return{widget:"email",source:"heuristics"};if(s.includes("url")||s.includes("link"))return{widget:"url",source:"heuristics"};if(s.includes("color"))return{widget:"color",source:"heuristics"};if(Bt(t).some(c=>s.includes(c.toLowerCase())))return{widget:"textarea",source:"heuristics"}}}}class ut{widgets=new Map;typeMapping=new Map;register(n,a){if(this.widgets.set(n,a),a.supportedTypes)for(const r of a.supportedTypes)this.typeMapping.has(r)||this.typeMapping.set(r,[]),this.typeMapping.get(r).push(n),this.typeMapping.get(r).sort((o,s)=>{const l=this.widgets.get(o)?.priority||0;return(this.widgets.get(s)?.priority||0)-l})}unregister(n){const a=this.widgets.get(n);if(a&&(this.widgets.delete(n),a.supportedTypes))for(const r of a.supportedTypes){const o=this.typeMapping.get(r);if(o){const s=o.indexOf(n);s>=0&&o.splice(s,1),o.length===0&&this.typeMapping.delete(r)}}}get(n){return this.widgets.get(n)}getAll(){return new Map(this.widgets)}getForType(n){return(this.typeMapping.get(n)||[]).map(r=>this.widgets.get(r)).filter(Boolean)}findBestWidget(n){const a=it(n.definition,n.name);if(a?.widget){const o=this.widgets.get(a.widget);if(o)return{name:a.widget,registration:o,resolved:a}}const r=[];for(const[o,s]of this.widgets.entries())if(s.matcher)try{s.matcher(n)&&r.push({name:o,registration:s,priority:s.priority??0})}catch(l){console.warn(`Error in matcher for widget "${o}":`,l)}if(r.length>0){r.sort((s,l)=>l.priority-s.priority);const o=r[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 Lt=new ut;function Ut(t,n,a){return{factory:n,matcher:r=>{const s=r.definition["x:ui"];return s===t||typeof s=="object"&&s!==null&&s.widget===t},displayName:a?.displayName??t,priority:a?.priority??100,...a}}function Wt(t,n,a){return{factory:n,matcher:r=>r.definition.format===t,displayName:a?.displayName??`${t} widget`,priority:a?.priority??75,...a}}function Ht(t,n,a,r){return{factory:a,matcher:o=>{const s=o.definition;return s.type===t&&s.format===n},displayName:r?.displayName??`${t}:${n} widget`,priority:r?.priority??80,...r}}function Pt(t){const n=t?.logPrefix??"WIDGET_DIAG",a=t?.filterFn??(()=>!0);return{factory:()=>null,displayName:"Diagnostic Widget (never matches)",priority:-1e3,matcher:r=>{if(!a(r))return!1;const o=r.definition,s={name:r.name,path:r.path.map(String),type:o?.type,hasRegistry:r.widgetRegistry!==void 0,definition:o};return console.log(`[${n}] name="${s.name??"ROOT"}" path=[${s.path.join(", ")}] type="${s.type??"unknown"}" hasRegistry=${s.hasRegistry}`),t?.onProcess?.(s),!1}}}exports.Base64Input=bt;exports.Base64sInput=st;exports.Card=xt;exports.ColorSwatchInput=wt;exports.EditableText=$t;exports.NullableDateInput=Mt;exports.NullableDateTimeInput=Ct;exports.NullableEmailInput=Tt;exports.NullablePasswordInput=At;exports.NullableRatingInput=Rt;exports.NullableSliderInput=Dt;exports.NullableTextArea=Ft;exports.NullableTextInput=_t;exports.NullableUUIDInput=vt;exports.NullableUrlInput=Ot;exports.RatingInput=lt;exports.SliderInput=Et;exports.Switch=kt;exports.WidgetRegistry=ut;exports.createDiagnosticWidget=Pt;exports.emptyToNull=H;exports.fileToBase64=at;exports.forFormat=Wt;exports.forTypeAndFormat=Ht;exports.forXUI=Ut;exports.formatColor=N;exports.getContrastRatio=mt;exports.getXUIConfig=ct;exports.globalWidgetRegistry=Lt;exports.hexToRgb=R;exports.hslToRgb=j;exports.hwbToRgb=tt;exports.isValidColor=gt;exports.isValidHexColor=P;exports.isValidHslColor=G;exports.isValidRgbColor=z;exports.isValidRgbaColor=Y;exports.linearToSrgb=O;exports.mulberry32=J;exports.normalizeHexColor=K;exports.nullToEmpty=ot;exports.oklchToRgb=nt;exports.parseAnyColor=Q;exports.resolveEffectiveFormat=S;exports.resolveWidget=it;exports.rgbToHex=B;exports.rgbToHsl=L;exports.rgbToHwb=et;exports.rgbToOklch=rt;exports.srgbToLinear=D;exports.toRgbaString=Z;
1
+ "use strict";const e=require("@tempots/dom"),k=require("./deep-merge-DBUbjJYt.cjs"),$=require("./translations-hMQlZmD4.cjs"),X=require("@tempots/ui"),q=require("./notice-BGaJ4k0O.cjs"),pt=require("./use-form-B4D58mxd.cjs");function P(t){if(typeof t!="string")return!1;const n=t.startsWith("#")?t.slice(1):t;return/^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(n)}function z(t){if(typeof t!="string")return!1;const n=/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i,a=t.match(n);if(!a)return!1;const[,r,o,s]=a,l=parseInt(r,10),c=parseInt(o,10),i=parseInt(s,10);return l>=0&&l<=255&&c>=0&&c<=255&&i>=0&&i<=255}function Y(t){if(typeof t!="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,a=t.match(n);if(!a)return!1;const[,r,o,s,l]=a,c=parseInt(r,10),i=parseInt(o,10),u=parseInt(s,10),p=parseFloat(l);return c>=0&&c<=255&&i>=0&&i<=255&&u>=0&&u<=255&&p>=0&&p<=1}function G(t){if(typeof t!="string")return!1;const n=/^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/i,a=t.match(n);if(!a)return!1;const[,r,o,s]=a,l=parseInt(r,10),c=parseInt(o,10),i=parseInt(s,10);return l>=0&&l<=360&&c>=0&&c<=100&&i>=0&&i<=100}function gt(t){return P(t)||z(t)||Y(t)||G(t)}function K(t){if(!P(t))return null;let n=t.startsWith("#")?t.slice(1):t;return n.length===3&&(n=n.split("").map(a=>a+a).join("")),`#${n.toLowerCase()}`}function B(t,n,a){const r=o=>{const s=Math.round(Math.max(0,Math.min(255,o))).toString(16);return s.length===1?"0"+s:s};return`#${r(t)}${r(n)}${r(a)}`}function R(t){const n=K(t);if(!n)return null;const a=/^#([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);return a?{r:parseInt(a[1],16),g:parseInt(a[2],16),b:parseInt(a[3],16)}:null}function mt(t,n){const a=R(t),r=R(n);if(!a||!r)return null;const o=(u,p,d)=>{const[f,g,y]=[u,p,d].map(w=>(w=w/255,w<=.03928?w/12.92:Math.pow((w+.055)/1.055,2.4)));return .2126*f+.7152*g+.0722*y},s=o(a.r,a.g,a.b),l=o(r.r,r.g,r.b),c=Math.max(s,l),i=Math.min(s,l);return(c+.05)/(i+.05)}function Q(t){if(!t)return[0,0,0,1];const a=t.trim().match(/^#?([a-fA-F0-9]{3,4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$/);if(a){const u=a[1];if(u.length===8){const p=parseInt(u.slice(0,2),16),d=parseInt(u.slice(2,4),16),f=parseInt(u.slice(4,6),16),g=parseInt(u.slice(6,8),16)/255;return[p,d,f,g]}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),d=parseInt(u[1]+u[1],16),f=parseInt(u[2]+u[2],16),g=parseInt(u[3]+u[3],16)/255;return[p,d,f,g]}if(u.length===3){const p=parseInt(u[0]+u[0],16),d=parseInt(u[1]+u[1],16),f=parseInt(u[2]+u[2],16);return[p,d,f,1]}}const r=t.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(r)return[parseInt(r[1],10),parseInt(r[2],10),parseInt(r[3],10),parseFloat(r[4])];const o=t.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=t.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]),d=parseFloat(s[3]),f=s[4]!=null?parseFloat(s[4]):1,[g,y,w]=j(u,p/100,d/100);return[g,y,w,f]}const l=t.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,d=parseFloat(l[3])/100,f=l[4]!=null?parseFloat(l[4]):1,[g,y,w]=tt(u,p,d);return[g,y,w,f]}const c=t.match(/^oklch\(\s*([+-]?[\d.]+%?)\s+([\d.]+)\s+([+-]?[\d.]+)(?:deg)?(?:\s*\/\s*(\d?(?:\.\d+)?))?\s*\)$/i);if(c){const u=c[1],p=parseFloat(c[2]),d=parseFloat(c[3]),f=c[4]!=null?parseFloat(c[4]):1,g=u.endsWith("%")?Math.max(0,Math.min(1,parseFloat(u)/100)):Math.max(0,Math.min(1,parseFloat(u))),[y,w,b]=nt(g,p,d);return[y,w,b,f]}const i=R(t);return i?[i.r,i.g,i.b,1]:[0,0,0,1]}function Z(t,n,a,r){return`rgba(${Math.round(t)}, ${Math.round(n)}, ${Math.round(a)}, ${Math.max(0,Math.min(1,Math.round(r*100)/100))})`}function J(t){let n=t+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(t,n,a){t=(t%360+360)%360;const r=(1-Math.abs(2*a-1))*n,o=r*(1-Math.abs(t/60%2-1)),s=a-r/2;let l=0,c=0,i=0;return 0<=t&&t<60?[l,c,i]=[r,o,0]:60<=t&&t<120?[l,c,i]=[o,r,0]:120<=t&&t<180?[l,c,i]=[0,r,o]:180<=t&&t<240?[l,c,i]=[0,o,r]:240<=t&&t<300?[l,c,i]=[o,0,r]:[l,c,i]=[r,0,o],[Math.round((l+s)*255),Math.round((c+s)*255),Math.round((i+s)*255)]}function tt(t,n,a){t=(t%360+360)%360;const r=n+a;r>1&&(n/=r,a/=r);const[o,s,l]=j(t,1,.5).map(d=>d/255),c=1-n-a,i=o*c+n,u=s*c+n,p=l*c+n;return[Math.round(i*255),Math.round(u*255),Math.round(p*255)]}function L(t,n,a){t/=255,n/=255,a/=255;const r=Math.max(t,n,a),o=Math.min(t,n,a);let s=0,l=0;const c=(r+o)/2,i=r-o;if(i!==0){switch(l=c>.5?i/(2-r-o):i/(r+o),r){case t:s=(n-a)/i+(n<a?6:0);break;case n:s=(a-t)/i+2;break;default:s=(t-n)/i+4}s*=60}return[Math.round(s),Math.round(l*100),Math.round(c*100)]}function et(t,n,a){const[r]=L(t,n,a),o=t/255,s=n/255,l=a/255,c=Math.min(o,s,l),i=1-Math.max(o,s,l);return[r,Math.round(c*100),Math.round(i*100)]}function D(t){const n=t/255;return n<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function O(t){const n=t<=.0031308?12.92*t:1.055*Math.pow(t,.4166666666666667)-.055;return Math.round(Math.max(0,Math.min(1,n))*255)}function nt(t,n,a){const r=a*Math.PI/180,o=Math.cos(r)*n,s=Math.sin(r)*n,l=t+.3963377774*o+.2158037573*s,c=t-.1055613458*o-.0638541728*s,i=t-.0894841775*o-1.291485548*s,u=l*l*l,p=c*c*c,d=i*i*i,f=4.0767416621*u-3.3077115913*p+.2309699292*d,g=-1.2684380046*u+2.6097574011*p-.3413193965*d,y=-.0041960863*u-.7034186147*p+1.707614701*d;return[O(f),O(g),O(y)]}function rt(t,n,a){const r=D(t),o=D(n),s=D(a),l=.4122214708*r+.5363325363*o+.0514459929*s,c=.2119034982*r+.6806995451*o+.1073969566*s,i=.0883024619*r+.2817188376*o+.6299787005*s,u=Math.cbrt(l),p=Math.cbrt(c),d=Math.cbrt(i),f=.2104542553*u+.793617785*p-.0040720468*d,g=1.9779984951*u-2.428592205*p+.4505937099*d,y=.0259040371*u+.7827717662*p-.808675766*d,w=Math.sqrt(g*g+y*y);let b=Math.atan2(y,g)*180/Math.PI;return b<0&&(b+=360),[f,w,b]}function N(t,n,a,r,o,s){switch(o){case"hex":if(s){const l=i=>i.toString(16).padStart(2,"0"),c=Math.max(0,Math.min(255,Math.round(r*255)));return`#${l(t)}${l(n)}${l(a)}${l(c)}`}return B(t,n,a);case"rgb":return`rgb(${t}, ${n}, ${a})`;case"rgba":return`rgba(${t}, ${n}, ${a}, ${Math.round(r*100)/100})`;case"hsl":{const[l,c,i]=L(t,n,a);return`hsl(${l}, ${c}%, ${i}%)`}case"hsla":{const[l,c,i]=L(t,n,a);return`hsla(${l}, ${c}%, ${i}%, ${Math.round(r*100)/100})`}case"hwb":{const[l,c,i]=et(t,n,a);return r<1?`hwb(${l} ${c}% ${i}% / ${Math.round(r*100)/100})`:`hwb(${l} ${c}% ${i}%)`}case"oklch":{const[l,c,i]=rt(t,n,a),u=(Math.round(l*1e3)/1e3).toFixed(3),p=(Math.round(c*1e3)/1e3).toFixed(3),d=(Math.round(i*10)/10).toFixed(1),f=Math.round(r*100)/100;return s||r<1?`oklch(${u} ${p} ${d} / ${f})`:`oklch(${u} ${p} ${d})`}}}function S(t,n){return n?t==="rgb"?"rgba":t==="hsl"?"hsla":t:t==="rgba"?"rgb":t==="hsla"?"hsl":t}async function at(t){return new Promise((n,a)=>{const r=new FileReader;r.readAsDataURL(t),r.onload=()=>{const o=r.result;n(o.split(",")[1])},r.onerror=o=>a(o)})}function dt(t){return Promise.all(t.map(at))}function ht(t){if(t.length>=4){if(t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71)return"image/png";if(t[0]===255&&t[1]===216)return"image/jpeg";if(t[0]===71&&t[1]===73&&t[2]===70)return"image/gif";if(t[0]===82&&t[1]===73&&t[2]===70&&t[3]===70&&t.length>=12&&t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80)return"image/webp"}try{if(new TextDecoder("utf-8").decode(t.slice(0,256)).includes("<svg"))return"image/svg+xml"}catch{}return"application/octet-stream"}function ft(t){const n=k.$t(t??""),a=n.length,r=new Uint8Array(a);for(let o=0;o<a;o++)r[o]=n.charCodeAt(o);return r}function st(t){const{value:n,onChange:a,onInput:r,...o}=t,s=new Map,l=e.Value.toSignal(n).map(p=>p.map((d,f)=>{const g=s.get(d),y=ft(d??""),w=g?.type||ht(y),b=g?.name??`file-${f}`,x=y.buffer.slice(y.byteOffset,y.byteOffset+y.byteLength),h=new Blob([x],{type:w});return new File([h],b,{type:w})})),c=p=>d=>{p&&dt(d).then(f=>{for(const[g,y]of f.entries())s.set(y,{name:d[g].name,type:d[g].type});p(f)})},i=c(a),u=c(r);return k.FilesInput({...o,value:l,onChange:i,onInput:u})}function bt(t){const{value:n,onInput:a,onChange:r,...o}=t;return st({...o,maxFiles:1,value:e.Value.map(n,s=>s==null?[]:[s]),onChange:s=>{r?.(s[0])},onInput:s=>{a?.(s[0])}})}function yt(t,n){const[a,r,o]=t,s=a<<16^r<<8^o,l=J(s),c=6+Math.floor(l()*5),i=.18+l()*.06,u=[];for(let g=0;g<c;g++){const y=g/c*Math.PI*2,w=n*(1+(l()*2-1)*i),b=Math.cos(y)*w,x=Math.sin(y)*w;u.push({x:b,y:x})}const p=(u[0].x+u[c-1].x)/2,d=(u[0].y+u[c-1].y)/2;let f=`M ${p.toFixed(3)} ${d.toFixed(3)}`;for(let g=0;g<c;g++){const y=u[g],w=u[(g+1)%c],b=(y.x+w.x)/2,x=(y.y+w.y)/2;f+=` Q ${y.x.toFixed(3)} ${y.y.toFixed(3)} ${b.toFixed(3)} ${x.toFixed(3)}`}return f+=" Z",f}const wt=t=>{const{value:n,onBlur:a,onChange:r,onInput:o,displayValue:s,size:l,withAlpha:c}=t,i=e.Value.map(l??32,m=>m),u=e.Value.map(n,m=>Q(m??"#000000")),p=e.Value.map(u,([m,I,V])=>[m,I,V]),d=e.Value.map(u,([,,,m])=>m),f=e.prop(e.Value.get(d)??1),g=e.Value.map(c??!1,m=>m),y=e.Value.map(t.colorTextFormat??"rgb",m=>m),w=e.computedOf(p,f,y,g)(([m,I,V],_,A,F)=>N(m,I,V,_??1,S(A,F),F)),b=e.Value.map(t.colorTextFormat??"hex",m=>m),x=e.Value.map(i,m=>`${-m/2} ${-m/2} ${m} ${m}`),h=e.computedOf(p,i)((m,I)=>yt(m,I/2)),T=e.computedOf(p,f,g)(([m,I,V],_,A)=>A||_<1?Z(m,I,V,_):B(m,I,V)),C=e.html.div(e.attr.class("bc-color-swatch-input__control"),e.attr.class(e.Value.map(g,m=>m?"bc-color-swatch-input__control--alpha":"")),e.attr.style(e.computedOf(i)(m=>`min-width:${m+2}px;height:${m+2}px`)),e.svg.svg(e.attr.class("bc-color-swatch-input__svg"),e.svgAttr.viewBox(x),e.svg.path(e.svgAttr.d(h),e.svgAttr.fill(T))),e.html.input(e.attr.type("color"),$.CommonInputAttributes(t),e.attr.value(e.Value.map(p,([m,I,V])=>B(m,I,V))),e.attr.class("bc-input bc-color-swatch-input bc-color-swatch-input__native"),a!=null?e.on.blur(a):e.Empty,r!=null?e.on.change(m=>{const I=m.target.value;if(!r)return;const{r:V,g:_,b:A}=R(I)??{r:0,g:0,b:0},F=e.Value.get(f)??1,v=S(e.Value.get(b),e.Value.get(g)),U=N(V,_,A,F,v,e.Value.get(g));r(U)}):e.Empty,o!=null?e.on.input(m=>{const I=m.target.value;if(!o)return;const{r:V,g:_,b:A}=R(I)??{r:0,g:0,b:0},F=e.Value.get(f)??1,v=S(e.Value.get(b),e.Value.get(g)),U=N(V,_,A,F,v,e.Value.get(g));o(U)}):e.Empty)),M=e.When(g,()=>e.html.input(e.attr.type("range"),e.attr.class("bc-color-swatch-input__alpha"),e.attr.min(0),e.attr.max(1),e.attr.step(.01),e.attr.value(e.Value.map(f,m=>String(m??1))),e.attr.disabled(t.disabled),e.on.input(m=>{const I=parseFloat(m.target.value);f.set(I);const[V,_,A]=e.Value.get(p),F=S(e.Value.get(b),e.Value.get(g)),v=N(V,_,A,I,F,e.Value.get(g));o?.(v)}),e.on.change(m=>{const I=parseFloat(m.target.value);f.set(I);const[V,_,A]=e.Value.get(p),F=S(e.Value.get(b),e.Value.get(g)),v=N(V,_,A,I,F,e.Value.get(g));r?.(v)})));return $.InputContainer({baseContainer:!0,...t,growInput:!1,input:C,after:e.Fragment(e.When(s??!1,()=>e.html.span(e.attr.class("bc-color-swatch-input__rgb"),w)),M,t.after)})};function It(t,n,a){const r=["bc-card"];return t!=="default"&&r.push(`bc-card--${t}`),n!=="md"&&r.push(`bc-card--padding-${n}`),a!=="lg"&&r.push(`bc-card--rounded-${a}`),r.join(" ")}function xt({variant:t="default",size:n="md",roundedness:a="lg"}={},...r){return e.html.div(e.attr.class(e.computedOf(t,n,a)((o,s,l)=>It(o??"default",s??"md",l??"lg"))),...r)}const $t=({startEditing:t,value:n,onChange:a,placeholder:r,disabled:o})=>{const s=e.Value.deriveProp(t??!1),l=e.prop(!1),c=e.Value.map(o??!1,i=>i);return e.html.div(e.attr.class("bc-editable-text"),e.attr.class(e.Value.map(c,i=>i?"bc-editable-text--disabled":"")),e.aria.disabled(c),e.When(s,()=>e.html.input(e.attr.placeholder(r),e.attr.value(n),e.attr.class("bc-editable-text__input"),X.AutoSelect(),e.on.keydown(i=>{i.key==="Enter"?s.set(!1):i.key==="Escape"&&(l.set(!0),s.set(!1))}),e.on.blur(e.emitValue(i=>{if(s.set(!1),l.value){l.set(!1);return}a(i)}))),()=>e.html.span(e.on.click(()=>{e.Value.get(c)||s.set(!0)}),e.attr.class("bc-editable-text__display"),e.When(e.Value.map(n,i=>i!=null&&i.trim()!==""),()=>e.html.span(e.attr.class("bc-editable-text__text"),n),()=>e.html.span(e.attr.class("bc-editable-text__placeholder"),r)),e.When(e.Value.map(c,i=>!i),()=>e.html.button(e.attr.type("button"),e.attr.class("bc-editable-text__edit-button"),e.Use($.BeatUII18n,i=>e.aria.label(i.$.editLabel)),e.on.click(()=>s.set(!0)),$.Icon({icon:"line-md/pencil",color:"neutral"}))))))},Mt=t=>{const{value:n,onBlur:a,onChange:r,onInput:o,after:s,disabled:l}=t,c=k.NullableResetAfter(n,l,r??o);return $.InputContainer({...t,input:e.input.date($.CommonInputAttributes(t),e.attr.valueAsDate(n),e.attr.class("bc-input"),a!=null?e.on.blur(e.emitValue(a)):e.Empty,r!=null?e.on.change(e.emitValueAsNullableDate(r)):e.Empty,o!=null?e.on.input(e.emitValueAsNullableDate(o)):e.Empty),after:s!=null?e.Fragment(c,s):c})},Vt=t=>{const n=t.getFullYear(),a=t.getMonth()+1,r=t.getDate(),o=t.getHours(),s=t.getMinutes(),l=t.getSeconds();return`${n}-${a.toString().padStart(2,"0")}-${r.toString().padStart(2,"0")}T${o.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}:${l.toString().padStart(2,"0")}`},Ct=t=>{const{value:n,onBlur:a,onChange:r,onInput:o,after:s,disabled:l}=t,c=e.Value.map(n,u=>u!=null?Vt(u):null),i=k.NullableResetAfter(n,l,r??o);return $.InputContainer({...t,input:e.input["datetime-local"]($.CommonInputAttributes(t),e.attr.value(e.Value.map(c,u=>u??null)),e.attr.class("bc-input"),a!=null?e.on.blur(e.emitValue(a)):e.Empty,r!=null?e.on.change(e.emitValueAsNullableDateTime(r)):e.Empty,o!=null?e.on.input(e.emitValueAsNullableDateTime(o)):e.Empty),after:s!=null?e.Fragment(i,s):i})},H=t=>typeof t=="string"&&t.trim()===""?null:t,ot=t=>t??"";function E(t){return n=>{const{value:a,onBlur:r,onChange:o,onInput:s,after:l,disabled:c,...i}=n,u=k.NullableResetAfter(a,c,o??s);return t({...i,disabled:c,value:e.Value.map(a,ot),onChange:o!=null?p=>o(H(p)):void 0,onInput:s!=null?p=>s(H(p)):void 0,onBlur:r,after:l!=null?e.Fragment(u,l):u})}}const Tt=E(q.EmailInput),_t=E($.TextInput),At=E(q.PasswordInput),Ft=E(k.TextArea),kt=({value:t,onChange:n,onInput:a,onBlur:r,offLabel:o,onLabel:s,disabled:l=!1,size:c="md",id:i,color:u="primary",tabIndex:p=0})=>{const d=i??pt.sessionId("switch");function f(b,x){const h=["bc-switch",`bc-switch--size-${x}`,`bc-switch--${x}`];return b&&h.push("bc-switch--disabled"),h.join(" ")}function g(b){const x=b??"primary",h=new Map,T=$.backgroundValue(x,"solid","light"),C=$.backgroundValue(x,"solid","dark");return h.set("--switch-track-on-bg",T.backgroundColor),h.set("--switch-track-on-label",T.textColor),h.set("--switch-track-on-bg-dark",C.backgroundColor),h.set("--switch-track-on-label-dark",C.textColor),h.set("--switch-track-on-border-dark",$.borderColorValue(x,"dark")),Array.from(h.entries()).map(([M,m])=>`${M}: ${m}`).join("; ")}const y=()=>{e.Value.get(l)||(n?.(!e.Value.get(t)),a?.(!e.Value.get(t)))},w=b=>{e.Value.get(l)||(b.key===" "||b.key==="Enter")&&(b.preventDefault(),y())};return e.html.div(e.attr.class(e.computedOf(l??!1,c)((b,x)=>f(b??!1,x??"md"))),e.attr.style(e.computedOf(u)(b=>g(b))),e.attr.id(d),e.attr.role("switch"),e.attr.tabindex(e.computedOf(l??!1,p)((b,x)=>b?-1:x??0)),e.aria.checked(t),e.aria.disabled(l),e.on.click(y),e.on.keydown(w),r!=null?e.on.blur(r):null,e.html.div(e.attr.class("bc-switch__track"),e.attr.class(e.Value.map(t,b=>b?"bc-switch__track--on":"bc-switch__track--off")),o!=null?e.html.div(e.aria.hidden(!0),e.attr.class("bc-switch__track-label bc-switch__track-label--off"),e.attr.class(e.Value.map(t,b=>b?"bc-switch__track-label--hidden":"bc-switch__track-label--visible")),o):null,s!=null?e.html.div(e.attr.class("bc-switch__track-label bc-switch__track-label--on"),e.attr.class(e.Value.map(t,b=>b?"bc-switch__track-label--visible":"bc-switch__track-label--hidden")),s):null,X.ElementRect(b=>e.Use($.Locale,({direction:x})=>e.html.div(e.attr.class("bc-switch__thumb"),e.attr.class(e.Value.map(t,h=>h?"bc-switch__thumb--on":"bc-switch__thumb--off")),e.style.transform(e.computedOf(t,b,c,x)((h,{width:T},C,M)=>{const m=(()=>{switch(C){case"xs":return 5;case"sm":return 5.5;case"md":return 6;case"lg":return 7;case"xl":return 8}})(),I=M==="rtl"?`calc((var(--spacing-base) * ${m}) - ${T}px)`:`calc(${T}px - (var(--spacing-base) * ${m}))`;return h?`translateX(${I})`:"translateX(0)"})))))))},vt=E(k.UUIDInput),Nt="line-md:star-alt-filled",St="line-md:star-alt",lt=t=>{const{value:n,onChange:a,disabled:r,max:o=5,fullColor:s="yellow",emptyColor:l="neutral",fullIcon:c=Nt,emptyIcon:i=St,size:u="md",onBlur:p,rounding:d=1}=t,f=()=>{const h=e.Value.get(d);return h>0?h:1},g=h=>Math.min(Math.max(h,0),e.Value.get(o)),y=(h,T)=>{if(e.Value.get(r??!1))return;const M=h.currentTarget.getBoundingClientRect(),m=(h.clientX-M.left)/M.width,I=T-1+m,V=f(),_=Math.ceil(I/V)*V,A=g(_);a?.(A)},w=h=>{if(e.Value.get(r??!1))return;const T=f(),C=e.Value.get(n)??0;let M;switch(h.key){case"ArrowRight":case"ArrowUp":M=g(C+T);break;case"ArrowLeft":case"ArrowDown":M=g(C-T);break;case"Home":M=0;break;case"End":M=e.Value.get(o);break;default:return}h.preventDefault(),a?.(M)},b=e.Value.map(u,h=>`bc-icon--${h}`),x=({index:h,counter:T})=>e.html.span(e.attr.class("bc-rating-input__icon-container"),e.attr.class(b),$.Icon({icon:i,size:u,color:l,tone:"soft"},e.attr.class("bc-rating-input__icon-empty")),e.html.span(e.attr.class("bc-rating-input__icon-clipper"),e.attr.class(b),e.style.width(e.Value.map(n,C=>{const M=Math.floor(C);return M>h?"100%":M<h?"0%":`${(C-h)*100}%`})),$.Icon({icon:c,size:u,color:s,tone:"soft"},e.attr.class("bc-rating-input__icon-full"))),e.on.click(e.emit(C=>y(C,T),{preventDefault:!0,stopPropagation:!0})));return $.InputContainer({baseContainer:!0,growInput:!1,focusableSelector:'[role="slider"]',...t,input:e.html.div($.CommonInputAttributes(t),e.attr.class("bc-rating-input"),e.attr.role("slider"),e.attr.tabindex(e.Value.map(r??!1,h=>h?-1:0)),e.aria.disabled(r??!1),e.aria.valuemin(0),e.aria.valuemax(e.Value.map(o,h=>h??0)),e.aria.valuenow(e.Value.map(n,h=>h??0)),e.aria.valuetext(e.computedOf(n,o)((h,T)=>{const C=h??0,M=T??0;return`${String(C)} / ${String(M)}`})),e.on.keydown(w),p!=null?e.on.blur(p):null,e.Repeat(o,x))})},Rt=t=>{const{value:n,onChange:a,onInput:r,onBlur:o,after:s,disabled:l,...c}=t,i=k.NullableResetAfter(n,l,a??r);return lt({...c,value:e.Value.map(n,u=>u??0),onChange:a,onInput:r,onBlur:o,after:s!=null?e.Fragment(i,s):i})},Et=t=>{const{value:n,step:a,min:r,max:o,onBlur:s,onChange:l,onInput:c}=t;return $.InputContainer({...t,focusableSelector:'input[type="range"]',input:e.html.input(e.attr.type("range"),$.CommonInputAttributes(t),e.attr.min(r),e.attr.max(o),e.attr.step(a),e.attr.valueAsNumber(n),e.attr.class("bc-input bc-slider-input"),s!=null?e.on.blur(e.emitValueAsNumber(s)):e.Empty,l!=null?e.on.change(e.emitValueAsNumber(l)):e.Empty,c!=null?e.on.input(e.emitValueAsNumber(c)):e.Empty)})},Dt=t=>{const{value:n,step:a,min:r,max:o,onBlur:s,onChange:l,onInput:c}=t,i=e.Value.map(n,p=>{if(p!=null)return p;const d=r!=null?e.Value.get(r):void 0;return typeof d=="number"?d:0}),u=k.NullableResetAfter(n,t.disabled,l??c);return $.InputContainer({...t,focusableSelector:'input[type="range"]',after:u,input:e.html.input(e.attr.type("range"),$.CommonInputAttributes(t),e.attr.min(r),e.attr.max(o),e.attr.step(a),e.attr.valueAsNumber(i),e.attr.class("bc-input bc-slider-input"),s!=null?e.on.blur(e.emitValueAsNumber(s)):e.Empty,l!=null?e.on.change(e.emitValueAsNumber(p=>{l(p)})):e.Empty,c!=null?e.on.input(e.emitValueAsNumber(p=>{c(p)})):e.Empty)},e.Fragment())},Ot=E(k.UrlInput),W=["description","comment","notes","text"];function Bt(t){if(typeof t=="boolean")return W;const n=t["x:ui"];return n&&Array.isArray(n.textAreaTriggers)?[...W,...n.textAreaTriggers]:W}function ct(t){if(typeof t=="boolean")return;const n=t["x:ui"];if(n!=null&&(typeof n=="string"||typeof n=="object"&&n!==null))return n}function it(t,n){if(typeof t=="boolean")return;const a=ct(t);if(typeof a=="object"&&typeof a.widget=="string")return{widget:a.widget,source:"explicit-widget",options:a};const r=typeof a=="string"?a:typeof a=="object"&&typeof a.format=="string"?a.format:void 0;if(r)return{widget:r,source:"explicit-format",options:typeof a=="object"?a:void 0};if(typeof t.format=="string")return{widget:{datetime:"date-time",base64:"binary",bytes:"binary",iri:"uri","iri-reference":"uri-reference","idn-hostname":"hostname"}[t.format]||t.format,source:"schema-format"};if(t.contentMediaType==="text/markdown")return{widget:"markdown",source:"schema-media"};if(t.contentMediaType!=null||t.contentEncoding==="base64")return{widget:"binary",source:"schema-media",options:{mediaType:t.contentMediaType,encoding:t.contentEncoding}};if(t.enum!=null)return{widget:"enum",source:"constraints"};if(t.const!=null)return{widget:"const",source:"constraints"};if((t.type==="number"||t.type==="integer"||Array.isArray(t.type)&&t.type.some(s=>s==="number"||s==="integer"))&&t.minimum!=null&&t.maximum!=null)return t.maximum-t.minimum<=5&&t.minimum>=0&&t.minimum<=1&&(t.multipleOf==null||t.multipleOf>=1)?{widget:"rating",source:"constraints",options:{max:t.maximum}}:{widget:"slider",source:"constraints",options:{min:t.minimum,max:t.maximum,step:t.multipleOf}};if(t.type==="string"){if(t.minLength!=null&&t.minLength>20||t.maxLength!=null&&t.maxLength>100)return{widget:"textarea",source:"heuristics"};if(n){const s=n.toLowerCase();if(s.includes("password")||s.includes("secret"))return{widget:"password",source:"heuristics"};if(s.includes("email"))return{widget:"email",source:"heuristics"};if(s.includes("url")||s.includes("link"))return{widget:"url",source:"heuristics"};if(s.includes("color"))return{widget:"color",source:"heuristics"};if(Bt(t).some(c=>s.includes(c.toLowerCase())))return{widget:"textarea",source:"heuristics"}}}}class ut{widgets=new Map;typeMapping=new Map;register(n,a){if(this.widgets.set(n,a),a.supportedTypes)for(const r of a.supportedTypes)this.typeMapping.has(r)||this.typeMapping.set(r,[]),this.typeMapping.get(r).push(n),this.typeMapping.get(r).sort((o,s)=>{const l=this.widgets.get(o)?.priority||0;return(this.widgets.get(s)?.priority||0)-l})}unregister(n){const a=this.widgets.get(n);if(a&&(this.widgets.delete(n),a.supportedTypes))for(const r of a.supportedTypes){const o=this.typeMapping.get(r);if(o){const s=o.indexOf(n);s>=0&&o.splice(s,1),o.length===0&&this.typeMapping.delete(r)}}}get(n){return this.widgets.get(n)}getAll(){return new Map(this.widgets)}getForType(n){return(this.typeMapping.get(n)||[]).map(r=>this.widgets.get(r)).filter(Boolean)}findBestWidget(n){const a=it(n.definition,n.name);if(a?.widget){const o=this.widgets.get(a.widget);if(o)return{name:a.widget,registration:o,resolved:a}}const r=[];for(const[o,s]of this.widgets.entries())if(s.matcher)try{s.matcher(n)&&r.push({name:o,registration:s,priority:s.priority??0})}catch(l){console.warn(`Error in matcher for widget "${o}":`,l)}if(r.length>0){r.sort((s,l)=>l.priority-s.priority);const o=r[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 Lt=new ut;function Ut(t,n,a){return{factory:n,matcher:r=>{const s=r.definition["x:ui"];return s===t||typeof s=="object"&&s!==null&&s.widget===t},displayName:a?.displayName??t,priority:a?.priority??100,...a}}function Wt(t,n,a){return{factory:n,matcher:r=>r.definition.format===t,displayName:a?.displayName??`${t} widget`,priority:a?.priority??75,...a}}function Ht(t,n,a,r){return{factory:a,matcher:o=>{const s=o.definition;return s.type===t&&s.format===n},displayName:r?.displayName??`${t}:${n} widget`,priority:r?.priority??80,...r}}function Pt(t){const n=t?.logPrefix??"WIDGET_DIAG",a=t?.filterFn??(()=>!0);return{factory:()=>null,displayName:"Diagnostic Widget (never matches)",priority:-1e3,matcher:r=>{if(!a(r))return!1;const o=r.definition,s={name:r.name,path:r.path.map(String),type:o?.type,hasRegistry:r.widgetRegistry!==void 0,definition:o};return console.log(`[${n}] name="${s.name??"ROOT"}" path=[${s.path.join(", ")}] type="${s.type??"unknown"}" hasRegistry=${s.hasRegistry}`),t?.onProcess?.(s),!1}}}exports.Base64Input=bt;exports.Base64sInput=st;exports.Card=xt;exports.ColorSwatchInput=wt;exports.EditableText=$t;exports.NullableDateInput=Mt;exports.NullableDateTimeInput=Ct;exports.NullableEmailInput=Tt;exports.NullablePasswordInput=At;exports.NullableRatingInput=Rt;exports.NullableSliderInput=Dt;exports.NullableTextArea=Ft;exports.NullableTextInput=_t;exports.NullableUUIDInput=vt;exports.NullableUrlInput=Ot;exports.RatingInput=lt;exports.SliderInput=Et;exports.Switch=kt;exports.WidgetRegistry=ut;exports.createDiagnosticWidget=Pt;exports.emptyToNull=H;exports.fileToBase64=at;exports.forFormat=Wt;exports.forTypeAndFormat=Ht;exports.forXUI=Ut;exports.formatColor=N;exports.getContrastRatio=mt;exports.getXUIConfig=ct;exports.globalWidgetRegistry=Lt;exports.hexToRgb=R;exports.hslToRgb=j;exports.hwbToRgb=tt;exports.isValidColor=gt;exports.isValidHexColor=P;exports.isValidHslColor=G;exports.isValidRgbColor=z;exports.isValidRgbaColor=Y;exports.linearToSrgb=O;exports.mulberry32=J;exports.normalizeHexColor=K;exports.nullToEmpty=ot;exports.oklchToRgb=nt;exports.parseAnyColor=Q;exports.resolveEffectiveFormat=S;exports.resolveWidget=it;exports.rgbToHex=B;exports.rgbToHsl=L;exports.rgbToHwb=et;exports.rgbToOklch=rt;exports.srgbToLinear=D;exports.toRgbaString=Z;
@@ -1,9 +1,9 @@
1
1
  import { Value as p, prop as ot, computedOf as D, html as _, attr as u, svg as et, svgAttr as Y, on as $, Empty as A, When as W, Fragment as E, aria as N, emitValue as tt, Use as ct, input as it, emitValueAsNullableDate as nt, emitValueAsNullableDateTime as st, style as lt, Repeat as gt, emit as dt, emitValueAsNumber as B } from "@tempots/dom";
2
- import { F as ht, $ as mt, N as X, T as ft, U as bt, a as yt } from "./deep-merge-CQQCMLwG.js";
2
+ import { F as ht, $ as mt, N as X, T as ft, U as bt, a as yt } from "./deep-merge-E6b9KE6l.js";
3
3
  import { C as V, b as U, a as wt, c as Q, T as xt, L as $t, d as rt, e as Mt } from "./translations-DQxouiBG.js";
4
4
  import { AutoSelect as It, ElementRect as _t } from "@tempots/ui";
5
- import { E as kt, P as Tt } from "./notice-Cqq8g17n.js";
6
- import { s as Ct } from "./use-form-B7A865EM.js";
5
+ import { E as kt, P as Tt } from "./notice-BvS1_9Va.js";
6
+ import { s as Ct } from "./use-form-DzA1RSrN.js";
7
7
  function ut(t) {
8
8
  if (typeof t != "string") return !1;
9
9
  const e = t.startsWith("#") ? t.slice(1) : t;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tempots/beatui",
3
- "version": "0.76.0",
3
+ "version": "0.77.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.umd.js",
6
6
  "module": "dist/index.es.js",
@@ -1 +0,0 @@
1
- "use strict";const t=require("@tempots/dom"),gt=require("./colors-B9fcMxa_.cjs"),bt=require("./timer-DK_yKNwE.cjs"),vt=require("@tempots/ui"),v=require("./translations-hMQlZmD4.cjs"),$=require("./use-form-DVJXMMoN.cjs");class xt extends Error{constructor(e="Missing implementation"){super(e),this.name="MissingImplementationError"}}const yt=n=>It(n).split("_").join(" "),It=n=>(n=n.replace(/::/g,"/"),n=n.replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2"),n=n.replace(/([a-z\d])([A-Z])/g,"$1_$2"),n=n.replace(/-/g,"_"),n.toLowerCase()),Vt=n=>n.substring(0,1).toUpperCase()+n.substring(1),wt=n=>{if(typeof Buffer<"u")return Buffer.from(n,"base64").toString("utf8");if(typeof atob<"u")return atob(n);throw new xt("No implementation found for base64 decoding")};function P({onChange:n,value:e,accept:l="*/*",enableClick:r=!0,content:a,disabled:d=!1,allowMultiple:o}){return t.Use(v.BeatUII18n,h=>{const p=t.Value.deriveProp(e??[]),m=t.prop(!1),u=i=>{i.preventDefault(),i.stopPropagation(),m.value=!0},g=i=>{i.preventDefault(),i.stopPropagation(),(!i.currentTarget||!i.currentTarget.contains(i.relatedTarget))&&(m.value=!1)},I=i=>{i.preventDefault(),i.stopPropagation(),m.value=!1;const f=Array.from(i.dataTransfer?.files||[]);f.length>0&&(p.value=f,n(f,"dragdrop"))},c=i=>{t.Value.get(r)&&i.currentTarget.querySelector('input[type="file"]')?.click()};let b=null;const x=()=>{if(b==null)return;const i=Array.from(b.files??[]);i.length>0&&(p.value=i,n(i,"click")),b.value=""},C=i=>{t.Value.get(r)&&(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),c(i))};return t.html.div(t.attr.role("button"),t.attr.tabindex(t.Value.map(r,i=>i?0:-1)),t.attr.style("position: relative;"),t.on.dragover(u),t.on.dragleave(g),t.on.drop(I),t.on.click(c),t.on.keydown(C),t.html.input(t.attr.type("file"),t.attr.disabled(d),t.attr.accept(l),t.attr.multiple(o),t.attr.style("position: absolute; left: -9999px; opacity: 0; pointer-events: none;"),t.on.change(x),t.WithElement(i=>(b=i,p.on(f=>{const _=globalThis.DataTransfer;if(_!=null){const k=new _;f.forEach(O=>k.items.add(O)),i.files=k.files}}),t.Empty))),t.aria.label(t.bind(h.$.dropZoneInstructions)(r)),a({files:p,clear:()=>p.value=[],change:p.set}))})}function Ct(n,e){return n.length===e.length&&n.every((l,r)=>l===e[r])}function _t(n,e){const l=["bc-segmented-input",`bc-segmented-input--size-${n}`];return e&&l.push("bc-segmented-input--disabled"),l.join(" ")}function kt({options:n,value:e,onChange:l,size:r="md",disabled:a=!1},...d){const o=gt.f(n).map(([h,p])=>({key:h,label:p}));return t.WithElement(()=>{const h=Object.fromEntries(o.map((m,u)=>[m.key,u])),p=t.prop(o.map(()=>({left:0,width:0})),Ct);return t.html.div(t.attr.class(t.computedOf(r,a)((m,u)=>_t(m??"md",u??!1))),t.html.div(t.attr.class("bc-segmented-input__container"),t.html.div(t.attr.class("bc-segmented-input__indicator"),t.style.width(t.computedOf(e,p)((m,u)=>{const{width:g}=u[h[m]??0];return`${g}px`})),t.style.left(t.computedOf(e,p)((m,u)=>{const{left:g}=u[h[m]??0];return`${g}px`}))),o.map(({label:m,key:u},g)=>t.html.button(t.attr.type("button"),t.on.click(I=>{I.preventDefault(),t.Value.get(a)||l?.(u)}),t.attr.disabled(a),t.attr.class("bc-segmented-input__segment"),t.attr.class(t.Value.map(e,I=>I===u?"bc-segmented-input__segment--active":"bc-segmented-input__segment--inactive")),vt.ElementRect(I=>{function c(){p.update(x=>{const C=[...x];return C[g]={width:I.value.width,left:I.value.localLeft},C})}const b=bt.g(c);return t.OnDispose(b,I.on(c))}),m))),...d)})}function Et(n){const e=n.type.toLowerCase();return e.startsWith("image/")&&(e.includes("jpeg")||e.includes("jpg")||e.includes("png")||e.includes("gif")||e.includes("webp")||e.includes("svg"))}function Dt(n){const e=n.type.toLowerCase();return e.startsWith("image/")?"vscode-icons:file-type-image":e.startsWith("video/")?"vscode-icons:file-type-video":e.startsWith("audio/")?"vscode-icons:file-type-audio":e.includes("pdf")?"vscode-icons:file-type-pdf2":e.includes("word")||e.includes("document")?"vscode-icons:file-type-word":e.includes("excel")||e.includes("spreadsheet")?"vscode-icons:file-type-excel":e.includes("powerpoint")||e.includes("presentation")?"vscode-icons:file-type-powerpoint":e.includes("zip")||e.includes("archive")?"vscode-icons:file-type-zip":e.includes("text")?"vscode-icons:file-type-text":e.includes("json")?"vscode-icons:file-type-json-official":e.includes("csv")?"vscode-icons:file-type-csv":e.includes("xml")?"vscode-icons:file-type-xml":e.includes("yaml")?"vscode-icons:file-type-yaml-official":"vscode-icons:file-type-binary"}function q(n){return t.When(n.map(Et),()=>{const e=t.prop(null);return n.on(l=>{e.value&&URL.revokeObjectURL(e.value);const r=URL.createObjectURL(l);e.value=r}),t.html.div(t.OnDispose(()=>{e.value&&URL.revokeObjectURL(e.value)}),t.attr.class("bc-file-input__thumbnail-container"),t.html.img(t.attr.src(e),t.attr.alt(n.map(l=>l.name)),t.attr.class("bc-file-input__thumbnail")))},()=>v.Icon({icon:n.map(Dt)}))}const Ut=(n,...e)=>{const{value:l=t.prop([]),accept:r="*/*",maxFiles:a,maxFileSize:d,onChange:o,onBlur:h,disabled:p,hasError:m,mode:u="default",showFileList:g=!0,...I}=n,c=l,b=t.Value.map(u,w=>w==="input"),x=t.Value.map(u,w=>w==="compact"),C=w=>{let s=w;if(a!=null){const y=t.Value.get(a);s=s.slice(0,y)}if(d){const y=t.Value.get(d);s=s.filter(E=>E.size<=y)}o?.(s)},i=w=>{const y=c.value.filter((E,D)=>D!==w);o?.(y)},f=()=>{o?.([])},_=({files:w,clear:s,change:y})=>t.Use(v.BeatUII18n,E=>t.html.div(t.attr.class("bc-file-input__drop-zone"),t.html.div(t.attr.class("bc-file-input__drop-zone-content bc-file-input__drop-zone-content--empty"),v.Icon({icon:"mdi:cloud-upload-outline",size:"xl"}),t.html.div(t.attr.class("bc-file-input__drop-zone-text"),t.bind(E.$.filesInputInstructions)(a,d,E.$.fileSizeUnits.value))))),k=({files:w})=>t.Use(v.BeatUII18n,s=>t.html.div(t.attr.class("bc-file-input__compact-drop-zone"),t.When(w.map(y=>y.length>0),()=>t.html.div(t.attr.class("bc-file-input__compact-file-list"),t.ForEach(w,(y,E)=>{const D=E.index;return t.html.div(t.attr.class("bc-file-input__compact-file-item"),t.html.div(t.attr.class("bc-file-input__compact-file-icon"),q(y)),t.html.div(t.attr.class("bc-file-input__compact-file-info"),t.html.div(t.attr.class("bc-file-input__compact-file-name"),t.attr.title(y.$.name),y.$.name),t.html.div(t.attr.class("bc-file-input__compact-file-meta"),t.computedOf(y.$.size,s.$.fileSizeUnits)((V,U)=>v.formatFileSize(V,{units:U}))," • ",t.computedOf(y.$.type,s.$.unknownType)((V,U)=>V||U))),$.CloseButton({size:"sm",label:s.$.removeFile,disabled:p,onClick:()=>i(D)},t.attr.class("bc-file-input__compact-remove-button")))})),()=>t.html.div(t.attr.class("bc-file-input__compact-placeholder"),v.Icon({icon:"mdi:cloud-upload-outline",size:"lg"}),t.html.div(t.attr.class("bc-file-input__compact-placeholder-text"),t.bind(s.$.filesInputInstructions)(a,d,s.$.fileSizeUnits.value)))))),O=({files:w})=>t.Use(v.BeatUII18n,s=>t.html.div(t.attr.class("bc-file-input__compact-input"),t.When(w.map(y=>y.length>0),()=>t.html.span(t.attr.class("bc-file-input__compact-value"),t.ForEach(w,y=>t.html.span(t.attr.class("bc-file-input__compact-value-item"),q(y),t.html.span(t.attr.class("bc-file-input__compact-value-item-name"),y.$.name)))),()=>t.html.span(t.attr.class("bc-file-input__compact-placeholder"),v.Icon({icon:"mdi:cloud-upload-outline",size:"md"})," ",t.bind(s.$.filesInputInstructions)(a,d,s.$.fileSizeUnits.value)))));return t.Use(v.BeatUII18n,w=>v.InputContainer({baseContainer:t.Value.map(b,s=>!s),disabled:p,hasError:m,after:t.When(b,()=>t.When(c.map(({length:s})=>s>0),()=>$.CloseButton({size:"sm",label:w.$.clearAllFiles,disabled:p,onClick:f},t.attr.class("bc-file-input__compact-clear")))),...I,input:t.When(b,()=>t.html.div(t.attr.class("bc-file-input bc-file-input--input"),P({value:c,accept:r,enableClick:!0,allowMultiple:t.Value.map(a??1/0,s=>s>1),disabled:p,onChange:C,content:O})),()=>t.When(x,()=>t.html.div(t.attr.class("bc-file-input bc-file-input--compact"),P({value:c,accept:r,enableClick:!0,allowMultiple:t.Value.map(a??1/0,s=>s>1),disabled:p,onChange:C,content:k})),()=>t.html.div(t.attr.class("bc-file-input"),P({value:c,accept:r,enableClick:!0,allowMultiple:t.Value.map(a??1/0,s=>s>1),disabled:p,onChange:C,content:_}),t.When(g,()=>t.NotEmpty(c,()=>t.Fragment(t.html.div(t.attr.class("bc-file-input__file-list"),t.ForEach(c,(s,y)=>{const E=y.index;return t.html.div(t.attr.class("bc-file-input__file-item"),t.html.div(t.attr.class("bc-file-input__file-icon"),q(s)),t.html.div(t.attr.class("bc-file-input__file-info"),t.html.div(t.attr.class("bc-file-input__file-name"),t.attr.title(s.$.name),s.$.name),t.html.div(t.attr.class("bc-file-input__file-meta"),t.computedOf(s.$.size,w.$.fileSizeUnits)((D,V)=>v.formatFileSize(D,{units:V}))," • ",t.computedOf(s.$.type,w.$.unknownType)((D,V)=>D||V))),$.CloseButton({size:"sm",label:w.$.removeFile,disabled:p,onClick:()=>i(E)},t.attr.class("bc-file-input__remove-button")))})),t.When(c.map(({length:s})=>s>1),()=>t.html.div(t.attr.class("bc-file-input__clear-all-button-container"),t.html.button(t.attr.type("button"),t.attr.class("bc-file-input__clear-all-button"),t.attr.disabled(p),w.$.clearAllFiles,t.on.click(s=>{s.preventDefault(),s.stopPropagation(),f()}))))))))))},...e))},Y="$$tts-exp-",rt=(n,e)=>t.WithElement(l=>{const r=`${Y}${n}`;return t.OnDispose(t.Value.on(e,a=>Reflect.set(l,r,a)))}),$t=(n,e)=>{const l=`${Y}${n}`;return r=>{e(Reflect.get(r.target,l))}},at=(n,e)=>{const l=`${Y}${n}`;return r=>{const a=r.target,d=a.selectedIndex,o=a.options[d];e(Reflect.get(o,l))}};function N(...n){return t.html.div(t.attr.class("bc-group"),...n)}const ot=(n,e,l)=>t.Ensure(n,r=>t.OneOfType(r,{value:a=>{const d=t.computedOf(a,l)((o,h)=>e(o.value,h));return t.html.option(t.attr.selected(d),rt("value",a.$.value),a.$.label)},group:a=>t.html.optgroup(t.attr.label(a.$.group),t.ForEach(a.$.options,d=>ot(d,e,l))),break:()=>t.html.hr()})),st=n=>{const{value:e,onBlur:l,onChange:r,options:a,unselectedLabel:d,equality:o=(m,u)=>m===u,after:h}=n;let p;return v.InputContainer({...n,after:t.Fragment(v.InputIcon({icon:"ph:caret-down-bold",color:"neutral",size:"sm"}),h),input:t.html.select(t.WithElement(m=>{p=m;const u=new MutationObserver(g=>{const{removedNodes:I}=g[0];I.length>0&&(p.selectedIndex=0)});return u.observe(m,{childList:!0}),t.OnDispose(()=>u.disconnect())}),v.CommonInputAttributes(n),t.attr.class("bc-native-select bc-input"),t.Use(v.BeatUII18n,m=>t.html.option(t.attr.hidden("hidden"),t.coalesce(d,m.$.selectOne))),t.ForEach(a,m=>ot(m,o,e)),l!=null?t.on.blur(l):t.Empty,r!=null?t.on.change(at("value",m=>r(m))):t.Empty)},t.on.click(()=>{if(p?.focus(),typeof p?.showPicker=="function")try{p.showPicker()}catch{}}))};function it(n){const{controller:e,onChange:l,onBlur:r,...a}=n;return st({...a,value:e.signal,onChange:$.makeOnChangeHandler(e,l),onBlur:$.makeOnBlurHandler(e,r)})}function Ot(n){return $.InputWrapper({...n,content:it(n)})}function ut(n,e,l){const r=n.length.map(a=>a);return t.Fragment(t.Repeat(r,a=>{const d=n.item(a.index),o=[];return t.Fragment(t.OnDispose(()=>{o.forEach(h=>h())}),e({list:n,item:d,position:a,remove:()=>n.removeAt(a.index),move:h=>{switch(h){case"up":if(a.index===0)return;n.move(a.index,a.index-1);break;case"down":if(a.index===n.length.value-1)return;n.move(a.index,a.index+1);break;case"first":n.move(a.index,0);break;case"last":n.move(a.index,n.length.value-1)}},canMove:h=>{const p=(()=>{switch(h){case"up":return t.signal(a.index>0);case"down":return n.length.map(m=>a.index<m-1)}})();return o.push(()=>p.dispose()),p},cannotMove:h=>{const p=(()=>{switch(h){case"up":return t.signal(a.index===0);case"down":return n.length.map(m=>a.index===m-1)}})();return o.push(()=>p.dispose()),p}}))},l))}const K={9:{pattern:/^[0-9]$/},A:{pattern:/^[A-Za-z]$/,transform:n=>n.toUpperCase()},"*":{pattern:/^.$/}},Bt=n=>n instanceof RegExp;function ct(n,e,l){if(n==null)return[];const r=l?{...K,...e}:e??K,a=(o,h)=>{const p=r[h];p?o.push({type:"pattern",name:h,...p}):o.push({type:"literal",char:h})},d=[];if(typeof n=="string"){for(const o of n)a(d,o);return d}for(const o of n)if(typeof o=="string")if(o.length<=1)a(d,o);else for(const h of o)a(d,h);else Bt(o)?d.push({type:"pattern",pattern:o}):typeof o=="object"&&o&&d.push(o);return d}function St(n,e){return l=>{switch(n){case"digits":return/[0-9]/.test(l);case"letters":return/[A-Za-z]/.test(l);case"alphanumeric":return/[A-Za-z0-9]/.test(l);case"custom":return e?.(l)??!0;default:return!0}}}function tt(n,e,l,r,a,d){const o={raw:n,previousConformed:e,cursor:a??n.length,completed:!1},h=r.definitions??{},p=typeof l=="function"?l(n,o):l,m=ct(p,h,r.useDefaultDefinitions??!0),u=St(r.allowMode,r.allow),g=new Set;for(const V of m)V.type==="literal"&&g.add(V.char);if(r.prefix)for(const V of r.prefix)g.add(V);if(r.suffix)for(const V of r.suffix)g.add(V);const I=Array.from(n).filter(V=>u(V)&&!g.has(V));if(I.length===0)return{value:"",cursor:0,completed:!1};const c=[],b=[];let x=0,C=0,i=0,f=-1;for(const V of m){if(V.type==="literal"){c.push(V.char),b.push({kind:"literal",filled:!0});continue}C+=V.optional?0:1;const U=I[x];if(U==null)break;if(V.type==="any"){i++,c.push(V.transform?V.transform(U):U),b.push({kind:"slot",filled:!0}),f=b.length-1,x++;continue}if(V.type==="pattern")if(V.pattern.test(U)){i++;const S=V.transform?V.transform(U):U;c.push(S),b.push({kind:"slot",filled:!0}),f=b.length-1,x++}else{x++;continue}}const _=c.join(""),k=(r.prefix??"")+_+(r.suffix??"");let w=(r.prefix??"").length;if(f>=0){let V=f+1;if((d?.policy??"smart")!=="sticky")for(;V<b.length&&b[V].kind==="literal";)V++;w+=V}const s=r.completion?.mode==="min"?(r.completion.minChars??0)<=i:r.completion?.mode==="custom"?!!r.completion.isComplete?.(k):C>0&&i>=C,y=r.pipe?.(k,{...o,completed:s});let E,D=w;return y===!1?(E=e,D=e.length):typeof y=="string"?(E=y,D=y.length):typeof y=="object"&&y?(E=y.value,D=y.cursor??y.value.length):E=k,{value:E,cursor:D,completed:s}}function Tt(n,e){const l=e?.strategy??"none";return l==="custom"&&e?.unmask?e.unmask(n):l==="strip"?n.replace(/[^A-Za-z0-9]/g,""):n}const G=n=>{const{value:e,onBlur:l,onChange:r,onInput:a,onAccept:d,onComplete:o,mask:h,definitions:p,useDefaultDefinitions:m,extraLiterals:u,prefix:g,suffix:I,autofix:c,pipe:b,completion:x,unmask:C,allowMode:i,allow:f,placeholder:_,placeholderOptions:k}=n,O=t.computedOf(e,h,p,m,u,g,I,c,x,C,i,_,k)((s,y,E,D,V,U,S,M,L,z,A,W,T)=>y?tt(s??"","",y,{definitions:E??{},useDefaultDefinitions:D??!0,extraLiterals:V??[],autofix:M??"none",completion:L??{mode:"mask"},pipe:b??(B=>B),unmask:z??{strategy:"none"},allowMode:A??"all",allow:f,prefix:U,suffix:S}).value:s??""),w=(s,y)=>{const E=s.value??"",D=t.Value.get(e)??"",V=h!=null?t.Value.get(h):null,U=p!=null?t.Value.get(p):void 0,S=m!=null?t.Value.get(m):void 0,M=u!=null?t.Value.get(u):void 0,L=c!=null?t.Value.get(c):void 0,z=x!=null?t.Value.get(x):void 0,A=C!=null?t.Value.get(C):void 0,W=i!=null?t.Value.get(i):void 0,T=g!=null?t.Value.get(g):void 0,B=I!=null?t.Value.get(I):void 0,{value:F,cursor:Z,completed:X}=V?tt(E,D,V,{definitions:U??{},useDefaultDefinitions:S??!0,extraLiterals:M??[],autofix:L??"none",completion:z??{mode:"mask"},pipe:b??(ht=>ht),unmask:A??{strategy:"none"},allowMode:W??"all",allow:f,prefix:T,suffix:B},s.selectionStart??E.length,n.cursor?t.Value.get(n.cursor):void 0):{value:E,cursor:E.length,completed:!0};if(F!==E){s.value=F;try{s.setSelectionRange(Z,Z)}catch{}}const Q=Tt(F,A);d?.({raw:Q,conformed:F,completed:X,cursor:Z}),y==="input"?a?.(F):(r?.(F),X&&o?.({raw:Q,conformed:F}))};return t.Fragment(v.InputContainer({...n,input:t.input.text(v.CommonInputAttributes(n),t.attr.value(O),t.attr.class("bc-input"),l!=null?t.on.blur(l):t.Empty,t.WithElement(s=>s instanceof HTMLInputElement?t.Fragment(t.on.input(()=>w(s,"input")),t.on.change(()=>w(s,"change")),t.on.keydown(y=>{if(y.key!=="Backspace"||!(n.cursor?t.Value.get(n.cursor)?.backspaceRubberBand??!0:!0))return;const D=s.selectionStart??0,V=s.selectionEnd??D;if(D!==V||D<=0)return;const U=s.value??"",S=h!=null?t.Value.get(h):null;if(!S)return;const M=p!=null?t.Value.get(p):void 0,L=m!=null?t.Value.get(m):!0,z=g!=null?t.Value.get(g):void 0,A=I!=null?t.Value.get(I):void 0,W=ct(typeof S=="function"?S(U,{raw:U,previousConformed:U,cursor:D,completed:!1}):S,M??{},L??!0),T=new Set;for(const B of W)B.type==="literal"&&T.add(B.char);if(z)for(const B of z)T.add(B);if(A)for(const B of A)T.add(B);if(T.has(U[D-1])){let B=D-1;for(;B>=0&&T.has(U[B]);)B--;B>=0&&(y.preventDefault(),y.stopPropagation(),s.value=U.slice(0,B)+U.slice(B+1),w(s,"input"))}})):t.Empty))}))};function J(n,e,l){const r=t.Value.map(n,d=>d!=null),a=v.defaultMessages.clearValue;return t.Fragment(t.When(r,()=>t.html.button(t.attr.type("button"),t.attr.class("bc-input-container__reset"),t.aria.label(a),t.attr.title(a),t.attr.disabled(e??!1),v.Icon({icon:"mdi:close",size:"sm"}),t.on.click(d=>{d.stopPropagation(),l?.(null)}))))}const At=n=>{const{value:e,onBlur:l,onChange:r,onInput:a,rows:d}=n;return v.InputContainer({baseContainer:!0,...n,input:t.html.textarea(t.attr.class(t.computedOf(n.size??"md")(o=>v.generateInputContainerInputClasses(!1,o??"md"))),v.CommonInputAttributes(n),t.attr.rows(d??3),t.attr.value(e),t.attr.class("bc-input"),l!=null?t.on.blur(t.emitValue(l)):t.Empty,r!=null?t.on.change(t.emitValue(r)):t.Empty,a!=null?t.on.input(t.emitValue(a)):t.Empty)})},Ft=n=>{const{value:e,step:l,min:r,max:a,onBlur:d,onChange:o,onInput:h,after:p}=n,m=I=>{const c=r!=null?t.Value.get(r):void 0,b=a!=null?t.Value.get(a):void 0;return c!=null&&I<c?c:b!=null&&I>b?b:I},u=l!=null?t.Use(v.BeatUII18n,I=>{const c=t.computedOf(e,r)((i,f)=>f==null?!0:(i??0)>f),b=t.computedOf(e,a)((i,f)=>f==null?!0:(i??0)<f),x=i=>{const f=t.Value.get(e)??0,_=t.Value.get(l),k=i?.shiftKey?10:1,O=f-_*k,w=r!=null?t.Value.get(r):void 0;if(w!=null&&O<w)return;const s=m(O);s!==f&&o&&o(s)},C=i=>{const f=t.Value.get(e)??0,_=t.Value.get(l),k=i?.shiftKey?10:1,O=f+_*k,w=a!=null?t.Value.get(a):void 0;if(w!=null&&O>w)return;const s=m(O);s!==f&&o&&o(s)};return $.Stack(t.attr.class("bc-number-input-steppers"),t.html.button(t.attr.type("button"),t.attr.class("bc-button bc-number-input-steppers-button bc-number-input-steppers-button--increment"),t.attr.disabled(t.computedOf(b,n.disabled??!1)((i,f)=>!i||f)),t.on.click(i=>C(i)),t.aria.label(I.$.incrementValue),v.Icon({icon:"line-md:plus",size:"xs"})),t.html.button(t.attr.type("button"),t.attr.class("bc-button bc-number-input-steppers-button bc-number-input-steppers-button--decrement"),t.attr.disabled(t.computedOf(c,n.disabled??!1)((i,f)=>!i||f)),t.on.click(i=>x(i)),t.aria.label(I.$.decrementValue),v.Icon({icon:"line-md:minus",size:"xs"})))}):null,g=p!=null&&u!=null?t.Fragment(u,p):p??u;return v.InputContainer({...n,input:t.input.number(r!=null?t.attr.min(r):t.Empty,a!=null?t.attr.max(a):t.Empty,v.CommonInputAttributes(n),t.attr.valueAsNumber(e),t.attr.step(l),t.attr.class("bc-input bc-number-input"),d!=null?t.on.blur(t.emitValue(d)):t.Empty,o!=null?t.on.change(t.emitValueAsNumber(o)):t.Empty,h!=null?t.on.input(t.emitValueAsNumber(h)):t.Empty,l!=null?t.on.wheel(I=>{I.preventDefault();const c=t.Value.get(e)??0,b=t.Value.get(l),x=I.shiftKey?10:1,C=I.deltaY<0?b*x:-b*x,i=m(c+C);i!==c&&o&&o(i)}):t.Empty),after:g})},et=n=>{if(n==null||n==="")return null;const e=Number(n);return Number.isNaN(e)?null:e},zt=n=>{const{value:e,step:l,min:r,max:a,onBlur:d,onChange:o,onInput:h,after:p}=n,m=c=>{const b=r!=null?t.Value.get(r):void 0,x=a!=null?t.Value.get(a):void 0;return b!=null&&c<b?b:x!=null&&c>x?x:c},u=(()=>{if(l==null)return null;const c=t.computedOf(e,r)((f,_)=>{const k=f??0;return _==null?!0:k>_}),b=t.computedOf(e,a)((f,_)=>{const k=f??0;return _==null?!0:k<_}),x=f=>{const _=t.Value.get(e)??0,k=t.Value.get(l),O=f?.shiftKey?10:1,w=_-k*O,s=r!=null?t.Value.get(r):void 0;if(s!=null&&w<s)return;const y=m(w);y!==_&&o&&o(y)},C=f=>{const _=t.Value.get(e)??0,k=t.Value.get(l),O=f?.shiftKey?10:1,w=_+k*O,s=a!=null?t.Value.get(a):void 0;if(s!=null&&w>s)return;const y=m(w);y!==_&&o&&o(y)};return((f,_)=>$.Stack(t.attr.class("bc-number-input-steppers"),t.html.button(t.attr.type("button"),t.attr.class("bc-button bc-number-input-steppers-button bc-number-input-steppers-button--increment"),t.attr.disabled(t.computedOf(b,n.disabled??!1)((k,O)=>!k||O)),t.on.click(k=>C(k)),t.aria.label(f),v.Icon({icon:"line-md:plus",size:"xs"})),t.html.button(t.attr.type("button"),t.attr.class("bc-button bc-number-input-steppers-button bc-number-input-steppers-button--decrement"),t.attr.disabled(t.computedOf(c,n.disabled??!1)((k,O)=>!k||O)),t.on.click(k=>x(k)),t.aria.label(_),v.Icon({icon:"line-md:minus",size:"xs"}))))(v.defaultMessages.incrementValue,v.defaultMessages.decrementValue)})(),g=J(e,n.disabled,o??h),I=p!=null&&u!=null?t.Fragment(u,g,p):p!=null?t.Fragment(g,p):u!=null?t.Fragment(u,g):g;return v.InputContainer({...n,input:t.input.number(r!=null?t.attr.min(r):t.Empty,a!=null?t.attr.max(a):t.Empty,v.CommonInputAttributes(n),t.attr.value(t.Value.map(e,c=>c==null?"":String(c))),t.attr.step(l),t.attr.class("bc-input bc-number-input"),d!=null?t.on.blur(t.emitValue(d)):t.Empty,o!=null?t.on.change(t.emitValue(c=>{const b=et(c);o(b)})):t.Empty,h!=null?t.on.input(t.emitValue(c=>{const b=et(c);h(b)})):t.Empty,l!=null?t.on.wheel(c=>{c.preventDefault();const b=t.Value.get(e)??0,x=t.Value.get(l),C=c.shiftKey?10:1,i=c.deltaY<0?x*C:-x*C,f=m(b+i);f!==b&&o&&o(f)}):t.Empty),after:I})},Mt=n=>{const e={type:"pattern",pattern:/[0-9A-Fa-f]/,transform:r=>r.toLowerCase()};return G({...n,mask:[e,e,e,e,e,e,e,e,"-",e,e,e,e,"-",e,e,e,e,"-",e,e,e,e,"-",e,e,e,e,e,e,e,e,e,e,e,e],placeholder:n.placeholder??"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"})};let H=null;async function j(){const n=globalThis;return n.Temporal?n.Temporal:(H||(H=Promise.resolve().then(()=>require("./index.esm-DJRz9AE-.cjs")).then(e=>{const l=e.Temporal;return n.Temporal||(n.Temporal=l),l})),H)}const pt=(n,e)=>e?t.Task(j,{then:n,pending:e.pending,error:e.error}):t.Task(j,n),Lt=/^P(\d+([YMWD]|$)){0,4}(T(\d+([HMS]|$)){0,3})?$/i,Nt=/^P(?:(\d+Y)?(\d+M)?(\d+W)?(\d+D)?)(T(\d+H)?(\d+M)?(\d+S)?)?$/i;function ft(n){return{mask:null,allowMode:"custom",allow:e=>/[0-9ptwdhms]/i.test(e),pipe:e=>{const l=e.toUpperCase();return l.length===0?l:!l.startsWith("P")||!Lt.test(l)?!1:l},completion:{mode:"custom",isComplete:e=>{const l=e.toUpperCase();if(!Nt.test(l))return!1;try{return n(l),!0}catch{return!1}}}}}const nt=(n,e)=>{if(n==null)return null;try{return n.Duration.from(e)}catch{return null}},Wt=n=>{const{value:e,onChange:l,onInput:r,after:a,disabled:d,onBlur:o}=n,h=()=>{const u=J(e,d,l??r);return a!=null?t.Fragment(u,a):u},p=n.placeholder!=null?t.Empty:t.attr.placeholder("P0DT0H0M0S");return pt(u=>G({...n,value:t.Value.map(e,g=>g?.toString()??""),onChange:l?g=>l(g===""?null:u.Duration.from(g)):void 0,onInput:void 0,...ft(u.Duration.from),placeholder:"P0DT0H0M0S",after:h()}),{pending:()=>{const u=g=>I=>{const b=I.currentTarget?.value??"";if(b===""){g(null);return}const x=globalThis.Temporal,C=nt(x,b);if(C!=null){g(C);return}j().then(i=>{const f=nt(i,b);f!=null&&g(f)}).catch(()=>{})};return v.InputContainer({...n,input:t.input.text(v.CommonInputAttributes(n),t.attr.value(t.Value.map(e,g=>g?.toString()??"")),t.attr.class("bc-input"),p,o!=null?t.on.blur(()=>o()):t.Empty,l!=null?t.on.change(u(l)):t.Empty,r!=null?t.on.input(u(r)):t.Empty),after:h()})}})},Rt=n=>{const{value:e,onBlur:l,onChange:r,onInput:a}=n;return v.InputContainer({...n,input:t.input.url(v.CommonInputAttributes(n),t.attr.value(e),t.attr.class("bc-input"),l!=null?t.on.blur(t.emitValue(l)):t.Empty,r!=null?t.on.change(t.emitValue(r)):t.Empty,a!=null?t.on.input(t.emitValue(a)):t.Empty)})},mt=n=>{const{controller:e,element:l,separator:r,showMove:a=!0,showRemove:d=!0,showAdd:o=!0,createItem:h,addLabel:p,controlsLayout:m="aside",removeDisabled:u,addDisabled:g}=n,I=t.Value.toSignal(m).map(x=>x==="aside"),c=x=>{const C=t.When(a??!1,()=>t.html.div(t.attr.class("bc-group--align-center"),t.attr.class(I.map(f=>f?"bc-group--direction-column bc-group--gap-1":"bc-group--direction-row bc-group--gap-1")),v.Button({size:"xs",roundedness:"full",variant:"text",onClick:()=>x.move("up"),disabled:x.cannotMove("up")},t.Use(v.BeatUII18n,f=>v.Icon({size:"xs",icon:"line-md:arrow-up",title:f.$.incrementValue}))),v.Button({size:"xs",roundedness:"full",variant:"text",onClick:()=>x.move("down"),disabled:x.cannotMove("down")},t.Use(v.BeatUII18n,f=>v.Icon({size:"xs",icon:"line-md:arrow-down",title:f.$.decrementValue}))))),i=t.When(d,()=>t.Use(v.BeatUII18n,f=>$.CloseButton({size:"xs",label:t.Value.map(f.$.removeItem,_=>_.toLowerCase()),color:"danger",disabled:u,onClick:x.remove})));return f=>t.When(I,()=>N(t.attr.class("bc-group--gap-1 bc-group--align-center"),$.Stack(t.attr.class("bc-stack--grow"),f),$.Stack(t.attr.class("bc-stack--align-center"),t.When(e.signal.map(_=>_.length>1),()=>C),i)),()=>$.Stack(t.attr.class("bc-stack--gap-2"),f,N(t.attr.class("bc-group--gap-2 bc-group--justify-between"),t.When(e.signal.map(_=>_.length>1),()=>C,()=>t.html.div()),i)))},b=t.When(t.computedOf(o,h)((x,C)=>x&&C!=null),()=>N(t.attr.class("bc-group--gap-2 bc-group--align-center bc-group--justify-center"),v.Button({size:"sm",variant:"filled",onClick:()=>e.push(h()),disabled:t.computedOf(e.disabled,g??!1)((x,C)=>x||C)},t.Use(v.BeatUII18n,x=>N(t.attr.class("bc-group--gap-2"),v.Icon({icon:"line-md:plus"}),p??x.$.addLabel)))));return t.Fragment(ut(e,x=>c(x)(l(x)),r),b)},Pt=(n,...e)=>{const{controller:l,element:r,separator:a,showMove:d,showRemove:o,showAdd:h,createItem:p,addLabel:m,controlsLayout:u,removeDisabled:g,addDisabled:I,...c}=n;return $.InputWrapper({...c,content:mt({controller:l,element:r,separator:a,showMove:d,showRemove:o,showAdd:h,createItem:p,addLabel:m,controlsLayout:u,removeDisabled:g,addDisabled:I})},...e)};class jt extends $.Controller{branches;activeBranch;#e;#t=new Map;constructor(e,l,r,a,d,o,h=$.O){super(e,l,r,a,d,h),this.branches=o;const p=u=>{for(const g of o)if(g.detect(u))return g.key;return o[0]?.key??"unknown"};this.activeBranch=r.map(p,$.O);const m=u=>{if(this.#t.has(u))return this.#t.get(u);const g=o.find(c=>c.key===u);if(!g)throw new Error(`Unknown branch: ${u}`);const I=new $.Controller([...e,u],c=>{this.change(c)},this.signal.map(c=>g.detect(c)?c:g.defaultValue(),h),a.map($.makeMapValidation([u])),{disabled:this.disabled,validationMode:this.parent.validationMode},h);return this.#t.set(u,I),I};this.#e=this.activeBranch.map(u=>m(u),$.O),this.onDispose(()=>{for(const u of this.#t.values())u.dispose();this.#t.clear(),this.activeBranch.dispose(),this.#e.dispose()})}get activeController(){return t.Value.get(this.#e)}getBranchController(e){const l=this.branches.find(a=>a.key===e);if(!l)throw new Error(`Unknown branch: ${e}`);if(this.#t.has(e))return this.#t.get(e);const r=new $.Controller([...this.path,e],a=>{this.change(a)},this.signal.map(a=>l.detect(a)?a:l.defaultValue(),$.O),this.status.map($.makeMapValidation([e])),{disabled:this.disabled,validationMode:this.parent.validationMode},$.O);return this.#t.set(e,r),r}switchToBranch(e,l=!1){const r=this.branches.find(o=>o.key===e);if(!r)throw new Error(`Unknown branch: ${e}`);const a=t.Value.get(this.signal);if(r.detect(a))return!0;if(r.convert){const o=r.convert(a);if(o.ok)return this.change(o.value),!0}if(l&&typeof window=="object"&&typeof window.confirm=="function"&&!window.confirm("Changing type will clear the current value. Continue?"))return!1;const d=r.defaultValue();return this.change(d),!0}get activeBranchDefinition(){const e=t.Value.get(this.activeBranch);return this.branches.find(l=>l.key===e)}}function Zt(n){return n.transform(e=>e??null,e=>e??void 0)}function qt(n){return n.transform(e=>e??"",e=>e===""?void 0:e)}function Ht(n){return n.transform(e=>e??void 0,e=>e??null)}function R(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)&&Object.prototype.toString.call(n)==="[object Object]"}function dt(n,e){if(e==null)return lt(n);if(n==null)return e;if(R(n)&&R(e)){const l={...e};for(const r of Object.keys(n))l[r]===void 0?l[r]=lt(n[r]):R(n[r])&&R(l[r])&&(l[r]=dt(n[r],l[r]));return l}return e}function lt(n){return typeof structuredClone=="function"?structuredClone(n):JSON.parse(JSON.stringify(n))}exports.$t=wt;exports.BaseListControl=mt;exports.BaseNativeSelectControl=it;exports.Expando=rt;exports.FilesInput=Ut;exports.Group=N;exports.ListControl=Pt;exports.ListInput=ut;exports.MaskInput=G;exports.NativeSelect=st;exports.NativeSelectControl=Ot;exports.NullableDurationInput=Wt;exports.NullableNumberInput=zt;exports.NullableResetAfter=J;exports.NumberInput=Ft;exports.SegmentedInput=kt;exports.TextArea=At;exports.UUIDInput=Mt;exports.UnionController=jt;exports.UnstyledDropZone=P;exports.UrlInput=Rt;exports.WithTemporal=pt;exports._t=Vt;exports.deepMergeDefaults=dt;exports.durationMaskConfig=ft;exports.emitExpando=$t;exports.emitOptionExpando=at;exports.ensureTemporal=j;exports.gt=yt;exports.transformEmptyStringToUndefined=qt;exports.transformNullToUndefined=Zt;exports.transformUndefinedToNull=Ht;
@@ -1,2 +0,0 @@
1
- "use strict";const r=require("@tempots/dom"),T=require("./translations-hMQlZmD4.cjs"),P=new Map;function I(e){const t=P.get(e)??0;return P.set(e,t+1),`${e}-${t}`}const f={notAsked:{type:"NotAsked"},loading(e=void 0){return{type:"Loading",previousValue:e}},success(e){return{type:"AsyncSuccess",value:e}},failure(e){return{type:"AsyncFailure",error:e}},isSuccess(e){return e.type==="AsyncSuccess"},isFailure(e){return e.type==="AsyncFailure"},isNotAsked(e){return e.type==="NotAsked"},isLoading(e){return e.type==="Loading"},getOrElse(e,t){return f.isSuccess(e)?e.value:t},getOrElseLazy(e,t){return f.isSuccess(e)?e.value:t()},getOrNull(e){return f.isSuccess(e)?e.value:null},getOrUndefined(e){return f.isSuccess(e)?e.value:void 0},getUnsafe:e=>{if(f.isSuccess(e))return e.value;throw f.isFailure(e)?e.error:new Error("Cannot get value from a not-asked or loading result")},match:(e,{success:t,failure:s,loading:n,notAsked:a=n})=>f.isSuccess(e)?t(e.value):f.isFailure(e)?s(e.error):f.isNotAsked(e)?a():n(e.previousValue),whenSuccess:(e,t)=>(f.isSuccess(e)&&t(e.value),e),whenFailure:(e,t)=>(f.isFailure(e)&&t(e.error),e),equals:(e,t,s={valueEquals:(n,a)=>n===a,errorEquals:(n,a)=>n===a})=>e.type==="AsyncSuccess"&&t.type==="AsyncSuccess"?s.valueEquals(e.value,t.value):e.type==="AsyncFailure"&&t.type==="AsyncFailure"?s.errorEquals(e.error,t.error):e.type==="Loading"&&t.type==="Loading"?s.valueEquals(e.previousValue,t.previousValue):e.type==="NotAsked"&&t.type==="NotAsked",all:e=>{const t=[];for(const s of e)if(f.isSuccess(s))t.push(s.value);else return s;return f.success(t)},ofPromise:async e=>{try{const t=await e;return f.success(t)}catch(t){return f.failure(t instanceof Error?t:new Error(String(t)))}}},E=(e,t)=>e===t||e!==e&&t!==t,b={valid:{type:"valid"},invalid(e){return{type:"invalid",error:e}},isValid(e){return e.type==="valid"},isInvalid(e){return e.type==="invalid"},match:(e,t,s)=>b.isValid(e)?t():s(e.error),toResult:(e,t)=>b.match(e,()=>d.success(t),s=>d.failure(s)),whenValid:(e,t)=>(b.isValid(e)&&t(),e),whenInvalid:(e,t)=>(b.isInvalid(e)&&t(e.error),e)},d={success(e){return{type:"Success",value:e}},failure(e){return{type:"Failure",error:e}},map:(e,t)=>e.type==="Success"?d.success(t(e.value)):e,flatMap:(e,t)=>e.type==="Success"?t(e.value):e,toAsync(e){return d.match(e,t=>f.success(t),t=>f.failure(t))},toValidation(e){return d.match(e,()=>b.valid,t=>b.invalid(t))},isSuccess(e){return e.type==="Success"},isFailure(e){return e.type==="Failure"},getOrElse(e,t){return d.isSuccess(e)?e.value:t},getOrElseLazy(e,t){return d.isSuccess(e)?e.value:t()},getOrNull(e){return d.isSuccess(e)?e.value:null},getOrUndefined(e){return d.isSuccess(e)?e.value:void 0},getUnsafe:e=>{if(d.isSuccess(e))return e.value;throw e.error},match:(e,t,s)=>d.isSuccess(e)?t(e.value):s(e.error),whenSuccess:(e,t)=>(d.isSuccess(e)&&t(e.value),e),whenFailure:(e,t)=>(d.isFailure(e)&&t(e.error),e),combine:(e,t,s,n)=>d.match(e,a=>d.match(t,i=>d.success(s(a,i)),i=>d.failure(i)),a=>d.match(t,i=>d.failure(a),i=>d.failure(n(a,i)))),equals:(e,t,s={valueEquals:(n,a)=>n===a,errorEquals:(n,a)=>n===a})=>e.type==="Success"&&t.type==="Success"?s.valueEquals(e.value,t.value):e.type==="Failure"&&t.type==="Failure"?s.errorEquals(e.error,t.error):!1,all:e=>{const t=[];for(const s of e)if(d.isSuccess(s))t.push(s.value);else return s;return d.success(t)}};function Z({size:e="sm",icon:t="line-md:close",disabled:s,roundedness:n="full",color:a="base",onClick:i,label:o},...l){return r.Use(T.BeatUII18n,c=>{const p=r.coalesce(o,c.$.closeModal);return T.Button({variant:"text",size:e,roundedness:n,disabled:s,color:a,onClick:i},r.attr.title(p),r.aria.label(p),...l,T.Icon({icon:t,size:e??"sm"}))})}function O(e){return`bc-label bc-label--${e}`}const ee=(...e)=>r.html.span(r.attr.class(O("emphasis")),...e),$=(...e)=>r.html.span(r.attr.class(O("default")),...e),q=(...e)=>r.html.span(r.attr.class(O("muted")),...e),te=(...e)=>r.html.span(r.attr.class(O("danger")),...e),se=e=>{const{value:t,onBlur:s,onChange:n,placeholder:a,disabled:i,id:o,checkedIcon:l,uncheckedIcon:c,iconSize:p="lg"}=e,u=o??I("checkbox"),m=`${u}-label`,v=()=>{if(r.Value.get(i??!1))return;const h=r.Value.get(t);n?.(!h)},k=h=>{r.Value.get(i??!1)||(h.key===" "||h.key==="Enter")&&(h.preventDefault(),v())};return T.InputContainer({baseContainer:!0,growInput:!1,...e,input:r.html.span(r.attr.class("bc-checkbox-input"),r.html.span(r.attr.class("bc-checkbox-input__checkbox"),r.attr.class(r.Value.map(t,h=>h?"bc-checkbox-input__checkbox--checked":"bc-checkbox-input__checkbox--unchecked")),r.attr.class(r.Value.map(i??!1,h=>h?"bc-checkbox-input__checkbox--disabled":"")),r.attr.id(u),r.attr.role("checkbox"),r.attr.tabindex(r.Value.map(i??!1,h=>h?-1:0)),r.aria.checked(t),r.aria.disabled(i),a!=null?r.aria.labelledby(m):r.Empty,r.on.keydown(k),s!=null?r.on.blur(s):r.Empty,T.Icon({icon:r.computedOf(t,l,c)((h,g,w)=>h?g??"akar-icons/check-box-fill":w??"akar-icons/box"),accessibility:"decorative",size:p})),a!=null?r.html.label(r.attr.class("bc-checkbox-input__label"),r.attr.id(m),r.attr.for(u),q(a)):r.Empty)},r.on.click(v))},j=r.html.span(r.attr.class("bc-input-wrapper__required")," *");function re(e){const t=["bc-input-wrapper"];return e!=="vertical"&&t.push(`bc-input-wrapper--${e}`),t.join(" ")}function ne(e,t){const s=["bc-input-wrapper__label-text"];return e?s.push("bc-input-wrapper__label-text--error"):t?s.push("bc-input-wrapper__label-text--disabled"):s.push("bc-input-wrapper__label-text--default"),s.join(" ")}function ae(e,t){if(e==="horizontal-fixed"&&t!=null)return`--input-wrapper-label-width: ${t}`}const L=({fullWidth:e=!1,required:t,label:s,labelChildren:n,context:a,description:i,content:o,error:l,labelFor:c,hasError:p,disabled:u,layout:m,labelWidth:v},...k)=>{const h=p??l!=null,g=u??!1,w=m??"vertical",D=I("input-wrapper"),A=i?`${D}-description`:void 0,_=l!=null?`${D}-error`:void 0,N=r.computedOf(w)(y=>y!=="vertical"),Y=r.computedOf(w,v??void 0)((y,C)=>ae(y,C));return r.html.div(r.attr.class(r.Value.map(w,y=>re(y))),r.attr.class(r.Value.map(e,y=>y?"bc-input-wrapper--full-width":"")),r.attr.style(Y),s!=null||a!=null?r.html.div(r.attr.class("bc-input-wrapper__header"),r.html.div(r.attr.class("bc-input-wrapper__label-section"),r.html.label(r.attr.class("bc-input-wrapper__label"),c!=null?r.attr.for(c):r.Empty,r.html.span(r.attr.class(r.computedOf(h,g)((y,C)=>ne(y??!1,C??!1))),s),s!=null&&t?j:r.Empty),r.When(r.computedOf(N,i)((y,C)=>y&&C!=null),()=>r.html.div(r.attr.class("bc-input-wrapper__description bc-input-wrapper__description--under-label"),r.attr.id(A),i))),a!=null?$(a):r.Empty,n):r.Empty,r.html.div(r.attr.class("bc-input-wrapper__content"),[A,_].filter(Boolean).length>0?r.dataAttr.describedby([A,_].filter(Boolean).join(" ")):r.Empty,t?r.dataAttr.required("true"):r.Empty,r.When(h,()=>r.dataAttr.invalid("true")),o),r.When(r.computedOf(N,i)((y,C)=>!y&&C!=null),()=>r.html.div(r.attr.class("bc-input-wrapper__description"),r.attr.id(A),i)),r.When(h,()=>r.html.div(r.attr.class("bc-input-wrapper__error"),r.attr.id(_),r.aria.live("polite"),r.attr.role("alert"),l)),...k)};function ie(...e){return r.html.div(r.attr.class("bc-stack"),...e)}const H=(e,t)=>()=>{e.markTouched(),t?.()},M=(e,t)=>s=>{e.change(s),t?.(s)};function x(e,t){const{controller:s,onBlur:n,onChange:a,id:i,triggerOn:o,...l}=t;return e({id:i??s.name,disabled:s.disabled,value:s.signal,hasError:s.errorVisible,name:s.name,...l,onInput:o==="input"?M(s,a):void 0,onChange:o!=="input"?M(s,a):void 0,onBlur:H(s,n)})}function le(e,{id:t,labelFor:s,...n},...a){const i=t??n.controller.name??I("control"),o=s??i;return L({...n,hasError:n.controller.errorVisible,error:r.TextNode(n.controller.error.map(l=>l??"")),labelFor:o,content:x(l=>e({...l,id:i}),n)},...a)}function W(e,t){const{toInput:s,fromInput:n,controller:a,...i}=t,o=a.transform(s,n);return x(e,{...i,controller:o})}function oe(e,{id:t,labelFor:s,...n},...a){const i=t??n.controller.name??I("control");return L({...n,labelFor:s??i,content:W(e,{...n,id:i})},...a)}function ce(e){return e.split(".").map(s=>{const n=s.match(/^\[(\d+)\]$/);return n?Number(n[1]):s})}function z(e){return typeof e=="number"?`[${e}]`:`.${e}`}function U(e){if(e.length===0)return"";const[t,...s]=e;return[typeof t=="number"?`[${t}]`:t,...s.map(z)].join("")}function V(e){return function(s){if(s.type==="valid")return s;let n=s.error;for(const a of e)if(n=n?.dependencies?.[a],n==null)return b.valid;return b.invalid(n)}}class S{path;change;signal;status;error;hasError;touched;errorVisible;dirty;dependencyErrors;#e={disabled:r.prop(!1),touched:r.prop(!1)};#s;#t=r.prop(void 0);parent;disabled;#r=[];disabledOrHasErrors;constructor(t,s,n,a,i,o=E){this.path=t,this.change=s,this.signal=n,this.status=a,this.#s=o,this.#t.set(n.value),this.error=a.map(l=>l?.type==="invalid"?l.error?.message:void 0),this.hasError=this.error.map(l=>l!=null),this.touched=this.#e.touched,i.validationMode?this.errorVisible=r.computedOf(this.hasError,this.touched,i.validationMode)((l,c,p)=>p==="eager"?!!l:!!l&&!!c):this.errorVisible=r.computedOf(this.hasError,this.touched)((l,c)=>!!l&&!!c),this.dirty=r.computedOf(this.signal,this.#t)((l,c)=>!this.#s(l,c)),this.dependencyErrors=a.map(l=>l?.type==="invalid"?l.error?.dependencies:void 0),this.parent=i,this.disabled=r.computedOf(this.#e.disabled,i.disabled)((l,c)=>l||c),this.disabledOrHasErrors=r.computedOf(this.disabled,this.hasError)((l,c)=>l||c),this.onDispose(()=>{this.#e.disabled.dispose(),this.#e.touched.dispose(),this.disabled.dispose(),this.error.dispose(),this.errorVisible.dispose(),this.dirty.dispose(),this.#t.dispose(),this.dependencyErrors.dispose(),this.disabledOrHasErrors.dispose()})}get name(){return U(this.path)}onDispose=t=>{this.#r.push(t)};dispose=()=>{for(const t of this.#r)try{t()}catch(s){console.error("Error in dispose callback:",s)}this.#r.length=0};setDisabled=t=>{this.#e.disabled.set(t)};disable=()=>this.setDisabled(!0);enable=()=>this.setDisabled(!1);markTouched=()=>{this.#e.touched.set(!0)};resetTouched=()=>{this.#e.touched.set(!1)};markPristine=()=>{this.#t.set(this.signal.value)};reset=()=>{this.change(this.#t.value)};array=(t=E)=>new K(this.path,this.change,this.signal,this.status,this.parent,t);object=(t=E)=>new R(this.path,this.change,this.signal,this.status,this.parent,t);transform=(t,s,n=[],a=E)=>new S([...this.path,...n],i=>this.change(s(i)),this.signal.map(t,a),this.status.map(V(n)),this.parent,a);asyncTransform=(t,s,n,a=[],i=E)=>new S([...this.path,...a],o=>{s(o).then(l=>this.change(l))},this.signal.mapAsync(t,n,void 0,i),this.status.map(V(a)),this.parent,i)}class R extends S{#e=new Map;#s=new Map;#t=new Map;#r=r.prop(!1);touchedDeep=this.#r;#a=new Map;#n=new Map;#l=r.prop(!1);dirtyDeep=this.#l;#c;#u;#o=()=>{let t=!1;for(const s of this.#s.values())if(s){t=!0;break}this.#r.set(this.touched.value||t)};constructor(t,s,n,a,i,o){super(t,s,n.map(c=>c??{},o),a,i,o),this.#c=this.touched.on(()=>{this.#o()}),this.#u=this.dirty.on(()=>{this.#i()});const l=this.signal.on(()=>this.#i());this.onDispose(()=>{for(const c of this.#e.values())c.dispose();this.#e.clear();for(const c of this.#t.values())c();this.#t.clear(),this.#s.clear(),this.#r.dispose();for(const c of this.#n.values())c();this.#n.clear(),this.#a.clear(),this.#l.dispose(),this.#c(),this.#u(),l()})}field=t=>{if(this.#e.has(t))return this.#e.get(t);const s=async o=>{this.change({...this.signal.value,[t]:o})},n=new S([...this.path,t],s,this.signal.map(o=>o[t]),this.status.map(V([t])),{disabled:this.disabled,validationMode:this.parent.validationMode});this.#e.set(t,n);const a=n.touched.on(o=>{this.#s.set(t,o),this.#o()});this.#t.set(t,a);const i=n.dirty.on(o=>{this.#a.set(t,o),this.#i()});return this.#n.set(t,i),n};markAllTouched=()=>{this.markTouched();const t=this.signal.value;for(const s of Object.keys(t))this.field(s).markTouched();for(const s of this.#e.values())s.markTouched()};markAllPristine=()=>{this.markPristine();const t=this.signal.value;for(const s of Object.keys(t))this.field(s).markPristine?.();for(const s of this.#e.values())s.markPristine?.()};#i=()=>{let t=!1;for(const s of this.#a.values())if(s){t=!0;break}this.#l.set(this.dirty.value||t)}}class K extends S{#e=new Array;length;#s=new Map;#t=new Map;#r=r.prop(!1);touchedDeep=this.#r;#a=new Map;#n=new Map;#l=r.prop(!1);dirtyDeep=this.#l;#c;#u;#o=()=>{let t=!1;for(const s of this.#s.values())if(s){t=!0;break}this.#r.set(this.touched.value||t)};constructor(t,s,n,a,i,o){const l=n.map(u=>u??[],o);super(t,s,l,a,i,o);const c=l.on(u=>{const m=this.#e.length-u.length;m>0&&(this.#e.splice(u.length,m).forEach((v,k)=>{const h=u.length+k;v.dispose(),this.#t.get(h)?.(),this.#t.delete(h),this.#s.delete(h),this.#n.get(h)?.(),this.#n.delete(h),this.#a.delete(h)}),this.#o(),this.#i())});this.length=l.map(u=>u.length),this.#c=this.touched.on(()=>{this.#o()}),this.#u=this.dirty.on(()=>{this.#i()});const p=this.signal.on(()=>this.#i());this.onDispose(()=>{for(const u of this.#e)u.dispose();this.length.dispose(),this.#e.length=0,c(),l.dispose();for(const u of this.#t.values())u();this.#t.clear(),this.#s.clear(),this.#r.dispose();for(const u of this.#n.values())u();this.#n.clear(),this.#a.clear(),this.#l.dispose(),this.#c(),this.#u(),p()})}item=t=>{if(this.#e[t])return this.#e[t];const s=async o=>{const l=this.signal.value.slice();l[t]=o,this.change(l)},n=new S([...this.path,t],s,this.signal.map(o=>o[t]),this.status.map(V([t])),{disabled:this.disabled,validationMode:this.parent.validationMode});this.#e[t]=n;const a=n.touched.on(o=>{this.#s.set(t,o),this.#o()});this.#t.set(t,a);const i=n.dirty.on(o=>{this.#a.set(t,o),this.#i()});return this.#n.set(t,i),n};push=(...t)=>{this.change([...this.signal.value,...t])};pop=()=>{this.splice(this.signal.value.length-1,1)};shift=()=>{this.splice(0,1)};unshift=(...t)=>{this.change([...t,...this.signal.value])};removeAt=t=>{this.splice(t,1)};splice=(t,s)=>{const n=this.signal.value.slice();n.splice(t,s),this.change(n)};move=(t,s,n=1)=>{if(n<1||t===s)return;const a=this.signal.value.slice(),i=a.splice(t,n);a.splice(s,0,...i),this.change(a)};markAllTouched=()=>{this.markTouched();const t=this.signal.value.length;for(let s=0;s<t;s++)this.item(s).markTouched()};markAllPristine=()=>{this.markPristine();const t=this.signal.value.length;for(let s=0;s<t;s++)this.item(s).markPristine?.()};#i=()=>{let t=!1;for(const s of this.#a.values())if(s){t=!0;break}this.#l.set(this.dirty.value||t)}}function G(e){function t(s){return typeof s=="number"?s:s.toString()}return e.map(s=>typeof s=="object"&&s.key!=null?t(s.key):t(s))}function J(e){const t=e.filter(a=>a.path==null||a.path.length===0).map(a=>a.message),s=e.filter(a=>a.path!=null&&a.path.length>0).reduce((a,i)=>{const o=G(i.path),l=o.pop();let c=a;for(const p of o)c.dependencies==null&&(c.dependencies={}),c.dependencies[p]==null&&(c.dependencies[p]={}),c=c.dependencies[p];return c.dependencies==null&&(c.dependencies={}),c.dependencies[l]={message:i.message},a},{}),n=t.join(`
2
- `);return{...s,message:n!=""?n:void 0}}function Q({initialValue:e,onChange:t,validate:s,equals:n,validationMode:a,validateDebounceMs:i}){const o=r.Value.deriveProp(e),l=r.prop(b.valid),c=r.prop(!1),p=r.prop(a??"onTouched"),u=g=>{l.set(g)};let m;const v=async g=>{if(s!=null){const w=await s(g);u(w)}},k=async g=>{o.set(g),t?.(g);const w=p.value;if(s!=null){if(w==="onSubmit")return;const D=i??0;D>0?(m&&clearTimeout(m),m=setTimeout(()=>{v(g)},D)):await v(g)}},h=new S([],k,o,l,{disabled:c,validationMode:p},n??E);return h.onDispose(()=>{c.dispose(),o.dispose(),l.dispose(),p.dispose(),m&&clearTimeout(m)}),{controller:h,setStatus:u}}function B(e){return r.Fragment(r.attr.disabled(e.disabled),r.attr.name(e.name))}function ue(e,{triggerOn:t="change"}={}){return r.Fragment(B(e),r.attr.value(e.signal),(t==="input"?r.on.input:r.on.change)(r.emitValue(e.change)))}function he(e,{triggerOn:t="change"}={}){return r.Fragment(B(e),r.attr.valueAsNumber(e.signal),(t==="input"?r.on.input:r.on.change)(r.emitValueAsNumber(e.change)))}function F(e){return e.issues!=null?b.invalid(J(e.issues)):b.valid}async function de({task:e,errorMessage:t,errorPath:s=["root"],validation:n}){try{const a=await e();return n!=null?n(a):b.valid}catch(a){const i=t??(a instanceof Error?a.message:"Operation failed");return s.length===1&&s[0]==="root"?b.invalid({message:i}):b.invalid({dependencies:X(s,i)})}}function X(e,t){if(e.length===1)return{[e[0]]:{message:t}};const[s,...n]=e;return{[s]:{dependencies:X(n,t)}}}function pe({initialValue:e={},schema:t,onSubmit:s=async()=>b.valid,validationMode:n,validateDebounceMs:a}){const{controller:i,setStatus:o}=Q({initialValue:e,validationMode:n??"onTouched",validateDebounceMs:a,validate:(n??"onTouched")==="onSubmit"||t==null?void 0:async u=>F(await t["~standard"].validate(u))}),l=r.prop(!1),c=i.object();return c.onDispose(l.dispose),{controller:c,setStatus:o,submit:async u=>{if(l.set(!0),u?.preventDefault(),c.markAllTouched(),t!=null){const v=c.signal.value,k=F(await t["~standard"].validate(v));if(o(k),k.type==="invalid"){l.set(!1);return}}const m=await s(c.signal.value);l.set(!1),m.type==="invalid"&&o(m)},submitting:l}}exports.ArrayController=K;exports.BaseControl=x;exports.BaseMappedControl=W;exports.CheckboxInput=se;exports.CloseButton=Z;exports.Control=le;exports.Controller=S;exports.DangerLabel=te;exports.EmphasisLabel=ee;exports.InputWrapper=L;exports.Label=$;exports.MappedControl=oe;exports.MutedLabel=q;exports.O=E;exports.ObjectController=R;exports.RequiredSymbol=j;exports.Stack=ie;exports.a=b;exports.connectCommonAttributes=B;exports.connectNumberInput=he;exports.connectStringInput=ue;exports.convertStandardSchemaIssues=J;exports.convertStandardSchemaPathToPath=G;exports.makeMapValidation=V;exports.makeOnBlurHandler=H;exports.makeOnChangeHandler=M;exports.parsePath=ce;exports.pathToString=U;exports.sessionId=I;exports.standardSchemaResultToValidation=F;exports.taskToValidation=de;exports.useController=Q;exports.useForm=pe;exports.wrapSegment=z;