@ahrowe/ui 0.1.4 → 0.1.5
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.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +59 -40
- package/dist/index.mjs.map +1 -1
- package/dist/types/package/services/formValidation/FormValidatorGroupWithForm.d.ts +3 -0
- package/dist/types/package/services/formValidation/formValidatorGroup.d.ts +8 -2
- package/dist/types/package/services/formValidation/useFormValidatorGroup.d.ts +5 -2
- package/package.json +2 -2
- /package/dist/{mcp → mcp.js} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -2,5 +2,5 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
2
2
|
`),s=n.map(t=>{let n=e.points[t.wallIndex],r=e.points[(t.wallIndex+1)%e.points.length],i=Yt(n,r,t);return i?` <path d="${i}" fill="none" />`:``}).filter(Boolean).join(`
|
|
3
3
|
`),c=e.name?` <text fontSize="5" x="${a.x.toFixed(1)}" y="${a.y.toFixed(1)}">${Kt(e.name)}</text>`:``;return[` <g id="${e.id}">`,o,` <path id="background" d="${i}" />`,s,c,` </g>`].filter(Boolean).join(`
|
|
4
4
|
`)});return[`<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="${o}">`,` <g id="layer1">`,...s,` </g>`,` <use id="use" href="" />`,`</svg>`].join(`
|
|
5
|
-
`)}function Zt(e){let t=[];for(let n of e.matchAll(/[ML]\s*([-\d.]+)[,\s]+([-\d.]+)/gi))t.push({x:parseFloat(n[1]),y:parseFloat(n[2])});return t}function Qt(e){let t=new DOMParser().parseFromString(e,`image/svg+xml`),n=[];return t.querySelectorAll(`[id^="room"]`).forEach(e=>{let t=e.querySelector(`[id="background"]`);if(!t)return;let r=t.getAttribute(`d`);if(!r)return;let i=Zt(r);if(i.length<3)return;let a=e.querySelector(`text`)?.textContent?.trim()??``;n.push({id:e.id,name:a,points:i})}),n}function $t(e,t){let n=Xt(e,t),r=new Blob([n],{type:`image/svg+xml`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`room-plan.svg`,a.click(),URL.revokeObjectURL(i)}var Z={roomDrawer:`roomDrawer_SJj4-`,"roomDrawer-toolbar":`roomDrawer-toolbar_55H5p`,roomDrawerToolbar:`roomDrawer-toolbar_55H5p`,"roomDrawer-toolbar-sep":`roomDrawer-toolbar-sep_nJeh8`,roomDrawerToolbarSep:`roomDrawer-toolbar-sep_nJeh8`,"roomDrawer-toolbar-btn":`roomDrawer-toolbar-btn_2qinY`,roomDrawerToolbarBtn:`roomDrawer-toolbar-btn_2qinY`,"roomDrawer-toolbar-btn-active":`roomDrawer-toolbar-btn-active_4XX25`,roomDrawerToolbarBtnActive:`roomDrawer-toolbar-btn-active_4XX25`,"roomDrawer-toolbar-zoomLabel":`roomDrawer-toolbar-zoomLabel_HMkb5`,roomDrawerToolbarZoomLabel:`roomDrawer-toolbar-zoomLabel_HMkb5`,"roomDrawer-canvas":`roomDrawer-canvas_Y18uD`,roomDrawerCanvas:`roomDrawer-canvas_Y18uD`,"roomDrawer-canvas-select":`roomDrawer-canvas-select_M43-x`,roomDrawerCanvasSelect:`roomDrawer-canvas-select_M43-x`,"roomDrawer-info":`roomDrawer-info_qwC6L`,roomDrawerInfo:`roomDrawer-info_qwC6L`,"roomDrawer-info-label":`roomDrawer-info-label_8I9hB`,roomDrawerInfoLabel:`roomDrawer-info-label_8I9hB`,"roomDrawer-info-input":`roomDrawer-info-input_YAl-K`,roomDrawerInfoInput:`roomDrawer-info-input_YAl-K`,"roomDrawer-info-spacer":`roomDrawer-info-spacer_cOj96`,roomDrawerInfoSpacer:`roomDrawer-info-spacer_cOj96`,"roomDrawer-info-delete":`roomDrawer-info-delete_TSBUN`,roomDrawerInfoDelete:`roomDrawer-info-delete_TSBUN`,"roomDrawer-hint":`roomDrawer-hint_3WTFa`,roomDrawerHint:`roomDrawer-hint_3WTFa`,"roomDrawer-info-doorsBtn":`roomDrawer-info-doorsBtn_oK5Uf`,roomDrawerInfoDoorsBtn:`roomDrawer-info-doorsBtn_oK5Uf`,"roomDrawer-doorPanel":`roomDrawer-doorPanel_e-Tl9`,roomDrawerDoorPanel:`roomDrawer-doorPanel_e-Tl9`,"roomDrawer-doorPanel-header":`roomDrawer-doorPanel-header_--iXz`,roomDrawerDoorPanelHeader:`roomDrawer-doorPanel-header_--iXz`,"roomDrawer-doorPanel-icon":`roomDrawer-doorPanel-icon_KxaVY`,roomDrawerDoorPanelIcon:`roomDrawer-doorPanel-icon_KxaVY`,"roomDrawer-doorPanel-title":`roomDrawer-doorPanel-title_8nOZS`,roomDrawerDoorPanelTitle:`roomDrawer-doorPanel-title_8nOZS`,"roomDrawer-doorPanel-done":`roomDrawer-doorPanel-done_ejQkx`,roomDrawerDoorPanelDone:`roomDrawer-doorPanel-done_ejQkx`,"roomDrawer-doorPanel-list":`roomDrawer-doorPanel-list_rDou7`,roomDrawerDoorPanelList:`roomDrawer-doorPanel-list_rDou7`,"roomDrawer-doorPanel-item":`roomDrawer-doorPanel-item_U-3-B`,roomDrawerDoorPanelItem:`roomDrawer-doorPanel-item_U-3-B`,"roomDrawer-doorPanel-label":`roomDrawer-doorPanel-label_qSYqY`,roomDrawerDoorPanelLabel:`roomDrawer-doorPanel-label_qSYqY`,"roomDrawer-doorPanel-widthLabel":`roomDrawer-doorPanel-widthLabel_jXv7D`,roomDrawerDoorPanelWidthLabel:`roomDrawer-doorPanel-widthLabel_jXv7D`,"roomDrawer-doorPanel-empty":`roomDrawer-doorPanel-empty_LcDw0`,roomDrawerDoorPanelEmpty:`roomDrawer-doorPanel-empty_LcDw0`,"roomDrawer-canvas-door":`roomDrawer-canvas-door_qzCIa`,roomDrawerCanvasDoor:`roomDrawer-canvas-door_qzCIa`,doorGap:`doorGap_KrIuB`,doorMarker:`doorMarker_-N63z`,gridLine:`gridLine_V-rxw`,roomFill:`roomFill_JnJ0J`,"roomFill-selected":`roomFill-selected_IfIRr`,roomFillSelected:`roomFill-selected_IfIRr`,roomStroke:`roomStroke_S18UH`,"roomStroke-selected":`roomStroke-selected_fm19u`,roomStrokeSelected:`roomStroke-selected_fm19u`,roomText:`roomText_6fIeU`,doorPanel:`doorPanel_raCv0`,"doorPanel-selected":`doorPanel-selected_5DG7g`,doorPanelSelected:`doorPanel-selected_5DG7g`,doorSwing:`doorSwing_Tbt9D`,"doorSwing-selected":`doorSwing-selected_fFte5`,doorSwingSelected:`doorSwing-selected_fFte5`,preview:`preview_seIZY`,polyCloseTarget:`polyCloseTarget_snjYx`,polyVertex:`polyVertex_fw0nX`,vertexHandle:`vertexHandle_-z7g5`},en=6,tn=5,nn=1.25,rn=.25,an=12,on=0;function sn(e){return on+=1,`${e}${on}`}var cn={select:`Drag inside to move · Drag corner to reshape · Click wall to add corner · Dbl-click corner to remove · Delete to erase`,rect:`Drag to draw a rectangular room`,polygon:`Click to place corners · Click first point or Enter to close · Esc to cancel`};function ln({className:e}){let[t,n]=(0,c.useState)([]),[r,i]=(0,c.useState)([]),[a,o]=(0,c.useState)(`rect`),[s,p]=(0,c.useState)(null),[m,h]=(0,c.useState)(null),[g,_]=(0,c.useState)(null),[v,y]=(0,c.useState)(null),[b,x]=(0,c.useState)([]),[S,C]=(0,c.useState)(null),[w,T]=(0,c.useState)(1),[E,D]=(0,c.useState)({x:0,y:0}),O=(0,c.useRef)(null),k=(0,c.useRef)(null),A=(0,c.useRef)(null),j=(0,c.useRef)(null),M=(0,c.useRef)(null),N=(0,c.useRef)({rooms:t,doors:r,tool:a,selectedId:s,editingDoorsForRoomId:m,polyPoints:b,zoom:w,pan:E});(0,c.useLayoutEffect)(()=>{N.current={rooms:t,doors:r,tool:a,selectedId:s,editingDoorsForRoomId:m,polyPoints:b,zoom:w,pan:E}});function P(e){e.length<3||(n(t=>[...t,{id:sn(`room`),name:`Room ${t.length+1}`,points:e}]),x([]),C(null))}(0,c.useEffect)(()=>{let e=j.current;if(!e)return;function t(e){e.preventDefault();let{zoom:t,pan:n}=N.current,r=Rt(e.clientX,e.clientY,j.current);if(!r)return;let i=e.deltaY<0?nn:1/nn,a=Math.max(rn,Math.min(an,t*i));D({x:r.x-(r.x-n.x)*(t/a),y:r.y-(r.y-n.y)*(t/a)}),T(a)}return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,c.useEffect)(()=>{function e(e){let{tool:t,selectedId:r,editingDoorsForRoomId:a,polyPoints:o,zoom:s,pan:c}=N.current;if(e.key===`Escape`){if(a){h(null);return}t===`polygon`&&(x([]),C(null)),p(null);return}if(e.key===`Enter`&&t===`polygon`&&o.length>=3){P(o);return}if((e.key===`+`||e.key===`=`)&&!(e.target instanceof HTMLInputElement)){let e=Math.max(rn,Math.min(an,s*nn)),t=c.x+400/s/2,n=c.y+300/s/2;T(e),D({x:t-400/e/2,y:n-300/e/2});return}if(e.key===`-`&&!(e.target instanceof HTMLInputElement)){let e=Math.max(rn,Math.min(an,s/nn)),t=c.x+400/s/2,n=c.y+300/s/2;T(e),D({x:t-400/e/2,y:n-300/e/2});return}if(e.key===`0`&&!(e.target instanceof HTMLInputElement)){T(1),D({x:0,y:0});return}(e.key===`Delete`||e.key===`Backspace`)&&r&&!a&&!(e.target instanceof HTMLInputElement)&&(n(e=>e.filter(e=>e.id!==r)),i(e=>e.filter(e=>e.roomId!==r)),p(null))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);function F(e,t=w,n=E){let r=Math.max(rn,Math.min(an,t*e)),i=n.x+400/t/2,a=n.y+300/t/2;D({x:i-400/r/2,y:a-300/r/2}),T(r)}function I(e){return j.current?Rt(e.clientX,e.clientY,j.current):null}function ee(e,t){let n=null;for(let r=0;r<t.points.length;r++){let i=zt(e,t.points[r]);i<=en&&(!n||i<n.d)&&(n={index:r,d:i})}return n}function te(e,t){let n=null;for(let r=0;r<t.points.length;r++){let i=t.points[r],a=t.points[(r+1)%t.points.length],{dist:o,t:s}=Bt(e,i,a);o<=tn&&(!n||o<n.d)&&(n={index:r,t:s,d:o})}return n}function L(e,t,r,a){return n(n=>n.map(n=>{if(n.id!==e)return n;let r=[...n.points];return r.splice(t+1,0,a),{...n,points:r}})),i(n=>n.map(n=>n.roomId===e?n.wallIndex===t?n.t<=r?{...n,t:r>0?n.t/r:0}:{...n,wallIndex:t+1,t:(n.t-r)/(1-r)}:n.wallIndex>t?{...n,wallIndex:n.wallIndex+1}:n:n)),t+1}function ne(e,r){let a=t.find(t=>t.id===e);if(!a||a.points.length<=3)return;let o=a.points.length;n(t=>t.map(t=>t.id===e?{...t,points:t.points.filter((e,t)=>t!==r)}:t)),i(t=>t.map(t=>{if(t.roomId!==e)return t;let n=(r-1+o)%o;return t.wallIndex===n||t.wallIndex===r?{...t,wallIndex:-1}:t.wallIndex>r?{...t,wallIndex:t.wallIndex-1}:t}).filter(e=>e.wallIndex!==-1))}function R(e){if(e.button===1){e.preventDefault();let t=j.current;if(t){let n=t.getBoundingClientRect();A.current={startClient:{x:e.clientX,y:e.clientY},origPan:{...E},scaleX:400/w/n.width,scaleY:300/w/n.height}}return}if(e.button!==0)return;e.preventDefault();let n=I(e);if(n){if(m){let e=t.find(e=>e.id===m);if(e){let t=Vt(n,[e]);t&&i(e=>[...e,{id:sn(`door`),roomId:t.roomId,wallIndex:t.wallIndex,t:t.t,width:12}])}return}if(a===`rect`){_(n),y(n);return}if(a===`polygon`){b.length>=3&&zt(n,b[0])<=8?P(b):x(e=>[...e,n]);return}if(a===`select`){let e=t.find(e=>e.id===s)??null;if(e){let t=ee(n,e);if(t){O.current={type:`vertex`,roomId:e.id,index:t.index,start:n,origPt:e.points[t.index]};return}}if(e){let t=te(n,e);if(t){let r=e.points[t.index],i=e.points[(t.index+1)%e.points.length],a=Lt({x:r.x+(i.x-r.x)*t.t,y:r.y+(i.y-r.y)*t.t}),o=L(e.id,t.index,t.t,a);O.current={type:`vertex`,roomId:e.id,index:o,start:n,origPt:a};return}}let r=t.find(e=>Ht(n,e.points));if(r){p(r.id),O.current={type:`room`,roomId:r.id,start:n,origPoints:[...r.points]};return}p(null)}}}function re(e){if(a!==`select`||m)return;let n=I(e);if(!n)return;let r=t.find(e=>e.id===s);if(!r)return;let i=ee(n,r);i&&(e.preventDefault(),ne(r.id,i.index))}function z(e){if(A.current){let{startClient:t,origPan:n,scaleX:r,scaleY:i}=A.current;D({x:n.x-(e.clientX-t.x)*r,y:n.y-(e.clientY-t.y)*i});return}let r=I(e);if(r){if(k.current&&m){let e=t.find(e=>e.id===m);if(e){let t=Vt(r,[e]);t&&i(e=>e.map(e=>e.id===k.current?{...e,wallIndex:t.wallIndex,t:t.t}:e))}return}if(a===`rect`&&g){y(r);return}if(a===`polygon`){C(r);return}if(a===`select`&&!m&&O.current){let e=O.current;if(e.type===`vertex`){let t=r.x-e.start.x,i=r.y-e.start.y,a=Lt({x:e.origPt.x+t,y:e.origPt.y+i});n(t=>t.map(t=>{if(t.id!==e.roomId)return t;let n=[...t.points];return n[e.index]=a,{...t,points:n}}))}else{let t=r.x-e.start.x,i=r.y-e.start.y;n(n=>n.map(n=>n.id===e.roomId?{...n,points:e.origPoints.map(e=>({x:e.x+t,y:e.y+i}))}:n))}}}}function ie(e){if(A.current){A.current=null;return}let t=I(e);if(t){if(a===`rect`&&g){let e=Math.min(g.x,t.x),r=Math.min(g.y,t.y),i=Math.abs(t.x-g.x),a=Math.abs(t.y-g.y);i>=10&&a>=10&&n(t=>[...t,{id:sn(`room`),name:`Room ${t.length+1}`,points:Wt(e,r,i,a)}]),_(null),y(null)}k.current=null,O.current=null}}function ae(e){s&&n(t=>t.map(t=>t.id===s?{...t,name:e}:t))}function B(e,t){let n=parseFloat(t);isNaN(n)||n<=0||i(t=>t.map(t=>t.id===e?{...t,width:n}:t))}function V(){s&&(n(e=>e.filter(e=>e.id!==s)),i(e=>e.filter(e=>e.roomId!==s)),h(null),p(null))}function oe(e){i(t=>t.filter(t=>t.id!==e))}function se(e){o(e),h(null),x([]),C(null),_(null),y(null)}function ce(e){let t=e.target.files?.[0];if(!t)return;e.target.value=``;let r=new FileReader;r.onload=e=>{let t=e.target?.result;if(typeof t!=`string`)return;let r=Qt(t);r.length!==0&&(n(r.map(e=>({...e,id:sn(`room`)}))),i([]),p(null),h(null),T(1),D({x:0,y:0}))},r.readAsText(t)}let le=a===`rect`&&g&&v?{x:Math.min(g.x,v.x),y:Math.min(g.y,v.y),w:Math.abs(v.x-g.x),h:Math.abs(v.y-g.y)}:null,H=s?t.find(e=>e.id===s)??null:null,U=m?t.find(e=>e.id===m)??null:null,ue=m?r.filter(e=>e.roomId===m):[],W=[{t:`select`,icon:d.faHandPointer,label:`Select & edit`},{t:`rect`,icon:d.faSquare,label:`Rectangle room`},{t:`polygon`,icon:d.faDrawPolygon,label:`Polygon room`}],de=400/w,fe=300/w,pe=m?Z.roomDrawerCanvasDoor:a===`select`?Z.roomDrawerCanvasSelect:void 0;return(0,f.jsxs)(`div`,{className:(0,l.default)(Z.roomDrawer,e),children:[(0,f.jsxs)(`div`,{className:Z.roomDrawerToolbar,children:[W.map(({t:e,icon:t,label:n})=>(0,f.jsx)(`button`,{title:n,className:(0,l.default)(Z.roomDrawerToolbarBtn,e===a&&!m&&Z.roomDrawerToolbarBtnActive),onClick:()=>se(e),children:(0,f.jsx)(u.FontAwesomeIcon,{icon:t})},e)),(0,f.jsx)(`div`,{className:Z.roomDrawerToolbarSep}),(0,f.jsx)(`button`,{title:`Zoom in (+)`,className:Z.roomDrawerToolbarBtn,onClick:()=>F(nn),disabled:w>=an,children:(0,f.jsx)(u.FontAwesomeIcon,{icon:d.faMagnifyingGlassPlus})}),(0,f.jsxs)(`button`,{title:`Reset zoom (0) — ${Math.round(w*100)}%`,className:Z.roomDrawerToolbarZoomLabel,onClick:()=>{T(1),D({x:0,y:0})},children:[Math.round(w*100),`%`]}),(0,f.jsx)(`button`,{title:`Zoom out (−)`,className:Z.roomDrawerToolbarBtn,onClick:()=>F(1/nn),disabled:w<=rn,children:(0,f.jsx)(u.FontAwesomeIcon,{icon:d.faMagnifyingGlassMinus})}),(0,f.jsx)(`div`,{className:Z.roomDrawerToolbarSep}),(0,f.jsx)(`button`,{title:`Upload SVG`,className:Z.roomDrawerToolbarBtn,onClick:()=>M.current?.click(),children:(0,f.jsx)(u.FontAwesomeIcon,{icon:d.faUpload})}),(0,f.jsx)(`button`,{title:`Download SVG`,className:Z.roomDrawerToolbarBtn,onClick:()=>$t(t,r),disabled:t.length===0,children:(0,f.jsx)(u.FontAwesomeIcon,{icon:d.faDownload})}),(0,f.jsx)(`input`,{ref:M,type:`file`,accept:`.svg,image/svg+xml`,style:{display:`none`},onChange:ce})]}),(0,f.jsxs)(`svg`,{ref:j,className:(0,l.default)(Z.roomDrawerCanvas,pe),viewBox:`${E.x} ${E.y} ${de} ${fe}`,onMouseDown:R,onMouseMove:z,onMouseUp:ie,onDoubleClick:re,children:[(0,f.jsx)(`defs`,{children:(0,f.jsx)(`pattern`,{id:`rd-grid`,width:5,height:5,patternUnits:`userSpaceOnUse`,children:(0,f.jsx)(`path`,{d:`M 5 0 L 0 0 0 5`,fill:`none`,className:Z.gridLine})})}),(0,f.jsx)(`rect`,{x:E.x,y:E.y,width:de,height:fe,fill:`url(#rd-grid)`}),t.map(e=>{let t=e.points,n=t.map((e,t)=>`${t===0?`M`:`L`} ${e.x},${e.y}`).join(` `)+` Z`,i=Jt(t,r.filter(t=>t.roomId===e.id)),a=Ut(t),o=s===e.id,c=m===e.id;return(0,f.jsxs)(`g`,{children:[(0,f.jsx)(`path`,{d:n,className:(0,l.default)(Z.roomFill,(o||c)&&Z.roomFillSelected)}),i.map((e,t)=>(0,f.jsx)(`path`,{d:e,className:(0,l.default)(Z.roomStroke,(o||c)&&Z.roomStrokeSelected)},t)),e.name&&(0,f.jsx)(`text`,{x:a.x,y:a.y,className:Z.roomText,textAnchor:`middle`,dominantBaseline:`middle`,children:e.name})]},e.id)}),r.map(e=>{let n=t.find(t=>t.id===e.roomId);if(!n)return null;let r=n.points[e.wallIndex],i=n.points[(e.wallIndex+1)%n.points.length],a=Gt(r,i,e.t,e.width);return a?(0,f.jsx)(`line`,{x1:a.p1.x,y1:a.p1.y,x2:a.p2.x,y2:a.p2.y,className:Z.doorGap},e.id):null}),m&&ue.map(e=>{let n=t.find(t=>t.id===e.roomId);if(!n)return null;let r=n.points[e.wallIndex],i=n.points[(e.wallIndex+1)%n.points.length],a=Gt(r,i,e.t,e.width);if(!a)return null;let o={x:(a.p1.x+a.p2.x)/2,y:(a.p1.y+a.p2.y)/2};return(0,f.jsx)(`circle`,{cx:o.x,cy:o.y,r:2.5,className:Z.doorMarker,onMouseDown:t=>{t.button===0&&(t.preventDefault(),t.stopPropagation(),k.current=e.id)}},e.id)}),a===`select`&&!m&&H&&H.points.map((e,t)=>(0,f.jsx)(`circle`,{cx:e.x,cy:e.y,r:3.5,className:Z.vertexHandle},t)),le&&(0,f.jsx)(`rect`,{x:le.x,y:le.y,width:le.w,height:le.h,className:Z.preview}),a===`polygon`&&b.length>0&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`polyline`,{points:[...b,S??b[b.length-1]].map(e=>`${e.x},${e.y}`).join(` `),className:Z.preview}),b.length>=3&&(0,f.jsx)(`circle`,{cx:b[0].x,cy:b[0].y,r:8/2,className:Z.polyCloseTarget}),b.map((e,t)=>(0,f.jsx)(`circle`,{cx:e.x,cy:e.y,r:2,className:Z.polyVertex},t))]})]}),H&&!m&&(0,f.jsxs)(`div`,{className:Z.roomDrawerInfo,children:[(0,f.jsx)(`span`,{className:Z.roomDrawerInfoLabel,children:`Name`}),(0,f.jsx)(`input`,{className:Z.roomDrawerInfoInput,value:H.name,onChange:e=>ae(e.target.value),placeholder:`Room name`}),(0,f.jsxs)(`button`,{className:Z.roomDrawerInfoDoorsBtn,onClick:()=>h(H.id),title:`Edit doors`,children:[(0,f.jsx)(u.FontAwesomeIcon,{icon:d.faDoorOpen}),(0,f.jsx)(`span`,{children:r.filter(e=>e.roomId===H.id).length})]}),(0,f.jsx)(`button`,{className:Z.roomDrawerInfoDelete,onClick:V,title:`Delete room`,children:(0,f.jsx)(u.FontAwesomeIcon,{icon:d.faTrash})})]}),m&&U&&(0,f.jsxs)(`div`,{className:Z.roomDrawerDoorPanel,children:[(0,f.jsxs)(`div`,{className:Z.roomDrawerDoorPanelHeader,children:[(0,f.jsx)(u.FontAwesomeIcon,{icon:d.faDoorOpen,className:Z.roomDrawerDoorPanelIcon}),(0,f.jsx)(`span`,{className:Z.roomDrawerDoorPanelTitle,children:U.name?`Doors · ${U.name}`:`Doors`}),(0,f.jsxs)(`button`,{className:Z.roomDrawerDoorPanelDone,onClick:()=>h(null),title:`Done (Esc)`,children:[(0,f.jsx)(u.FontAwesomeIcon,{icon:d.faCheck}),`Done`]})]}),(0,f.jsxs)(`div`,{className:Z.roomDrawerDoorPanelList,children:[ue.length===0&&(0,f.jsx)(`span`,{className:Z.roomDrawerDoorPanelEmpty,children:`Click on a wall to add a door`}),ue.map((e,t)=>(0,f.jsxs)(`div`,{className:Z.roomDrawerDoorPanelItem,children:[(0,f.jsxs)(`span`,{className:Z.roomDrawerDoorPanelLabel,children:[`Door `,t+1]}),(0,f.jsx)(`span`,{className:Z.roomDrawerDoorPanelWidthLabel,children:`Width`}),(0,f.jsx)(`input`,{className:Z.roomDrawerInfoInput,type:`number`,min:1,value:e.width,onChange:t=>B(e.id,t.target.value)}),(0,f.jsx)(`button`,{className:Z.roomDrawerInfoDelete,onClick:()=>oe(e.id),title:`Delete door`,children:(0,f.jsx)(u.FontAwesomeIcon,{icon:d.faTrash})})]},e.id))]})]}),(0,f.jsx)(`div`,{className:Z.roomDrawerHint,children:m?`Click a wall to add a door · Adjust width or delete from the list · Done or Esc to finish`:`${cn[a]} · Scroll to zoom · Middle-drag to pan · 0 to reset`})]})}var un={scrollbarProvider:`scrollbarProvider_IMBFu`};function dn({className:e=void 0,children:t=void 0}){return(0,f.jsx)(`div`,{className:(0,l.default)(un.scrollbarProvider,e),children:t})}var fn=dn,pn={resultCount:`resultCount_Sn48Q`};function mn({value:e,onChange:t,onDebounce:n,placeholder:r,label:i,debounceMs:a=500,totalAmount:o,showAmount:s=!0,className:l,width:u,...d}){let p=(0,c.useRef)(null);(0,c.useEffect)(()=>()=>{p.current!==null&&clearTimeout(p.current)},[]);function m(e){let r=e==null?``:String(e),i=r.trim()===``?``:r;t(i),p.current!==null&&clearTimeout(p.current),p.current=setTimeout(()=>{n?.(i)},a)}let h=s&&typeof o==`number`&&!Number.isNaN(o);return(0,f.jsxs)(`div`,{...d,className:l,style:u==null?void 0:{width:u},children:[(0,f.jsx)(ye,{type:K.Search,label:i,placeholder:r,value:e,onChange:m}),h&&(0,f.jsxs)(`p`,{className:pn.resultCount,children:[o,` `,o===1?`result`:`results`]})]})}var Q={stepper:`stepper_kiS2A`,"stepper-clickable":`stepper-clickable_Nm6fP`,stepperClickable:`stepper-clickable_Nm6fP`,"stepper-vertical":`stepper-vertical_2y9rg`,stepperVertical:`stepper-vertical_2y9rg`,"stepper-connector":`stepper-connector_J2FwZ`,stepperConnector:`stepper-connector_J2FwZ`,"stepper-connector-vertical":`stepper-connector-vertical_vwY38`,stepperConnectorVertical:`stepper-connector-vertical_vwY38`,"stepper-connector-filled":`stepper-connector-filled_W8UZS`,stepperConnectorFilled:`stepper-connector-filled_W8UZS`,"stepper-entry":`stepper-entry_KD4JJ`,stepperEntry:`stepper-entry_KD4JJ`,"stepper-entry-active":`stepper-entry-active_V1aRt`,stepperEntryActive:`stepper-entry-active_V1aRt`,"stepper-entry-done":`stepper-entry-done_M3wb5`,stepperEntryDone:`stepper-entry-done_M3wb5`,"stepper-entry-number":`stepper-entry-number_J168Q`,stepperEntryNumber:`stepper-entry-number_J168Q`,"stepper-entry-number-done":`stepper-entry-number-done_-m7sD`,stepperEntryNumberDone:`stepper-entry-number-done_-m7sD`,showCheckmark:`showCheckmark_Rd0oW`,"stepper-entry-label":`stepper-entry-label_b94eg`,stepperEntryLabel:`stepper-entry-label_b94eg`,"stepper-entry-label-vertical":`stepper-entry-label-vertical_Zm8i4`,stepperEntryLabelVertical:`stepper-entry-label-vertical_Zm8i4`},hn=class e extends c.Component{static alignments={VERTICAL:`vertical`,HORIZONTAL:`horizontal`};static propTypes={steps:g.default.arrayOf(g.default.shape({})),currentStep:g.default.number,alignment:g.default.oneOf([e.alignments.HORIZONTAL,e.alignments.VERTICAL]),onStepClicked:g.default.func};static defaultProps={steps:[],currentStep:0,alignment:e.alignments.HORIZONTAL,onStepClicked:null};constructor(e){super(e)}state={};renderCheckmark=()=>(0,f.jsx)(`svg`,{strokeLinejoin:`round`,strokeLinecap:`round`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`-0.2 -1.2 3.4 2`,height:`20px`,width:`20px`,children:(0,f.jsx)(`path`,{d:`M 0 0 l 1 1 l 2 -2`,stroke:`white`,strokeWidth:`0.4`,fill:`none`})});renderStep=(t,n)=>{let{steps:r,currentStep:i,alignment:a,onStepClicked:o}=this.props;return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`div`,{className:(0,l.default)(Q.stepperEntry,{[Q.stepperEntryActive]:n<=i,[Q.stepperEntryDone]:n<i,[Q.stepperClickable]:n<i&&o}),onClick:()=>o?o(n):null,children:[(0,f.jsx)(`div`,{className:(0,l.default)(Q.stepperEntryNumber,{[Q.stepperEntryNumberDone]:n<i}),children:n>=i?n+1:this.renderCheckmark()}),(0,f.jsx)(`div`,{className:(0,l.default)(Q.stepperEntryLabel,{[Q.stepperEntryLabelVertical]:a===e.alignments.VERTICAL}),children:t.label})]}),r.length-1>n&&(0,f.jsx)(`div`,{className:(0,l.default)(Q.stepperConnector,{[Q.stepperConnectorFilled]:n<i,[Q.stepperConnectorVertical]:a===e.alignments.VERTICAL})})]})};render(){let{steps:t,alignment:n}=this.props;return(0,f.jsx)(`div`,{className:(0,l.default)(Q.stepper,{[Q.stepperVertical]:n===e.alignments.VERTICAL}),children:t.map(this.renderStep)})}},gn=`https://tenor.googleapis.com/v2`,_n=class{constructor(e){this.key=e}async search(e,t={}){let n=new URLSearchParams({q:e,key:this.key});return t.limit!=null&&n.set(`limit`,String(t.limit)),t.contentfilter!=null&&n.set(`contentfilter`,t.contentfilter),t.pos!=null&&n.set(`pos`,t.pos),(await fetch(`${gn}/search?${n}`)).json()}async searchSuggestions(e){let t=new URLSearchParams({q:e,key:this.key});return(await fetch(`${gn}/search_suggestions?${t}`)).json()}registerShare(e,t){let n=new URLSearchParams({id:t,q:e,key:this.key});fetch(`${gn}/registershare?${n}`).catch(()=>null)}},vn={gifPreview:`gifPreview_-ECUZ`,"gifPreview-image":`gifPreview-image_Aq7-a`,gifPreviewImage:`gifPreview-image_Aq7-a`,"gifPreview-image-container":`gifPreview-image-container_ycypL`,gifPreviewImageContainer:`gifPreview-image-container_ycypL`,gradientBottomLeftToTopRight:`gradientBottomLeftToTopRight_wo6HB`};function yn({className:e,previewItems:t=[],onSelect:n,onLoadAdditional:r}){function i(e){let t=e.currentTarget,n=t.scrollHeight-t.clientHeight*1.5;t.scrollTop>=n&&r?.()}return(0,f.jsx)(f.Fragment,{children:t.length>0&&(0,f.jsx)(`div`,{className:(0,l.default)(vn.gifPreview,e),onScroll:i,children:t.map((e,t)=>(0,f.jsx)(z,{className:vn.gifPreviewImageContainer,onClick:()=>n?.(e),children:(0,f.jsx)(`div`,{className:vn.gifPreviewImage,style:{backgroundImage:`url(${e.media_formats.tinygif.url})`}})},`${e.id}_${t}`))})})}var bn={gifView:`gifView_Fa2zj`,"gifView-loading":`gifView-loading_LfNJr`,gifViewLoading:`gifView-loading_LfNJr`,gradientBottomLeftToTopRight:`gradientBottomLeftToTopRight_JR6aS`};function xn({className:e,src:t=``}){let[n,r]=(0,c.useState)(!0);return(0,c.useEffect)(()=>{r(!0)},[t]),(0,f.jsxs)(`div`,{className:(0,l.default)(bn.gifView,e),children:[(0,f.jsx)(`img`,{className:bn.tenorPickerSelected,src:t,onLoad:()=>r(!1)}),n&&(0,f.jsx)(`div`,{className:bn.gifViewLoading})]})}var Sn={"tenorPicker-selected":`tenorPicker-selected_IfR2z`,tenorPickerSelected:`tenorPicker-selected_IfR2z`,"tenorPicker-modal-content":`tenorPicker-modal-content_Vkolf`,tenorPickerModalContent:`tenorPicker-modal-content_Vkolf`,"tenorPicker-suggestions-container":`tenorPicker-suggestions-container_kJCj5`,tenorPickerSuggestionsContainer:`tenorPicker-suggestions-container_kJCj5`,"tenorPicker-suggestions-item":`tenorPicker-suggestions-item_Rl99M`,tenorPickerSuggestionsItem:`tenorPicker-suggestions-item_Rl99M`};function Cn({className:e,token:t=``,isModal:n=!1,onSelect:r=()=>void 0,selected:i=null}){let a=(0,c.useMemo)(()=>new _n(t),[t]),[o,s]=(0,c.useState)(``),[u,d]=(0,c.useState)([]),[p,m]=(0,c.useState)([]),[h,g]=(0,c.useState)(null),[_,v]=(0,c.useState)(!1);async function y(e){if(s(e),!e.trim()){d([]),m([]),g(null);return}let[{results:t=[],next:n=null},{results:r=[]}]=await Promise.all([a.search(e,{limit:18,contentfilter:`medium`}),a.searchSuggestions(e)]);d(t),g(n),m(r)}async function b(){let{results:e=[],next:t=null}=await a.search(o,{limit:36,pos:h??void 0,contentfilter:`medium`});g(t),d(t=>[...t,...e])}async function x(e){await r(e),v(!1),e&&a.registerShare(o,e.id)}function S(){return(0,f.jsx)(fe,{inline:!0,className:Sn.tenorPickerSuggestionsContainer,children:p.map(e=>(0,f.jsx)(de,{className:Sn.tenorPickerSuggestionsItem,text:e,onClick:()=>y(e)},e))})}function C(){return(0,f.jsx)(yn,{previewItems:u,onSelect:x,onLoadAdditional:b})}function w(){return(0,f.jsx)(mn,{label:`Pick gif`,value:o,onDebounce:y,onChange:s})}return n?(0,f.jsxs)(`div`,{className:(0,l.default)(Sn.tenorPicker,e),children:[(0,f.jsxs)(`div`,{className:D.actionButtons,children:[(0,f.jsx)(L,{onClick:()=>v(!0),children:`Pick gif`}),i&&(0,f.jsx)(L,{styleType:M.Delete,onClick:()=>x(null),children:`Remove gif`})]}),i&&(0,f.jsx)(xn,{className:Sn.tenorPickerSelected,src:i}),(0,f.jsx)(je,{isOpen:_,onClose:()=>v(!1),children:(0,f.jsxs)(`div`,{className:Sn.tenorPickerModalContent,children:[w(),S(),C()]})})]}):(0,f.jsxs)(`div`,{className:(0,l.default)(Sn.tenorPicker,e),children:[(0,f.jsx)(ge,{align:me.Left,isOpen:u.length>0&&_,onOpenChange:v,content:(0,f.jsxs)(f.Fragment,{children:[S(),C()]}),children:w()}),i&&(0,f.jsx)(L,{styleType:M.Delete,onClick:()=>x(null),children:`Remove gif`}),i&&(0,f.jsx)(xn,{className:Sn.tenorPickerSelected,src:i})]})}function wn(e){return(0,f.jsx)(ye,{...e,multiline:!0})}var Tn={id:`default`,variables:{"--grey":`#8A8A8A`,"--lightgrey":`#e0e0e0`,"--lightergrey":`#B1B1B1`,"--white":`#FFFFFF`,"--red":`#D6002A`,"--lighter-red":`#ffeae9`,"--green":`#287626`,"--lighter-green":`#C4FFC9`,"--blue":`#5873d5`,"--lighter-blue":`#C6DBFF`,"--black":`black`,"--orange":`#ff7f50`,"--lighter-orange":`#ffe5d9`,"--primary-color":`#8184d6`,"--primary-accent":`#90CAF9`,"--primary-lighter":`#9a9ce4`,"--accent-color":`var(--grey)`,"--accent-color-light":`var(--lightgrey)`,"--text-color":`var(--white)`,"--text-dark":`var(--lightergrey)`,"--text-light":`var(--lightergrey)`,"--text-on-primary":`var(--white)`,"--text-on-delete":`var(--white)`,"--border-color":`#656574`,"--background":`#393945`,"--background-accent":`#33333c`,"--background-accent-dark":`var(--grey)`,"--background-accent-light":`#484856`,"--background-modal":`#484856`,"--success-color":`var(--green)`,"--success-lighter":`var(--lighter-green)`,"--error-color":`var(--red)`,"--error-lighter":`var(--lighter-red)`,"--info-color":`var(--blue)`,"--info-lighter":`var(--lighter-blue)`,"--warn-color":`var(--orange)`,"--warn-lighter":`var(--lighter-orange)`,"--default-font-size":`14px`,"--text-small-font-size":`12px`,"--header-font-size":`24px`,"--header-medium-font-size":`18px`,"--header-small-font-size":`16px`,"--default-font-weight":`400`,"--header-font-weight":`600`,"--input-background":`transparent`,"--input-icon-color":`var(--text-color)`,"--error-border-color":`var(--red)`,"--default-border-radius":`8px`,"--padding-sides":`15px`,"--margin-top":`10px`,"--default-font":`'Inter', sans-serif`,"--themed-font":`'Inter', sans-serif`,"--card-shadow":`0 3px 1px -2px rgb(0 0 0 / 20%), 0 2px 2px 0 rgb(0 0 0 / 14%), 0 1px 5px 0 rgb(0 0 0 / 12%)`,"--spacing-s":`4px`,"--spacing-m":`8px`,"--spacing-l":`16px`}},En={colorFade:`colorFade_eLv2g`},Dn=class extends c.Component{constructor(...e){super(...e),this.state={resolvedVariables:{},colorFadeActive:!1,currentThemeColor:null},this.colorFadeTimeout=null,this.wrapperRef=c.default.createRef(),this.themeColorMeta=null,this.createdThemeColorMeta=!1,this.applyTheme=e=>{let t=this.props.themes??[Tn],n=t.find(e=>!e.baseThemeId)??t[0],r=n?n.variables:{},i=t.find(t=>t.id===e),a=i?this.resolveChain(i.id):[],o=Object.assign({},r,...a);this.setState({resolvedVariables:o,colorFadeActive:!0}),this.colorFadeTimeout&&clearTimeout(this.colorFadeTimeout),this.colorFadeTimeout=setTimeout(()=>{this.setState({colorFadeActive:!1}),this.colorFadeTimeout=null},500),setTimeout(()=>{this.wrapperRef.current&&this.setState({currentThemeColor:getComputedStyle(this.wrapperRef.current).getPropertyValue(`--primary-color`).trim()})},1)}}componentDidMount(){this.applyTheme(this.props.currentThemeId),this.syncThemeColorMeta(this.state.currentThemeColor??``)}componentDidUpdate(e,t){t.currentThemeColor!==this.state.currentThemeColor&&this.syncThemeColorMeta(this.state.currentThemeColor??``),(e.currentThemeId!==this.props.currentThemeId||e.themes!==this.props.themes)&&this.applyTheme(this.props.currentThemeId)}componentWillUnmount(){this.colorFadeTimeout&&clearTimeout(this.colorFadeTimeout),this.createdThemeColorMeta&&this.themeColorMeta?.remove()}syncThemeColorMeta(e){if(!(typeof document>`u`)){if(!this.themeColorMeta){let e=document.head.querySelector(`meta[name="theme-color"]`);if(e)this.themeColorMeta=e;else{let e=document.createElement(`meta`);e.setAttribute(`name`,`theme-color`),document.head.appendChild(e),this.themeColorMeta=e,this.createdThemeColorMeta=!0}}this.themeColorMeta.setAttribute(`content`,e)}}resolveChain(e){let t=(this.props.themes??[Tn]).find(t=>t.id===e);return t?[...t.baseThemeId?this.resolveChain(t.baseThemeId):[],t.variables]:[]}render(){let{children:e}=this.props,{resolvedVariables:t,colorFadeActive:n}=this.state;return(0,f.jsx)(`div`,{ref:this.wrapperRef,id:`themeProvider`,className:n?En.colorFade:void 0,style:t,children:e})}};function On(e=`default`){let[t,n]=(0,c.useState)(localStorage.getItem(`theme`)||e);return{currentThemeId:t,setCurrentThemeId:e=>{n(e),localStorage.setItem(`theme`,e)}}}var kn={wizard:`wizard_uRBAN`,"wizard-content":`wizard-content_lcl4C`,wizardContent:`wizard-content_lcl4C`,"wizard-content-outOfFrame":`wizard-content-outOfFrame_Eks4Y`,wizardContentOutOfFrame:`wizard-content-outOfFrame_Eks4Y`,"wizard-content-container":`wizard-content-container_yxbCJ`,wizardContentContainer:`wizard-content-container_yxbCJ`},An=class extends c.Component{static propTypes={currentStep:g.default.number,stepCount:g.default.number,renderStep:g.default.func,className:g.default.string};static defaultProps={currentStep:0,stepCount:0,renderStep:()=>null,className:``};constructor(e){super(e)}state={height:void 0,showOtherContent:!1,minRenderStep:0,maxRenderStep:0};componentDidUpdate(e){let{currentStep:t}=this.props,{currentStep:n}=e;t!==n&&(this.hideContentTimeout&&clearTimeout(this.hideContentTimeout),this.setState({showOtherContent:!0}),this.hideContentTimeout=setTimeout(()=>{this.setState({showOtherContent:!1}),this.hideContentTimeout=null},400))}updateCurrentRef=(e,t)=>{let{currentStep:n}=this.props,{height:r}=this.state;e&&n===t&&r!==e.clientHeight&&this.setState({height:e.clientHeight})};render(){let{renderStep:e,currentStep:t,stepCount:n,className:r}=this.props,{height:i,showOtherContent:a}=this.state,o=i===void 0?{}:{height:`${i}px`};return(0,f.jsx)(`div`,{className:(0,l.default)((0,l.default)(kn.wizard,r)),style:o,children:(0,f.jsx)(`div`,{className:kn.wizardContentContainer,style:{width:`${n*100}%`,marginLeft:`-${t*100}%`},children:Array.from(Array(n),()=>null).map((r,i)=>(0,f.jsx)(`div`,{ref:e=>this.updateCurrentRef(e,i),className:kn.wizardContent,style:{width:`${100/n}%`,marginLeft:`${100/n*i}%`},children:(0,f.jsx)(`div`,{className:(0,l.default)({[kn.wizardContentOutOfFrame]:t!==i&&!a}),children:e(i)})},`wizardContent${i}`))})})}};function jn(e){let t=e;return t?.errors&&Array.isArray(t.errors)?t.errors.flatMap(e=>Object.entries(e).map(([e,t])=>({id:e,message:t}))):[]}var Mn=class{#e;#t;#n;#r;#i;constructor(e,t=null,{initialValues:n,onSubmit:r=()=>void 0,onValidate:i=()=>void 0,errorParser:a=jn}={}){this.#t=!1,this.#i=[],this.getFormError=()=>{let e=Object.keys(this.group);for(let t=0;t<e.length;t+=1){let n=e[t];if(this.group[n].errors.length>0)return this.group[n].errors[0]}return null},this.set=(e,t)=>(this.group[e].set(t),this),this.reset=(e={})=>{this.submitCount=0;let t=Object.keys(e);Object.keys(this.group).forEach(n=>{this.group[n].set(t.includes(n)?e[n]:this.#r[n],!1)}),this.resetDirtyAndTouched(),this.onReset&&this.onReset(this,this.#r,this.#e)},this.resetDirtyAndTouched=()=>{Object.keys(this.group).forEach(e=>{this.group[e].dirty=!1,this.group[e].touched=!1})},this.parseError=(e,t=!1)=>{this.errorParser(e).forEach(({id:e,message:t})=>{this.group[e]&&this.group[e].addError({id:e,message:t})})},this.#a=()=>{this.component&&this.component.forceUpdate(),this.#i.forEach(e=>e())},this.registerOnUpdateListener=e=>{this.#i.push(e)},this.removeOnUpdateListener=e=>{this.#i.splice(this.#i.indexOf(e),1)},this.setSubmitting=e=>{this.#t!==e&&(this.#t=e,this.#a())},this.submit=async e=>{e&&(e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation()),this.setSubmitting(!0);let t=null;if(this.submitCount===0?t=await Promise.resolve(this.validate()):this.onValidateCallback&&(t=await Promise.resolve(this.onValidateCallback(this))),this.getFormError()||t){this.setSubmitting(!1),this.submitCount,this.submitCount+=1,this.#a();return}try{await this.onSubmitCallback(this.getValues(),this),this.resetDirtyAndTouched()}catch(e){this.parseError(e,!0)}this.setSubmitting(!1),this.#a(),this.submitCount+=1},this.getValues=()=>{let e={};return Object.keys(this.group).forEach(t=>{e[t]=this.group[t].value}),{...this.#e,...e}},this.validate=()=>{if(Object.keys(this.group).forEach(e=>{this.group[e].validate(),this.group[e].touched=!0}),this.onValidateCallback)return this.onValidateCallback(this)},this.setValidator=(e,t)=>(this.group[e]=t,this),this.group=e,this.#e=n??{},this.#r={},this.submitCount=0,this.onDebounce=()=>{},this.onReset=()=>{},Object.keys(this.group).forEach(e=>{let t=this.group[e],n=this.#e;n[e]!==void 0&&t.set(n[e]),this.#r[e]=t.value,this.group[e].registerOnUpdateListener(()=>{this.#a(),this.submitCount=0,this.#n&&clearTimeout(this.#n),this.#n=setTimeout(()=>this.onDebounce(this.getValues()),500)})}),this.component=t,this.onSubmitCallback=r,this.onValidateCallback=i,this.errorParser=a,this.setSubmitting(!1)}get isSubmitting(){return this.#t}get wasTouched(){return Object.keys(this.group).some(e=>this.group[e].touched)}get isDirty(){return Object.keys(this.group).some(e=>this.group[e].dirty)}get hasErrors(){return Object.keys(this.group).some(e=>this.group[e].errors.length>0)}get initialValues(){return{...this.#e}}#a};function Nn(e){return function({children:t,...n}){return(0,f.jsx)(`form`,{onSubmit:e.submit,noValidate:!0,...n,children:t})}}var Pn=class extends Mn{constructor(e,t=null,n){super(e,t,n),this.Form=Nn(this)}},Fn=class{#e;#t;#n;#r;#i;constructor(e,t){this.addError=e=>{this.#r.push(e),this.onUpdate()},this.removeErrors=e=>{this.#r=this.#r.filter(t=>!e.includes(t.id)),this.onUpdate()},this.clearErrors=()=>{this.#r=[],this.onUpdate()},this.hasError=e=>!e&&this.errors.length>0?!0:!!this.errors.find(t=>t.id===e),this.getCurrentErrorMessage=()=>this.errors.length===0?null:this.errors[0].message,this.validate=()=>{this.clearErrors(),this.validators.forEach(e=>{let t=e(this.value,this.label);t&&this.addError(t)})},this.onUpdate=()=>{this.onUpdateCallbacks.forEach(e=>e(this))},this.registerOnUpdateListener=e=>{this.onUpdateCallbacks.push(e)},this.removeOnUpdateListener=e=>{this.onUpdateCallbacks.splice(this.onUpdateCallbacks.indexOf(e),1)},this.set=(e,t=!0)=>(this.value=e,t&&!this.dirty&&(this.dirty=!0),this.validate(),this),this.#e=e,this.validators=t??[],this.#t=!1,this.#n=!1,this.#r=[],this.#i=``,this.onUpdateCallbacks=[],this.validate()}get touched(){return this.#t}set touched(e){this.#t=e,this.onUpdate()}get label(){return this.#i}set label(e){this.#i=e}get dirty(){return this.#n}set dirty(e){this.#n=e,this.onUpdate()}get value(){return this.#e}set value(e){this.#e=e,this.onUpdate()}get errors(){return this.#r}};Fn.prototype.toString=function(){return`${this.value}`};function In(e){return/^[0-9]+$/.test(e)}function Ln(e){return/^[0-9]{2}.[0-9]{2}.[0-9]{4}$/.test(e)}function Rn(e){return/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}Z$/.test(e)}function zn(e){return/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-ZöäüÜÖÄß\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e)}function Bn(e){return/^[A-Z]{6}[A-Z\d]{2}([A-Z\d]{3})?$/.test(e)}function Vn(e){return/[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,63}(\/[-a-zA-Z0-9@:%_+.~#?&//=]*)?$/.test(e)}function Hn(e){return/^[\w!@#$%^&*?±§~`'"/\\[\]{}\-,.();:><+=|öäüÖÄÜß €μ]{8,}$/.test(e)}function Un(e){return/^(?=.*[a-zöäüA-ZÖÄÜß])/.test(e)}function Wn(e){return/^(?=.*\d)/.test(e)}function Gn(e){return Hn(e)&&Un(e)&&Wn(e)}var $={t:(e,t)=>({"formValidators.minLength":`Must be at least ${t?.min} characters long`,"formValidators.maxLength":`Must be at most ${t?.max} characters long`,"formValidators.email":`Must be a valid email address`,"formValidators.required":`${t?.label||`Value`} is required`,"formValidators.value":`Value`,"formValidators.mustBeNumber":`Must be a number`,"formValidators.oneOf":`Must be one of the following values: ${t?.allowedValues}`,"formValidators.typeOf":`Must have type of ${t?.allowedTypes}`,"formValidators.multiEmail":`Must be a comma or semicolon separated list of valid email addresses`,"formValidators.date":`Must be a valid date`,"garages.errors.website":`Must be a valid URL`,"garages.errors.bic":`Must be a valid BIC`,"formValidators.minLetters":`Must contain at least ${t?.smart_count} letters`,"formValidators.minDigits":`Must contain at least ${t?.smart_count} digits`})[e]||e},Kn=class e{static{this.minLength=(e,t)=>n=>!n||n.length<e?{id:`minLength`,message:t||$.t(`formValidators.minLength`,{min:e})}:null}static{this.maxLength=(e,t)=>n=>n&&n.length>e?{id:`maxLength`,message:t||$.t(`formValidators.maxLength`,{max:e})}:null}static{this.email=e=>t=>t&&!zn(t)?{id:`email`,message:e||$.t(`formValidators.email`)}:null}static{this.required=e=>{function t(t,n){return!t&&t!==0?{id:`required`,message:e||$.t(`formValidators.required`,{label:n||$.t(`formValidators.value`)})}:null}return t.validatorId=`required`,t}}static{this.mustBeNumber=e=>t=>t&&Number.isNaN(+t)?{id:`mustBeNumber`,message:e||$.t(`formValidators.mustBeNumber`)}:null}static{this.oneOf=(e,t)=>n=>n&&!e.includes(n)?{id:`oneOf`,message:t||$.t(`formValidators.oneOf`,{allowedValues:e})}:null}static{this.typeOf=(e,t)=>n=>{if(Array.isArray(e)){for(let t=0;t<e.length;t+=1)if(typeof n===e[t])return null}else if(typeof n===e)return null;return{id:`typeOf`,message:t||`Must have type of ${e}`}}}static{this.multiEmail=e=>t=>{if(t){let n=t.replace(/ /g,``).replace(/,/g,`;`).split(`;`);for(let t=0;t<n.length;t+=1)if(!zn(n[t]))return{id:`multiEmail`,message:e||$.t(`formValidators.multiEmail`)}}return null}}static{this.date=e=>t=>t&&!Ln(t)&&!Rn(t)?{id:`date`,message:e||$.t(`formValidators.date`)}:null}static{this.dateObject=e=>t=>t&&!t.isValid?{id:`date`,message:e||$.t(`formValidators.date`)}:null}static{this.website=e=>t=>t&&!Vn(t)?{id:`website`,message:e||$.t(`garages.errors.website`)}:null}static{this.bic=e=>t=>t&&!Bn(t)?{id:`bic`,message:e||$.t(`garages.errors.bic`)}:null}static{this.minLetters=(e,t)=>n=>n&&n.replace(/[^a-zöäüA-ZÖÄÜß]/g,``).length<e?{id:`minLetters`,message:t||$.t(`formValidators.minLetters`,{smart_count:e})}:null}static{this.minDigits=(e,t)=>n=>n&&n.replace(/[\D]/g,``).length<e?{id:`minDigits`,message:t||$.t(`formValidators.minDigits`,{smart_count:e})}:null}static{this.password=t=>n=>{let r=e.minLength(8)(n)||e.minLetters(1)(n)||e.minDigits(1)(n);return r?t?{id:`password`,message:t}:r:null}}},qn=class extends c.PureComponent{static{this.defaultProps={formValidator:null,onMouseEnter:null,onMouseLeave:null,onFocus:null,onBlur:null,onChange:null,errorMessage:``,isValid:!1,isRequired:!1,label:``}}constructor(e){super(e);let{formValidator:t}=e;t&&(t.label=e.label??``,t.validate(),t.registerOnUpdateListener(()=>{this.forceUpdate()})),this.state={isFocused:!1,isHovered:!1},this.onMouseEnter=this.onMouseEnter.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),this.hasError=this.hasError.bind(this),this.renderTooltip=this.renderTooltip.bind(this),this.onChange=this.onChange.bind(this)}componentDidMount(){setTimeout(()=>this.setState({isFocused:!1,isHovered:!1}),1)}componentDidUpdate(e){let{formValidator:t}=this.props;e.formValidator&&t&&e.formValidator!==t&&t.registerOnUpdateListener(()=>{this.forceUpdate()})}onMouseEnter(e){let{onMouseEnter:t}=this.props;this.setState({isHovered:!0}),t&&t(e)}onMouseLeave(e){let{onMouseLeave:t}=this.props;this.setState({isHovered:!1}),t&&t(e)}onFocus(e){let{onFocus:t}=this.props;this.setState({isFocused:!0}),t&&t(e)}onBlur(e){let{formValidator:t,onBlur:n}=this.props;t&&(t.touched=!0),this.setState({isFocused:!1}),n&&n(e)}hasError(){let{errorMessage:e,isValid:t,formValidator:n}=this.props;return n?n.touched&&n.hasError():!t||!!e}isRequired(){let{isRequired:e,formValidator:t}=this.props;return!!(e||t&&t.validators.find(e=>e.validatorId===`required`))}renderTooltip(){let{errorMessage:e,formValidator:t}=this.props,{isHovered:n,isFocused:r}=this.state;return(0,f.jsx)(ve,{variant:`error`,message:t?t.getCurrentErrorMessage():e||``,isVisible:this.hasError()&&(r||n)})}onChange(e){let{onChange:t,formValidator:n}=this.props;if(n){let t=e;e&&e.target&&(t=e.target.value),n.set(t)}t&&t(e)}};function Jn(e){let[,t]=(0,c.useReducer)(e=>e+1,0);return(0,c.useEffect)(()=>{if(e)return e.registerOnUpdateListener(t),()=>e.removeOnUpdateListener(t)},[e]),e}function Yn(e,{initialValues:t,onSubmit:n,onValidate:r,errorParser:i}={}){let[,a]=(0,c.useReducer)(e=>e+1,0),o=(0,c.useRef)(null);o.current||=new Pn(e,null,{initialValues:t,errorParser:i});let s=o.current,l=(0,c.useRef)(n),u=(0,c.useRef)(r);return l.current=n,u.current=r,(0,c.useEffect)(()=>(n!==void 0&&(s.onSubmitCallback=(...e)=>l.current?.(...e)),r!==void 0&&(s.onValidateCallback=(...e)=>u.current?.(...e)),s.registerOnUpdateListener(a),()=>s.removeOnUpdateListener(a)),[]),s}exports.Accordion=E,exports.AccordionStyleType=x,exports.ActionButtons=ne,exports.ActionIcon=ae,exports.Align=me,exports.BodyEnd=B,exports.Button=L,exports.ButtonSize=N,exports.ButtonStyleType=M,exports.ButtonType=P,exports.Card=oe,exports.CardActions=H,exports.CardContent=le,exports.CardHeader=se,exports.CardMedia=ce,exports.Checkbox=ue,exports.Chip=de,exports.ChipContainer=fe,exports.ColorPicker=ke,exports.ConfirmModal=Me,exports.DatePicker=at,exports.Dropdown=rt,exports.EmptyState=st,exports.Fab=dt,exports.FloatingMenu=ge,exports.FormValidator=Fn,exports.FormValidatorGroup=Pn,exports.Icon=mt,exports.IconLoading=Ct,exports.IdleManager=gt,exports.InfiniteBlock=nt,exports.Input=ye,exports.InputType=K,exports.InteractableDiv=z,exports.KanbanBoard=bt,exports.KanbanColumn=yt,exports.Modal=je,exports.NumberInput=Et,exports.OptionPicker=Ot,exports.Overscroll=Mt,exports.ProgressBar=Ft,exports.Ripple=I,exports.RoomDrawer=ln,exports.ScrollbarProvider=fn,exports.SearchInput=mn,exports.SpinnerLoading=j,exports.Stepper=hn,exports.TenorPicker=Cn,exports.Textarea=wn,exports.ThemeProvider=Dn,exports.Tooltip=ve,exports.ValidatableComponent=qn,exports.Validators=Kn,exports.Wizard=An,exports.getLocale=ze,exports.hasEightPasswordChars=Hn,exports.hasOnePasswordDigit=Wn,exports.hasOnePasswordLetter=Un,exports.isBic=Bn,exports.isDate=Ln,exports.isEmail=zn,exports.isISODate=Rn,exports.isNumber=In,exports.isPassword=Gn,exports.isURL=Vn,exports.mapLocale=Ie,exports.setLocale=Re,exports.useFormValidator=Jn,exports.useFormValidatorGroup=Yn,exports.useTheme=On;
|
|
5
|
+
`)}function Zt(e){let t=[];for(let n of e.matchAll(/[ML]\s*([-\d.]+)[,\s]+([-\d.]+)/gi))t.push({x:parseFloat(n[1]),y:parseFloat(n[2])});return t}function Qt(e){let t=new DOMParser().parseFromString(e,`image/svg+xml`),n=[];return t.querySelectorAll(`[id^="room"]`).forEach(e=>{let t=e.querySelector(`[id="background"]`);if(!t)return;let r=t.getAttribute(`d`);if(!r)return;let i=Zt(r);if(i.length<3)return;let a=e.querySelector(`text`)?.textContent?.trim()??``;n.push({id:e.id,name:a,points:i})}),n}function $t(e,t){let n=Xt(e,t),r=new Blob([n],{type:`image/svg+xml`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`room-plan.svg`,a.click(),URL.revokeObjectURL(i)}var Z={roomDrawer:`roomDrawer_SJj4-`,"roomDrawer-toolbar":`roomDrawer-toolbar_55H5p`,roomDrawerToolbar:`roomDrawer-toolbar_55H5p`,"roomDrawer-toolbar-sep":`roomDrawer-toolbar-sep_nJeh8`,roomDrawerToolbarSep:`roomDrawer-toolbar-sep_nJeh8`,"roomDrawer-toolbar-btn":`roomDrawer-toolbar-btn_2qinY`,roomDrawerToolbarBtn:`roomDrawer-toolbar-btn_2qinY`,"roomDrawer-toolbar-btn-active":`roomDrawer-toolbar-btn-active_4XX25`,roomDrawerToolbarBtnActive:`roomDrawer-toolbar-btn-active_4XX25`,"roomDrawer-toolbar-zoomLabel":`roomDrawer-toolbar-zoomLabel_HMkb5`,roomDrawerToolbarZoomLabel:`roomDrawer-toolbar-zoomLabel_HMkb5`,"roomDrawer-canvas":`roomDrawer-canvas_Y18uD`,roomDrawerCanvas:`roomDrawer-canvas_Y18uD`,"roomDrawer-canvas-select":`roomDrawer-canvas-select_M43-x`,roomDrawerCanvasSelect:`roomDrawer-canvas-select_M43-x`,"roomDrawer-info":`roomDrawer-info_qwC6L`,roomDrawerInfo:`roomDrawer-info_qwC6L`,"roomDrawer-info-label":`roomDrawer-info-label_8I9hB`,roomDrawerInfoLabel:`roomDrawer-info-label_8I9hB`,"roomDrawer-info-input":`roomDrawer-info-input_YAl-K`,roomDrawerInfoInput:`roomDrawer-info-input_YAl-K`,"roomDrawer-info-spacer":`roomDrawer-info-spacer_cOj96`,roomDrawerInfoSpacer:`roomDrawer-info-spacer_cOj96`,"roomDrawer-info-delete":`roomDrawer-info-delete_TSBUN`,roomDrawerInfoDelete:`roomDrawer-info-delete_TSBUN`,"roomDrawer-hint":`roomDrawer-hint_3WTFa`,roomDrawerHint:`roomDrawer-hint_3WTFa`,"roomDrawer-info-doorsBtn":`roomDrawer-info-doorsBtn_oK5Uf`,roomDrawerInfoDoorsBtn:`roomDrawer-info-doorsBtn_oK5Uf`,"roomDrawer-doorPanel":`roomDrawer-doorPanel_e-Tl9`,roomDrawerDoorPanel:`roomDrawer-doorPanel_e-Tl9`,"roomDrawer-doorPanel-header":`roomDrawer-doorPanel-header_--iXz`,roomDrawerDoorPanelHeader:`roomDrawer-doorPanel-header_--iXz`,"roomDrawer-doorPanel-icon":`roomDrawer-doorPanel-icon_KxaVY`,roomDrawerDoorPanelIcon:`roomDrawer-doorPanel-icon_KxaVY`,"roomDrawer-doorPanel-title":`roomDrawer-doorPanel-title_8nOZS`,roomDrawerDoorPanelTitle:`roomDrawer-doorPanel-title_8nOZS`,"roomDrawer-doorPanel-done":`roomDrawer-doorPanel-done_ejQkx`,roomDrawerDoorPanelDone:`roomDrawer-doorPanel-done_ejQkx`,"roomDrawer-doorPanel-list":`roomDrawer-doorPanel-list_rDou7`,roomDrawerDoorPanelList:`roomDrawer-doorPanel-list_rDou7`,"roomDrawer-doorPanel-item":`roomDrawer-doorPanel-item_U-3-B`,roomDrawerDoorPanelItem:`roomDrawer-doorPanel-item_U-3-B`,"roomDrawer-doorPanel-label":`roomDrawer-doorPanel-label_qSYqY`,roomDrawerDoorPanelLabel:`roomDrawer-doorPanel-label_qSYqY`,"roomDrawer-doorPanel-widthLabel":`roomDrawer-doorPanel-widthLabel_jXv7D`,roomDrawerDoorPanelWidthLabel:`roomDrawer-doorPanel-widthLabel_jXv7D`,"roomDrawer-doorPanel-empty":`roomDrawer-doorPanel-empty_LcDw0`,roomDrawerDoorPanelEmpty:`roomDrawer-doorPanel-empty_LcDw0`,"roomDrawer-canvas-door":`roomDrawer-canvas-door_qzCIa`,roomDrawerCanvasDoor:`roomDrawer-canvas-door_qzCIa`,doorGap:`doorGap_KrIuB`,doorMarker:`doorMarker_-N63z`,gridLine:`gridLine_V-rxw`,roomFill:`roomFill_JnJ0J`,"roomFill-selected":`roomFill-selected_IfIRr`,roomFillSelected:`roomFill-selected_IfIRr`,roomStroke:`roomStroke_S18UH`,"roomStroke-selected":`roomStroke-selected_fm19u`,roomStrokeSelected:`roomStroke-selected_fm19u`,roomText:`roomText_6fIeU`,doorPanel:`doorPanel_raCv0`,"doorPanel-selected":`doorPanel-selected_5DG7g`,doorPanelSelected:`doorPanel-selected_5DG7g`,doorSwing:`doorSwing_Tbt9D`,"doorSwing-selected":`doorSwing-selected_fFte5`,doorSwingSelected:`doorSwing-selected_fFte5`,preview:`preview_seIZY`,polyCloseTarget:`polyCloseTarget_snjYx`,polyVertex:`polyVertex_fw0nX`,vertexHandle:`vertexHandle_-z7g5`},en=6,tn=5,nn=1.25,rn=.25,an=12,on=0;function sn(e){return on+=1,`${e}${on}`}var cn={select:`Drag inside to move · Drag corner to reshape · Click wall to add corner · Dbl-click corner to remove · Delete to erase`,rect:`Drag to draw a rectangular room`,polygon:`Click to place corners · Click first point or Enter to close · Esc to cancel`};function ln({className:e}){let[t,n]=(0,c.useState)([]),[r,i]=(0,c.useState)([]),[a,o]=(0,c.useState)(`rect`),[s,p]=(0,c.useState)(null),[m,h]=(0,c.useState)(null),[g,_]=(0,c.useState)(null),[v,y]=(0,c.useState)(null),[b,x]=(0,c.useState)([]),[S,C]=(0,c.useState)(null),[w,T]=(0,c.useState)(1),[E,D]=(0,c.useState)({x:0,y:0}),O=(0,c.useRef)(null),k=(0,c.useRef)(null),A=(0,c.useRef)(null),j=(0,c.useRef)(null),M=(0,c.useRef)(null),N=(0,c.useRef)({rooms:t,doors:r,tool:a,selectedId:s,editingDoorsForRoomId:m,polyPoints:b,zoom:w,pan:E});(0,c.useLayoutEffect)(()=>{N.current={rooms:t,doors:r,tool:a,selectedId:s,editingDoorsForRoomId:m,polyPoints:b,zoom:w,pan:E}});function P(e){e.length<3||(n(t=>[...t,{id:sn(`room`),name:`Room ${t.length+1}`,points:e}]),x([]),C(null))}(0,c.useEffect)(()=>{let e=j.current;if(!e)return;function t(e){e.preventDefault();let{zoom:t,pan:n}=N.current,r=Rt(e.clientX,e.clientY,j.current);if(!r)return;let i=e.deltaY<0?nn:1/nn,a=Math.max(rn,Math.min(an,t*i));D({x:r.x-(r.x-n.x)*(t/a),y:r.y-(r.y-n.y)*(t/a)}),T(a)}return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)},[]),(0,c.useEffect)(()=>{function e(e){let{tool:t,selectedId:r,editingDoorsForRoomId:a,polyPoints:o,zoom:s,pan:c}=N.current;if(e.key===`Escape`){if(a){h(null);return}t===`polygon`&&(x([]),C(null)),p(null);return}if(e.key===`Enter`&&t===`polygon`&&o.length>=3){P(o);return}if((e.key===`+`||e.key===`=`)&&!(e.target instanceof HTMLInputElement)){let e=Math.max(rn,Math.min(an,s*nn)),t=c.x+400/s/2,n=c.y+300/s/2;T(e),D({x:t-400/e/2,y:n-300/e/2});return}if(e.key===`-`&&!(e.target instanceof HTMLInputElement)){let e=Math.max(rn,Math.min(an,s/nn)),t=c.x+400/s/2,n=c.y+300/s/2;T(e),D({x:t-400/e/2,y:n-300/e/2});return}if(e.key===`0`&&!(e.target instanceof HTMLInputElement)){T(1),D({x:0,y:0});return}(e.key===`Delete`||e.key===`Backspace`)&&r&&!a&&!(e.target instanceof HTMLInputElement)&&(n(e=>e.filter(e=>e.id!==r)),i(e=>e.filter(e=>e.roomId!==r)),p(null))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);function F(e,t=w,n=E){let r=Math.max(rn,Math.min(an,t*e)),i=n.x+400/t/2,a=n.y+300/t/2;D({x:i-400/r/2,y:a-300/r/2}),T(r)}function I(e){return j.current?Rt(e.clientX,e.clientY,j.current):null}function ee(e,t){let n=null;for(let r=0;r<t.points.length;r++){let i=zt(e,t.points[r]);i<=en&&(!n||i<n.d)&&(n={index:r,d:i})}return n}function te(e,t){let n=null;for(let r=0;r<t.points.length;r++){let i=t.points[r],a=t.points[(r+1)%t.points.length],{dist:o,t:s}=Bt(e,i,a);o<=tn&&(!n||o<n.d)&&(n={index:r,t:s,d:o})}return n}function L(e,t,r,a){return n(n=>n.map(n=>{if(n.id!==e)return n;let r=[...n.points];return r.splice(t+1,0,a),{...n,points:r}})),i(n=>n.map(n=>n.roomId===e?n.wallIndex===t?n.t<=r?{...n,t:r>0?n.t/r:0}:{...n,wallIndex:t+1,t:(n.t-r)/(1-r)}:n.wallIndex>t?{...n,wallIndex:n.wallIndex+1}:n:n)),t+1}function ne(e,r){let a=t.find(t=>t.id===e);if(!a||a.points.length<=3)return;let o=a.points.length;n(t=>t.map(t=>t.id===e?{...t,points:t.points.filter((e,t)=>t!==r)}:t)),i(t=>t.map(t=>{if(t.roomId!==e)return t;let n=(r-1+o)%o;return t.wallIndex===n||t.wallIndex===r?{...t,wallIndex:-1}:t.wallIndex>r?{...t,wallIndex:t.wallIndex-1}:t}).filter(e=>e.wallIndex!==-1))}function R(e){if(e.button===1){e.preventDefault();let t=j.current;if(t){let n=t.getBoundingClientRect();A.current={startClient:{x:e.clientX,y:e.clientY},origPan:{...E},scaleX:400/w/n.width,scaleY:300/w/n.height}}return}if(e.button!==0)return;e.preventDefault();let n=I(e);if(n){if(m){let e=t.find(e=>e.id===m);if(e){let t=Vt(n,[e]);t&&i(e=>[...e,{id:sn(`door`),roomId:t.roomId,wallIndex:t.wallIndex,t:t.t,width:12}])}return}if(a===`rect`){_(n),y(n);return}if(a===`polygon`){b.length>=3&&zt(n,b[0])<=8?P(b):x(e=>[...e,n]);return}if(a===`select`){let e=t.find(e=>e.id===s)??null;if(e){let t=ee(n,e);if(t){O.current={type:`vertex`,roomId:e.id,index:t.index,start:n,origPt:e.points[t.index]};return}}if(e){let t=te(n,e);if(t){let r=e.points[t.index],i=e.points[(t.index+1)%e.points.length],a=Lt({x:r.x+(i.x-r.x)*t.t,y:r.y+(i.y-r.y)*t.t}),o=L(e.id,t.index,t.t,a);O.current={type:`vertex`,roomId:e.id,index:o,start:n,origPt:a};return}}let r=t.find(e=>Ht(n,e.points));if(r){p(r.id),O.current={type:`room`,roomId:r.id,start:n,origPoints:[...r.points]};return}p(null)}}}function re(e){if(a!==`select`||m)return;let n=I(e);if(!n)return;let r=t.find(e=>e.id===s);if(!r)return;let i=ee(n,r);i&&(e.preventDefault(),ne(r.id,i.index))}function z(e){if(A.current){let{startClient:t,origPan:n,scaleX:r,scaleY:i}=A.current;D({x:n.x-(e.clientX-t.x)*r,y:n.y-(e.clientY-t.y)*i});return}let r=I(e);if(r){if(k.current&&m){let e=t.find(e=>e.id===m);if(e){let t=Vt(r,[e]);t&&i(e=>e.map(e=>e.id===k.current?{...e,wallIndex:t.wallIndex,t:t.t}:e))}return}if(a===`rect`&&g){y(r);return}if(a===`polygon`){C(r);return}if(a===`select`&&!m&&O.current){let e=O.current;if(e.type===`vertex`){let t=r.x-e.start.x,i=r.y-e.start.y,a=Lt({x:e.origPt.x+t,y:e.origPt.y+i});n(t=>t.map(t=>{if(t.id!==e.roomId)return t;let n=[...t.points];return n[e.index]=a,{...t,points:n}}))}else{let t=r.x-e.start.x,i=r.y-e.start.y;n(n=>n.map(n=>n.id===e.roomId?{...n,points:e.origPoints.map(e=>({x:e.x+t,y:e.y+i}))}:n))}}}}function ie(e){if(A.current){A.current=null;return}let t=I(e);if(t){if(a===`rect`&&g){let e=Math.min(g.x,t.x),r=Math.min(g.y,t.y),i=Math.abs(t.x-g.x),a=Math.abs(t.y-g.y);i>=10&&a>=10&&n(t=>[...t,{id:sn(`room`),name:`Room ${t.length+1}`,points:Wt(e,r,i,a)}]),_(null),y(null)}k.current=null,O.current=null}}function ae(e){s&&n(t=>t.map(t=>t.id===s?{...t,name:e}:t))}function B(e,t){let n=parseFloat(t);isNaN(n)||n<=0||i(t=>t.map(t=>t.id===e?{...t,width:n}:t))}function V(){s&&(n(e=>e.filter(e=>e.id!==s)),i(e=>e.filter(e=>e.roomId!==s)),h(null),p(null))}function oe(e){i(t=>t.filter(t=>t.id!==e))}function se(e){o(e),h(null),x([]),C(null),_(null),y(null)}function ce(e){let t=e.target.files?.[0];if(!t)return;e.target.value=``;let r=new FileReader;r.onload=e=>{let t=e.target?.result;if(typeof t!=`string`)return;let r=Qt(t);r.length!==0&&(n(r.map(e=>({...e,id:sn(`room`)}))),i([]),p(null),h(null),T(1),D({x:0,y:0}))},r.readAsText(t)}let le=a===`rect`&&g&&v?{x:Math.min(g.x,v.x),y:Math.min(g.y,v.y),w:Math.abs(v.x-g.x),h:Math.abs(v.y-g.y)}:null,H=s?t.find(e=>e.id===s)??null:null,U=m?t.find(e=>e.id===m)??null:null,ue=m?r.filter(e=>e.roomId===m):[],W=[{t:`select`,icon:d.faHandPointer,label:`Select & edit`},{t:`rect`,icon:d.faSquare,label:`Rectangle room`},{t:`polygon`,icon:d.faDrawPolygon,label:`Polygon room`}],de=400/w,fe=300/w,pe=m?Z.roomDrawerCanvasDoor:a===`select`?Z.roomDrawerCanvasSelect:void 0;return(0,f.jsxs)(`div`,{className:(0,l.default)(Z.roomDrawer,e),children:[(0,f.jsxs)(`div`,{className:Z.roomDrawerToolbar,children:[W.map(({t:e,icon:t,label:n})=>(0,f.jsx)(`button`,{title:n,className:(0,l.default)(Z.roomDrawerToolbarBtn,e===a&&!m&&Z.roomDrawerToolbarBtnActive),onClick:()=>se(e),children:(0,f.jsx)(u.FontAwesomeIcon,{icon:t})},e)),(0,f.jsx)(`div`,{className:Z.roomDrawerToolbarSep}),(0,f.jsx)(`button`,{title:`Zoom in (+)`,className:Z.roomDrawerToolbarBtn,onClick:()=>F(nn),disabled:w>=an,children:(0,f.jsx)(u.FontAwesomeIcon,{icon:d.faMagnifyingGlassPlus})}),(0,f.jsxs)(`button`,{title:`Reset zoom (0) — ${Math.round(w*100)}%`,className:Z.roomDrawerToolbarZoomLabel,onClick:()=>{T(1),D({x:0,y:0})},children:[Math.round(w*100),`%`]}),(0,f.jsx)(`button`,{title:`Zoom out (−)`,className:Z.roomDrawerToolbarBtn,onClick:()=>F(1/nn),disabled:w<=rn,children:(0,f.jsx)(u.FontAwesomeIcon,{icon:d.faMagnifyingGlassMinus})}),(0,f.jsx)(`div`,{className:Z.roomDrawerToolbarSep}),(0,f.jsx)(`button`,{title:`Upload SVG`,className:Z.roomDrawerToolbarBtn,onClick:()=>M.current?.click(),children:(0,f.jsx)(u.FontAwesomeIcon,{icon:d.faUpload})}),(0,f.jsx)(`button`,{title:`Download SVG`,className:Z.roomDrawerToolbarBtn,onClick:()=>$t(t,r),disabled:t.length===0,children:(0,f.jsx)(u.FontAwesomeIcon,{icon:d.faDownload})}),(0,f.jsx)(`input`,{ref:M,type:`file`,accept:`.svg,image/svg+xml`,style:{display:`none`},onChange:ce})]}),(0,f.jsxs)(`svg`,{ref:j,className:(0,l.default)(Z.roomDrawerCanvas,pe),viewBox:`${E.x} ${E.y} ${de} ${fe}`,onMouseDown:R,onMouseMove:z,onMouseUp:ie,onDoubleClick:re,children:[(0,f.jsx)(`defs`,{children:(0,f.jsx)(`pattern`,{id:`rd-grid`,width:5,height:5,patternUnits:`userSpaceOnUse`,children:(0,f.jsx)(`path`,{d:`M 5 0 L 0 0 0 5`,fill:`none`,className:Z.gridLine})})}),(0,f.jsx)(`rect`,{x:E.x,y:E.y,width:de,height:fe,fill:`url(#rd-grid)`}),t.map(e=>{let t=e.points,n=t.map((e,t)=>`${t===0?`M`:`L`} ${e.x},${e.y}`).join(` `)+` Z`,i=Jt(t,r.filter(t=>t.roomId===e.id)),a=Ut(t),o=s===e.id,c=m===e.id;return(0,f.jsxs)(`g`,{children:[(0,f.jsx)(`path`,{d:n,className:(0,l.default)(Z.roomFill,(o||c)&&Z.roomFillSelected)}),i.map((e,t)=>(0,f.jsx)(`path`,{d:e,className:(0,l.default)(Z.roomStroke,(o||c)&&Z.roomStrokeSelected)},t)),e.name&&(0,f.jsx)(`text`,{x:a.x,y:a.y,className:Z.roomText,textAnchor:`middle`,dominantBaseline:`middle`,children:e.name})]},e.id)}),r.map(e=>{let n=t.find(t=>t.id===e.roomId);if(!n)return null;let r=n.points[e.wallIndex],i=n.points[(e.wallIndex+1)%n.points.length],a=Gt(r,i,e.t,e.width);return a?(0,f.jsx)(`line`,{x1:a.p1.x,y1:a.p1.y,x2:a.p2.x,y2:a.p2.y,className:Z.doorGap},e.id):null}),m&&ue.map(e=>{let n=t.find(t=>t.id===e.roomId);if(!n)return null;let r=n.points[e.wallIndex],i=n.points[(e.wallIndex+1)%n.points.length],a=Gt(r,i,e.t,e.width);if(!a)return null;let o={x:(a.p1.x+a.p2.x)/2,y:(a.p1.y+a.p2.y)/2};return(0,f.jsx)(`circle`,{cx:o.x,cy:o.y,r:2.5,className:Z.doorMarker,onMouseDown:t=>{t.button===0&&(t.preventDefault(),t.stopPropagation(),k.current=e.id)}},e.id)}),a===`select`&&!m&&H&&H.points.map((e,t)=>(0,f.jsx)(`circle`,{cx:e.x,cy:e.y,r:3.5,className:Z.vertexHandle},t)),le&&(0,f.jsx)(`rect`,{x:le.x,y:le.y,width:le.w,height:le.h,className:Z.preview}),a===`polygon`&&b.length>0&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`polyline`,{points:[...b,S??b[b.length-1]].map(e=>`${e.x},${e.y}`).join(` `),className:Z.preview}),b.length>=3&&(0,f.jsx)(`circle`,{cx:b[0].x,cy:b[0].y,r:8/2,className:Z.polyCloseTarget}),b.map((e,t)=>(0,f.jsx)(`circle`,{cx:e.x,cy:e.y,r:2,className:Z.polyVertex},t))]})]}),H&&!m&&(0,f.jsxs)(`div`,{className:Z.roomDrawerInfo,children:[(0,f.jsx)(`span`,{className:Z.roomDrawerInfoLabel,children:`Name`}),(0,f.jsx)(`input`,{className:Z.roomDrawerInfoInput,value:H.name,onChange:e=>ae(e.target.value),placeholder:`Room name`}),(0,f.jsxs)(`button`,{className:Z.roomDrawerInfoDoorsBtn,onClick:()=>h(H.id),title:`Edit doors`,children:[(0,f.jsx)(u.FontAwesomeIcon,{icon:d.faDoorOpen}),(0,f.jsx)(`span`,{children:r.filter(e=>e.roomId===H.id).length})]}),(0,f.jsx)(`button`,{className:Z.roomDrawerInfoDelete,onClick:V,title:`Delete room`,children:(0,f.jsx)(u.FontAwesomeIcon,{icon:d.faTrash})})]}),m&&U&&(0,f.jsxs)(`div`,{className:Z.roomDrawerDoorPanel,children:[(0,f.jsxs)(`div`,{className:Z.roomDrawerDoorPanelHeader,children:[(0,f.jsx)(u.FontAwesomeIcon,{icon:d.faDoorOpen,className:Z.roomDrawerDoorPanelIcon}),(0,f.jsx)(`span`,{className:Z.roomDrawerDoorPanelTitle,children:U.name?`Doors · ${U.name}`:`Doors`}),(0,f.jsxs)(`button`,{className:Z.roomDrawerDoorPanelDone,onClick:()=>h(null),title:`Done (Esc)`,children:[(0,f.jsx)(u.FontAwesomeIcon,{icon:d.faCheck}),`Done`]})]}),(0,f.jsxs)(`div`,{className:Z.roomDrawerDoorPanelList,children:[ue.length===0&&(0,f.jsx)(`span`,{className:Z.roomDrawerDoorPanelEmpty,children:`Click on a wall to add a door`}),ue.map((e,t)=>(0,f.jsxs)(`div`,{className:Z.roomDrawerDoorPanelItem,children:[(0,f.jsxs)(`span`,{className:Z.roomDrawerDoorPanelLabel,children:[`Door `,t+1]}),(0,f.jsx)(`span`,{className:Z.roomDrawerDoorPanelWidthLabel,children:`Width`}),(0,f.jsx)(`input`,{className:Z.roomDrawerInfoInput,type:`number`,min:1,value:e.width,onChange:t=>B(e.id,t.target.value)}),(0,f.jsx)(`button`,{className:Z.roomDrawerInfoDelete,onClick:()=>oe(e.id),title:`Delete door`,children:(0,f.jsx)(u.FontAwesomeIcon,{icon:d.faTrash})})]},e.id))]})]}),(0,f.jsx)(`div`,{className:Z.roomDrawerHint,children:m?`Click a wall to add a door · Adjust width or delete from the list · Done or Esc to finish`:`${cn[a]} · Scroll to zoom · Middle-drag to pan · 0 to reset`})]})}var un={scrollbarProvider:`scrollbarProvider_IMBFu`};function dn({className:e=void 0,children:t=void 0}){return(0,f.jsx)(`div`,{className:(0,l.default)(un.scrollbarProvider,e),children:t})}var fn=dn,pn={resultCount:`resultCount_Sn48Q`};function mn({value:e,onChange:t,onDebounce:n,placeholder:r,label:i,debounceMs:a=500,totalAmount:o,showAmount:s=!0,className:l,width:u,...d}){let p=(0,c.useRef)(null);(0,c.useEffect)(()=>()=>{p.current!==null&&clearTimeout(p.current)},[]);function m(e){let r=e==null?``:String(e),i=r.trim()===``?``:r;t(i),p.current!==null&&clearTimeout(p.current),p.current=setTimeout(()=>{n?.(i)},a)}let h=s&&typeof o==`number`&&!Number.isNaN(o);return(0,f.jsxs)(`div`,{...d,className:l,style:u==null?void 0:{width:u},children:[(0,f.jsx)(ye,{type:K.Search,label:i,placeholder:r,value:e,onChange:m}),h&&(0,f.jsxs)(`p`,{className:pn.resultCount,children:[o,` `,o===1?`result`:`results`]})]})}var Q={stepper:`stepper_kiS2A`,"stepper-clickable":`stepper-clickable_Nm6fP`,stepperClickable:`stepper-clickable_Nm6fP`,"stepper-vertical":`stepper-vertical_2y9rg`,stepperVertical:`stepper-vertical_2y9rg`,"stepper-connector":`stepper-connector_J2FwZ`,stepperConnector:`stepper-connector_J2FwZ`,"stepper-connector-vertical":`stepper-connector-vertical_vwY38`,stepperConnectorVertical:`stepper-connector-vertical_vwY38`,"stepper-connector-filled":`stepper-connector-filled_W8UZS`,stepperConnectorFilled:`stepper-connector-filled_W8UZS`,"stepper-entry":`stepper-entry_KD4JJ`,stepperEntry:`stepper-entry_KD4JJ`,"stepper-entry-active":`stepper-entry-active_V1aRt`,stepperEntryActive:`stepper-entry-active_V1aRt`,"stepper-entry-done":`stepper-entry-done_M3wb5`,stepperEntryDone:`stepper-entry-done_M3wb5`,"stepper-entry-number":`stepper-entry-number_J168Q`,stepperEntryNumber:`stepper-entry-number_J168Q`,"stepper-entry-number-done":`stepper-entry-number-done_-m7sD`,stepperEntryNumberDone:`stepper-entry-number-done_-m7sD`,showCheckmark:`showCheckmark_Rd0oW`,"stepper-entry-label":`stepper-entry-label_b94eg`,stepperEntryLabel:`stepper-entry-label_b94eg`,"stepper-entry-label-vertical":`stepper-entry-label-vertical_Zm8i4`,stepperEntryLabelVertical:`stepper-entry-label-vertical_Zm8i4`},hn=class e extends c.Component{static alignments={VERTICAL:`vertical`,HORIZONTAL:`horizontal`};static propTypes={steps:g.default.arrayOf(g.default.shape({})),currentStep:g.default.number,alignment:g.default.oneOf([e.alignments.HORIZONTAL,e.alignments.VERTICAL]),onStepClicked:g.default.func};static defaultProps={steps:[],currentStep:0,alignment:e.alignments.HORIZONTAL,onStepClicked:null};constructor(e){super(e)}state={};renderCheckmark=()=>(0,f.jsx)(`svg`,{strokeLinejoin:`round`,strokeLinecap:`round`,xmlns:`http://www.w3.org/2000/svg`,viewBox:`-0.2 -1.2 3.4 2`,height:`20px`,width:`20px`,children:(0,f.jsx)(`path`,{d:`M 0 0 l 1 1 l 2 -2`,stroke:`white`,strokeWidth:`0.4`,fill:`none`})});renderStep=(t,n)=>{let{steps:r,currentStep:i,alignment:a,onStepClicked:o}=this.props;return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`div`,{className:(0,l.default)(Q.stepperEntry,{[Q.stepperEntryActive]:n<=i,[Q.stepperEntryDone]:n<i,[Q.stepperClickable]:n<i&&o}),onClick:()=>o?o(n):null,children:[(0,f.jsx)(`div`,{className:(0,l.default)(Q.stepperEntryNumber,{[Q.stepperEntryNumberDone]:n<i}),children:n>=i?n+1:this.renderCheckmark()}),(0,f.jsx)(`div`,{className:(0,l.default)(Q.stepperEntryLabel,{[Q.stepperEntryLabelVertical]:a===e.alignments.VERTICAL}),children:t.label})]}),r.length-1>n&&(0,f.jsx)(`div`,{className:(0,l.default)(Q.stepperConnector,{[Q.stepperConnectorFilled]:n<i,[Q.stepperConnectorVertical]:a===e.alignments.VERTICAL})})]})};render(){let{steps:t,alignment:n}=this.props;return(0,f.jsx)(`div`,{className:(0,l.default)(Q.stepper,{[Q.stepperVertical]:n===e.alignments.VERTICAL}),children:t.map(this.renderStep)})}},gn=`https://tenor.googleapis.com/v2`,_n=class{constructor(e){this.key=e}async search(e,t={}){let n=new URLSearchParams({q:e,key:this.key});return t.limit!=null&&n.set(`limit`,String(t.limit)),t.contentfilter!=null&&n.set(`contentfilter`,t.contentfilter),t.pos!=null&&n.set(`pos`,t.pos),(await fetch(`${gn}/search?${n}`)).json()}async searchSuggestions(e){let t=new URLSearchParams({q:e,key:this.key});return(await fetch(`${gn}/search_suggestions?${t}`)).json()}registerShare(e,t){let n=new URLSearchParams({id:t,q:e,key:this.key});fetch(`${gn}/registershare?${n}`).catch(()=>null)}},vn={gifPreview:`gifPreview_-ECUZ`,"gifPreview-image":`gifPreview-image_Aq7-a`,gifPreviewImage:`gifPreview-image_Aq7-a`,"gifPreview-image-container":`gifPreview-image-container_ycypL`,gifPreviewImageContainer:`gifPreview-image-container_ycypL`,gradientBottomLeftToTopRight:`gradientBottomLeftToTopRight_wo6HB`};function yn({className:e,previewItems:t=[],onSelect:n,onLoadAdditional:r}){function i(e){let t=e.currentTarget,n=t.scrollHeight-t.clientHeight*1.5;t.scrollTop>=n&&r?.()}return(0,f.jsx)(f.Fragment,{children:t.length>0&&(0,f.jsx)(`div`,{className:(0,l.default)(vn.gifPreview,e),onScroll:i,children:t.map((e,t)=>(0,f.jsx)(z,{className:vn.gifPreviewImageContainer,onClick:()=>n?.(e),children:(0,f.jsx)(`div`,{className:vn.gifPreviewImage,style:{backgroundImage:`url(${e.media_formats.tinygif.url})`}})},`${e.id}_${t}`))})})}var bn={gifView:`gifView_Fa2zj`,"gifView-loading":`gifView-loading_LfNJr`,gifViewLoading:`gifView-loading_LfNJr`,gradientBottomLeftToTopRight:`gradientBottomLeftToTopRight_JR6aS`};function xn({className:e,src:t=``}){let[n,r]=(0,c.useState)(!0);return(0,c.useEffect)(()=>{r(!0)},[t]),(0,f.jsxs)(`div`,{className:(0,l.default)(bn.gifView,e),children:[(0,f.jsx)(`img`,{className:bn.tenorPickerSelected,src:t,onLoad:()=>r(!1)}),n&&(0,f.jsx)(`div`,{className:bn.gifViewLoading})]})}var Sn={"tenorPicker-selected":`tenorPicker-selected_IfR2z`,tenorPickerSelected:`tenorPicker-selected_IfR2z`,"tenorPicker-modal-content":`tenorPicker-modal-content_Vkolf`,tenorPickerModalContent:`tenorPicker-modal-content_Vkolf`,"tenorPicker-suggestions-container":`tenorPicker-suggestions-container_kJCj5`,tenorPickerSuggestionsContainer:`tenorPicker-suggestions-container_kJCj5`,"tenorPicker-suggestions-item":`tenorPicker-suggestions-item_Rl99M`,tenorPickerSuggestionsItem:`tenorPicker-suggestions-item_Rl99M`};function Cn({className:e,token:t=``,isModal:n=!1,onSelect:r=()=>void 0,selected:i=null}){let a=(0,c.useMemo)(()=>new _n(t),[t]),[o,s]=(0,c.useState)(``),[u,d]=(0,c.useState)([]),[p,m]=(0,c.useState)([]),[h,g]=(0,c.useState)(null),[_,v]=(0,c.useState)(!1);async function y(e){if(s(e),!e.trim()){d([]),m([]),g(null);return}let[{results:t=[],next:n=null},{results:r=[]}]=await Promise.all([a.search(e,{limit:18,contentfilter:`medium`}),a.searchSuggestions(e)]);d(t),g(n),m(r)}async function b(){let{results:e=[],next:t=null}=await a.search(o,{limit:36,pos:h??void 0,contentfilter:`medium`});g(t),d(t=>[...t,...e])}async function x(e){await r(e),v(!1),e&&a.registerShare(o,e.id)}function S(){return(0,f.jsx)(fe,{inline:!0,className:Sn.tenorPickerSuggestionsContainer,children:p.map(e=>(0,f.jsx)(de,{className:Sn.tenorPickerSuggestionsItem,text:e,onClick:()=>y(e)},e))})}function C(){return(0,f.jsx)(yn,{previewItems:u,onSelect:x,onLoadAdditional:b})}function w(){return(0,f.jsx)(mn,{label:`Pick gif`,value:o,onDebounce:y,onChange:s})}return n?(0,f.jsxs)(`div`,{className:(0,l.default)(Sn.tenorPicker,e),children:[(0,f.jsxs)(`div`,{className:D.actionButtons,children:[(0,f.jsx)(L,{onClick:()=>v(!0),children:`Pick gif`}),i&&(0,f.jsx)(L,{styleType:M.Delete,onClick:()=>x(null),children:`Remove gif`})]}),i&&(0,f.jsx)(xn,{className:Sn.tenorPickerSelected,src:i}),(0,f.jsx)(je,{isOpen:_,onClose:()=>v(!1),children:(0,f.jsxs)(`div`,{className:Sn.tenorPickerModalContent,children:[w(),S(),C()]})})]}):(0,f.jsxs)(`div`,{className:(0,l.default)(Sn.tenorPicker,e),children:[(0,f.jsx)(ge,{align:me.Left,isOpen:u.length>0&&_,onOpenChange:v,content:(0,f.jsxs)(f.Fragment,{children:[S(),C()]}),children:w()}),i&&(0,f.jsx)(L,{styleType:M.Delete,onClick:()=>x(null),children:`Remove gif`}),i&&(0,f.jsx)(xn,{className:Sn.tenorPickerSelected,src:i})]})}function wn(e){return(0,f.jsx)(ye,{...e,multiline:!0})}var Tn={id:`default`,variables:{"--grey":`#8A8A8A`,"--lightgrey":`#e0e0e0`,"--lightergrey":`#B1B1B1`,"--white":`#FFFFFF`,"--red":`#D6002A`,"--lighter-red":`#ffeae9`,"--green":`#287626`,"--lighter-green":`#C4FFC9`,"--blue":`#5873d5`,"--lighter-blue":`#C6DBFF`,"--black":`black`,"--orange":`#ff7f50`,"--lighter-orange":`#ffe5d9`,"--primary-color":`#8184d6`,"--primary-accent":`#90CAF9`,"--primary-lighter":`#9a9ce4`,"--accent-color":`var(--grey)`,"--accent-color-light":`var(--lightgrey)`,"--text-color":`var(--white)`,"--text-dark":`var(--lightergrey)`,"--text-light":`var(--lightergrey)`,"--text-on-primary":`var(--white)`,"--text-on-delete":`var(--white)`,"--border-color":`#656574`,"--background":`#393945`,"--background-accent":`#33333c`,"--background-accent-dark":`var(--grey)`,"--background-accent-light":`#484856`,"--background-modal":`#484856`,"--success-color":`var(--green)`,"--success-lighter":`var(--lighter-green)`,"--error-color":`var(--red)`,"--error-lighter":`var(--lighter-red)`,"--info-color":`var(--blue)`,"--info-lighter":`var(--lighter-blue)`,"--warn-color":`var(--orange)`,"--warn-lighter":`var(--lighter-orange)`,"--default-font-size":`14px`,"--text-small-font-size":`12px`,"--header-font-size":`24px`,"--header-medium-font-size":`18px`,"--header-small-font-size":`16px`,"--default-font-weight":`400`,"--header-font-weight":`600`,"--input-background":`transparent`,"--input-icon-color":`var(--text-color)`,"--error-border-color":`var(--red)`,"--default-border-radius":`8px`,"--padding-sides":`15px`,"--margin-top":`10px`,"--default-font":`'Inter', sans-serif`,"--themed-font":`'Inter', sans-serif`,"--card-shadow":`0 3px 1px -2px rgb(0 0 0 / 20%), 0 2px 2px 0 rgb(0 0 0 / 14%), 0 1px 5px 0 rgb(0 0 0 / 12%)`,"--spacing-s":`4px`,"--spacing-m":`8px`,"--spacing-l":`16px`}},En={colorFade:`colorFade_eLv2g`},Dn=class extends c.Component{constructor(...e){super(...e),this.state={resolvedVariables:{},colorFadeActive:!1,currentThemeColor:null},this.colorFadeTimeout=null,this.wrapperRef=c.default.createRef(),this.themeColorMeta=null,this.createdThemeColorMeta=!1,this.applyTheme=e=>{let t=this.props.themes??[Tn],n=t.find(e=>!e.baseThemeId)??t[0],r=n?n.variables:{},i=t.find(t=>t.id===e),a=i?this.resolveChain(i.id):[],o=Object.assign({},r,...a);this.setState({resolvedVariables:o,colorFadeActive:!0}),this.colorFadeTimeout&&clearTimeout(this.colorFadeTimeout),this.colorFadeTimeout=setTimeout(()=>{this.setState({colorFadeActive:!1}),this.colorFadeTimeout=null},500),setTimeout(()=>{this.wrapperRef.current&&this.setState({currentThemeColor:getComputedStyle(this.wrapperRef.current).getPropertyValue(`--primary-color`).trim()})},1)}}componentDidMount(){this.applyTheme(this.props.currentThemeId),this.syncThemeColorMeta(this.state.currentThemeColor??``)}componentDidUpdate(e,t){t.currentThemeColor!==this.state.currentThemeColor&&this.syncThemeColorMeta(this.state.currentThemeColor??``),(e.currentThemeId!==this.props.currentThemeId||e.themes!==this.props.themes)&&this.applyTheme(this.props.currentThemeId)}componentWillUnmount(){this.colorFadeTimeout&&clearTimeout(this.colorFadeTimeout),this.createdThemeColorMeta&&this.themeColorMeta?.remove()}syncThemeColorMeta(e){if(!(typeof document>`u`)){if(!this.themeColorMeta){let e=document.head.querySelector(`meta[name="theme-color"]`);if(e)this.themeColorMeta=e;else{let e=document.createElement(`meta`);e.setAttribute(`name`,`theme-color`),document.head.appendChild(e),this.themeColorMeta=e,this.createdThemeColorMeta=!0}}this.themeColorMeta.setAttribute(`content`,e)}}resolveChain(e){let t=(this.props.themes??[Tn]).find(t=>t.id===e);return t?[...t.baseThemeId?this.resolveChain(t.baseThemeId):[],t.variables]:[]}render(){let{children:e}=this.props,{resolvedVariables:t,colorFadeActive:n}=this.state;return(0,f.jsx)(`div`,{ref:this.wrapperRef,id:`themeProvider`,className:n?En.colorFade:void 0,style:t,children:e})}};function On(e=`default`){let[t,n]=(0,c.useState)(localStorage.getItem(`theme`)||e);return{currentThemeId:t,setCurrentThemeId:e=>{n(e),localStorage.setItem(`theme`,e)}}}var kn={wizard:`wizard_uRBAN`,"wizard-content":`wizard-content_lcl4C`,wizardContent:`wizard-content_lcl4C`,"wizard-content-outOfFrame":`wizard-content-outOfFrame_Eks4Y`,wizardContentOutOfFrame:`wizard-content-outOfFrame_Eks4Y`,"wizard-content-container":`wizard-content-container_yxbCJ`,wizardContentContainer:`wizard-content-container_yxbCJ`},An=class extends c.Component{static propTypes={currentStep:g.default.number,stepCount:g.default.number,renderStep:g.default.func,className:g.default.string};static defaultProps={currentStep:0,stepCount:0,renderStep:()=>null,className:``};constructor(e){super(e)}state={height:void 0,showOtherContent:!1,minRenderStep:0,maxRenderStep:0};componentDidUpdate(e){let{currentStep:t}=this.props,{currentStep:n}=e;t!==n&&(this.hideContentTimeout&&clearTimeout(this.hideContentTimeout),this.setState({showOtherContent:!0}),this.hideContentTimeout=setTimeout(()=>{this.setState({showOtherContent:!1}),this.hideContentTimeout=null},400))}updateCurrentRef=(e,t)=>{let{currentStep:n}=this.props,{height:r}=this.state;e&&n===t&&r!==e.clientHeight&&this.setState({height:e.clientHeight})};render(){let{renderStep:e,currentStep:t,stepCount:n,className:r}=this.props,{height:i,showOtherContent:a}=this.state,o=i===void 0?{}:{height:`${i}px`};return(0,f.jsx)(`div`,{className:(0,l.default)((0,l.default)(kn.wizard,r)),style:o,children:(0,f.jsx)(`div`,{className:kn.wizardContentContainer,style:{width:`${n*100}%`,marginLeft:`-${t*100}%`},children:Array.from(Array(n),()=>null).map((r,i)=>(0,f.jsx)(`div`,{ref:e=>this.updateCurrentRef(e,i),className:kn.wizardContent,style:{width:`${100/n}%`,marginLeft:`${100/n*i}%`},children:(0,f.jsx)(`div`,{className:(0,l.default)({[kn.wizardContentOutOfFrame]:t!==i&&!a}),children:e(i)})},`wizardContent${i}`))})})}},jn=null;function Mn(e,t){if(!jn){console.error(`[Toast] No ToastProvider found. Wrap your app with <ToastProvider>.`);return}jn(e,t)}function Nn(e){let t=e;return t?.errors&&Array.isArray(t.errors)?t.errors.flatMap(e=>Object.entries(e).map(([e,t])=>({id:e,message:t}))):[]}var Pn=class{#e;#t;#n;#r;#i;constructor(e,t=null,{initialValues:n,onSubmit:r=()=>void 0,onValidate:i=()=>void 0,errorParser:a=Nn,onSubmitError:o=()=>void 0}={}){this.#t=!1,this.#i=[],this.getFormError=()=>{let e=Object.keys(this.group);for(let t=0;t<e.length;t+=1){let n=e[t];if(this.group[n].errors.length>0)return this.group[n].errors[0]}return null},this.set=(e,t)=>(this.group[e].set(t),this),this.reset=(e={})=>{this.submitCount=0;let t=Object.keys(e);Object.keys(this.group).forEach(n=>{this.group[n].set(t.includes(n)?e[n]:this.#r[n],!1)}),this.resetDirtyAndTouched(),this.onReset&&this.onReset(this,this.#r,this.#e)},this.resetDirtyAndTouched=()=>{Object.keys(this.group).forEach(e=>{this.group[e].dirty=!1,this.group[e].touched=!1})},this.parseError=(e,t=!1)=>{let n=this.errorParser(e);n.length>0?(n.forEach(({id:e,message:t})=>{this.group[e]&&this.group[e].addError({id:e,message:t})}),t&&this.onSubmitError(n)):this.onSubmitError([{id:`generic`,message:`An error occurred`}])},this.#a=()=>{this.component&&this.component.forceUpdate(),this.#i.forEach(e=>e())},this.registerOnUpdateListener=e=>{this.#i.push(e)},this.removeOnUpdateListener=e=>{this.#i.splice(this.#i.indexOf(e),1)},this.setSubmitting=e=>{this.#t!==e&&(this.#t=e,this.#a())},this.submit=async e=>{e&&(e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation()),this.setSubmitting(!0);let t=null;this.submitCount===0?t=await Promise.resolve(this.validate()):this.onValidateCallback&&(t=await Promise.resolve(this.onValidateCallback(this)));let n=this.getFormError()||t;if(n){this.setSubmitting(!1),this.submitCount>-1&&this.onSubmitError([n]),this.submitCount+=1,this.#a();return}try{await this.onSubmitCallback(this.getValues(),this),this.resetDirtyAndTouched()}catch(e){this.parseError(e,!0)}this.setSubmitting(!1),this.#a(),this.submitCount+=1},this.getValues=()=>{let e={};return Object.keys(this.group).forEach(t=>{e[t]=this.group[t].value}),{...this.#e,...e}},this.validate=()=>{if(Object.keys(this.group).forEach(e=>{this.group[e].validate(),this.group[e].touched=!0}),this.onValidateCallback)return this.onValidateCallback(this)},this.setValidator=(e,t)=>(this.group[e]=t,this),this.group=e,this.#e=n??{},this.#r={},this.submitCount=0,this.onDebounce=()=>{},this.onReset=()=>{},Object.keys(this.group).forEach(e=>{let t=this.group[e],n=this.#e;n[e]!==void 0&&t.set(n[e]),this.#r[e]=t.value,this.group[e].registerOnUpdateListener(()=>{this.#a(),this.submitCount=0,this.#n&&clearTimeout(this.#n),this.#n=setTimeout(()=>this.onDebounce(this.getValues()),500)})}),this.component=t,this.onSubmitCallback=r,this.onValidateCallback=i,this.errorParser=a,this.onSubmitError=o,this.setSubmitting(!1)}get isSubmitting(){return this.#t}get wasTouched(){return Object.keys(this.group).some(e=>this.group[e].touched)}get isDirty(){return Object.keys(this.group).some(e=>this.group[e].dirty)}get hasErrors(){return Object.keys(this.group).some(e=>this.group[e].errors.length>0)}get initialValues(){return{...this.#e}}#a};function Fn(e){return function({children:t,...n}){return(0,f.jsx)(`form`,{onSubmit:e.submit,noValidate:!0,...n,children:t})}}var In=e=>{Mn(e[0].message,{type:`error`})},Ln=class extends Pn{constructor(e,t=null,n){super(e,t,{...n,onSubmitError:n?.onSubmitError??In}),this.Form=Fn(this)}},Rn=class{#e;#t;#n;#r;#i;constructor(e,t){this.addError=e=>{this.#r.push(e),this.onUpdate()},this.removeErrors=e=>{this.#r=this.#r.filter(t=>!e.includes(t.id)),this.onUpdate()},this.clearErrors=()=>{this.#r=[],this.onUpdate()},this.hasError=e=>!e&&this.errors.length>0?!0:!!this.errors.find(t=>t.id===e),this.getCurrentErrorMessage=()=>this.errors.length===0?null:this.errors[0].message,this.validate=()=>{this.clearErrors(),this.validators.forEach(e=>{let t=e(this.value,this.label);t&&this.addError(t)})},this.onUpdate=()=>{this.onUpdateCallbacks.forEach(e=>e(this))},this.registerOnUpdateListener=e=>{this.onUpdateCallbacks.push(e)},this.removeOnUpdateListener=e=>{this.onUpdateCallbacks.splice(this.onUpdateCallbacks.indexOf(e),1)},this.set=(e,t=!0)=>(this.value=e,t&&!this.dirty&&(this.dirty=!0),this.validate(),this),this.#e=e,this.validators=t??[],this.#t=!1,this.#n=!1,this.#r=[],this.#i=``,this.onUpdateCallbacks=[],this.validate()}get touched(){return this.#t}set touched(e){this.#t=e,this.onUpdate()}get label(){return this.#i}set label(e){this.#i=e}get dirty(){return this.#n}set dirty(e){this.#n=e,this.onUpdate()}get value(){return this.#e}set value(e){this.#e=e,this.onUpdate()}get errors(){return this.#r}};Rn.prototype.toString=function(){return`${this.value}`};function zn(e){return/^[0-9]+$/.test(e)}function Bn(e){return/^[0-9]{2}.[0-9]{2}.[0-9]{4}$/.test(e)}function Vn(e){return/^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{3}Z$/.test(e)}function Hn(e){return/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-ZöäüÜÖÄß\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e)}function Un(e){return/^[A-Z]{6}[A-Z\d]{2}([A-Z\d]{3})?$/.test(e)}function Wn(e){return/[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,63}(\/[-a-zA-Z0-9@:%_+.~#?&//=]*)?$/.test(e)}function Gn(e){return/^[\w!@#$%^&*?±§~`'"/\\[\]{}\-,.();:><+=|öäüÖÄÜß €μ]{8,}$/.test(e)}function Kn(e){return/^(?=.*[a-zöäüA-ZÖÄÜß])/.test(e)}function qn(e){return/^(?=.*\d)/.test(e)}function Jn(e){return Gn(e)&&Kn(e)&&qn(e)}var $={t:(e,t)=>({"formValidators.minLength":`Must be at least ${t?.min} characters long`,"formValidators.maxLength":`Must be at most ${t?.max} characters long`,"formValidators.email":`Must be a valid email address`,"formValidators.required":`${t?.label||`Value`} is required`,"formValidators.value":`Value`,"formValidators.mustBeNumber":`Must be a number`,"formValidators.oneOf":`Must be one of the following values: ${t?.allowedValues}`,"formValidators.typeOf":`Must have type of ${t?.allowedTypes}`,"formValidators.multiEmail":`Must be a comma or semicolon separated list of valid email addresses`,"formValidators.date":`Must be a valid date`,"garages.errors.website":`Must be a valid URL`,"garages.errors.bic":`Must be a valid BIC`,"formValidators.minLetters":`Must contain at least ${t?.smart_count} letters`,"formValidators.minDigits":`Must contain at least ${t?.smart_count} digits`})[e]||e},Yn=class e{static{this.minLength=(e,t)=>n=>!n||n.length<e?{id:`minLength`,message:t||$.t(`formValidators.minLength`,{min:e})}:null}static{this.maxLength=(e,t)=>n=>n&&n.length>e?{id:`maxLength`,message:t||$.t(`formValidators.maxLength`,{max:e})}:null}static{this.email=e=>t=>t&&!Hn(t)?{id:`email`,message:e||$.t(`formValidators.email`)}:null}static{this.required=e=>{function t(t,n){return!t&&t!==0?{id:`required`,message:e||$.t(`formValidators.required`,{label:n||$.t(`formValidators.value`)})}:null}return t.validatorId=`required`,t}}static{this.mustBeNumber=e=>t=>t&&Number.isNaN(+t)?{id:`mustBeNumber`,message:e||$.t(`formValidators.mustBeNumber`)}:null}static{this.oneOf=(e,t)=>n=>n&&!e.includes(n)?{id:`oneOf`,message:t||$.t(`formValidators.oneOf`,{allowedValues:e})}:null}static{this.typeOf=(e,t)=>n=>{if(Array.isArray(e)){for(let t=0;t<e.length;t+=1)if(typeof n===e[t])return null}else if(typeof n===e)return null;return{id:`typeOf`,message:t||`Must have type of ${e}`}}}static{this.multiEmail=e=>t=>{if(t){let n=t.replace(/ /g,``).replace(/,/g,`;`).split(`;`);for(let t=0;t<n.length;t+=1)if(!Hn(n[t]))return{id:`multiEmail`,message:e||$.t(`formValidators.multiEmail`)}}return null}}static{this.date=e=>t=>t&&!Bn(t)&&!Vn(t)?{id:`date`,message:e||$.t(`formValidators.date`)}:null}static{this.dateObject=e=>t=>t&&!t.isValid?{id:`date`,message:e||$.t(`formValidators.date`)}:null}static{this.website=e=>t=>t&&!Wn(t)?{id:`website`,message:e||$.t(`garages.errors.website`)}:null}static{this.bic=e=>t=>t&&!Un(t)?{id:`bic`,message:e||$.t(`garages.errors.bic`)}:null}static{this.minLetters=(e,t)=>n=>n&&n.replace(/[^a-zöäüA-ZÖÄÜß]/g,``).length<e?{id:`minLetters`,message:t||$.t(`formValidators.minLetters`,{smart_count:e})}:null}static{this.minDigits=(e,t)=>n=>n&&n.replace(/[\D]/g,``).length<e?{id:`minDigits`,message:t||$.t(`formValidators.minDigits`,{smart_count:e})}:null}static{this.password=t=>n=>{let r=e.minLength(8)(n)||e.minLetters(1)(n)||e.minDigits(1)(n);return r?t?{id:`password`,message:t}:r:null}}},Xn=class extends c.PureComponent{static{this.defaultProps={formValidator:null,onMouseEnter:null,onMouseLeave:null,onFocus:null,onBlur:null,onChange:null,errorMessage:``,isValid:!1,isRequired:!1,label:``}}constructor(e){super(e);let{formValidator:t}=e;t&&(t.label=e.label??``,t.validate(),t.registerOnUpdateListener(()=>{this.forceUpdate()})),this.state={isFocused:!1,isHovered:!1},this.onMouseEnter=this.onMouseEnter.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),this.hasError=this.hasError.bind(this),this.renderTooltip=this.renderTooltip.bind(this),this.onChange=this.onChange.bind(this)}componentDidMount(){setTimeout(()=>this.setState({isFocused:!1,isHovered:!1}),1)}componentDidUpdate(e){let{formValidator:t}=this.props;e.formValidator&&t&&e.formValidator!==t&&t.registerOnUpdateListener(()=>{this.forceUpdate()})}onMouseEnter(e){let{onMouseEnter:t}=this.props;this.setState({isHovered:!0}),t&&t(e)}onMouseLeave(e){let{onMouseLeave:t}=this.props;this.setState({isHovered:!1}),t&&t(e)}onFocus(e){let{onFocus:t}=this.props;this.setState({isFocused:!0}),t&&t(e)}onBlur(e){let{formValidator:t,onBlur:n}=this.props;t&&(t.touched=!0),this.setState({isFocused:!1}),n&&n(e)}hasError(){let{errorMessage:e,isValid:t,formValidator:n}=this.props;return n?n.touched&&n.hasError():!t||!!e}isRequired(){let{isRequired:e,formValidator:t}=this.props;return!!(e||t&&t.validators.find(e=>e.validatorId===`required`))}renderTooltip(){let{errorMessage:e,formValidator:t}=this.props,{isHovered:n,isFocused:r}=this.state;return(0,f.jsx)(ve,{variant:`error`,message:t?t.getCurrentErrorMessage():e||``,isVisible:this.hasError()&&(r||n)})}onChange(e){let{onChange:t,formValidator:n}=this.props;if(n){let t=e;e&&e.target&&(t=e.target.value),n.set(t)}t&&t(e)}};function Zn(e){let[,t]=(0,c.useReducer)(e=>e+1,0);return(0,c.useEffect)(()=>{if(e)return e.registerOnUpdateListener(t),()=>e.removeOnUpdateListener(t)},[e]),e}function Qn(e,{initialValues:t,onSubmit:n,onValidate:r,errorParser:i,onSubmitError:a}={}){let[,o]=(0,c.useReducer)(e=>e+1,0),s=(0,c.useRef)(null);s.current||=new Ln(e,null,{initialValues:t,errorParser:i,onSubmitError:a});let l=s.current,u=(0,c.useRef)(n),d=(0,c.useRef)(r);return u.current=n,d.current=r,(0,c.useEffect)(()=>(n!==void 0&&(l.onSubmitCallback=(...e)=>u.current?.(...e)),r!==void 0&&(l.onValidateCallback=(...e)=>d.current?.(...e)),l.registerOnUpdateListener(o),()=>l.removeOnUpdateListener(o)),[]),l}exports.Accordion=E,exports.AccordionStyleType=x,exports.ActionButtons=ne,exports.ActionIcon=ae,exports.Align=me,exports.BodyEnd=B,exports.Button=L,exports.ButtonSize=N,exports.ButtonStyleType=M,exports.ButtonType=P,exports.Card=oe,exports.CardActions=H,exports.CardContent=le,exports.CardHeader=se,exports.CardMedia=ce,exports.Checkbox=ue,exports.Chip=de,exports.ChipContainer=fe,exports.ColorPicker=ke,exports.ConfirmModal=Me,exports.DatePicker=at,exports.Dropdown=rt,exports.EmptyState=st,exports.Fab=dt,exports.FloatingMenu=ge,exports.FormValidator=Rn,exports.FormValidatorGroup=Ln,exports.Icon=mt,exports.IconLoading=Ct,exports.IdleManager=gt,exports.InfiniteBlock=nt,exports.Input=ye,exports.InputType=K,exports.InteractableDiv=z,exports.KanbanBoard=bt,exports.KanbanColumn=yt,exports.Modal=je,exports.NumberInput=Et,exports.OptionPicker=Ot,exports.Overscroll=Mt,exports.ProgressBar=Ft,exports.Ripple=I,exports.RoomDrawer=ln,exports.ScrollbarProvider=fn,exports.SearchInput=mn,exports.SpinnerLoading=j,exports.Stepper=hn,exports.TenorPicker=Cn,exports.Textarea=wn,exports.ThemeProvider=Dn,exports.Tooltip=ve,exports.ValidatableComponent=Xn,exports.Validators=Yn,exports.Wizard=An,exports.getLocale=ze,exports.hasEightPasswordChars=Gn,exports.hasOnePasswordDigit=qn,exports.hasOnePasswordLetter=Kn,exports.isBic=Un,exports.isDate=Bn,exports.isEmail=Hn,exports.isISODate=Vn,exports.isNumber=zn,exports.isPassword=Jn,exports.isURL=Wn,exports.mapLocale=Ie,exports.setLocale=Re,exports.useFormValidator=Zn,exports.useFormValidatorGroup=Qn,exports.useTheme=On;
|
|
6
6
|
//# sourceMappingURL=index.cjs.map
|