@osamash/floor-planner 1.2.2 → 1.2.3

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.
@@ -52486,7 +52486,7 @@ const SearchInput = ({
52486
52486
  )
52487
52487
  }
52488
52488
  ) }),
52489
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs font-semibold capitalize", children: k.info.description })
52489
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs font-semibold capitalize", children: k.info.title })
52490
52490
  ]
52491
52491
  },
52492
52492
  k.name.replace(/\s+/g, "_")
@@ -3928,7 +3928,7 @@ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
3928
3928
  transform-gpu
3929
3929
  transition-opacity transition-transform
3930
3930
  duration-150 ease-out
3931
- `,children:e}),document.body)},ToolbarButton=({active:i,tooltip:e,tooltipPosition:t="right",onClick:n,children:s,className:o,showDelay:a=300,hideDelay:l=0})=>{const c=React.useRef(null),u=React.useRef(null),h=React.useRef(null),[d,p]=React.useState(!1),m=()=>{u.current&&(window.clearTimeout(u.current),u.current=null),h.current&&(window.clearTimeout(h.current),h.current=null)},g=()=>{m(),u.current=window.setTimeout(()=>{p(!0)},a)},y=()=>{m(),h.current=window.setTimeout(()=>{p(!1)},l)};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{ref:c,className:cn("w-[30px] h-[30px] flex items-center justify-center text-[25px] cursor-pointer",o),onMouseEnter:g,onMouseLeave:y,onClick:n,children:jsxRuntimeExports.jsx("div",{className:cn("transition-colors",i?"text-dark-blue":""),children:s})}),jsxRuntimeExports.jsx(Tooltip,{anchorEl:c.current,title:e,visible:d,position:t})]})},getSVGScreenshot=()=>new Promise(async i=>{const e=document.getElementsByTagName("svg");if(!e.length)return;let t=e[0];for(let p=1;p<e.length;p++)e[p].width.baseVal.value>t.width.baseVal.value&&(t=e[p]);const n=t.cloneNode(!0),s=n.querySelectorAll("image");await Promise.all(Array.from(s).map(async p=>{const m=p.getAttribute("href")||p.getAttribute("xlink:href");if(m)try{const y=await(await fetch(m)).blob(),_=new FileReader;await new Promise(x=>{_.onloadend=()=>{p.setAttribute("href",_.result),x()},_.readAsDataURL(y)})}catch(g){console.warn("⚠️ Could not inline image:",m,g)}}));const a=new XMLSerializer().serializeToString(n),l=t.width.baseVal.value,c=t.height.baseVal.value,u=document.createElement("canvas");u.width=l,u.height=c;const h=u.getContext("2d");h.fillStyle="white",h.fillRect(0,0,l,c);const d=new Image;d.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(a)))}`,d.onload=()=>{h.drawImage(d,0,0,l,c),i(u.toDataURL("image/png"))}});function TbScreenshot(i){return GenIcon({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M7 19a2 2 0 0 1 -2 -2"},child:[]},{tag:"path",attr:{d:"M5 13v-2"},child:[]},{tag:"path",attr:{d:"M5 7a2 2 0 0 1 2 -2"},child:[]},{tag:"path",attr:{d:"M11 5h2"},child:[]},{tag:"path",attr:{d:"M17 5a2 2 0 0 1 2 2"},child:[]},{tag:"path",attr:{d:"M19 11v2"},child:[]},{tag:"path",attr:{d:"M19 17v4"},child:[]},{tag:"path",attr:{d:"M21 19h-4"},child:[]},{tag:"path",attr:{d:"M13 19h-2"},child:[]}]})(i)}const imageBrowserDownload=i=>{let e=document.createElement("a"),t="output"+Date.now()+".png";t=window.prompt("Insert output filename",t),t&&(e.setAttribute("download",t),e.href=i,e.style.display="none",document.body.appendChild(e),e.click(),document.body.removeChild(e))};function ToolbarScreenshotButton({mode:i}){const e=n=>{n.preventDefault();const s=document.getElementsByTagName("canvas")[0];imageBrowserDownload(s.toDataURL())},t=async n=>{n.preventDefault(),getSVGScreenshot().then(imageBrowserDownload)};return[MODE_3D_FIRST_PERSON,MODE_3D_VIEW].includes(i)?jsxRuntimeExports.jsx(ToolbarButton,{active:!1,tooltip:"Get Screenshot",onClick:e,children:jsxRuntimeExports.jsx(TbScreenshot,{size:28})}):[MODE_IDLE$1,MODE_2D_ZOOM_IN,MODE_2D_ZOOM_OUT,MODE_2D_PAN,MODE_WAITING_DRAWING_LINE,MODE_WAITING_DRAWING_SURFACE,MODE_DRAGGING_LINE,MODE_DRAGGING_VERTEX,MODE_DRAGGING_ITEM,MODE_DRAWING_LINE,MODE_DRAWING_SURFACE,MODE_DRAWING_HOLE,MODE_DRAWING_ITEM,MODE_DRAGGING_HOLE,MODE_ROTATING_ITEM].includes(i)?jsxRuntimeExports.jsx(ToolbarButton,{active:!1,tooltip:"Get Screenshot",onClick:t,children:jsxRuntimeExports.jsx(TbScreenshot,{size:28})}):null}function LuBrickWall(i){return GenIcon({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{width:"18",height:"18",x:"3",y:"3",rx:"2"},child:[]},{tag:"path",attr:{d:"M12 9v6"},child:[]},{tag:"path",attr:{d:"M16 15v6"},child:[]},{tag:"path",attr:{d:"M16 3v6"},child:[]},{tag:"path",attr:{d:"M3 15h18"},child:[]},{tag:"path",attr:{d:"M3 9h18"},child:[]},{tag:"path",attr:{d:"M8 15v6"},child:[]},{tag:"path",attr:{d:"M8 3v6"},child:[]}]})(i)}function PiWall(i){return GenIcon({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M224,48H32a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8H224a8,8,0,0,0,8-8V56A8,8,0,0,0,224,48ZM88,144V112h80v32Zm-48,0V112H72v32Zm144-32h32v32H184Zm32-16H136V64h80ZM120,64V96H40V64ZM40,160h80v32H40Zm96,32V160h80v32Z"},child:[]}]})(i)}const EREG_NUMBER=/^.*$/;function FormColorInput({onChange:i,...e}){const[t,n]=React.useState(""),s=React.useRef(null);React.useEffect(()=>{n(e.value)},[e.value]);const o=l=>{if(!l)return;const c=l.target.value;EREG_NUMBER.test(c)&&i&&i(l)},a=l=>{(!l.key||l.key==="Enter")&&o({target:{value:t}})};return jsxRuntimeExports.jsxs("div",{className:"color-field flex-1 flex pr-3 mt-1 cursor-pointer",children:[jsxRuntimeExports.jsx("div",{className:"colorBox relative w-[22px] h-[22px]",style:{background:e.value},onClick:()=>{s.current&&s.current.click()},children:jsxRuntimeExports.jsx("input",{ref:s,type:"color",onChange:o,value:e.value,className:"absolute invisible h-full w-full"})}),jsxRuntimeExports.jsx("div",{className:"flex-1 pl-2",children:jsxRuntimeExports.jsx("input",{className:"colorFieldInput min-w-[90px] cursor-pointer",type:"text",value:t,onKeyDown:a,onChange:l=>n(l.target.value),onBlur:a})})]})}function PropertyColor({value:i,onUpdate:e,configs:t,propertyName:n,sourceElement:s,internalState:o}){const a=s.toJS(),{planner:l}=useReactPlannerStore(),c=u=>t.hook?t.hook(u,s,o,l).then(h=>e(h)):e(u);return React.useEffect(()=>{var p;const u=a.type==="wall",h=n==="colorA"||n==="colorB",d=!((p=a.properties)!=null&&p[n]);u&&h&&d&&c(i)},[a.type,a.properties,n,c,i]),jsxRuntimeExports.jsxs("div",{className:"PropertyColor w-full mb-2",children:[jsxRuntimeExports.jsx(FormLabel,{children:t.label}),jsxRuntimeExports.jsx(FormColorInput,{value:i,onChange:u=>c(u.target.value)})]})}function PropertyEnum({value:i,onUpdate:e,configs:t,sourceElement:n,internalState:s}){const{planner:o}=useReactPlannerStore(),a=l=>t.hook?t.hook(l,n,s,o).then(c=>e(c)):e(l);return jsxRuntimeExports.jsxs("div",{className:"PropertyEnum w-full mb-2",children:[jsxRuntimeExports.jsx(FormLabel,{children:t.label}),jsxRuntimeExports.jsx(FormSelect,{value:i,onChange:l=>a(l.target.value),children:Seq(t.values).entrySeq().map(([l,c])=>jsxRuntimeExports.jsx("option",{value:l,children:c},l))})]})}function PropertyString({value:i,onUpdate:e,configs:t,sourceElement:n,internalState:s}){const{planner:o}=useReactPlannerStore();let a=l=>t.hook?t.hook(l,n,s,o).then(c=>e(c)):e(l);return jsxRuntimeExports.jsxs("div",{className:"PropertyString w-full mb-2",children:[jsxRuntimeExports.jsx(FormLabel,{children:t.label}),jsxRuntimeExports.jsx(FormTextInput,{value:i,onChange:l=>a(l.target.value)})]})}function PropertyNumber({value:i,onUpdate:e,onValid:t,configs:n,sourceElement:s,internalState:o}){const{planner:a}=useReactPlannerStore(),l=c=>{let u=parseFloat(c);return isNaN(u)&&(u=0),n.hook?n.hook(u,s,o,a).then(h=>e(h)):e(u)};return jsxRuntimeExports.jsxs("div",{className:"PropertyNumber w-full mb-2",children:[jsxRuntimeExports.jsx(FormLabel,{children:n.label}),jsxRuntimeExports.jsx(FormNumberInput,{value:i,onChange:c=>l(c.target.value),onValid:t,min:n.min,max:n.max})]})}function PropertyLengthMeasure({value:i,onUpdate:e,onValid:t,configs:n,sourceElement:s,internalState:o}){const{planner:a}=useReactPlannerStore(),{mode:l}=a,c=i.get("length")||0,u=i.get("_length")||c,h=i.get("_unit")||UNIT_CENTIMETER,{hook:d,label:p,...m}=n,g=(y,_)=>{let x=toFixedFloat(y),S=i.merge({length:_!==UNIT_CENTIMETER?convert(x).from(_).to(UNIT_CENTIMETER):x,_length:y,_unit:_});return d?d(S,s,o,a).then(b=>e(b)):e(S)};if(l!==MODE_3D_VIEW)return jsxRuntimeExports.jsxs("div",{className:"PropertyLengthMeasure w-full mb-2",children:[jsxRuntimeExports.jsx(FormLabel,{children:p}),jsxRuntimeExports.jsxs("div",{className:"w-full flex",children:[jsxRuntimeExports.jsx(FormNumberInput,{value:u,style:{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:0},onChange:y=>g(y.target.value,h),onValid:t,...m}),jsxRuntimeExports.jsx("div",{className:"w-1/4 [&>*:first-child]:text-center",children:jsxRuntimeExports.jsx(FormSelect,{style:{borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"},disabled:!0,value:h,onChange:y=>{},children:UNITS_LENGTH.map(y=>jsxRuntimeExports.jsx("option",{value:y,children:y},y))})})]})]})}function Button({type:i="button",size:e="normal",style:t,styleHover:n,children:s,...o}){const[a,l]=React.useState(!1),c="inline-block font-normal leading-[1.25] text-center whitespace-nowrap align-middle cursor-pointer select-none outline-none border border-solid w-full transition-colors duration-175 ease-linear rounded-[2px]",u=e==="small"?"text-[12px] px-2 py-[3px]":e==="large"?"px-5 py-2":"text-[14px] px-3 py-[5px]",h={backgroundColor:"#e6e6e6",borderColor:"#adadad"},d={backgroundColor:"#d4d4d4",borderColor:"#8c8c8c"};return jsxRuntimeExports.jsx("button",{type:i,className:`${c} ${u}`,style:{...a?{...d,...n}:{...h,...t}},onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),...o,children:s})}const tableStyle={width:"100%",borderSpacing:"2px 0",marginBottom:"2px"},firstTdStyle={width:"6em",textTransform:"capitalize"},PropertyStyle={tableStyle,firstTdStyle};function PropertyToggle({value:i,onUpdate:e,configs:t,sourceElement:n,internalState:s}){const{planner:o}=useReactPlannerStore(),a=l=>t.hook?t.hook(l,n,s,o).then(c=>e(c)):e(l);return jsxRuntimeExports.jsx("table",{className:"PropertyToggle",style:PropertyStyle.tableStyle,children:jsxRuntimeExports.jsx("tbody",{children:jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{style:PropertyStyle.firstTdStyle,children:jsxRuntimeExports.jsx(FormLabel,{children:t.label})}),jsxRuntimeExports.jsx("td",{children:jsxRuntimeExports.jsx(Button,{onClick:()=>a(!i),size:"small",children:t.actionName})})]})})})}function PropertyCheckbox({value:i,onUpdate:e,configs:t,sourceElement:n,internalState:s}){const{planner:o}=useReactPlannerStore(),a=l=>t.hook?t.hook(l,n,s,o).then(c=>e(c)):e(l);return jsxRuntimeExports.jsxs("div",{className:"PropertyCheckbox w-full flex items-center gap-2 mb-2",children:[jsxRuntimeExports.jsx("input",{className:"m-0 mt-0.5",type:"checkbox",checked:i,onChange:()=>a(!i)}),jsxRuntimeExports.jsx(FormLabel,{className:"mb-0",children:t.label})]})}function PropertyHidden(){return null}function PropertyReadOnly({value:i,configs:e}){return jsxRuntimeExports.jsx("table",{className:"PropertyReadOnly",style:PropertyStyle.tableStyle,children:jsxRuntimeExports.jsx("tbody",{children:jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{style:PropertyStyle.firstTdStyle,children:jsxRuntimeExports.jsx(FormLabel,{children:e.label})}),jsxRuntimeExports.jsx("td",{children:jsxRuntimeExports.jsx("div",{children:i})})]})})})}class Catalog{constructor(e=UNIT_CENTIMETER){tt(this,"elements");tt(this,"categories");tt(this,"propertyTypes");tt(this,"unit");this.elements={},this.categories={root:{name:"root",label:"/",elements:[],categories:[]}},this.propertyTypes={},this.unit=e,this.registerMultiplePropertyType([["color",PropertyColor,PropertyColor],["enum",PropertyEnum,PropertyEnum],["string",PropertyString,PropertyString],["number",PropertyNumber,PropertyNumber],["length-measure",PropertyLengthMeasure,PropertyLengthMeasure],["toggle",PropertyToggle,PropertyToggle],["checkbox",PropertyCheckbox,PropertyCheckbox],["hidden",PropertyHidden,PropertyHidden],["read-only",PropertyReadOnly,PropertyReadOnly]])}getElement(e){if(this.hasElement(e))return this.elements[e];throw new Error(`Element ${e} does not exist in catalog`)}getCategory(e){if(this.hasCategory(e))return this.categories[e];throw new Error(`Category ${e} does not exist in catalog`)}getPropertyType(e){if(this.propertyTypes.hasOwnProperty(e))return this.propertyTypes[e];throw new Error(`Element ${e} does not exist in catalog`)}registerElement(e){e.properties=e.properties||{},this.validateElement(e)&&(this.elements[e.name]=e,this.categories.root.elements.push(this.elements[e.name]))}registerMultipleElements(e){e.forEach(t=>this.registerElement(t))}registerPropertyType(e,t,n){this.propertyTypes[e]={type:e,Viewer:t,Editor:n}}registerMultiplePropertyType(e){e.forEach(t=>this.registerPropertyType(...t))}validateElement(e){if(!e.hasOwnProperty("name"))throw new Error("Element not valid");let t=e.name;if(!e.hasOwnProperty("prototype"))throw new Error(`Element ${t} doesn't have prototype`);if(!e.hasOwnProperty("info"))throw new Error(`Element ${t} doesn't have info`);if(!e.info.hasOwnProperty("tag"))throw new Error(`Element ${t} doesn't have tag`);if(!e.info.hasOwnProperty("description"))throw new Error(`Element ${t} doesn't have description`);if(!e.info.hasOwnProperty("image"))throw new Error(`Element ${t} doesn't have image`);if(!e.hasOwnProperty("render2D"))throw new Error(`Element ${t} doesn't have render2D handler`);if(!e.hasOwnProperty("render3D"))throw new Error(`Element ${t} doesn't have render3D handler`);if(!e.hasOwnProperty("properties"))throw new Error(`Element ${t} doesn't have properties`);for(let n in e.properties){let s=e.properties[n];if(!s.hasOwnProperty("type"))throw new Error(`Element ${t}, Property ${n} doesn't have type`);if(!s.hasOwnProperty("defaultValue"))throw new Error(`Element ${t}, Property ${n} doesn't have defaultValue`)}return!0}hasElement(e){return this.elements.hasOwnProperty(e)}registerCategory(e,t,n){return this.validateCategory(e,t)?(this.categories[e]={name:e,label:t,categories:[],elements:[]},this.categories.root.categories.push(this.categories[e]),n&&n.length&&n.forEach(s=>this.addToCategory(e,s)),this.categories[e]):null}addToCategory(e,t){if(this.hasElement(t.name))this.categories[e].elements.push(t),this.categories.root.elements.splice(this.categories.root.elements.indexOf(t),1);else if(this.hasCategory(t.name))this.categories[e].categories.push(t),this.categories.root.categories.splice(this.categories.root.categories.indexOf(t),1);else throw new Error(`child ${t} is either category nor element`)}categoryHasElement(e,t){return this.hasCategory(e)&&this.categories[e].elements.some(n=>n.name===t)}validateCategory(e,t){if(!e)throw new Error("Category has undefined name");if(e==="")throw new Error("Category has empty name");if(this.hasCategory(e))throw new Error("Category has already been registered");return!0}hasCategory(e){return this.categories.hasOwnProperty(e)}}function BiRedo(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M9 18h3v-2H9c-1.654 0-3-1.346-3-3s1.346-3 3-3h6v3l5-4-5-4v3H9c-2.757 0-5 2.243-5 5s2.243 5 5 5z"},child:[]}]})(i)}function BiSearch(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M10 18a7.952 7.952 0 0 0 4.897-1.688l4.396 4.396 1.414-1.414-4.396-4.396A7.952 7.952 0 0 0 18 10c0-4.411-3.589-8-8-8s-8 3.589-8 8 3.589 8 8 8zm0-14c3.309 0 6 2.691 6 6s-2.691 6-6 6-6-2.691-6-6 2.691-6 6-6z"},child:[]}]})(i)}function BiUndo(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M9 10h6c1.654 0 3 1.346 3 3s-1.346 3-3 3h-3v2h3c2.757 0 5-2.243 5-5s-2.243-5-5-5H9V5L4 9l5 4v-3z"},child:[]}]})(i)}const SearchInput=({term:i="",placeholder:e="Search",noSpacing:t=!1,onClick:n=()=>!1,isStatic:s=!1,hasDropDown:o=!1,onSearch:a,className:l,value:c})=>{const[u,h]=React.useState("");return React.useEffect(()=>{c!==void 0&&c!==u&&h(c??"")},[c]),jsxRuntimeExports.jsxs("div",{className:cn(`relative w-full ${t?"mt-1":"mt-2"}`,l),onClick:n??(()=>!1),children:[jsxRuntimeExports.jsx("span",{className:`absolute left-0 top-2 text-[#637381] ${t?"":"ml-2"}`,style:{zIndex:2},children:jsxRuntimeExports.jsx(BiSearch,{size:18})}),s?jsxRuntimeExports.jsx("div",{className:"w-full rounded border border-gray-300 bg-white px-3 py-1.5 text-xs font-normal cursor-pointer",style:{marginTop:3},children:i}):jsxRuntimeExports.jsx("input",{className:"w-full rounded pl-[30px] focus:outline-none border border-gray-300 bg-white pr-3 py-1.5 text-sm text-gray-900",type:"text",placeholder:e,onChange:d=>{a(d.target.value,d),h(d.target.value)},value:u,onClick:n??(()=>!1)}),n!==null&&o&&jsxRuntimeExports.jsx("span",{className:`absolute right-2 top-1/2 -translate-y-1/2 ${t?"":"ml-2"}`,style:{zIndex:1},children:jsxRuntimeExports.jsx(FaSortDown,{className:"-mb-1"})})]})},TOP_OFFSET$1=0,LEFT_OFFSET$1=58,getCatalogOptions=i=>{const e=[{label:"All Categories",value:"all"}],t=i.map(n=>n.info.tag);for(const n of t){let s=e;for(let o=0;o<n.length;o++){const a=n[o];let l=s.find(c=>c.label===a);l||(l={label:a,value:a},o<n.length-1&&(l.options=[{label:"All Categories",value:"all"}]),s.push(l)),o<n.length-1&&l.options&&(s=l.options)}}return e},SegmentedTabs=({selected:i,options:e,onChange:t})=>{const n=React.useMemo(()=>e.findIndex(o=>o.value===i),[e,i]),s=100/e.length;return jsxRuntimeExports.jsxs("div",{className:"relative w-full rounded-lg border border-gray-200 bg-white p-1",children:[jsxRuntimeExports.jsx("div",{className:"absolute top-1 bottom-1 rounded-md bg-slate-900 transition-transform duration-300 ease-out",style:{width:`calc(${s}% - 4px)`,transform:`translateX(${n*100}%)`}}),jsxRuntimeExports.jsx("div",{role:"tablist",className:"relative z-10 grid",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map(o=>{const a=o.value===i;return jsxRuntimeExports.jsx("button",{role:"tab","aria-selected":a,className:cn("h-8 text-sm font-medium capitalize transition-colors",a?"text-white":"text-gray-700 hover:text-black"),onClick:()=>t(o),children:o.label},o.value)})})]})},NestedSelect=({options:i,selections:e,level:t,onChange:n})=>{var s,o;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("select",{className:"w-full rounded capitalize cursor-pointer focus:outline-none border border-gray-300 bg-white pr-3 pl-1.5 py-1.5 text-sm text-gray-900",value:e[t]||"all",onChange:a=>n(t,a.target.value),children:i.map(a=>jsxRuntimeExports.jsx("option",{className:"capitalize",value:a.value,children:a.label},a.value))}),e[t]&&e[t]!=="all"&&((s=i.find(a=>a.value===e[t]))==null?void 0:s.options)&&jsxRuntimeExports.jsx(NestedSelect,{options:((o=i.find(a=>a.value===e[t]))==null?void 0:o.options)||[],level:t+1,selections:e,onChange:n})]})},Popup$1=({catalog:i,popupEvent:e,onClose:t})=>{const{setToast:n,selectToolDrawingLine:s,selectToolDrawingItem:o,selectToolDrawingHole:a,pushLastSelectedCatalogElementToHistory:l}=useReactPlannerStore(),[c,u]=React.useState([]),[h,d]=React.useState(""),[p,m]=React.useState([]),[g,y]=React.useState(["all"]),[_,x]=React.useState([]),[S,b]=React.useState(""),E=React.useRef(null),M=React.useRef(null),w=()=>{b(""),m([]),u([]),y(["all"]),d("")};React.useEffect(()=>{if(e){w();const H=i.getCategory(e.page).elements.filter(Y=>Y.info.visibility?Y.info.visibility.catalog:!0);E.current=e.page,x(H);const{x:X,y:te}=e.rect;if(M.current={top:te+TOP_OFFSET$1,left:X+LEFT_OFFSET$1},e.page==="objects"){const Y=Array.from(new Set(H.map(_e=>_e.info.category).filter(Boolean))),re=Y[0]??"",G=H.filter(_e=>_e.info.category===re);d(re),u(Y),m(getCatalogOptions(G))}}},[e]);const P=()=>{t()},C=k=>{P(),e&&e.page!=="objects"&&n({text:`Cancel placing ${e.page}`}),setTimeout(()=>{switch(k.prototype){case"lines":s(k.name);break;case"items":o(k.name);break;case"holes":a(k.name);break}l(k)},0)},A=(k,H)=>{const X=[...g.slice(0,k),H];y(X)},I=(k,H)=>{k.preventDefault();const X=k.currentTarget.closest(".fp_side-bar");let te=!1;const Y=_e=>{const{clientX:U,clientY:W}=_e,he=X==null?void 0:X.getBoundingClientRect();he&&(U<he.left||U>he.right||W<he.top||W>he.bottom)&&(te=!0),te&&(C(H),G())},re=()=>G(),G=()=>{document.removeEventListener("mousemove",Y),document.removeEventListener("mouseup",re)};document.addEventListener("mousemove",Y),document.addEventListener("mouseup",re)},D=React.useMemo(()=>_.filter(k=>{const H=k.info.title.toLowerCase().includes(S.toLowerCase()),X=h?k.info.category===h:k,te=g.every(Y=>Y==="all"||k.info.tag.includes(Y));return H&&X&&te}),[_,S,h,g]);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[e&&jsxRuntimeExports.jsx("div",{className:"fixed inset-0 bg-black/30 z-10",onClick:P}),jsxRuntimeExports.jsxs("div",{style:e&&e.rect?{top:e.rect.y+TOP_OFFSET$1,left:e.rect.x+LEFT_OFFSET$1}:M.current?M.current:{},className:cn("fixed select-none z-10 shadow-md !gap-0 rounded-lg pt-4 fp_side-bar !min-h-[250px] !min-w-[330px] max-w-[330px] !max-h-[510px] transition-all duration-200 ease-out transform",e?"opacity-100 scale-100":"opacity-0 scale-95 pointer-events-none"),children:[jsxRuntimeExports.jsxs("header",{className:"px-[18px] sticky top-0 left-0 gap-3 flex flex-col",children:[jsxRuntimeExports.jsx("div",{className:"flex items-center gap-1",children:jsxRuntimeExports.jsx("span",{className:cn("flex flex-col gap-0.5"),children:jsxRuntimeExports.jsx("span",{className:"fp-sidebar-label capitalize",children:(e==null?void 0:e.page)??E.current})})}),jsxRuntimeExports.jsxs("div",{className:cn("fp-highlight"),children:[c.length>1&&jsxRuntimeExports.jsx(SegmentedTabs,{selected:h,onChange:k=>{y(["all"]),d(k.value),m(getCatalogOptions(_.filter(H=>H.info.category===k.value)))},options:c.map(k=>({label:k,value:k}))}),p.length>0&&jsxRuntimeExports.jsx(NestedSelect,{options:p,level:0,selections:g,onChange:A}),jsxRuntimeExports.jsx(SearchInput,{className:"mt-0",placeholder:"Search",value:S,onSearch:(k,H)=>{H.preventDefault(),H.stopPropagation(),b(k)}})]})]}),D.length>0?jsxRuntimeExports.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 pb-5 overflow-auto w-full pt-[18px] px-4",onWheel:k=>k.stopPropagation(),children:D.map(k=>jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1.5",children:[jsxRuntimeExports.jsx("div",{className:"fp-aspect-ratio-container",children:jsxRuntimeExports.jsx("div",{className:"fp-aspect-ratio-content",onMouseDown:H=>I(H,k),children:jsxRuntimeExports.jsx("img",{draggable:!1,className:"fp-item-image",alt:k.info.title,src:k.info.image})})}),jsxRuntimeExports.jsx("p",{className:"text-xs font-semibold capitalize",children:k.info.description})]},k.name.replace(/\s+/g,"_")))}):jsxRuntimeExports.jsx("div",{className:"min-h-28 w-full flex items-center justify-center",children:jsxRuntimeExports.jsx("p",{className:"text-sm font-medium text-gray-400 text-center",children:"No records found"})})]})]})};function FaDoorOpen(i){return GenIcon({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M320 32c0-9.9-4.5-19.2-12.3-25.2S289.8-1.4 280.2 1l-179.9 45C79 51.3 64 70.5 64 92.5L64 448l-32 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l64 0 192 0 32 0 0-32 0-448zM256 256c0 17.7-10.7 32-24 32s-24-14.3-24-32s10.7-32 24-32s24 14.3 24 32zm96-128l96 0 0 352c0 17.7 14.3 32 32 32l64 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-32 0 0-320c0-35.3-28.7-64-64-64l-96 0 0 64z"},child:[]}]})(i)}function GiSofa(i){return GenIcon({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M112 73c-13.75 0-24.214 4.87-33.047 13.271-8.832 8.402-15.755 20.6-20.414 34.575-5.887 17.661-7.953 38.064-6.887 56.111a57.246 57.246 0 0 1 2.461-.187c8.38-.405 16.317 1.094 23.494 4.234 14.355 6.28 25.436 18.27 34.057 32.28 15.104 24.543 23.187 55.746 24.96 80.585 114.097-14.223 124.655-14.223 238.753 0 1.772-24.84 9.855-56.042 24.959-80.586 8.62-14.009 19.702-25.999 34.057-32.28 7.875-3.444 16.67-4.898 25.955-4.046 1.066-18.047-1-38.45-6.887-56.111-4.659-13.976-11.582-26.173-20.414-34.575C424.214 77.87 413.75 73 400 73zM56.969 194.502c-.686-.008-1.38.006-2.082.04-5.621.284-11.8 1.978-18.862 5.509-23.413 11.707-26.349 65.687 14.82 79.41l4.505 1.502L86.79 391h338.42l31.44-110.037 4.504-1.502c41.17-13.723 38.234-67.703 14.82-79.41-14.121-7.061-24.722-6.775-34.367-2.555-9.645 4.22-18.564 13.23-25.943 25.22C400.906 246.7 393 282 393 304v10.195l-10.117-1.265c-128-16-125.766-16-253.766 0L119 314.195V304c0-22-7.906-57.3-22.664-81.283-7.38-11.991-16.298-21.001-25.943-25.22-4.22-1.847-8.624-2.94-13.424-2.995zM83.727 409l-23.272 23.271c11.994 3.239 33.75 3.763 42.545-1.666 3.272-4.695 6.903-14.536 10.438-21.605zm314.836 0c1.494 6.017 6.952 19.12 10.437 21.605 13.2 5.463 29.904 5.774 42.545 1.666L428.273 409z"},child:[]}]})(i)}function RxDimensions(i){return GenIcon({attr:{viewBox:"0 0 15 15",fill:"none"},child:[{tag:"path",attr:{fillRule:"evenodd",clipRule:"evenodd",d:"M3.00014 2.73895C3.00014 2.94698 2.76087 3.06401 2.59666 2.93628L1.00386 1.69744C0.875177 1.59735 0.875177 1.40286 1.00386 1.30277L2.59666 0.063928C2.76087 -0.0637944 3.00014 0.0532293 3.00014 0.261266V1.00012H9.00009V0.261296C9.00009 0.0532591 9.23936 -0.0637646 9.40358 0.0639578L10.9964 1.3028C11.1251 1.40289 11.1251 1.59738 10.9964 1.69747L9.40358 2.93631C9.23936 3.06404 9.00009 2.94701 9.00009 2.73898V2.00012H3.00014V2.73895ZM9.50002 4.99998H2.50002C2.22388 4.99998 2.00002 5.22384 2.00002 5.49998V12.5C2.00002 12.7761 2.22388 13 2.50002 13H9.50002C9.77616 13 10 12.7761 10 12.5V5.49998C10 5.22384 9.77616 4.99998 9.50002 4.99998ZM2.50002 3.99998C1.67159 3.99998 1.00002 4.67156 1.00002 5.49998V12.5C1.00002 13.3284 1.67159 14 2.50002 14H9.50002C10.3284 14 11 13.3284 11 12.5V5.49998C11 4.67156 10.3284 3.99998 9.50002 3.99998H2.50002ZM14.7389 6.00001H14V12H14.7389C14.9469 12 15.064 12.2393 14.9362 12.4035L13.6974 13.9963C13.5973 14.125 13.4028 14.125 13.3027 13.9963L12.0639 12.4035C11.9362 12.2393 12.0532 12 12.2612 12H13V6.00001H12.2612C12.0532 6.00001 11.9361 5.76074 12.0639 5.59653L13.3027 4.00373C13.4028 3.87505 13.5973 3.87505 13.6974 4.00374L14.9362 5.59653C15.0639 5.76074 14.9469 6.00001 14.7389 6.00001Z",fill:"currentColor"},child:[]}]})(i)}const iconTextStyle={fontSize:"19px",textDecoration:"none",fontWeight:"bold",margin:"0px",userSelect:"none"},Icon2D=({style:i})=>jsxRuntimeExports.jsx("p",{style:{...iconTextStyle,...i},children:"2D"}),Icon3D=({style:i})=>jsxRuntimeExports.jsx("p",{style:{...iconTextStyle,...i},children:"3D"});function Toolbar({catalog:i,has3dView:e}){const{planner:t,setMode:n,setToast:s,selectTool3DView:o,unselectAll:a,selectToolDrawingLine:l,selectToolDrawingSurface:c,showDimensions:u,setShowDimensions:h}=useReactPlannerStore(),{mode:d,alterate:p,drawingSupport:m}=t,[g,y]=React.useState(null);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("aside",{className:"floor_planner-toolbar -mt-[20px] absolute !pt-3 top-1/2 -translate-y-1/2 z-[1] max-h-full max-w-[50px] p-2.5 space-y-4",children:[jsxRuntimeExports.jsx(ToolbarButton,{active:[MODE_WAITING_DRAWING_LINE,MODE_DRAWING_LINE].includes(d)&&m.get("type")==="wall",tooltip:"Draw wall",onClick:()=>{s({text:"Cancel drawing"}),l("wall")},children:jsxRuntimeExports.jsx(LuBrickWall,{})}),jsxRuntimeExports.jsx(ToolbarButton,{active:[MODE_WAITING_DRAWING_SURFACE,MODE_DRAWING_SURFACE].includes(d),tooltip:"Draw landscape surface",onClick:()=>{s({text:"Cancel drawing"}),c("surface")},children:jsxRuntimeExports.jsx(PiWall,{size:26})}),jsxRuntimeExports.jsx(ToolbarButton,{active:!!([MODE_DRAWING_HOLE].includes(d)&&g&&g.page==="windows"),tooltip:"Place windows",onClick:_=>{y({rect:(_.currentTarget.parentElement??_.currentTarget).getBoundingClientRect(),page:"windows"})},children:jsxRuntimeExports.jsx(MdOutlineWindow,{size:26})}),jsxRuntimeExports.jsx(ToolbarButton,{active:!!([MODE_DRAWING_HOLE].includes(d)&&g&&g.page==="doors"),tooltip:"Place doors",onClick:_=>{y({rect:(_.currentTarget.parentElement??_.currentTarget).getBoundingClientRect(),page:"doors"})},children:jsxRuntimeExports.jsx(FaDoorOpen,{size:26})}),jsxRuntimeExports.jsx(ToolbarButton,{active:!!([MODE_DRAWING_ITEM].includes(d)&&g&&g.page==="objects"),tooltip:"Place objects",onClick:_=>{y({rect:(_.currentTarget.parentElement??_.currentTarget).getBoundingClientRect(),page:"objects"})},children:jsxRuntimeExports.jsx(GiSofa,{size:26})}),e?[MODE_3D_VIEW].includes(d)?jsxRuntimeExports.jsx(ToolbarButton,{active:[MODE_IDLE$1].includes(d),tooltip:"2D View",onClick:()=>{a(),setTimeout(()=>{n(MODE_IDLE$1)},0)},children:jsxRuntimeExports.jsx(Icon2D,{style:{color:p?"#FF9800":""}})}):jsxRuntimeExports.jsx(ToolbarButton,{active:[MODE_3D_VIEW].includes(d),tooltip:"3D View",onClick:o,children:jsxRuntimeExports.jsx(Icon3D,{})}):null,jsxRuntimeExports.jsx(ToolbarScreenshotButton,{mode:d}),jsxRuntimeExports.jsx(ToolbarButton,{active:u,tooltip:"Show dimensions",onClick:()=>{[MODE_3D_VIEW].includes(d)||h(!u)},children:jsxRuntimeExports.jsx(RxDimensions,{size:24})})]}),jsxRuntimeExports.jsx(Popup$1,{catalog:i,popupEvent:g,onClose:()=>y(null)})]})}const localStorage=window.hasOwnProperty("localStorage")?window.localStorage:!1,TIMEOUT_DELAY=500;let timeout=null;function autosave(i,e){return(t,n,s)=>{let o;if(e=e||TIMEOUT_DELAY,!!i&&localStorage){if(n){t.setPlan(n);const a=n.floors[0].floorDesign;o=JSON.parse(a)}else if(localStorage.getItem(i)!==null){const a=localStorage.getItem(i);o=JSON.parse(a)}o&&t.loadProject(o),useReactPlannerStore.subscribe(a=>{timeout&&clearTimeout(timeout),timeout=setTimeout(()=>{const l=localStorage.getItem(i),c=Project.unselectAll(a.planner).updatedState,u=JSON.stringify(c.scene.toJS());if(l!==u&&(localStorage.setItem(i,u),a.plan))try{const h=a.plan.floors[a.activeFloor];s&&s({floor:{floorID:h.floorID,title:h.floorTitle,description:h.floorDescription,design:u}})}catch{}},e)})}}}function keyboard(){return i=>{window.addEventListener("keydown",e=>{const t=i.planner,n=t.get("mode");switch(e.keyCode){case KEYBOARD_BUTTON_CODE.BACKSPACE:case KEYBOARD_BUTTON_CODE.DELETE:{[MODE_IDLE$1,MODE_3D_FIRST_PERSON,MODE_3D_VIEW].includes(n)&&i.remove();break}case KEYBOARD_BUTTON_CODE.ESC:{i.rollback();break}case KEYBOARD_BUTTON_CODE.Z:{(e.getModifierState("Control")||e.getModifierState("Meta"))&&(e.getModifierState("Shift")?i.redo():i.undo());break}case KEYBOARD_BUTTON_CODE.ALT:{MODE_SNAPPING.includes(n)&&i.toggleSnap(t.snapMask.merge({SNAP_POINT:!1,SNAP_LINE:!1,SNAP_SEGMENT:!1,SNAP_GRID:!1,SNAP_GUIDE:!1,tempSnapConfiguartion:t.snapMask.toJS()}));break}case KEYBOARD_BUTTON_CODE.C:{let s=t.getIn(["scene","selectedLayer"]),o=t.getIn(["scene","layers",s,"selected"]);if((n===MODE_IDLE$1||n===MODE_3D_VIEW)&&(o.holes.size||o.areas.size||o.items.size||o.lines.size)){if(o.holes.size){let a=t.getIn(["scene","layers",s,"holes",o.holes.get(0)]);i.copyProperties(a.get("properties"))}else if(o.areas.size){const a=t.getIn(["scene","layers",s,"areas",o.areas.get(0)]);i.copyProperties(a.properties)}else if(o.items.size){const a=t.getIn(["scene","layers",s,"items",o.items.get(0)]);i.copyProperties(a.properties)}else if(o.lines.size){const a=t.getIn(["scene","layers",s,"lines",o.lines.get(0)]);i.copyProperties(a.properties)}}break}case KEYBOARD_BUTTON_CODE.V:{i.pasteProperties();break}case KEYBOARD_BUTTON_CODE.CTRL:{i.setAlterateState();break}}}),window.addEventListener("keyup",e=>{const t=i.planner,n=t.get("mode");switch(e.keyCode){case KEYBOARD_BUTTON_CODE.ALT:{MODE_SNAPPING.includes(n)&&i.toggleSnap(t.snapMask.merge(t.snapMask.get("tempSnapConfiguartion")));break}case KEYBOARD_BUTTON_CODE.CTRL:{i.setAlterateState();break}}})}}const TOP_OFFSET=38,LEFT_OFFSET=-220,ToggleSetting=({title:i,toggleState:e,toggleOn:t,toggleOff:n})=>{const[s,o]=React.useState(e||!1),a=()=>{o(!s),s?n():t()};return jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[jsxRuntimeExports.jsx("div",{className:"fp__onoffswitch",onClick:a,children:jsxRuntimeExports.jsxs("div",{className:cn("fp__onoffswitch_label",s?"fp__onoffswitch_label-checked":""),children:[jsxRuntimeExports.jsx("span",{className:"fp__onoffswitch_inner"}),jsxRuntimeExports.jsx("span",{className:"fp__onoffswitch_switch"})]})}),jsxRuntimeExports.jsx("div",{className:"fp__onoffswitch_caption",children:i})]})},Popup=({popupEvent:i,onClose:e})=>{const{planner:t,toggleSnap:n}=useReactPlannerStore(),{snapMask:s}=t,o=React.useRef(null);React.useEffect(()=>{if(i){const{x:c,y:u}=i.rect;o.current={top:u+TOP_OFFSET,left:c+LEFT_OFFSET}}},[i]);const a=()=>{e()},l=c=>n(s.merge(c));return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[i&&jsxRuntimeExports.jsx("div",{className:"fixed inset-0 bg-black/30 z-10",onClick:a}),jsxRuntimeExports.jsxs("div",{style:i&&i.rect?{top:i.rect.y+TOP_OFFSET,left:i.rect.x+LEFT_OFFSET}:o.current?o.current:{},id:"headerbar-popup",className:cn("fixed select-none z-10 shadow-md !gap-0 rounded-lg pt-4 fp_side-bar !min-h-[200px] !min-w-[250px] max-w-[250px] !max-h-[300px] transition-all duration-200 ease-out transform",i?"opacity-100 scale-100":"opacity-0 scale-95 pointer-events-none"),children:[jsxRuntimeExports.jsx("header",{className:"px-[18px] sticky top-0 left-0 gap-3 flex flex-col",children:jsxRuntimeExports.jsx("div",{className:"flex items-center gap-1",children:jsxRuntimeExports.jsx("span",{className:cn("flex flex-col gap-0.5"),children:jsxRuntimeExports.jsx("span",{className:"fp-sidebar-label capitalize",children:"Settings"})})})}),jsxRuntimeExports.jsxs("div",{className:"min-h-28 w-full space-y-2.5 px-2 py-4",children:[jsxRuntimeExports.jsx(ToggleSetting,{title:"Snap to Point",toggleState:s.get(SNAP_POINT),toggleOn:()=>{l({SNAP_POINT:!0})},toggleOff:()=>{l({SNAP_POINT:!1})}}),jsxRuntimeExports.jsx(ToggleSetting,{toggleOn:()=>{l({SNAP_LINE:!0})},toggleOff:()=>{l({SNAP_LINE:!1})},toggleState:s.get(SNAP_LINE),title:"Snap to Line"}),jsxRuntimeExports.jsx(ToggleSetting,{toggleOn:()=>{l({SNAP_SEGMENT:!0})},toggleOff:()=>{l({SNAP_SEGMENT:!1})},toggleState:s.get(SNAP_SEGMENT),title:"Snap to Segment"}),jsxRuntimeExports.jsx(ToggleSetting,{toggleOn:()=>{l({SNAP_GRID:!0})},toggleOff:()=>{l({SNAP_GRID:!1})},toggleState:s.get(SNAP_GRID),title:"Snap to Grid"}),jsxRuntimeExports.jsx(ToggleSetting,{toggleOn:()=>{l({SNAP_GUIDE:!0})},toggleOff:()=>{l({SNAP_GUIDE:!1})},toggleState:s.get(SNAP_GUIDE),title:"Snap to Guide"})]})]})]})},Headerbar=({onBack:i,onSave:e})=>{const{undo:t,redo:n,plan:s,setPlan:o}=useReactPlannerStore(),[a,l]=React.useState(!1),[c,u]=React.useState(null),h=()=>{l(!0)},d=p=>{if(!s)return;l(!1);const m=p.target.value.trim();if(m&&m!==(s==null?void 0:s.planTitle)){o({...s,planTitle:m});try{e&&e({title:m,description:""})}catch{}}};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"floor_planner-headerbar absolute flex items-center justify-between z-[9001] py-[3px] px-[1em] w-full select-none cursor-default top-0 m-0",children:[jsxRuntimeExports.jsx(ToolbarButton,{className:"border border-white rounded -ml-1",active:!1,tooltip:"Go Back",onClick:()=>{i&&i()},children:jsxRuntimeExports.jsx(MdArrowBack,{})}),jsxRuntimeExports.jsx("div",{className:"flex flex-col items-center justify-center",children:a?jsxRuntimeExports.jsx("input",{autoFocus:!0,type:"text",defaultValue:s==null?void 0:s.planTitle,onBlur:d,onKeyDown:p=>{(p.key==="Enter"||p.key==="Escape")&&d(p)},className:"bg-transparent border-b border-gray-400 outline-none text-lg text-center"}):jsxRuntimeExports.jsx("span",{onDoubleClick:h,className:"projectName__fp text-lg",title:(s==null?void 0:s.planTitle)??"Example House",children:(s==null?void 0:s.planTitle)??"Example House"})}),jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 relative",children:[jsxRuntimeExports.jsx(ToolbarButton,{active:!1,tooltip:"Undo (CTRL-Z)",onClick:t,children:jsxRuntimeExports.jsx(BiUndo,{})}),jsxRuntimeExports.jsx(ToolbarButton,{active:!1,tooltip:"Redo (CTRL-SHIFT-Z)",onClick:n,children:jsxRuntimeExports.jsx(BiRedo,{})}),jsxRuntimeExports.jsx("div",{className:"ml-8",children:jsxRuntimeExports.jsx(ToolbarButton,{active:!1,tooltip:"Settings",onClick:p=>{u({rect:p.currentTarget.getBoundingClientRect()})},children:jsxRuntimeExports.jsx(FaCog,{size:17})})})]})]}),jsxRuntimeExports.jsx(Popup,{popupEvent:c,onClose:()=>u(null)})]})};var collectionUtils={exports:{}},hasRequiredCollectionUtils;function requireCollectionUtils(){if(hasRequiredCollectionUtils)return collectionUtils.exports;hasRequiredCollectionUtils=1;var i=collectionUtils.exports={};return i.forEach=function(e,t){for(var n=0;n<e.length;n++){var s=t(e[n]);if(s)return s}},collectionUtils.exports}var elementUtils,hasRequiredElementUtils;function requireElementUtils(){return hasRequiredElementUtils||(hasRequiredElementUtils=1,elementUtils=function(i){var e=i.stateHandler.getState;function t(a){var l=e(a);return l&&!!l.isDetectable}function n(a){e(a).isDetectable=!0}function s(a){return!!e(a).busy}function o(a,l){e(a).busy=!!l}return{isDetectable:t,markAsDetectable:n,isBusy:s,markBusy:o}}),elementUtils}var listenerHandler,hasRequiredListenerHandler;function requireListenerHandler(){return hasRequiredListenerHandler||(hasRequiredListenerHandler=1,listenerHandler=function(i){var e={};function t(a){var l=i.get(a);return l===void 0?[]:e[l]||[]}function n(a,l){var c=i.get(a);e[c]||(e[c]=[]),e[c].push(l)}function s(a,l){for(var c=t(a),u=0,h=c.length;u<h;++u)if(c[u]===l){c.splice(u,1);break}}function o(a){var l=t(a);l&&(l.length=0)}return{get:t,add:n,removeListener:s,removeAllListeners:o}}),listenerHandler}var idGenerator,hasRequiredIdGenerator;function requireIdGenerator(){return hasRequiredIdGenerator||(hasRequiredIdGenerator=1,idGenerator=function(){var i=1;function e(){return i++}return{generate:e}}),idGenerator}var idHandler,hasRequiredIdHandler;function requireIdHandler(){return hasRequiredIdHandler||(hasRequiredIdHandler=1,idHandler=function(i){var e=i.idGenerator,t=i.stateHandler.getState;function n(o){var a=t(o);return a&&a.id!==void 0?a.id:null}function s(o){var a=t(o);if(!a)throw new Error("setId required the element to have a resize detection state.");var l=e.generate();return a.id=l,l}return{get:n,set:s}}),idHandler}var reporter,hasRequiredReporter;function requireReporter(){return hasRequiredReporter||(hasRequiredReporter=1,reporter=function(i){function e(){}var t={log:e,warn:e,error:e};if(!i&&window.console){var n=function(s,o){s[o]=function(){var l=console[o];if(l.apply)l.apply(console,arguments);else for(var c=0;c<arguments.length;c++)l(arguments[c])}};n(t,"log"),n(t,"warn"),n(t,"error")}return t}),reporter}var browserDetector={exports:{}},hasRequiredBrowserDetector;function requireBrowserDetector(){if(hasRequiredBrowserDetector)return browserDetector.exports;hasRequiredBrowserDetector=1;var i=browserDetector.exports={};return i.isIE=function(e){function t(){var s=navigator.userAgent.toLowerCase();return s.indexOf("msie")!==-1||s.indexOf("trident")!==-1||s.indexOf(" edge/")!==-1}if(!t())return!1;if(!e)return!0;var n=(function(){var s,o=3,a=document.createElement("div"),l=a.getElementsByTagName("i");do a.innerHTML="<!--[if gt IE "+ ++o+"]><i></i><![endif]-->";while(l[0]);return o>4?o:s})();return e===n},i.isLegacyOpera=function(){return!!window.opera},browserDetector.exports}var utils={exports:{}},hasRequiredUtils;function requireUtils(){if(hasRequiredUtils)return utils.exports;hasRequiredUtils=1;var i=utils.exports={};i.getOption=e;function e(t,n,s){var o=t[n];return o==null&&s!==void 0?s:o}return utils.exports}var batchProcessor,hasRequiredBatchProcessor;function requireBatchProcessor(){if(hasRequiredBatchProcessor)return batchProcessor;hasRequiredBatchProcessor=1;var i=requireUtils();batchProcessor=function(n){n=n||{};var s=n.reporter,o=i.getOption(n,"async",!0),a=i.getOption(n,"auto",!0);a&&!o&&(s&&s.warn("Invalid options combination. auto=true and async=false is invalid. Setting async=true."),o=!0);var l=e(),c,u=!1;function h(_,x){!u&&a&&o&&l.size()===0&&m(),l.add(_,x)}function d(){for(u=!0;l.size();){var _=l;l=e(),_.process()}u=!1}function p(_){u||(_===void 0&&(_=o),c&&(g(c),c=null),_?m():d())}function m(){c=y(d)}function g(_){var x=clearTimeout;return x(_)}function y(_){var x=function(S){return setTimeout(S,0)};return x(_)}return{add:h,force:p}};function e(){var t={},n=0,s=0,o=0;function a(u,h){h||(h=u,u=0),u>s?s=u:u<o&&(o=u),t[u]||(t[u]=[]),t[u].push(h),n++}function l(){for(var u=o;u<=s;u++)for(var h=t[u],d=0;d<h.length;d++){var p=h[d];p()}}function c(){return n}return{add:a,process:l,size:c}}return batchProcessor}var stateHandler,hasRequiredStateHandler;function requireStateHandler(){if(hasRequiredStateHandler)return stateHandler;hasRequiredStateHandler=1;var i="_erd";function e(s){return s[i]={},t(s)}function t(s){return s[i]}function n(s){delete s[i]}return stateHandler={initState:e,getState:t,cleanState:n},stateHandler}var object,hasRequiredObject;function requireObject(){if(hasRequiredObject)return object;hasRequiredObject=1;var i=requireBrowserDetector();return object=function(e){e=e||{};var t=e.reporter,n=e.batchProcessor,s=e.stateHandler.getState;if(!t)throw new Error("Missing required dependency: reporter.");function o(h,d){function p(){d(h)}if(i.isIE(8))s(h).object={proxy:p},h.attachEvent("onresize",p);else{var m=c(h);if(!m)throw new Error("Element is not detectable by this strategy.");m.contentDocument.defaultView.addEventListener("resize",p)}}function a(h){var d=e.important?" !important; ":"; ";return(h.join(d)+d).trim()}function l(h,d,p){p||(p=d,d=h,h=null),h=h||{},h.debug;function m(g,y){var _=a(["display: block","position: absolute","top: 0","left: 0","width: 100%","height: 100%","border: none","padding: 0","margin: 0","opacity: 0","z-index: -1000","pointer-events: none"]),x=!1,S=window.getComputedStyle(g),b=g.offsetWidth,E=g.offsetHeight;s(g).startSize={width:b,height:E};function M(){function w(){if(S.position==="static"){g.style.setProperty("position","relative",h.important?"important":"");var A=function(I,D,k,H){function X(Y){return Y.replace(/[^-\d\.]/g,"")}var te=k[H];te!=="auto"&&X(te)!=="0"&&(I.warn("An element that is positioned static has style."+H+"="+te+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+H+" will be set to 0. Element: ",D),D.style.setProperty(H,"0",h.important?"important":""))};A(t,g,S,"top"),A(t,g,S,"right"),A(t,g,S,"bottom"),A(t,g,S,"left")}}function P(){x||w();function A(D,k){if(!D.contentDocument){var H=s(D);H.checkForObjectDocumentTimeoutId&&window.clearTimeout(H.checkForObjectDocumentTimeoutId),H.checkForObjectDocumentTimeoutId=setTimeout(function(){H.checkForObjectDocumentTimeoutId=0,A(D,k)},100);return}k(D.contentDocument)}var I=this;A(I,function(k){y(g)})}S.position!==""&&(w(),x=!0);var C=document.createElement("object");C.style.cssText=_,C.tabIndex=-1,C.type="text/html",C.setAttribute("aria-hidden","true"),C.onload=P,i.isIE()||(C.data="about:blank"),s(g)&&(g.appendChild(C),s(g).object=C,i.isIE()&&(C.data="about:blank"))}n?n.add(M):M()}i.isIE(8)?p(d):m(d,p)}function c(h){return s(h).object}function u(h){if(s(h)){var d=c(h);d&&(i.isIE(8)?h.detachEvent("onresize",d.proxy):h.removeChild(d),s(h).checkForObjectDocumentTimeoutId&&window.clearTimeout(s(h).checkForObjectDocumentTimeoutId),delete s(h).object)}}return{makeDetectable:l,addListener:o,uninstall:u}},object}var scroll,hasRequiredScroll;function requireScroll(){if(hasRequiredScroll)return scroll;hasRequiredScroll=1;var i=requireCollectionUtils().forEach;return scroll=function(e){e=e||{};var t=e.reporter,n=e.batchProcessor,s=e.stateHandler.getState;e.stateHandler.hasState;var o=e.idHandler;if(!n)throw new Error("Missing required dependency: batchProcessor");if(!t)throw new Error("Missing required dependency: reporter.");var a=d(),l="erd_scroll_detection_scrollbar_style",c="erd_scroll_detection_container";function u(M){p(M,l,c)}u(window.document);function h(M){var w=e.important?" !important; ":"; ";return(M.join(w)+w).trim()}function d(){var M=500,w=500,P=document.createElement("div");P.style.cssText=h(["position: absolute","width: "+M*2+"px","height: "+w*2+"px","visibility: hidden","margin: 0","padding: 0"]);var C=document.createElement("div");C.style.cssText=h(["position: absolute","width: "+M+"px","height: "+w+"px","overflow: scroll","visibility: none","top: "+-M*3+"px","left: "+-w*3+"px","visibility: hidden","margin: 0","padding: 0"]),C.appendChild(P),document.body.insertBefore(C,document.body.firstChild);var A=M-C.clientWidth,I=w-C.clientHeight;return document.body.removeChild(C),{width:A,height:I}}function p(M,w,P){function C(k,H){H=H||function(te){M.head.appendChild(te)};var X=M.createElement("style");return X.innerHTML=k,X.id=w,H(X),X}if(!M.getElementById(w)){var A=P+"_animation",I=P+"_animation_active",D=`/* Created by the element-resize-detector library. */
3931
+ `,children:e}),document.body)},ToolbarButton=({active:i,tooltip:e,tooltipPosition:t="right",onClick:n,children:s,className:o,showDelay:a=300,hideDelay:l=0})=>{const c=React.useRef(null),u=React.useRef(null),h=React.useRef(null),[d,p]=React.useState(!1),m=()=>{u.current&&(window.clearTimeout(u.current),u.current=null),h.current&&(window.clearTimeout(h.current),h.current=null)},g=()=>{m(),u.current=window.setTimeout(()=>{p(!0)},a)},y=()=>{m(),h.current=window.setTimeout(()=>{p(!1)},l)};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{ref:c,className:cn("w-[30px] h-[30px] flex items-center justify-center text-[25px] cursor-pointer",o),onMouseEnter:g,onMouseLeave:y,onClick:n,children:jsxRuntimeExports.jsx("div",{className:cn("transition-colors",i?"text-dark-blue":""),children:s})}),jsxRuntimeExports.jsx(Tooltip,{anchorEl:c.current,title:e,visible:d,position:t})]})},getSVGScreenshot=()=>new Promise(async i=>{const e=document.getElementsByTagName("svg");if(!e.length)return;let t=e[0];for(let p=1;p<e.length;p++)e[p].width.baseVal.value>t.width.baseVal.value&&(t=e[p]);const n=t.cloneNode(!0),s=n.querySelectorAll("image");await Promise.all(Array.from(s).map(async p=>{const m=p.getAttribute("href")||p.getAttribute("xlink:href");if(m)try{const y=await(await fetch(m)).blob(),_=new FileReader;await new Promise(x=>{_.onloadend=()=>{p.setAttribute("href",_.result),x()},_.readAsDataURL(y)})}catch(g){console.warn("⚠️ Could not inline image:",m,g)}}));const a=new XMLSerializer().serializeToString(n),l=t.width.baseVal.value,c=t.height.baseVal.value,u=document.createElement("canvas");u.width=l,u.height=c;const h=u.getContext("2d");h.fillStyle="white",h.fillRect(0,0,l,c);const d=new Image;d.src=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(a)))}`,d.onload=()=>{h.drawImage(d,0,0,l,c),i(u.toDataURL("image/png"))}});function TbScreenshot(i){return GenIcon({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M7 19a2 2 0 0 1 -2 -2"},child:[]},{tag:"path",attr:{d:"M5 13v-2"},child:[]},{tag:"path",attr:{d:"M5 7a2 2 0 0 1 2 -2"},child:[]},{tag:"path",attr:{d:"M11 5h2"},child:[]},{tag:"path",attr:{d:"M17 5a2 2 0 0 1 2 2"},child:[]},{tag:"path",attr:{d:"M19 11v2"},child:[]},{tag:"path",attr:{d:"M19 17v4"},child:[]},{tag:"path",attr:{d:"M21 19h-4"},child:[]},{tag:"path",attr:{d:"M13 19h-2"},child:[]}]})(i)}const imageBrowserDownload=i=>{let e=document.createElement("a"),t="output"+Date.now()+".png";t=window.prompt("Insert output filename",t),t&&(e.setAttribute("download",t),e.href=i,e.style.display="none",document.body.appendChild(e),e.click(),document.body.removeChild(e))};function ToolbarScreenshotButton({mode:i}){const e=n=>{n.preventDefault();const s=document.getElementsByTagName("canvas")[0];imageBrowserDownload(s.toDataURL())},t=async n=>{n.preventDefault(),getSVGScreenshot().then(imageBrowserDownload)};return[MODE_3D_FIRST_PERSON,MODE_3D_VIEW].includes(i)?jsxRuntimeExports.jsx(ToolbarButton,{active:!1,tooltip:"Get Screenshot",onClick:e,children:jsxRuntimeExports.jsx(TbScreenshot,{size:28})}):[MODE_IDLE$1,MODE_2D_ZOOM_IN,MODE_2D_ZOOM_OUT,MODE_2D_PAN,MODE_WAITING_DRAWING_LINE,MODE_WAITING_DRAWING_SURFACE,MODE_DRAGGING_LINE,MODE_DRAGGING_VERTEX,MODE_DRAGGING_ITEM,MODE_DRAWING_LINE,MODE_DRAWING_SURFACE,MODE_DRAWING_HOLE,MODE_DRAWING_ITEM,MODE_DRAGGING_HOLE,MODE_ROTATING_ITEM].includes(i)?jsxRuntimeExports.jsx(ToolbarButton,{active:!1,tooltip:"Get Screenshot",onClick:t,children:jsxRuntimeExports.jsx(TbScreenshot,{size:28})}):null}function LuBrickWall(i){return GenIcon({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{width:"18",height:"18",x:"3",y:"3",rx:"2"},child:[]},{tag:"path",attr:{d:"M12 9v6"},child:[]},{tag:"path",attr:{d:"M16 15v6"},child:[]},{tag:"path",attr:{d:"M16 3v6"},child:[]},{tag:"path",attr:{d:"M3 15h18"},child:[]},{tag:"path",attr:{d:"M3 9h18"},child:[]},{tag:"path",attr:{d:"M8 15v6"},child:[]},{tag:"path",attr:{d:"M8 3v6"},child:[]}]})(i)}function PiWall(i){return GenIcon({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M224,48H32a8,8,0,0,0-8,8V200a8,8,0,0,0,8,8H224a8,8,0,0,0,8-8V56A8,8,0,0,0,224,48ZM88,144V112h80v32Zm-48,0V112H72v32Zm144-32h32v32H184Zm32-16H136V64h80ZM120,64V96H40V64ZM40,160h80v32H40Zm96,32V160h80v32Z"},child:[]}]})(i)}const EREG_NUMBER=/^.*$/;function FormColorInput({onChange:i,...e}){const[t,n]=React.useState(""),s=React.useRef(null);React.useEffect(()=>{n(e.value)},[e.value]);const o=l=>{if(!l)return;const c=l.target.value;EREG_NUMBER.test(c)&&i&&i(l)},a=l=>{(!l.key||l.key==="Enter")&&o({target:{value:t}})};return jsxRuntimeExports.jsxs("div",{className:"color-field flex-1 flex pr-3 mt-1 cursor-pointer",children:[jsxRuntimeExports.jsx("div",{className:"colorBox relative w-[22px] h-[22px]",style:{background:e.value},onClick:()=>{s.current&&s.current.click()},children:jsxRuntimeExports.jsx("input",{ref:s,type:"color",onChange:o,value:e.value,className:"absolute invisible h-full w-full"})}),jsxRuntimeExports.jsx("div",{className:"flex-1 pl-2",children:jsxRuntimeExports.jsx("input",{className:"colorFieldInput min-w-[90px] cursor-pointer",type:"text",value:t,onKeyDown:a,onChange:l=>n(l.target.value),onBlur:a})})]})}function PropertyColor({value:i,onUpdate:e,configs:t,propertyName:n,sourceElement:s,internalState:o}){const a=s.toJS(),{planner:l}=useReactPlannerStore(),c=u=>t.hook?t.hook(u,s,o,l).then(h=>e(h)):e(u);return React.useEffect(()=>{var p;const u=a.type==="wall",h=n==="colorA"||n==="colorB",d=!((p=a.properties)!=null&&p[n]);u&&h&&d&&c(i)},[a.type,a.properties,n,c,i]),jsxRuntimeExports.jsxs("div",{className:"PropertyColor w-full mb-2",children:[jsxRuntimeExports.jsx(FormLabel,{children:t.label}),jsxRuntimeExports.jsx(FormColorInput,{value:i,onChange:u=>c(u.target.value)})]})}function PropertyEnum({value:i,onUpdate:e,configs:t,sourceElement:n,internalState:s}){const{planner:o}=useReactPlannerStore(),a=l=>t.hook?t.hook(l,n,s,o).then(c=>e(c)):e(l);return jsxRuntimeExports.jsxs("div",{className:"PropertyEnum w-full mb-2",children:[jsxRuntimeExports.jsx(FormLabel,{children:t.label}),jsxRuntimeExports.jsx(FormSelect,{value:i,onChange:l=>a(l.target.value),children:Seq(t.values).entrySeq().map(([l,c])=>jsxRuntimeExports.jsx("option",{value:l,children:c},l))})]})}function PropertyString({value:i,onUpdate:e,configs:t,sourceElement:n,internalState:s}){const{planner:o}=useReactPlannerStore();let a=l=>t.hook?t.hook(l,n,s,o).then(c=>e(c)):e(l);return jsxRuntimeExports.jsxs("div",{className:"PropertyString w-full mb-2",children:[jsxRuntimeExports.jsx(FormLabel,{children:t.label}),jsxRuntimeExports.jsx(FormTextInput,{value:i,onChange:l=>a(l.target.value)})]})}function PropertyNumber({value:i,onUpdate:e,onValid:t,configs:n,sourceElement:s,internalState:o}){const{planner:a}=useReactPlannerStore(),l=c=>{let u=parseFloat(c);return isNaN(u)&&(u=0),n.hook?n.hook(u,s,o,a).then(h=>e(h)):e(u)};return jsxRuntimeExports.jsxs("div",{className:"PropertyNumber w-full mb-2",children:[jsxRuntimeExports.jsx(FormLabel,{children:n.label}),jsxRuntimeExports.jsx(FormNumberInput,{value:i,onChange:c=>l(c.target.value),onValid:t,min:n.min,max:n.max})]})}function PropertyLengthMeasure({value:i,onUpdate:e,onValid:t,configs:n,sourceElement:s,internalState:o}){const{planner:a}=useReactPlannerStore(),{mode:l}=a,c=i.get("length")||0,u=i.get("_length")||c,h=i.get("_unit")||UNIT_CENTIMETER,{hook:d,label:p,...m}=n,g=(y,_)=>{let x=toFixedFloat(y),S=i.merge({length:_!==UNIT_CENTIMETER?convert(x).from(_).to(UNIT_CENTIMETER):x,_length:y,_unit:_});return d?d(S,s,o,a).then(b=>e(b)):e(S)};if(l!==MODE_3D_VIEW)return jsxRuntimeExports.jsxs("div",{className:"PropertyLengthMeasure w-full mb-2",children:[jsxRuntimeExports.jsx(FormLabel,{children:p}),jsxRuntimeExports.jsxs("div",{className:"w-full flex",children:[jsxRuntimeExports.jsx(FormNumberInput,{value:u,style:{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:0},onChange:y=>g(y.target.value,h),onValid:t,...m}),jsxRuntimeExports.jsx("div",{className:"w-1/4 [&>*:first-child]:text-center",children:jsxRuntimeExports.jsx(FormSelect,{style:{borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"},disabled:!0,value:h,onChange:y=>{},children:UNITS_LENGTH.map(y=>jsxRuntimeExports.jsx("option",{value:y,children:y},y))})})]})]})}function Button({type:i="button",size:e="normal",style:t,styleHover:n,children:s,...o}){const[a,l]=React.useState(!1),c="inline-block font-normal leading-[1.25] text-center whitespace-nowrap align-middle cursor-pointer select-none outline-none border border-solid w-full transition-colors duration-175 ease-linear rounded-[2px]",u=e==="small"?"text-[12px] px-2 py-[3px]":e==="large"?"px-5 py-2":"text-[14px] px-3 py-[5px]",h={backgroundColor:"#e6e6e6",borderColor:"#adadad"},d={backgroundColor:"#d4d4d4",borderColor:"#8c8c8c"};return jsxRuntimeExports.jsx("button",{type:i,className:`${c} ${u}`,style:{...a?{...d,...n}:{...h,...t}},onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),...o,children:s})}const tableStyle={width:"100%",borderSpacing:"2px 0",marginBottom:"2px"},firstTdStyle={width:"6em",textTransform:"capitalize"},PropertyStyle={tableStyle,firstTdStyle};function PropertyToggle({value:i,onUpdate:e,configs:t,sourceElement:n,internalState:s}){const{planner:o}=useReactPlannerStore(),a=l=>t.hook?t.hook(l,n,s,o).then(c=>e(c)):e(l);return jsxRuntimeExports.jsx("table",{className:"PropertyToggle",style:PropertyStyle.tableStyle,children:jsxRuntimeExports.jsx("tbody",{children:jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{style:PropertyStyle.firstTdStyle,children:jsxRuntimeExports.jsx(FormLabel,{children:t.label})}),jsxRuntimeExports.jsx("td",{children:jsxRuntimeExports.jsx(Button,{onClick:()=>a(!i),size:"small",children:t.actionName})})]})})})}function PropertyCheckbox({value:i,onUpdate:e,configs:t,sourceElement:n,internalState:s}){const{planner:o}=useReactPlannerStore(),a=l=>t.hook?t.hook(l,n,s,o).then(c=>e(c)):e(l);return jsxRuntimeExports.jsxs("div",{className:"PropertyCheckbox w-full flex items-center gap-2 mb-2",children:[jsxRuntimeExports.jsx("input",{className:"m-0 mt-0.5",type:"checkbox",checked:i,onChange:()=>a(!i)}),jsxRuntimeExports.jsx(FormLabel,{className:"mb-0",children:t.label})]})}function PropertyHidden(){return null}function PropertyReadOnly({value:i,configs:e}){return jsxRuntimeExports.jsx("table",{className:"PropertyReadOnly",style:PropertyStyle.tableStyle,children:jsxRuntimeExports.jsx("tbody",{children:jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{style:PropertyStyle.firstTdStyle,children:jsxRuntimeExports.jsx(FormLabel,{children:e.label})}),jsxRuntimeExports.jsx("td",{children:jsxRuntimeExports.jsx("div",{children:i})})]})})})}class Catalog{constructor(e=UNIT_CENTIMETER){tt(this,"elements");tt(this,"categories");tt(this,"propertyTypes");tt(this,"unit");this.elements={},this.categories={root:{name:"root",label:"/",elements:[],categories:[]}},this.propertyTypes={},this.unit=e,this.registerMultiplePropertyType([["color",PropertyColor,PropertyColor],["enum",PropertyEnum,PropertyEnum],["string",PropertyString,PropertyString],["number",PropertyNumber,PropertyNumber],["length-measure",PropertyLengthMeasure,PropertyLengthMeasure],["toggle",PropertyToggle,PropertyToggle],["checkbox",PropertyCheckbox,PropertyCheckbox],["hidden",PropertyHidden,PropertyHidden],["read-only",PropertyReadOnly,PropertyReadOnly]])}getElement(e){if(this.hasElement(e))return this.elements[e];throw new Error(`Element ${e} does not exist in catalog`)}getCategory(e){if(this.hasCategory(e))return this.categories[e];throw new Error(`Category ${e} does not exist in catalog`)}getPropertyType(e){if(this.propertyTypes.hasOwnProperty(e))return this.propertyTypes[e];throw new Error(`Element ${e} does not exist in catalog`)}registerElement(e){e.properties=e.properties||{},this.validateElement(e)&&(this.elements[e.name]=e,this.categories.root.elements.push(this.elements[e.name]))}registerMultipleElements(e){e.forEach(t=>this.registerElement(t))}registerPropertyType(e,t,n){this.propertyTypes[e]={type:e,Viewer:t,Editor:n}}registerMultiplePropertyType(e){e.forEach(t=>this.registerPropertyType(...t))}validateElement(e){if(!e.hasOwnProperty("name"))throw new Error("Element not valid");let t=e.name;if(!e.hasOwnProperty("prototype"))throw new Error(`Element ${t} doesn't have prototype`);if(!e.hasOwnProperty("info"))throw new Error(`Element ${t} doesn't have info`);if(!e.info.hasOwnProperty("tag"))throw new Error(`Element ${t} doesn't have tag`);if(!e.info.hasOwnProperty("description"))throw new Error(`Element ${t} doesn't have description`);if(!e.info.hasOwnProperty("image"))throw new Error(`Element ${t} doesn't have image`);if(!e.hasOwnProperty("render2D"))throw new Error(`Element ${t} doesn't have render2D handler`);if(!e.hasOwnProperty("render3D"))throw new Error(`Element ${t} doesn't have render3D handler`);if(!e.hasOwnProperty("properties"))throw new Error(`Element ${t} doesn't have properties`);for(let n in e.properties){let s=e.properties[n];if(!s.hasOwnProperty("type"))throw new Error(`Element ${t}, Property ${n} doesn't have type`);if(!s.hasOwnProperty("defaultValue"))throw new Error(`Element ${t}, Property ${n} doesn't have defaultValue`)}return!0}hasElement(e){return this.elements.hasOwnProperty(e)}registerCategory(e,t,n){return this.validateCategory(e,t)?(this.categories[e]={name:e,label:t,categories:[],elements:[]},this.categories.root.categories.push(this.categories[e]),n&&n.length&&n.forEach(s=>this.addToCategory(e,s)),this.categories[e]):null}addToCategory(e,t){if(this.hasElement(t.name))this.categories[e].elements.push(t),this.categories.root.elements.splice(this.categories.root.elements.indexOf(t),1);else if(this.hasCategory(t.name))this.categories[e].categories.push(t),this.categories.root.categories.splice(this.categories.root.categories.indexOf(t),1);else throw new Error(`child ${t} is either category nor element`)}categoryHasElement(e,t){return this.hasCategory(e)&&this.categories[e].elements.some(n=>n.name===t)}validateCategory(e,t){if(!e)throw new Error("Category has undefined name");if(e==="")throw new Error("Category has empty name");if(this.hasCategory(e))throw new Error("Category has already been registered");return!0}hasCategory(e){return this.categories.hasOwnProperty(e)}}function BiRedo(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M9 18h3v-2H9c-1.654 0-3-1.346-3-3s1.346-3 3-3h6v3l5-4-5-4v3H9c-2.757 0-5 2.243-5 5s2.243 5 5 5z"},child:[]}]})(i)}function BiSearch(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M10 18a7.952 7.952 0 0 0 4.897-1.688l4.396 4.396 1.414-1.414-4.396-4.396A7.952 7.952 0 0 0 18 10c0-4.411-3.589-8-8-8s-8 3.589-8 8 3.589 8 8 8zm0-14c3.309 0 6 2.691 6 6s-2.691 6-6 6-6-2.691-6-6 2.691-6 6-6z"},child:[]}]})(i)}function BiUndo(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M9 10h6c1.654 0 3 1.346 3 3s-1.346 3-3 3h-3v2h3c2.757 0 5-2.243 5-5s-2.243-5-5-5H9V5L4 9l5 4v-3z"},child:[]}]})(i)}const SearchInput=({term:i="",placeholder:e="Search",noSpacing:t=!1,onClick:n=()=>!1,isStatic:s=!1,hasDropDown:o=!1,onSearch:a,className:l,value:c})=>{const[u,h]=React.useState("");return React.useEffect(()=>{c!==void 0&&c!==u&&h(c??"")},[c]),jsxRuntimeExports.jsxs("div",{className:cn(`relative w-full ${t?"mt-1":"mt-2"}`,l),onClick:n??(()=>!1),children:[jsxRuntimeExports.jsx("span",{className:`absolute left-0 top-2 text-[#637381] ${t?"":"ml-2"}`,style:{zIndex:2},children:jsxRuntimeExports.jsx(BiSearch,{size:18})}),s?jsxRuntimeExports.jsx("div",{className:"w-full rounded border border-gray-300 bg-white px-3 py-1.5 text-xs font-normal cursor-pointer",style:{marginTop:3},children:i}):jsxRuntimeExports.jsx("input",{className:"w-full rounded pl-[30px] focus:outline-none border border-gray-300 bg-white pr-3 py-1.5 text-sm text-gray-900",type:"text",placeholder:e,onChange:d=>{a(d.target.value,d),h(d.target.value)},value:u,onClick:n??(()=>!1)}),n!==null&&o&&jsxRuntimeExports.jsx("span",{className:`absolute right-2 top-1/2 -translate-y-1/2 ${t?"":"ml-2"}`,style:{zIndex:1},children:jsxRuntimeExports.jsx(FaSortDown,{className:"-mb-1"})})]})},TOP_OFFSET$1=0,LEFT_OFFSET$1=58,getCatalogOptions=i=>{const e=[{label:"All Categories",value:"all"}],t=i.map(n=>n.info.tag);for(const n of t){let s=e;for(let o=0;o<n.length;o++){const a=n[o];let l=s.find(c=>c.label===a);l||(l={label:a,value:a},o<n.length-1&&(l.options=[{label:"All Categories",value:"all"}]),s.push(l)),o<n.length-1&&l.options&&(s=l.options)}}return e},SegmentedTabs=({selected:i,options:e,onChange:t})=>{const n=React.useMemo(()=>e.findIndex(o=>o.value===i),[e,i]),s=100/e.length;return jsxRuntimeExports.jsxs("div",{className:"relative w-full rounded-lg border border-gray-200 bg-white p-1",children:[jsxRuntimeExports.jsx("div",{className:"absolute top-1 bottom-1 rounded-md bg-slate-900 transition-transform duration-300 ease-out",style:{width:`calc(${s}% - 4px)`,transform:`translateX(${n*100}%)`}}),jsxRuntimeExports.jsx("div",{role:"tablist",className:"relative z-10 grid",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map(o=>{const a=o.value===i;return jsxRuntimeExports.jsx("button",{role:"tab","aria-selected":a,className:cn("h-8 text-sm font-medium capitalize transition-colors",a?"text-white":"text-gray-700 hover:text-black"),onClick:()=>t(o),children:o.label},o.value)})})]})},NestedSelect=({options:i,selections:e,level:t,onChange:n})=>{var s,o;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("select",{className:"w-full rounded capitalize cursor-pointer focus:outline-none border border-gray-300 bg-white pr-3 pl-1.5 py-1.5 text-sm text-gray-900",value:e[t]||"all",onChange:a=>n(t,a.target.value),children:i.map(a=>jsxRuntimeExports.jsx("option",{className:"capitalize",value:a.value,children:a.label},a.value))}),e[t]&&e[t]!=="all"&&((s=i.find(a=>a.value===e[t]))==null?void 0:s.options)&&jsxRuntimeExports.jsx(NestedSelect,{options:((o=i.find(a=>a.value===e[t]))==null?void 0:o.options)||[],level:t+1,selections:e,onChange:n})]})},Popup$1=({catalog:i,popupEvent:e,onClose:t})=>{const{setToast:n,selectToolDrawingLine:s,selectToolDrawingItem:o,selectToolDrawingHole:a,pushLastSelectedCatalogElementToHistory:l}=useReactPlannerStore(),[c,u]=React.useState([]),[h,d]=React.useState(""),[p,m]=React.useState([]),[g,y]=React.useState(["all"]),[_,x]=React.useState([]),[S,b]=React.useState(""),E=React.useRef(null),M=React.useRef(null),w=()=>{b(""),m([]),u([]),y(["all"]),d("")};React.useEffect(()=>{if(e){w();const H=i.getCategory(e.page).elements.filter(Y=>Y.info.visibility?Y.info.visibility.catalog:!0);E.current=e.page,x(H);const{x:X,y:te}=e.rect;if(M.current={top:te+TOP_OFFSET$1,left:X+LEFT_OFFSET$1},e.page==="objects"){const Y=Array.from(new Set(H.map(_e=>_e.info.category).filter(Boolean))),re=Y[0]??"",G=H.filter(_e=>_e.info.category===re);d(re),u(Y),m(getCatalogOptions(G))}}},[e]);const P=()=>{t()},C=k=>{P(),e&&e.page!=="objects"&&n({text:`Cancel placing ${e.page}`}),setTimeout(()=>{switch(k.prototype){case"lines":s(k.name);break;case"items":o(k.name);break;case"holes":a(k.name);break}l(k)},0)},A=(k,H)=>{const X=[...g.slice(0,k),H];y(X)},I=(k,H)=>{k.preventDefault();const X=k.currentTarget.closest(".fp_side-bar");let te=!1;const Y=_e=>{const{clientX:U,clientY:W}=_e,he=X==null?void 0:X.getBoundingClientRect();he&&(U<he.left||U>he.right||W<he.top||W>he.bottom)&&(te=!0),te&&(C(H),G())},re=()=>G(),G=()=>{document.removeEventListener("mousemove",Y),document.removeEventListener("mouseup",re)};document.addEventListener("mousemove",Y),document.addEventListener("mouseup",re)},D=React.useMemo(()=>_.filter(k=>{const H=k.info.title.toLowerCase().includes(S.toLowerCase()),X=h?k.info.category===h:k,te=g.every(Y=>Y==="all"||k.info.tag.includes(Y));return H&&X&&te}),[_,S,h,g]);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[e&&jsxRuntimeExports.jsx("div",{className:"fixed inset-0 bg-black/30 z-10",onClick:P}),jsxRuntimeExports.jsxs("div",{style:e&&e.rect?{top:e.rect.y+TOP_OFFSET$1,left:e.rect.x+LEFT_OFFSET$1}:M.current?M.current:{},className:cn("fixed select-none z-10 shadow-md !gap-0 rounded-lg pt-4 fp_side-bar !min-h-[250px] !min-w-[330px] max-w-[330px] !max-h-[510px] transition-all duration-200 ease-out transform",e?"opacity-100 scale-100":"opacity-0 scale-95 pointer-events-none"),children:[jsxRuntimeExports.jsxs("header",{className:"px-[18px] sticky top-0 left-0 gap-3 flex flex-col",children:[jsxRuntimeExports.jsx("div",{className:"flex items-center gap-1",children:jsxRuntimeExports.jsx("span",{className:cn("flex flex-col gap-0.5"),children:jsxRuntimeExports.jsx("span",{className:"fp-sidebar-label capitalize",children:(e==null?void 0:e.page)??E.current})})}),jsxRuntimeExports.jsxs("div",{className:cn("fp-highlight"),children:[c.length>1&&jsxRuntimeExports.jsx(SegmentedTabs,{selected:h,onChange:k=>{y(["all"]),d(k.value),m(getCatalogOptions(_.filter(H=>H.info.category===k.value)))},options:c.map(k=>({label:k,value:k}))}),p.length>0&&jsxRuntimeExports.jsx(NestedSelect,{options:p,level:0,selections:g,onChange:A}),jsxRuntimeExports.jsx(SearchInput,{className:"mt-0",placeholder:"Search",value:S,onSearch:(k,H)=>{H.preventDefault(),H.stopPropagation(),b(k)}})]})]}),D.length>0?jsxRuntimeExports.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-6 pb-5 overflow-auto w-full pt-[18px] px-4",onWheel:k=>k.stopPropagation(),children:D.map(k=>jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1.5",children:[jsxRuntimeExports.jsx("div",{className:"fp-aspect-ratio-container",children:jsxRuntimeExports.jsx("div",{className:"fp-aspect-ratio-content",onMouseDown:H=>I(H,k),children:jsxRuntimeExports.jsx("img",{draggable:!1,className:"fp-item-image",alt:k.info.title,src:k.info.image})})}),jsxRuntimeExports.jsx("p",{className:"text-xs font-semibold capitalize",children:k.info.title})]},k.name.replace(/\s+/g,"_")))}):jsxRuntimeExports.jsx("div",{className:"min-h-28 w-full flex items-center justify-center",children:jsxRuntimeExports.jsx("p",{className:"text-sm font-medium text-gray-400 text-center",children:"No records found"})})]})]})};function FaDoorOpen(i){return GenIcon({attr:{viewBox:"0 0 576 512"},child:[{tag:"path",attr:{d:"M320 32c0-9.9-4.5-19.2-12.3-25.2S289.8-1.4 280.2 1l-179.9 45C79 51.3 64 70.5 64 92.5L64 448l-32 0c-17.7 0-32 14.3-32 32s14.3 32 32 32l64 0 192 0 32 0 0-32 0-448zM256 256c0 17.7-10.7 32-24 32s-24-14.3-24-32s10.7-32 24-32s24 14.3 24 32zm96-128l96 0 0 352c0 17.7 14.3 32 32 32l64 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-32 0 0-320c0-35.3-28.7-64-64-64l-96 0 0 64z"},child:[]}]})(i)}function GiSofa(i){return GenIcon({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M112 73c-13.75 0-24.214 4.87-33.047 13.271-8.832 8.402-15.755 20.6-20.414 34.575-5.887 17.661-7.953 38.064-6.887 56.111a57.246 57.246 0 0 1 2.461-.187c8.38-.405 16.317 1.094 23.494 4.234 14.355 6.28 25.436 18.27 34.057 32.28 15.104 24.543 23.187 55.746 24.96 80.585 114.097-14.223 124.655-14.223 238.753 0 1.772-24.84 9.855-56.042 24.959-80.586 8.62-14.009 19.702-25.999 34.057-32.28 7.875-3.444 16.67-4.898 25.955-4.046 1.066-18.047-1-38.45-6.887-56.111-4.659-13.976-11.582-26.173-20.414-34.575C424.214 77.87 413.75 73 400 73zM56.969 194.502c-.686-.008-1.38.006-2.082.04-5.621.284-11.8 1.978-18.862 5.509-23.413 11.707-26.349 65.687 14.82 79.41l4.505 1.502L86.79 391h338.42l31.44-110.037 4.504-1.502c41.17-13.723 38.234-67.703 14.82-79.41-14.121-7.061-24.722-6.775-34.367-2.555-9.645 4.22-18.564 13.23-25.943 25.22C400.906 246.7 393 282 393 304v10.195l-10.117-1.265c-128-16-125.766-16-253.766 0L119 314.195V304c0-22-7.906-57.3-22.664-81.283-7.38-11.991-16.298-21.001-25.943-25.22-4.22-1.847-8.624-2.94-13.424-2.995zM83.727 409l-23.272 23.271c11.994 3.239 33.75 3.763 42.545-1.666 3.272-4.695 6.903-14.536 10.438-21.605zm314.836 0c1.494 6.017 6.952 19.12 10.437 21.605 13.2 5.463 29.904 5.774 42.545 1.666L428.273 409z"},child:[]}]})(i)}function RxDimensions(i){return GenIcon({attr:{viewBox:"0 0 15 15",fill:"none"},child:[{tag:"path",attr:{fillRule:"evenodd",clipRule:"evenodd",d:"M3.00014 2.73895C3.00014 2.94698 2.76087 3.06401 2.59666 2.93628L1.00386 1.69744C0.875177 1.59735 0.875177 1.40286 1.00386 1.30277L2.59666 0.063928C2.76087 -0.0637944 3.00014 0.0532293 3.00014 0.261266V1.00012H9.00009V0.261296C9.00009 0.0532591 9.23936 -0.0637646 9.40358 0.0639578L10.9964 1.3028C11.1251 1.40289 11.1251 1.59738 10.9964 1.69747L9.40358 2.93631C9.23936 3.06404 9.00009 2.94701 9.00009 2.73898V2.00012H3.00014V2.73895ZM9.50002 4.99998H2.50002C2.22388 4.99998 2.00002 5.22384 2.00002 5.49998V12.5C2.00002 12.7761 2.22388 13 2.50002 13H9.50002C9.77616 13 10 12.7761 10 12.5V5.49998C10 5.22384 9.77616 4.99998 9.50002 4.99998ZM2.50002 3.99998C1.67159 3.99998 1.00002 4.67156 1.00002 5.49998V12.5C1.00002 13.3284 1.67159 14 2.50002 14H9.50002C10.3284 14 11 13.3284 11 12.5V5.49998C11 4.67156 10.3284 3.99998 9.50002 3.99998H2.50002ZM14.7389 6.00001H14V12H14.7389C14.9469 12 15.064 12.2393 14.9362 12.4035L13.6974 13.9963C13.5973 14.125 13.4028 14.125 13.3027 13.9963L12.0639 12.4035C11.9362 12.2393 12.0532 12 12.2612 12H13V6.00001H12.2612C12.0532 6.00001 11.9361 5.76074 12.0639 5.59653L13.3027 4.00373C13.4028 3.87505 13.5973 3.87505 13.6974 4.00374L14.9362 5.59653C15.0639 5.76074 14.9469 6.00001 14.7389 6.00001Z",fill:"currentColor"},child:[]}]})(i)}const iconTextStyle={fontSize:"19px",textDecoration:"none",fontWeight:"bold",margin:"0px",userSelect:"none"},Icon2D=({style:i})=>jsxRuntimeExports.jsx("p",{style:{...iconTextStyle,...i},children:"2D"}),Icon3D=({style:i})=>jsxRuntimeExports.jsx("p",{style:{...iconTextStyle,...i},children:"3D"});function Toolbar({catalog:i,has3dView:e}){const{planner:t,setMode:n,setToast:s,selectTool3DView:o,unselectAll:a,selectToolDrawingLine:l,selectToolDrawingSurface:c,showDimensions:u,setShowDimensions:h}=useReactPlannerStore(),{mode:d,alterate:p,drawingSupport:m}=t,[g,y]=React.useState(null);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("aside",{className:"floor_planner-toolbar -mt-[20px] absolute !pt-3 top-1/2 -translate-y-1/2 z-[1] max-h-full max-w-[50px] p-2.5 space-y-4",children:[jsxRuntimeExports.jsx(ToolbarButton,{active:[MODE_WAITING_DRAWING_LINE,MODE_DRAWING_LINE].includes(d)&&m.get("type")==="wall",tooltip:"Draw wall",onClick:()=>{s({text:"Cancel drawing"}),l("wall")},children:jsxRuntimeExports.jsx(LuBrickWall,{})}),jsxRuntimeExports.jsx(ToolbarButton,{active:[MODE_WAITING_DRAWING_SURFACE,MODE_DRAWING_SURFACE].includes(d),tooltip:"Draw landscape surface",onClick:()=>{s({text:"Cancel drawing"}),c("surface")},children:jsxRuntimeExports.jsx(PiWall,{size:26})}),jsxRuntimeExports.jsx(ToolbarButton,{active:!!([MODE_DRAWING_HOLE].includes(d)&&g&&g.page==="windows"),tooltip:"Place windows",onClick:_=>{y({rect:(_.currentTarget.parentElement??_.currentTarget).getBoundingClientRect(),page:"windows"})},children:jsxRuntimeExports.jsx(MdOutlineWindow,{size:26})}),jsxRuntimeExports.jsx(ToolbarButton,{active:!!([MODE_DRAWING_HOLE].includes(d)&&g&&g.page==="doors"),tooltip:"Place doors",onClick:_=>{y({rect:(_.currentTarget.parentElement??_.currentTarget).getBoundingClientRect(),page:"doors"})},children:jsxRuntimeExports.jsx(FaDoorOpen,{size:26})}),jsxRuntimeExports.jsx(ToolbarButton,{active:!!([MODE_DRAWING_ITEM].includes(d)&&g&&g.page==="objects"),tooltip:"Place objects",onClick:_=>{y({rect:(_.currentTarget.parentElement??_.currentTarget).getBoundingClientRect(),page:"objects"})},children:jsxRuntimeExports.jsx(GiSofa,{size:26})}),e?[MODE_3D_VIEW].includes(d)?jsxRuntimeExports.jsx(ToolbarButton,{active:[MODE_IDLE$1].includes(d),tooltip:"2D View",onClick:()=>{a(),setTimeout(()=>{n(MODE_IDLE$1)},0)},children:jsxRuntimeExports.jsx(Icon2D,{style:{color:p?"#FF9800":""}})}):jsxRuntimeExports.jsx(ToolbarButton,{active:[MODE_3D_VIEW].includes(d),tooltip:"3D View",onClick:o,children:jsxRuntimeExports.jsx(Icon3D,{})}):null,jsxRuntimeExports.jsx(ToolbarScreenshotButton,{mode:d}),jsxRuntimeExports.jsx(ToolbarButton,{active:u,tooltip:"Show dimensions",onClick:()=>{[MODE_3D_VIEW].includes(d)||h(!u)},children:jsxRuntimeExports.jsx(RxDimensions,{size:24})})]}),jsxRuntimeExports.jsx(Popup$1,{catalog:i,popupEvent:g,onClose:()=>y(null)})]})}const localStorage=window.hasOwnProperty("localStorage")?window.localStorage:!1,TIMEOUT_DELAY=500;let timeout=null;function autosave(i,e){return(t,n,s)=>{let o;if(e=e||TIMEOUT_DELAY,!!i&&localStorage){if(n){t.setPlan(n);const a=n.floors[0].floorDesign;o=JSON.parse(a)}else if(localStorage.getItem(i)!==null){const a=localStorage.getItem(i);o=JSON.parse(a)}o&&t.loadProject(o),useReactPlannerStore.subscribe(a=>{timeout&&clearTimeout(timeout),timeout=setTimeout(()=>{const l=localStorage.getItem(i),c=Project.unselectAll(a.planner).updatedState,u=JSON.stringify(c.scene.toJS());if(l!==u&&(localStorage.setItem(i,u),a.plan))try{const h=a.plan.floors[a.activeFloor];s&&s({floor:{floorID:h.floorID,title:h.floorTitle,description:h.floorDescription,design:u}})}catch{}},e)})}}}function keyboard(){return i=>{window.addEventListener("keydown",e=>{const t=i.planner,n=t.get("mode");switch(e.keyCode){case KEYBOARD_BUTTON_CODE.BACKSPACE:case KEYBOARD_BUTTON_CODE.DELETE:{[MODE_IDLE$1,MODE_3D_FIRST_PERSON,MODE_3D_VIEW].includes(n)&&i.remove();break}case KEYBOARD_BUTTON_CODE.ESC:{i.rollback();break}case KEYBOARD_BUTTON_CODE.Z:{(e.getModifierState("Control")||e.getModifierState("Meta"))&&(e.getModifierState("Shift")?i.redo():i.undo());break}case KEYBOARD_BUTTON_CODE.ALT:{MODE_SNAPPING.includes(n)&&i.toggleSnap(t.snapMask.merge({SNAP_POINT:!1,SNAP_LINE:!1,SNAP_SEGMENT:!1,SNAP_GRID:!1,SNAP_GUIDE:!1,tempSnapConfiguartion:t.snapMask.toJS()}));break}case KEYBOARD_BUTTON_CODE.C:{let s=t.getIn(["scene","selectedLayer"]),o=t.getIn(["scene","layers",s,"selected"]);if((n===MODE_IDLE$1||n===MODE_3D_VIEW)&&(o.holes.size||o.areas.size||o.items.size||o.lines.size)){if(o.holes.size){let a=t.getIn(["scene","layers",s,"holes",o.holes.get(0)]);i.copyProperties(a.get("properties"))}else if(o.areas.size){const a=t.getIn(["scene","layers",s,"areas",o.areas.get(0)]);i.copyProperties(a.properties)}else if(o.items.size){const a=t.getIn(["scene","layers",s,"items",o.items.get(0)]);i.copyProperties(a.properties)}else if(o.lines.size){const a=t.getIn(["scene","layers",s,"lines",o.lines.get(0)]);i.copyProperties(a.properties)}}break}case KEYBOARD_BUTTON_CODE.V:{i.pasteProperties();break}case KEYBOARD_BUTTON_CODE.CTRL:{i.setAlterateState();break}}}),window.addEventListener("keyup",e=>{const t=i.planner,n=t.get("mode");switch(e.keyCode){case KEYBOARD_BUTTON_CODE.ALT:{MODE_SNAPPING.includes(n)&&i.toggleSnap(t.snapMask.merge(t.snapMask.get("tempSnapConfiguartion")));break}case KEYBOARD_BUTTON_CODE.CTRL:{i.setAlterateState();break}}})}}const TOP_OFFSET=38,LEFT_OFFSET=-220,ToggleSetting=({title:i,toggleState:e,toggleOn:t,toggleOff:n})=>{const[s,o]=React.useState(e||!1),a=()=>{o(!s),s?n():t()};return jsxRuntimeExports.jsxs("div",{className:"flex items-center",children:[jsxRuntimeExports.jsx("div",{className:"fp__onoffswitch",onClick:a,children:jsxRuntimeExports.jsxs("div",{className:cn("fp__onoffswitch_label",s?"fp__onoffswitch_label-checked":""),children:[jsxRuntimeExports.jsx("span",{className:"fp__onoffswitch_inner"}),jsxRuntimeExports.jsx("span",{className:"fp__onoffswitch_switch"})]})}),jsxRuntimeExports.jsx("div",{className:"fp__onoffswitch_caption",children:i})]})},Popup=({popupEvent:i,onClose:e})=>{const{planner:t,toggleSnap:n}=useReactPlannerStore(),{snapMask:s}=t,o=React.useRef(null);React.useEffect(()=>{if(i){const{x:c,y:u}=i.rect;o.current={top:u+TOP_OFFSET,left:c+LEFT_OFFSET}}},[i]);const a=()=>{e()},l=c=>n(s.merge(c));return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[i&&jsxRuntimeExports.jsx("div",{className:"fixed inset-0 bg-black/30 z-10",onClick:a}),jsxRuntimeExports.jsxs("div",{style:i&&i.rect?{top:i.rect.y+TOP_OFFSET,left:i.rect.x+LEFT_OFFSET}:o.current?o.current:{},id:"headerbar-popup",className:cn("fixed select-none z-10 shadow-md !gap-0 rounded-lg pt-4 fp_side-bar !min-h-[200px] !min-w-[250px] max-w-[250px] !max-h-[300px] transition-all duration-200 ease-out transform",i?"opacity-100 scale-100":"opacity-0 scale-95 pointer-events-none"),children:[jsxRuntimeExports.jsx("header",{className:"px-[18px] sticky top-0 left-0 gap-3 flex flex-col",children:jsxRuntimeExports.jsx("div",{className:"flex items-center gap-1",children:jsxRuntimeExports.jsx("span",{className:cn("flex flex-col gap-0.5"),children:jsxRuntimeExports.jsx("span",{className:"fp-sidebar-label capitalize",children:"Settings"})})})}),jsxRuntimeExports.jsxs("div",{className:"min-h-28 w-full space-y-2.5 px-2 py-4",children:[jsxRuntimeExports.jsx(ToggleSetting,{title:"Snap to Point",toggleState:s.get(SNAP_POINT),toggleOn:()=>{l({SNAP_POINT:!0})},toggleOff:()=>{l({SNAP_POINT:!1})}}),jsxRuntimeExports.jsx(ToggleSetting,{toggleOn:()=>{l({SNAP_LINE:!0})},toggleOff:()=>{l({SNAP_LINE:!1})},toggleState:s.get(SNAP_LINE),title:"Snap to Line"}),jsxRuntimeExports.jsx(ToggleSetting,{toggleOn:()=>{l({SNAP_SEGMENT:!0})},toggleOff:()=>{l({SNAP_SEGMENT:!1})},toggleState:s.get(SNAP_SEGMENT),title:"Snap to Segment"}),jsxRuntimeExports.jsx(ToggleSetting,{toggleOn:()=>{l({SNAP_GRID:!0})},toggleOff:()=>{l({SNAP_GRID:!1})},toggleState:s.get(SNAP_GRID),title:"Snap to Grid"}),jsxRuntimeExports.jsx(ToggleSetting,{toggleOn:()=>{l({SNAP_GUIDE:!0})},toggleOff:()=>{l({SNAP_GUIDE:!1})},toggleState:s.get(SNAP_GUIDE),title:"Snap to Guide"})]})]})]})},Headerbar=({onBack:i,onSave:e})=>{const{undo:t,redo:n,plan:s,setPlan:o}=useReactPlannerStore(),[a,l]=React.useState(!1),[c,u]=React.useState(null),h=()=>{l(!0)},d=p=>{if(!s)return;l(!1);const m=p.target.value.trim();if(m&&m!==(s==null?void 0:s.planTitle)){o({...s,planTitle:m});try{e&&e({title:m,description:""})}catch{}}};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"floor_planner-headerbar absolute flex items-center justify-between z-[9001] py-[3px] px-[1em] w-full select-none cursor-default top-0 m-0",children:[jsxRuntimeExports.jsx(ToolbarButton,{className:"border border-white rounded -ml-1",active:!1,tooltip:"Go Back",onClick:()=>{i&&i()},children:jsxRuntimeExports.jsx(MdArrowBack,{})}),jsxRuntimeExports.jsx("div",{className:"flex flex-col items-center justify-center",children:a?jsxRuntimeExports.jsx("input",{autoFocus:!0,type:"text",defaultValue:s==null?void 0:s.planTitle,onBlur:d,onKeyDown:p=>{(p.key==="Enter"||p.key==="Escape")&&d(p)},className:"bg-transparent border-b border-gray-400 outline-none text-lg text-center"}):jsxRuntimeExports.jsx("span",{onDoubleClick:h,className:"projectName__fp text-lg",title:(s==null?void 0:s.planTitle)??"Example House",children:(s==null?void 0:s.planTitle)??"Example House"})}),jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 relative",children:[jsxRuntimeExports.jsx(ToolbarButton,{active:!1,tooltip:"Undo (CTRL-Z)",onClick:t,children:jsxRuntimeExports.jsx(BiUndo,{})}),jsxRuntimeExports.jsx(ToolbarButton,{active:!1,tooltip:"Redo (CTRL-SHIFT-Z)",onClick:n,children:jsxRuntimeExports.jsx(BiRedo,{})}),jsxRuntimeExports.jsx("div",{className:"ml-8",children:jsxRuntimeExports.jsx(ToolbarButton,{active:!1,tooltip:"Settings",onClick:p=>{u({rect:p.currentTarget.getBoundingClientRect()})},children:jsxRuntimeExports.jsx(FaCog,{size:17})})})]})]}),jsxRuntimeExports.jsx(Popup,{popupEvent:c,onClose:()=>u(null)})]})};var collectionUtils={exports:{}},hasRequiredCollectionUtils;function requireCollectionUtils(){if(hasRequiredCollectionUtils)return collectionUtils.exports;hasRequiredCollectionUtils=1;var i=collectionUtils.exports={};return i.forEach=function(e,t){for(var n=0;n<e.length;n++){var s=t(e[n]);if(s)return s}},collectionUtils.exports}var elementUtils,hasRequiredElementUtils;function requireElementUtils(){return hasRequiredElementUtils||(hasRequiredElementUtils=1,elementUtils=function(i){var e=i.stateHandler.getState;function t(a){var l=e(a);return l&&!!l.isDetectable}function n(a){e(a).isDetectable=!0}function s(a){return!!e(a).busy}function o(a,l){e(a).busy=!!l}return{isDetectable:t,markAsDetectable:n,isBusy:s,markBusy:o}}),elementUtils}var listenerHandler,hasRequiredListenerHandler;function requireListenerHandler(){return hasRequiredListenerHandler||(hasRequiredListenerHandler=1,listenerHandler=function(i){var e={};function t(a){var l=i.get(a);return l===void 0?[]:e[l]||[]}function n(a,l){var c=i.get(a);e[c]||(e[c]=[]),e[c].push(l)}function s(a,l){for(var c=t(a),u=0,h=c.length;u<h;++u)if(c[u]===l){c.splice(u,1);break}}function o(a){var l=t(a);l&&(l.length=0)}return{get:t,add:n,removeListener:s,removeAllListeners:o}}),listenerHandler}var idGenerator,hasRequiredIdGenerator;function requireIdGenerator(){return hasRequiredIdGenerator||(hasRequiredIdGenerator=1,idGenerator=function(){var i=1;function e(){return i++}return{generate:e}}),idGenerator}var idHandler,hasRequiredIdHandler;function requireIdHandler(){return hasRequiredIdHandler||(hasRequiredIdHandler=1,idHandler=function(i){var e=i.idGenerator,t=i.stateHandler.getState;function n(o){var a=t(o);return a&&a.id!==void 0?a.id:null}function s(o){var a=t(o);if(!a)throw new Error("setId required the element to have a resize detection state.");var l=e.generate();return a.id=l,l}return{get:n,set:s}}),idHandler}var reporter,hasRequiredReporter;function requireReporter(){return hasRequiredReporter||(hasRequiredReporter=1,reporter=function(i){function e(){}var t={log:e,warn:e,error:e};if(!i&&window.console){var n=function(s,o){s[o]=function(){var l=console[o];if(l.apply)l.apply(console,arguments);else for(var c=0;c<arguments.length;c++)l(arguments[c])}};n(t,"log"),n(t,"warn"),n(t,"error")}return t}),reporter}var browserDetector={exports:{}},hasRequiredBrowserDetector;function requireBrowserDetector(){if(hasRequiredBrowserDetector)return browserDetector.exports;hasRequiredBrowserDetector=1;var i=browserDetector.exports={};return i.isIE=function(e){function t(){var s=navigator.userAgent.toLowerCase();return s.indexOf("msie")!==-1||s.indexOf("trident")!==-1||s.indexOf(" edge/")!==-1}if(!t())return!1;if(!e)return!0;var n=(function(){var s,o=3,a=document.createElement("div"),l=a.getElementsByTagName("i");do a.innerHTML="<!--[if gt IE "+ ++o+"]><i></i><![endif]-->";while(l[0]);return o>4?o:s})();return e===n},i.isLegacyOpera=function(){return!!window.opera},browserDetector.exports}var utils={exports:{}},hasRequiredUtils;function requireUtils(){if(hasRequiredUtils)return utils.exports;hasRequiredUtils=1;var i=utils.exports={};i.getOption=e;function e(t,n,s){var o=t[n];return o==null&&s!==void 0?s:o}return utils.exports}var batchProcessor,hasRequiredBatchProcessor;function requireBatchProcessor(){if(hasRequiredBatchProcessor)return batchProcessor;hasRequiredBatchProcessor=1;var i=requireUtils();batchProcessor=function(n){n=n||{};var s=n.reporter,o=i.getOption(n,"async",!0),a=i.getOption(n,"auto",!0);a&&!o&&(s&&s.warn("Invalid options combination. auto=true and async=false is invalid. Setting async=true."),o=!0);var l=e(),c,u=!1;function h(_,x){!u&&a&&o&&l.size()===0&&m(),l.add(_,x)}function d(){for(u=!0;l.size();){var _=l;l=e(),_.process()}u=!1}function p(_){u||(_===void 0&&(_=o),c&&(g(c),c=null),_?m():d())}function m(){c=y(d)}function g(_){var x=clearTimeout;return x(_)}function y(_){var x=function(S){return setTimeout(S,0)};return x(_)}return{add:h,force:p}};function e(){var t={},n=0,s=0,o=0;function a(u,h){h||(h=u,u=0),u>s?s=u:u<o&&(o=u),t[u]||(t[u]=[]),t[u].push(h),n++}function l(){for(var u=o;u<=s;u++)for(var h=t[u],d=0;d<h.length;d++){var p=h[d];p()}}function c(){return n}return{add:a,process:l,size:c}}return batchProcessor}var stateHandler,hasRequiredStateHandler;function requireStateHandler(){if(hasRequiredStateHandler)return stateHandler;hasRequiredStateHandler=1;var i="_erd";function e(s){return s[i]={},t(s)}function t(s){return s[i]}function n(s){delete s[i]}return stateHandler={initState:e,getState:t,cleanState:n},stateHandler}var object,hasRequiredObject;function requireObject(){if(hasRequiredObject)return object;hasRequiredObject=1;var i=requireBrowserDetector();return object=function(e){e=e||{};var t=e.reporter,n=e.batchProcessor,s=e.stateHandler.getState;if(!t)throw new Error("Missing required dependency: reporter.");function o(h,d){function p(){d(h)}if(i.isIE(8))s(h).object={proxy:p},h.attachEvent("onresize",p);else{var m=c(h);if(!m)throw new Error("Element is not detectable by this strategy.");m.contentDocument.defaultView.addEventListener("resize",p)}}function a(h){var d=e.important?" !important; ":"; ";return(h.join(d)+d).trim()}function l(h,d,p){p||(p=d,d=h,h=null),h=h||{},h.debug;function m(g,y){var _=a(["display: block","position: absolute","top: 0","left: 0","width: 100%","height: 100%","border: none","padding: 0","margin: 0","opacity: 0","z-index: -1000","pointer-events: none"]),x=!1,S=window.getComputedStyle(g),b=g.offsetWidth,E=g.offsetHeight;s(g).startSize={width:b,height:E};function M(){function w(){if(S.position==="static"){g.style.setProperty("position","relative",h.important?"important":"");var A=function(I,D,k,H){function X(Y){return Y.replace(/[^-\d\.]/g,"")}var te=k[H];te!=="auto"&&X(te)!=="0"&&(I.warn("An element that is positioned static has style."+H+"="+te+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+H+" will be set to 0. Element: ",D),D.style.setProperty(H,"0",h.important?"important":""))};A(t,g,S,"top"),A(t,g,S,"right"),A(t,g,S,"bottom"),A(t,g,S,"left")}}function P(){x||w();function A(D,k){if(!D.contentDocument){var H=s(D);H.checkForObjectDocumentTimeoutId&&window.clearTimeout(H.checkForObjectDocumentTimeoutId),H.checkForObjectDocumentTimeoutId=setTimeout(function(){H.checkForObjectDocumentTimeoutId=0,A(D,k)},100);return}k(D.contentDocument)}var I=this;A(I,function(k){y(g)})}S.position!==""&&(w(),x=!0);var C=document.createElement("object");C.style.cssText=_,C.tabIndex=-1,C.type="text/html",C.setAttribute("aria-hidden","true"),C.onload=P,i.isIE()||(C.data="about:blank"),s(g)&&(g.appendChild(C),s(g).object=C,i.isIE()&&(C.data="about:blank"))}n?n.add(M):M()}i.isIE(8)?p(d):m(d,p)}function c(h){return s(h).object}function u(h){if(s(h)){var d=c(h);d&&(i.isIE(8)?h.detachEvent("onresize",d.proxy):h.removeChild(d),s(h).checkForObjectDocumentTimeoutId&&window.clearTimeout(s(h).checkForObjectDocumentTimeoutId),delete s(h).object)}}return{makeDetectable:l,addListener:o,uninstall:u}},object}var scroll,hasRequiredScroll;function requireScroll(){if(hasRequiredScroll)return scroll;hasRequiredScroll=1;var i=requireCollectionUtils().forEach;return scroll=function(e){e=e||{};var t=e.reporter,n=e.batchProcessor,s=e.stateHandler.getState;e.stateHandler.hasState;var o=e.idHandler;if(!n)throw new Error("Missing required dependency: batchProcessor");if(!t)throw new Error("Missing required dependency: reporter.");var a=d(),l="erd_scroll_detection_scrollbar_style",c="erd_scroll_detection_container";function u(M){p(M,l,c)}u(window.document);function h(M){var w=e.important?" !important; ":"; ";return(M.join(w)+w).trim()}function d(){var M=500,w=500,P=document.createElement("div");P.style.cssText=h(["position: absolute","width: "+M*2+"px","height: "+w*2+"px","visibility: hidden","margin: 0","padding: 0"]);var C=document.createElement("div");C.style.cssText=h(["position: absolute","width: "+M+"px","height: "+w+"px","overflow: scroll","visibility: none","top: "+-M*3+"px","left: "+-w*3+"px","visibility: hidden","margin: 0","padding: 0"]),C.appendChild(P),document.body.insertBefore(C,document.body.firstChild);var A=M-C.clientWidth,I=w-C.clientHeight;return document.body.removeChild(C),{width:A,height:I}}function p(M,w,P){function C(k,H){H=H||function(te){M.head.appendChild(te)};var X=M.createElement("style");return X.innerHTML=k,X.id=w,H(X),X}if(!M.getElementById(w)){var A=P+"_animation",I=P+"_animation_active",D=`/* Created by the element-resize-detector library. */
3932
3932
  `;D+="."+P+" > div::-webkit-scrollbar { "+h(["display: none"])+` }
3933
3933
 
3934
3934
  `,D+="."+I+" { "+h(["-webkit-animation-duration: 0.1s","animation-duration: 0.1s","-webkit-animation-name: "+A,"animation-name: "+A])+` }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "files": [
12
12
  "dist"
13
13
  ],
14
- "version": "1.2.2",
14
+ "version": "1.2.3",
15
15
  "type": "module",
16
16
  "scripts": {
17
17
  "dev": "vite",