@osamash/floor-planner 1.2.5 → 1.2.6

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.
@@ -42,7 +42,7 @@ React keys must be passed directly to JSX without using spread:
42
42
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
43
43
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
44
44
  * SOFTWARE.
45
- */var DELETE="delete",SHIFT=5,SIZE=1<<SHIFT,MASK=SIZE-1,NOT_SET={};function MakeRef(){return{value:!1}}function SetRef(i){i&&(i.value=!0)}function OwnerID(){}function ensureSize(i){return i.size===void 0&&(i.size=i.__iterate(returnTrue)),i.size}function wrapIndex(i,e){if(typeof e!="number"){var t=e>>>0;if(""+t!==e||t===4294967295)return NaN;e=t}return e<0?ensureSize(i)+e:e}function returnTrue(){return!0}function wholeSlice(i,e,t){return(i===0&&!isNeg(i)||t!==void 0&&i<=-t)&&(e===void 0||t!==void 0&&e>=t)}function resolveBegin(i,e){return resolveIndex(i,e,0)}function resolveEnd(i,e){return resolveIndex(i,e,e)}function resolveIndex(i,e,t){return i===void 0?t:isNeg(i)?e===1/0?e:Math.max(0,e+i)|0:e===void 0||e===i?i:Math.min(e,i)|0}function isNeg(i){return i<0||i===0&&1/i===-1/0}var IS_COLLECTION_SYMBOL="@@__IMMUTABLE_ITERABLE__@@";function isCollection(i){return!!(i&&i[IS_COLLECTION_SYMBOL])}var IS_KEYED_SYMBOL="@@__IMMUTABLE_KEYED__@@";function isKeyed(i){return!!(i&&i[IS_KEYED_SYMBOL])}var IS_INDEXED_SYMBOL="@@__IMMUTABLE_INDEXED__@@";function isIndexed(i){return!!(i&&i[IS_INDEXED_SYMBOL])}function isAssociative(i){return isKeyed(i)||isIndexed(i)}var Collection=function(e){return isCollection(e)?e:Seq(e)},KeyedCollection=(function(i){function e(t){return isKeyed(t)?t:KeyedSeq(t)}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e})(Collection),IndexedCollection=(function(i){function e(t){return isIndexed(t)?t:IndexedSeq(t)}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e})(Collection),SetCollection=(function(i){function e(t){return isCollection(t)&&!isAssociative(t)?t:SetSeq(t)}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e})(Collection);Collection.Keyed=KeyedCollection,Collection.Indexed=IndexedCollection,Collection.Set=SetCollection;var IS_SEQ_SYMBOL="@@__IMMUTABLE_SEQ__@@";function isSeq(i){return!!(i&&i[IS_SEQ_SYMBOL])}var IS_RECORD_SYMBOL="@@__IMMUTABLE_RECORD__@@";function isRecord$2(i){return!!(i&&i[IS_RECORD_SYMBOL])}function isImmutable(i){return isCollection(i)||isRecord$2(i)}var IS_ORDERED_SYMBOL="@@__IMMUTABLE_ORDERED__@@";function isOrdered(i){return!!(i&&i[IS_ORDERED_SYMBOL])}var ITERATE_KEYS=0,ITERATE_VALUES=1,ITERATE_ENTRIES=2,REAL_ITERATOR_SYMBOL=typeof Symbol=="function"&&Symbol.iterator,FAUX_ITERATOR_SYMBOL="@@iterator",ITERATOR_SYMBOL=REAL_ITERATOR_SYMBOL||FAUX_ITERATOR_SYMBOL,Iterator=function(e){this.next=e};Iterator.prototype.toString=function(){return"[Iterator]"},Iterator.KEYS=ITERATE_KEYS,Iterator.VALUES=ITERATE_VALUES,Iterator.ENTRIES=ITERATE_ENTRIES,Iterator.prototype.inspect=Iterator.prototype.toSource=function(){return this.toString()},Iterator.prototype[ITERATOR_SYMBOL]=function(){return this};function iteratorValue(i,e,t,n){var s=i===ITERATE_KEYS?e:i===ITERATE_VALUES?t:[e,t];return n?n.value=s:n={value:s,done:!1},n}function iteratorDone(){return{value:void 0,done:!0}}function hasIterator(i){return Array.isArray(i)?!0:!!getIteratorFn(i)}function isIterator(i){return i&&typeof i.next=="function"}function getIterator(i){var e=getIteratorFn(i);return e&&e.call(i)}function getIteratorFn(i){var e=i&&(REAL_ITERATOR_SYMBOL&&i[REAL_ITERATOR_SYMBOL]||i[FAUX_ITERATOR_SYMBOL]);if(typeof e=="function")return e}function isEntriesIterable(i){var e=getIteratorFn(i);return e&&e===i.entries}function isKeysIterable(i){var e=getIteratorFn(i);return e&&e===i.keys}var hasOwnProperty=Object.prototype.hasOwnProperty;function isArrayLike(i){return Array.isArray(i)||typeof i=="string"?!0:i&&typeof i=="object"&&Number.isInteger(i.length)&&i.length>=0&&(i.length===0?Object.keys(i).length===1:i.hasOwnProperty(i.length-1))}var Seq=(function(i){function e(t){return t==null?emptySequence():isImmutable(t)?t.toSeq():seqFromValue(t)}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(n,s){var o=this._cache;if(o){for(var a=o.length,l=0;l!==a;){var c=o[s?a-++l:l++];if(n(c[1],c[0],this)===!1)break}return l}return this.__iterateUncached(n,s)},e.prototype.__iterator=function(n,s){var o=this._cache;if(o){var a=o.length,l=0;return new Iterator(function(){if(l===a)return iteratorDone();var c=o[s?a-++l:l++];return iteratorValue(n,c[0],c[1])})}return this.__iteratorUncached(n,s)},e})(Collection),KeyedSeq=(function(i){function e(t){return t==null?emptySequence().toKeyedSeq():isCollection(t)?isKeyed(t)?t.toSeq():t.fromEntrySeq():isRecord$2(t)?t.toSeq():keyedSeqFromValue(t)}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e})(Seq),IndexedSeq=(function(i){function e(t){return t==null?emptySequence():isCollection(t)?isKeyed(t)?t.entrySeq():t.toIndexedSeq():isRecord$2(t)?t.toSeq().entrySeq():indexedSeqFromValue(t)}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e})(Seq),SetSeq=(function(i){function e(t){return(isCollection(t)&&!isAssociative(t)?t:IndexedSeq(t)).toSetSeq()}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e})(Seq);Seq.isSeq=isSeq,Seq.Keyed=KeyedSeq,Seq.Set=SetSeq,Seq.Indexed=IndexedSeq,Seq.prototype[IS_SEQ_SYMBOL]=!0;var ArraySeq=(function(i){function e(t){this._array=t,this.size=t.length}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.get=function(n,s){return this.has(n)?this._array[wrapIndex(this,n)]:s},e.prototype.__iterate=function(n,s){for(var o=this._array,a=o.length,l=0;l!==a;){var c=s?a-++l:l++;if(n(o[c],c,this)===!1)break}return l},e.prototype.__iterator=function(n,s){var o=this._array,a=o.length,l=0;return new Iterator(function(){if(l===a)return iteratorDone();var c=s?a-++l:l++;return iteratorValue(n,c,o[c])})},e})(IndexedSeq),ObjectSeq=(function(i){function e(t){var n=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=n,this.size=n.length}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.get=function(n,s){return s!==void 0&&!this.has(n)?s:this._object[n]},e.prototype.has=function(n){return hasOwnProperty.call(this._object,n)},e.prototype.__iterate=function(n,s){for(var o=this._object,a=this._keys,l=a.length,c=0;c!==l;){var u=a[s?l-++c:c++];if(n(o[u],u,this)===!1)break}return c},e.prototype.__iterator=function(n,s){var o=this._object,a=this._keys,l=a.length,c=0;return new Iterator(function(){if(c===l)return iteratorDone();var u=a[s?l-++c:c++];return iteratorValue(n,u,o[u])})},e})(KeyedSeq);ObjectSeq.prototype[IS_ORDERED_SYMBOL]=!0;var CollectionSeq=(function(i){function e(t){this._collection=t,this.size=t.length||t.size}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(n,s){if(s)return this.cacheResult().__iterate(n,s);var o=this._collection,a=getIterator(o),l=0;if(isIterator(a))for(var c;!(c=a.next()).done&&n(c.value,l++,this)!==!1;);return l},e.prototype.__iteratorUncached=function(n,s){if(s)return this.cacheResult().__iterator(n,s);var o=this._collection,a=getIterator(o);if(!isIterator(a))return new Iterator(iteratorDone);var l=0;return new Iterator(function(){var c=a.next();return c.done?c:iteratorValue(n,l++,c.value)})},e})(IndexedSeq),EMPTY_SEQ;function emptySequence(){return EMPTY_SEQ||(EMPTY_SEQ=new ArraySeq([]))}function keyedSeqFromValue(i){var e=maybeIndexedSeqFromValue(i);if(e)return e.fromEntrySeq();if(typeof i=="object")return new ObjectSeq(i);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+i)}function indexedSeqFromValue(i){var e=maybeIndexedSeqFromValue(i);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+i)}function seqFromValue(i){var e=maybeIndexedSeqFromValue(i);if(e)return isEntriesIterable(i)?e.fromEntrySeq():isKeysIterable(i)?e.toSetSeq():e;if(typeof i=="object")return new ObjectSeq(i);throw new TypeError("Expected Array or collection object of values, or keyed object: "+i)}function maybeIndexedSeqFromValue(i){return isArrayLike(i)?new ArraySeq(i):hasIterator(i)?new CollectionSeq(i):void 0}var IS_MAP_SYMBOL="@@__IMMUTABLE_MAP__@@";function isMap$1(i){return!!(i&&i[IS_MAP_SYMBOL])}function isOrderedMap(i){return isMap$1(i)&&isOrdered(i)}function isValueObject(i){return!!(i&&typeof i.equals=="function"&&typeof i.hashCode=="function")}function is(i,e){if(i===e||i!==i&&e!==e)return!0;if(!i||!e)return!1;if(typeof i.valueOf=="function"&&typeof e.valueOf=="function"){if(i=i.valueOf(),e=e.valueOf(),i===e||i!==i&&e!==e)return!0;if(!i||!e)return!1}return!!(isValueObject(i)&&isValueObject(e)&&i.equals(e))}var imul=typeof Math.imul=="function"&&Math.imul(4294967295,2)===-2?Math.imul:function(e,t){e|=0,t|=0;var n=e&65535,s=t&65535;return n*s+((e>>>16)*s+n*(t>>>16)<<16>>>0)|0};function smi(i){return i>>>1&1073741824|i&3221225471}var defaultValueOf=Object.prototype.valueOf;function hash(i){if(i==null)return hashNullish(i);if(typeof i.hashCode=="function")return smi(i.hashCode(i));var e=valueOf(i);if(e==null)return hashNullish(e);switch(typeof e){case"boolean":return e?1108378657:1108378656;case"number":return hashNumber(e);case"string":return e.length>STRING_HASH_CACHE_MIN_STRLEN?cachedHashString(e):hashString(e);case"object":case"function":return hashJSObj(e);case"symbol":return hashSymbol(e);default:if(typeof e.toString=="function")return hashString(e.toString());throw new Error("Value type "+typeof e+" cannot be hashed.")}}function hashNullish(i){return i===null?1108378658:1108378659}function hashNumber(i){if(i!==i||i===1/0)return 0;var e=i|0;for(e!==i&&(e^=i*4294967295);i>4294967295;)i/=4294967295,e^=i;return smi(e)}function cachedHashString(i){var e=stringHashCache[i];return e===void 0&&(e=hashString(i),STRING_HASH_CACHE_SIZE===STRING_HASH_CACHE_MAX_SIZE&&(STRING_HASH_CACHE_SIZE=0,stringHashCache={}),STRING_HASH_CACHE_SIZE++,stringHashCache[i]=e),e}function hashString(i){for(var e=0,t=0;t<i.length;t++)e=31*e+i.charCodeAt(t)|0;return smi(e)}function hashSymbol(i){var e=symbolMap[i];return e!==void 0||(e=nextHash(),symbolMap[i]=e),e}function hashJSObj(i){var e;if(usingWeakMap&&(e=weakMap.get(i),e!==void 0)||(e=i[UID_HASH_KEY],e!==void 0)||!canDefineProperty&&(e=i.propertyIsEnumerable&&i.propertyIsEnumerable[UID_HASH_KEY],e!==void 0||(e=getIENodeHash(i),e!==void 0)))return e;if(e=nextHash(),usingWeakMap)weakMap.set(i,e);else{if(isExtensible!==void 0&&isExtensible(i)===!1)throw new Error("Non-extensible objects are not allowed as keys.");if(canDefineProperty)Object.defineProperty(i,UID_HASH_KEY,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(i.propertyIsEnumerable!==void 0&&i.propertyIsEnumerable===i.constructor.prototype.propertyIsEnumerable)i.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},i.propertyIsEnumerable[UID_HASH_KEY]=e;else if(i.nodeType!==void 0)i[UID_HASH_KEY]=e;else throw new Error("Unable to set a non-enumerable property on object.")}return e}var isExtensible=Object.isExtensible,canDefineProperty=(function(){try{return Object.defineProperty({},"@",{}),!0}catch{return!1}})();function getIENodeHash(i){if(i&&i.nodeType>0)switch(i.nodeType){case 1:return i.uniqueID;case 9:return i.documentElement&&i.documentElement.uniqueID}}function valueOf(i){return i.valueOf!==defaultValueOf&&typeof i.valueOf=="function"?i.valueOf(i):i}function nextHash(){var i=++_objHashUID;return _objHashUID&1073741824&&(_objHashUID=0),i}var usingWeakMap=typeof WeakMap=="function",weakMap;usingWeakMap&&(weakMap=new WeakMap);var symbolMap=Object.create(null),_objHashUID=0,UID_HASH_KEY="__immutablehash__";typeof Symbol=="function"&&(UID_HASH_KEY=Symbol(UID_HASH_KEY));var STRING_HASH_CACHE_MIN_STRLEN=16,STRING_HASH_CACHE_MAX_SIZE=255,STRING_HASH_CACHE_SIZE=0,stringHashCache={},ToKeyedSequence=(function(i){function e(t,n){this._iter=t,this._useKeys=n,this.size=t.size}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.get=function(n,s){return this._iter.get(n,s)},e.prototype.has=function(n){return this._iter.has(n)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var n=this,s=reverseFactory(this,!0);return this._useKeys||(s.valueSeq=function(){return n._iter.toSeq().reverse()}),s},e.prototype.map=function(n,s){var o=this,a=mapFactory(this,n,s);return this._useKeys||(a.valueSeq=function(){return o._iter.toSeq().map(n,s)}),a},e.prototype.__iterate=function(n,s){var o=this;return this._iter.__iterate(function(a,l){return n(a,l,o)},s)},e.prototype.__iterator=function(n,s){return this._iter.__iterator(n,s)},e})(KeyedSeq);ToKeyedSequence.prototype[IS_ORDERED_SYMBOL]=!0;var ToIndexedSequence=(function(i){function e(t){this._iter=t,this.size=t.size}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.includes=function(n){return this._iter.includes(n)},e.prototype.__iterate=function(n,s){var o=this,a=0;return s&&ensureSize(this),this._iter.__iterate(function(l){return n(l,s?o.size-++a:a++,o)},s)},e.prototype.__iterator=function(n,s){var o=this,a=this._iter.__iterator(ITERATE_VALUES,s),l=0;return s&&ensureSize(this),new Iterator(function(){var c=a.next();return c.done?c:iteratorValue(n,s?o.size-++l:l++,c.value,c)})},e})(IndexedSeq),ToSetSequence=(function(i){function e(t){this._iter=t,this.size=t.size}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.has=function(n){return this._iter.includes(n)},e.prototype.__iterate=function(n,s){var o=this;return this._iter.__iterate(function(a){return n(a,a,o)},s)},e.prototype.__iterator=function(n,s){var o=this._iter.__iterator(ITERATE_VALUES,s);return new Iterator(function(){var a=o.next();return a.done?a:iteratorValue(n,a.value,a.value,a)})},e})(SetSeq),FromEntriesSequence=(function(i){function e(t){this._iter=t,this.size=t.size}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(n,s){var o=this;return this._iter.__iterate(function(a){if(a){validateEntry(a);var l=isCollection(a);return n(l?a.get(1):a[1],l?a.get(0):a[0],o)}},s)},e.prototype.__iterator=function(n,s){var o=this._iter.__iterator(ITERATE_VALUES,s);return new Iterator(function(){for(;;){var a=o.next();if(a.done)return a;var l=a.value;if(l){validateEntry(l);var c=isCollection(l);return iteratorValue(n,c?l.get(0):l[0],c?l.get(1):l[1],a)}}})},e})(KeyedSeq);ToIndexedSequence.prototype.cacheResult=ToKeyedSequence.prototype.cacheResult=ToSetSequence.prototype.cacheResult=FromEntriesSequence.prototype.cacheResult=cacheResultThrough;function flipFactory(i){var e=makeSequence(i);return e._iter=i,e.size=i.size,e.flip=function(){return i},e.reverse=function(){var t=i.reverse.apply(this);return t.flip=function(){return i.reverse()},t},e.has=function(t){return i.includes(t)},e.includes=function(t){return i.has(t)},e.cacheResult=cacheResultThrough,e.__iterateUncached=function(t,n){var s=this;return i.__iterate(function(o,a){return t(a,o,s)!==!1},n)},e.__iteratorUncached=function(t,n){if(t===ITERATE_ENTRIES){var s=i.__iterator(t,n);return new Iterator(function(){var o=s.next();if(!o.done){var a=o.value[0];o.value[0]=o.value[1],o.value[1]=a}return o})}return i.__iterator(t===ITERATE_VALUES?ITERATE_KEYS:ITERATE_VALUES,n)},e}function mapFactory(i,e,t){var n=makeSequence(i);return n.size=i.size,n.has=function(s){return i.has(s)},n.get=function(s,o){var a=i.get(s,NOT_SET);return a===NOT_SET?o:e.call(t,a,s,i)},n.__iterateUncached=function(s,o){var a=this;return i.__iterate(function(l,c,u){return s(e.call(t,l,c,u),c,a)!==!1},o)},n.__iteratorUncached=function(s,o){var a=i.__iterator(ITERATE_ENTRIES,o);return new Iterator(function(){var l=a.next();if(l.done)return l;var c=l.value,u=c[0];return iteratorValue(s,u,e.call(t,c[1],u,i),l)})},n}function reverseFactory(i,e){var t=this,n=makeSequence(i);return n._iter=i,n.size=i.size,n.reverse=function(){return i},i.flip&&(n.flip=function(){var s=flipFactory(i);return s.reverse=function(){return i.flip()},s}),n.get=function(s,o){return i.get(e?s:-1-s,o)},n.has=function(s){return i.has(e?s:-1-s)},n.includes=function(s){return i.includes(s)},n.cacheResult=cacheResultThrough,n.__iterate=function(s,o){var a=this,l=0;return o&&ensureSize(i),i.__iterate(function(c,u){return s(c,e?u:o?a.size-++l:l++,a)},!o)},n.__iterator=function(s,o){var a=0;o&&ensureSize(i);var l=i.__iterator(ITERATE_ENTRIES,!o);return new Iterator(function(){var c=l.next();if(c.done)return c;var u=c.value;return iteratorValue(s,e?u[0]:o?t.size-++a:a++,u[1],c)})},n}function filterFactory(i,e,t,n){var s=makeSequence(i);return n&&(s.has=function(o){var a=i.get(o,NOT_SET);return a!==NOT_SET&&!!e.call(t,a,o,i)},s.get=function(o,a){var l=i.get(o,NOT_SET);return l!==NOT_SET&&e.call(t,l,o,i)?l:a}),s.__iterateUncached=function(o,a){var l=this,c=0;return i.__iterate(function(u,h,d){if(e.call(t,u,h,d))return c++,o(u,n?h:c-1,l)},a),c},s.__iteratorUncached=function(o,a){var l=i.__iterator(ITERATE_ENTRIES,a),c=0;return new Iterator(function(){for(;;){var u=l.next();if(u.done)return u;var h=u.value,d=h[0],p=h[1];if(e.call(t,p,d,i))return iteratorValue(o,n?d:c++,p,u)}})},s}function countByFactory(i,e,t){var n=Map$1().asMutable();return i.__iterate(function(s,o){n.update(e.call(t,s,o,i),0,function(a){return a+1})}),n.asImmutable()}function groupByFactory(i,e,t){var n=isKeyed(i),s=(isOrdered(i)?OrderedMap():Map$1()).asMutable();i.__iterate(function(a,l){s.update(e.call(t,a,l,i),function(c){return c=c||[],c.push(n?[l,a]:a),c})});var o=collectionClass(i);return s.map(function(a){return reify(i,o(a))}).asImmutable()}function partitionFactory(i,e,t){var n=isKeyed(i),s=[[],[]];i.__iterate(function(a,l){s[e.call(t,a,l,i)?1:0].push(n?[l,a]:a)});var o=collectionClass(i);return s.map(function(a){return reify(i,o(a))})}function sliceFactory(i,e,t,n){var s=i.size;if(wholeSlice(e,t,s))return i;if(typeof s>"u"&&(e<0||t<0))return sliceFactory(i.toSeq().cacheResult(),e,t,n);var o=resolveBegin(e,s),a=resolveEnd(t,s),l=a-o,c;l===l&&(c=l<0?0:l);var u=makeSequence(i);return u.size=c===0?c:i.size&&c||void 0,!n&&isSeq(i)&&c>=0&&(u.get=function(h,d){return h=wrapIndex(this,h),h>=0&&h<c?i.get(h+o,d):d}),u.__iterateUncached=function(h,d){var p=this;if(c===0)return 0;if(d)return this.cacheResult().__iterate(h,d);var f=0,g=!0,_=0;return i.__iterate(function(x,y){if(!(g&&(g=f++<o)))return _++,h(x,n?y:_-1,p)!==!1&&_!==c}),_},u.__iteratorUncached=function(h,d){if(c!==0&&d)return this.cacheResult().__iterator(h,d);if(c===0)return new Iterator(iteratorDone);var p=i.__iterator(h,d),f=0,g=0;return new Iterator(function(){for(;f++<o;)p.next();if(++g>c)return iteratorDone();var _=p.next();return n||h===ITERATE_VALUES||_.done?_:h===ITERATE_KEYS?iteratorValue(h,g-1,void 0,_):iteratorValue(h,g-1,_.value[1],_)})},u}function takeWhileFactory(i,e,t){var n=makeSequence(i);return n.__iterateUncached=function(s,o){var a=this;if(o)return this.cacheResult().__iterate(s,o);var l=0;return i.__iterate(function(c,u,h){return e.call(t,c,u,h)&&++l&&s(c,u,a)}),l},n.__iteratorUncached=function(s,o){var a=this;if(o)return this.cacheResult().__iterator(s,o);var l=i.__iterator(ITERATE_ENTRIES,o),c=!0;return new Iterator(function(){if(!c)return iteratorDone();var u=l.next();if(u.done)return u;var h=u.value,d=h[0],p=h[1];return e.call(t,p,d,a)?s===ITERATE_ENTRIES?u:iteratorValue(s,d,p,u):(c=!1,iteratorDone())})},n}function skipWhileFactory(i,e,t,n){var s=makeSequence(i);return s.__iterateUncached=function(o,a){var l=this;if(a)return this.cacheResult().__iterate(o,a);var c=!0,u=0;return i.__iterate(function(h,d,p){if(!(c&&(c=e.call(t,h,d,p))))return u++,o(h,n?d:u-1,l)}),u},s.__iteratorUncached=function(o,a){var l=this;if(a)return this.cacheResult().__iterator(o,a);var c=i.__iterator(ITERATE_ENTRIES,a),u=!0,h=0;return new Iterator(function(){var d,p,f;do{if(d=c.next(),d.done)return n||o===ITERATE_VALUES?d:o===ITERATE_KEYS?iteratorValue(o,h++,void 0,d):iteratorValue(o,h++,d.value[1],d);var g=d.value;p=g[0],f=g[1],u&&(u=e.call(t,f,p,l))}while(u);return o===ITERATE_ENTRIES?d:iteratorValue(o,p,f,d)})},s}var ConcatSeq=(function(i){function e(t){this._wrappedIterables=t.flatMap(function(n){return n._wrappedIterables?n._wrappedIterables:[n]}),this.size=this._wrappedIterables.reduce(function(n,s){if(n!==void 0){var o=s.size;if(o!==void 0)return n+o}},0),this[IS_KEYED_SYMBOL]=this._wrappedIterables[0][IS_KEYED_SYMBOL],this[IS_INDEXED_SYMBOL]=this._wrappedIterables[0][IS_INDEXED_SYMBOL],this[IS_ORDERED_SYMBOL]=this._wrappedIterables[0][IS_ORDERED_SYMBOL]}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(n,s){if(this._wrappedIterables.length!==0){if(s)return this.cacheResult().__iterate(n,s);for(var o=0,a=isKeyed(this),l=a?ITERATE_ENTRIES:ITERATE_VALUES,c=this._wrappedIterables[o].__iterator(l,s),u=!0,h=0;u;){for(var d=c.next();d.done;){if(o++,o===this._wrappedIterables.length)return h;c=this._wrappedIterables[o].__iterator(l,s),d=c.next()}var p=a?n(d.value[1],d.value[0],this):n(d.value,h,this);u=p!==!1,h++}return h}},e.prototype.__iteratorUncached=function(n,s){var o=this;if(this._wrappedIterables.length===0)return new Iterator(iteratorDone);if(s)return this.cacheResult().__iterator(n,s);var a=0,l=this._wrappedIterables[a].__iterator(n,s);return new Iterator(function(){for(var c=l.next();c.done;){if(a++,a===o._wrappedIterables.length)return c;l=o._wrappedIterables[a].__iterator(n,s),c=l.next()}return c})},e})(Seq);function concatFactory(i,e){var t=isKeyed(i),n=[i].concat(e).map(function(o){return isCollection(o)?t&&(o=KeyedCollection(o)):o=t?keyedSeqFromValue(o):indexedSeqFromValue(Array.isArray(o)?o:[o]),o}).filter(function(o){return o.size!==0});if(n.length===0)return i;if(n.length===1){var s=n[0];if(s===i||t&&isKeyed(s)||isIndexed(i)&&isIndexed(s))return s}return new ConcatSeq(n)}function flattenFactory(i,e,t){var n=makeSequence(i);return n.__iterateUncached=function(s,o){if(o)return this.cacheResult().__iterate(s,o);var a=0,l=!1;function c(u,h){u.__iterate(function(d,p){return(!e||h<e)&&isCollection(d)?c(d,h+1):(a++,s(d,t?p:a-1,n)===!1&&(l=!0)),!l},o)}return c(i,0),a},n.__iteratorUncached=function(s,o){if(o)return this.cacheResult().__iterator(s,o);var a=i.__iterator(s,o),l=[],c=0;return new Iterator(function(){for(;a;){var u=a.next();if(u.done!==!1){a=l.pop();continue}var h=u.value;if(s===ITERATE_ENTRIES&&(h=h[1]),(!e||l.length<e)&&isCollection(h))l.push(a),a=h.__iterator(s,o);else return t?u:iteratorValue(s,c++,h,u)}return iteratorDone()})},n}function flatMapFactory(i,e,t){var n=collectionClass(i);return i.toSeq().map(function(s,o){return n(e.call(t,s,o,i))}).flatten(!0)}function interposeFactory(i,e){var t=makeSequence(i);return t.size=i.size&&i.size*2-1,t.__iterateUncached=function(n,s){var o=this,a=0;return i.__iterate(function(l){return(!a||n(e,a++,o)!==!1)&&n(l,a++,o)!==!1},s),a},t.__iteratorUncached=function(n,s){var o=i.__iterator(ITERATE_VALUES,s),a=0,l;return new Iterator(function(){return(!l||a%2)&&(l=o.next(),l.done)?l:a%2?iteratorValue(n,a++,e):iteratorValue(n,a++,l.value,l)})},t}function sortFactory(i,e,t){e||(e=defaultComparator);var n=isKeyed(i),s=0,o=i.toSeq().map(function(a,l){return[l,a,s++,t?t(a,l,i):a]}).valueSeq().toArray();return o.sort(function(a,l){return e(a[3],l[3])||a[2]-l[2]}).forEach(n?function(a,l){o[l].length=2}:function(a,l){o[l]=a[1]}),n?KeyedSeq(o):isIndexed(i)?IndexedSeq(o):SetSeq(o)}function maxFactory(i,e,t){if(e||(e=defaultComparator),t){var n=i.toSeq().map(function(s,o){return[s,t(s,o,i)]}).reduce(function(s,o){return maxCompare(e,s[1],o[1])?o:s});return n&&n[0]}return i.reduce(function(s,o){return maxCompare(e,s,o)?o:s})}function maxCompare(i,e,t){var n=i(t,e);return n===0&&t!==e&&(t==null||t!==t)||n>0}function zipWithFactory(i,e,t,n){var s=makeSequence(i),o=new ArraySeq(t).map(function(a){return a.size});return s.size=n?o.max():o.min(),s.__iterate=function(a,l){for(var c=this.__iterator(ITERATE_VALUES,l),u,h=0;!(u=c.next()).done&&a(u.value,h++,this)!==!1;);return h},s.__iteratorUncached=function(a,l){var c=t.map(function(d){return d=Collection(d),getIterator(l?d.reverse():d)}),u=0,h=!1;return new Iterator(function(){var d;return h||(d=c.map(function(p){return p.next()}),h=n?d.every(function(p){return p.done}):d.some(function(p){return p.done})),h?iteratorDone():iteratorValue(a,u++,e.apply(null,d.map(function(p){return p.value})))})},s}function reify(i,e){return i===e?i:isSeq(i)?e:i.constructor(e)}function validateEntry(i){if(i!==Object(i))throw new TypeError("Expected [K, V] tuple: "+i)}function collectionClass(i){return isKeyed(i)?KeyedCollection:isIndexed(i)?IndexedCollection:SetCollection}function makeSequence(i){return Object.create((isKeyed(i)?KeyedSeq:isIndexed(i)?IndexedSeq:SetSeq).prototype)}function cacheResultThrough(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Seq.prototype.cacheResult.call(this)}function defaultComparator(i,e){return i===void 0&&e===void 0?0:i===void 0?1:e===void 0?-1:i>e?1:i<e?-1:0}function arrCopy(i,e){e=e||0;for(var t=Math.max(0,i.length-e),n=new Array(t),s=0;s<t;s++)n[s]=i[s+e];return n}function invariant(i,e){if(!i)throw new Error(e)}function assertNotInfinite(i){invariant(i!==1/0,"Cannot perform this action with an infinite size.")}function coerceKeyPath(i){if(isArrayLike(i)&&typeof i!="string")return i;if(isOrdered(i))return i.toArray();throw new TypeError("Invalid keyPath: expected Ordered Collection or Array: "+i)}var toString$1=Object.prototype.toString;function isPlainObject(i){if(!i||typeof i!="object"||toString$1.call(i)!=="[object Object]")return!1;var e=Object.getPrototypeOf(i);if(e===null)return!0;for(var t=e,n=Object.getPrototypeOf(e);n!==null;)t=n,n=Object.getPrototypeOf(t);return t===e}function isDataStructure(i){return typeof i=="object"&&(isImmutable(i)||Array.isArray(i)||isPlainObject(i))}function quoteString(i){try{return typeof i=="string"?JSON.stringify(i):String(i)}catch{return JSON.stringify(i)}}function has$1(i,e){return isImmutable(i)?i.has(e):isDataStructure(i)&&hasOwnProperty.call(i,e)}function get(i,e,t){return isImmutable(i)?i.get(e,t):has$1(i,e)?typeof i.get=="function"?i.get(e):i[e]:t}function shallowCopy(i){if(Array.isArray(i))return arrCopy(i);var e={};for(var t in i)hasOwnProperty.call(i,t)&&(e[t]=i[t]);return e}function remove(i,e){if(!isDataStructure(i))throw new TypeError("Cannot update non-data-structure value: "+i);if(isImmutable(i)){if(!i.remove)throw new TypeError("Cannot update immutable value without .remove() method: "+i);return i.remove(e)}if(!hasOwnProperty.call(i,e))return i;var t=shallowCopy(i);return Array.isArray(t)?t.splice(e,1):delete t[e],t}function set$1(i,e,t){if(!isDataStructure(i))throw new TypeError("Cannot update non-data-structure value: "+i);if(isImmutable(i)){if(!i.set)throw new TypeError("Cannot update immutable value without .set() method: "+i);return i.set(e,t)}if(hasOwnProperty.call(i,e)&&t===i[e])return i;var n=shallowCopy(i);return n[e]=t,n}function updateIn$1(i,e,t,n){n||(n=t,t=void 0);var s=updateInDeeply(isImmutable(i),i,coerceKeyPath(e),0,t,n);return s===NOT_SET?t:s}function updateInDeeply(i,e,t,n,s,o){var a=e===NOT_SET;if(n===t.length){var l=a?s:e,c=o(l);return c===l?e:c}if(!a&&!isDataStructure(e))throw new TypeError("Cannot update within non-data-structure value in path ["+Array.from(t).slice(0,n).map(quoteString)+"]: "+e);var u=t[n],h=a?NOT_SET:get(e,u,NOT_SET),d=updateInDeeply(h===NOT_SET?i:isImmutable(h),h,t,n+1,s,o);return d===h?e:d===NOT_SET?remove(e,u):set$1(a?i?emptyMap():{}:e,u,d)}function setIn$1(i,e,t){return updateIn$1(i,e,NOT_SET,function(){return t})}function setIn(i,e){return setIn$1(this,i,e)}function removeIn(i,e){return updateIn$1(i,e,function(){return NOT_SET})}function deleteIn(i){return removeIn(this,i)}function update$1(i,e,t,n){return updateIn$1(i,[e],t,n)}function update(i,e,t){return arguments.length===1?i(this):update$1(this,i,e,t)}function updateIn(i,e,t){return updateIn$1(this,i,e,t)}function merge$1(){for(var i=[],e=arguments.length;e--;)i[e]=arguments[e];return mergeIntoKeyedWith(this,i)}function mergeWith$1(i){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];if(typeof i!="function")throw new TypeError("Invalid merger function: "+i);return mergeIntoKeyedWith(this,e,i)}function mergeIntoKeyedWith(i,e,t){for(var n=[],s=0;s<e.length;s++){var o=KeyedCollection(e[s]);o.size!==0&&n.push(o)}return n.length===0?i:i.toSeq().size===0&&!i.__ownerID&&n.length===1?isRecord$2(i)?i:i.constructor(n[0]):i.withMutations(function(a){for(var l=t?function(u,h){update$1(a,h,NOT_SET,function(d){return d===NOT_SET?u:t(d,u,h)})}:function(u,h){a.set(h,u)},c=0;c<n.length;c++)n[c].forEach(l)})}function merge(i){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return mergeWithSources(i,e)}function mergeWith(i,e){for(var t=[],n=arguments.length-2;n-- >0;)t[n]=arguments[n+2];return mergeWithSources(e,t,i)}function mergeDeep$1(i){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return mergeDeepWithSources(i,e)}function mergeDeepWith$1(i,e){for(var t=[],n=arguments.length-2;n-- >0;)t[n]=arguments[n+2];return mergeDeepWithSources(e,t,i)}function mergeDeepWithSources(i,e,t){return mergeWithSources(i,e,deepMergerWith(t))}function mergeWithSources(i,e,t){if(!isDataStructure(i))throw new TypeError("Cannot merge into non-data-structure value: "+i);if(isImmutable(i))return typeof t=="function"&&i.mergeWith?i.mergeWith.apply(i,[t].concat(e)):i.merge?i.merge.apply(i,e):i.concat.apply(i,e);for(var n=Array.isArray(i),s=i,o=n?IndexedCollection:KeyedCollection,a=n?function(c){s===i&&(s=shallowCopy(s)),s.push(c)}:function(c,u){var h=hasOwnProperty.call(s,u),d=h&&t?t(s[u],c,u):c;(!h||d!==s[u])&&(s===i&&(s=shallowCopy(s)),s[u]=d)},l=0;l<e.length;l++)o(e[l]).forEach(a);return s}function deepMergerWith(i){function e(t,n,s){return isDataStructure(t)&&isDataStructure(n)&&areMergeable(t,n)?mergeWithSources(t,[n],e):i?i(t,n,s):n}return e}function areMergeable(i,e){var t=Seq(i),n=Seq(e);return isIndexed(t)===isIndexed(n)&&isKeyed(t)===isKeyed(n)}function mergeDeep(){for(var i=[],e=arguments.length;e--;)i[e]=arguments[e];return mergeDeepWithSources(this,i)}function mergeDeepWith(i){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return mergeDeepWithSources(this,e,i)}function mergeIn(i){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return updateIn$1(this,i,emptyMap(),function(n){return mergeWithSources(n,e)})}function mergeDeepIn(i){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return updateIn$1(this,i,emptyMap(),function(n){return mergeDeepWithSources(n,e)})}function withMutations(i){var e=this.asMutable();return i(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function asMutable(){return this.__ownerID?this:this.__ensureOwner(new OwnerID)}function asImmutable(){return this.__ensureOwner()}function wasAltered(){return this.__altered}var Map$1=(function(i){function e(t){return t==null?emptyMap():isMap$1(t)&&!isOrdered(t)?t:emptyMap().withMutations(function(n){var s=i(t);assertNotInfinite(s.size),s.forEach(function(o,a){return n.set(a,o)})})}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(n,s){return this._root?this._root.get(0,void 0,n,s):s},e.prototype.set=function(n,s){return updateMap(this,n,s)},e.prototype.remove=function(n){return updateMap(this,n,NOT_SET)},e.prototype.deleteAll=function(n){var s=Collection(n);return s.size===0?this:this.withMutations(function(o){s.forEach(function(a){return o.remove(a)})})},e.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):emptyMap()},e.prototype.sort=function(n){return OrderedMap(sortFactory(this,n))},e.prototype.sortBy=function(n,s){return OrderedMap(sortFactory(this,s,n))},e.prototype.map=function(n,s){var o=this;return this.withMutations(function(a){a.forEach(function(l,c){a.set(c,n.call(s,l,c,o))})})},e.prototype.__iterator=function(n,s){return new MapIterator(this,n,s)},e.prototype.__iterate=function(n,s){var o=this,a=0;return this._root&&this._root.iterate(function(l){return a++,n(l[1],l[0],o)},s),a},e.prototype.__ensureOwner=function(n){return n===this.__ownerID?this:n?makeMap(this.size,this._root,n,this.__hash):this.size===0?emptyMap():(this.__ownerID=n,this.__altered=!1,this)},e})(KeyedCollection);Map$1.isMap=isMap$1;var MapPrototype=Map$1.prototype;MapPrototype[IS_MAP_SYMBOL]=!0,MapPrototype[DELETE]=MapPrototype.remove,MapPrototype.removeAll=MapPrototype.deleteAll,MapPrototype.setIn=setIn,MapPrototype.removeIn=MapPrototype.deleteIn=deleteIn,MapPrototype.update=update,MapPrototype.updateIn=updateIn,MapPrototype.merge=MapPrototype.concat=merge$1,MapPrototype.mergeWith=mergeWith$1,MapPrototype.mergeDeep=mergeDeep,MapPrototype.mergeDeepWith=mergeDeepWith,MapPrototype.mergeIn=mergeIn,MapPrototype.mergeDeepIn=mergeDeepIn,MapPrototype.withMutations=withMutations,MapPrototype.wasAltered=wasAltered,MapPrototype.asImmutable=asImmutable,MapPrototype["@@transducer/init"]=MapPrototype.asMutable=asMutable,MapPrototype["@@transducer/step"]=function(i,e){return i.set(e[0],e[1])},MapPrototype["@@transducer/result"]=function(i){return i.asImmutable()};var ArrayMapNode=function(e,t){this.ownerID=e,this.entries=t};ArrayMapNode.prototype.get=function(e,t,n,s){for(var o=this.entries,a=0,l=o.length;a<l;a++)if(is(n,o[a][0]))return o[a][1];return s},ArrayMapNode.prototype.update=function(e,t,n,s,o,a,l){for(var c=o===NOT_SET,u=this.entries,h=0,d=u.length;h<d&&!is(s,u[h][0]);h++);var p=h<d;if(p?u[h][1]===o:c)return this;if(SetRef(l),(c||!p)&&SetRef(a),!(c&&u.length===1)){if(!p&&!c&&u.length>=MAX_ARRAY_MAP_SIZE)return createNodes(e,u,s,o);var f=e&&e===this.ownerID,g=f?u:arrCopy(u);return p?c?h===d-1?g.pop():g[h]=g.pop():g[h]=[s,o]:g.push([s,o]),f?(this.entries=g,this):new ArrayMapNode(e,g)}};var BitmapIndexedNode=function(e,t,n){this.ownerID=e,this.bitmap=t,this.nodes=n};BitmapIndexedNode.prototype.get=function(e,t,n,s){t===void 0&&(t=hash(n));var o=1<<((e===0?t:t>>>e)&MASK),a=this.bitmap;return(a&o)===0?s:this.nodes[popCount(a&o-1)].get(e+SHIFT,t,n,s)},BitmapIndexedNode.prototype.update=function(e,t,n,s,o,a,l){n===void 0&&(n=hash(s));var c=(t===0?n:n>>>t)&MASK,u=1<<c,h=this.bitmap,d=(h&u)!==0;if(!d&&o===NOT_SET)return this;var p=popCount(h&u-1),f=this.nodes,g=d?f[p]:void 0,_=updateNode(g,e,t+SHIFT,n,s,o,a,l);if(_===g)return this;if(!d&&_&&f.length>=MAX_BITMAP_INDEXED_SIZE)return expandNodes(e,f,h,c,_);if(d&&!_&&f.length===2&&isLeafNode(f[p^1]))return f[p^1];if(d&&_&&f.length===1&&isLeafNode(_))return _;var x=e&&e===this.ownerID,y=d?_?h:h^u:h|u,E=d?_?setAt(f,p,_,x):spliceOut(f,p,x):spliceIn(f,p,_,x);return x?(this.bitmap=y,this.nodes=E,this):new BitmapIndexedNode(e,y,E)};var HashArrayMapNode=function(e,t,n){this.ownerID=e,this.count=t,this.nodes=n};HashArrayMapNode.prototype.get=function(e,t,n,s){t===void 0&&(t=hash(n));var o=(e===0?t:t>>>e)&MASK,a=this.nodes[o];return a?a.get(e+SHIFT,t,n,s):s},HashArrayMapNode.prototype.update=function(e,t,n,s,o,a,l){n===void 0&&(n=hash(s));var c=(t===0?n:n>>>t)&MASK,u=o===NOT_SET,h=this.nodes,d=h[c];if(u&&!d)return this;var p=updateNode(d,e,t+SHIFT,n,s,o,a,l);if(p===d)return this;var f=this.count;if(!d)f++;else if(!p&&(f--,f<MIN_HASH_ARRAY_MAP_SIZE))return packNodes(e,h,f,c);var g=e&&e===this.ownerID,_=setAt(h,c,p,g);return g?(this.count=f,this.nodes=_,this):new HashArrayMapNode(e,f,_)};var HashCollisionNode=function(e,t,n){this.ownerID=e,this.keyHash=t,this.entries=n};HashCollisionNode.prototype.get=function(e,t,n,s){for(var o=this.entries,a=0,l=o.length;a<l;a++)if(is(n,o[a][0]))return o[a][1];return s},HashCollisionNode.prototype.update=function(e,t,n,s,o,a,l){n===void 0&&(n=hash(s));var c=o===NOT_SET;if(n!==this.keyHash)return c?this:(SetRef(l),SetRef(a),mergeIntoNode(this,e,t,n,[s,o]));for(var u=this.entries,h=0,d=u.length;h<d&&!is(s,u[h][0]);h++);var p=h<d;if(p?u[h][1]===o:c)return this;if(SetRef(l),(c||!p)&&SetRef(a),c&&d===2)return new ValueNode(e,this.keyHash,u[h^1]);var f=e&&e===this.ownerID,g=f?u:arrCopy(u);return p?c?h===d-1?g.pop():g[h]=g.pop():g[h]=[s,o]:g.push([s,o]),f?(this.entries=g,this):new HashCollisionNode(e,this.keyHash,g)};var ValueNode=function(e,t,n){this.ownerID=e,this.keyHash=t,this.entry=n};ValueNode.prototype.get=function(e,t,n,s){return is(n,this.entry[0])?this.entry[1]:s},ValueNode.prototype.update=function(e,t,n,s,o,a,l){var c=o===NOT_SET,u=is(s,this.entry[0]);if(u?o===this.entry[1]:c)return this;if(SetRef(l),c){SetRef(a);return}return u?e&&e===this.ownerID?(this.entry[1]=o,this):new ValueNode(e,this.keyHash,[s,o]):(SetRef(a),mergeIntoNode(this,e,t,hash(s),[s,o]))},ArrayMapNode.prototype.iterate=HashCollisionNode.prototype.iterate=function(i,e){for(var t=this.entries,n=0,s=t.length-1;n<=s;n++)if(i(t[e?s-n:n])===!1)return!1},BitmapIndexedNode.prototype.iterate=HashArrayMapNode.prototype.iterate=function(i,e){for(var t=this.nodes,n=0,s=t.length-1;n<=s;n++){var o=t[e?s-n:n];if(o&&o.iterate(i,e)===!1)return!1}},ValueNode.prototype.iterate=function(i,e){return i(this.entry)};var MapIterator=(function(i){function e(t,n,s){this._type=n,this._reverse=s,this._stack=t._root&&mapIteratorFrame(t._root)}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.next=function(){for(var n=this._type,s=this._stack;s;){var o=s.node,a=s.index++,l=void 0;if(o.entry){if(a===0)return mapIteratorValue(n,o.entry)}else if(o.entries){if(l=o.entries.length-1,a<=l)return mapIteratorValue(n,o.entries[this._reverse?l-a:a])}else if(l=o.nodes.length-1,a<=l){var c=o.nodes[this._reverse?l-a:a];if(c){if(c.entry)return mapIteratorValue(n,c.entry);s=this._stack=mapIteratorFrame(c,s)}continue}s=this._stack=this._stack.__prev}return iteratorDone()},e})(Iterator);function mapIteratorValue(i,e){return iteratorValue(i,e[0],e[1])}function mapIteratorFrame(i,e){return{node:i,index:0,__prev:e}}function makeMap(i,e,t,n){var s=Object.create(MapPrototype);return s.size=i,s._root=e,s.__ownerID=t,s.__hash=n,s.__altered=!1,s}var EMPTY_MAP;function emptyMap(){return EMPTY_MAP||(EMPTY_MAP=makeMap(0))}function updateMap(i,e,t){var n,s;if(i._root){var o=MakeRef(),a=MakeRef();if(n=updateNode(i._root,i.__ownerID,0,void 0,e,t,o,a),!a.value)return i;s=i.size+(o.value?t===NOT_SET?-1:1:0)}else{if(t===NOT_SET)return i;s=1,n=new ArrayMapNode(i.__ownerID,[[e,t]])}return i.__ownerID?(i.size=s,i._root=n,i.__hash=void 0,i.__altered=!0,i):n?makeMap(s,n):emptyMap()}function updateNode(i,e,t,n,s,o,a,l){return i?i.update(e,t,n,s,o,a,l):o===NOT_SET?i:(SetRef(l),SetRef(a),new ValueNode(e,n,[s,o]))}function isLeafNode(i){return i.constructor===ValueNode||i.constructor===HashCollisionNode}function mergeIntoNode(i,e,t,n,s){if(i.keyHash===n)return new HashCollisionNode(e,n,[i.entry,s]);var o=(t===0?i.keyHash:i.keyHash>>>t)&MASK,a=(t===0?n:n>>>t)&MASK,l,c=o===a?[mergeIntoNode(i,e,t+SHIFT,n,s)]:(l=new ValueNode(e,n,s),o<a?[i,l]:[l,i]);return new BitmapIndexedNode(e,1<<o|1<<a,c)}function createNodes(i,e,t,n){i||(i=new OwnerID);for(var s=new ValueNode(i,hash(t),[t,n]),o=0;o<e.length;o++){var a=e[o];s=s.update(i,0,void 0,a[0],a[1])}return s}function packNodes(i,e,t,n){for(var s=0,o=0,a=new Array(t),l=0,c=1,u=e.length;l<u;l++,c<<=1){var h=e[l];h!==void 0&&l!==n&&(s|=c,a[o++]=h)}return new BitmapIndexedNode(i,s,a)}function expandNodes(i,e,t,n,s){for(var o=0,a=new Array(SIZE),l=0;t!==0;l++,t>>>=1)a[l]=t&1?e[o++]:void 0;return a[n]=s,new HashArrayMapNode(i,o+1,a)}function popCount(i){return i-=i>>1&1431655765,i=(i&858993459)+(i>>2&858993459),i=i+(i>>4)&252645135,i+=i>>8,i+=i>>16,i&127}function setAt(i,e,t,n){var s=n?i:arrCopy(i);return s[e]=t,s}function spliceIn(i,e,t,n){var s=i.length+1;if(n&&e+1===s)return i[e]=t,i;for(var o=new Array(s),a=0,l=0;l<s;l++)l===e?(o[l]=t,a=-1):o[l]=i[l+a];return o}function spliceOut(i,e,t){var n=i.length-1;if(t&&e===n)return i.pop(),i;for(var s=new Array(n),o=0,a=0;a<n;a++)a===e&&(o=1),s[a]=i[a+o];return s}var MAX_ARRAY_MAP_SIZE=SIZE/4,MAX_BITMAP_INDEXED_SIZE=SIZE/2,MIN_HASH_ARRAY_MAP_SIZE=SIZE/4,IS_LIST_SYMBOL="@@__IMMUTABLE_LIST__@@";function isList(i){return!!(i&&i[IS_LIST_SYMBOL])}var List=(function(i){function e(t){var n=emptyList();if(t==null)return n;if(isList(t))return t;var s=i(t),o=s.size;return o===0?n:(assertNotInfinite(o),o>0&&o<SIZE?makeList(0,o,SHIFT,null,new VNode(s.toArray())):n.withMutations(function(a){a.setSize(o),s.forEach(function(l,c){return a.set(c,l)})}))}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("List [","]")},e.prototype.get=function(n,s){if(n=wrapIndex(this,n),n>=0&&n<this.size){n+=this._origin;var o=listNodeFor(this,n);return o&&o.array[n&MASK]}return s},e.prototype.set=function(n,s){return updateList(this,n,s)},e.prototype.remove=function(n){return this.has(n)?n===0?this.shift():n===this.size-1?this.pop():this.splice(n,1):this},e.prototype.insert=function(n,s){return this.splice(n,0,s)},e.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=SHIFT,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):emptyList()},e.prototype.push=function(){var n=arguments,s=this.size;return this.withMutations(function(o){setListBounds(o,0,s+n.length);for(var a=0;a<n.length;a++)o.set(s+a,n[a])})},e.prototype.pop=function(){return setListBounds(this,0,-1)},e.prototype.unshift=function(){var n=arguments;return this.withMutations(function(s){setListBounds(s,-n.length);for(var o=0;o<n.length;o++)s.set(o,n[o])})},e.prototype.shift=function(){return setListBounds(this,1)},e.prototype.shuffle=function(n){return n===void 0&&(n=Math.random),this.withMutations(function(s){for(var o=s.size,a,l;o;)a=Math.floor(n()*o--),l=s.get(a),s.set(a,s.get(o)),s.set(o,l)})},e.prototype.concat=function(){for(var n=arguments,s=[],o=0;o<arguments.length;o++){var a=n[o],l=i(typeof a!="string"&&hasIterator(a)?a:[a]);l.size!==0&&s.push(l)}return s.length===0?this:this.size===0&&!this.__ownerID&&s.length===1?this.constructor(s[0]):this.withMutations(function(c){s.forEach(function(u){return u.forEach(function(h){return c.push(h)})})})},e.prototype.setSize=function(n){return setListBounds(this,0,n)},e.prototype.map=function(n,s){var o=this;return this.withMutations(function(a){for(var l=0;l<o.size;l++)a.set(l,n.call(s,a.get(l),l,o))})},e.prototype.slice=function(n,s){var o=this.size;return wholeSlice(n,s,o)?this:setListBounds(this,resolveBegin(n,o),resolveEnd(s,o))},e.prototype.__iterator=function(n,s){var o=s?this.size:0,a=iterateList(this,s);return new Iterator(function(){var l=a();return l===DONE?iteratorDone():iteratorValue(n,s?--o:o++,l)})},e.prototype.__iterate=function(n,s){for(var o=s?this.size:0,a=iterateList(this,s),l;(l=a())!==DONE&&n(l,s?--o:o++,this)!==!1;);return o},e.prototype.__ensureOwner=function(n){return n===this.__ownerID?this:n?makeList(this._origin,this._capacity,this._level,this._root,this._tail,n,this.__hash):this.size===0?emptyList():(this.__ownerID=n,this.__altered=!1,this)},e})(IndexedCollection);List.isList=isList;var ListPrototype=List.prototype;ListPrototype[IS_LIST_SYMBOL]=!0,ListPrototype[DELETE]=ListPrototype.remove,ListPrototype.merge=ListPrototype.concat,ListPrototype.setIn=setIn,ListPrototype.deleteIn=ListPrototype.removeIn=deleteIn,ListPrototype.update=update,ListPrototype.updateIn=updateIn,ListPrototype.mergeIn=mergeIn,ListPrototype.mergeDeepIn=mergeDeepIn,ListPrototype.withMutations=withMutations,ListPrototype.wasAltered=wasAltered,ListPrototype.asImmutable=asImmutable,ListPrototype["@@transducer/init"]=ListPrototype.asMutable=asMutable,ListPrototype["@@transducer/step"]=function(i,e){return i.push(e)},ListPrototype["@@transducer/result"]=function(i){return i.asImmutable()};var VNode=function(e,t){this.array=e,this.ownerID=t};VNode.prototype.removeBefore=function(e,t,n){if((n&(1<<t+SHIFT)-1)===0||this.array.length===0)return this;var s=n>>>t&MASK;if(s>=this.array.length)return new VNode([],e);var o=s===0,a;if(t>0){var l=this.array[s];if(a=l&&l.removeBefore(e,t-SHIFT,n),a===l&&o)return this}if(o&&!a)return this;var c=editableVNode(this,e);if(!o)for(var u=0;u<s;u++)c.array[u]=void 0;return a&&(c.array[s]=a),c},VNode.prototype.removeAfter=function(e,t,n){if(n===(t?1<<t+SHIFT:SIZE)||this.array.length===0)return this;var s=n-1>>>t&MASK;if(s>=this.array.length)return this;var o;if(t>0){var a=this.array[s];if(o=a&&a.removeAfter(e,t-SHIFT,n),o===a&&s===this.array.length-1)return this}var l=editableVNode(this,e);return l.array.splice(s+1),o&&(l.array[s]=o),l};var DONE={};function iterateList(i,e){var t=i._origin,n=i._capacity,s=getTailOffset(n),o=i._tail;return a(i._root,i._level,0);function a(u,h,d){return h===0?l(u,d):c(u,h,d)}function l(u,h){var d=h===s?o&&o.array:u&&u.array,p=h>t?0:t-h,f=n-h;return f>SIZE&&(f=SIZE),function(){if(p===f)return DONE;var g=e?--f:p++;return d&&d[g]}}function c(u,h,d){var p,f=u&&u.array,g=d>t?0:t-d>>h,_=(n-d>>h)+1;return _>SIZE&&(_=SIZE),function(){for(;;){if(p){var x=p();if(x!==DONE)return x;p=null}if(g===_)return DONE;var y=e?--_:g++;p=a(f&&f[y],h-SHIFT,d+(y<<h))}}}}function makeList(i,e,t,n,s,o,a){var l=Object.create(ListPrototype);return l.size=e-i,l._origin=i,l._capacity=e,l._level=t,l._root=n,l._tail=s,l.__ownerID=o,l.__hash=a,l.__altered=!1,l}function emptyList(){return makeList(0,0,SHIFT)}function updateList(i,e,t){if(e=wrapIndex(i,e),e!==e)return i;if(e>=i.size||e<0)return i.withMutations(function(a){e<0?setListBounds(a,e).set(0,t):setListBounds(a,0,e+1).set(e,t)});e+=i._origin;var n=i._tail,s=i._root,o=MakeRef();return e>=getTailOffset(i._capacity)?n=updateVNode(n,i.__ownerID,0,e,t,o):s=updateVNode(s,i.__ownerID,i._level,e,t,o),o.value?i.__ownerID?(i._root=s,i._tail=n,i.__hash=void 0,i.__altered=!0,i):makeList(i._origin,i._capacity,i._level,s,n):i}function updateVNode(i,e,t,n,s,o){var a=n>>>t&MASK,l=i&&a<i.array.length;if(!l&&s===void 0)return i;var c;if(t>0){var u=i&&i.array[a],h=updateVNode(u,e,t-SHIFT,n,s,o);return h===u?i:(c=editableVNode(i,e),c.array[a]=h,c)}return l&&i.array[a]===s?i:(o&&SetRef(o),c=editableVNode(i,e),s===void 0&&a===c.array.length-1?c.array.pop():c.array[a]=s,c)}function editableVNode(i,e){return e&&i&&e===i.ownerID?i:new VNode(i?i.array.slice():[],e)}function listNodeFor(i,e){if(e>=getTailOffset(i._capacity))return i._tail;if(e<1<<i._level+SHIFT){for(var t=i._root,n=i._level;t&&n>0;)t=t.array[e>>>n&MASK],n-=SHIFT;return t}}function setListBounds(i,e,t){e!==void 0&&(e|=0),t!==void 0&&(t|=0);var n=i.__ownerID||new OwnerID,s=i._origin,o=i._capacity,a=s+e,l=t===void 0?o:t<0?o+t:s+t;if(a===s&&l===o)return i;if(a>=l)return i.clear();for(var c=i._level,u=i._root,h=0;a+h<0;)u=new VNode(u&&u.array.length?[void 0,u]:[],n),c+=SHIFT,h+=1<<c;h&&(a+=h,s+=h,l+=h,o+=h);for(var d=getTailOffset(o),p=getTailOffset(l);p>=1<<c+SHIFT;)u=new VNode(u&&u.array.length?[u]:[],n),c+=SHIFT;var f=i._tail,g=p<d?listNodeFor(i,l-1):p>d?new VNode([],n):f;if(f&&p>d&&a<o&&f.array.length){u=editableVNode(u,n);for(var _=u,x=c;x>SHIFT;x-=SHIFT){var y=d>>>x&MASK;_=_.array[y]=editableVNode(_.array[y],n)}_.array[d>>>SHIFT&MASK]=f}if(l<o&&(g=g&&g.removeAfter(n,0,l)),a>=p)a-=p,l-=p,c=SHIFT,u=null,g=g&&g.removeBefore(n,0,a);else if(a>s||p<d){for(h=0;u;){var E=a>>>c&MASK;if(E!==p>>>c&MASK)break;E&&(h+=(1<<c)*E),c-=SHIFT,u=u.array[E]}u&&a>s&&(u=u.removeBefore(n,c,a-h)),u&&p<d&&(u=u.removeAfter(n,c,p-h)),h&&(a-=h,l-=h)}return i.__ownerID?(i.size=l-a,i._origin=a,i._capacity=l,i._level=c,i._root=u,i._tail=g,i.__hash=void 0,i.__altered=!0,i):makeList(a,l,c,u,g)}function getTailOffset(i){return i<SIZE?0:i-1>>>SHIFT<<SHIFT}var OrderedMap=(function(i){function e(t){return t==null?emptyOrderedMap():isOrderedMap(t)?t:emptyOrderedMap().withMutations(function(n){var s=KeyedCollection(t);assertNotInfinite(s.size),s.forEach(function(o,a){return n.set(a,o)})})}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(n,s){var o=this._map.get(n);return o!==void 0?this._list.get(o)[1]:s},e.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this.__altered=!0,this):emptyOrderedMap()},e.prototype.set=function(n,s){return updateOrderedMap(this,n,s)},e.prototype.remove=function(n){return updateOrderedMap(this,n,NOT_SET)},e.prototype.__iterate=function(n,s){var o=this;return this._list.__iterate(function(a){return a&&n(a[1],a[0],o)},s)},e.prototype.__iterator=function(n,s){return this._list.fromEntrySeq().__iterator(n,s)},e.prototype.__ensureOwner=function(n){if(n===this.__ownerID)return this;var s=this._map.__ensureOwner(n),o=this._list.__ensureOwner(n);return n?makeOrderedMap(s,o,n,this.__hash):this.size===0?emptyOrderedMap():(this.__ownerID=n,this.__altered=!1,this._map=s,this._list=o,this)},e})(Map$1);OrderedMap.isOrderedMap=isOrderedMap,OrderedMap.prototype[IS_ORDERED_SYMBOL]=!0,OrderedMap.prototype[DELETE]=OrderedMap.prototype.remove;function makeOrderedMap(i,e,t,n){var s=Object.create(OrderedMap.prototype);return s.size=i?i.size:0,s._map=i,s._list=e,s.__ownerID=t,s.__hash=n,s.__altered=!1,s}var EMPTY_ORDERED_MAP;function emptyOrderedMap(){return EMPTY_ORDERED_MAP||(EMPTY_ORDERED_MAP=makeOrderedMap(emptyMap(),emptyList()))}function updateOrderedMap(i,e,t){var n=i._map,s=i._list,o=n.get(e),a=o!==void 0,l,c;if(t===NOT_SET){if(!a)return i;s.size>=SIZE&&s.size>=n.size*2?(c=s.filter(function(u,h){return u!==void 0&&o!==h}),l=c.toKeyedSeq().map(function(u){return u[0]}).flip().toMap(),i.__ownerID&&(l.__ownerID=c.__ownerID=i.__ownerID)):(l=n.remove(e),c=o===s.size-1?s.pop():s.set(o,void 0))}else if(a){if(t===s.get(o)[1])return i;l=n,c=s.set(o,[e,t])}else l=n.set(e,s.size),c=s.set(s.size,[e,t]);return i.__ownerID?(i.size=l.size,i._map=l,i._list=c,i.__hash=void 0,i.__altered=!0,i):makeOrderedMap(l,c)}var IS_STACK_SYMBOL="@@__IMMUTABLE_STACK__@@";function isStack(i){return!!(i&&i[IS_STACK_SYMBOL])}var Stack=(function(i){function e(t){return t==null?emptyStack():isStack(t)?t:emptyStack().pushAll(t)}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(n,s){var o=this._head;for(n=wrapIndex(this,n);o&&n--;)o=o.next;return o?o.value:s},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var n=arguments;if(arguments.length===0)return this;for(var s=this.size+arguments.length,o=this._head,a=arguments.length-1;a>=0;a--)o={value:n[a],next:o};return this.__ownerID?(this.size=s,this._head=o,this.__hash=void 0,this.__altered=!0,this):makeStack(s,o)},e.prototype.pushAll=function(n){if(n=i(n),n.size===0)return this;if(this.size===0&&isStack(n))return n;assertNotInfinite(n.size);var s=this.size,o=this._head;return n.__iterate(function(a){s++,o={value:a,next:o}},!0),this.__ownerID?(this.size=s,this._head=o,this.__hash=void 0,this.__altered=!0,this):makeStack(s,o)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):emptyStack()},e.prototype.slice=function(n,s){if(wholeSlice(n,s,this.size))return this;var o=resolveBegin(n,this.size),a=resolveEnd(s,this.size);if(a!==this.size)return i.prototype.slice.call(this,n,s);for(var l=this.size-o,c=this._head;o--;)c=c.next;return this.__ownerID?(this.size=l,this._head=c,this.__hash=void 0,this.__altered=!0,this):makeStack(l,c)},e.prototype.__ensureOwner=function(n){return n===this.__ownerID?this:n?makeStack(this.size,this._head,n,this.__hash):this.size===0?emptyStack():(this.__ownerID=n,this.__altered=!1,this)},e.prototype.__iterate=function(n,s){var o=this;if(s)return new ArraySeq(this.toArray()).__iterate(function(c,u){return n(c,u,o)},s);for(var a=0,l=this._head;l&&n(l.value,a++,this)!==!1;)l=l.next;return a},e.prototype.__iterator=function(n,s){if(s)return new ArraySeq(this.toArray()).__iterator(n,s);var o=0,a=this._head;return new Iterator(function(){if(a){var l=a.value;return a=a.next,iteratorValue(n,o++,l)}return iteratorDone()})},e})(IndexedCollection);Stack.isStack=isStack;var StackPrototype=Stack.prototype;StackPrototype[IS_STACK_SYMBOL]=!0,StackPrototype.shift=StackPrototype.pop,StackPrototype.unshift=StackPrototype.push,StackPrototype.unshiftAll=StackPrototype.pushAll,StackPrototype.withMutations=withMutations,StackPrototype.wasAltered=wasAltered,StackPrototype.asImmutable=asImmutable,StackPrototype["@@transducer/init"]=StackPrototype.asMutable=asMutable,StackPrototype["@@transducer/step"]=function(i,e){return i.unshift(e)},StackPrototype["@@transducer/result"]=function(i){return i.asImmutable()};function makeStack(i,e,t,n){var s=Object.create(StackPrototype);return s.size=i,s._head=e,s.__ownerID=t,s.__hash=n,s.__altered=!1,s}var EMPTY_STACK;function emptyStack(){return EMPTY_STACK||(EMPTY_STACK=makeStack(0))}var IS_SET_SYMBOL="@@__IMMUTABLE_SET__@@";function isSet(i){return!!(i&&i[IS_SET_SYMBOL])}function isOrderedSet(i){return isSet(i)&&isOrdered(i)}function deepEqual(i,e){if(i===e)return!0;if(!isCollection(e)||i.size!==void 0&&e.size!==void 0&&i.size!==e.size||i.__hash!==void 0&&e.__hash!==void 0&&i.__hash!==e.__hash||isKeyed(i)!==isKeyed(e)||isIndexed(i)!==isIndexed(e)||isOrdered(i)!==isOrdered(e))return!1;if(i.size===0&&e.size===0)return!0;var t=!isAssociative(i);if(isOrdered(i)){var n=i.entries();return e.every(function(c,u){var h=n.next().value;return h&&is(h[1],c)&&(t||is(h[0],u))})&&n.next().done}var s=!1;if(i.size===void 0)if(e.size===void 0)typeof i.cacheResult=="function"&&i.cacheResult();else{s=!0;var o=i;i=e,e=o}var a=!0,l=e.__iterate(function(c,u){if(t?!i.has(c):s?!is(c,i.get(u,NOT_SET)):!is(i.get(u,NOT_SET),c))return a=!1,!1});return a&&i.size===l}function mixin(i,e){var t=function(n){i.prototype[n]=e[n]};return Object.keys(e).forEach(t),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(t),i}function toJS(i){if(!i||typeof i!="object")return i;if(!isCollection(i)){if(!isDataStructure(i))return i;i=Seq(i)}if(isKeyed(i)){var e={};return i.__iterate(function(n,s){e[s]=toJS(n)}),e}var t=[];return i.__iterate(function(n){t.push(toJS(n))}),t}var Set$1=(function(i){function e(t){return t==null?emptySet():isSet(t)&&!isOrdered(t)?t:emptySet().withMutations(function(n){var s=i(t);assertNotInfinite(s.size),s.forEach(function(o){return n.add(o)})})}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(n){return this(KeyedCollection(n).keySeq())},e.intersect=function(n){return n=Collection(n).toArray(),n.length?SetPrototype.intersect.apply(e(n.pop()),n):emptySet()},e.union=function(n){return n=Collection(n).toArray(),n.length?SetPrototype.union.apply(e(n.pop()),n):emptySet()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(n){return this._map.has(n)},e.prototype.add=function(n){return updateSet(this,this._map.set(n,n))},e.prototype.remove=function(n){return updateSet(this,this._map.remove(n))},e.prototype.clear=function(){return updateSet(this,this._map.clear())},e.prototype.map=function(n,s){var o=this,a=!1,l=updateSet(this,this._map.mapEntries(function(c){var u=c[1],h=n.call(s,u,u,o);return h!==u&&(a=!0),[h,h]},s));return a?l:this},e.prototype.union=function(){for(var n=[],s=arguments.length;s--;)n[s]=arguments[s];return n=n.filter(function(o){return o.size!==0}),n.length===0?this:this.size===0&&!this.__ownerID&&n.length===1?this.constructor(n[0]):this.withMutations(function(o){for(var a=0;a<n.length;a++)typeof n[a]=="string"?o.add(n[a]):i(n[a]).forEach(function(l){return o.add(l)})})},e.prototype.intersect=function(){for(var n=[],s=arguments.length;s--;)n[s]=arguments[s];if(n.length===0)return this;n=n.map(function(a){return i(a)});var o=[];return this.forEach(function(a){n.every(function(l){return l.includes(a)})||o.push(a)}),this.withMutations(function(a){o.forEach(function(l){a.remove(l)})})},e.prototype.subtract=function(){for(var n=[],s=arguments.length;s--;)n[s]=arguments[s];if(n.length===0)return this;n=n.map(function(a){return i(a)});var o=[];return this.forEach(function(a){n.some(function(l){return l.includes(a)})&&o.push(a)}),this.withMutations(function(a){o.forEach(function(l){a.remove(l)})})},e.prototype.sort=function(n){return OrderedSet(sortFactory(this,n))},e.prototype.sortBy=function(n,s){return OrderedSet(sortFactory(this,s,n))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(n,s){var o=this;return this._map.__iterate(function(a){return n(a,a,o)},s)},e.prototype.__iterator=function(n,s){return this._map.__iterator(n,s)},e.prototype.__ensureOwner=function(n){if(n===this.__ownerID)return this;var s=this._map.__ensureOwner(n);return n?this.__make(s,n):this.size===0?this.__empty():(this.__ownerID=n,this._map=s,this)},e})(SetCollection);Set$1.isSet=isSet;var SetPrototype=Set$1.prototype;SetPrototype[IS_SET_SYMBOL]=!0,SetPrototype[DELETE]=SetPrototype.remove,SetPrototype.merge=SetPrototype.concat=SetPrototype.union,SetPrototype.withMutations=withMutations,SetPrototype.asImmutable=asImmutable,SetPrototype["@@transducer/init"]=SetPrototype.asMutable=asMutable,SetPrototype["@@transducer/step"]=function(i,e){return i.add(e)},SetPrototype["@@transducer/result"]=function(i){return i.asImmutable()},SetPrototype.__empty=emptySet,SetPrototype.__make=makeSet;function updateSet(i,e){return i.__ownerID?(i.size=e.size,i._map=e,i):e===i._map?i:e.size===0?i.__empty():i.__make(e)}function makeSet(i,e){var t=Object.create(SetPrototype);return t.size=i?i.size:0,t._map=i,t.__ownerID=e,t}var EMPTY_SET;function emptySet(){return EMPTY_SET||(EMPTY_SET=makeSet(emptyMap()))}var Range=(function(i){function e(t,n,s){if(s===void 0&&(s=1),!(this instanceof e))return new e(t,n,s);if(invariant(s!==0,"Cannot step a Range by 0"),invariant(t!==void 0,"You must define a start value when using Range"),invariant(n!==void 0,"You must define an end value when using Range"),s=Math.abs(s),n<t&&(s=-s),this._start=t,this._end=n,this._step=s,this.size=Math.max(0,Math.ceil((n-t)/s-1)+1),this.size===0){if(EMPTY_RANGE)return EMPTY_RANGE;EMPTY_RANGE=this}}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.size===0?"Range []":"Range [ "+this._start+"..."+this._end+(this._step!==1?" by "+this._step:"")+" ]"},e.prototype.get=function(n,s){return this.has(n)?this._start+wrapIndex(this,n)*this._step:s},e.prototype.includes=function(n){var s=(n-this._start)/this._step;return s>=0&&s<this.size&&s===Math.floor(s)},e.prototype.slice=function(n,s){return wholeSlice(n,s,this.size)?this:(n=resolveBegin(n,this.size),s=resolveEnd(s,this.size),s<=n?new e(0,0):new e(this.get(n,this._end),this.get(s,this._end),this._step))},e.prototype.indexOf=function(n){var s=n-this._start;if(s%this._step===0){var o=s/this._step;if(o>=0&&o<this.size)return o}return-1},e.prototype.lastIndexOf=function(n){return this.indexOf(n)},e.prototype.__iterate=function(n,s){for(var o=this.size,a=this._step,l=s?this._start+(o-1)*a:this._start,c=0;c!==o&&n(l,s?o-++c:c++,this)!==!1;)l+=s?-a:a;return c},e.prototype.__iterator=function(n,s){var o=this.size,a=this._step,l=s?this._start+(o-1)*a:this._start,c=0;return new Iterator(function(){if(c===o)return iteratorDone();var u=l;return l+=s?-a:a,iteratorValue(n,s?o-++c:c++,u)})},e.prototype.equals=function(n){return n instanceof e?this._start===n._start&&this._end===n._end&&this._step===n._step:deepEqual(this,n)},e})(IndexedSeq),EMPTY_RANGE;function getIn$1(i,e,t){for(var n=coerceKeyPath(e),s=0;s!==n.length;)if(i=get(i,n[s++],NOT_SET),i===NOT_SET)return t;return i}function getIn(i,e){return getIn$1(this,i,e)}function hasIn$1(i,e){return getIn$1(i,e,NOT_SET)!==NOT_SET}function hasIn(i){return hasIn$1(this,i)}function toObject(){assertNotInfinite(this.size);var i={};return this.__iterate(function(e,t){i[t]=e}),i}Collection.Iterator=Iterator,mixin(Collection,{toArray:function(){assertNotInfinite(this.size);var e=new Array(this.size||0),t=isKeyed(this),n=0;return this.__iterate(function(s,o){e[n++]=t?[o,s]:s}),e},toIndexedSeq:function(){return new ToIndexedSequence(this)},toJS:function(){return toJS(this)},toKeyedSeq:function(){return new ToKeyedSequence(this,!0)},toMap:function(){return Map$1(this.toKeyedSeq())},toObject,toOrderedMap:function(){return OrderedMap(this.toKeyedSeq())},toOrderedSet:function(){return OrderedSet(isKeyed(this)?this.valueSeq():this)},toSet:function(){return Set$1(isKeyed(this)?this.valueSeq():this)},toSetSeq:function(){return new ToSetSequence(this)},toSeq:function(){return isIndexed(this)?this.toIndexedSeq():isKeyed(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return Stack(isKeyed(this)?this.valueSeq():this)},toList:function(){return List(isKeyed(this)?this.valueSeq():this)},toString:function(){return"[Collection]"},__toString:function(e,t){return this.size===0?e+t:e+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+t},concat:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return reify(this,concatFactory(this,e))},includes:function(e){return this.some(function(t){return is(t,e)})},entries:function(){return this.__iterator(ITERATE_ENTRIES)},every:function(e,t){assertNotInfinite(this.size);var n=!0;return this.__iterate(function(s,o,a){if(!e.call(t,s,o,a))return n=!1,!1}),n},filter:function(e,t){return reify(this,filterFactory(this,e,t,!0))},partition:function(e,t){return partitionFactory(this,e,t)},find:function(e,t,n){var s=this.findEntry(e,t);return s?s[1]:n},forEach:function(e,t){return assertNotInfinite(this.size),this.__iterate(t?e.bind(t):e)},join:function(e){assertNotInfinite(this.size),e=e!==void 0?""+e:",";var t="",n=!0;return this.__iterate(function(s){n?n=!1:t+=e,t+=s!=null?s.toString():""}),t},keys:function(){return this.__iterator(ITERATE_KEYS)},map:function(e,t){return reify(this,mapFactory(this,e,t))},reduce:function(e,t,n){return reduce(this,e,t,n,arguments.length<2,!1)},reduceRight:function(e,t,n){return reduce(this,e,t,n,arguments.length<2,!0)},reverse:function(){return reify(this,reverseFactory(this,!0))},slice:function(e,t){return reify(this,sliceFactory(this,e,t,!0))},some:function(e,t){assertNotInfinite(this.size);var n=!1;return this.__iterate(function(s,o,a){if(e.call(t,s,o,a))return n=!0,!1}),n},sort:function(e){return reify(this,sortFactory(this,e))},values:function(){return this.__iterator(ITERATE_VALUES)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return this.size!==void 0?this.size===0:!this.some(function(){return!0})},count:function(e,t){return ensureSize(e?this.toSeq().filter(e,t):this)},countBy:function(e,t){return countByFactory(this,e,t)},equals:function(e){return deepEqual(this,e)},entrySeq:function(){var e=this;if(e._cache)return new ArraySeq(e._cache);var t=e.toSeq().map(entryMapper).toIndexedSeq();return t.fromEntrySeq=function(){return e.toSeq()},t},filterNot:function(e,t){return this.filter(not(e),t)},findEntry:function(e,t,n){var s=n;return this.__iterate(function(o,a,l){if(e.call(t,o,a,l))return s=[a,o],!1}),s},findKey:function(e,t){var n=this.findEntry(e,t);return n&&n[0]},findLast:function(e,t,n){return this.toKeyedSeq().reverse().find(e,t,n)},findLastEntry:function(e,t,n){return this.toKeyedSeq().reverse().findEntry(e,t,n)},findLastKey:function(e,t){return this.toKeyedSeq().reverse().findKey(e,t)},first:function(e){return this.find(returnTrue,null,e)},flatMap:function(e,t){return reify(this,flatMapFactory(this,e,t))},flatten:function(e){return reify(this,flattenFactory(this,e,!0))},fromEntrySeq:function(){return new FromEntriesSequence(this)},get:function(e,t){return this.find(function(n,s){return is(s,e)},void 0,t)},getIn,groupBy:function(e,t){return groupByFactory(this,e,t)},has:function(e){return this.get(e,NOT_SET)!==NOT_SET},hasIn,isSubset:function(e){return e=typeof e.includes=="function"?e:Collection(e),this.every(function(t){return e.includes(t)})},isSuperset:function(e){return e=typeof e.isSubset=="function"?e:Collection(e),e.isSubset(this)},keyOf:function(e){return this.findKey(function(t){return is(t,e)})},keySeq:function(){return this.toSeq().map(keyMapper).toIndexedSeq()},last:function(e){return this.toSeq().reverse().first(e)},lastKeyOf:function(e){return this.toKeyedSeq().reverse().keyOf(e)},max:function(e){return maxFactory(this,e)},maxBy:function(e,t){return maxFactory(this,t,e)},min:function(e){return maxFactory(this,e?neg(e):defaultNegComparator)},minBy:function(e,t){return maxFactory(this,t?neg(t):defaultNegComparator,e)},rest:function(){return this.slice(1)},skip:function(e){return e===0?this:this.slice(Math.max(0,e))},skipLast:function(e){return e===0?this:this.slice(0,-Math.max(0,e))},skipWhile:function(e,t){return reify(this,skipWhileFactory(this,e,t,!0))},skipUntil:function(e,t){return this.skipWhile(not(e),t)},sortBy:function(e,t){return reify(this,sortFactory(this,t,e))},take:function(e){return this.slice(0,Math.max(0,e))},takeLast:function(e){return this.slice(-Math.max(0,e))},takeWhile:function(e,t){return reify(this,takeWhileFactory(this,e,t))},takeUntil:function(e,t){return this.takeWhile(not(e),t)},update:function(e){return e(this)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=hashCollection(this))}});var CollectionPrototype=Collection.prototype;CollectionPrototype[IS_COLLECTION_SYMBOL]=!0,CollectionPrototype[ITERATOR_SYMBOL]=CollectionPrototype.values,CollectionPrototype.toJSON=CollectionPrototype.toArray,CollectionPrototype.__toStringMapper=quoteString,CollectionPrototype.inspect=CollectionPrototype.toSource=function(){return this.toString()},CollectionPrototype.chain=CollectionPrototype.flatMap,CollectionPrototype.contains=CollectionPrototype.includes,mixin(KeyedCollection,{flip:function(){return reify(this,flipFactory(this))},mapEntries:function(e,t){var n=this,s=0;return reify(this,this.toSeq().map(function(o,a){return e.call(t,[a,o],s++,n)}).fromEntrySeq())},mapKeys:function(e,t){var n=this;return reify(this,this.toSeq().flip().map(function(s,o){return e.call(t,s,o,n)}).flip())}});var KeyedCollectionPrototype=KeyedCollection.prototype;KeyedCollectionPrototype[IS_KEYED_SYMBOL]=!0,KeyedCollectionPrototype[ITERATOR_SYMBOL]=CollectionPrototype.entries,KeyedCollectionPrototype.toJSON=toObject,KeyedCollectionPrototype.__toStringMapper=function(i,e){return quoteString(e)+": "+quoteString(i)},mixin(IndexedCollection,{toKeyedSeq:function(){return new ToKeyedSequence(this,!1)},filter:function(e,t){return reify(this,filterFactory(this,e,t,!1))},findIndex:function(e,t){var n=this.findEntry(e,t);return n?n[0]:-1},indexOf:function(e){var t=this.keyOf(e);return t===void 0?-1:t},lastIndexOf:function(e){var t=this.lastKeyOf(e);return t===void 0?-1:t},reverse:function(){return reify(this,reverseFactory(this,!1))},slice:function(e,t){return reify(this,sliceFactory(this,e,t,!1))},splice:function(e,t){var n=arguments.length;if(t=Math.max(t||0,0),n===0||n===2&&!t)return this;e=resolveBegin(e,e<0?this.count():this.size);var s=this.slice(0,e);return reify(this,n===1?s:s.concat(arrCopy(arguments,2),this.slice(e+t)))},findLastIndex:function(e,t){var n=this.findLastEntry(e,t);return n?n[0]:-1},first:function(e){return this.get(0,e)},flatten:function(e){return reify(this,flattenFactory(this,e,!1))},get:function(e,t){return e=wrapIndex(this,e),e<0||this.size===1/0||this.size!==void 0&&e>this.size?t:this.find(function(n,s){return s===e},void 0,t)},has:function(e){return e=wrapIndex(this,e),e>=0&&(this.size!==void 0?this.size===1/0||e<this.size:this.indexOf(e)!==-1)},interpose:function(e){return reify(this,interposeFactory(this,e))},interleave:function(){var e=[this].concat(arrCopy(arguments)),t=zipWithFactory(this.toSeq(),IndexedSeq.of,e),n=t.flatten(!0);return t.size&&(n.size=t.size*e.length),reify(this,n)},keySeq:function(){return Range(0,this.size)},last:function(e){return this.get(-1,e)},skipWhile:function(e,t){return reify(this,skipWhileFactory(this,e,t,!1))},zip:function(){var e=[this].concat(arrCopy(arguments));return reify(this,zipWithFactory(this,defaultZipper,e))},zipAll:function(){var e=[this].concat(arrCopy(arguments));return reify(this,zipWithFactory(this,defaultZipper,e,!0))},zipWith:function(e){var t=arrCopy(arguments);return t[0]=this,reify(this,zipWithFactory(this,e,t))}});var IndexedCollectionPrototype=IndexedCollection.prototype;IndexedCollectionPrototype[IS_INDEXED_SYMBOL]=!0,IndexedCollectionPrototype[IS_ORDERED_SYMBOL]=!0,mixin(SetCollection,{get:function(e,t){return this.has(e)?e:t},includes:function(e){return this.has(e)},keySeq:function(){return this.valueSeq()}});var SetCollectionPrototype=SetCollection.prototype;SetCollectionPrototype.has=CollectionPrototype.includes,SetCollectionPrototype.contains=SetCollectionPrototype.includes,SetCollectionPrototype.keys=SetCollectionPrototype.values,mixin(KeyedSeq,KeyedCollectionPrototype),mixin(IndexedSeq,IndexedCollectionPrototype),mixin(SetSeq,SetCollectionPrototype);function reduce(i,e,t,n,s,o){return assertNotInfinite(i.size),i.__iterate(function(a,l,c){s?(s=!1,t=a):t=e.call(n,t,a,l,c)},o),t}function keyMapper(i,e){return e}function entryMapper(i,e){return[e,i]}function not(i){return function(){return!i.apply(this,arguments)}}function neg(i){return function(){return-i.apply(this,arguments)}}function defaultZipper(){return arrCopy(arguments)}function defaultNegComparator(i,e){return i<e?1:i>e?-1:0}function hashCollection(i){if(i.size===1/0)return 0;var e=isOrdered(i),t=isKeyed(i),n=e?1:0;return i.__iterate(t?e?function(s,o){n=31*n+hashMerge(hash(s),hash(o))|0}:function(s,o){n=n+hashMerge(hash(s),hash(o))|0}:e?function(s){n=31*n+hash(s)|0}:function(s){n=n+hash(s)|0}),murmurHashOfSize(i.size,n)}function murmurHashOfSize(i,e){return e=imul(e,3432918353),e=imul(e<<15|e>>>-15,461845907),e=imul(e<<13|e>>>-13,5),e=(e+3864292196|0)^i,e=imul(e^e>>>16,2246822507),e=imul(e^e>>>13,3266489909),e=smi(e^e>>>16),e}function hashMerge(i,e){return i^e+2654435769+(i<<6)+(i>>2)|0}var OrderedSet=(function(i){function e(t){return t==null?emptyOrderedSet():isOrderedSet(t)?t:emptyOrderedSet().withMutations(function(n){var s=SetCollection(t);assertNotInfinite(s.size),s.forEach(function(o){return n.add(o)})})}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(n){return this(KeyedCollection(n).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e})(Set$1);OrderedSet.isOrderedSet=isOrderedSet;var OrderedSetPrototype=OrderedSet.prototype;OrderedSetPrototype[IS_ORDERED_SYMBOL]=!0,OrderedSetPrototype.zip=IndexedCollectionPrototype.zip,OrderedSetPrototype.zipWith=IndexedCollectionPrototype.zipWith,OrderedSetPrototype.zipAll=IndexedCollectionPrototype.zipAll,OrderedSetPrototype.__empty=emptyOrderedSet,OrderedSetPrototype.__make=makeOrderedSet;function makeOrderedSet(i,e){var t=Object.create(OrderedSetPrototype);return t.size=i?i.size:0,t._map=i,t.__ownerID=e,t}var EMPTY_ORDERED_SET;function emptyOrderedSet(){return EMPTY_ORDERED_SET||(EMPTY_ORDERED_SET=makeOrderedSet(emptyOrderedMap()))}var PairSorting={LeftThenRight:-1,RightThenLeft:1};function throwOnInvalidDefaultValues(i){if(isRecord$2(i))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(isImmutable(i))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(i===null||typeof i!="object")throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}var Record=function(e,t){var n;throwOnInvalidDefaultValues(e);var s=function(l){var c=this;if(l instanceof s)return l;if(!(this instanceof s))return new s(l);if(!n){n=!0;var u=Object.keys(e),h=o._indices={};o._name=t,o._keys=u,o._defaultValues=e;for(var d=0;d<u.length;d++){var p=u[d];h[p]=d,o[p]?typeof console=="object"&&console.warn&&console.warn("Cannot define "+recordName(this)+' with property "'+p+'" since that property name is part of the Record API.'):setProp(o,p)}}return this.__ownerID=void 0,this._values=List().withMutations(function(f){f.setSize(c._keys.length),KeyedCollection(l).forEach(function(g,_){f.set(c._indices[_],g===c._defaultValues[_]?void 0:g)})}),this},o=s.prototype=Object.create(RecordPrototype);return o.constructor=s,t&&(s.displayName=t),s};Record.prototype.toString=function(){for(var e=recordName(this)+" { ",t=this._keys,n,s=0,o=t.length;s!==o;s++)n=t[s],e+=(s?", ":"")+n+": "+quoteString(this.get(n));return e+" }"},Record.prototype.equals=function(e){return this===e||isRecord$2(e)&&recordSeq(this).equals(recordSeq(e))},Record.prototype.hashCode=function(){return recordSeq(this).hashCode()},Record.prototype.has=function(e){return this._indices.hasOwnProperty(e)},Record.prototype.get=function(e,t){if(!this.has(e))return t;var n=this._indices[e],s=this._values.get(n);return s===void 0?this._defaultValues[e]:s},Record.prototype.set=function(e,t){if(this.has(e)){var n=this._values.set(this._indices[e],t===this._defaultValues[e]?void 0:t);if(n!==this._values&&!this.__ownerID)return makeRecord(this,n)}return this},Record.prototype.remove=function(e){return this.set(e)},Record.prototype.clear=function(){var e=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:makeRecord(this,e)},Record.prototype.wasAltered=function(){return this._values.wasAltered()},Record.prototype.toSeq=function(){return recordSeq(this)},Record.prototype.toJS=function(){return toJS(this)},Record.prototype.entries=function(){return this.__iterator(ITERATE_ENTRIES)},Record.prototype.__iterator=function(e,t){return recordSeq(this).__iterator(e,t)},Record.prototype.__iterate=function(e,t){return recordSeq(this).__iterate(e,t)},Record.prototype.__ensureOwner=function(e){if(e===this.__ownerID)return this;var t=this._values.__ensureOwner(e);return e?makeRecord(this,t,e):(this.__ownerID=e,this._values=t,this)},Record.isRecord=isRecord$2,Record.getDescriptiveName=recordName;var RecordPrototype=Record.prototype;RecordPrototype[IS_RECORD_SYMBOL]=!0,RecordPrototype[DELETE]=RecordPrototype.remove,RecordPrototype.deleteIn=RecordPrototype.removeIn=deleteIn,RecordPrototype.getIn=getIn,RecordPrototype.hasIn=CollectionPrototype.hasIn,RecordPrototype.merge=merge$1,RecordPrototype.mergeWith=mergeWith$1,RecordPrototype.mergeIn=mergeIn,RecordPrototype.mergeDeep=mergeDeep,RecordPrototype.mergeDeepWith=mergeDeepWith,RecordPrototype.mergeDeepIn=mergeDeepIn,RecordPrototype.setIn=setIn,RecordPrototype.update=update,RecordPrototype.updateIn=updateIn,RecordPrototype.withMutations=withMutations,RecordPrototype.asMutable=asMutable,RecordPrototype.asImmutable=asImmutable,RecordPrototype[ITERATOR_SYMBOL]=RecordPrototype.entries,RecordPrototype.toJSON=RecordPrototype.toObject=CollectionPrototype.toObject,RecordPrototype.inspect=RecordPrototype.toSource=function(){return this.toString()};function makeRecord(i,e,t){var n=Object.create(Object.getPrototypeOf(i));return n._values=e,n.__ownerID=t,n}function recordName(i){return i.constructor.displayName||i.constructor.name||"Record"}function recordSeq(i){return keyedSeqFromValue(i._keys.map(function(e){return[e,i.get(e)]}))}function setProp(i,e){try{Object.defineProperty(i,e,{get:function(){return this.get(e)},set:function(t){invariant(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch{}}var Repeat=(function(i){function e(t,n){if(!(this instanceof e))return new e(t,n);if(this._value=t,this.size=n===void 0?1/0:Math.max(0,n),this.size===0){if(EMPTY_REPEAT)return EMPTY_REPEAT;EMPTY_REPEAT=this}}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.size===0?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},e.prototype.get=function(n,s){return this.has(n)?this._value:s},e.prototype.includes=function(n){return is(this._value,n)},e.prototype.slice=function(n,s){var o=this.size;return wholeSlice(n,s,o)?this:new e(this._value,resolveEnd(s,o)-resolveBegin(n,o))},e.prototype.reverse=function(){return this},e.prototype.indexOf=function(n){return is(this._value,n)?0:-1},e.prototype.lastIndexOf=function(n){return is(this._value,n)?this.size:-1},e.prototype.__iterate=function(n,s){for(var o=this.size,a=0;a!==o&&n(this._value,s?o-++a:a++,this)!==!1;);return a},e.prototype.__iterator=function(n,s){var o=this,a=this.size,l=0;return new Iterator(function(){return l===a?iteratorDone():iteratorValue(n,s?a-++l:l++,o._value)})},e.prototype.equals=function(n){return n instanceof e?is(this._value,n._value):deepEqual(this,n)},e})(IndexedSeq),EMPTY_REPEAT;function fromJS(i,e){return fromJSWith([],e||defaultConverter,i,"",e&&e.length>2?[]:void 0,{"":i})}function fromJSWith(i,e,t,n,s,o){if(typeof t!="string"&&!isImmutable(t)&&(isArrayLike(t)||hasIterator(t)||isPlainObject(t))){if(~i.indexOf(t))throw new TypeError("Cannot convert circular structure to Immutable");i.push(t),s&&n!==""&&s.push(n);var a=e.call(o,n,Seq(t).map(function(l,c){return fromJSWith(i,e,l,c,s,t)}),s&&s.slice());return i.pop(),s&&s.pop(),a}return t}function defaultConverter(i,e){return isIndexed(e)?e.toList():isKeyed(e)?e.toMap():e.toSet()}var version="5.1.3",Iterable=Collection;const immutable_es=Object.freeze(Object.defineProperty({__proto__:null,Collection,Iterable,List,Map:Map$1,OrderedMap,OrderedSet,PairSorting,Range,Record,Repeat,Seq,Set:Set$1,Stack,fromJS,get,getIn:getIn$1,has:has$1,hasIn:hasIn$1,hash,is,isAssociative,isCollection,isImmutable,isIndexed,isKeyed,isList,isMap:isMap$1,isOrdered,isOrderedMap,isOrderedSet,isPlainObject,isRecord:isRecord$2,isSeq,isSet,isStack,isValueObject,merge,mergeDeep:mergeDeep$1,mergeDeepWith:mergeDeepWith$1,mergeWith,remove,removeIn,set:set$1,setIn:setIn$1,update:update$1,updateIn:updateIn$1,version},Symbol.toStringTag,{value:"Module"})),MODE_IDLE$1="MODE_IDLE",MODE_2D_ZOOM_IN="MODE_2D_ZOOM_IN",MODE_2D_ZOOM_OUT="MODE_2D_ZOOM_OUT",MODE_2D_PAN="MODE_2D_PAN",MODE_3D_VIEW="MODE_3D_VIEW",MODE_3D_FIRST_PERSON="MODE_3D_FIRST_PERSON",MODE_WAITING_DRAWING_LINE="MODE_WAITING_DRAWING_LINE",MODE_WAITING_DRAWING_SURFACE="MODE_WAITING_DRAWING_SURFACE",MODE_WAITING_DRAWING_ROOM="MODE_WAITING_DRAWING_ROOM",MODE_DRAWING_ROOM="MODE_DRAWING_ROOM",MODE_DRAGGING_LINE="MODE_DRAGGING_LINE",MODE_DRAGGING_VERTEX="MODE_DRAGGING_VERTEX",MODE_DRAGGING_ITEM="MODE_DRAGGING_ITEM",MODE_DRAGGING_HOLE="MODE_DRAGGING_HOLE",MODE_DRAWING_LINE="MODE_DRAWING_LINE",MODE_DRAWING_HOLE="MODE_DRAWING_HOLE",MODE_DRAWING_ITEM="MODE_DRAWING_ITEM",MODE_DRAWING_SURFACE="MODE_DRAWING_SURFACE",MODE_ROTATING_ITEM="MODE_ROTATING_ITEM",MODE_RESIZING_ITEM="MODE_RESIZING_ITEM",MODE_UPLOADING_IMAGE="MODE_UPLOADING_IMAGE",MODE_FITTING_IMAGE="MODE_FITTING_IMAGE",MODE_VIEWING_CATALOG="MODE_VIEWING_CATALOG",MODE_CONFIGURING_PROJECT="MODE_CONFIGURING_PROJECT",MODE_SNAPPING=[MODE_IDLE$1,MODE_2D_ZOOM_IN,MODE_2D_ZOOM_OUT,MODE_2D_PAN,MODE_WAITING_DRAWING_LINE,MODE_DRAWING_LINE,MODE_DRAWING_HOLE,MODE_DRAWING_ITEM,MODE_DRAGGING_LINE,MODE_DRAGGING_VERTEX,MODE_DRAGGING_ITEM,MODE_DRAGGING_HOLE,MODE_FITTING_IMAGE,MODE_UPLOADING_IMAGE,MODE_ROTATING_ITEM,MODE_WAITING_DRAWING_ROOM,MODE_DRAWING_ROOM],UNIT_MILLIMETER="mm",UNIT_CENTIMETER="cm",UNIT_METER="m",UNIT_INCH="in",UNIT_FOOT="ft",UNIT_MILE="mi",UNITS_LENGTH=[UNIT_MILLIMETER,UNIT_CENTIMETER,UNIT_METER,UNIT_INCH,UNIT_FOOT,UNIT_MILE],EPSILON$1=1e-6,KEYBOARD_BUTTON_CODE={DELETE:46,BACKSPACE:8,ESC:27,Z:90,ALT:18,C:67,V:86,CTRL:17,ENTER:13,TAB:9},toFixedFloat=(i,e=6)=>i&&e?parseFloat(parseFloat(i.toString()).toFixed(e)):0,fAbs=i=>{let e=i;return e<0&&(e=~e+1),e};function compareVertices(i,e){return i.x===e.x?i.y-e.y:i.x-e.x}function minVertex(i,e){return compareVertices(i,e)>0?e:i}function maxVertex(i,e){return compareVertices(i,e)>0?i:e}function orderVertices(i){return[...i].sort(compareVertices)}function pointsDistance(i,e,t,n){let s=i-t,o=e-n;return Math.sqrt(s*s+o*o)}function verticesDistance(i,e){let{x:t,y:n}=i,{x:s,y:o}=e;return pointsDistance(t,n,s,o)}function horizontalLine(i){return{a:0,b:1,c:-i}}function verticalLine(i){return{a:1,b:0,c:-i}}function distancePointFromLine(i,e,t,n,s){return fAbs(i*n+e*s+t)/Math.sqrt(i*i+e*e)}function closestPointFromLine(i,e,t,n,s){let o=i*i+e*e;return{x:(e*(e*n-i*s)-i*t)/o,y:(i*-e*n+i*s-e*t)/o}}function twoLinesIntersection(i,e,t,n,s,o){let a=e*n-i*s;if(a===0)return;let l=(i*o-t*n)/a;return{x:(t*s-e*o)/a,y:l}}function twoLineSegmentsIntersection(i,e,t,n){let{x:s,y:o}=i,{x:a,y:l}=e,{x:c,y:u}=t,{x:h,y:d}=n,p=(d-u)*(a-s)-(h-c)*(l-o),f=(h-c)*(o-u)-(d-u)*(s-c),g=(a-s)*(o-u)-(l-o)*(s-c);if(fAbs(p)<=EPSILON$1){if(fAbs(f)<=EPSILON$1&&fAbs(g)<=EPSILON$1){let y=(T,I)=>T.x===I.x?T.y-I.y:T.x-I.x,E=[i,e].sort(y),b=[t.toJS(),n.toJS()].sort(y),[v,M]=[E,b].sort((T,I)=>y(T[0],I[0]));return v[1].x===M[0].x?{type:M[0].y<=v[1].y?"colinear":"none"}:{type:M[0].x<=v[1].x?"colinear":"none"}}return{type:"parallel"}}let _=f/p,x=g/p;return _>=0-EPSILON$1&&_<=1+EPSILON$1&&x>=0-EPSILON$1&&x<=1+EPSILON$1?{type:"intersecting",point:{x:s+_*(a-s),y:o+_*(l-o)}}:{type:"none"}}function distancePointFromLineSegment(i,e,t,n,s,o){let a=s-i,l=o-e,c=t-i,u=n-e,h=a*c+l*u,d=c*c+u*u,p=-1;d!=0&&(p=h/d);let f,g;p<0?(f=i,g=e):p>1?(f=t,g=n):(f=i+p*c,g=e+p*u);let _=s-f,x=o-g;return Math.sqrt(_*_+x*x)}function isPointOnLineSegment(i,e,t,n,s,o,a=EPSILON$1){return distancePointFromLineSegment(i,e,t,n,s,o)<=a}function closestPointFromLineSegment(i,e,t,n,s,o){if(i===t)return{x:i,y:o};if(e===n)return{x:s,y:e};let a=(n-e)/(t-i),l=e-a*i,c=-1/a,h=(o-c*s-l)/(a-c),d=a*h+l;return{x:h,y:d}}function pointPositionOnLineSegment(i,e,t,n,s,o){let a=pointsDistance(i,e,t,n),c=pointsDistance(i,e,s,o)/a;return i>t&&(c=mapRange$1(c,0,1,1,0)),c}function mapRange$1(i,e,t,n,s){return n+(s-n)*(i-e)/(t-e)}function angleBetweenTwoPointsAndOrigin(i,e,t,n){return-Math.atan2(e-n,t-i)*180/Math.PI}function angleBetweenTwoPoints(i,e,t,n){return Math.atan2(n-e,t-i)}function absAngleBetweenTwoPoints(i,e,t,n){return Math.atan2(Math.abs(n-e),Math.abs(t-i))}function samePoints({x:i,y:e},{x:t,y:n}){return fAbs(i-t)<=EPSILON$1&&fAbs(e-n)<=EPSILON$1}function extendLine(i,e,t,n,s,o=6){let a=angleBetweenTwoPoints(i,e,t,n);return{x:toFixedFloat(i+Math.cos(a)*s,o),y:toFixedFloat(e+Math.sin(a)*s,o)}}function distanceToSegment(i,e,t,n,s,o){const a=t-i,l=n-e,c=a*a+l*l;if(c===0)return s===i&&o===e?0:Math.hypot(s-i,o-e);const u=((s-i)*a+(o-e)*l)/c;return u<0||u>1?null:Math.abs(a*(o-e)-l*(s-i))/Math.sqrt(c)}function ContainsPoint(i,e,t){const n=i.length>>1;if(n<3)return!1;const s=1e-9;let o=!1;for(let a=0,l=n-1;a<n;l=a++){const c=i[2*l],u=i[2*l+1],h=i[2*a],d=i[2*a+1],p=distanceToSegment(c,u,h,d,e,t);if(p!==null&&p<=s)return!1;u>t!=d>t&&c+(t-u)/(d-u)*(h-c)>e&&(o=!o)}return o}function cosWithThreshold(i,e){let t=Math.cos(i);return t<e?0:t}function sinWithThreshold(i,e){let t=Math.sin(i);return t<e?0:t}function midPoint(i,e,t,n){return{x:(i+t)/2,y:(e+n)/2}}function verticesMidPoint(i){let e=i.reduce((t,n)=>({x:t.x+n.x,y:t.y+n.y}),{x:0,y:0});return{x:e.x/i.length,y:e.y/i.length}}function rotatePointAroundPoint(i,e,t,n,s){let o=s*Math.PI/180,a=Math.cos(o),l=Math.sin(o),c=i-t,u=e-n;return{x:a*c-l*u+t,y:l*c+a*u+n}}const SNAP_POINT="SNAP_POINT",SNAP_LINE="SNAP_LINE",SNAP_SEGMENT="SNAP_SEGMENT",SNAP_GRID="SNAP_GRID",SNAP_GUIDE="SNAP_GUIDE",SNAP_MASK=Map$1({SNAP_POINT:!0,SNAP_LINE:!0,SNAP_SEGMENT:!0,SNAP_GRID:!1,SNAP_GUIDE:!0});class PointSnap extends Record({type:"point",x:-1,y:-1,radius:1,priority:1,related:List()}){nearestPoint(e,t){return{x:this.x,y:this.y,distance:pointsDistance(this.x,this.y,e,t)}}isNear(e,t,n){return~(this.x-e)+1<n&&~(this.y-t)+1<n}}class LineSnap extends Record({type:"line",a:-1,b:-1,c:-1,radius:1,priority:1,related:List()}){nearestPoint(e,t){return{...closestPointFromLine(this.a,this.b,this.c,e,t),distance:distancePointFromLine(this.a,this.b,this.c,e,t)}}isNear(e,t,n){return!0}}class LineSegmentSnap extends Record({type:"line-segment",x1:-1,y1:-1,x2:-1,y2:-1,radius:1,priority:1,related:List()}){nearestPoint(e,t){return{...closestPointFromLineSegment(this.x1,this.y1,this.x2,this.y2,e,t),distance:distancePointFromLineSegment(this.x1,this.y1,this.x2,this.y2,e,t)}}isNear(e,t,n){return!0}}class GridSnap extends Record({type:"grid",x:-1,y:-1,radius:1,priority:1,related:List()}){nearestPoint(e,t){return{x:this.x,y:this.y,distance:pointsDistance(this.x,this.y,e,t)}}isNear(e,t,n){return~(this.x-e)+1<n&&~(this.y-t)+1<n}}function nearestSnap(i,e,t,n){let s={point:n.get(SNAP_POINT),line:n.get(SNAP_LINE),"line-segment":n.get(SNAP_SEGMENT),grid:n.get(SNAP_GRID)};return i.valueSeq().filter(o=>s[o.type]&&o.isNear(e,t,o.radius)).map(o=>({snap:o,point:o.nearestPoint(e,t)})).filter(({snap:{radius:o},point:{distance:a}})=>a<o).min(({snap:{priority:o},point:{distance:a}},{snap:{priority:l},point:{distance:c}})=>o===l?a<c?-1:1:o>l?-1:1)}function addPointSnap(i,e,t,n,s,o){return o=List([o]),i.push(new PointSnap({x:e,y:t,radius:n,priority:s,related:o}))}function addLineSnap(i,e,t,n,s,o,a){return a=List([a]),i.withMutations(l=>{if(l.some(u=>u.type==="line"&&e===u.a&&t===u.b&&n===u.c))return l;l.valueSeq().filter(u=>u.type==="line").map(u=>twoLinesIntersection(u.a,u.b,u.c,e,t,n)).filter(u=>u!==void 0).forEach(({x:u,y:h})=>addPointSnap(l,u,h,20,40)),l.push(new LineSnap({a:e,b:t,c:n,radius:s,priority:o,related:a}))})}function addLineSegmentSnap(i,e,t,n,s,o,a,l){return l=List([l]),i.push(new LineSegmentSnap({x1:e,y1:t,x2:n,y2:s,radius:o,priority:a,related:l}))}function addGridSnap(i,e,t,n,s,o){return o=List([o]),i.push(new GridSnap({x:e,y:t,radius:n,priority:s,related:o}))}let safeLoadMapList=(i,e,t)=>i?Map$1(i).map(n=>new e(n)).toMap():t||Map$1();class Grid extends Record({id:"",type:"",properties:Map$1()},"Grid"){constructor(e={}){super({...e,properties:fromJS(e.properties||{})})}}const DefaultGrids=Map$1({h1:new Grid({id:"h1",type:"horizontal-streak",properties:{step:40,colors:["#ddd","#ddd","#ddd","#ddd"]}}),v1:new Grid({id:"v1",type:"vertical-streak",properties:{step:40,colors:["#ddd","#ddd","#ddd","#ddd"]}})});class ElementsSet extends Record({vertices:List(),lines:List(),holes:List(),areas:List(),items:List()},"ElementsSet"){constructor(e={}){super({vertices:List(e.vertices||[]),lines:List(e.lines||[]),holes:List(e.holes||[]),areas:List(e.areas||[]),items:List(e.items||[])})}}const sharedAttributes={id:"",type:"",prototype:"",name:"",misc:Map$1(),selected:!1,properties:Map$1(),visible:!0};let Vertex$3=class extends Record({...sharedAttributes,x:-1,y:-1,prototype:"vertices",lines:List(),areas:List()},"Vertex"){constructor(e={}){super({...e,lines:List(e.lines||[]),areas:List(e.areas||[])})}},Line$3=class extends Record({...sharedAttributes,prototype:"lines",vertices:List(),holes:List()},"Line"){constructor(e={}){super({...e,properties:fromJS(e.properties||{}),vertices:List(e.vertices||[]),holes:List(e.holes||[])})}},Hole$1=class extends Record({...sharedAttributes,prototype:"holes",offset:-1,line:"",flipAlongWall:!1},"Hole"){constructor(e={}){super({...e,properties:fromJS(e.properties||{})})}},Area$2=class extends Record({...sharedAttributes,prototype:"areas",vertices:List(),holes:List()},"Area"){constructor(e={}){super({...e,properties:fromJS(e.properties||{}),vertices:List(e.vertices||[])})}},Item$2=class extends Record({...sharedAttributes,prototype:"items",x:0,y:0,rotation:0,altitude:0,scale:1,flipHorizontal:!1,flipVertical:!1},"Item"){constructor(e={}){super({...e,properties:fromJS(e.properties||{})})}},Layer$2=class extends Record({id:"",altitude:0,order:0,opacity:1,name:"",visible:!0,vertices:Map$1(),lines:Map$1(),holes:Map$1(),areas:Map$1(),items:Map$1(),selected:new ElementsSet},"Layer"){constructor(e={}){super({...e,vertices:safeLoadMapList(e.vertices,Vertex$3),lines:safeLoadMapList(e.lines,Line$3),holes:safeLoadMapList(e.holes,Hole$1),areas:safeLoadMapList(e.areas,Area$2),items:safeLoadMapList(e.items,Item$2),selected:new ElementsSet(e.selected)})}},Group$3=class extends Record({...sharedAttributes,prototype:"groups",x:0,y:0,rotation:0,elements:Map$1()},"Group"){constructor(e={}){super({...e,properties:fromJS(e.properties||{}),elements:fromJS(e.elements||{})})}};const DefaultLayers=Map$1({"layer-1":new Layer$2({id:"layer-1",name:"default"})});let Scene$3=class extends Record({unit:UNIT_FOOT,layers:Map$1(),grids:Map$1(),selectedLayer:null,groups:Map$1(),width:3e3,height:2e3,meta:Map$1(),guides:Map$1()},"Scene"){constructor(e={}){let t=safeLoadMapList(e.layers,Layer$2,DefaultLayers);super({...e,grids:safeLoadMapList(void 0,Grid,DefaultGrids),layers:t,selectedLayer:t.first().id,groups:safeLoadMapList(e.groups||{},Group$3),meta:e.meta?fromJS(e.meta):Map$1(),guides:e.guides?fromJS(e.guides):Map$1({horizontal:Map$1(),vertical:Map$1(),circular:Map$1()})})}};class CatalogElement extends Record({name:"",prototype:"",info:Map$1(),properties:Map$1(),textures:Map$1()},"CatalogElement"){constructor(e={}){const t=fromJS(e.properties);super({...e,info:fromJS(e.info),properties:Map$1.isMap(t)?t:Map$1(),textures:fromJS(e.textures||{})})}}let Catalog$1=class extends Record({ready:!1,page:"root",path:List(),elements:Map$1()},"Catalog"){constructor(e={}){let t=safeLoadMapList(e.elements,CatalogElement);super({elements:t,ready:!t.isEmpty()})}factoryElement(e,t,n){const s=this.elements.get(e),o=s?s.prototype:t==null?void 0:t.prototype;if(!s&&!o){let l=this.elements.map(c=>c.name).toArray();throw new Error(`Element ${e} does not exist in catalog ${l}`)}const a=s?s.properties.map((l,c)=>n&&n.has(c)?n.get(c):l.get("defaultValue")):n??Map$1();switch(o){case"lines":return new Line$3(t).merge({properties:a});case"holes":return new Hole$1(t).merge({properties:a});case"areas":return new Area$2(t).merge({properties:a});case"items":return new Item$2(t).merge({properties:a});default:throw new Error("prototype not valid")}}};class HistoryStructure extends Record({list:List(),first:null,last:null,redoList:List()},"HistoryStructure"){constructor(e={}){super({list:fromJS(e.list||[]),first:new Scene$3(e.scene),last:new Scene$3(e.last||e.scene)})}}let State$1=class extends Record({mode:MODE_IDLE$1,scene:new Scene$3,sceneHistory:new HistoryStructure,catalog:new Catalog$1,viewer2D:Map$1(),mouse:Map$1({x:0,y:0}),zoom:0,snapMask:SNAP_MASK,snapElements:List(),activeSnapElement:null,drawingSupport:Map$1(),draggingSupport:Map$1(),rotatingSupport:Map$1(),resizingSupport:Map$1(),itemSnapGuides:null,errors:List(),warnings:List(),clipboardProperties:Map$1(),selectedElementsHistory:List(),misc:Map$1(),alterate:!1},"State"){constructor(e={}){super({...e,scene:new Scene$3(e.scene),sceneHistory:new HistoryStructure(e),catalog:new Catalog$1(e.catalog||{}),viewer2D:Map$1(e.viewer2D||{}),drawingSupport:Map$1(e.drawingSupport||{}),draggingSupport:Map$1(e.draggingSupport||{}),rotatingSupport:Map$1(e.rotatingSupport||{}),resizingSupport:Map$1(e.resizingSupport||{}),misc:e.misc?fromJS(e.misc):Map$1()})}};function create_array(i){let e=[];for(let t=0;t<i;++t)e.push([]);return e}class Edge{constructor(e,t){ze(this,"u");ze(this,"v");this.u=e,this.v=t}}class Graph{constructor(e){ze(this,"count");ze(this,"subgraphs");ze(this,"time");ze(this,"V");ze(this,"E");ze(this,"adj");ze(this,"children");this.count=0,this.subgraphs=[],this.time=0,this.children=0,this.V=e,this.E=0,this.adj=[],this.adj=create_array(e)}addEdge(e,t){this.adj[e].push(t),this.E++}_BCCUtil(e,t,n,s,o){t[e]=n[e]=++this.time,this.children=0,this.adj[e].forEach(a=>{if(t[a]==-1){if(this.children++,o[a]=e,s.push(new Edge(e,a)),this._BCCUtil(a,t,n,s,o),n[e]>n[a]&&(n[e]=n[a]),t[e]==1&&this.children>1||t[e]>1&&n[a]>=t[e]){let l=[];for(;s[s.length-1].u!=e||s[s.length-1].v!=a;)l.push(s[s.length-1]),s.splice(s.length-1,1);l.push(s[s.length-1]),this.subgraphs.push(l),l=[],s.splice(s.length-1,1),this.count++}}else a!=o[e]&&t[a]<n[e]&&(n[e]>t[a]&&(n[e]=t[a]),s.push(new Edge(e,a)))})}BCC(){let e=this.V,t=create_array(e),n=create_array(e),s=create_array(e),o=[];for(let a=0;a<e;a++)t[a]=-1,n[a]=-1,s[a]=-1;for(let a=0;a<e;a++){t[a]==-1&&this._BCCUtil(a,t,n,o,s);let l=0,c=[];for(;o.length>0;)l=1,c.push(o[o.length-1]),o.splice(o.length-1,1);l==1&&(this.subgraphs.push(c),c=[],this.count++)}}}const getEdgesOfSubgraphs=(i,e)=>{let t=[];return i.forEach(n=>{t.push([]);let s=getVerticesFromBiconnectedComponent(n);s.forEach(o=>{e.adj[o].forEach(l=>{o<=l&&s.has(l)&&t[t.length-1].push([o,l])})})}),t},getVerticesFromBiconnectedComponent=i=>{let e=new Set;return i.forEach(t=>{e.add(t.u),e.add(t.v)}),e};function sub(i,e){return[i[0]-e[0],i[1]-e[1]]}function mod(i,e){return(i%e+e)%e}function compute_ev_mapping(i){return i.map(function(t){return{ev:t,color:0,direction:-1}})}function compute_angle(i,e){let t=sub(e,i);return Math.atan2(t[1],t[0])}function compute_incidences(i,e){return i.map(function(t,n){let s=[];return e.forEach(function(o,a){let l,c;o[0]===n&&(l=o[1],c=1),o[1]===n&&(l=o[0],c=0),l!==void 0&&s.push({index:a,endpoint:l,angle:compute_angle(t,i[l]),edge:o,position:c})}),s.sort(function(o,a){return a.angle-o.angle}),s})}function get_starting_edge(i,e){let t,n;for(t=0;t<e.length;t+=1)if(e[t].color<2)return n=-1*e[t].direction,color(e,t,n),{edge:t,direction:n,position:n===-1?0:1}}function get_next_edge(i,e,t,n){let s=i[n[e][t]],o=s.length,a,l,c;for(c=0;c<o;c+=1)if(a=s[c],a.index===e)return l=s[mod(c+1,s.length)],{edge:l.index,vertex:l.endpoint,position:l.position,direction:l.position?1:-1}}function color(i,e,t){i[e].color+=1,i[e].direction=t}function find_cycles(i,e){let t=compute_ev_mapping(e),n=compute_incidences(i,e),s=[],o=[],a=[],l,c,u,h,d=get_starting_edge(n,t);for(;d!==void 0;){for(l=[e[d.edge][mod(d.position+1,2)],e[d.edge][d.position]],c=[d.edge],u=[d.direction],h=get_next_edge(n,d.edge,d.position,e);h.edge!==d.edge;)l.push(h.vertex),c.push(h.edge),u.push(h.direction),color(t,h.edge,h.direction),h=get_next_edge(n,h.edge,h.position,e);o.push(c),s.push(l),a.push(u),d=get_starting_edge(n,t)}return{v_cycles:s,e_cycles:o,dir_e_cycles:a,ev_mapping:t}}function find_short_cycles_indexes(i,e){let t=[],n,s,o;for(o=0;o<e.length;o+=1)n=e[o],s=i[o],(n.length<3||s[0]!==s[s.length-1])&&t.push(o);return t}function find_inner_cycles(i,e){let t=find_cycles(i,e),n=t.v_cycles,s=t.e_cycles;find_short_cycles_indexes(n,s).forEach(p=>{n.splice(p,1),s.splice(p,1)});let a=t.dir_e_cycles,c=t.e_cycles.map((p,f)=>p.map(function(g,_){let x,y;return a[f][_]>0?(x=e[g][0],y=e[g][1]):(x=e[g][1],y=e[g][0]),(i[y][0]-i[x][0])*(i[y][1]+i[x][1])})).map(p=>p.reduce((f,g)=>f+g)),u=c.filter(p=>p>0).length,h=c.length-u,d=u>=h?1:-1;return{v_cycles:t.v_cycles.filter((p,f)=>d*c[f]>0),e_cycles:t.e_cycles.filter((p,f)=>d*c[f]>0),ev_mapping:t.ev_mapping}}function calculateInnerCycles(i,e){let t=List();const n=new Graph(i.length);e.forEach(([c,u])=>{n.addEdge(c,u),n.addEdge(u,c)}),n.BCC();const s=n.subgraphs.filter(c=>c.length>=3),o=getEdgesOfSubgraphs(s,n),a=[];return o.forEach(c=>{c.forEach(u=>a.push(u))}),find_inner_cycles(i,a).v_cycles.forEach(c=>{c.shift(),t=t.push(c)}),t}function isClockWiseOrder(i){let e=0,t=0,n=i.size;for(e=0;e<n;e++){let{x:s,y:o}=i.get(e)||{x:0,y:0},{x:a,y:l}=i.get((e+1)%n)||{x:0,y:0};t+=(a-s)*(l+o)}return t>0}function sceneSnapElements(i,e=List(),t=Map$1()){let{width:n,height:s}=i,o,a,l;return e.withMutations(c=>{if(i.layers.forEach(u=>{let{lines:h,vertices:d}=u;d.forEach(({id:p,x:f,y:g})=>{t.get(SNAP_POINT)&&addPointSnap(c,f,g,10,10,p),t.get(SNAP_LINE)&&({a:o,b:a,c:l}=horizontalLine(g),addLineSnap(c,o,a,l,10,1,p),{a:o,b:a,c:l}=verticalLine(f),addLineSnap(c,o,a,l,10,1,p))}),t.get(SNAP_SEGMENT)&&h.forEach(({id:p,vertices:[f,g]})=>{let{x:_,y:x}=d.get(f),{x:y,y:E}=d.get(g);addLineSegmentSnap(c,_,x,y,E,20,1,p)})}),t.get(SNAP_GRID)){let u=5,h=100/u,d=n/h,p=s/h;for(let f=0;f<d;f++){let g=f*h;for(let _=0;_<p;_++){let x=_*h,y=!(f%u),E=!(_%u);addGridSnap(c,g,x,10,y&&E?15:10,null)}}}if(t.get(SNAP_GUIDE)){let u=i.getIn(["guides","horizontal"]),h=i.getIn(["guides","vertical"]),d=u.valueSeq(),p=h.valueSeq();d.forEach(f=>{p.forEach(g=>{addPointSnap(c,g,f,10,10)})}),d.forEach(f=>addLineSegmentSnap(c,0,f,n,f,20,1)),p.forEach(f=>addLineSegmentSnap(c,f,0,f,s,20,1))}})}var immutable$1={exports:{}},immutable=immutable$1.exports,hasRequiredImmutable;function requireImmutable(){return hasRequiredImmutable||(hasRequiredImmutable=1,(function(i,e){(function(t,n){i.exports=n()})(immutable,function(){var t=Array.prototype.slice;function n(m,S){S&&(m.prototype=Object.create(S.prototype)),m.prototype.constructor=m}function s(m){return c(m)?m:V(m)}n(o,s);function o(m){return u(m)?m:pe(m)}n(a,s);function a(m){return h(m)?m:ae(m)}n(l,s);function l(m){return c(m)&&!d(m)?m:Te(m)}function c(m){return!!(m&&m[f])}function u(m){return!!(m&&m[g])}function h(m){return!!(m&&m[_])}function d(m){return u(m)||h(m)}function p(m){return!!(m&&m[x])}s.isIterable=c,s.isKeyed=u,s.isIndexed=h,s.isAssociative=d,s.isOrdered=p,s.Keyed=o,s.Indexed=a,s.Set=l;var f="@@__IMMUTABLE_ITERABLE__@@",g="@@__IMMUTABLE_KEYED__@@",_="@@__IMMUTABLE_INDEXED__@@",x="@@__IMMUTABLE_ORDERED__@@",y="delete",E=5,b=1<<E,v=b-1,M={},T={value:!1},I={value:!1};function w(m){return m.value=!1,m}function R(m){m&&(m.value=!0)}function A(){}function P(m,S){S=S||0;for(var C=Math.max(0,m.length-S),L=new Array(C),O=0;O<C;O++)L[O]=m[O+S];return L}function B(m){return m.size===void 0&&(m.size=m.__iterate(W)),m.size}function k(m,S){if(typeof S!="number"){var C=S>>>0;if(""+C!==S||C===4294967295)return NaN;S=C}return S<0?B(m)+S:S}function W(){return!0}function Y(m,S,C){return(m===0||C!==void 0&&m<=-C)&&(S===void 0||C!==void 0&&S>=C)}function $(m,S){return G(m,S,0)}function ee(m,S){return G(m,S,S)}function G(m,S,C){return m===void 0?C:m<0?Math.max(0,S+m):S===void 0?m:Math.min(S,m)}var K=0,F=1,X=2,se=typeof Symbol=="function"&&Symbol.iterator,me="@@iterator",Me=se||me;function j(m){this.next=m}j.prototype.toString=function(){return"[Iterator]"},j.KEYS=K,j.VALUES=F,j.ENTRIES=X,j.prototype.inspect=j.prototype.toSource=function(){return this.toString()},j.prototype[Me]=function(){return this};function ie(m,S,C,L){var O=m===0?S:m===1?C:[S,C];return L?L.value=O:L={value:O,done:!1},L}function Z(){return{value:void 0,done:!0}}function ue(m){return!!Fe(m)}function be(m){return m&&typeof m.next=="function"}function re(m){var S=Fe(m);return S&&S.call(m)}function Fe(m){var S=m&&(se&&m[se]||m[me]);if(typeof S=="function")return S}function oe(m){return m&&typeof m.length=="number"}n(V,s);function V(m){return m==null?N():c(m)?m.toSeq():Ie(m)}V.of=function(){return V(arguments)},V.prototype.toSeq=function(){return this},V.prototype.toString=function(){return this.__toString("Seq {","}")},V.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},V.prototype.__iterate=function(m,S){return Be(this,m,S,!0)},V.prototype.__iterator=function(m,S){return Le(this,m,S,!0)},n(pe,V);function pe(m){return m==null?N().toKeyedSeq():c(m)?u(m)?m.toSeq():m.fromEntrySeq():ne(m)}pe.prototype.toKeyedSeq=function(){return this},n(ae,V);function ae(m){return m==null?N():c(m)?u(m)?m.entrySeq():m.toIndexedSeq():he(m)}ae.of=function(){return ae(arguments)},ae.prototype.toIndexedSeq=function(){return this},ae.prototype.toString=function(){return this.__toString("Seq [","]")},ae.prototype.__iterate=function(m,S){return Be(this,m,S,!1)},ae.prototype.__iterator=function(m,S){return Le(this,m,S,!1)},n(Te,V);function Te(m){return(m==null?N():c(m)?u(m)?m.entrySeq():m:he(m)).toSetSeq()}Te.of=function(){return Te(arguments)},Te.prototype.toSetSeq=function(){return this},V.isSeq=$e,V.Keyed=pe,V.Set=Te,V.Indexed=ae;var _e="@@__IMMUTABLE_SEQ__@@";V.prototype[_e]=!0,n(ye,ae);function ye(m){this._array=m,this.size=m.length}ye.prototype.get=function(m,S){return this.has(m)?this._array[k(this,m)]:S},ye.prototype.__iterate=function(m,S){for(var C=this._array,L=C.length-1,O=0;O<=L;O++)if(m(C[S?L-O:O],O,this)===!1)return O+1;return O},ye.prototype.__iterator=function(m,S){var C=this._array,L=C.length-1,O=0;return new j(function(){return O>L?Z():ie(m,O,C[S?L-O++:O++])})},n(Se,pe);function Se(m){var S=Object.keys(m);this._object=m,this._keys=S,this.size=S.length}Se.prototype.get=function(m,S){return S!==void 0&&!this.has(m)?S:this._object[m]},Se.prototype.has=function(m){return this._object.hasOwnProperty(m)},Se.prototype.__iterate=function(m,S){for(var C=this._object,L=this._keys,O=L.length-1,q=0;q<=O;q++){var z=L[S?O-q:q];if(m(C[z],z,this)===!1)return q+1}return q},Se.prototype.__iterator=function(m,S){var C=this._object,L=this._keys,O=L.length-1,q=0;return new j(function(){var z=L[S?O-q:q];return q++>O?Z():ie(m,z,C[z])})},Se.prototype[x]=!0,n(Ae,ae);function Ae(m){this._iterable=m,this.size=m.length||m.size}Ae.prototype.__iterateUncached=function(m,S){if(S)return this.cacheResult().__iterate(m,S);var C=this._iterable,L=re(C),O=0;if(be(L))for(var q;!(q=L.next()).done&&m(q.value,O++,this)!==!1;);return O},Ae.prototype.__iteratorUncached=function(m,S){if(S)return this.cacheResult().__iterator(m,S);var C=this._iterable,L=re(C);if(!be(L))return new j(Z);var O=0;return new j(function(){var q=L.next();return q.done?q:ie(m,O++,q.value)})},n(qe,ae);function qe(m){this._iterator=m,this._iteratorCache=[]}qe.prototype.__iterateUncached=function(m,S){if(S)return this.cacheResult().__iterate(m,S);for(var C=this._iterator,L=this._iteratorCache,O=0;O<L.length;)if(m(L[O],O++,this)===!1)return O;for(var q;!(q=C.next()).done;){var z=q.value;if(L[O]=z,m(z,O++,this)===!1)break}return O},qe.prototype.__iteratorUncached=function(m,S){if(S)return this.cacheResult().__iterator(m,S);var C=this._iterator,L=this._iteratorCache,O=0;return new j(function(){if(O>=L.length){var q=C.next();if(q.done)return q;L[O]=q.value}return ie(m,O,L[O++])})};function $e(m){return!!(m&&m[_e])}var U;function N(){return U||(U=new ye([]))}function ne(m){var S=Array.isArray(m)?new ye(m).fromEntrySeq():be(m)?new qe(m).fromEntrySeq():ue(m)?new Ae(m).fromEntrySeq():typeof m=="object"?new Se(m):void 0;if(!S)throw new TypeError("Expected Array or iterable object of [k, v] entries, or keyed object: "+m);return S}function he(m){var S=fe(m);if(!S)throw new TypeError("Expected Array or iterable object of values: "+m);return S}function Ie(m){var S=fe(m)||typeof m=="object"&&new Se(m);if(!S)throw new TypeError("Expected Array or iterable object of values, or keyed object: "+m);return S}function fe(m){return oe(m)?new ye(m):be(m)?new qe(m):ue(m)?new Ae(m):void 0}function Be(m,S,C,L){var O=m._cache;if(O){for(var q=O.length-1,z=0;z<=q;z++){var J=O[C?q-z:z];if(S(J[1],L?J[0]:z,m)===!1)return z+1}return z}return m.__iterateUncached(S,C)}function Le(m,S,C,L){var O=m._cache;if(O){var q=O.length-1,z=0;return new j(function(){var J=O[C?q-z:z];return z++>q?Z():ie(S,L?J[0]:z-1,J[1])})}return m.__iteratorUncached(S,C)}function je(m,S){return S?Ve(S,m,"",{"":m}):Oe(m)}function Ve(m,S,C,L){return Array.isArray(S)?m.call(L,C,ae(S).map(function(O,q){return Ve(m,O,q,S)})):ve(S)?m.call(L,C,pe(S).map(function(O,q){return Ve(m,O,q,S)})):S}function Oe(m){return Array.isArray(m)?ae(m).map(Oe).toList():ve(m)?pe(m).map(Oe).toMap():m}function ve(m){return m&&(m.constructor===Object||m.constructor===void 0)}function Ne(m,S){if(m===S||m!==m&&S!==S)return!0;if(!m||!S)return!1;if(typeof m.valueOf=="function"&&typeof S.valueOf=="function"){if(m=m.valueOf(),S=S.valueOf(),m===S||m!==m&&S!==S)return!0;if(!m||!S)return!1}return!!(typeof m.equals=="function"&&typeof S.equals=="function"&&m.equals(S))}function Ce(m,S){if(m===S)return!0;if(!c(S)||m.size!==void 0&&S.size!==void 0&&m.size!==S.size||m.__hash!==void 0&&S.__hash!==void 0&&m.__hash!==S.__hash||u(m)!==u(S)||h(m)!==h(S)||p(m)!==p(S))return!1;if(m.size===0&&S.size===0)return!0;var C=!d(m);if(p(m)){var L=m.entries();return S.every(function(de,ge){var we=L.next().value;return we&&Ne(we[1],de)&&(C||Ne(we[0],ge))})&&L.next().done}var O=!1;if(m.size===void 0)if(S.size===void 0)typeof m.cacheResult=="function"&&m.cacheResult();else{O=!0;var q=m;m=S,S=q}var z=!0,J=S.__iterate(function(de,ge){if(C?!m.has(de):O?!Ne(de,m.get(ge,M)):!Ne(m.get(ge,M),de))return z=!1,!1});return z&&m.size===J}n(xe,ae);function xe(m,S){if(!(this instanceof xe))return new xe(m,S);if(this._value=m,this.size=S===void 0?1/0:Math.max(0,S),this.size===0){if(We)return We;We=this}}xe.prototype.toString=function(){return this.size===0?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},xe.prototype.get=function(m,S){return this.has(m)?this._value:S},xe.prototype.includes=function(m){return Ne(this._value,m)},xe.prototype.slice=function(m,S){var C=this.size;return Y(m,S,C)?this:new xe(this._value,ee(S,C)-$(m,C))},xe.prototype.reverse=function(){return this},xe.prototype.indexOf=function(m){return Ne(this._value,m)?0:-1},xe.prototype.lastIndexOf=function(m){return Ne(this._value,m)?this.size:-1},xe.prototype.__iterate=function(m,S){for(var C=0;C<this.size;C++)if(m(this._value,C,this)===!1)return C+1;return C},xe.prototype.__iterator=function(m,S){var C=this,L=0;return new j(function(){return L<C.size?ie(m,L++,C._value):Z()})},xe.prototype.equals=function(m){return m instanceof xe?Ne(this._value,m._value):Ce(m)};var We;function H(m,S){if(!m)throw new Error(S)}n(Ee,ae);function Ee(m,S,C){if(!(this instanceof Ee))return new Ee(m,S,C);if(H(C!==0,"Cannot step a Range by 0"),m=m||0,S===void 0&&(S=1/0),C=C===void 0?1:Math.abs(C),S<m&&(C=-C),this._start=m,this._end=S,this._step=C,this.size=Math.max(0,Math.ceil((S-m)/C-1)+1),this.size===0){if(ke)return ke;ke=this}}Ee.prototype.toString=function(){return this.size===0?"Range []":"Range [ "+this._start+"..."+this._end+(this._step!==1?" by "+this._step:"")+" ]"},Ee.prototype.get=function(m,S){return this.has(m)?this._start+k(this,m)*this._step:S},Ee.prototype.includes=function(m){var S=(m-this._start)/this._step;return S>=0&&S<this.size&&S===Math.floor(S)},Ee.prototype.slice=function(m,S){return Y(m,S,this.size)?this:(m=$(m,this.size),S=ee(S,this.size),S<=m?new Ee(0,0):new Ee(this.get(m,this._end),this.get(S,this._end),this._step))},Ee.prototype.indexOf=function(m){var S=m-this._start;if(S%this._step===0){var C=S/this._step;if(C>=0&&C<this.size)return C}return-1},Ee.prototype.lastIndexOf=function(m){return this.indexOf(m)},Ee.prototype.__iterate=function(m,S){for(var C=this.size-1,L=this._step,O=S?this._start+C*L:this._start,q=0;q<=C;q++){if(m(O,q,this)===!1)return q+1;O+=S?-L:L}return q},Ee.prototype.__iterator=function(m,S){var C=this.size-1,L=this._step,O=S?this._start+C*L:this._start,q=0;return new j(function(){var z=O;return O+=S?-L:L,q>C?Z():ie(m,q++,z)})},Ee.prototype.equals=function(m){return m instanceof Ee?this._start===m._start&&this._end===m._end&&this._step===m._step:Ce(this,m)};var ke;n(Ge,s);function Ge(){throw TypeError("Abstract")}n(De,Ge);function De(){}n(Re,Ge);function Re(){}n(Ye,Ge);function Ye(){}Ge.Keyed=De,Ge.Indexed=Re,Ge.Set=Ye;var nt=typeof Math.imul=="function"&&Math.imul(4294967295,2)===-2?Math.imul:function(S,C){S=S|0,C=C|0;var L=S&65535,O=C&65535;return L*O+((S>>>16)*O+L*(C>>>16)<<16>>>0)|0};function ut(m){return m>>>1&1073741824|m&3221225471}function rt(m){if(m===!1||m===null||m===void 0||typeof m.valueOf=="function"&&(m=m.valueOf(),m===!1||m===null||m===void 0))return 0;if(m===!0)return 1;var S=typeof m;if(S==="number"){if(m!==m||m===1/0)return 0;var C=m|0;for(C!==m&&(C^=m*4294967295);m>4294967295;)m/=4294967295,C^=m;return ut(C)}if(S==="string")return m.length>xn?Bt(m):Pt(m);if(typeof m.hashCode=="function")return m.hashCode();if(S==="object")return gn(m);if(typeof m.toString=="function")return Pt(m.toString());throw new Error("Value type "+S+" cannot be hashed.")}function Bt(m){var S=ln[m];return S===void 0&&(S=Pt(m),an===yn&&(an=0,ln={}),an++,ln[m]=S),S}function Pt(m){for(var S=0,C=0;C<m.length;C++)S=31*S+m.charCodeAt(C)|0;return ut(S)}function gn(m){var S;if(Jt&&(S=Wt.get(m),S!==void 0)||(S=m[Ft],S!==void 0)||!Zt&&(S=m.propertyIsEnumerable&&m.propertyIsEnumerable[Ft],S!==void 0||(S=_n(m),S!==void 0)))return S;if(S=++Qt,Qt&1073741824&&(Qt=0),Jt)Wt.set(m,S);else{if(qt!==void 0&&qt(m)===!1)throw new Error("Non-extensible objects are not allowed as keys.");if(Zt)Object.defineProperty(m,Ft,{enumerable:!1,configurable:!1,writable:!1,value:S});else if(m.propertyIsEnumerable!==void 0&&m.propertyIsEnumerable===m.constructor.prototype.propertyIsEnumerable)m.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},m.propertyIsEnumerable[Ft]=S;else if(m.nodeType!==void 0)m[Ft]=S;else throw new Error("Unable to set a non-enumerable property on object.")}return S}var qt=Object.isExtensible,Zt=(function(){try{return Object.defineProperty({},"@",{}),!0}catch{return!1}})();function _n(m){if(m&&m.nodeType>0)switch(m.nodeType){case 1:return m.uniqueID;case 9:return m.documentElement&&m.documentElement.uniqueID}}var Jt=typeof WeakMap=="function",Wt;Jt&&(Wt=new WeakMap);var Qt=0,Ft="__immutablehash__";typeof Symbol=="function"&&(Ft=Symbol(Ft));var xn=16,yn=255,an=0,ln={};function wt(m){H(m!==1/0,"Cannot perform this action with an infinite size.")}n(lt,De);function lt(m){return m==null?Ze():un(m)&&!p(m)?m:Ze().withMutations(function(S){var C=o(m);wt(C.size),C.forEach(function(L,O){return S.set(O,L)})})}lt.of=function(){var m=t.call(arguments,0);return Ze().withMutations(function(S){for(var C=0;C<m.length;C+=2){if(C+1>=m.length)throw new Error("Missing value for key: "+m[C]);S.set(m[C],m[C+1])}})},lt.prototype.toString=function(){return this.__toString("Map {","}")},lt.prototype.get=function(m,S){return this._root?this._root.get(0,void 0,m,S):S},lt.prototype.set=function(m,S){return st(this,m,S)},lt.prototype.setIn=function(m,S){return this.updateIn(m,M,function(){return S})},lt.prototype.remove=function(m){return st(this,m,M)},lt.prototype.deleteIn=function(m){return this.updateIn(m,function(){return M})},lt.prototype.update=function(m,S,C){return arguments.length===1?m(this):this.updateIn([m],S,C)},lt.prototype.updateIn=function(m,S,C){C||(C=S,S=void 0);var L=Xt(this,or(m),S,C);return L===M?void 0:L},lt.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Ze()},lt.prototype.merge=function(){return at(this,void 0,arguments)},lt.prototype.mergeWith=function(m){var S=t.call(arguments,1);return at(this,m,S)},lt.prototype.mergeIn=function(m){var S=t.call(arguments,1);return this.updateIn(m,Ze(),function(C){return typeof C.merge=="function"?C.merge.apply(C,S):S[S.length-1]})},lt.prototype.mergeDeep=function(){return at(this,Mt,arguments)},lt.prototype.mergeDeepWith=function(m){var S=t.call(arguments,1);return at(this,Ht(m),S)},lt.prototype.mergeDeepIn=function(m){var S=t.call(arguments,1);return this.updateIn(m,Ze(),function(C){return typeof C.mergeDeep=="function"?C.mergeDeep.apply(C,S):S[S.length-1]})},lt.prototype.sort=function(m){return vt(sn(this,m))},lt.prototype.sortBy=function(m,S){return vt(sn(this,S,m))},lt.prototype.withMutations=function(m){var S=this.asMutable();return m(S),S.wasAltered()?S.__ensureOwner(this.__ownerID):this},lt.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new A)},lt.prototype.asImmutable=function(){return this.__ensureOwner()},lt.prototype.wasAltered=function(){return this.__altered},lt.prototype.__iterator=function(m,S){return new Ue(this,m,S)},lt.prototype.__iterate=function(m,S){var C=this,L=0;return this._root&&this._root.iterate(function(O){return L++,m(O[1],O[0],C)},S),L},lt.prototype.__ensureOwner=function(m){return m===this.__ownerID?this:m?Qe(this.size,this._root,m,this.__hash):(this.__ownerID=m,this.__altered=!1,this)};function un(m){return!!(m&&m[vn])}lt.isMap=un;var vn="@@__IMMUTABLE_MAP__@@",D=lt.prototype;D[vn]=!0,D[y]=D.remove,D.removeIn=D.deleteIn;function Q(m,S){this.ownerID=m,this.entries=S}Q.prototype.get=function(m,S,C,L){for(var O=this.entries,q=0,z=O.length;q<z;q++)if(Ne(C,O[q][0]))return O[q][1];return L},Q.prototype.update=function(m,S,C,L,O,q,z){for(var J=O===M,de=this.entries,ge=0,we=de.length;ge<we&&!Ne(L,de[ge][0]);ge++);var He=ge<we;if(He?de[ge][1]===O:J)return this;if(R(z),(J||!He)&&R(q),!(J&&de.length===1)){if(!He&&!J&&de.length>=Rt)return dt(m,de,L,O);var Je=m&&m===this.ownerID,it=Je?de:P(de);return He?J?ge===we-1?it.pop():it[ge]=it.pop():it[ge]=[L,O]:it.push([L,O]),Je?(this.entries=it,this):new Q(m,it)}};function le(m,S,C){this.ownerID=m,this.bitmap=S,this.nodes=C}le.prototype.get=function(m,S,C,L){S===void 0&&(S=rt(C));var O=1<<((m===0?S:S>>>m)&v),q=this.bitmap;return(q&O)===0?L:this.nodes[ft(q&O-1)].get(m+E,S,C,L)},le.prototype.update=function(m,S,C,L,O,q,z){C===void 0&&(C=rt(L));var J=(S===0?C:C>>>S)&v,de=1<<J,ge=this.bitmap,we=(ge&de)!==0;if(!we&&O===M)return this;var He=ft(ge&de-1),Je=this.nodes,it=we?Je[He]:void 0,ot=ct(it,m,S+E,C,L,O,q,z);if(ot===it)return this;if(!we&&ot&&Je.length>=hn)return gt(m,Je,ge,J,ot);if(we&&!ot&&Je.length===2&&mt(Je[He^1]))return Je[He^1];if(we&&ot&&Je.length===1&&mt(ot))return ot;var yt=m&&m===this.ownerID,Ut=we?ot?ge:ge^de:ge|de,jt=we?ot?At(Je,He,ot,yt):Et(Je,He,yt):Lt(Je,He,ot,yt);return yt?(this.bitmap=Ut,this.nodes=jt,this):new le(m,Ut,jt)};function ce(m,S,C){this.ownerID=m,this.count=S,this.nodes=C}ce.prototype.get=function(m,S,C,L){S===void 0&&(S=rt(C));var O=(m===0?S:S>>>m)&v,q=this.nodes[O];return q?q.get(m+E,S,C,L):L},ce.prototype.update=function(m,S,C,L,O,q,z){C===void 0&&(C=rt(L));var J=(S===0?C:C>>>S)&v,de=O===M,ge=this.nodes,we=ge[J];if(de&&!we)return this;var He=ct(we,m,S+E,C,L,O,q,z);if(He===we)return this;var Je=this.count;if(!we)Je++;else if(!He&&(Je--,Je<$t))return et(m,ge,Je,J);var it=m&&m===this.ownerID,ot=At(ge,J,He,it);return it?(this.count=Je,this.nodes=ot,this):new ce(m,Je,ot)};function te(m,S,C){this.ownerID=m,this.keyHash=S,this.entries=C}te.prototype.get=function(m,S,C,L){for(var O=this.entries,q=0,z=O.length;q<z;q++)if(Ne(C,O[q][0]))return O[q][1];return L},te.prototype.update=function(m,S,C,L,O,q,z){C===void 0&&(C=rt(L));var J=O===M;if(C!==this.keyHash)return J?this:(R(z),R(q),ht(this,m,S,C,[L,O]));for(var de=this.entries,ge=0,we=de.length;ge<we&&!Ne(L,de[ge][0]);ge++);var He=ge<we;if(He?de[ge][1]===O:J)return this;if(R(z),(J||!He)&&R(q),J&&we===2)return new Pe(m,this.keyHash,de[ge^1]);var Je=m&&m===this.ownerID,it=Je?de:P(de);return He?J?ge===we-1?it.pop():it[ge]=it.pop():it[ge]=[L,O]:it.push([L,O]),Je?(this.entries=it,this):new te(m,this.keyHash,it)};function Pe(m,S,C){this.ownerID=m,this.keyHash=S,this.entry=C}Pe.prototype.get=function(m,S,C,L){return Ne(C,this.entry[0])?this.entry[1]:L},Pe.prototype.update=function(m,S,C,L,O,q,z){var J=O===M,de=Ne(L,this.entry[0]);if(de?O===this.entry[1]:J)return this;if(R(z),J){R(q);return}return de?m&&m===this.ownerID?(this.entry[1]=O,this):new Pe(m,this.keyHash,[L,O]):(R(q),ht(this,m,S,rt(L),[L,O]))},Q.prototype.iterate=te.prototype.iterate=function(m,S){for(var C=this.entries,L=0,O=C.length-1;L<=O;L++)if(m(C[S?O-L:L])===!1)return!1},le.prototype.iterate=ce.prototype.iterate=function(m,S){for(var C=this.nodes,L=0,O=C.length-1;L<=O;L++){var q=C[S?O-L:L];if(q&&q.iterate(m,S)===!1)return!1}},Pe.prototype.iterate=function(m,S){return m(this.entry)},n(Ue,j);function Ue(m,S,C){this._type=S,this._reverse=C,this._stack=m._root&&Xe(m._root)}Ue.prototype.next=function(){for(var m=this._type,S=this._stack;S;){var C=S.node,L=S.index++,O;if(C.entry){if(L===0)return Ke(m,C.entry)}else if(C.entries){if(O=C.entries.length-1,L<=O)return Ke(m,C.entries[this._reverse?O-L:L])}else if(O=C.nodes.length-1,L<=O){var q=C.nodes[this._reverse?O-L:L];if(q){if(q.entry)return Ke(m,q.entry);S=this._stack=Xe(q,S)}continue}S=this._stack=this._stack.__prev}return Z()};function Ke(m,S){return ie(m,S[0],S[1])}function Xe(m,S){return{node:m,index:0,__prev:S}}function Qe(m,S,C,L){var O=Object.create(D);return O.size=m,O._root=S,O.__ownerID=C,O.__hash=L,O.__altered=!1,O}var tt;function Ze(){return tt||(tt=Qe(0))}function st(m,S,C){var L,O;if(m._root){var q=w(T),z=w(I);if(L=ct(m._root,m.__ownerID,0,void 0,S,C,q,z),!z.value)return m;O=m.size+(q.value?C===M?-1:1:0)}else{if(C===M)return m;O=1,L=new Q(m.__ownerID,[[S,C]])}return m.__ownerID?(m.size=O,m._root=L,m.__hash=void 0,m.__altered=!0,m):L?Qe(O,L):Ze()}function ct(m,S,C,L,O,q,z,J){return m?m.update(S,C,L,O,q,z,J):q===M?m:(R(J),R(z),new Pe(S,L,[O,q]))}function mt(m){return m.constructor===Pe||m.constructor===te}function ht(m,S,C,L,O){if(m.keyHash===L)return new te(S,L,[m.entry,O]);var q=(C===0?m.keyHash:m.keyHash>>>C)&v,z=(C===0?L:L>>>C)&v,J,de=q===z?[ht(m,S,C+E,L,O)]:(J=new Pe(S,L,O),q<z?[m,J]:[J,m]);return new le(S,1<<q|1<<z,de)}function dt(m,S,C,L){m||(m=new A);for(var O=new Pe(m,rt(C),[C,L]),q=0;q<S.length;q++){var z=S[q];O=O.update(m,0,void 0,z[0],z[1])}return O}function et(m,S,C,L){for(var O=0,q=0,z=new Array(C),J=0,de=1,ge=S.length;J<ge;J++,de<<=1){var we=S[J];we!==void 0&&J!==L&&(O|=de,z[q++]=we)}return new le(m,O,z)}function gt(m,S,C,L,O){for(var q=0,z=new Array(b),J=0;C!==0;J++,C>>>=1)z[J]=C&1?S[q++]:void 0;return z[L]=O,new ce(m,q+1,z)}function at(m,S,C){for(var L=[],O=0;O<C.length;O++){var q=C[O],z=o(q);c(q)||(z=z.map(function(J){return je(J)})),L.push(z)}return Tt(m,S,L)}function Mt(m,S,C){return m&&m.mergeDeep&&c(S)?m.mergeDeep(S):Ne(m,S)?m:S}function Ht(m){return function(S,C,L){if(S&&S.mergeDeepWith&&c(C))return S.mergeDeepWith(m,C);var O=m(S,C,L);return Ne(S,O)?S:O}}function Tt(m,S,C){return C=C.filter(function(L){return L.size!==0}),C.length===0?m:m.size===0&&!m.__ownerID&&C.length===1?m.constructor(C[0]):m.withMutations(function(L){for(var O=S?function(z,J){L.update(J,M,function(de){return de===M?z:S(de,z,J)})}:function(z,J){L.set(J,z)},q=0;q<C.length;q++)C[q].forEach(O)})}function Xt(m,S,C,L){var O=m===M,q=S.next();if(q.done){var z=O?C:m,J=L(z);return J===z?m:J}H(O||m&&m.set,"invalid keyPath");var de=q.value,ge=O?M:m.get(de,M),we=Xt(ge,S,C,L);return we===ge?m:we===M?m.remove(de):(O?Ze():m).set(de,we)}function ft(m){return m=m-(m>>1&1431655765),m=(m&858993459)+(m>>2&858993459),m=m+(m>>4)&252645135,m=m+(m>>8),m=m+(m>>16),m&127}function At(m,S,C,L){var O=L?m:P(m);return O[S]=C,O}function Lt(m,S,C,L){var O=m.length+1;if(L&&S+1===O)return m[S]=C,m;for(var q=new Array(O),z=0,J=0;J<O;J++)J===S?(q[J]=C,z=-1):q[J]=m[J+z];return q}function Et(m,S,C){var L=m.length-1;if(C&&S===L)return m.pop(),m;for(var O=new Array(L),q=0,z=0;z<L;z++)z===S&&(q=1),O[z]=m[z+q];return O}var Rt=b/4,hn=b/2,$t=b/4;n(_t,Re);function _t(m){var S=Cn();if(m==null)return S;if(Gn(m))return m;var C=a(m),L=C.size;return L===0?S:(wt(L),L>0&&L<b?pn(0,L,E,null,new Yt(C.toArray())):S.withMutations(function(O){O.setSize(L),C.forEach(function(q,z){return O.set(z,q)})}))}_t.of=function(){return this(arguments)},_t.prototype.toString=function(){return this.__toString("List [","]")},_t.prototype.get=function(m,S){if(m=k(this,m),m>=0&&m<this.size){m+=this._origin;var C=$n(this,m);return C&&C.array[m&v]}return S},_t.prototype.set=function(m,S){return br(this,m,S)},_t.prototype.remove=function(m){return this.has(m)?m===0?this.shift():m===this.size-1?this.pop():this.splice(m,1):this},_t.prototype.insert=function(m,S){return this.splice(m,0,S)},_t.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=E,this._root=this._tail=null,this.__hash=void 0,this.__altered=!0,this):Cn()},_t.prototype.push=function(){var m=arguments,S=this.size;return this.withMutations(function(C){Kt(C,0,S+m.length);for(var L=0;L<m.length;L++)C.set(S+L,m[L])})},_t.prototype.pop=function(){return Kt(this,0,-1)},_t.prototype.unshift=function(){var m=arguments;return this.withMutations(function(S){Kt(S,-m.length);for(var C=0;C<m.length;C++)S.set(C,m[C])})},_t.prototype.shift=function(){return Kt(this,1)},_t.prototype.merge=function(){return Sn(this,void 0,arguments)},_t.prototype.mergeWith=function(m){var S=t.call(arguments,1);return Sn(this,m,S)},_t.prototype.mergeDeep=function(){return Sn(this,Mt,arguments)},_t.prototype.mergeDeepWith=function(m){var S=t.call(arguments,1);return Sn(this,Ht(m),S)},_t.prototype.setSize=function(m){return Kt(this,0,m)},_t.prototype.slice=function(m,S){var C=this.size;return Y(m,S,C)?this:Kt(this,$(m,C),ee(S,C))},_t.prototype.__iterator=function(m,S){var C=0,L=jn(this,S);return new j(function(){var O=L();return O===dn?Z():ie(m,C++,O)})},_t.prototype.__iterate=function(m,S){for(var C=0,L=jn(this,S),O;(O=L())!==dn&&m(O,C++,this)!==!1;);return C},_t.prototype.__ensureOwner=function(m){return m===this.__ownerID?this:m?pn(this._origin,this._capacity,this._level,this._root,this._tail,m,this.__hash):(this.__ownerID=m,this)};function Gn(m){return!!(m&&m[zn])}_t.isList=Gn;var zn="@@__IMMUTABLE_LIST__@@",It=_t.prototype;It[zn]=!0,It[y]=It.remove,It.setIn=D.setIn,It.deleteIn=It.removeIn=D.removeIn,It.update=D.update,It.updateIn=D.updateIn,It.mergeIn=D.mergeIn,It.mergeDeepIn=D.mergeDeepIn,It.withMutations=D.withMutations,It.asMutable=D.asMutable,It.asImmutable=D.asImmutable,It.wasAltered=D.wasAltered;function Yt(m,S){this.array=m,this.ownerID=S}Yt.prototype.removeBefore=function(m,S,C){if(C===S?1<<S:this.array.length===0)return this;var L=C>>>S&v;if(L>=this.array.length)return new Yt([],m);var O=L===0,q;if(S>0){var z=this.array[L];if(q=z&&z.removeBefore(m,S-E,C),q===z&&O)return this}if(O&&!q)return this;var J=en(this,m);if(!O)for(var de=0;de<L;de++)J.array[de]=void 0;return q&&(J.array[L]=q),J},Yt.prototype.removeAfter=function(m,S,C){if(C===(S?1<<S:0)||this.array.length===0)return this;var L=C-1>>>S&v;if(L>=this.array.length)return this;var O;if(S>0){var q=this.array[L];if(O=q&&q.removeAfter(m,S-E,C),O===q&&L===this.array.length-1)return this}var z=en(this,m);return z.array.splice(L+1),O&&(z.array[L]=O),z};var dn={};function jn(m,S){var C=m._origin,L=m._capacity,O=fn(L),q=m._tail;return z(m._root,m._level,0);function z(ge,we,He){return we===0?J(ge,He):de(ge,we,He)}function J(ge,we){var He=we===O?q&&q.array:ge&&ge.array,Je=we>C?0:C-we,it=L-we;return it>b&&(it=b),function(){if(Je===it)return dn;var ot=S?--it:Je++;return He&&He[ot]}}function de(ge,we,He){var Je,it=ge&&ge.array,ot=He>C?0:C-He>>we,yt=(L-He>>we)+1;return yt>b&&(yt=b),function(){do{if(Je){var Ut=Je();if(Ut!==dn)return Ut;Je=null}if(ot===yt)return dn;var jt=S?--yt:ot++;Je=z(it&&it[jt],we-E,He+(jt<<we))}while(!0)}}}function pn(m,S,C,L,O,q,z){var J=Object.create(It);return J.size=S-m,J._origin=m,J._capacity=S,J._level=C,J._root=L,J._tail=O,J.__ownerID=q,J.__hash=z,J.__altered=!1,J}var Hn;function Cn(){return Hn||(Hn=pn(0,0,E))}function br(m,S,C){if(S=k(m,S),S!==S)return m;if(S>=m.size||S<0)return m.withMutations(function(z){S<0?Kt(z,S).set(0,C):Kt(z,0,S+1).set(S,C)});S+=m._origin;var L=m._tail,O=m._root,q=w(I);return S>=fn(m._capacity)?L=Pn(L,m.__ownerID,0,S,C,q):O=Pn(O,m.__ownerID,m._level,S,C,q),q.value?m.__ownerID?(m._root=O,m._tail=L,m.__hash=void 0,m.__altered=!0,m):pn(m._origin,m._capacity,m._level,O,L):m}function Pn(m,S,C,L,O,q){var z=L>>>C&v,J=m&&z<m.array.length;if(!J&&O===void 0)return m;var de;if(C>0){var ge=m&&m.array[z],we=Pn(ge,S,C-E,L,O,q);return we===ge?m:(de=en(m,S),de.array[z]=we,de)}return J&&m.array[z]===O?m:(R(q),de=en(m,S),O===void 0&&z===de.array.length-1?de.array.pop():de.array[z]=O,de)}function en(m,S){return S&&m&&S===m.ownerID?m:new Yt(m?m.array.slice():[],S)}function $n(m,S){if(S>=fn(m._capacity))return m._tail;if(S<1<<m._level+E){for(var C=m._root,L=m._level;C&&L>0;)C=C.array[S>>>L&v],L-=E;return C}}function Kt(m,S,C){S!==void 0&&(S=S|0),C!==void 0&&(C=C|0);var L=m.__ownerID||new A,O=m._origin,q=m._capacity,z=O+S,J=C===void 0?q:C<0?q+C:O+C;if(z===O&&J===q)return m;if(z>=J)return m.clear();for(var de=m._level,ge=m._root,we=0;z+we<0;)ge=new Yt(ge&&ge.array.length?[void 0,ge]:[],L),de+=E,we+=1<<de;we&&(z+=we,O+=we,J+=we,q+=we);for(var He=fn(q),Je=fn(J);Je>=1<<de+E;)ge=new Yt(ge&&ge.array.length?[ge]:[],L),de+=E;var it=m._tail,ot=Je<He?$n(m,J-1):Je>He?new Yt([],L):it;if(it&&Je>He&&z<q&&it.array.length){ge=en(ge,L);for(var yt=ge,Ut=de;Ut>E;Ut-=E){var jt=He>>>Ut&v;yt=yt.array[jt]=en(yt.array[jt],L)}yt.array[He>>>E&v]=it}if(J<q&&(ot=ot&&ot.removeAfter(L,0,J)),z>=Je)z-=Je,J-=Je,de=E,ge=null,ot=ot&&ot.removeBefore(L,0,z);else if(z>O||Je<He){for(we=0;ge;){var An=z>>>de&v;if(An!==Je>>>de&v)break;An&&(we+=(1<<de)*An),de-=E,ge=ge.array[An]}ge&&z>O&&(ge=ge.removeBefore(L,de,z-we)),ge&&Je<He&&(ge=ge.removeAfter(L,de,Je-we)),we&&(z-=we,J-=we)}return m.__ownerID?(m.size=J-z,m._origin=z,m._capacity=J,m._level=de,m._root=ge,m._tail=ot,m.__hash=void 0,m.__altered=!0,m):pn(z,J,de,ge,ot)}function Sn(m,S,C){for(var L=[],O=0,q=0;q<C.length;q++){var z=C[q],J=a(z);J.size>O&&(O=J.size),c(z)||(J=J.map(function(de){return je(de)})),L.push(J)}return O>m.size&&(m=m.setSize(O)),Tt(m,S,L)}function fn(m){return m<b?0:m-1>>>E<<E}n(vt,lt);function vt(m){return m==null?En():Wn(m)?m:En().withMutations(function(S){var C=o(m);wt(C.size),C.forEach(function(L,O){return S.set(O,L)})})}vt.of=function(){return this(arguments)},vt.prototype.toString=function(){return this.__toString("OrderedMap {","}")},vt.prototype.get=function(m,S){var C=this._map.get(m);return C!==void 0?this._list.get(C)[1]:S},vt.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):En()},vt.prototype.set=function(m,S){return Yn(this,m,S)},vt.prototype.remove=function(m){return Yn(this,m,M)},vt.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},vt.prototype.__iterate=function(m,S){var C=this;return this._list.__iterate(function(L){return L&&m(L[1],L[0],C)},S)},vt.prototype.__iterator=function(m,S){return this._list.fromEntrySeq().__iterator(m,S)},vt.prototype.__ensureOwner=function(m){if(m===this.__ownerID)return this;var S=this._map.__ensureOwner(m),C=this._list.__ensureOwner(m);return m?Ln(S,C,m,this.__hash):(this.__ownerID=m,this._map=S,this._list=C,this)};function Wn(m){return un(m)&&p(m)}vt.isOrderedMap=Wn,vt.prototype[x]=!0,vt.prototype[y]=vt.prototype.remove;function Ln(m,S,C,L){var O=Object.create(vt.prototype);return O.size=m?m.size:0,O._map=m,O._list=S,O.__ownerID=C,O.__hash=L,O}var Xn;function En(){return Xn||(Xn=Ln(Ze(),Cn()))}function Yn(m,S,C){var L=m._map,O=m._list,q=L.get(S),z=q!==void 0,J,de;if(C===M){if(!z)return m;O.size>=b&&O.size>=L.size*2?(de=O.filter(function(ge,we){return ge!==void 0&&q!==we}),J=de.toKeyedSeq().map(function(ge){return ge[0]}).flip().toMap(),m.__ownerID&&(J.__ownerID=de.__ownerID=m.__ownerID)):(J=L.remove(S),de=q===O.size-1?O.pop():O.set(q,void 0))}else if(z){if(C===O.get(q)[1])return m;J=L,de=O.set(q,[S,C])}else J=L.set(S,O.size),de=O.set(O.size,[S,C]);return m.__ownerID?(m.size=J.size,m._map=J,m._list=de,m.__hash=void 0,m):Ln(J,de)}n(kt,pe);function kt(m,S){this._iter=m,this._useKeys=S,this.size=m.size}kt.prototype.get=function(m,S){return this._iter.get(m,S)},kt.prototype.has=function(m){return this._iter.has(m)},kt.prototype.valueSeq=function(){return this._iter.valueSeq()},kt.prototype.reverse=function(){var m=this,S=On(this,!0);return this._useKeys||(S.valueSeq=function(){return m._iter.toSeq().reverse()}),S},kt.prototype.map=function(m,S){var C=this,L=Zn(this,m,S);return this._useKeys||(L.valueSeq=function(){return C._iter.toSeq().map(m,S)}),L},kt.prototype.__iterate=function(m,S){var C=this,L;return this._iter.__iterate(this._useKeys?function(O,q){return m(O,q,C)}:(L=S?rr(this):0,function(O){return m(O,S?--L:L++,C)}),S)},kt.prototype.__iterator=function(m,S){if(this._useKeys)return this._iter.__iterator(m,S);var C=this._iter.__iterator(F,S),L=S?rr(this):0;return new j(function(){var O=C.next();return O.done?O:ie(m,S?--L:L++,O.value,O)})},kt.prototype[x]=!0,n(tn,ae);function tn(m){this._iter=m,this.size=m.size}tn.prototype.includes=function(m){return this._iter.includes(m)},tn.prototype.__iterate=function(m,S){var C=this,L=0;return this._iter.__iterate(function(O){return m(O,L++,C)},S)},tn.prototype.__iterator=function(m,S){var C=this._iter.__iterator(F,S),L=0;return new j(function(){var O=C.next();return O.done?O:ie(m,L++,O.value,O)})},n(nn,Te);function nn(m){this._iter=m,this.size=m.size}nn.prototype.has=function(m){return this._iter.includes(m)},nn.prototype.__iterate=function(m,S){var C=this;return this._iter.__iterate(function(L){return m(L,L,C)},S)},nn.prototype.__iterator=function(m,S){var C=this._iter.__iterator(F,S);return new j(function(){var L=C.next();return L.done?L:ie(m,L.value,L.value,L)})},n(rn,pe);function rn(m){this._iter=m,this.size=m.size}rn.prototype.entrySeq=function(){return this._iter.toSeq()},rn.prototype.__iterate=function(m,S){var C=this;return this._iter.__iterate(function(L){if(L){nr(L);var O=c(L);return m(O?L.get(1):L[1],O?L.get(0):L[0],C)}},S)},rn.prototype.__iterator=function(m,S){var C=this._iter.__iterator(F,S);return new j(function(){for(;;){var L=C.next();if(L.done)return L;var O=L.value;if(O){nr(O);var q=c(O);return ie(m,q?O.get(0):O[0],q?O.get(1):O[1],L)}}})},tn.prototype.cacheResult=kt.prototype.cacheResult=nn.prototype.cacheResult=rn.prototype.cacheResult=Fn;function Kn(m){var S=Vt(m);return S._iter=m,S.size=m.size,S.flip=function(){return m},S.reverse=function(){var C=m.reverse.apply(this);return C.flip=function(){return m.reverse()},C},S.has=function(C){return m.includes(C)},S.includes=function(C){return m.has(C)},S.cacheResult=Fn,S.__iterateUncached=function(C,L){var O=this;return m.__iterate(function(q,z){return C(z,q,O)!==!1},L)},S.__iteratorUncached=function(C,L){if(C===X){var O=m.__iterator(C,L);return new j(function(){var q=O.next();if(!q.done){var z=q.value[0];q.value[0]=q.value[1],q.value[1]=z}return q})}return m.__iterator(C===F?K:F,L)},S}function Zn(m,S,C){var L=Vt(m);return L.size=m.size,L.has=function(O){return m.has(O)},L.get=function(O,q){var z=m.get(O,M);return z===M?q:S.call(C,z,O,m)},L.__iterateUncached=function(O,q){var z=this;return m.__iterate(function(J,de,ge){return O(S.call(C,J,de,ge),de,z)!==!1},q)},L.__iteratorUncached=function(O,q){var z=m.__iterator(X,q);return new j(function(){var J=z.next();if(J.done)return J;var de=J.value,ge=de[0];return ie(O,ge,S.call(C,de[1],ge,m),J)})},L}function On(m,S){var C=Vt(m);return C._iter=m,C.size=m.size,C.reverse=function(){return m},m.flip&&(C.flip=function(){var L=Kn(m);return L.reverse=function(){return m.flip()},L}),C.get=function(L,O){return m.get(S?L:-1-L,O)},C.has=function(L){return m.has(S?L:-1-L)},C.includes=function(L){return m.includes(L)},C.cacheResult=Fn,C.__iterate=function(L,O){var q=this;return m.__iterate(function(z,J){return L(z,J,q)},!O)},C.__iterator=function(L,O){return m.__iterator(L,!O)},C}function Jn(m,S,C,L){var O=Vt(m);return L&&(O.has=function(q){var z=m.get(q,M);return z!==M&&!!S.call(C,z,q,m)},O.get=function(q,z){var J=m.get(q,M);return J!==M&&S.call(C,J,q,m)?J:z}),O.__iterateUncached=function(q,z){var J=this,de=0;return m.__iterate(function(ge,we,He){if(S.call(C,ge,we,He))return de++,q(ge,L?we:de-1,J)},z),de},O.__iteratorUncached=function(q,z){var J=m.__iterator(X,z),de=0;return new j(function(){for(;;){var ge=J.next();if(ge.done)return ge;var we=ge.value,He=we[0],Je=we[1];if(S.call(C,Je,He,m))return ie(q,L?He:de++,Je,ge)}})},O}function Mr(m,S,C){var L=lt().asMutable();return m.__iterate(function(O,q){L.update(S.call(C,O,q,m),0,function(z){return z+1})}),L.asImmutable()}function Tr(m,S,C){var L=u(m),O=(p(m)?vt():lt()).asMutable();m.__iterate(function(z,J){O.update(S.call(C,z,J,m),function(de){return de=de||[],de.push(L?[J,z]:z),de})});var q=ir(m);return O.map(function(z){return pt(m,q(z))})}function Nn(m,S,C,L){var O=m.size;if(S!==void 0&&(S=S|0),C!==void 0&&(C===1/0?C=O:C=C|0),Y(S,C,O))return m;var q=$(S,O),z=ee(C,O);if(q!==q||z!==z)return Nn(m.toSeq().cacheResult(),S,C,L);var J=z-q,de;J===J&&(de=J<0?0:J);var ge=Vt(m);return ge.size=de===0?de:m.size&&de||void 0,!L&&$e(m)&&de>=0&&(ge.get=function(we,He){return we=k(this,we),we>=0&&we<de?m.get(we+q,He):He}),ge.__iterateUncached=function(we,He){var Je=this;if(de===0)return 0;if(He)return this.cacheResult().__iterate(we,He);var it=0,ot=!0,yt=0;return m.__iterate(function(Ut,jt){if(!(ot&&(ot=it++<q)))return yt++,we(Ut,L?jt:yt-1,Je)!==!1&&yt!==de}),yt},ge.__iteratorUncached=function(we,He){if(de!==0&&He)return this.cacheResult().__iterator(we,He);var Je=de!==0&&m.__iterator(we,He),it=0,ot=0;return new j(function(){for(;it++<q;)Je.next();if(++ot>de)return Z();var yt=Je.next();return L||we===F?yt:we===K?ie(we,ot-1,void 0,yt):ie(we,ot-1,yt.value[1],yt)})},ge}function Rr(m,S,C){var L=Vt(m);return L.__iterateUncached=function(O,q){var z=this;if(q)return this.cacheResult().__iterate(O,q);var J=0;return m.__iterate(function(de,ge,we){return S.call(C,de,ge,we)&&++J&&O(de,ge,z)}),J},L.__iteratorUncached=function(O,q){var z=this;if(q)return this.cacheResult().__iterator(O,q);var J=m.__iterator(X,q),de=!0;return new j(function(){if(!de)return Z();var ge=J.next();if(ge.done)return ge;var we=ge.value,He=we[0],Je=we[1];return S.call(C,Je,He,z)?O===X?ge:ie(O,He,Je,ge):(de=!1,Z())})},L}function Qn(m,S,C,L){var O=Vt(m);return O.__iterateUncached=function(q,z){var J=this;if(z)return this.cacheResult().__iterate(q,z);var de=!0,ge=0;return m.__iterate(function(we,He,Je){if(!(de&&(de=S.call(C,we,He,Je))))return ge++,q(we,L?He:ge-1,J)}),ge},O.__iteratorUncached=function(q,z){var J=this;if(z)return this.cacheResult().__iterator(q,z);var de=m.__iterator(X,z),ge=!0,we=0;return new j(function(){var He,Je,it;do{if(He=de.next(),He.done)return L||q===F?He:q===K?ie(q,we++,void 0,He):ie(q,we++,He.value[1],He);var ot=He.value;Je=ot[0],it=ot[1],ge&&(ge=S.call(C,it,Je,J))}while(ge);return q===X?He:ie(q,Je,it,He)})},O}function wr(m,S){var C=u(m),L=[m].concat(S).map(function(z){return c(z)?C&&(z=o(z)):z=C?ne(z):he(Array.isArray(z)?z:[z]),z}).filter(function(z){return z.size!==0});if(L.length===0)return m;if(L.length===1){var O=L[0];if(O===m||C&&u(O)||h(m)&&h(O))return O}var q=new ye(L);return C?q=q.toKeyedSeq():h(m)||(q=q.toSetSeq()),q=q.flatten(!0),q.size=L.reduce(function(z,J){if(z!==void 0){var de=J.size;if(de!==void 0)return z+de}},0),q}function er(m,S,C){var L=Vt(m);return L.__iterateUncached=function(O,q){var z=0,J=!1;function de(ge,we){var He=this;ge.__iterate(function(Je,it){return(!S||we<S)&&c(Je)?de(Je,we+1):O(Je,C?it:z++,He)===!1&&(J=!0),!J},q)}return de(m,0),z},L.__iteratorUncached=function(O,q){var z=m.__iterator(O,q),J=[],de=0;return new j(function(){for(;z;){var ge=z.next();if(ge.done!==!1){z=J.pop();continue}var we=ge.value;if(O===X&&(we=we[1]),(!S||J.length<S)&&c(we))J.push(z),z=we.__iterator(O,q);else return C?ge:ie(O,de++,we,ge)}return Z()})},L}function Ar(m,S,C){var L=ir(m);return m.toSeq().map(function(O,q){return L(S.call(C,O,q,m))}).flatten(!0)}function Ir(m,S){var C=Vt(m);return C.size=m.size&&m.size*2-1,C.__iterateUncached=function(L,O){var q=this,z=0;return m.__iterate(function(J,de){return(!z||L(S,z++,q)!==!1)&&L(J,z++,q)!==!1},O),z},C.__iteratorUncached=function(L,O){var q=m.__iterator(F,O),z=0,J;return new j(function(){return(!J||z%2)&&(J=q.next(),J.done)?J:z%2?ie(L,z++,S):ie(L,z++,J.value,J)})},C}function sn(m,S,C){S||(S=sr);var L=u(m),O=0,q=m.toSeq().map(function(z,J){return[J,z,O++,C?C(z,J,m):z]}).toArray();return q.sort(function(z,J){return S(z[3],J[3])||z[2]-J[2]}).forEach(L?function(z,J){q[J].length=2}:function(z,J){q[J]=z[1]}),L?pe(q):h(m)?ae(q):Te(q)}function bn(m,S,C){if(S||(S=sr),C){var L=m.toSeq().map(function(O,q){return[O,C(O,q,m)]}).reduce(function(O,q){return tr(S,O[1],q[1])?q:O});return L&&L[0]}else return m.reduce(function(O,q){return tr(S,O,q)?q:O})}function tr(m,S,C){var L=m(C,S);return L===0&&C!==S&&(C==null||C!==C)||L>0}function Dn(m,S,C){var L=Vt(m);return L.size=new ye(C).map(function(O){return O.size}).min(),L.__iterate=function(O,q){for(var z=this.__iterator(F,q),J,de=0;!(J=z.next()).done&&O(J.value,de++,this)!==!1;);return de},L.__iteratorUncached=function(O,q){var z=C.map(function(ge){return ge=s(ge),re(q?ge.reverse():ge)}),J=0,de=!1;return new j(function(){var ge;return de||(ge=z.map(function(we){return we.next()}),de=ge.some(function(we){return we.done})),de?Z():ie(O,J++,S.apply(null,ge.map(function(we){return we.value})))})},L}function pt(m,S){return $e(m)?S:m.constructor(S)}function nr(m){if(m!==Object(m))throw new TypeError("Expected [K, V] tuple: "+m)}function rr(m){return wt(m.size),B(m)}function ir(m){return u(m)?o:h(m)?a:l}function Vt(m){return Object.create((u(m)?pe:h(m)?ae:Te).prototype)}function Fn(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):V.prototype.cacheResult.call(this)}function sr(m,S){return m>S?1:m<S?-1:0}function or(m){var S=re(m);if(!S){if(!oe(m))throw new TypeError("Expected iterable or array-like: "+m);S=re(s(m))}return S}n(Nt,De);function Nt(m,S){var C,L=function(z){if(z instanceof L)return z;if(!(this instanceof L))return new L(z);if(!C){C=!0;var J=Object.keys(m);Cr(O,J),O.size=J.length,O._name=S,O._keys=J,O._defaultValues=m}this._map=lt(z)},O=L.prototype=Object.create(bt);return O.constructor=L,L}Nt.prototype.toString=function(){return this.__toString(ar(this)+" {","}")},Nt.prototype.has=function(m){return this._defaultValues.hasOwnProperty(m)},Nt.prototype.get=function(m,S){if(!this.has(m))return S;var C=this._defaultValues[m];return this._map?this._map.get(m,C):C},Nt.prototype.clear=function(){if(this.__ownerID)return this._map&&this._map.clear(),this;var m=this.constructor;return m._empty||(m._empty=Mn(this,Ze()))},Nt.prototype.set=function(m,S){if(!this.has(m))throw new Error('Cannot set unknown key "'+m+'" on '+ar(this));if(this._map&&!this._map.has(m)){var C=this._defaultValues[m];if(S===C)return this}var L=this._map&&this._map.set(m,S);return this.__ownerID||L===this._map?this:Mn(this,L)},Nt.prototype.remove=function(m){if(!this.has(m))return this;var S=this._map&&this._map.remove(m);return this.__ownerID||S===this._map?this:Mn(this,S)},Nt.prototype.wasAltered=function(){return this._map.wasAltered()},Nt.prototype.__iterator=function(m,S){var C=this;return o(this._defaultValues).map(function(L,O){return C.get(O)}).__iterator(m,S)},Nt.prototype.__iterate=function(m,S){var C=this;return o(this._defaultValues).map(function(L,O){return C.get(O)}).__iterate(m,S)},Nt.prototype.__ensureOwner=function(m){if(m===this.__ownerID)return this;var S=this._map&&this._map.__ensureOwner(m);return m?Mn(this,S,m):(this.__ownerID=m,this._map=S,this)};var bt=Nt.prototype;bt[y]=bt.remove,bt.deleteIn=bt.removeIn=D.removeIn,bt.merge=D.merge,bt.mergeWith=D.mergeWith,bt.mergeIn=D.mergeIn,bt.mergeDeep=D.mergeDeep,bt.mergeDeepWith=D.mergeDeepWith,bt.mergeDeepIn=D.mergeDeepIn,bt.setIn=D.setIn,bt.update=D.update,bt.updateIn=D.updateIn,bt.withMutations=D.withMutations,bt.asMutable=D.asMutable,bt.asImmutable=D.asImmutable;function Mn(m,S,C){var L=Object.create(Object.getPrototypeOf(m));return L._map=S,L.__ownerID=C,L}function ar(m){return m._name||m.constructor.name||"Record"}function Cr(m,S){try{S.forEach(Pr.bind(void 0,m))}catch{}}function Pr(m,S){Object.defineProperty(m,S,{get:function(){return this.get(S)},set:function(C){H(this.__ownerID,"Cannot set on an immutable record."),this.set(S,C)}})}n(xt,Ye);function xt(m){return m==null?Un():kn(m)&&!p(m)?m:Un().withMutations(function(S){var C=l(m);wt(C.size),C.forEach(function(L){return S.add(L)})})}xt.of=function(){return this(arguments)},xt.fromKeys=function(m){return this(o(m).keySeq())},xt.prototype.toString=function(){return this.__toString("Set {","}")},xt.prototype.has=function(m){return this._map.has(m)},xt.prototype.add=function(m){return Bn(this,this._map.set(m,!0))},xt.prototype.remove=function(m){return Bn(this,this._map.remove(m))},xt.prototype.clear=function(){return Bn(this,this._map.clear())},xt.prototype.union=function(){var m=t.call(arguments,0);return m=m.filter(function(S){return S.size!==0}),m.length===0?this:this.size===0&&!this.__ownerID&&m.length===1?this.constructor(m[0]):this.withMutations(function(S){for(var C=0;C<m.length;C++)l(m[C]).forEach(function(L){return S.add(L)})})},xt.prototype.intersect=function(){var m=t.call(arguments,0);if(m.length===0)return this;m=m.map(function(C){return l(C)});var S=this;return this.withMutations(function(C){S.forEach(function(L){m.every(function(O){return O.includes(L)})||C.remove(L)})})},xt.prototype.subtract=function(){var m=t.call(arguments,0);if(m.length===0)return this;m=m.map(function(C){return l(C)});var S=this;return this.withMutations(function(C){S.forEach(function(L){m.some(function(O){return O.includes(L)})&&C.remove(L)})})},xt.prototype.merge=function(){return this.union.apply(this,arguments)},xt.prototype.mergeWith=function(m){var S=t.call(arguments,1);return this.union.apply(this,S)},xt.prototype.sort=function(m){return Gt(sn(this,m))},xt.prototype.sortBy=function(m,S){return Gt(sn(this,S,m))},xt.prototype.wasAltered=function(){return this._map.wasAltered()},xt.prototype.__iterate=function(m,S){var C=this;return this._map.__iterate(function(L,O){return m(O,O,C)},S)},xt.prototype.__iterator=function(m,S){return this._map.map(function(C,L){return L}).__iterator(m,S)},xt.prototype.__ensureOwner=function(m){if(m===this.__ownerID)return this;var S=this._map.__ensureOwner(m);return m?this.__make(S,m):(this.__ownerID=m,this._map=S,this)};function kn(m){return!!(m&&m[lr])}xt.isSet=kn;var lr="@@__IMMUTABLE_SET__@@",Dt=xt.prototype;Dt[lr]=!0,Dt[y]=Dt.remove,Dt.mergeDeep=Dt.merge,Dt.mergeDeepWith=Dt.mergeWith,Dt.withMutations=D.withMutations,Dt.asMutable=D.asMutable,Dt.asImmutable=D.asImmutable,Dt.__empty=Un,Dt.__make=cr;function Bn(m,S){return m.__ownerID?(m.size=S.size,m._map=S,m):S===m._map?m:S.size===0?m.__empty():m.__make(S)}function cr(m,S){var C=Object.create(Dt);return C.size=m?m.size:0,C._map=m,C.__ownerID=S,C}var ur;function Un(){return ur||(ur=cr(Ze()))}n(Gt,xt);function Gt(m){return m==null?qn():hr(m)?m:qn().withMutations(function(S){var C=l(m);wt(C.size),C.forEach(function(L){return S.add(L)})})}Gt.of=function(){return this(arguments)},Gt.fromKeys=function(m){return this(o(m).keySeq())},Gt.prototype.toString=function(){return this.__toString("OrderedSet {","}")};function hr(m){return kn(m)&&p(m)}Gt.isOrderedSet=hr;var Tn=Gt.prototype;Tn[x]=!0,Tn.__empty=qn,Tn.__make=dr;function dr(m,S){var C=Object.create(Tn);return C.size=m?m.size:0,C._map=m,C.__ownerID=S,C}var pr;function qn(){return pr||(pr=dr(En()))}n(St,Re);function St(m){return m==null?Vn():fr(m)?m:Vn().unshiftAll(m)}St.of=function(){return this(arguments)},St.prototype.toString=function(){return this.__toString("Stack [","]")},St.prototype.get=function(m,S){var C=this._head;for(m=k(this,m);C&&m--;)C=C.next;return C?C.value:S},St.prototype.peek=function(){return this._head&&this._head.value},St.prototype.push=function(){if(arguments.length===0)return this;for(var m=this.size+arguments.length,S=this._head,C=arguments.length-1;C>=0;C--)S={value:arguments[C],next:S};return this.__ownerID?(this.size=m,this._head=S,this.__hash=void 0,this.__altered=!0,this):mn(m,S)},St.prototype.pushAll=function(m){if(m=a(m),m.size===0)return this;wt(m.size);var S=this.size,C=this._head;return m.reverse().forEach(function(L){S++,C={value:L,next:C}}),this.__ownerID?(this.size=S,this._head=C,this.__hash=void 0,this.__altered=!0,this):mn(S,C)},St.prototype.pop=function(){return this.slice(1)},St.prototype.unshift=function(){return this.push.apply(this,arguments)},St.prototype.unshiftAll=function(m){return this.pushAll(m)},St.prototype.shift=function(){return this.pop.apply(this,arguments)},St.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Vn()},St.prototype.slice=function(m,S){if(Y(m,S,this.size))return this;var C=$(m,this.size),L=ee(S,this.size);if(L!==this.size)return Re.prototype.slice.call(this,m,S);for(var O=this.size-C,q=this._head;C--;)q=q.next;return this.__ownerID?(this.size=O,this._head=q,this.__hash=void 0,this.__altered=!0,this):mn(O,q)},St.prototype.__ensureOwner=function(m){return m===this.__ownerID?this:m?mn(this.size,this._head,m,this.__hash):(this.__ownerID=m,this.__altered=!1,this)},St.prototype.__iterate=function(m,S){if(S)return this.reverse().__iterate(m);for(var C=0,L=this._head;L&&m(L.value,C++,this)!==!1;)L=L.next;return C},St.prototype.__iterator=function(m,S){if(S)return this.reverse().__iterator(m);var C=0,L=this._head;return new j(function(){if(L){var O=L.value;return L=L.next,ie(m,C++,O)}return Z()})};function fr(m){return!!(m&&m[mr])}St.isStack=fr;var mr="@@__IMMUTABLE_STACK__@@",on=St.prototype;on[mr]=!0,on.withMutations=D.withMutations,on.asMutable=D.asMutable,on.asImmutable=D.asImmutable,on.wasAltered=D.wasAltered;function mn(m,S,C,L){var O=Object.create(on);return O.size=m,O._head=S,O.__ownerID=C,O.__hash=L,O.__altered=!1,O}var gr;function Vn(){return gr||(gr=mn(0))}function zt(m,S){var C=function(L){m.prototype[L]=S[L]};return Object.keys(S).forEach(C),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(S).forEach(C),m}s.Iterator=j,zt(s,{toArray:function(){wt(this.size);var m=new Array(this.size||0);return this.valueSeq().__iterate(function(S,C){m[C]=S}),m},toIndexedSeq:function(){return new tn(this)},toJS:function(){return this.toSeq().map(function(m){return m&&typeof m.toJS=="function"?m.toJS():m}).__toJS()},toJSON:function(){return this.toSeq().map(function(m){return m&&typeof m.toJSON=="function"?m.toJSON():m}).__toJS()},toKeyedSeq:function(){return new kt(this,!0)},toMap:function(){return lt(this.toKeyedSeq())},toObject:function(){wt(this.size);var m={};return this.__iterate(function(S,C){m[C]=S}),m},toOrderedMap:function(){return vt(this.toKeyedSeq())},toOrderedSet:function(){return Gt(u(this)?this.valueSeq():this)},toSet:function(){return xt(u(this)?this.valueSeq():this)},toSetSeq:function(){return new nn(this)},toSeq:function(){return h(this)?this.toIndexedSeq():u(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return St(u(this)?this.valueSeq():this)},toList:function(){return _t(u(this)?this.valueSeq():this)},toString:function(){return"[Iterable]"},__toString:function(m,S){return this.size===0?m+S:m+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+S},concat:function(){var m=t.call(arguments,0);return pt(this,wr(this,m))},includes:function(m){return this.some(function(S){return Ne(S,m)})},entries:function(){return this.__iterator(X)},every:function(m,S){wt(this.size);var C=!0;return this.__iterate(function(L,O,q){if(!m.call(S,L,O,q))return C=!1,!1}),C},filter:function(m,S){return pt(this,Jn(this,m,S,!0))},find:function(m,S,C){var L=this.findEntry(m,S);return L?L[1]:C},forEach:function(m,S){return wt(this.size),this.__iterate(S?m.bind(S):m)},join:function(m){wt(this.size),m=m!==void 0?""+m:",";var S="",C=!0;return this.__iterate(function(L){C?C=!1:S+=m,S+=L!=null?L.toString():""}),S},keys:function(){return this.__iterator(K)},map:function(m,S){return pt(this,Zn(this,m,S))},reduce:function(m,S,C){wt(this.size);var L,O;return arguments.length<2?O=!0:L=S,this.__iterate(function(q,z,J){O?(O=!1,L=q):L=m.call(C,L,q,z,J)}),L},reduceRight:function(m,S,C){var L=this.toKeyedSeq().reverse();return L.reduce.apply(L,arguments)},reverse:function(){return pt(this,On(this,!0))},slice:function(m,S){return pt(this,Nn(this,m,S,!0))},some:function(m,S){return!this.every(wn(m),S)},sort:function(m){return pt(this,sn(this,m))},values:function(){return this.__iterator(F)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return this.size!==void 0?this.size===0:!this.some(function(){return!0})},count:function(m,S){return B(m?this.toSeq().filter(m,S):this)},countBy:function(m,S){return Mr(this,m,S)},equals:function(m){return Ce(this,m)},entrySeq:function(){var m=this;if(m._cache)return new ye(m._cache);var S=m.toSeq().map(Or).toIndexedSeq();return S.fromEntrySeq=function(){return m.toSeq()},S},filterNot:function(m,S){return this.filter(wn(m),S)},findEntry:function(m,S,C){var L=C;return this.__iterate(function(O,q,z){if(m.call(S,O,q,z))return L=[q,O],!1}),L},findKey:function(m,S){var C=this.findEntry(m,S);return C&&C[0]},findLast:function(m,S,C){return this.toKeyedSeq().reverse().find(m,S,C)},findLastEntry:function(m,S,C){return this.toKeyedSeq().reverse().findEntry(m,S,C)},findLastKey:function(m,S){return this.toKeyedSeq().reverse().findKey(m,S)},first:function(){return this.find(W)},flatMap:function(m,S){return pt(this,Ar(this,m,S))},flatten:function(m){return pt(this,er(this,m,!0))},fromEntrySeq:function(){return new rn(this)},get:function(m,S){return this.find(function(C,L){return Ne(L,m)},void 0,S)},getIn:function(m,S){for(var C=this,L=or(m),O;!(O=L.next()).done;){var q=O.value;if(C=C&&C.get?C.get(q,M):M,C===M)return S}return C},groupBy:function(m,S){return Tr(this,m,S)},has:function(m){return this.get(m,M)!==M},hasIn:function(m){return this.getIn(m,M)!==M},isSubset:function(m){return m=typeof m.includes=="function"?m:s(m),this.every(function(S){return m.includes(S)})},isSuperset:function(m){return m=typeof m.isSubset=="function"?m:s(m),m.isSubset(this)},keyOf:function(m){return this.findKey(function(S){return Ne(S,m)})},keySeq:function(){return this.toSeq().map(Lr).toIndexedSeq()},last:function(){return this.toSeq().reverse().first()},lastKeyOf:function(m){return this.toKeyedSeq().reverse().keyOf(m)},max:function(m){return bn(this,m)},maxBy:function(m,S){return bn(this,S,m)},min:function(m){return bn(this,m?_r(m):yr)},minBy:function(m,S){return bn(this,S?_r(S):yr,m)},rest:function(){return this.slice(1)},skip:function(m){return this.slice(Math.max(0,m))},skipLast:function(m){return pt(this,this.toSeq().reverse().skip(m).reverse())},skipWhile:function(m,S){return pt(this,Qn(this,m,S,!0))},skipUntil:function(m,S){return this.skipWhile(wn(m),S)},sortBy:function(m,S){return pt(this,sn(this,S,m))},take:function(m){return this.slice(0,Math.max(0,m))},takeLast:function(m){return pt(this,this.toSeq().reverse().take(m).reverse())},takeWhile:function(m,S){return pt(this,Rr(this,m,S))},takeUntil:function(m,S){return this.takeWhile(wn(m),S)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=Dr(this))}});var Ct=s.prototype;Ct[f]=!0,Ct[Me]=Ct.values,Ct.__toJS=Ct.toArray,Ct.__toStringMapper=xr,Ct.inspect=Ct.toSource=function(){return this.toString()},Ct.chain=Ct.flatMap,Ct.contains=Ct.includes,zt(o,{flip:function(){return pt(this,Kn(this))},mapEntries:function(m,S){var C=this,L=0;return pt(this,this.toSeq().map(function(O,q){return m.call(S,[q,O],L++,C)}).fromEntrySeq())},mapKeys:function(m,S){var C=this;return pt(this,this.toSeq().flip().map(function(L,O){return m.call(S,L,O,C)}).flip())}});var Rn=o.prototype;Rn[g]=!0,Rn[Me]=Ct.entries,Rn.__toJS=Ct.toObject,Rn.__toStringMapper=function(m,S){return JSON.stringify(S)+": "+xr(m)},zt(a,{toKeyedSeq:function(){return new kt(this,!1)},filter:function(m,S){return pt(this,Jn(this,m,S,!1))},findIndex:function(m,S){var C=this.findEntry(m,S);return C?C[0]:-1},indexOf:function(m){var S=this.keyOf(m);return S===void 0?-1:S},lastIndexOf:function(m){var S=this.lastKeyOf(m);return S===void 0?-1:S},reverse:function(){return pt(this,On(this,!1))},slice:function(m,S){return pt(this,Nn(this,m,S,!1))},splice:function(m,S){var C=arguments.length;if(S=Math.max(S|0,0),C===0||C===2&&!S)return this;m=$(m,m<0?this.count():this.size);var L=this.slice(0,m);return pt(this,C===1?L:L.concat(P(arguments,2),this.slice(m+S)))},findLastIndex:function(m,S){var C=this.findLastEntry(m,S);return C?C[0]:-1},first:function(){return this.get(0)},flatten:function(m){return pt(this,er(this,m,!1))},get:function(m,S){return m=k(this,m),m<0||this.size===1/0||this.size!==void 0&&m>this.size?S:this.find(function(C,L){return L===m},void 0,S)},has:function(m){return m=k(this,m),m>=0&&(this.size!==void 0?this.size===1/0||m<this.size:this.indexOf(m)!==-1)},interpose:function(m){return pt(this,Ir(this,m))},interleave:function(){var m=[this].concat(P(arguments)),S=Dn(this.toSeq(),ae.of,m),C=S.flatten(!0);return S.size&&(C.size=S.size*m.length),pt(this,C)},keySeq:function(){return Ee(0,this.size)},last:function(){return this.get(-1)},skipWhile:function(m,S){return pt(this,Qn(this,m,S,!1))},zip:function(){var m=[this].concat(P(arguments));return pt(this,Dn(this,Nr,m))},zipWith:function(m){var S=P(arguments);return S[0]=this,pt(this,Dn(this,m,S))}}),a.prototype[_]=!0,a.prototype[x]=!0,zt(l,{get:function(m,S){return this.has(m)?m:S},includes:function(m){return this.has(m)},keySeq:function(){return this.valueSeq()}}),l.prototype.has=Ct.includes,l.prototype.contains=l.prototype.includes,zt(pe,o.prototype),zt(ae,a.prototype),zt(Te,l.prototype),zt(De,o.prototype),zt(Re,a.prototype),zt(Ye,l.prototype);function Lr(m,S){return S}function Or(m,S){return[S,m]}function wn(m){return function(){return!m.apply(this,arguments)}}function _r(m){return function(){return-m.apply(this,arguments)}}function xr(m){return typeof m=="string"?JSON.stringify(m):String(m)}function Nr(){return P(arguments)}function yr(m,S){return m<S?1:m>S?-1:0}function Dr(m){if(m.size===1/0)return 0;var S=p(m),C=u(m),L=S?1:0,O=m.__iterate(C?S?function(q,z){L=31*L+vr(rt(q),rt(z))|0}:function(q,z){L=L+vr(rt(q),rt(z))|0}:S?function(q){L=31*L+rt(q)|0}:function(q){L=L+rt(q)|0});return Fr(O,L)}function Fr(m,S){return S=nt(S,3432918353),S=nt(S<<15|S>>>-15,461845907),S=nt(S<<13|S>>>-13,5),S=(S+3864292196|0)^m,S=nt(S^S>>>16,2246822507),S=nt(S^S>>>13,3266489909),S=ut(S^S>>>16),S}function vr(m,S){return m^S+2654435769+(m<<6)+(m>>2)|0}var kr={Iterable:s,Seq:V,Collection:Ge,Map:lt,OrderedMap:vt,List:_t,Stack:St,Set:xt,OrderedSet:Gt,Record:Nt,Range:Ee,Repeat:xe,is:Ne,fromJS:je};return kr})})(immutable$1)),immutable$1.exports}var utils$1,hasRequiredUtils$1;function requireUtils$1(){if(hasRequiredUtils$1)return utils$1;hasRequiredUtils$1=1;var i=requireImmutable(),e=function(s){return i.Iterable.isKeyed(s)},t=function(s){return i.Iterable.isIndexed(s)},n=function(s,o,a){return s==="remove"?{op:s,path:o}:{op:s,path:o,value:a}};return utils$1={isMap:e,isIndexed:t,op:n},utils$1}var lcs_1,hasRequiredLcs;function requireLcs(){if(hasRequiredLcs)return lcs_1;hasRequiredLcs=1;var i=requireImmutable(),e=function(u,h,d){for(var p=[],f=0;f<u;f++){p[f]=new Array(h);for(var g=0;g<h;g++)p[f][g]=d}return p},t=function(u,h){var d=l(u,h);return c(u,h,d)},n=i.Record({op:"=",val:null}),s=i.Record({op:"!=",val:null,newVal:null}),o=function(u,h){var d=l(u,h);return a(d,u,h,u.size||0,h.size||0)},a=function(u,h,d,p,f){for(var g=[],_=p-1,x=f-1;_>=0||x>=0;)_>=0&&x>=0&&i.is(h.get(_),d.get(x))?(g.push(new n({op:"=",val:h.get(_)})),_-=1,x-=1):_>=0&&x>=0&&_===x&&!i.is(h.get(_),d.get(x))?(g.push(new s({val:h.get(_),newVal:d.get(_)})),_-=1,x-=1):x>=0&&(_===-1||u[_+1][x]>=u[_][x+1])?(g.push(new n({op:"+",val:d.get(x)})),x-=1):_>=0&&(x===-1||u[_+1][x]<u[_][x+1])&&(g.push(new n({op:"-",val:h.get(_)})),_-=1);return g.reverse()};function l(u,h){for(var d=u.size||0,p=h.size||0,f=e(d+1,p+1,0),g=0;g<d;g++)for(var _=0;_<p;_++)i.is(u.get(g),h.get(_))?f[g+1][_+1]=f[g][_]+1:f[g+1][_+1]=Math.max(f[g+1][_],f[g][_+1]);return f}var c=function(u,h,d){for(var p=[],f=u.size,g=h.size;f!==0&&g!==0;)d[f][g]===d[f-1][g]?f--:d[f][g]===d[f][g-1]?g--:i.is(u.get(f-1),h.get(g-1))&&(p.push(u.get(f-1)),f--,g--);return p.reverse()};return lcs_1={lcs:t,computeLcsMatrix:l,diff:o},lcs_1}var path$1,hasRequiredPath$1;function requirePath$1(){if(hasRequiredPath$1)return path$1;hasRequiredPath$1=1;var i=new RegExp("/","g"),e=new RegExp("~1","g"),t=/~/g,n=/~0/g,s={escape:function(o){if(typeof o=="number")return o.toString();if(typeof o!="string")throw"param str ("+o+") is not a string";return o.replace(t,"~0").replace(i,"~1")},unescape:function(o){return typeof o=="string"?o.replace(e,"/").replace(n,"~"):o},concat:function(o,a){return o+"/"+a}};return path$1=s,path$1}var diff_1,hasRequiredDiff;function requireDiff(){if(hasRequiredDiff)return diff_1;hasRequiredDiff=1;var i=requireImmutable(),e=requireUtils$1(),t=requireLcs(),n=requirePath$1(),s=n.concat,o=n.escape,a=e.op,l=e.isMap,c=e.isIndexed,u=function(f,g,_){var x=[],y=_||"";if(i.is(f,g)||f==g==null)return x;var E=c(f)&&c(g),b=null,v=null;return f.forEach&&f.forEach(function(M,T){if(g.has(T))if(l(M)&&l(g.get(T)))x=x.concat(u(M,g.get(T),s(y,o(T))));else if(c(g.get(T))&&c(M))x=x.concat(h(M,g.get(T),s(y,o(T))));else{var I=g.get?g.get(T):g,w=M!==I;w&&x.push(a("replace",s(y,o(T)),I))}else E?(v=b!=null&&b+1===T?v:T,x.push(a("remove",s(y,o(v)))),b=T):x.push(a("remove",s(y,o(T))))}),g.forEach(function(M,T){f.has&&!f.has(T)&&x.push(a("add",s(y,o(T)),M))}),x},h=function(f,g,_){var x=[],y=_||"";if(i.is(f,g)||f==g==null)return x;if((f.count()+1)*(g.count()+1)>=1e4)return u(f,g,_);var E=t.diff(f,g),b=0;return E.forEach(function(v){if(v.op==="=")b++;else if(v.op==="!="){if(l(v.val)&&l(v.newVal)){var M=u(v.val,v.newVal,s(y,b));x=x.concat(M)}else x.push(a("replace",s(y,b),v.newVal));b++}else v.op==="+"?(x.push(a("add",s(y,b),v.val)),b++):v.op==="-"&&x.push(a("remove",s(y,b)))}),x},d=function(f,g,_){var x=_||"";return f===g?[]:[a("replace",s(x,""),g)]},p=function(f,g,_){return i.is(f,g)?i.List():f!=g&&(f==null||g==null)?i.fromJS([a("replace","/",g)]):c(f)&&c(g)?i.fromJS(h(f,g)):l(f)&&l(g)?i.fromJS(u(f,g)):i.fromJS(d(f,g,_))};return diff_1=p,diff_1}var diffExports=requireDiff();const diff$2=getDefaultExportFromCjs(diffExports),require$$0=getAugmentedNamespace(immutable_es);var path,hasRequiredPath;function requirePath(){if(hasRequiredPath)return path;hasRequiredPath=1;var i=new RegExp("/","g"),e=new RegExp("~1","g"),t=/~/g,n=/~0/g,s={escape:function(o){if(typeof o!="string")throw"param str ("+o+") is not a string";return o.replace(t,"~0").replace(i,"~1")},unescape:function(o){return typeof o=="string"?o.replace(e,"/").replace(n,"~"):o}};return path=s,path}var patch$1,hasRequiredPatch;function requirePatch(){if(hasRequiredPatch)return patch$1;hasRequiredPatch=1;var i=require$$0,e=requirePath(),t=function(h){var d=parseInt(h);return isNaN(d)?h:d},n=function(h,d){if(h==="add"||h==="replace")return d;if(h==="remove")return null},s=function(h,d,p,f,g){if(f==="add")if(p.length>0&&h.get(d)===void 0){var _=p[0].match(/^\d+$/)?i.List():i.Map();return h.set(d,l(_,p,f,g))}else return h.set(d,l(h.get(d),p,f,g));else{if(f==="replace")return p.length>0?h.set(d,l(h.get(d),p,f,g)):h.set(d,g);if(f==="remove")return p.length>0?h.set(d,l(h.get(d),p,f,g)):h.remove(d);throw new Error("map patch Error, unknown op: "+f)}},o=function(h,d,p,f,g){if(d=t(d),f==="add")if(h.get(d)===void 0)if(p.length>0){var _=p[0].match(/^\d+$/)?i.List():i.Map();return h.set(d,l(_,p,f,g))}else return d==="-"?h.splice(h.size,0,g):h.splice(d,0,g);else return p.length>0?h.set(d,l(h.get(d),p,f,g)):h.splice(d,0,g);else{if(f==="replace")return p.length>0?h.set(d,l(h.get(d),p,f,g)):h.set(d,g);if(f==="remove")return p.length>0?h.set(d,l(h.get(d),p,f,g)):h.remove(d);throw new Error("sequence patch Error, unknown op: "+f)}},a=function(h){return h!=null&&typeof h.updateIn=="function"&&typeof h.set=="function"},l=function(h,d,p,f){var g,_;return i.Iterable.isIndexed(h)?d.length===0?h:(g=d[0],_=d.slice(1),o(h,g,_,p,f)):i.Iterable.isKeyed(h)||a(h)?d.length===0?h:(g=d[0],_=d.slice(1),s(h,g,_,p,f)):d.length===0?f:n(p,f)},c=function(h,d){for(;d.size;){var p=d.get(0),d=d.slice(1),f=p.get("path").split("/").slice(1).map(e.unescape);h=l(h,f,p.get("op"),p.get("value"))}return h},u=function(h,d){if(d.size===1){var p=d.get(0);if(p.get("op")==="replace"&&p.get("path")==="/")return p.get("value")}return c(h,d)};return u.default=u,patch$1=u,patch$1}var patchExports=requirePatch();const patch=getDefaultExportFromCjs(patchExports),historyPush=(i,e)=>{if(i.last){if(i.last.hashCode()!==e.hashCode()){let t=Map$1({time:Date.now(),diff:diff$2(i.last,e)});i=i.set("last",e).set("list",i.list.push(t)).set("redoList",i.redoList.clear())}}else i=i.set("last",e);return i},historyRedo=i=>{if(i.last&&i.redoList.size){const e=i.redoList.last(),t=patch(i.last,e.get("diff"));i=i.set("last",t).set("list",i.list.push(e)).set("redoList",i.redoList.pop())}return i},historyPop=i=>{var e;if(i.last&&i.list.size){const t=i.list.last();let n=i.first;for(let s=0;s<i.list.size-1;s++)n=patch(n,(e=i.list.get(s))==null?void 0:e.get("diff"));i=i.set("last",n).set("list",i.list.pop()).set("redoList",i.redoList.push(t))}return i},SURFACE_LINE_TYPE="surface";function lineFamily(i){return i===SURFACE_LINE_TYPE?"surface":"structure"}function lineFamilyOf(i){return i?lineFamily(i.get?i.get("type"):i.type):"structure"}function vertexAcceptsFamily(i,e,t){var a;const n=(a=i==null?void 0:i.get)==null?void 0:a.call(i,"lines");if(!n||n.size===0)return!0;let s=!1,o=!1;return n.forEach(l=>{var u;const c=(u=e==null?void 0:e.getIn)==null?void 0:u.call(e,["lines",l]);c&&(s=!0,lineFamilyOf(c)===t&&(o=!0))}),s?o:!0}function areaFamily(i,e){var s,o;let t=!1,n=!1;return(o=(s=i==null?void 0:i.get)==null?void 0:s.call(i,"vertices"))==null||o.forEach(a=>{var l,c,u;(u=(c=(l=e==null?void 0:e.getIn)==null?void 0:l.call(e,["vertices",a]))==null?void 0:c.get("lines"))==null||u.forEach(h=>{const d=e.getIn(["lines",h]);d&&(lineFamilyOf(d)==="surface"?t=!0:n=!0)})}),t&&!n?"surface":"structure"}const LINE_FAMILIES=["structure","surface"];var lib={exports:{}},randomFromSeed,hasRequiredRandomFromSeed;function requireRandomFromSeed(){if(hasRequiredRandomFromSeed)return randomFromSeed;hasRequiredRandomFromSeed=1;var i=1;function e(){return i=(i*9301+49297)%233280,i/233280}function t(n){i=n}return randomFromSeed={nextValue:e,seed:t},randomFromSeed}var alphabet_1,hasRequiredAlphabet;function requireAlphabet(){if(hasRequiredAlphabet)return alphabet_1;hasRequiredAlphabet=1;var i=requireRandomFromSeed(),e="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-",t,n,s;function o(){s=!1}function a(f){if(!f){t!==e&&(t=e,o());return}if(f!==t){if(f.length!==e.length)throw new Error("Custom alphabet for shortid must be "+e.length+" unique characters. You submitted "+f.length+" characters: "+f);var g=f.split("").filter(function(_,x,y){return x!==y.lastIndexOf(_)});if(g.length)throw new Error("Custom alphabet for shortid must be "+e.length+" unique characters. These characters were not unique: "+g.join(", "));t=f,o()}}function l(f){return a(f),t}function c(f){i.seed(f),n!==f&&(o(),n=f)}function u(){t||a(e);for(var f=t.split(""),g=[],_=i.nextValue(),x;f.length>0;)_=i.nextValue(),x=Math.floor(_*f.length),g.push(f.splice(x,1)[0]);return g.join("")}function h(){return s||(s=u(),s)}function d(f){var g=h();return g[f]}function p(){return t||e}return alphabet_1={get:p,characters:l,seed:c,lookup:d,shuffled:h},alphabet_1}var randomByteBrowser,hasRequiredRandomByteBrowser;function requireRandomByteBrowser(){if(hasRequiredRandomByteBrowser)return randomByteBrowser;hasRequiredRandomByteBrowser=1;var i=typeof window=="object"&&(window.crypto||window.msCrypto),e;return!i||!i.getRandomValues?e=function(t){for(var n=[],s=0;s<t;s++)n.push(Math.floor(Math.random()*256));return n}:e=function(t){return i.getRandomValues(new Uint8Array(t))},randomByteBrowser=e,randomByteBrowser}let urlAlphabet="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",random=i=>crypto.getRandomValues(new Uint8Array(i)),customRandom=(i,e,t)=>{let n=(2<<Math.log(i.length-1)/Math.LN2)-1,s=-~(1.6*n*e/i.length);return(o=e)=>{let a="";for(;;){let l=t(s),c=s|0;for(;c--;)if(a+=i[l[c]&n]||"",a.length===o)return a}}},customAlphabet=(i,e=21)=>customRandom(i,e,random),nanoid=(i=21)=>crypto.getRandomValues(new Uint8Array(i)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),"");const index_browser=Object.freeze(Object.defineProperty({__proto__:null,customAlphabet,customRandom,nanoid,random,urlAlphabet},Symbol.toStringTag,{value:"Module"})),require$$2=getAugmentedNamespace(index_browser);var generate_1,hasRequiredGenerate;function requireGenerate(){if(hasRequiredGenerate)return generate_1;hasRequiredGenerate=1;var i=requireAlphabet(),e=requireRandomByteBrowser(),t=require$$2.customRandom;function n(s){for(var o=0,a,l="";!a;)l=l+t(i.get(),1,e)(),a=s<Math.pow(16,o+1),o++;return l}return generate_1=n,generate_1}var build_1,hasRequiredBuild;function requireBuild(){if(hasRequiredBuild)return build_1;hasRequiredBuild=1;var i=requireGenerate();requireAlphabet();var e=1567752802062,t=7,n,s;function o(a){var l="",c=Math.floor((Date.now()-e)*.001);return c===s?n++:(n=0,s=c),l=l+i(t),l=l+i(a),n>0&&(l=l+i(n)),l=l+i(c),l}return build_1=o,build_1}var isValid,hasRequiredIsValid;function requireIsValid(){if(hasRequiredIsValid)return isValid;hasRequiredIsValid=1;var i=requireAlphabet();function e(t){if(!t||typeof t!="string"||t.length<6)return!1;var n=new RegExp("[^"+i.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]");return!n.test(t)}return isValid=e,isValid}var clusterWorkerIdBrowser,hasRequiredClusterWorkerIdBrowser;function requireClusterWorkerIdBrowser(){return hasRequiredClusterWorkerIdBrowser||(hasRequiredClusterWorkerIdBrowser=1,clusterWorkerIdBrowser=0),clusterWorkerIdBrowser}var hasRequiredLib;function requireLib(){return hasRequiredLib||(hasRequiredLib=1,(function(i){var e=requireAlphabet(),t=requireBuild(),n=requireIsValid(),s=requireClusterWorkerIdBrowser()||0;function o(u){return e.seed(u),i.exports}function a(u){return s=u,i.exports}function l(u){return u!==void 0&&e.characters(u),e.shuffled()}function c(){return t(s)}i.exports=c,i.exports.generate=c,i.exports.seed=o,i.exports.worker=a,i.exports.characters=l,i.exports.isValid=n})(lib)),lib.exports}var shortid$1,hasRequiredShortid;function requireShortid(){return hasRequiredShortid||(hasRequiredShortid=1,shortid$1=requireLib()),shortid$1}var shortidExports=requireShortid();const shortid=getDefaultExportFromCjs(shortidExports);class IDBroker{static acquireID(){return shortid.generate()}}class NameGenerator{static generateName(e,t){const n=typeof t=="string"&&t.length>0?t:"Element";return n.charAt(0).toUpperCase()+n.slice(1)}}class TinyQueue{constructor(e=[],t=(n,s)=>n<s?-1:n>s?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:n}=this,s=t[e];for(;e>0;){const o=e-1>>1,a=t[o];if(n(s,a)>=0)break;t[e]=a,e=o}t[e]=s}_down(e){const{data:t,compare:n}=this,s=this.length>>1,o=t[e];for(;e<s;){let a=(e<<1)+1;const l=a+1;if(l<this.length&&n(t[l],t[a])<0&&(a=l),n(t[a],o)>=0)break;t[e]=t[a],e=a}t[e]=o}}function polylabel(i,e=1,t=!1){let n=1/0,s=1/0,o=-1/0,a=-1/0;for(const[y,E]of i[0])y<n&&(n=y),E<s&&(s=E),y>o&&(o=y),E>a&&(a=E);const l=o-n,c=a-s,u=Math.max(e,Math.min(l,c));if(u===e){const y=[n,s];return y.distance=0,y}const h=new TinyQueue([],(y,E)=>E.max-y.max);let d=getCentroidCell(i);const p=new Cell(n+l/2,s+c/2,0,i);p.d>d.d&&(d=p);let f=2;function g(y,E,b){const v=new Cell(y,E,b,i);f++,v.max>d.d+e&&h.push(v),v.d>d.d&&(d=v,t&&console.log(`found best ${Math.round(1e4*v.d)/1e4} after ${f} probes`))}let _=u/2;for(let y=n;y<o;y+=u)for(let E=s;E<a;E+=u)g(y+_,E+_,_);for(;h.length;){const{max:y,x:E,y:b,h:v}=h.pop();if(y-d.d<=e)break;_=v/2,g(E-_,b-_,_),g(E+_,b-_,_),g(E-_,b+_,_),g(E+_,b+_,_)}t&&console.log(`num probes: ${f}
45
+ */var DELETE="delete",SHIFT=5,SIZE=1<<SHIFT,MASK=SIZE-1,NOT_SET={};function MakeRef(){return{value:!1}}function SetRef(i){i&&(i.value=!0)}function OwnerID(){}function ensureSize(i){return i.size===void 0&&(i.size=i.__iterate(returnTrue)),i.size}function wrapIndex(i,e){if(typeof e!="number"){var t=e>>>0;if(""+t!==e||t===4294967295)return NaN;e=t}return e<0?ensureSize(i)+e:e}function returnTrue(){return!0}function wholeSlice(i,e,t){return(i===0&&!isNeg(i)||t!==void 0&&i<=-t)&&(e===void 0||t!==void 0&&e>=t)}function resolveBegin(i,e){return resolveIndex(i,e,0)}function resolveEnd(i,e){return resolveIndex(i,e,e)}function resolveIndex(i,e,t){return i===void 0?t:isNeg(i)?e===1/0?e:Math.max(0,e+i)|0:e===void 0||e===i?i:Math.min(e,i)|0}function isNeg(i){return i<0||i===0&&1/i===-1/0}var IS_COLLECTION_SYMBOL="@@__IMMUTABLE_ITERABLE__@@";function isCollection(i){return!!(i&&i[IS_COLLECTION_SYMBOL])}var IS_KEYED_SYMBOL="@@__IMMUTABLE_KEYED__@@";function isKeyed(i){return!!(i&&i[IS_KEYED_SYMBOL])}var IS_INDEXED_SYMBOL="@@__IMMUTABLE_INDEXED__@@";function isIndexed(i){return!!(i&&i[IS_INDEXED_SYMBOL])}function isAssociative(i){return isKeyed(i)||isIndexed(i)}var Collection=function(e){return isCollection(e)?e:Seq(e)},KeyedCollection=(function(i){function e(t){return isKeyed(t)?t:KeyedSeq(t)}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e})(Collection),IndexedCollection=(function(i){function e(t){return isIndexed(t)?t:IndexedSeq(t)}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e})(Collection),SetCollection=(function(i){function e(t){return isCollection(t)&&!isAssociative(t)?t:SetSeq(t)}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e})(Collection);Collection.Keyed=KeyedCollection,Collection.Indexed=IndexedCollection,Collection.Set=SetCollection;var IS_SEQ_SYMBOL="@@__IMMUTABLE_SEQ__@@";function isSeq(i){return!!(i&&i[IS_SEQ_SYMBOL])}var IS_RECORD_SYMBOL="@@__IMMUTABLE_RECORD__@@";function isRecord$2(i){return!!(i&&i[IS_RECORD_SYMBOL])}function isImmutable(i){return isCollection(i)||isRecord$2(i)}var IS_ORDERED_SYMBOL="@@__IMMUTABLE_ORDERED__@@";function isOrdered(i){return!!(i&&i[IS_ORDERED_SYMBOL])}var ITERATE_KEYS=0,ITERATE_VALUES=1,ITERATE_ENTRIES=2,REAL_ITERATOR_SYMBOL=typeof Symbol=="function"&&Symbol.iterator,FAUX_ITERATOR_SYMBOL="@@iterator",ITERATOR_SYMBOL=REAL_ITERATOR_SYMBOL||FAUX_ITERATOR_SYMBOL,Iterator=function(e){this.next=e};Iterator.prototype.toString=function(){return"[Iterator]"},Iterator.KEYS=ITERATE_KEYS,Iterator.VALUES=ITERATE_VALUES,Iterator.ENTRIES=ITERATE_ENTRIES,Iterator.prototype.inspect=Iterator.prototype.toSource=function(){return this.toString()},Iterator.prototype[ITERATOR_SYMBOL]=function(){return this};function iteratorValue(i,e,t,n){var s=i===ITERATE_KEYS?e:i===ITERATE_VALUES?t:[e,t];return n?n.value=s:n={value:s,done:!1},n}function iteratorDone(){return{value:void 0,done:!0}}function hasIterator(i){return Array.isArray(i)?!0:!!getIteratorFn(i)}function isIterator(i){return i&&typeof i.next=="function"}function getIterator(i){var e=getIteratorFn(i);return e&&e.call(i)}function getIteratorFn(i){var e=i&&(REAL_ITERATOR_SYMBOL&&i[REAL_ITERATOR_SYMBOL]||i[FAUX_ITERATOR_SYMBOL]);if(typeof e=="function")return e}function isEntriesIterable(i){var e=getIteratorFn(i);return e&&e===i.entries}function isKeysIterable(i){var e=getIteratorFn(i);return e&&e===i.keys}var hasOwnProperty=Object.prototype.hasOwnProperty;function isArrayLike(i){return Array.isArray(i)||typeof i=="string"?!0:i&&typeof i=="object"&&Number.isInteger(i.length)&&i.length>=0&&(i.length===0?Object.keys(i).length===1:i.hasOwnProperty(i.length-1))}var Seq=(function(i){function e(t){return t==null?emptySequence():isImmutable(t)?t.toSeq():seqFromValue(t)}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.toSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq {","}")},e.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},e.prototype.__iterate=function(n,s){var o=this._cache;if(o){for(var a=o.length,l=0;l!==a;){var c=o[s?a-++l:l++];if(n(c[1],c[0],this)===!1)break}return l}return this.__iterateUncached(n,s)},e.prototype.__iterator=function(n,s){var o=this._cache;if(o){var a=o.length,l=0;return new Iterator(function(){if(l===a)return iteratorDone();var c=o[s?a-++l:l++];return iteratorValue(n,c[0],c[1])})}return this.__iteratorUncached(n,s)},e})(Collection),KeyedSeq=(function(i){function e(t){return t==null?emptySequence().toKeyedSeq():isCollection(t)?isKeyed(t)?t.toSeq():t.fromEntrySeq():isRecord$2(t)?t.toSeq():keyedSeqFromValue(t)}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.toKeyedSeq=function(){return this},e})(Seq),IndexedSeq=(function(i){function e(t){return t==null?emptySequence():isCollection(t)?isKeyed(t)?t.entrySeq():t.toIndexedSeq():isRecord$2(t)?t.toSeq().entrySeq():indexedSeqFromValue(t)}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toIndexedSeq=function(){return this},e.prototype.toString=function(){return this.__toString("Seq [","]")},e})(Seq),SetSeq=(function(i){function e(t){return(isCollection(t)&&!isAssociative(t)?t:IndexedSeq(t)).toSetSeq()}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.of=function(){return e(arguments)},e.prototype.toSetSeq=function(){return this},e})(Seq);Seq.isSeq=isSeq,Seq.Keyed=KeyedSeq,Seq.Set=SetSeq,Seq.Indexed=IndexedSeq,Seq.prototype[IS_SEQ_SYMBOL]=!0;var ArraySeq=(function(i){function e(t){this._array=t,this.size=t.length}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.get=function(n,s){return this.has(n)?this._array[wrapIndex(this,n)]:s},e.prototype.__iterate=function(n,s){for(var o=this._array,a=o.length,l=0;l!==a;){var c=s?a-++l:l++;if(n(o[c],c,this)===!1)break}return l},e.prototype.__iterator=function(n,s){var o=this._array,a=o.length,l=0;return new Iterator(function(){if(l===a)return iteratorDone();var c=s?a-++l:l++;return iteratorValue(n,c,o[c])})},e})(IndexedSeq),ObjectSeq=(function(i){function e(t){var n=Object.keys(t).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]);this._object=t,this._keys=n,this.size=n.length}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.get=function(n,s){return s!==void 0&&!this.has(n)?s:this._object[n]},e.prototype.has=function(n){return hasOwnProperty.call(this._object,n)},e.prototype.__iterate=function(n,s){for(var o=this._object,a=this._keys,l=a.length,c=0;c!==l;){var u=a[s?l-++c:c++];if(n(o[u],u,this)===!1)break}return c},e.prototype.__iterator=function(n,s){var o=this._object,a=this._keys,l=a.length,c=0;return new Iterator(function(){if(c===l)return iteratorDone();var u=a[s?l-++c:c++];return iteratorValue(n,u,o[u])})},e})(KeyedSeq);ObjectSeq.prototype[IS_ORDERED_SYMBOL]=!0;var CollectionSeq=(function(i){function e(t){this._collection=t,this.size=t.length||t.size}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(n,s){if(s)return this.cacheResult().__iterate(n,s);var o=this._collection,a=getIterator(o),l=0;if(isIterator(a))for(var c;!(c=a.next()).done&&n(c.value,l++,this)!==!1;);return l},e.prototype.__iteratorUncached=function(n,s){if(s)return this.cacheResult().__iterator(n,s);var o=this._collection,a=getIterator(o);if(!isIterator(a))return new Iterator(iteratorDone);var l=0;return new Iterator(function(){var c=a.next();return c.done?c:iteratorValue(n,l++,c.value)})},e})(IndexedSeq),EMPTY_SEQ;function emptySequence(){return EMPTY_SEQ||(EMPTY_SEQ=new ArraySeq([]))}function keyedSeqFromValue(i){var e=maybeIndexedSeqFromValue(i);if(e)return e.fromEntrySeq();if(typeof i=="object")return new ObjectSeq(i);throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: "+i)}function indexedSeqFromValue(i){var e=maybeIndexedSeqFromValue(i);if(e)return e;throw new TypeError("Expected Array or collection object of values: "+i)}function seqFromValue(i){var e=maybeIndexedSeqFromValue(i);if(e)return isEntriesIterable(i)?e.fromEntrySeq():isKeysIterable(i)?e.toSetSeq():e;if(typeof i=="object")return new ObjectSeq(i);throw new TypeError("Expected Array or collection object of values, or keyed object: "+i)}function maybeIndexedSeqFromValue(i){return isArrayLike(i)?new ArraySeq(i):hasIterator(i)?new CollectionSeq(i):void 0}var IS_MAP_SYMBOL="@@__IMMUTABLE_MAP__@@";function isMap$1(i){return!!(i&&i[IS_MAP_SYMBOL])}function isOrderedMap(i){return isMap$1(i)&&isOrdered(i)}function isValueObject(i){return!!(i&&typeof i.equals=="function"&&typeof i.hashCode=="function")}function is(i,e){if(i===e||i!==i&&e!==e)return!0;if(!i||!e)return!1;if(typeof i.valueOf=="function"&&typeof e.valueOf=="function"){if(i=i.valueOf(),e=e.valueOf(),i===e||i!==i&&e!==e)return!0;if(!i||!e)return!1}return!!(isValueObject(i)&&isValueObject(e)&&i.equals(e))}var imul=typeof Math.imul=="function"&&Math.imul(4294967295,2)===-2?Math.imul:function(e,t){e|=0,t|=0;var n=e&65535,s=t&65535;return n*s+((e>>>16)*s+n*(t>>>16)<<16>>>0)|0};function smi(i){return i>>>1&1073741824|i&3221225471}var defaultValueOf=Object.prototype.valueOf;function hash(i){if(i==null)return hashNullish(i);if(typeof i.hashCode=="function")return smi(i.hashCode(i));var e=valueOf(i);if(e==null)return hashNullish(e);switch(typeof e){case"boolean":return e?1108378657:1108378656;case"number":return hashNumber(e);case"string":return e.length>STRING_HASH_CACHE_MIN_STRLEN?cachedHashString(e):hashString(e);case"object":case"function":return hashJSObj(e);case"symbol":return hashSymbol(e);default:if(typeof e.toString=="function")return hashString(e.toString());throw new Error("Value type "+typeof e+" cannot be hashed.")}}function hashNullish(i){return i===null?1108378658:1108378659}function hashNumber(i){if(i!==i||i===1/0)return 0;var e=i|0;for(e!==i&&(e^=i*4294967295);i>4294967295;)i/=4294967295,e^=i;return smi(e)}function cachedHashString(i){var e=stringHashCache[i];return e===void 0&&(e=hashString(i),STRING_HASH_CACHE_SIZE===STRING_HASH_CACHE_MAX_SIZE&&(STRING_HASH_CACHE_SIZE=0,stringHashCache={}),STRING_HASH_CACHE_SIZE++,stringHashCache[i]=e),e}function hashString(i){for(var e=0,t=0;t<i.length;t++)e=31*e+i.charCodeAt(t)|0;return smi(e)}function hashSymbol(i){var e=symbolMap[i];return e!==void 0||(e=nextHash(),symbolMap[i]=e),e}function hashJSObj(i){var e;if(usingWeakMap&&(e=weakMap.get(i),e!==void 0)||(e=i[UID_HASH_KEY],e!==void 0)||!canDefineProperty&&(e=i.propertyIsEnumerable&&i.propertyIsEnumerable[UID_HASH_KEY],e!==void 0||(e=getIENodeHash(i),e!==void 0)))return e;if(e=nextHash(),usingWeakMap)weakMap.set(i,e);else{if(isExtensible!==void 0&&isExtensible(i)===!1)throw new Error("Non-extensible objects are not allowed as keys.");if(canDefineProperty)Object.defineProperty(i,UID_HASH_KEY,{enumerable:!1,configurable:!1,writable:!1,value:e});else if(i.propertyIsEnumerable!==void 0&&i.propertyIsEnumerable===i.constructor.prototype.propertyIsEnumerable)i.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},i.propertyIsEnumerable[UID_HASH_KEY]=e;else if(i.nodeType!==void 0)i[UID_HASH_KEY]=e;else throw new Error("Unable to set a non-enumerable property on object.")}return e}var isExtensible=Object.isExtensible,canDefineProperty=(function(){try{return Object.defineProperty({},"@",{}),!0}catch{return!1}})();function getIENodeHash(i){if(i&&i.nodeType>0)switch(i.nodeType){case 1:return i.uniqueID;case 9:return i.documentElement&&i.documentElement.uniqueID}}function valueOf(i){return i.valueOf!==defaultValueOf&&typeof i.valueOf=="function"?i.valueOf(i):i}function nextHash(){var i=++_objHashUID;return _objHashUID&1073741824&&(_objHashUID=0),i}var usingWeakMap=typeof WeakMap=="function",weakMap;usingWeakMap&&(weakMap=new WeakMap);var symbolMap=Object.create(null),_objHashUID=0,UID_HASH_KEY="__immutablehash__";typeof Symbol=="function"&&(UID_HASH_KEY=Symbol(UID_HASH_KEY));var STRING_HASH_CACHE_MIN_STRLEN=16,STRING_HASH_CACHE_MAX_SIZE=255,STRING_HASH_CACHE_SIZE=0,stringHashCache={},ToKeyedSequence=(function(i){function e(t,n){this._iter=t,this._useKeys=n,this.size=t.size}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.get=function(n,s){return this._iter.get(n,s)},e.prototype.has=function(n){return this._iter.has(n)},e.prototype.valueSeq=function(){return this._iter.valueSeq()},e.prototype.reverse=function(){var n=this,s=reverseFactory(this,!0);return this._useKeys||(s.valueSeq=function(){return n._iter.toSeq().reverse()}),s},e.prototype.map=function(n,s){var o=this,a=mapFactory(this,n,s);return this._useKeys||(a.valueSeq=function(){return o._iter.toSeq().map(n,s)}),a},e.prototype.__iterate=function(n,s){var o=this;return this._iter.__iterate(function(a,l){return n(a,l,o)},s)},e.prototype.__iterator=function(n,s){return this._iter.__iterator(n,s)},e})(KeyedSeq);ToKeyedSequence.prototype[IS_ORDERED_SYMBOL]=!0;var ToIndexedSequence=(function(i){function e(t){this._iter=t,this.size=t.size}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.includes=function(n){return this._iter.includes(n)},e.prototype.__iterate=function(n,s){var o=this,a=0;return s&&ensureSize(this),this._iter.__iterate(function(l){return n(l,s?o.size-++a:a++,o)},s)},e.prototype.__iterator=function(n,s){var o=this,a=this._iter.__iterator(ITERATE_VALUES,s),l=0;return s&&ensureSize(this),new Iterator(function(){var c=a.next();return c.done?c:iteratorValue(n,s?o.size-++l:l++,c.value,c)})},e})(IndexedSeq),ToSetSequence=(function(i){function e(t){this._iter=t,this.size=t.size}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.has=function(n){return this._iter.includes(n)},e.prototype.__iterate=function(n,s){var o=this;return this._iter.__iterate(function(a){return n(a,a,o)},s)},e.prototype.__iterator=function(n,s){var o=this._iter.__iterator(ITERATE_VALUES,s);return new Iterator(function(){var a=o.next();return a.done?a:iteratorValue(n,a.value,a.value,a)})},e})(SetSeq),FromEntriesSequence=(function(i){function e(t){this._iter=t,this.size=t.size}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.entrySeq=function(){return this._iter.toSeq()},e.prototype.__iterate=function(n,s){var o=this;return this._iter.__iterate(function(a){if(a){validateEntry(a);var l=isCollection(a);return n(l?a.get(1):a[1],l?a.get(0):a[0],o)}},s)},e.prototype.__iterator=function(n,s){var o=this._iter.__iterator(ITERATE_VALUES,s);return new Iterator(function(){for(;;){var a=o.next();if(a.done)return a;var l=a.value;if(l){validateEntry(l);var c=isCollection(l);return iteratorValue(n,c?l.get(0):l[0],c?l.get(1):l[1],a)}}})},e})(KeyedSeq);ToIndexedSequence.prototype.cacheResult=ToKeyedSequence.prototype.cacheResult=ToSetSequence.prototype.cacheResult=FromEntriesSequence.prototype.cacheResult=cacheResultThrough;function flipFactory(i){var e=makeSequence(i);return e._iter=i,e.size=i.size,e.flip=function(){return i},e.reverse=function(){var t=i.reverse.apply(this);return t.flip=function(){return i.reverse()},t},e.has=function(t){return i.includes(t)},e.includes=function(t){return i.has(t)},e.cacheResult=cacheResultThrough,e.__iterateUncached=function(t,n){var s=this;return i.__iterate(function(o,a){return t(a,o,s)!==!1},n)},e.__iteratorUncached=function(t,n){if(t===ITERATE_ENTRIES){var s=i.__iterator(t,n);return new Iterator(function(){var o=s.next();if(!o.done){var a=o.value[0];o.value[0]=o.value[1],o.value[1]=a}return o})}return i.__iterator(t===ITERATE_VALUES?ITERATE_KEYS:ITERATE_VALUES,n)},e}function mapFactory(i,e,t){var n=makeSequence(i);return n.size=i.size,n.has=function(s){return i.has(s)},n.get=function(s,o){var a=i.get(s,NOT_SET);return a===NOT_SET?o:e.call(t,a,s,i)},n.__iterateUncached=function(s,o){var a=this;return i.__iterate(function(l,c,u){return s(e.call(t,l,c,u),c,a)!==!1},o)},n.__iteratorUncached=function(s,o){var a=i.__iterator(ITERATE_ENTRIES,o);return new Iterator(function(){var l=a.next();if(l.done)return l;var c=l.value,u=c[0];return iteratorValue(s,u,e.call(t,c[1],u,i),l)})},n}function reverseFactory(i,e){var t=this,n=makeSequence(i);return n._iter=i,n.size=i.size,n.reverse=function(){return i},i.flip&&(n.flip=function(){var s=flipFactory(i);return s.reverse=function(){return i.flip()},s}),n.get=function(s,o){return i.get(e?s:-1-s,o)},n.has=function(s){return i.has(e?s:-1-s)},n.includes=function(s){return i.includes(s)},n.cacheResult=cacheResultThrough,n.__iterate=function(s,o){var a=this,l=0;return o&&ensureSize(i),i.__iterate(function(c,u){return s(c,e?u:o?a.size-++l:l++,a)},!o)},n.__iterator=function(s,o){var a=0;o&&ensureSize(i);var l=i.__iterator(ITERATE_ENTRIES,!o);return new Iterator(function(){var c=l.next();if(c.done)return c;var u=c.value;return iteratorValue(s,e?u[0]:o?t.size-++a:a++,u[1],c)})},n}function filterFactory(i,e,t,n){var s=makeSequence(i);return n&&(s.has=function(o){var a=i.get(o,NOT_SET);return a!==NOT_SET&&!!e.call(t,a,o,i)},s.get=function(o,a){var l=i.get(o,NOT_SET);return l!==NOT_SET&&e.call(t,l,o,i)?l:a}),s.__iterateUncached=function(o,a){var l=this,c=0;return i.__iterate(function(u,h,d){if(e.call(t,u,h,d))return c++,o(u,n?h:c-1,l)},a),c},s.__iteratorUncached=function(o,a){var l=i.__iterator(ITERATE_ENTRIES,a),c=0;return new Iterator(function(){for(;;){var u=l.next();if(u.done)return u;var h=u.value,d=h[0],p=h[1];if(e.call(t,p,d,i))return iteratorValue(o,n?d:c++,p,u)}})},s}function countByFactory(i,e,t){var n=Map$1().asMutable();return i.__iterate(function(s,o){n.update(e.call(t,s,o,i),0,function(a){return a+1})}),n.asImmutable()}function groupByFactory(i,e,t){var n=isKeyed(i),s=(isOrdered(i)?OrderedMap():Map$1()).asMutable();i.__iterate(function(a,l){s.update(e.call(t,a,l,i),function(c){return c=c||[],c.push(n?[l,a]:a),c})});var o=collectionClass(i);return s.map(function(a){return reify(i,o(a))}).asImmutable()}function partitionFactory(i,e,t){var n=isKeyed(i),s=[[],[]];i.__iterate(function(a,l){s[e.call(t,a,l,i)?1:0].push(n?[l,a]:a)});var o=collectionClass(i);return s.map(function(a){return reify(i,o(a))})}function sliceFactory(i,e,t,n){var s=i.size;if(wholeSlice(e,t,s))return i;if(typeof s>"u"&&(e<0||t<0))return sliceFactory(i.toSeq().cacheResult(),e,t,n);var o=resolveBegin(e,s),a=resolveEnd(t,s),l=a-o,c;l===l&&(c=l<0?0:l);var u=makeSequence(i);return u.size=c===0?c:i.size&&c||void 0,!n&&isSeq(i)&&c>=0&&(u.get=function(h,d){return h=wrapIndex(this,h),h>=0&&h<c?i.get(h+o,d):d}),u.__iterateUncached=function(h,d){var p=this;if(c===0)return 0;if(d)return this.cacheResult().__iterate(h,d);var f=0,g=!0,_=0;return i.__iterate(function(x,y){if(!(g&&(g=f++<o)))return _++,h(x,n?y:_-1,p)!==!1&&_!==c}),_},u.__iteratorUncached=function(h,d){if(c!==0&&d)return this.cacheResult().__iterator(h,d);if(c===0)return new Iterator(iteratorDone);var p=i.__iterator(h,d),f=0,g=0;return new Iterator(function(){for(;f++<o;)p.next();if(++g>c)return iteratorDone();var _=p.next();return n||h===ITERATE_VALUES||_.done?_:h===ITERATE_KEYS?iteratorValue(h,g-1,void 0,_):iteratorValue(h,g-1,_.value[1],_)})},u}function takeWhileFactory(i,e,t){var n=makeSequence(i);return n.__iterateUncached=function(s,o){var a=this;if(o)return this.cacheResult().__iterate(s,o);var l=0;return i.__iterate(function(c,u,h){return e.call(t,c,u,h)&&++l&&s(c,u,a)}),l},n.__iteratorUncached=function(s,o){var a=this;if(o)return this.cacheResult().__iterator(s,o);var l=i.__iterator(ITERATE_ENTRIES,o),c=!0;return new Iterator(function(){if(!c)return iteratorDone();var u=l.next();if(u.done)return u;var h=u.value,d=h[0],p=h[1];return e.call(t,p,d,a)?s===ITERATE_ENTRIES?u:iteratorValue(s,d,p,u):(c=!1,iteratorDone())})},n}function skipWhileFactory(i,e,t,n){var s=makeSequence(i);return s.__iterateUncached=function(o,a){var l=this;if(a)return this.cacheResult().__iterate(o,a);var c=!0,u=0;return i.__iterate(function(h,d,p){if(!(c&&(c=e.call(t,h,d,p))))return u++,o(h,n?d:u-1,l)}),u},s.__iteratorUncached=function(o,a){var l=this;if(a)return this.cacheResult().__iterator(o,a);var c=i.__iterator(ITERATE_ENTRIES,a),u=!0,h=0;return new Iterator(function(){var d,p,f;do{if(d=c.next(),d.done)return n||o===ITERATE_VALUES?d:o===ITERATE_KEYS?iteratorValue(o,h++,void 0,d):iteratorValue(o,h++,d.value[1],d);var g=d.value;p=g[0],f=g[1],u&&(u=e.call(t,f,p,l))}while(u);return o===ITERATE_ENTRIES?d:iteratorValue(o,p,f,d)})},s}var ConcatSeq=(function(i){function e(t){this._wrappedIterables=t.flatMap(function(n){return n._wrappedIterables?n._wrappedIterables:[n]}),this.size=this._wrappedIterables.reduce(function(n,s){if(n!==void 0){var o=s.size;if(o!==void 0)return n+o}},0),this[IS_KEYED_SYMBOL]=this._wrappedIterables[0][IS_KEYED_SYMBOL],this[IS_INDEXED_SYMBOL]=this._wrappedIterables[0][IS_INDEXED_SYMBOL],this[IS_ORDERED_SYMBOL]=this._wrappedIterables[0][IS_ORDERED_SYMBOL]}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.__iterateUncached=function(n,s){if(this._wrappedIterables.length!==0){if(s)return this.cacheResult().__iterate(n,s);for(var o=0,a=isKeyed(this),l=a?ITERATE_ENTRIES:ITERATE_VALUES,c=this._wrappedIterables[o].__iterator(l,s),u=!0,h=0;u;){for(var d=c.next();d.done;){if(o++,o===this._wrappedIterables.length)return h;c=this._wrappedIterables[o].__iterator(l,s),d=c.next()}var p=a?n(d.value[1],d.value[0],this):n(d.value,h,this);u=p!==!1,h++}return h}},e.prototype.__iteratorUncached=function(n,s){var o=this;if(this._wrappedIterables.length===0)return new Iterator(iteratorDone);if(s)return this.cacheResult().__iterator(n,s);var a=0,l=this._wrappedIterables[a].__iterator(n,s);return new Iterator(function(){for(var c=l.next();c.done;){if(a++,a===o._wrappedIterables.length)return c;l=o._wrappedIterables[a].__iterator(n,s),c=l.next()}return c})},e})(Seq);function concatFactory(i,e){var t=isKeyed(i),n=[i].concat(e).map(function(o){return isCollection(o)?t&&(o=KeyedCollection(o)):o=t?keyedSeqFromValue(o):indexedSeqFromValue(Array.isArray(o)?o:[o]),o}).filter(function(o){return o.size!==0});if(n.length===0)return i;if(n.length===1){var s=n[0];if(s===i||t&&isKeyed(s)||isIndexed(i)&&isIndexed(s))return s}return new ConcatSeq(n)}function flattenFactory(i,e,t){var n=makeSequence(i);return n.__iterateUncached=function(s,o){if(o)return this.cacheResult().__iterate(s,o);var a=0,l=!1;function c(u,h){u.__iterate(function(d,p){return(!e||h<e)&&isCollection(d)?c(d,h+1):(a++,s(d,t?p:a-1,n)===!1&&(l=!0)),!l},o)}return c(i,0),a},n.__iteratorUncached=function(s,o){if(o)return this.cacheResult().__iterator(s,o);var a=i.__iterator(s,o),l=[],c=0;return new Iterator(function(){for(;a;){var u=a.next();if(u.done!==!1){a=l.pop();continue}var h=u.value;if(s===ITERATE_ENTRIES&&(h=h[1]),(!e||l.length<e)&&isCollection(h))l.push(a),a=h.__iterator(s,o);else return t?u:iteratorValue(s,c++,h,u)}return iteratorDone()})},n}function flatMapFactory(i,e,t){var n=collectionClass(i);return i.toSeq().map(function(s,o){return n(e.call(t,s,o,i))}).flatten(!0)}function interposeFactory(i,e){var t=makeSequence(i);return t.size=i.size&&i.size*2-1,t.__iterateUncached=function(n,s){var o=this,a=0;return i.__iterate(function(l){return(!a||n(e,a++,o)!==!1)&&n(l,a++,o)!==!1},s),a},t.__iteratorUncached=function(n,s){var o=i.__iterator(ITERATE_VALUES,s),a=0,l;return new Iterator(function(){return(!l||a%2)&&(l=o.next(),l.done)?l:a%2?iteratorValue(n,a++,e):iteratorValue(n,a++,l.value,l)})},t}function sortFactory(i,e,t){e||(e=defaultComparator);var n=isKeyed(i),s=0,o=i.toSeq().map(function(a,l){return[l,a,s++,t?t(a,l,i):a]}).valueSeq().toArray();return o.sort(function(a,l){return e(a[3],l[3])||a[2]-l[2]}).forEach(n?function(a,l){o[l].length=2}:function(a,l){o[l]=a[1]}),n?KeyedSeq(o):isIndexed(i)?IndexedSeq(o):SetSeq(o)}function maxFactory(i,e,t){if(e||(e=defaultComparator),t){var n=i.toSeq().map(function(s,o){return[s,t(s,o,i)]}).reduce(function(s,o){return maxCompare(e,s[1],o[1])?o:s});return n&&n[0]}return i.reduce(function(s,o){return maxCompare(e,s,o)?o:s})}function maxCompare(i,e,t){var n=i(t,e);return n===0&&t!==e&&(t==null||t!==t)||n>0}function zipWithFactory(i,e,t,n){var s=makeSequence(i),o=new ArraySeq(t).map(function(a){return a.size});return s.size=n?o.max():o.min(),s.__iterate=function(a,l){for(var c=this.__iterator(ITERATE_VALUES,l),u,h=0;!(u=c.next()).done&&a(u.value,h++,this)!==!1;);return h},s.__iteratorUncached=function(a,l){var c=t.map(function(d){return d=Collection(d),getIterator(l?d.reverse():d)}),u=0,h=!1;return new Iterator(function(){var d;return h||(d=c.map(function(p){return p.next()}),h=n?d.every(function(p){return p.done}):d.some(function(p){return p.done})),h?iteratorDone():iteratorValue(a,u++,e.apply(null,d.map(function(p){return p.value})))})},s}function reify(i,e){return i===e?i:isSeq(i)?e:i.constructor(e)}function validateEntry(i){if(i!==Object(i))throw new TypeError("Expected [K, V] tuple: "+i)}function collectionClass(i){return isKeyed(i)?KeyedCollection:isIndexed(i)?IndexedCollection:SetCollection}function makeSequence(i){return Object.create((isKeyed(i)?KeyedSeq:isIndexed(i)?IndexedSeq:SetSeq).prototype)}function cacheResultThrough(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):Seq.prototype.cacheResult.call(this)}function defaultComparator(i,e){return i===void 0&&e===void 0?0:i===void 0?1:e===void 0?-1:i>e?1:i<e?-1:0}function arrCopy(i,e){e=e||0;for(var t=Math.max(0,i.length-e),n=new Array(t),s=0;s<t;s++)n[s]=i[s+e];return n}function invariant(i,e){if(!i)throw new Error(e)}function assertNotInfinite(i){invariant(i!==1/0,"Cannot perform this action with an infinite size.")}function coerceKeyPath(i){if(isArrayLike(i)&&typeof i!="string")return i;if(isOrdered(i))return i.toArray();throw new TypeError("Invalid keyPath: expected Ordered Collection or Array: "+i)}var toString$1=Object.prototype.toString;function isPlainObject(i){if(!i||typeof i!="object"||toString$1.call(i)!=="[object Object]")return!1;var e=Object.getPrototypeOf(i);if(e===null)return!0;for(var t=e,n=Object.getPrototypeOf(e);n!==null;)t=n,n=Object.getPrototypeOf(t);return t===e}function isDataStructure(i){return typeof i=="object"&&(isImmutable(i)||Array.isArray(i)||isPlainObject(i))}function quoteString(i){try{return typeof i=="string"?JSON.stringify(i):String(i)}catch{return JSON.stringify(i)}}function has$1(i,e){return isImmutable(i)?i.has(e):isDataStructure(i)&&hasOwnProperty.call(i,e)}function get(i,e,t){return isImmutable(i)?i.get(e,t):has$1(i,e)?typeof i.get=="function"?i.get(e):i[e]:t}function shallowCopy(i){if(Array.isArray(i))return arrCopy(i);var e={};for(var t in i)hasOwnProperty.call(i,t)&&(e[t]=i[t]);return e}function remove(i,e){if(!isDataStructure(i))throw new TypeError("Cannot update non-data-structure value: "+i);if(isImmutable(i)){if(!i.remove)throw new TypeError("Cannot update immutable value without .remove() method: "+i);return i.remove(e)}if(!hasOwnProperty.call(i,e))return i;var t=shallowCopy(i);return Array.isArray(t)?t.splice(e,1):delete t[e],t}function set$1(i,e,t){if(!isDataStructure(i))throw new TypeError("Cannot update non-data-structure value: "+i);if(isImmutable(i)){if(!i.set)throw new TypeError("Cannot update immutable value without .set() method: "+i);return i.set(e,t)}if(hasOwnProperty.call(i,e)&&t===i[e])return i;var n=shallowCopy(i);return n[e]=t,n}function updateIn$1(i,e,t,n){n||(n=t,t=void 0);var s=updateInDeeply(isImmutable(i),i,coerceKeyPath(e),0,t,n);return s===NOT_SET?t:s}function updateInDeeply(i,e,t,n,s,o){var a=e===NOT_SET;if(n===t.length){var l=a?s:e,c=o(l);return c===l?e:c}if(!a&&!isDataStructure(e))throw new TypeError("Cannot update within non-data-structure value in path ["+Array.from(t).slice(0,n).map(quoteString)+"]: "+e);var u=t[n],h=a?NOT_SET:get(e,u,NOT_SET),d=updateInDeeply(h===NOT_SET?i:isImmutable(h),h,t,n+1,s,o);return d===h?e:d===NOT_SET?remove(e,u):set$1(a?i?emptyMap():{}:e,u,d)}function setIn$1(i,e,t){return updateIn$1(i,e,NOT_SET,function(){return t})}function setIn(i,e){return setIn$1(this,i,e)}function removeIn(i,e){return updateIn$1(i,e,function(){return NOT_SET})}function deleteIn(i){return removeIn(this,i)}function update$1(i,e,t,n){return updateIn$1(i,[e],t,n)}function update(i,e,t){return arguments.length===1?i(this):update$1(this,i,e,t)}function updateIn(i,e,t){return updateIn$1(this,i,e,t)}function merge$1(){for(var i=[],e=arguments.length;e--;)i[e]=arguments[e];return mergeIntoKeyedWith(this,i)}function mergeWith$1(i){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];if(typeof i!="function")throw new TypeError("Invalid merger function: "+i);return mergeIntoKeyedWith(this,e,i)}function mergeIntoKeyedWith(i,e,t){for(var n=[],s=0;s<e.length;s++){var o=KeyedCollection(e[s]);o.size!==0&&n.push(o)}return n.length===0?i:i.toSeq().size===0&&!i.__ownerID&&n.length===1?isRecord$2(i)?i:i.constructor(n[0]):i.withMutations(function(a){for(var l=t?function(u,h){update$1(a,h,NOT_SET,function(d){return d===NOT_SET?u:t(d,u,h)})}:function(u,h){a.set(h,u)},c=0;c<n.length;c++)n[c].forEach(l)})}function merge(i){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return mergeWithSources(i,e)}function mergeWith(i,e){for(var t=[],n=arguments.length-2;n-- >0;)t[n]=arguments[n+2];return mergeWithSources(e,t,i)}function mergeDeep$1(i){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return mergeDeepWithSources(i,e)}function mergeDeepWith$1(i,e){for(var t=[],n=arguments.length-2;n-- >0;)t[n]=arguments[n+2];return mergeDeepWithSources(e,t,i)}function mergeDeepWithSources(i,e,t){return mergeWithSources(i,e,deepMergerWith(t))}function mergeWithSources(i,e,t){if(!isDataStructure(i))throw new TypeError("Cannot merge into non-data-structure value: "+i);if(isImmutable(i))return typeof t=="function"&&i.mergeWith?i.mergeWith.apply(i,[t].concat(e)):i.merge?i.merge.apply(i,e):i.concat.apply(i,e);for(var n=Array.isArray(i),s=i,o=n?IndexedCollection:KeyedCollection,a=n?function(c){s===i&&(s=shallowCopy(s)),s.push(c)}:function(c,u){var h=hasOwnProperty.call(s,u),d=h&&t?t(s[u],c,u):c;(!h||d!==s[u])&&(s===i&&(s=shallowCopy(s)),s[u]=d)},l=0;l<e.length;l++)o(e[l]).forEach(a);return s}function deepMergerWith(i){function e(t,n,s){return isDataStructure(t)&&isDataStructure(n)&&areMergeable(t,n)?mergeWithSources(t,[n],e):i?i(t,n,s):n}return e}function areMergeable(i,e){var t=Seq(i),n=Seq(e);return isIndexed(t)===isIndexed(n)&&isKeyed(t)===isKeyed(n)}function mergeDeep(){for(var i=[],e=arguments.length;e--;)i[e]=arguments[e];return mergeDeepWithSources(this,i)}function mergeDeepWith(i){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return mergeDeepWithSources(this,e,i)}function mergeIn(i){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return updateIn$1(this,i,emptyMap(),function(n){return mergeWithSources(n,e)})}function mergeDeepIn(i){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return updateIn$1(this,i,emptyMap(),function(n){return mergeDeepWithSources(n,e)})}function withMutations(i){var e=this.asMutable();return i(e),e.wasAltered()?e.__ensureOwner(this.__ownerID):this}function asMutable(){return this.__ownerID?this:this.__ensureOwner(new OwnerID)}function asImmutable(){return this.__ensureOwner()}function wasAltered(){return this.__altered}var Map$1=(function(i){function e(t){return t==null?emptyMap():isMap$1(t)&&!isOrdered(t)?t:emptyMap().withMutations(function(n){var s=i(t);assertNotInfinite(s.size),s.forEach(function(o,a){return n.set(a,o)})})}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.__toString("Map {","}")},e.prototype.get=function(n,s){return this._root?this._root.get(0,void 0,n,s):s},e.prototype.set=function(n,s){return updateMap(this,n,s)},e.prototype.remove=function(n){return updateMap(this,n,NOT_SET)},e.prototype.deleteAll=function(n){var s=Collection(n);return s.size===0?this:this.withMutations(function(o){s.forEach(function(a){return o.remove(a)})})},e.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):emptyMap()},e.prototype.sort=function(n){return OrderedMap(sortFactory(this,n))},e.prototype.sortBy=function(n,s){return OrderedMap(sortFactory(this,s,n))},e.prototype.map=function(n,s){var o=this;return this.withMutations(function(a){a.forEach(function(l,c){a.set(c,n.call(s,l,c,o))})})},e.prototype.__iterator=function(n,s){return new MapIterator(this,n,s)},e.prototype.__iterate=function(n,s){var o=this,a=0;return this._root&&this._root.iterate(function(l){return a++,n(l[1],l[0],o)},s),a},e.prototype.__ensureOwner=function(n){return n===this.__ownerID?this:n?makeMap(this.size,this._root,n,this.__hash):this.size===0?emptyMap():(this.__ownerID=n,this.__altered=!1,this)},e})(KeyedCollection);Map$1.isMap=isMap$1;var MapPrototype=Map$1.prototype;MapPrototype[IS_MAP_SYMBOL]=!0,MapPrototype[DELETE]=MapPrototype.remove,MapPrototype.removeAll=MapPrototype.deleteAll,MapPrototype.setIn=setIn,MapPrototype.removeIn=MapPrototype.deleteIn=deleteIn,MapPrototype.update=update,MapPrototype.updateIn=updateIn,MapPrototype.merge=MapPrototype.concat=merge$1,MapPrototype.mergeWith=mergeWith$1,MapPrototype.mergeDeep=mergeDeep,MapPrototype.mergeDeepWith=mergeDeepWith,MapPrototype.mergeIn=mergeIn,MapPrototype.mergeDeepIn=mergeDeepIn,MapPrototype.withMutations=withMutations,MapPrototype.wasAltered=wasAltered,MapPrototype.asImmutable=asImmutable,MapPrototype["@@transducer/init"]=MapPrototype.asMutable=asMutable,MapPrototype["@@transducer/step"]=function(i,e){return i.set(e[0],e[1])},MapPrototype["@@transducer/result"]=function(i){return i.asImmutable()};var ArrayMapNode=function(e,t){this.ownerID=e,this.entries=t};ArrayMapNode.prototype.get=function(e,t,n,s){for(var o=this.entries,a=0,l=o.length;a<l;a++)if(is(n,o[a][0]))return o[a][1];return s},ArrayMapNode.prototype.update=function(e,t,n,s,o,a,l){for(var c=o===NOT_SET,u=this.entries,h=0,d=u.length;h<d&&!is(s,u[h][0]);h++);var p=h<d;if(p?u[h][1]===o:c)return this;if(SetRef(l),(c||!p)&&SetRef(a),!(c&&u.length===1)){if(!p&&!c&&u.length>=MAX_ARRAY_MAP_SIZE)return createNodes(e,u,s,o);var f=e&&e===this.ownerID,g=f?u:arrCopy(u);return p?c?h===d-1?g.pop():g[h]=g.pop():g[h]=[s,o]:g.push([s,o]),f?(this.entries=g,this):new ArrayMapNode(e,g)}};var BitmapIndexedNode=function(e,t,n){this.ownerID=e,this.bitmap=t,this.nodes=n};BitmapIndexedNode.prototype.get=function(e,t,n,s){t===void 0&&(t=hash(n));var o=1<<((e===0?t:t>>>e)&MASK),a=this.bitmap;return(a&o)===0?s:this.nodes[popCount(a&o-1)].get(e+SHIFT,t,n,s)},BitmapIndexedNode.prototype.update=function(e,t,n,s,o,a,l){n===void 0&&(n=hash(s));var c=(t===0?n:n>>>t)&MASK,u=1<<c,h=this.bitmap,d=(h&u)!==0;if(!d&&o===NOT_SET)return this;var p=popCount(h&u-1),f=this.nodes,g=d?f[p]:void 0,_=updateNode(g,e,t+SHIFT,n,s,o,a,l);if(_===g)return this;if(!d&&_&&f.length>=MAX_BITMAP_INDEXED_SIZE)return expandNodes(e,f,h,c,_);if(d&&!_&&f.length===2&&isLeafNode(f[p^1]))return f[p^1];if(d&&_&&f.length===1&&isLeafNode(_))return _;var x=e&&e===this.ownerID,y=d?_?h:h^u:h|u,E=d?_?setAt(f,p,_,x):spliceOut(f,p,x):spliceIn(f,p,_,x);return x?(this.bitmap=y,this.nodes=E,this):new BitmapIndexedNode(e,y,E)};var HashArrayMapNode=function(e,t,n){this.ownerID=e,this.count=t,this.nodes=n};HashArrayMapNode.prototype.get=function(e,t,n,s){t===void 0&&(t=hash(n));var o=(e===0?t:t>>>e)&MASK,a=this.nodes[o];return a?a.get(e+SHIFT,t,n,s):s},HashArrayMapNode.prototype.update=function(e,t,n,s,o,a,l){n===void 0&&(n=hash(s));var c=(t===0?n:n>>>t)&MASK,u=o===NOT_SET,h=this.nodes,d=h[c];if(u&&!d)return this;var p=updateNode(d,e,t+SHIFT,n,s,o,a,l);if(p===d)return this;var f=this.count;if(!d)f++;else if(!p&&(f--,f<MIN_HASH_ARRAY_MAP_SIZE))return packNodes(e,h,f,c);var g=e&&e===this.ownerID,_=setAt(h,c,p,g);return g?(this.count=f,this.nodes=_,this):new HashArrayMapNode(e,f,_)};var HashCollisionNode=function(e,t,n){this.ownerID=e,this.keyHash=t,this.entries=n};HashCollisionNode.prototype.get=function(e,t,n,s){for(var o=this.entries,a=0,l=o.length;a<l;a++)if(is(n,o[a][0]))return o[a][1];return s},HashCollisionNode.prototype.update=function(e,t,n,s,o,a,l){n===void 0&&(n=hash(s));var c=o===NOT_SET;if(n!==this.keyHash)return c?this:(SetRef(l),SetRef(a),mergeIntoNode(this,e,t,n,[s,o]));for(var u=this.entries,h=0,d=u.length;h<d&&!is(s,u[h][0]);h++);var p=h<d;if(p?u[h][1]===o:c)return this;if(SetRef(l),(c||!p)&&SetRef(a),c&&d===2)return new ValueNode(e,this.keyHash,u[h^1]);var f=e&&e===this.ownerID,g=f?u:arrCopy(u);return p?c?h===d-1?g.pop():g[h]=g.pop():g[h]=[s,o]:g.push([s,o]),f?(this.entries=g,this):new HashCollisionNode(e,this.keyHash,g)};var ValueNode=function(e,t,n){this.ownerID=e,this.keyHash=t,this.entry=n};ValueNode.prototype.get=function(e,t,n,s){return is(n,this.entry[0])?this.entry[1]:s},ValueNode.prototype.update=function(e,t,n,s,o,a,l){var c=o===NOT_SET,u=is(s,this.entry[0]);if(u?o===this.entry[1]:c)return this;if(SetRef(l),c){SetRef(a);return}return u?e&&e===this.ownerID?(this.entry[1]=o,this):new ValueNode(e,this.keyHash,[s,o]):(SetRef(a),mergeIntoNode(this,e,t,hash(s),[s,o]))},ArrayMapNode.prototype.iterate=HashCollisionNode.prototype.iterate=function(i,e){for(var t=this.entries,n=0,s=t.length-1;n<=s;n++)if(i(t[e?s-n:n])===!1)return!1},BitmapIndexedNode.prototype.iterate=HashArrayMapNode.prototype.iterate=function(i,e){for(var t=this.nodes,n=0,s=t.length-1;n<=s;n++){var o=t[e?s-n:n];if(o&&o.iterate(i,e)===!1)return!1}},ValueNode.prototype.iterate=function(i,e){return i(this.entry)};var MapIterator=(function(i){function e(t,n,s){this._type=n,this._reverse=s,this._stack=t._root&&mapIteratorFrame(t._root)}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.next=function(){for(var n=this._type,s=this._stack;s;){var o=s.node,a=s.index++,l=void 0;if(o.entry){if(a===0)return mapIteratorValue(n,o.entry)}else if(o.entries){if(l=o.entries.length-1,a<=l)return mapIteratorValue(n,o.entries[this._reverse?l-a:a])}else if(l=o.nodes.length-1,a<=l){var c=o.nodes[this._reverse?l-a:a];if(c){if(c.entry)return mapIteratorValue(n,c.entry);s=this._stack=mapIteratorFrame(c,s)}continue}s=this._stack=this._stack.__prev}return iteratorDone()},e})(Iterator);function mapIteratorValue(i,e){return iteratorValue(i,e[0],e[1])}function mapIteratorFrame(i,e){return{node:i,index:0,__prev:e}}function makeMap(i,e,t,n){var s=Object.create(MapPrototype);return s.size=i,s._root=e,s.__ownerID=t,s.__hash=n,s.__altered=!1,s}var EMPTY_MAP;function emptyMap(){return EMPTY_MAP||(EMPTY_MAP=makeMap(0))}function updateMap(i,e,t){var n,s;if(i._root){var o=MakeRef(),a=MakeRef();if(n=updateNode(i._root,i.__ownerID,0,void 0,e,t,o,a),!a.value)return i;s=i.size+(o.value?t===NOT_SET?-1:1:0)}else{if(t===NOT_SET)return i;s=1,n=new ArrayMapNode(i.__ownerID,[[e,t]])}return i.__ownerID?(i.size=s,i._root=n,i.__hash=void 0,i.__altered=!0,i):n?makeMap(s,n):emptyMap()}function updateNode(i,e,t,n,s,o,a,l){return i?i.update(e,t,n,s,o,a,l):o===NOT_SET?i:(SetRef(l),SetRef(a),new ValueNode(e,n,[s,o]))}function isLeafNode(i){return i.constructor===ValueNode||i.constructor===HashCollisionNode}function mergeIntoNode(i,e,t,n,s){if(i.keyHash===n)return new HashCollisionNode(e,n,[i.entry,s]);var o=(t===0?i.keyHash:i.keyHash>>>t)&MASK,a=(t===0?n:n>>>t)&MASK,l,c=o===a?[mergeIntoNode(i,e,t+SHIFT,n,s)]:(l=new ValueNode(e,n,s),o<a?[i,l]:[l,i]);return new BitmapIndexedNode(e,1<<o|1<<a,c)}function createNodes(i,e,t,n){i||(i=new OwnerID);for(var s=new ValueNode(i,hash(t),[t,n]),o=0;o<e.length;o++){var a=e[o];s=s.update(i,0,void 0,a[0],a[1])}return s}function packNodes(i,e,t,n){for(var s=0,o=0,a=new Array(t),l=0,c=1,u=e.length;l<u;l++,c<<=1){var h=e[l];h!==void 0&&l!==n&&(s|=c,a[o++]=h)}return new BitmapIndexedNode(i,s,a)}function expandNodes(i,e,t,n,s){for(var o=0,a=new Array(SIZE),l=0;t!==0;l++,t>>>=1)a[l]=t&1?e[o++]:void 0;return a[n]=s,new HashArrayMapNode(i,o+1,a)}function popCount(i){return i-=i>>1&1431655765,i=(i&858993459)+(i>>2&858993459),i=i+(i>>4)&252645135,i+=i>>8,i+=i>>16,i&127}function setAt(i,e,t,n){var s=n?i:arrCopy(i);return s[e]=t,s}function spliceIn(i,e,t,n){var s=i.length+1;if(n&&e+1===s)return i[e]=t,i;for(var o=new Array(s),a=0,l=0;l<s;l++)l===e?(o[l]=t,a=-1):o[l]=i[l+a];return o}function spliceOut(i,e,t){var n=i.length-1;if(t&&e===n)return i.pop(),i;for(var s=new Array(n),o=0,a=0;a<n;a++)a===e&&(o=1),s[a]=i[a+o];return s}var MAX_ARRAY_MAP_SIZE=SIZE/4,MAX_BITMAP_INDEXED_SIZE=SIZE/2,MIN_HASH_ARRAY_MAP_SIZE=SIZE/4,IS_LIST_SYMBOL="@@__IMMUTABLE_LIST__@@";function isList(i){return!!(i&&i[IS_LIST_SYMBOL])}var List=(function(i){function e(t){var n=emptyList();if(t==null)return n;if(isList(t))return t;var s=i(t),o=s.size;return o===0?n:(assertNotInfinite(o),o>0&&o<SIZE?makeList(0,o,SHIFT,null,new VNode(s.toArray())):n.withMutations(function(a){a.setSize(o),s.forEach(function(l,c){return a.set(c,l)})}))}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("List [","]")},e.prototype.get=function(n,s){if(n=wrapIndex(this,n),n>=0&&n<this.size){n+=this._origin;var o=listNodeFor(this,n);return o&&o.array[n&MASK]}return s},e.prototype.set=function(n,s){return updateList(this,n,s)},e.prototype.remove=function(n){return this.has(n)?n===0?this.shift():n===this.size-1?this.pop():this.splice(n,1):this},e.prototype.insert=function(n,s){return this.splice(n,0,s)},e.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=SHIFT,this._root=this._tail=this.__hash=void 0,this.__altered=!0,this):emptyList()},e.prototype.push=function(){var n=arguments,s=this.size;return this.withMutations(function(o){setListBounds(o,0,s+n.length);for(var a=0;a<n.length;a++)o.set(s+a,n[a])})},e.prototype.pop=function(){return setListBounds(this,0,-1)},e.prototype.unshift=function(){var n=arguments;return this.withMutations(function(s){setListBounds(s,-n.length);for(var o=0;o<n.length;o++)s.set(o,n[o])})},e.prototype.shift=function(){return setListBounds(this,1)},e.prototype.shuffle=function(n){return n===void 0&&(n=Math.random),this.withMutations(function(s){for(var o=s.size,a,l;o;)a=Math.floor(n()*o--),l=s.get(a),s.set(a,s.get(o)),s.set(o,l)})},e.prototype.concat=function(){for(var n=arguments,s=[],o=0;o<arguments.length;o++){var a=n[o],l=i(typeof a!="string"&&hasIterator(a)?a:[a]);l.size!==0&&s.push(l)}return s.length===0?this:this.size===0&&!this.__ownerID&&s.length===1?this.constructor(s[0]):this.withMutations(function(c){s.forEach(function(u){return u.forEach(function(h){return c.push(h)})})})},e.prototype.setSize=function(n){return setListBounds(this,0,n)},e.prototype.map=function(n,s){var o=this;return this.withMutations(function(a){for(var l=0;l<o.size;l++)a.set(l,n.call(s,a.get(l),l,o))})},e.prototype.slice=function(n,s){var o=this.size;return wholeSlice(n,s,o)?this:setListBounds(this,resolveBegin(n,o),resolveEnd(s,o))},e.prototype.__iterator=function(n,s){var o=s?this.size:0,a=iterateList(this,s);return new Iterator(function(){var l=a();return l===DONE?iteratorDone():iteratorValue(n,s?--o:o++,l)})},e.prototype.__iterate=function(n,s){for(var o=s?this.size:0,a=iterateList(this,s),l;(l=a())!==DONE&&n(l,s?--o:o++,this)!==!1;);return o},e.prototype.__ensureOwner=function(n){return n===this.__ownerID?this:n?makeList(this._origin,this._capacity,this._level,this._root,this._tail,n,this.__hash):this.size===0?emptyList():(this.__ownerID=n,this.__altered=!1,this)},e})(IndexedCollection);List.isList=isList;var ListPrototype=List.prototype;ListPrototype[IS_LIST_SYMBOL]=!0,ListPrototype[DELETE]=ListPrototype.remove,ListPrototype.merge=ListPrototype.concat,ListPrototype.setIn=setIn,ListPrototype.deleteIn=ListPrototype.removeIn=deleteIn,ListPrototype.update=update,ListPrototype.updateIn=updateIn,ListPrototype.mergeIn=mergeIn,ListPrototype.mergeDeepIn=mergeDeepIn,ListPrototype.withMutations=withMutations,ListPrototype.wasAltered=wasAltered,ListPrototype.asImmutable=asImmutable,ListPrototype["@@transducer/init"]=ListPrototype.asMutable=asMutable,ListPrototype["@@transducer/step"]=function(i,e){return i.push(e)},ListPrototype["@@transducer/result"]=function(i){return i.asImmutable()};var VNode=function(e,t){this.array=e,this.ownerID=t};VNode.prototype.removeBefore=function(e,t,n){if((n&(1<<t+SHIFT)-1)===0||this.array.length===0)return this;var s=n>>>t&MASK;if(s>=this.array.length)return new VNode([],e);var o=s===0,a;if(t>0){var l=this.array[s];if(a=l&&l.removeBefore(e,t-SHIFT,n),a===l&&o)return this}if(o&&!a)return this;var c=editableVNode(this,e);if(!o)for(var u=0;u<s;u++)c.array[u]=void 0;return a&&(c.array[s]=a),c},VNode.prototype.removeAfter=function(e,t,n){if(n===(t?1<<t+SHIFT:SIZE)||this.array.length===0)return this;var s=n-1>>>t&MASK;if(s>=this.array.length)return this;var o;if(t>0){var a=this.array[s];if(o=a&&a.removeAfter(e,t-SHIFT,n),o===a&&s===this.array.length-1)return this}var l=editableVNode(this,e);return l.array.splice(s+1),o&&(l.array[s]=o),l};var DONE={};function iterateList(i,e){var t=i._origin,n=i._capacity,s=getTailOffset(n),o=i._tail;return a(i._root,i._level,0);function a(u,h,d){return h===0?l(u,d):c(u,h,d)}function l(u,h){var d=h===s?o&&o.array:u&&u.array,p=h>t?0:t-h,f=n-h;return f>SIZE&&(f=SIZE),function(){if(p===f)return DONE;var g=e?--f:p++;return d&&d[g]}}function c(u,h,d){var p,f=u&&u.array,g=d>t?0:t-d>>h,_=(n-d>>h)+1;return _>SIZE&&(_=SIZE),function(){for(;;){if(p){var x=p();if(x!==DONE)return x;p=null}if(g===_)return DONE;var y=e?--_:g++;p=a(f&&f[y],h-SHIFT,d+(y<<h))}}}}function makeList(i,e,t,n,s,o,a){var l=Object.create(ListPrototype);return l.size=e-i,l._origin=i,l._capacity=e,l._level=t,l._root=n,l._tail=s,l.__ownerID=o,l.__hash=a,l.__altered=!1,l}function emptyList(){return makeList(0,0,SHIFT)}function updateList(i,e,t){if(e=wrapIndex(i,e),e!==e)return i;if(e>=i.size||e<0)return i.withMutations(function(a){e<0?setListBounds(a,e).set(0,t):setListBounds(a,0,e+1).set(e,t)});e+=i._origin;var n=i._tail,s=i._root,o=MakeRef();return e>=getTailOffset(i._capacity)?n=updateVNode(n,i.__ownerID,0,e,t,o):s=updateVNode(s,i.__ownerID,i._level,e,t,o),o.value?i.__ownerID?(i._root=s,i._tail=n,i.__hash=void 0,i.__altered=!0,i):makeList(i._origin,i._capacity,i._level,s,n):i}function updateVNode(i,e,t,n,s,o){var a=n>>>t&MASK,l=i&&a<i.array.length;if(!l&&s===void 0)return i;var c;if(t>0){var u=i&&i.array[a],h=updateVNode(u,e,t-SHIFT,n,s,o);return h===u?i:(c=editableVNode(i,e),c.array[a]=h,c)}return l&&i.array[a]===s?i:(o&&SetRef(o),c=editableVNode(i,e),s===void 0&&a===c.array.length-1?c.array.pop():c.array[a]=s,c)}function editableVNode(i,e){return e&&i&&e===i.ownerID?i:new VNode(i?i.array.slice():[],e)}function listNodeFor(i,e){if(e>=getTailOffset(i._capacity))return i._tail;if(e<1<<i._level+SHIFT){for(var t=i._root,n=i._level;t&&n>0;)t=t.array[e>>>n&MASK],n-=SHIFT;return t}}function setListBounds(i,e,t){e!==void 0&&(e|=0),t!==void 0&&(t|=0);var n=i.__ownerID||new OwnerID,s=i._origin,o=i._capacity,a=s+e,l=t===void 0?o:t<0?o+t:s+t;if(a===s&&l===o)return i;if(a>=l)return i.clear();for(var c=i._level,u=i._root,h=0;a+h<0;)u=new VNode(u&&u.array.length?[void 0,u]:[],n),c+=SHIFT,h+=1<<c;h&&(a+=h,s+=h,l+=h,o+=h);for(var d=getTailOffset(o),p=getTailOffset(l);p>=1<<c+SHIFT;)u=new VNode(u&&u.array.length?[u]:[],n),c+=SHIFT;var f=i._tail,g=p<d?listNodeFor(i,l-1):p>d?new VNode([],n):f;if(f&&p>d&&a<o&&f.array.length){u=editableVNode(u,n);for(var _=u,x=c;x>SHIFT;x-=SHIFT){var y=d>>>x&MASK;_=_.array[y]=editableVNode(_.array[y],n)}_.array[d>>>SHIFT&MASK]=f}if(l<o&&(g=g&&g.removeAfter(n,0,l)),a>=p)a-=p,l-=p,c=SHIFT,u=null,g=g&&g.removeBefore(n,0,a);else if(a>s||p<d){for(h=0;u;){var E=a>>>c&MASK;if(E!==p>>>c&MASK)break;E&&(h+=(1<<c)*E),c-=SHIFT,u=u.array[E]}u&&a>s&&(u=u.removeBefore(n,c,a-h)),u&&p<d&&(u=u.removeAfter(n,c,p-h)),h&&(a-=h,l-=h)}return i.__ownerID?(i.size=l-a,i._origin=a,i._capacity=l,i._level=c,i._root=u,i._tail=g,i.__hash=void 0,i.__altered=!0,i):makeList(a,l,c,u,g)}function getTailOffset(i){return i<SIZE?0:i-1>>>SHIFT<<SHIFT}var OrderedMap=(function(i){function e(t){return t==null?emptyOrderedMap():isOrderedMap(t)?t:emptyOrderedMap().withMutations(function(n){var s=KeyedCollection(t);assertNotInfinite(s.size),s.forEach(function(o,a){return n.set(a,o)})})}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("OrderedMap {","}")},e.prototype.get=function(n,s){var o=this._map.get(n);return o!==void 0?this._list.get(o)[1]:s},e.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this.__altered=!0,this):emptyOrderedMap()},e.prototype.set=function(n,s){return updateOrderedMap(this,n,s)},e.prototype.remove=function(n){return updateOrderedMap(this,n,NOT_SET)},e.prototype.__iterate=function(n,s){var o=this;return this._list.__iterate(function(a){return a&&n(a[1],a[0],o)},s)},e.prototype.__iterator=function(n,s){return this._list.fromEntrySeq().__iterator(n,s)},e.prototype.__ensureOwner=function(n){if(n===this.__ownerID)return this;var s=this._map.__ensureOwner(n),o=this._list.__ensureOwner(n);return n?makeOrderedMap(s,o,n,this.__hash):this.size===0?emptyOrderedMap():(this.__ownerID=n,this.__altered=!1,this._map=s,this._list=o,this)},e})(Map$1);OrderedMap.isOrderedMap=isOrderedMap,OrderedMap.prototype[IS_ORDERED_SYMBOL]=!0,OrderedMap.prototype[DELETE]=OrderedMap.prototype.remove;function makeOrderedMap(i,e,t,n){var s=Object.create(OrderedMap.prototype);return s.size=i?i.size:0,s._map=i,s._list=e,s.__ownerID=t,s.__hash=n,s.__altered=!1,s}var EMPTY_ORDERED_MAP;function emptyOrderedMap(){return EMPTY_ORDERED_MAP||(EMPTY_ORDERED_MAP=makeOrderedMap(emptyMap(),emptyList()))}function updateOrderedMap(i,e,t){var n=i._map,s=i._list,o=n.get(e),a=o!==void 0,l,c;if(t===NOT_SET){if(!a)return i;s.size>=SIZE&&s.size>=n.size*2?(c=s.filter(function(u,h){return u!==void 0&&o!==h}),l=c.toKeyedSeq().map(function(u){return u[0]}).flip().toMap(),i.__ownerID&&(l.__ownerID=c.__ownerID=i.__ownerID)):(l=n.remove(e),c=o===s.size-1?s.pop():s.set(o,void 0))}else if(a){if(t===s.get(o)[1])return i;l=n,c=s.set(o,[e,t])}else l=n.set(e,s.size),c=s.set(s.size,[e,t]);return i.__ownerID?(i.size=l.size,i._map=l,i._list=c,i.__hash=void 0,i.__altered=!0,i):makeOrderedMap(l,c)}var IS_STACK_SYMBOL="@@__IMMUTABLE_STACK__@@";function isStack(i){return!!(i&&i[IS_STACK_SYMBOL])}var Stack=(function(i){function e(t){return t==null?emptyStack():isStack(t)?t:emptyStack().pushAll(t)}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.prototype.toString=function(){return this.__toString("Stack [","]")},e.prototype.get=function(n,s){var o=this._head;for(n=wrapIndex(this,n);o&&n--;)o=o.next;return o?o.value:s},e.prototype.peek=function(){return this._head&&this._head.value},e.prototype.push=function(){var n=arguments;if(arguments.length===0)return this;for(var s=this.size+arguments.length,o=this._head,a=arguments.length-1;a>=0;a--)o={value:n[a],next:o};return this.__ownerID?(this.size=s,this._head=o,this.__hash=void 0,this.__altered=!0,this):makeStack(s,o)},e.prototype.pushAll=function(n){if(n=i(n),n.size===0)return this;if(this.size===0&&isStack(n))return n;assertNotInfinite(n.size);var s=this.size,o=this._head;return n.__iterate(function(a){s++,o={value:a,next:o}},!0),this.__ownerID?(this.size=s,this._head=o,this.__hash=void 0,this.__altered=!0,this):makeStack(s,o)},e.prototype.pop=function(){return this.slice(1)},e.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):emptyStack()},e.prototype.slice=function(n,s){if(wholeSlice(n,s,this.size))return this;var o=resolveBegin(n,this.size),a=resolveEnd(s,this.size);if(a!==this.size)return i.prototype.slice.call(this,n,s);for(var l=this.size-o,c=this._head;o--;)c=c.next;return this.__ownerID?(this.size=l,this._head=c,this.__hash=void 0,this.__altered=!0,this):makeStack(l,c)},e.prototype.__ensureOwner=function(n){return n===this.__ownerID?this:n?makeStack(this.size,this._head,n,this.__hash):this.size===0?emptyStack():(this.__ownerID=n,this.__altered=!1,this)},e.prototype.__iterate=function(n,s){var o=this;if(s)return new ArraySeq(this.toArray()).__iterate(function(c,u){return n(c,u,o)},s);for(var a=0,l=this._head;l&&n(l.value,a++,this)!==!1;)l=l.next;return a},e.prototype.__iterator=function(n,s){if(s)return new ArraySeq(this.toArray()).__iterator(n,s);var o=0,a=this._head;return new Iterator(function(){if(a){var l=a.value;return a=a.next,iteratorValue(n,o++,l)}return iteratorDone()})},e})(IndexedCollection);Stack.isStack=isStack;var StackPrototype=Stack.prototype;StackPrototype[IS_STACK_SYMBOL]=!0,StackPrototype.shift=StackPrototype.pop,StackPrototype.unshift=StackPrototype.push,StackPrototype.unshiftAll=StackPrototype.pushAll,StackPrototype.withMutations=withMutations,StackPrototype.wasAltered=wasAltered,StackPrototype.asImmutable=asImmutable,StackPrototype["@@transducer/init"]=StackPrototype.asMutable=asMutable,StackPrototype["@@transducer/step"]=function(i,e){return i.unshift(e)},StackPrototype["@@transducer/result"]=function(i){return i.asImmutable()};function makeStack(i,e,t,n){var s=Object.create(StackPrototype);return s.size=i,s._head=e,s.__ownerID=t,s.__hash=n,s.__altered=!1,s}var EMPTY_STACK;function emptyStack(){return EMPTY_STACK||(EMPTY_STACK=makeStack(0))}var IS_SET_SYMBOL="@@__IMMUTABLE_SET__@@";function isSet(i){return!!(i&&i[IS_SET_SYMBOL])}function isOrderedSet(i){return isSet(i)&&isOrdered(i)}function deepEqual(i,e){if(i===e)return!0;if(!isCollection(e)||i.size!==void 0&&e.size!==void 0&&i.size!==e.size||i.__hash!==void 0&&e.__hash!==void 0&&i.__hash!==e.__hash||isKeyed(i)!==isKeyed(e)||isIndexed(i)!==isIndexed(e)||isOrdered(i)!==isOrdered(e))return!1;if(i.size===0&&e.size===0)return!0;var t=!isAssociative(i);if(isOrdered(i)){var n=i.entries();return e.every(function(c,u){var h=n.next().value;return h&&is(h[1],c)&&(t||is(h[0],u))})&&n.next().done}var s=!1;if(i.size===void 0)if(e.size===void 0)typeof i.cacheResult=="function"&&i.cacheResult();else{s=!0;var o=i;i=e,e=o}var a=!0,l=e.__iterate(function(c,u){if(t?!i.has(c):s?!is(c,i.get(u,NOT_SET)):!is(i.get(u,NOT_SET),c))return a=!1,!1});return a&&i.size===l}function mixin(i,e){var t=function(n){i.prototype[n]=e[n]};return Object.keys(e).forEach(t),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(e).forEach(t),i}function toJS(i){if(!i||typeof i!="object")return i;if(!isCollection(i)){if(!isDataStructure(i))return i;i=Seq(i)}if(isKeyed(i)){var e={};return i.__iterate(function(n,s){e[s]=toJS(n)}),e}var t=[];return i.__iterate(function(n){t.push(toJS(n))}),t}var Set$1=(function(i){function e(t){return t==null?emptySet():isSet(t)&&!isOrdered(t)?t:emptySet().withMutations(function(n){var s=i(t);assertNotInfinite(s.size),s.forEach(function(o){return n.add(o)})})}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(n){return this(KeyedCollection(n).keySeq())},e.intersect=function(n){return n=Collection(n).toArray(),n.length?SetPrototype.intersect.apply(e(n.pop()),n):emptySet()},e.union=function(n){return n=Collection(n).toArray(),n.length?SetPrototype.union.apply(e(n.pop()),n):emptySet()},e.prototype.toString=function(){return this.__toString("Set {","}")},e.prototype.has=function(n){return this._map.has(n)},e.prototype.add=function(n){return updateSet(this,this._map.set(n,n))},e.prototype.remove=function(n){return updateSet(this,this._map.remove(n))},e.prototype.clear=function(){return updateSet(this,this._map.clear())},e.prototype.map=function(n,s){var o=this,a=!1,l=updateSet(this,this._map.mapEntries(function(c){var u=c[1],h=n.call(s,u,u,o);return h!==u&&(a=!0),[h,h]},s));return a?l:this},e.prototype.union=function(){for(var n=[],s=arguments.length;s--;)n[s]=arguments[s];return n=n.filter(function(o){return o.size!==0}),n.length===0?this:this.size===0&&!this.__ownerID&&n.length===1?this.constructor(n[0]):this.withMutations(function(o){for(var a=0;a<n.length;a++)typeof n[a]=="string"?o.add(n[a]):i(n[a]).forEach(function(l){return o.add(l)})})},e.prototype.intersect=function(){for(var n=[],s=arguments.length;s--;)n[s]=arguments[s];if(n.length===0)return this;n=n.map(function(a){return i(a)});var o=[];return this.forEach(function(a){n.every(function(l){return l.includes(a)})||o.push(a)}),this.withMutations(function(a){o.forEach(function(l){a.remove(l)})})},e.prototype.subtract=function(){for(var n=[],s=arguments.length;s--;)n[s]=arguments[s];if(n.length===0)return this;n=n.map(function(a){return i(a)});var o=[];return this.forEach(function(a){n.some(function(l){return l.includes(a)})&&o.push(a)}),this.withMutations(function(a){o.forEach(function(l){a.remove(l)})})},e.prototype.sort=function(n){return OrderedSet(sortFactory(this,n))},e.prototype.sortBy=function(n,s){return OrderedSet(sortFactory(this,s,n))},e.prototype.wasAltered=function(){return this._map.wasAltered()},e.prototype.__iterate=function(n,s){var o=this;return this._map.__iterate(function(a){return n(a,a,o)},s)},e.prototype.__iterator=function(n,s){return this._map.__iterator(n,s)},e.prototype.__ensureOwner=function(n){if(n===this.__ownerID)return this;var s=this._map.__ensureOwner(n);return n?this.__make(s,n):this.size===0?this.__empty():(this.__ownerID=n,this._map=s,this)},e})(SetCollection);Set$1.isSet=isSet;var SetPrototype=Set$1.prototype;SetPrototype[IS_SET_SYMBOL]=!0,SetPrototype[DELETE]=SetPrototype.remove,SetPrototype.merge=SetPrototype.concat=SetPrototype.union,SetPrototype.withMutations=withMutations,SetPrototype.asImmutable=asImmutable,SetPrototype["@@transducer/init"]=SetPrototype.asMutable=asMutable,SetPrototype["@@transducer/step"]=function(i,e){return i.add(e)},SetPrototype["@@transducer/result"]=function(i){return i.asImmutable()},SetPrototype.__empty=emptySet,SetPrototype.__make=makeSet;function updateSet(i,e){return i.__ownerID?(i.size=e.size,i._map=e,i):e===i._map?i:e.size===0?i.__empty():i.__make(e)}function makeSet(i,e){var t=Object.create(SetPrototype);return t.size=i?i.size:0,t._map=i,t.__ownerID=e,t}var EMPTY_SET;function emptySet(){return EMPTY_SET||(EMPTY_SET=makeSet(emptyMap()))}var Range=(function(i){function e(t,n,s){if(s===void 0&&(s=1),!(this instanceof e))return new e(t,n,s);if(invariant(s!==0,"Cannot step a Range by 0"),invariant(t!==void 0,"You must define a start value when using Range"),invariant(n!==void 0,"You must define an end value when using Range"),s=Math.abs(s),n<t&&(s=-s),this._start=t,this._end=n,this._step=s,this.size=Math.max(0,Math.ceil((n-t)/s-1)+1),this.size===0){if(EMPTY_RANGE)return EMPTY_RANGE;EMPTY_RANGE=this}}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.size===0?"Range []":"Range [ "+this._start+"..."+this._end+(this._step!==1?" by "+this._step:"")+" ]"},e.prototype.get=function(n,s){return this.has(n)?this._start+wrapIndex(this,n)*this._step:s},e.prototype.includes=function(n){var s=(n-this._start)/this._step;return s>=0&&s<this.size&&s===Math.floor(s)},e.prototype.slice=function(n,s){return wholeSlice(n,s,this.size)?this:(n=resolveBegin(n,this.size),s=resolveEnd(s,this.size),s<=n?new e(0,0):new e(this.get(n,this._end),this.get(s,this._end),this._step))},e.prototype.indexOf=function(n){var s=n-this._start;if(s%this._step===0){var o=s/this._step;if(o>=0&&o<this.size)return o}return-1},e.prototype.lastIndexOf=function(n){return this.indexOf(n)},e.prototype.__iterate=function(n,s){for(var o=this.size,a=this._step,l=s?this._start+(o-1)*a:this._start,c=0;c!==o&&n(l,s?o-++c:c++,this)!==!1;)l+=s?-a:a;return c},e.prototype.__iterator=function(n,s){var o=this.size,a=this._step,l=s?this._start+(o-1)*a:this._start,c=0;return new Iterator(function(){if(c===o)return iteratorDone();var u=l;return l+=s?-a:a,iteratorValue(n,s?o-++c:c++,u)})},e.prototype.equals=function(n){return n instanceof e?this._start===n._start&&this._end===n._end&&this._step===n._step:deepEqual(this,n)},e})(IndexedSeq),EMPTY_RANGE;function getIn$1(i,e,t){for(var n=coerceKeyPath(e),s=0;s!==n.length;)if(i=get(i,n[s++],NOT_SET),i===NOT_SET)return t;return i}function getIn(i,e){return getIn$1(this,i,e)}function hasIn$1(i,e){return getIn$1(i,e,NOT_SET)!==NOT_SET}function hasIn(i){return hasIn$1(this,i)}function toObject(){assertNotInfinite(this.size);var i={};return this.__iterate(function(e,t){i[t]=e}),i}Collection.Iterator=Iterator,mixin(Collection,{toArray:function(){assertNotInfinite(this.size);var e=new Array(this.size||0),t=isKeyed(this),n=0;return this.__iterate(function(s,o){e[n++]=t?[o,s]:s}),e},toIndexedSeq:function(){return new ToIndexedSequence(this)},toJS:function(){return toJS(this)},toKeyedSeq:function(){return new ToKeyedSequence(this,!0)},toMap:function(){return Map$1(this.toKeyedSeq())},toObject,toOrderedMap:function(){return OrderedMap(this.toKeyedSeq())},toOrderedSet:function(){return OrderedSet(isKeyed(this)?this.valueSeq():this)},toSet:function(){return Set$1(isKeyed(this)?this.valueSeq():this)},toSetSeq:function(){return new ToSetSequence(this)},toSeq:function(){return isIndexed(this)?this.toIndexedSeq():isKeyed(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return Stack(isKeyed(this)?this.valueSeq():this)},toList:function(){return List(isKeyed(this)?this.valueSeq():this)},toString:function(){return"[Collection]"},__toString:function(e,t){return this.size===0?e+t:e+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+t},concat:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return reify(this,concatFactory(this,e))},includes:function(e){return this.some(function(t){return is(t,e)})},entries:function(){return this.__iterator(ITERATE_ENTRIES)},every:function(e,t){assertNotInfinite(this.size);var n=!0;return this.__iterate(function(s,o,a){if(!e.call(t,s,o,a))return n=!1,!1}),n},filter:function(e,t){return reify(this,filterFactory(this,e,t,!0))},partition:function(e,t){return partitionFactory(this,e,t)},find:function(e,t,n){var s=this.findEntry(e,t);return s?s[1]:n},forEach:function(e,t){return assertNotInfinite(this.size),this.__iterate(t?e.bind(t):e)},join:function(e){assertNotInfinite(this.size),e=e!==void 0?""+e:",";var t="",n=!0;return this.__iterate(function(s){n?n=!1:t+=e,t+=s!=null?s.toString():""}),t},keys:function(){return this.__iterator(ITERATE_KEYS)},map:function(e,t){return reify(this,mapFactory(this,e,t))},reduce:function(e,t,n){return reduce(this,e,t,n,arguments.length<2,!1)},reduceRight:function(e,t,n){return reduce(this,e,t,n,arguments.length<2,!0)},reverse:function(){return reify(this,reverseFactory(this,!0))},slice:function(e,t){return reify(this,sliceFactory(this,e,t,!0))},some:function(e,t){assertNotInfinite(this.size);var n=!1;return this.__iterate(function(s,o,a){if(e.call(t,s,o,a))return n=!0,!1}),n},sort:function(e){return reify(this,sortFactory(this,e))},values:function(){return this.__iterator(ITERATE_VALUES)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return this.size!==void 0?this.size===0:!this.some(function(){return!0})},count:function(e,t){return ensureSize(e?this.toSeq().filter(e,t):this)},countBy:function(e,t){return countByFactory(this,e,t)},equals:function(e){return deepEqual(this,e)},entrySeq:function(){var e=this;if(e._cache)return new ArraySeq(e._cache);var t=e.toSeq().map(entryMapper).toIndexedSeq();return t.fromEntrySeq=function(){return e.toSeq()},t},filterNot:function(e,t){return this.filter(not(e),t)},findEntry:function(e,t,n){var s=n;return this.__iterate(function(o,a,l){if(e.call(t,o,a,l))return s=[a,o],!1}),s},findKey:function(e,t){var n=this.findEntry(e,t);return n&&n[0]},findLast:function(e,t,n){return this.toKeyedSeq().reverse().find(e,t,n)},findLastEntry:function(e,t,n){return this.toKeyedSeq().reverse().findEntry(e,t,n)},findLastKey:function(e,t){return this.toKeyedSeq().reverse().findKey(e,t)},first:function(e){return this.find(returnTrue,null,e)},flatMap:function(e,t){return reify(this,flatMapFactory(this,e,t))},flatten:function(e){return reify(this,flattenFactory(this,e,!0))},fromEntrySeq:function(){return new FromEntriesSequence(this)},get:function(e,t){return this.find(function(n,s){return is(s,e)},void 0,t)},getIn,groupBy:function(e,t){return groupByFactory(this,e,t)},has:function(e){return this.get(e,NOT_SET)!==NOT_SET},hasIn,isSubset:function(e){return e=typeof e.includes=="function"?e:Collection(e),this.every(function(t){return e.includes(t)})},isSuperset:function(e){return e=typeof e.isSubset=="function"?e:Collection(e),e.isSubset(this)},keyOf:function(e){return this.findKey(function(t){return is(t,e)})},keySeq:function(){return this.toSeq().map(keyMapper).toIndexedSeq()},last:function(e){return this.toSeq().reverse().first(e)},lastKeyOf:function(e){return this.toKeyedSeq().reverse().keyOf(e)},max:function(e){return maxFactory(this,e)},maxBy:function(e,t){return maxFactory(this,t,e)},min:function(e){return maxFactory(this,e?neg(e):defaultNegComparator)},minBy:function(e,t){return maxFactory(this,t?neg(t):defaultNegComparator,e)},rest:function(){return this.slice(1)},skip:function(e){return e===0?this:this.slice(Math.max(0,e))},skipLast:function(e){return e===0?this:this.slice(0,-Math.max(0,e))},skipWhile:function(e,t){return reify(this,skipWhileFactory(this,e,t,!0))},skipUntil:function(e,t){return this.skipWhile(not(e),t)},sortBy:function(e,t){return reify(this,sortFactory(this,t,e))},take:function(e){return this.slice(0,Math.max(0,e))},takeLast:function(e){return this.slice(-Math.max(0,e))},takeWhile:function(e,t){return reify(this,takeWhileFactory(this,e,t))},takeUntil:function(e,t){return this.takeWhile(not(e),t)},update:function(e){return e(this)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=hashCollection(this))}});var CollectionPrototype=Collection.prototype;CollectionPrototype[IS_COLLECTION_SYMBOL]=!0,CollectionPrototype[ITERATOR_SYMBOL]=CollectionPrototype.values,CollectionPrototype.toJSON=CollectionPrototype.toArray,CollectionPrototype.__toStringMapper=quoteString,CollectionPrototype.inspect=CollectionPrototype.toSource=function(){return this.toString()},CollectionPrototype.chain=CollectionPrototype.flatMap,CollectionPrototype.contains=CollectionPrototype.includes,mixin(KeyedCollection,{flip:function(){return reify(this,flipFactory(this))},mapEntries:function(e,t){var n=this,s=0;return reify(this,this.toSeq().map(function(o,a){return e.call(t,[a,o],s++,n)}).fromEntrySeq())},mapKeys:function(e,t){var n=this;return reify(this,this.toSeq().flip().map(function(s,o){return e.call(t,s,o,n)}).flip())}});var KeyedCollectionPrototype=KeyedCollection.prototype;KeyedCollectionPrototype[IS_KEYED_SYMBOL]=!0,KeyedCollectionPrototype[ITERATOR_SYMBOL]=CollectionPrototype.entries,KeyedCollectionPrototype.toJSON=toObject,KeyedCollectionPrototype.__toStringMapper=function(i,e){return quoteString(e)+": "+quoteString(i)},mixin(IndexedCollection,{toKeyedSeq:function(){return new ToKeyedSequence(this,!1)},filter:function(e,t){return reify(this,filterFactory(this,e,t,!1))},findIndex:function(e,t){var n=this.findEntry(e,t);return n?n[0]:-1},indexOf:function(e){var t=this.keyOf(e);return t===void 0?-1:t},lastIndexOf:function(e){var t=this.lastKeyOf(e);return t===void 0?-1:t},reverse:function(){return reify(this,reverseFactory(this,!1))},slice:function(e,t){return reify(this,sliceFactory(this,e,t,!1))},splice:function(e,t){var n=arguments.length;if(t=Math.max(t||0,0),n===0||n===2&&!t)return this;e=resolveBegin(e,e<0?this.count():this.size);var s=this.slice(0,e);return reify(this,n===1?s:s.concat(arrCopy(arguments,2),this.slice(e+t)))},findLastIndex:function(e,t){var n=this.findLastEntry(e,t);return n?n[0]:-1},first:function(e){return this.get(0,e)},flatten:function(e){return reify(this,flattenFactory(this,e,!1))},get:function(e,t){return e=wrapIndex(this,e),e<0||this.size===1/0||this.size!==void 0&&e>this.size?t:this.find(function(n,s){return s===e},void 0,t)},has:function(e){return e=wrapIndex(this,e),e>=0&&(this.size!==void 0?this.size===1/0||e<this.size:this.indexOf(e)!==-1)},interpose:function(e){return reify(this,interposeFactory(this,e))},interleave:function(){var e=[this].concat(arrCopy(arguments)),t=zipWithFactory(this.toSeq(),IndexedSeq.of,e),n=t.flatten(!0);return t.size&&(n.size=t.size*e.length),reify(this,n)},keySeq:function(){return Range(0,this.size)},last:function(e){return this.get(-1,e)},skipWhile:function(e,t){return reify(this,skipWhileFactory(this,e,t,!1))},zip:function(){var e=[this].concat(arrCopy(arguments));return reify(this,zipWithFactory(this,defaultZipper,e))},zipAll:function(){var e=[this].concat(arrCopy(arguments));return reify(this,zipWithFactory(this,defaultZipper,e,!0))},zipWith:function(e){var t=arrCopy(arguments);return t[0]=this,reify(this,zipWithFactory(this,e,t))}});var IndexedCollectionPrototype=IndexedCollection.prototype;IndexedCollectionPrototype[IS_INDEXED_SYMBOL]=!0,IndexedCollectionPrototype[IS_ORDERED_SYMBOL]=!0,mixin(SetCollection,{get:function(e,t){return this.has(e)?e:t},includes:function(e){return this.has(e)},keySeq:function(){return this.valueSeq()}});var SetCollectionPrototype=SetCollection.prototype;SetCollectionPrototype.has=CollectionPrototype.includes,SetCollectionPrototype.contains=SetCollectionPrototype.includes,SetCollectionPrototype.keys=SetCollectionPrototype.values,mixin(KeyedSeq,KeyedCollectionPrototype),mixin(IndexedSeq,IndexedCollectionPrototype),mixin(SetSeq,SetCollectionPrototype);function reduce(i,e,t,n,s,o){return assertNotInfinite(i.size),i.__iterate(function(a,l,c){s?(s=!1,t=a):t=e.call(n,t,a,l,c)},o),t}function keyMapper(i,e){return e}function entryMapper(i,e){return[e,i]}function not(i){return function(){return!i.apply(this,arguments)}}function neg(i){return function(){return-i.apply(this,arguments)}}function defaultZipper(){return arrCopy(arguments)}function defaultNegComparator(i,e){return i<e?1:i>e?-1:0}function hashCollection(i){if(i.size===1/0)return 0;var e=isOrdered(i),t=isKeyed(i),n=e?1:0;return i.__iterate(t?e?function(s,o){n=31*n+hashMerge(hash(s),hash(o))|0}:function(s,o){n=n+hashMerge(hash(s),hash(o))|0}:e?function(s){n=31*n+hash(s)|0}:function(s){n=n+hash(s)|0}),murmurHashOfSize(i.size,n)}function murmurHashOfSize(i,e){return e=imul(e,3432918353),e=imul(e<<15|e>>>-15,461845907),e=imul(e<<13|e>>>-13,5),e=(e+3864292196|0)^i,e=imul(e^e>>>16,2246822507),e=imul(e^e>>>13,3266489909),e=smi(e^e>>>16),e}function hashMerge(i,e){return i^e+2654435769+(i<<6)+(i>>2)|0}var OrderedSet=(function(i){function e(t){return t==null?emptyOrderedSet():isOrderedSet(t)?t:emptyOrderedSet().withMutations(function(n){var s=SetCollection(t);assertNotInfinite(s.size),s.forEach(function(o){return n.add(o)})})}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.of=function(){return this(arguments)},e.fromKeys=function(n){return this(KeyedCollection(n).keySeq())},e.prototype.toString=function(){return this.__toString("OrderedSet {","}")},e})(Set$1);OrderedSet.isOrderedSet=isOrderedSet;var OrderedSetPrototype=OrderedSet.prototype;OrderedSetPrototype[IS_ORDERED_SYMBOL]=!0,OrderedSetPrototype.zip=IndexedCollectionPrototype.zip,OrderedSetPrototype.zipWith=IndexedCollectionPrototype.zipWith,OrderedSetPrototype.zipAll=IndexedCollectionPrototype.zipAll,OrderedSetPrototype.__empty=emptyOrderedSet,OrderedSetPrototype.__make=makeOrderedSet;function makeOrderedSet(i,e){var t=Object.create(OrderedSetPrototype);return t.size=i?i.size:0,t._map=i,t.__ownerID=e,t}var EMPTY_ORDERED_SET;function emptyOrderedSet(){return EMPTY_ORDERED_SET||(EMPTY_ORDERED_SET=makeOrderedSet(emptyOrderedMap()))}var PairSorting={LeftThenRight:-1,RightThenLeft:1};function throwOnInvalidDefaultValues(i){if(isRecord$2(i))throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");if(isImmutable(i))throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");if(i===null||typeof i!="object")throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.")}var Record=function(e,t){var n;throwOnInvalidDefaultValues(e);var s=function(l){var c=this;if(l instanceof s)return l;if(!(this instanceof s))return new s(l);if(!n){n=!0;var u=Object.keys(e),h=o._indices={};o._name=t,o._keys=u,o._defaultValues=e;for(var d=0;d<u.length;d++){var p=u[d];h[p]=d,o[p]?typeof console=="object"&&console.warn&&console.warn("Cannot define "+recordName(this)+' with property "'+p+'" since that property name is part of the Record API.'):setProp(o,p)}}return this.__ownerID=void 0,this._values=List().withMutations(function(f){f.setSize(c._keys.length),KeyedCollection(l).forEach(function(g,_){f.set(c._indices[_],g===c._defaultValues[_]?void 0:g)})}),this},o=s.prototype=Object.create(RecordPrototype);return o.constructor=s,t&&(s.displayName=t),s};Record.prototype.toString=function(){for(var e=recordName(this)+" { ",t=this._keys,n,s=0,o=t.length;s!==o;s++)n=t[s],e+=(s?", ":"")+n+": "+quoteString(this.get(n));return e+" }"},Record.prototype.equals=function(e){return this===e||isRecord$2(e)&&recordSeq(this).equals(recordSeq(e))},Record.prototype.hashCode=function(){return recordSeq(this).hashCode()},Record.prototype.has=function(e){return this._indices.hasOwnProperty(e)},Record.prototype.get=function(e,t){if(!this.has(e))return t;var n=this._indices[e],s=this._values.get(n);return s===void 0?this._defaultValues[e]:s},Record.prototype.set=function(e,t){if(this.has(e)){var n=this._values.set(this._indices[e],t===this._defaultValues[e]?void 0:t);if(n!==this._values&&!this.__ownerID)return makeRecord(this,n)}return this},Record.prototype.remove=function(e){return this.set(e)},Record.prototype.clear=function(){var e=this._values.clear().setSize(this._keys.length);return this.__ownerID?this:makeRecord(this,e)},Record.prototype.wasAltered=function(){return this._values.wasAltered()},Record.prototype.toSeq=function(){return recordSeq(this)},Record.prototype.toJS=function(){return toJS(this)},Record.prototype.entries=function(){return this.__iterator(ITERATE_ENTRIES)},Record.prototype.__iterator=function(e,t){return recordSeq(this).__iterator(e,t)},Record.prototype.__iterate=function(e,t){return recordSeq(this).__iterate(e,t)},Record.prototype.__ensureOwner=function(e){if(e===this.__ownerID)return this;var t=this._values.__ensureOwner(e);return e?makeRecord(this,t,e):(this.__ownerID=e,this._values=t,this)},Record.isRecord=isRecord$2,Record.getDescriptiveName=recordName;var RecordPrototype=Record.prototype;RecordPrototype[IS_RECORD_SYMBOL]=!0,RecordPrototype[DELETE]=RecordPrototype.remove,RecordPrototype.deleteIn=RecordPrototype.removeIn=deleteIn,RecordPrototype.getIn=getIn,RecordPrototype.hasIn=CollectionPrototype.hasIn,RecordPrototype.merge=merge$1,RecordPrototype.mergeWith=mergeWith$1,RecordPrototype.mergeIn=mergeIn,RecordPrototype.mergeDeep=mergeDeep,RecordPrototype.mergeDeepWith=mergeDeepWith,RecordPrototype.mergeDeepIn=mergeDeepIn,RecordPrototype.setIn=setIn,RecordPrototype.update=update,RecordPrototype.updateIn=updateIn,RecordPrototype.withMutations=withMutations,RecordPrototype.asMutable=asMutable,RecordPrototype.asImmutable=asImmutable,RecordPrototype[ITERATOR_SYMBOL]=RecordPrototype.entries,RecordPrototype.toJSON=RecordPrototype.toObject=CollectionPrototype.toObject,RecordPrototype.inspect=RecordPrototype.toSource=function(){return this.toString()};function makeRecord(i,e,t){var n=Object.create(Object.getPrototypeOf(i));return n._values=e,n.__ownerID=t,n}function recordName(i){return i.constructor.displayName||i.constructor.name||"Record"}function recordSeq(i){return keyedSeqFromValue(i._keys.map(function(e){return[e,i.get(e)]}))}function setProp(i,e){try{Object.defineProperty(i,e,{get:function(){return this.get(e)},set:function(t){invariant(this.__ownerID,"Cannot set on an immutable record."),this.set(e,t)}})}catch{}}var Repeat=(function(i){function e(t,n){if(!(this instanceof e))return new e(t,n);if(this._value=t,this.size=n===void 0?1/0:Math.max(0,n),this.size===0){if(EMPTY_REPEAT)return EMPTY_REPEAT;EMPTY_REPEAT=this}}return i&&(e.__proto__=i),e.prototype=Object.create(i&&i.prototype),e.prototype.constructor=e,e.prototype.toString=function(){return this.size===0?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},e.prototype.get=function(n,s){return this.has(n)?this._value:s},e.prototype.includes=function(n){return is(this._value,n)},e.prototype.slice=function(n,s){var o=this.size;return wholeSlice(n,s,o)?this:new e(this._value,resolveEnd(s,o)-resolveBegin(n,o))},e.prototype.reverse=function(){return this},e.prototype.indexOf=function(n){return is(this._value,n)?0:-1},e.prototype.lastIndexOf=function(n){return is(this._value,n)?this.size:-1},e.prototype.__iterate=function(n,s){for(var o=this.size,a=0;a!==o&&n(this._value,s?o-++a:a++,this)!==!1;);return a},e.prototype.__iterator=function(n,s){var o=this,a=this.size,l=0;return new Iterator(function(){return l===a?iteratorDone():iteratorValue(n,s?a-++l:l++,o._value)})},e.prototype.equals=function(n){return n instanceof e?is(this._value,n._value):deepEqual(this,n)},e})(IndexedSeq),EMPTY_REPEAT;function fromJS(i,e){return fromJSWith([],e||defaultConverter,i,"",e&&e.length>2?[]:void 0,{"":i})}function fromJSWith(i,e,t,n,s,o){if(typeof t!="string"&&!isImmutable(t)&&(isArrayLike(t)||hasIterator(t)||isPlainObject(t))){if(~i.indexOf(t))throw new TypeError("Cannot convert circular structure to Immutable");i.push(t),s&&n!==""&&s.push(n);var a=e.call(o,n,Seq(t).map(function(l,c){return fromJSWith(i,e,l,c,s,t)}),s&&s.slice());return i.pop(),s&&s.pop(),a}return t}function defaultConverter(i,e){return isIndexed(e)?e.toList():isKeyed(e)?e.toMap():e.toSet()}var version="5.1.3",Iterable=Collection;const immutable_es=Object.freeze(Object.defineProperty({__proto__:null,Collection,Iterable,List,Map:Map$1,OrderedMap,OrderedSet,PairSorting,Range,Record,Repeat,Seq,Set:Set$1,Stack,fromJS,get,getIn:getIn$1,has:has$1,hasIn:hasIn$1,hash,is,isAssociative,isCollection,isImmutable,isIndexed,isKeyed,isList,isMap:isMap$1,isOrdered,isOrderedMap,isOrderedSet,isPlainObject,isRecord:isRecord$2,isSeq,isSet,isStack,isValueObject,merge,mergeDeep:mergeDeep$1,mergeDeepWith:mergeDeepWith$1,mergeWith,remove,removeIn,set:set$1,setIn:setIn$1,update:update$1,updateIn:updateIn$1,version},Symbol.toStringTag,{value:"Module"})),MODE_IDLE$1="MODE_IDLE",MODE_2D_ZOOM_IN="MODE_2D_ZOOM_IN",MODE_2D_ZOOM_OUT="MODE_2D_ZOOM_OUT",MODE_2D_PAN="MODE_2D_PAN",MODE_3D_VIEW="MODE_3D_VIEW",MODE_3D_FIRST_PERSON="MODE_3D_FIRST_PERSON",MODE_WAITING_DRAWING_LINE="MODE_WAITING_DRAWING_LINE",MODE_WAITING_DRAWING_SURFACE="MODE_WAITING_DRAWING_SURFACE",MODE_WAITING_DRAWING_ROOM="MODE_WAITING_DRAWING_ROOM",MODE_DRAWING_ROOM="MODE_DRAWING_ROOM",MODE_DRAGGING_LINE="MODE_DRAGGING_LINE",MODE_DRAGGING_VERTEX="MODE_DRAGGING_VERTEX",MODE_DRAGGING_ITEM="MODE_DRAGGING_ITEM",MODE_DRAGGING_HOLE="MODE_DRAGGING_HOLE",MODE_DRAWING_LINE="MODE_DRAWING_LINE",MODE_DRAWING_HOLE="MODE_DRAWING_HOLE",MODE_DRAWING_ITEM="MODE_DRAWING_ITEM",MODE_DRAWING_SURFACE="MODE_DRAWING_SURFACE",MODE_ROTATING_ITEM="MODE_ROTATING_ITEM",MODE_RESIZING_ITEM="MODE_RESIZING_ITEM",MODE_UPLOADING_IMAGE="MODE_UPLOADING_IMAGE",MODE_FITTING_IMAGE="MODE_FITTING_IMAGE",MODE_VIEWING_CATALOG="MODE_VIEWING_CATALOG",MODE_CONFIGURING_PROJECT="MODE_CONFIGURING_PROJECT",MODE_SNAPPING=[MODE_IDLE$1,MODE_2D_ZOOM_IN,MODE_2D_ZOOM_OUT,MODE_2D_PAN,MODE_WAITING_DRAWING_LINE,MODE_DRAWING_LINE,MODE_DRAWING_HOLE,MODE_DRAWING_ITEM,MODE_DRAGGING_LINE,MODE_DRAGGING_VERTEX,MODE_DRAGGING_ITEM,MODE_DRAGGING_HOLE,MODE_FITTING_IMAGE,MODE_UPLOADING_IMAGE,MODE_ROTATING_ITEM,MODE_WAITING_DRAWING_ROOM,MODE_DRAWING_ROOM],MODE_2D_VIEWER=[MODE_IDLE$1,MODE_2D_ZOOM_IN,MODE_2D_ZOOM_OUT,MODE_2D_PAN,MODE_WAITING_DRAWING_ROOM,MODE_WAITING_DRAWING_LINE,MODE_WAITING_DRAWING_SURFACE,MODE_DRAGGING_LINE,MODE_DRAGGING_VERTEX,MODE_DRAGGING_ITEM,MODE_DRAWING_SURFACE,MODE_DRAWING_LINE,MODE_DRAWING_ROOM,MODE_DRAWING_HOLE,MODE_DRAWING_ITEM,MODE_DRAGGING_HOLE,MODE_ROTATING_ITEM,MODE_RESIZING_ITEM],MODE_IN_PROGRESS=[MODE_DRAWING_LINE,MODE_DRAWING_SURFACE,MODE_DRAWING_ROOM,MODE_DRAWING_HOLE,MODE_DRAWING_ITEM,MODE_DRAGGING_LINE,MODE_DRAGGING_VERTEX,MODE_DRAGGING_ITEM,MODE_DRAGGING_HOLE,MODE_ROTATING_ITEM,MODE_RESIZING_ITEM],UNIT_MILLIMETER="mm",UNIT_CENTIMETER="cm",UNIT_METER="m",UNIT_INCH="in",UNIT_FOOT="ft",UNIT_MILE="mi",UNITS_LENGTH=[UNIT_MILLIMETER,UNIT_CENTIMETER,UNIT_METER,UNIT_INCH,UNIT_FOOT,UNIT_MILE],EPSILON$1=1e-6,KEYBOARD_BUTTON_CODE={DELETE:46,BACKSPACE:8,ESC:27,Z:90,C:67,V:86,ENTER:13,TAB:9},toFixedFloat=(i,e=6)=>i&&e?parseFloat(parseFloat(i.toString()).toFixed(e)):0,fAbs=i=>{let e=i;return e<0&&(e=~e+1),e};function compareVertices(i,e){return i.x===e.x?i.y-e.y:i.x-e.x}function minVertex(i,e){return compareVertices(i,e)>0?e:i}function maxVertex(i,e){return compareVertices(i,e)>0?i:e}function orderVertices(i){return[...i].sort(compareVertices)}function pointsDistance(i,e,t,n){let s=i-t,o=e-n;return Math.sqrt(s*s+o*o)}function verticesDistance(i,e){let{x:t,y:n}=i,{x:s,y:o}=e;return pointsDistance(t,n,s,o)}function horizontalLine(i){return{a:0,b:1,c:-i}}function verticalLine(i){return{a:1,b:0,c:-i}}function distancePointFromLine(i,e,t,n,s){return fAbs(i*n+e*s+t)/Math.sqrt(i*i+e*e)}function closestPointFromLine(i,e,t,n,s){let o=i*i+e*e;return{x:(e*(e*n-i*s)-i*t)/o,y:(i*-e*n+i*s-e*t)/o}}function twoLinesIntersection(i,e,t,n,s,o){let a=e*n-i*s;if(a===0)return;let l=(i*o-t*n)/a;return{x:(t*s-e*o)/a,y:l}}function twoLineSegmentsIntersection(i,e,t,n){let{x:s,y:o}=i,{x:a,y:l}=e,{x:c,y:u}=t,{x:h,y:d}=n,p=(d-u)*(a-s)-(h-c)*(l-o),f=(h-c)*(o-u)-(d-u)*(s-c),g=(a-s)*(o-u)-(l-o)*(s-c);if(fAbs(p)<=EPSILON$1){if(fAbs(f)<=EPSILON$1&&fAbs(g)<=EPSILON$1){let y=(T,I)=>T.x===I.x?T.y-I.y:T.x-I.x,E=[i,e].sort(y),b=[t.toJS(),n.toJS()].sort(y),[v,M]=[E,b].sort((T,I)=>y(T[0],I[0]));return v[1].x===M[0].x?{type:M[0].y<=v[1].y?"colinear":"none"}:{type:M[0].x<=v[1].x?"colinear":"none"}}return{type:"parallel"}}let _=f/p,x=g/p;return _>=0-EPSILON$1&&_<=1+EPSILON$1&&x>=0-EPSILON$1&&x<=1+EPSILON$1?{type:"intersecting",point:{x:s+_*(a-s),y:o+_*(l-o)}}:{type:"none"}}function distancePointFromLineSegment(i,e,t,n,s,o){let a=s-i,l=o-e,c=t-i,u=n-e,h=a*c+l*u,d=c*c+u*u,p=-1;d!=0&&(p=h/d);let f,g;p<0?(f=i,g=e):p>1?(f=t,g=n):(f=i+p*c,g=e+p*u);let _=s-f,x=o-g;return Math.sqrt(_*_+x*x)}function isPointOnLineSegment(i,e,t,n,s,o,a=EPSILON$1){return distancePointFromLineSegment(i,e,t,n,s,o)<=a}function closestPointFromLineSegment(i,e,t,n,s,o){if(i===t)return{x:i,y:o};if(e===n)return{x:s,y:e};let a=(n-e)/(t-i),l=e-a*i,c=-1/a,h=(o-c*s-l)/(a-c),d=a*h+l;return{x:h,y:d}}function pointPositionOnLineSegment(i,e,t,n,s,o){let a=pointsDistance(i,e,t,n),c=pointsDistance(i,e,s,o)/a;return i>t&&(c=mapRange$1(c,0,1,1,0)),c}function mapRange$1(i,e,t,n,s){return n+(s-n)*(i-e)/(t-e)}function angleBetweenTwoPointsAndOrigin(i,e,t,n){return-Math.atan2(e-n,t-i)*180/Math.PI}function angleBetweenTwoPoints(i,e,t,n){return Math.atan2(n-e,t-i)}function absAngleBetweenTwoPoints(i,e,t,n){return Math.atan2(Math.abs(n-e),Math.abs(t-i))}function samePoints({x:i,y:e},{x:t,y:n}){return fAbs(i-t)<=EPSILON$1&&fAbs(e-n)<=EPSILON$1}function extendLine(i,e,t,n,s,o=6){let a=angleBetweenTwoPoints(i,e,t,n);return{x:toFixedFloat(i+Math.cos(a)*s,o),y:toFixedFloat(e+Math.sin(a)*s,o)}}function distanceToSegment(i,e,t,n,s,o){const a=t-i,l=n-e,c=a*a+l*l;if(c===0)return s===i&&o===e?0:Math.hypot(s-i,o-e);const u=((s-i)*a+(o-e)*l)/c;return u<0||u>1?null:Math.abs(a*(o-e)-l*(s-i))/Math.sqrt(c)}function ContainsPoint(i,e,t){const n=i.length>>1;if(n<3)return!1;const s=1e-9;let o=!1;for(let a=0,l=n-1;a<n;l=a++){const c=i[2*l],u=i[2*l+1],h=i[2*a],d=i[2*a+1],p=distanceToSegment(c,u,h,d,e,t);if(p!==null&&p<=s)return!1;u>t!=d>t&&c+(t-u)/(d-u)*(h-c)>e&&(o=!o)}return o}function cosWithThreshold(i,e){let t=Math.cos(i);return t<e?0:t}function sinWithThreshold(i,e){let t=Math.sin(i);return t<e?0:t}function midPoint(i,e,t,n){return{x:(i+t)/2,y:(e+n)/2}}function verticesMidPoint(i){let e=i.reduce((t,n)=>({x:t.x+n.x,y:t.y+n.y}),{x:0,y:0});return{x:e.x/i.length,y:e.y/i.length}}function rotatePointAroundPoint(i,e,t,n,s){let o=s*Math.PI/180,a=Math.cos(o),l=Math.sin(o),c=i-t,u=e-n;return{x:a*c-l*u+t,y:l*c+a*u+n}}const SNAP_POINT="SNAP_POINT",SNAP_LINE="SNAP_LINE",SNAP_SEGMENT="SNAP_SEGMENT",SNAP_GRID="SNAP_GRID",SNAP_GUIDE="SNAP_GUIDE",SNAP_MASK=Map$1({SNAP_POINT:!0,SNAP_LINE:!0,SNAP_SEGMENT:!0,SNAP_GRID:!1,SNAP_GUIDE:!0});class PointSnap extends Record({type:"point",x:-1,y:-1,radius:1,priority:1,related:List()}){nearestPoint(e,t){return{x:this.x,y:this.y,distance:pointsDistance(this.x,this.y,e,t)}}isNear(e,t,n){return~(this.x-e)+1<n&&~(this.y-t)+1<n}}class LineSnap extends Record({type:"line",a:-1,b:-1,c:-1,radius:1,priority:1,related:List()}){nearestPoint(e,t){return{...closestPointFromLine(this.a,this.b,this.c,e,t),distance:distancePointFromLine(this.a,this.b,this.c,e,t)}}isNear(e,t,n){return!0}}class LineSegmentSnap extends Record({type:"line-segment",x1:-1,y1:-1,x2:-1,y2:-1,radius:1,priority:1,related:List()}){nearestPoint(e,t){return{...closestPointFromLineSegment(this.x1,this.y1,this.x2,this.y2,e,t),distance:distancePointFromLineSegment(this.x1,this.y1,this.x2,this.y2,e,t)}}isNear(e,t,n){return!0}}class GridSnap extends Record({type:"grid",x:-1,y:-1,radius:1,priority:1,related:List()}){nearestPoint(e,t){return{x:this.x,y:this.y,distance:pointsDistance(this.x,this.y,e,t)}}isNear(e,t,n){return~(this.x-e)+1<n&&~(this.y-t)+1<n}}function nearestSnap(i,e,t,n){let s={point:n.get(SNAP_POINT),line:n.get(SNAP_LINE),"line-segment":n.get(SNAP_SEGMENT),grid:n.get(SNAP_GRID)};return i.valueSeq().filter(o=>s[o.type]&&o.isNear(e,t,o.radius)).map(o=>({snap:o,point:o.nearestPoint(e,t)})).filter(({snap:{radius:o},point:{distance:a}})=>a<o).min(({snap:{priority:o},point:{distance:a}},{snap:{priority:l},point:{distance:c}})=>o===l?a<c?-1:1:o>l?-1:1)}function addPointSnap(i,e,t,n,s,o){return o=List([o]),i.push(new PointSnap({x:e,y:t,radius:n,priority:s,related:o}))}function addLineSnap(i,e,t,n,s,o,a){return a=List([a]),i.withMutations(l=>{if(l.some(u=>u.type==="line"&&e===u.a&&t===u.b&&n===u.c))return l;l.valueSeq().filter(u=>u.type==="line").map(u=>twoLinesIntersection(u.a,u.b,u.c,e,t,n)).filter(u=>u!==void 0).forEach(({x:u,y:h})=>addPointSnap(l,u,h,20,40)),l.push(new LineSnap({a:e,b:t,c:n,radius:s,priority:o,related:a}))})}function addLineSegmentSnap(i,e,t,n,s,o,a,l){return l=List([l]),i.push(new LineSegmentSnap({x1:e,y1:t,x2:n,y2:s,radius:o,priority:a,related:l}))}function addGridSnap(i,e,t,n,s,o){return o=List([o]),i.push(new GridSnap({x:e,y:t,radius:n,priority:s,related:o}))}let safeLoadMapList=(i,e,t)=>i?Map$1(i).map(n=>new e(n)).toMap():t||Map$1();class Grid extends Record({id:"",type:"",properties:Map$1()},"Grid"){constructor(e={}){super({...e,properties:fromJS(e.properties||{})})}}const DefaultGrids=Map$1({h1:new Grid({id:"h1",type:"horizontal-streak",properties:{step:40,colors:["#ddd","#ddd","#ddd","#ddd"]}}),v1:new Grid({id:"v1",type:"vertical-streak",properties:{step:40,colors:["#ddd","#ddd","#ddd","#ddd"]}})});class ElementsSet extends Record({vertices:List(),lines:List(),holes:List(),areas:List(),items:List()},"ElementsSet"){constructor(e={}){super({vertices:List(e.vertices||[]),lines:List(e.lines||[]),holes:List(e.holes||[]),areas:List(e.areas||[]),items:List(e.items||[])})}}const sharedAttributes={id:"",type:"",prototype:"",name:"",misc:Map$1(),selected:!1,properties:Map$1(),visible:!0};let Vertex$3=class extends Record({...sharedAttributes,x:-1,y:-1,prototype:"vertices",lines:List(),areas:List()},"Vertex"){constructor(e={}){super({...e,lines:List(e.lines||[]),areas:List(e.areas||[])})}},Line$3=class extends Record({...sharedAttributes,prototype:"lines",vertices:List(),holes:List()},"Line"){constructor(e={}){super({...e,properties:fromJS(e.properties||{}),vertices:List(e.vertices||[]),holes:List(e.holes||[])})}},Hole$1=class extends Record({...sharedAttributes,prototype:"holes",offset:-1,line:"",flipAlongWall:!1},"Hole"){constructor(e={}){super({...e,properties:fromJS(e.properties||{})})}},Area$2=class extends Record({...sharedAttributes,prototype:"areas",vertices:List(),holes:List()},"Area"){constructor(e={}){super({...e,properties:fromJS(e.properties||{}),vertices:List(e.vertices||[])})}},Item$2=class extends Record({...sharedAttributes,prototype:"items",x:0,y:0,rotation:0,altitude:0,scale:1,flipHorizontal:!1,flipVertical:!1},"Item"){constructor(e={}){super({...e,properties:fromJS(e.properties||{})})}},Layer$2=class extends Record({id:"",altitude:0,order:0,opacity:1,name:"",visible:!0,vertices:Map$1(),lines:Map$1(),holes:Map$1(),areas:Map$1(),items:Map$1(),selected:new ElementsSet},"Layer"){constructor(e={}){super({...e,vertices:safeLoadMapList(e.vertices,Vertex$3),lines:safeLoadMapList(e.lines,Line$3),holes:safeLoadMapList(e.holes,Hole$1),areas:safeLoadMapList(e.areas,Area$2),items:safeLoadMapList(e.items,Item$2),selected:new ElementsSet(e.selected)})}},Group$3=class extends Record({...sharedAttributes,prototype:"groups",x:0,y:0,rotation:0,elements:Map$1()},"Group"){constructor(e={}){super({...e,properties:fromJS(e.properties||{}),elements:fromJS(e.elements||{})})}};const DefaultLayers=Map$1({"layer-1":new Layer$2({id:"layer-1",name:"default"})});let Scene$3=class extends Record({unit:UNIT_FOOT,layers:Map$1(),grids:Map$1(),selectedLayer:null,groups:Map$1(),width:3e3,height:2e3,meta:Map$1(),guides:Map$1()},"Scene"){constructor(e={}){let t=safeLoadMapList(e.layers,Layer$2,DefaultLayers);super({...e,grids:safeLoadMapList(void 0,Grid,DefaultGrids),layers:t,selectedLayer:t.first().id,groups:safeLoadMapList(e.groups||{},Group$3),meta:e.meta?fromJS(e.meta):Map$1(),guides:e.guides?fromJS(e.guides):Map$1({horizontal:Map$1(),vertical:Map$1(),circular:Map$1()})})}};class CatalogElement extends Record({name:"",prototype:"",info:Map$1(),properties:Map$1(),textures:Map$1()},"CatalogElement"){constructor(e={}){const t=fromJS(e.properties);super({...e,info:fromJS(e.info),properties:Map$1.isMap(t)?t:Map$1(),textures:fromJS(e.textures||{})})}}let Catalog$1=class extends Record({ready:!1,page:"root",path:List(),elements:Map$1()},"Catalog"){constructor(e={}){let t=safeLoadMapList(e.elements,CatalogElement);super({elements:t,ready:!t.isEmpty()})}factoryElement(e,t,n){const s=this.elements.get(e),o=s?s.prototype:t==null?void 0:t.prototype;if(!s&&!o){let l=this.elements.map(c=>c.name).toArray();throw new Error(`Element ${e} does not exist in catalog ${l}`)}const a=s?s.properties.map((l,c)=>n&&n.has(c)?n.get(c):l.get("defaultValue")):n??Map$1();switch(o){case"lines":return new Line$3(t).merge({properties:a});case"holes":return new Hole$1(t).merge({properties:a});case"areas":return new Area$2(t).merge({properties:a});case"items":return new Item$2(t).merge({properties:a});default:throw new Error("prototype not valid")}}};class HistoryStructure extends Record({list:List(),first:null,last:null,redoList:List()},"HistoryStructure"){constructor(e={}){super({list:fromJS(e.list||[]),first:new Scene$3(e.scene),last:new Scene$3(e.last||e.scene)})}}let State$1=class extends Record({mode:MODE_IDLE$1,scene:new Scene$3,sceneHistory:new HistoryStructure,catalog:new Catalog$1,viewer2D:Map$1(),mouse:Map$1({x:0,y:0}),zoom:0,snapMask:SNAP_MASK,snapElements:List(),activeSnapElement:null,drawingSupport:Map$1(),draggingSupport:Map$1(),rotatingSupport:Map$1(),resizingSupport:Map$1(),itemSnapGuides:null,errors:List(),warnings:List(),clipboardProperties:Map$1(),selectedElementsHistory:List(),misc:Map$1(),alterate:!1},"State"){constructor(e={}){super({...e,scene:new Scene$3(e.scene),sceneHistory:new HistoryStructure(e),catalog:new Catalog$1(e.catalog||{}),viewer2D:Map$1(e.viewer2D||{}),drawingSupport:Map$1(e.drawingSupport||{}),draggingSupport:Map$1(e.draggingSupport||{}),rotatingSupport:Map$1(e.rotatingSupport||{}),resizingSupport:Map$1(e.resizingSupport||{}),misc:e.misc?fromJS(e.misc):Map$1()})}};function create_array(i){let e=[];for(let t=0;t<i;++t)e.push([]);return e}class Edge{constructor(e,t){ze(this,"u");ze(this,"v");this.u=e,this.v=t}}class Graph{constructor(e){ze(this,"count");ze(this,"subgraphs");ze(this,"time");ze(this,"V");ze(this,"E");ze(this,"adj");ze(this,"children");this.count=0,this.subgraphs=[],this.time=0,this.children=0,this.V=e,this.E=0,this.adj=[],this.adj=create_array(e)}addEdge(e,t){this.adj[e].push(t),this.E++}_BCCUtil(e,t,n,s,o){t[e]=n[e]=++this.time,this.children=0,this.adj[e].forEach(a=>{if(t[a]==-1){if(this.children++,o[a]=e,s.push(new Edge(e,a)),this._BCCUtil(a,t,n,s,o),n[e]>n[a]&&(n[e]=n[a]),t[e]==1&&this.children>1||t[e]>1&&n[a]>=t[e]){let l=[];for(;s[s.length-1].u!=e||s[s.length-1].v!=a;)l.push(s[s.length-1]),s.splice(s.length-1,1);l.push(s[s.length-1]),this.subgraphs.push(l),l=[],s.splice(s.length-1,1),this.count++}}else a!=o[e]&&t[a]<n[e]&&(n[e]>t[a]&&(n[e]=t[a]),s.push(new Edge(e,a)))})}BCC(){let e=this.V,t=create_array(e),n=create_array(e),s=create_array(e),o=[];for(let a=0;a<e;a++)t[a]=-1,n[a]=-1,s[a]=-1;for(let a=0;a<e;a++){t[a]==-1&&this._BCCUtil(a,t,n,o,s);let l=0,c=[];for(;o.length>0;)l=1,c.push(o[o.length-1]),o.splice(o.length-1,1);l==1&&(this.subgraphs.push(c),c=[],this.count++)}}}const getEdgesOfSubgraphs=(i,e)=>{let t=[];return i.forEach(n=>{t.push([]);let s=getVerticesFromBiconnectedComponent(n);s.forEach(o=>{e.adj[o].forEach(l=>{o<=l&&s.has(l)&&t[t.length-1].push([o,l])})})}),t},getVerticesFromBiconnectedComponent=i=>{let e=new Set;return i.forEach(t=>{e.add(t.u),e.add(t.v)}),e};function sub(i,e){return[i[0]-e[0],i[1]-e[1]]}function mod(i,e){return(i%e+e)%e}function compute_ev_mapping(i){return i.map(function(t){return{ev:t,color:0,direction:-1}})}function compute_angle(i,e){let t=sub(e,i);return Math.atan2(t[1],t[0])}function compute_incidences(i,e){return i.map(function(t,n){let s=[];return e.forEach(function(o,a){let l,c;o[0]===n&&(l=o[1],c=1),o[1]===n&&(l=o[0],c=0),l!==void 0&&s.push({index:a,endpoint:l,angle:compute_angle(t,i[l]),edge:o,position:c})}),s.sort(function(o,a){return a.angle-o.angle}),s})}function get_starting_edge(i,e){let t,n;for(t=0;t<e.length;t+=1)if(e[t].color<2)return n=-1*e[t].direction,color(e,t,n),{edge:t,direction:n,position:n===-1?0:1}}function get_next_edge(i,e,t,n){let s=i[n[e][t]],o=s.length,a,l,c;for(c=0;c<o;c+=1)if(a=s[c],a.index===e)return l=s[mod(c+1,s.length)],{edge:l.index,vertex:l.endpoint,position:l.position,direction:l.position?1:-1}}function color(i,e,t){i[e].color+=1,i[e].direction=t}function find_cycles(i,e){let t=compute_ev_mapping(e),n=compute_incidences(i,e),s=[],o=[],a=[],l,c,u,h,d=get_starting_edge(n,t);for(;d!==void 0;){for(l=[e[d.edge][mod(d.position+1,2)],e[d.edge][d.position]],c=[d.edge],u=[d.direction],h=get_next_edge(n,d.edge,d.position,e);h.edge!==d.edge;)l.push(h.vertex),c.push(h.edge),u.push(h.direction),color(t,h.edge,h.direction),h=get_next_edge(n,h.edge,h.position,e);o.push(c),s.push(l),a.push(u),d=get_starting_edge(n,t)}return{v_cycles:s,e_cycles:o,dir_e_cycles:a,ev_mapping:t}}function find_short_cycles_indexes(i,e){let t=[],n,s,o;for(o=0;o<e.length;o+=1)n=e[o],s=i[o],(n.length<3||s[0]!==s[s.length-1])&&t.push(o);return t}function find_inner_cycles(i,e){let t=find_cycles(i,e),n=t.v_cycles,s=t.e_cycles;find_short_cycles_indexes(n,s).forEach(p=>{n.splice(p,1),s.splice(p,1)});let a=t.dir_e_cycles,c=t.e_cycles.map((p,f)=>p.map(function(g,_){let x,y;return a[f][_]>0?(x=e[g][0],y=e[g][1]):(x=e[g][1],y=e[g][0]),(i[y][0]-i[x][0])*(i[y][1]+i[x][1])})).map(p=>p.reduce((f,g)=>f+g)),u=c.filter(p=>p>0).length,h=c.length-u,d=u>=h?1:-1;return{v_cycles:t.v_cycles.filter((p,f)=>d*c[f]>0),e_cycles:t.e_cycles.filter((p,f)=>d*c[f]>0),ev_mapping:t.ev_mapping}}function calculateInnerCycles(i,e){let t=List();const n=new Graph(i.length);e.forEach(([c,u])=>{n.addEdge(c,u),n.addEdge(u,c)}),n.BCC();const s=n.subgraphs.filter(c=>c.length>=3),o=getEdgesOfSubgraphs(s,n),a=[];return o.forEach(c=>{c.forEach(u=>a.push(u))}),find_inner_cycles(i,a).v_cycles.forEach(c=>{c.shift(),t=t.push(c)}),t}function isClockWiseOrder(i){let e=0,t=0,n=i.size;for(e=0;e<n;e++){let{x:s,y:o}=i.get(e)||{x:0,y:0},{x:a,y:l}=i.get((e+1)%n)||{x:0,y:0};t+=(a-s)*(l+o)}return t>0}function sceneSnapElements(i,e=List(),t=Map$1()){let{width:n,height:s}=i,o,a,l;return e.withMutations(c=>{if(i.layers.forEach(u=>{let{lines:h,vertices:d}=u;d.forEach(({id:p,x:f,y:g})=>{t.get(SNAP_POINT)&&addPointSnap(c,f,g,10,10,p),t.get(SNAP_LINE)&&({a:o,b:a,c:l}=horizontalLine(g),addLineSnap(c,o,a,l,10,1,p),{a:o,b:a,c:l}=verticalLine(f),addLineSnap(c,o,a,l,10,1,p))}),t.get(SNAP_SEGMENT)&&h.forEach(({id:p,vertices:[f,g]})=>{let{x:_,y:x}=d.get(f),{x:y,y:E}=d.get(g);addLineSegmentSnap(c,_,x,y,E,20,1,p)})}),t.get(SNAP_GRID)){let u=5,h=100/u,d=n/h,p=s/h;for(let f=0;f<d;f++){let g=f*h;for(let _=0;_<p;_++){let x=_*h,y=!(f%u),E=!(_%u);addGridSnap(c,g,x,10,y&&E?15:10,null)}}}if(t.get(SNAP_GUIDE)){let u=i.getIn(["guides","horizontal"]),h=i.getIn(["guides","vertical"]),d=u.valueSeq(),p=h.valueSeq();d.forEach(f=>{p.forEach(g=>{addPointSnap(c,g,f,10,10)})}),d.forEach(f=>addLineSegmentSnap(c,0,f,n,f,20,1)),p.forEach(f=>addLineSegmentSnap(c,f,0,f,s,20,1))}})}var immutable$1={exports:{}},immutable=immutable$1.exports,hasRequiredImmutable;function requireImmutable(){return hasRequiredImmutable||(hasRequiredImmutable=1,(function(i,e){(function(t,n){i.exports=n()})(immutable,function(){var t=Array.prototype.slice;function n(m,S){S&&(m.prototype=Object.create(S.prototype)),m.prototype.constructor=m}function s(m){return c(m)?m:V(m)}n(o,s);function o(m){return u(m)?m:pe(m)}n(a,s);function a(m){return h(m)?m:ae(m)}n(l,s);function l(m){return c(m)&&!d(m)?m:Te(m)}function c(m){return!!(m&&m[f])}function u(m){return!!(m&&m[g])}function h(m){return!!(m&&m[_])}function d(m){return u(m)||h(m)}function p(m){return!!(m&&m[x])}s.isIterable=c,s.isKeyed=u,s.isIndexed=h,s.isAssociative=d,s.isOrdered=p,s.Keyed=o,s.Indexed=a,s.Set=l;var f="@@__IMMUTABLE_ITERABLE__@@",g="@@__IMMUTABLE_KEYED__@@",_="@@__IMMUTABLE_INDEXED__@@",x="@@__IMMUTABLE_ORDERED__@@",y="delete",E=5,b=1<<E,v=b-1,M={},T={value:!1},I={value:!1};function w(m){return m.value=!1,m}function R(m){m&&(m.value=!0)}function A(){}function P(m,S){S=S||0;for(var C=Math.max(0,m.length-S),L=new Array(C),O=0;O<C;O++)L[O]=m[O+S];return L}function B(m){return m.size===void 0&&(m.size=m.__iterate(W)),m.size}function k(m,S){if(typeof S!="number"){var C=S>>>0;if(""+C!==S||C===4294967295)return NaN;S=C}return S<0?B(m)+S:S}function W(){return!0}function Y(m,S,C){return(m===0||C!==void 0&&m<=-C)&&(S===void 0||C!==void 0&&S>=C)}function $(m,S){return G(m,S,0)}function ee(m,S){return G(m,S,S)}function G(m,S,C){return m===void 0?C:m<0?Math.max(0,S+m):S===void 0?m:Math.min(S,m)}var K=0,F=1,X=2,se=typeof Symbol=="function"&&Symbol.iterator,me="@@iterator",Me=se||me;function j(m){this.next=m}j.prototype.toString=function(){return"[Iterator]"},j.KEYS=K,j.VALUES=F,j.ENTRIES=X,j.prototype.inspect=j.prototype.toSource=function(){return this.toString()},j.prototype[Me]=function(){return this};function ie(m,S,C,L){var O=m===0?S:m===1?C:[S,C];return L?L.value=O:L={value:O,done:!1},L}function Z(){return{value:void 0,done:!0}}function ue(m){return!!Fe(m)}function be(m){return m&&typeof m.next=="function"}function re(m){var S=Fe(m);return S&&S.call(m)}function Fe(m){var S=m&&(se&&m[se]||m[me]);if(typeof S=="function")return S}function oe(m){return m&&typeof m.length=="number"}n(V,s);function V(m){return m==null?N():c(m)?m.toSeq():Ie(m)}V.of=function(){return V(arguments)},V.prototype.toSeq=function(){return this},V.prototype.toString=function(){return this.__toString("Seq {","}")},V.prototype.cacheResult=function(){return!this._cache&&this.__iterateUncached&&(this._cache=this.entrySeq().toArray(),this.size=this._cache.length),this},V.prototype.__iterate=function(m,S){return Be(this,m,S,!0)},V.prototype.__iterator=function(m,S){return Le(this,m,S,!0)},n(pe,V);function pe(m){return m==null?N().toKeyedSeq():c(m)?u(m)?m.toSeq():m.fromEntrySeq():ne(m)}pe.prototype.toKeyedSeq=function(){return this},n(ae,V);function ae(m){return m==null?N():c(m)?u(m)?m.entrySeq():m.toIndexedSeq():he(m)}ae.of=function(){return ae(arguments)},ae.prototype.toIndexedSeq=function(){return this},ae.prototype.toString=function(){return this.__toString("Seq [","]")},ae.prototype.__iterate=function(m,S){return Be(this,m,S,!1)},ae.prototype.__iterator=function(m,S){return Le(this,m,S,!1)},n(Te,V);function Te(m){return(m==null?N():c(m)?u(m)?m.entrySeq():m:he(m)).toSetSeq()}Te.of=function(){return Te(arguments)},Te.prototype.toSetSeq=function(){return this},V.isSeq=$e,V.Keyed=pe,V.Set=Te,V.Indexed=ae;var _e="@@__IMMUTABLE_SEQ__@@";V.prototype[_e]=!0,n(ye,ae);function ye(m){this._array=m,this.size=m.length}ye.prototype.get=function(m,S){return this.has(m)?this._array[k(this,m)]:S},ye.prototype.__iterate=function(m,S){for(var C=this._array,L=C.length-1,O=0;O<=L;O++)if(m(C[S?L-O:O],O,this)===!1)return O+1;return O},ye.prototype.__iterator=function(m,S){var C=this._array,L=C.length-1,O=0;return new j(function(){return O>L?Z():ie(m,O,C[S?L-O++:O++])})},n(Se,pe);function Se(m){var S=Object.keys(m);this._object=m,this._keys=S,this.size=S.length}Se.prototype.get=function(m,S){return S!==void 0&&!this.has(m)?S:this._object[m]},Se.prototype.has=function(m){return this._object.hasOwnProperty(m)},Se.prototype.__iterate=function(m,S){for(var C=this._object,L=this._keys,O=L.length-1,q=0;q<=O;q++){var z=L[S?O-q:q];if(m(C[z],z,this)===!1)return q+1}return q},Se.prototype.__iterator=function(m,S){var C=this._object,L=this._keys,O=L.length-1,q=0;return new j(function(){var z=L[S?O-q:q];return q++>O?Z():ie(m,z,C[z])})},Se.prototype[x]=!0,n(Ae,ae);function Ae(m){this._iterable=m,this.size=m.length||m.size}Ae.prototype.__iterateUncached=function(m,S){if(S)return this.cacheResult().__iterate(m,S);var C=this._iterable,L=re(C),O=0;if(be(L))for(var q;!(q=L.next()).done&&m(q.value,O++,this)!==!1;);return O},Ae.prototype.__iteratorUncached=function(m,S){if(S)return this.cacheResult().__iterator(m,S);var C=this._iterable,L=re(C);if(!be(L))return new j(Z);var O=0;return new j(function(){var q=L.next();return q.done?q:ie(m,O++,q.value)})},n(qe,ae);function qe(m){this._iterator=m,this._iteratorCache=[]}qe.prototype.__iterateUncached=function(m,S){if(S)return this.cacheResult().__iterate(m,S);for(var C=this._iterator,L=this._iteratorCache,O=0;O<L.length;)if(m(L[O],O++,this)===!1)return O;for(var q;!(q=C.next()).done;){var z=q.value;if(L[O]=z,m(z,O++,this)===!1)break}return O},qe.prototype.__iteratorUncached=function(m,S){if(S)return this.cacheResult().__iterator(m,S);var C=this._iterator,L=this._iteratorCache,O=0;return new j(function(){if(O>=L.length){var q=C.next();if(q.done)return q;L[O]=q.value}return ie(m,O,L[O++])})};function $e(m){return!!(m&&m[_e])}var U;function N(){return U||(U=new ye([]))}function ne(m){var S=Array.isArray(m)?new ye(m).fromEntrySeq():be(m)?new qe(m).fromEntrySeq():ue(m)?new Ae(m).fromEntrySeq():typeof m=="object"?new Se(m):void 0;if(!S)throw new TypeError("Expected Array or iterable object of [k, v] entries, or keyed object: "+m);return S}function he(m){var S=fe(m);if(!S)throw new TypeError("Expected Array or iterable object of values: "+m);return S}function Ie(m){var S=fe(m)||typeof m=="object"&&new Se(m);if(!S)throw new TypeError("Expected Array or iterable object of values, or keyed object: "+m);return S}function fe(m){return oe(m)?new ye(m):be(m)?new qe(m):ue(m)?new Ae(m):void 0}function Be(m,S,C,L){var O=m._cache;if(O){for(var q=O.length-1,z=0;z<=q;z++){var J=O[C?q-z:z];if(S(J[1],L?J[0]:z,m)===!1)return z+1}return z}return m.__iterateUncached(S,C)}function Le(m,S,C,L){var O=m._cache;if(O){var q=O.length-1,z=0;return new j(function(){var J=O[C?q-z:z];return z++>q?Z():ie(S,L?J[0]:z-1,J[1])})}return m.__iteratorUncached(S,C)}function je(m,S){return S?Ve(S,m,"",{"":m}):Oe(m)}function Ve(m,S,C,L){return Array.isArray(S)?m.call(L,C,ae(S).map(function(O,q){return Ve(m,O,q,S)})):ve(S)?m.call(L,C,pe(S).map(function(O,q){return Ve(m,O,q,S)})):S}function Oe(m){return Array.isArray(m)?ae(m).map(Oe).toList():ve(m)?pe(m).map(Oe).toMap():m}function ve(m){return m&&(m.constructor===Object||m.constructor===void 0)}function Ne(m,S){if(m===S||m!==m&&S!==S)return!0;if(!m||!S)return!1;if(typeof m.valueOf=="function"&&typeof S.valueOf=="function"){if(m=m.valueOf(),S=S.valueOf(),m===S||m!==m&&S!==S)return!0;if(!m||!S)return!1}return!!(typeof m.equals=="function"&&typeof S.equals=="function"&&m.equals(S))}function Ce(m,S){if(m===S)return!0;if(!c(S)||m.size!==void 0&&S.size!==void 0&&m.size!==S.size||m.__hash!==void 0&&S.__hash!==void 0&&m.__hash!==S.__hash||u(m)!==u(S)||h(m)!==h(S)||p(m)!==p(S))return!1;if(m.size===0&&S.size===0)return!0;var C=!d(m);if(p(m)){var L=m.entries();return S.every(function(de,ge){var we=L.next().value;return we&&Ne(we[1],de)&&(C||Ne(we[0],ge))})&&L.next().done}var O=!1;if(m.size===void 0)if(S.size===void 0)typeof m.cacheResult=="function"&&m.cacheResult();else{O=!0;var q=m;m=S,S=q}var z=!0,J=S.__iterate(function(de,ge){if(C?!m.has(de):O?!Ne(de,m.get(ge,M)):!Ne(m.get(ge,M),de))return z=!1,!1});return z&&m.size===J}n(xe,ae);function xe(m,S){if(!(this instanceof xe))return new xe(m,S);if(this._value=m,this.size=S===void 0?1/0:Math.max(0,S),this.size===0){if(We)return We;We=this}}xe.prototype.toString=function(){return this.size===0?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},xe.prototype.get=function(m,S){return this.has(m)?this._value:S},xe.prototype.includes=function(m){return Ne(this._value,m)},xe.prototype.slice=function(m,S){var C=this.size;return Y(m,S,C)?this:new xe(this._value,ee(S,C)-$(m,C))},xe.prototype.reverse=function(){return this},xe.prototype.indexOf=function(m){return Ne(this._value,m)?0:-1},xe.prototype.lastIndexOf=function(m){return Ne(this._value,m)?this.size:-1},xe.prototype.__iterate=function(m,S){for(var C=0;C<this.size;C++)if(m(this._value,C,this)===!1)return C+1;return C},xe.prototype.__iterator=function(m,S){var C=this,L=0;return new j(function(){return L<C.size?ie(m,L++,C._value):Z()})},xe.prototype.equals=function(m){return m instanceof xe?Ne(this._value,m._value):Ce(m)};var We;function H(m,S){if(!m)throw new Error(S)}n(Ee,ae);function Ee(m,S,C){if(!(this instanceof Ee))return new Ee(m,S,C);if(H(C!==0,"Cannot step a Range by 0"),m=m||0,S===void 0&&(S=1/0),C=C===void 0?1:Math.abs(C),S<m&&(C=-C),this._start=m,this._end=S,this._step=C,this.size=Math.max(0,Math.ceil((S-m)/C-1)+1),this.size===0){if(ke)return ke;ke=this}}Ee.prototype.toString=function(){return this.size===0?"Range []":"Range [ "+this._start+"..."+this._end+(this._step!==1?" by "+this._step:"")+" ]"},Ee.prototype.get=function(m,S){return this.has(m)?this._start+k(this,m)*this._step:S},Ee.prototype.includes=function(m){var S=(m-this._start)/this._step;return S>=0&&S<this.size&&S===Math.floor(S)},Ee.prototype.slice=function(m,S){return Y(m,S,this.size)?this:(m=$(m,this.size),S=ee(S,this.size),S<=m?new Ee(0,0):new Ee(this.get(m,this._end),this.get(S,this._end),this._step))},Ee.prototype.indexOf=function(m){var S=m-this._start;if(S%this._step===0){var C=S/this._step;if(C>=0&&C<this.size)return C}return-1},Ee.prototype.lastIndexOf=function(m){return this.indexOf(m)},Ee.prototype.__iterate=function(m,S){for(var C=this.size-1,L=this._step,O=S?this._start+C*L:this._start,q=0;q<=C;q++){if(m(O,q,this)===!1)return q+1;O+=S?-L:L}return q},Ee.prototype.__iterator=function(m,S){var C=this.size-1,L=this._step,O=S?this._start+C*L:this._start,q=0;return new j(function(){var z=O;return O+=S?-L:L,q>C?Z():ie(m,q++,z)})},Ee.prototype.equals=function(m){return m instanceof Ee?this._start===m._start&&this._end===m._end&&this._step===m._step:Ce(this,m)};var ke;n(Ge,s);function Ge(){throw TypeError("Abstract")}n(De,Ge);function De(){}n(Re,Ge);function Re(){}n(Ye,Ge);function Ye(){}Ge.Keyed=De,Ge.Indexed=Re,Ge.Set=Ye;var nt=typeof Math.imul=="function"&&Math.imul(4294967295,2)===-2?Math.imul:function(S,C){S=S|0,C=C|0;var L=S&65535,O=C&65535;return L*O+((S>>>16)*O+L*(C>>>16)<<16>>>0)|0};function ut(m){return m>>>1&1073741824|m&3221225471}function rt(m){if(m===!1||m===null||m===void 0||typeof m.valueOf=="function"&&(m=m.valueOf(),m===!1||m===null||m===void 0))return 0;if(m===!0)return 1;var S=typeof m;if(S==="number"){if(m!==m||m===1/0)return 0;var C=m|0;for(C!==m&&(C^=m*4294967295);m>4294967295;)m/=4294967295,C^=m;return ut(C)}if(S==="string")return m.length>xn?Bt(m):Pt(m);if(typeof m.hashCode=="function")return m.hashCode();if(S==="object")return gn(m);if(typeof m.toString=="function")return Pt(m.toString());throw new Error("Value type "+S+" cannot be hashed.")}function Bt(m){var S=ln[m];return S===void 0&&(S=Pt(m),an===yn&&(an=0,ln={}),an++,ln[m]=S),S}function Pt(m){for(var S=0,C=0;C<m.length;C++)S=31*S+m.charCodeAt(C)|0;return ut(S)}function gn(m){var S;if(Jt&&(S=Wt.get(m),S!==void 0)||(S=m[Ft],S!==void 0)||!Zt&&(S=m.propertyIsEnumerable&&m.propertyIsEnumerable[Ft],S!==void 0||(S=_n(m),S!==void 0)))return S;if(S=++Qt,Qt&1073741824&&(Qt=0),Jt)Wt.set(m,S);else{if(qt!==void 0&&qt(m)===!1)throw new Error("Non-extensible objects are not allowed as keys.");if(Zt)Object.defineProperty(m,Ft,{enumerable:!1,configurable:!1,writable:!1,value:S});else if(m.propertyIsEnumerable!==void 0&&m.propertyIsEnumerable===m.constructor.prototype.propertyIsEnumerable)m.propertyIsEnumerable=function(){return this.constructor.prototype.propertyIsEnumerable.apply(this,arguments)},m.propertyIsEnumerable[Ft]=S;else if(m.nodeType!==void 0)m[Ft]=S;else throw new Error("Unable to set a non-enumerable property on object.")}return S}var qt=Object.isExtensible,Zt=(function(){try{return Object.defineProperty({},"@",{}),!0}catch{return!1}})();function _n(m){if(m&&m.nodeType>0)switch(m.nodeType){case 1:return m.uniqueID;case 9:return m.documentElement&&m.documentElement.uniqueID}}var Jt=typeof WeakMap=="function",Wt;Jt&&(Wt=new WeakMap);var Qt=0,Ft="__immutablehash__";typeof Symbol=="function"&&(Ft=Symbol(Ft));var xn=16,yn=255,an=0,ln={};function wt(m){H(m!==1/0,"Cannot perform this action with an infinite size.")}n(lt,De);function lt(m){return m==null?Ze():un(m)&&!p(m)?m:Ze().withMutations(function(S){var C=o(m);wt(C.size),C.forEach(function(L,O){return S.set(O,L)})})}lt.of=function(){var m=t.call(arguments,0);return Ze().withMutations(function(S){for(var C=0;C<m.length;C+=2){if(C+1>=m.length)throw new Error("Missing value for key: "+m[C]);S.set(m[C],m[C+1])}})},lt.prototype.toString=function(){return this.__toString("Map {","}")},lt.prototype.get=function(m,S){return this._root?this._root.get(0,void 0,m,S):S},lt.prototype.set=function(m,S){return st(this,m,S)},lt.prototype.setIn=function(m,S){return this.updateIn(m,M,function(){return S})},lt.prototype.remove=function(m){return st(this,m,M)},lt.prototype.deleteIn=function(m){return this.updateIn(m,function(){return M})},lt.prototype.update=function(m,S,C){return arguments.length===1?m(this):this.updateIn([m],S,C)},lt.prototype.updateIn=function(m,S,C){C||(C=S,S=void 0);var L=Xt(this,or(m),S,C);return L===M?void 0:L},lt.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):Ze()},lt.prototype.merge=function(){return at(this,void 0,arguments)},lt.prototype.mergeWith=function(m){var S=t.call(arguments,1);return at(this,m,S)},lt.prototype.mergeIn=function(m){var S=t.call(arguments,1);return this.updateIn(m,Ze(),function(C){return typeof C.merge=="function"?C.merge.apply(C,S):S[S.length-1]})},lt.prototype.mergeDeep=function(){return at(this,Mt,arguments)},lt.prototype.mergeDeepWith=function(m){var S=t.call(arguments,1);return at(this,Ht(m),S)},lt.prototype.mergeDeepIn=function(m){var S=t.call(arguments,1);return this.updateIn(m,Ze(),function(C){return typeof C.mergeDeep=="function"?C.mergeDeep.apply(C,S):S[S.length-1]})},lt.prototype.sort=function(m){return vt(sn(this,m))},lt.prototype.sortBy=function(m,S){return vt(sn(this,S,m))},lt.prototype.withMutations=function(m){var S=this.asMutable();return m(S),S.wasAltered()?S.__ensureOwner(this.__ownerID):this},lt.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new A)},lt.prototype.asImmutable=function(){return this.__ensureOwner()},lt.prototype.wasAltered=function(){return this.__altered},lt.prototype.__iterator=function(m,S){return new Ue(this,m,S)},lt.prototype.__iterate=function(m,S){var C=this,L=0;return this._root&&this._root.iterate(function(O){return L++,m(O[1],O[0],C)},S),L},lt.prototype.__ensureOwner=function(m){return m===this.__ownerID?this:m?Qe(this.size,this._root,m,this.__hash):(this.__ownerID=m,this.__altered=!1,this)};function un(m){return!!(m&&m[vn])}lt.isMap=un;var vn="@@__IMMUTABLE_MAP__@@",D=lt.prototype;D[vn]=!0,D[y]=D.remove,D.removeIn=D.deleteIn;function Q(m,S){this.ownerID=m,this.entries=S}Q.prototype.get=function(m,S,C,L){for(var O=this.entries,q=0,z=O.length;q<z;q++)if(Ne(C,O[q][0]))return O[q][1];return L},Q.prototype.update=function(m,S,C,L,O,q,z){for(var J=O===M,de=this.entries,ge=0,we=de.length;ge<we&&!Ne(L,de[ge][0]);ge++);var He=ge<we;if(He?de[ge][1]===O:J)return this;if(R(z),(J||!He)&&R(q),!(J&&de.length===1)){if(!He&&!J&&de.length>=Rt)return dt(m,de,L,O);var Je=m&&m===this.ownerID,it=Je?de:P(de);return He?J?ge===we-1?it.pop():it[ge]=it.pop():it[ge]=[L,O]:it.push([L,O]),Je?(this.entries=it,this):new Q(m,it)}};function le(m,S,C){this.ownerID=m,this.bitmap=S,this.nodes=C}le.prototype.get=function(m,S,C,L){S===void 0&&(S=rt(C));var O=1<<((m===0?S:S>>>m)&v),q=this.bitmap;return(q&O)===0?L:this.nodes[ft(q&O-1)].get(m+E,S,C,L)},le.prototype.update=function(m,S,C,L,O,q,z){C===void 0&&(C=rt(L));var J=(S===0?C:C>>>S)&v,de=1<<J,ge=this.bitmap,we=(ge&de)!==0;if(!we&&O===M)return this;var He=ft(ge&de-1),Je=this.nodes,it=we?Je[He]:void 0,ot=ct(it,m,S+E,C,L,O,q,z);if(ot===it)return this;if(!we&&ot&&Je.length>=hn)return gt(m,Je,ge,J,ot);if(we&&!ot&&Je.length===2&&mt(Je[He^1]))return Je[He^1];if(we&&ot&&Je.length===1&&mt(ot))return ot;var yt=m&&m===this.ownerID,Ut=we?ot?ge:ge^de:ge|de,jt=we?ot?At(Je,He,ot,yt):Et(Je,He,yt):Lt(Je,He,ot,yt);return yt?(this.bitmap=Ut,this.nodes=jt,this):new le(m,Ut,jt)};function ce(m,S,C){this.ownerID=m,this.count=S,this.nodes=C}ce.prototype.get=function(m,S,C,L){S===void 0&&(S=rt(C));var O=(m===0?S:S>>>m)&v,q=this.nodes[O];return q?q.get(m+E,S,C,L):L},ce.prototype.update=function(m,S,C,L,O,q,z){C===void 0&&(C=rt(L));var J=(S===0?C:C>>>S)&v,de=O===M,ge=this.nodes,we=ge[J];if(de&&!we)return this;var He=ct(we,m,S+E,C,L,O,q,z);if(He===we)return this;var Je=this.count;if(!we)Je++;else if(!He&&(Je--,Je<$t))return et(m,ge,Je,J);var it=m&&m===this.ownerID,ot=At(ge,J,He,it);return it?(this.count=Je,this.nodes=ot,this):new ce(m,Je,ot)};function te(m,S,C){this.ownerID=m,this.keyHash=S,this.entries=C}te.prototype.get=function(m,S,C,L){for(var O=this.entries,q=0,z=O.length;q<z;q++)if(Ne(C,O[q][0]))return O[q][1];return L},te.prototype.update=function(m,S,C,L,O,q,z){C===void 0&&(C=rt(L));var J=O===M;if(C!==this.keyHash)return J?this:(R(z),R(q),ht(this,m,S,C,[L,O]));for(var de=this.entries,ge=0,we=de.length;ge<we&&!Ne(L,de[ge][0]);ge++);var He=ge<we;if(He?de[ge][1]===O:J)return this;if(R(z),(J||!He)&&R(q),J&&we===2)return new Pe(m,this.keyHash,de[ge^1]);var Je=m&&m===this.ownerID,it=Je?de:P(de);return He?J?ge===we-1?it.pop():it[ge]=it.pop():it[ge]=[L,O]:it.push([L,O]),Je?(this.entries=it,this):new te(m,this.keyHash,it)};function Pe(m,S,C){this.ownerID=m,this.keyHash=S,this.entry=C}Pe.prototype.get=function(m,S,C,L){return Ne(C,this.entry[0])?this.entry[1]:L},Pe.prototype.update=function(m,S,C,L,O,q,z){var J=O===M,de=Ne(L,this.entry[0]);if(de?O===this.entry[1]:J)return this;if(R(z),J){R(q);return}return de?m&&m===this.ownerID?(this.entry[1]=O,this):new Pe(m,this.keyHash,[L,O]):(R(q),ht(this,m,S,rt(L),[L,O]))},Q.prototype.iterate=te.prototype.iterate=function(m,S){for(var C=this.entries,L=0,O=C.length-1;L<=O;L++)if(m(C[S?O-L:L])===!1)return!1},le.prototype.iterate=ce.prototype.iterate=function(m,S){for(var C=this.nodes,L=0,O=C.length-1;L<=O;L++){var q=C[S?O-L:L];if(q&&q.iterate(m,S)===!1)return!1}},Pe.prototype.iterate=function(m,S){return m(this.entry)},n(Ue,j);function Ue(m,S,C){this._type=S,this._reverse=C,this._stack=m._root&&Xe(m._root)}Ue.prototype.next=function(){for(var m=this._type,S=this._stack;S;){var C=S.node,L=S.index++,O;if(C.entry){if(L===0)return Ke(m,C.entry)}else if(C.entries){if(O=C.entries.length-1,L<=O)return Ke(m,C.entries[this._reverse?O-L:L])}else if(O=C.nodes.length-1,L<=O){var q=C.nodes[this._reverse?O-L:L];if(q){if(q.entry)return Ke(m,q.entry);S=this._stack=Xe(q,S)}continue}S=this._stack=this._stack.__prev}return Z()};function Ke(m,S){return ie(m,S[0],S[1])}function Xe(m,S){return{node:m,index:0,__prev:S}}function Qe(m,S,C,L){var O=Object.create(D);return O.size=m,O._root=S,O.__ownerID=C,O.__hash=L,O.__altered=!1,O}var tt;function Ze(){return tt||(tt=Qe(0))}function st(m,S,C){var L,O;if(m._root){var q=w(T),z=w(I);if(L=ct(m._root,m.__ownerID,0,void 0,S,C,q,z),!z.value)return m;O=m.size+(q.value?C===M?-1:1:0)}else{if(C===M)return m;O=1,L=new Q(m.__ownerID,[[S,C]])}return m.__ownerID?(m.size=O,m._root=L,m.__hash=void 0,m.__altered=!0,m):L?Qe(O,L):Ze()}function ct(m,S,C,L,O,q,z,J){return m?m.update(S,C,L,O,q,z,J):q===M?m:(R(J),R(z),new Pe(S,L,[O,q]))}function mt(m){return m.constructor===Pe||m.constructor===te}function ht(m,S,C,L,O){if(m.keyHash===L)return new te(S,L,[m.entry,O]);var q=(C===0?m.keyHash:m.keyHash>>>C)&v,z=(C===0?L:L>>>C)&v,J,de=q===z?[ht(m,S,C+E,L,O)]:(J=new Pe(S,L,O),q<z?[m,J]:[J,m]);return new le(S,1<<q|1<<z,de)}function dt(m,S,C,L){m||(m=new A);for(var O=new Pe(m,rt(C),[C,L]),q=0;q<S.length;q++){var z=S[q];O=O.update(m,0,void 0,z[0],z[1])}return O}function et(m,S,C,L){for(var O=0,q=0,z=new Array(C),J=0,de=1,ge=S.length;J<ge;J++,de<<=1){var we=S[J];we!==void 0&&J!==L&&(O|=de,z[q++]=we)}return new le(m,O,z)}function gt(m,S,C,L,O){for(var q=0,z=new Array(b),J=0;C!==0;J++,C>>>=1)z[J]=C&1?S[q++]:void 0;return z[L]=O,new ce(m,q+1,z)}function at(m,S,C){for(var L=[],O=0;O<C.length;O++){var q=C[O],z=o(q);c(q)||(z=z.map(function(J){return je(J)})),L.push(z)}return Tt(m,S,L)}function Mt(m,S,C){return m&&m.mergeDeep&&c(S)?m.mergeDeep(S):Ne(m,S)?m:S}function Ht(m){return function(S,C,L){if(S&&S.mergeDeepWith&&c(C))return S.mergeDeepWith(m,C);var O=m(S,C,L);return Ne(S,O)?S:O}}function Tt(m,S,C){return C=C.filter(function(L){return L.size!==0}),C.length===0?m:m.size===0&&!m.__ownerID&&C.length===1?m.constructor(C[0]):m.withMutations(function(L){for(var O=S?function(z,J){L.update(J,M,function(de){return de===M?z:S(de,z,J)})}:function(z,J){L.set(J,z)},q=0;q<C.length;q++)C[q].forEach(O)})}function Xt(m,S,C,L){var O=m===M,q=S.next();if(q.done){var z=O?C:m,J=L(z);return J===z?m:J}H(O||m&&m.set,"invalid keyPath");var de=q.value,ge=O?M:m.get(de,M),we=Xt(ge,S,C,L);return we===ge?m:we===M?m.remove(de):(O?Ze():m).set(de,we)}function ft(m){return m=m-(m>>1&1431655765),m=(m&858993459)+(m>>2&858993459),m=m+(m>>4)&252645135,m=m+(m>>8),m=m+(m>>16),m&127}function At(m,S,C,L){var O=L?m:P(m);return O[S]=C,O}function Lt(m,S,C,L){var O=m.length+1;if(L&&S+1===O)return m[S]=C,m;for(var q=new Array(O),z=0,J=0;J<O;J++)J===S?(q[J]=C,z=-1):q[J]=m[J+z];return q}function Et(m,S,C){var L=m.length-1;if(C&&S===L)return m.pop(),m;for(var O=new Array(L),q=0,z=0;z<L;z++)z===S&&(q=1),O[z]=m[z+q];return O}var Rt=b/4,hn=b/2,$t=b/4;n(_t,Re);function _t(m){var S=Cn();if(m==null)return S;if(Gn(m))return m;var C=a(m),L=C.size;return L===0?S:(wt(L),L>0&&L<b?pn(0,L,E,null,new Yt(C.toArray())):S.withMutations(function(O){O.setSize(L),C.forEach(function(q,z){return O.set(z,q)})}))}_t.of=function(){return this(arguments)},_t.prototype.toString=function(){return this.__toString("List [","]")},_t.prototype.get=function(m,S){if(m=k(this,m),m>=0&&m<this.size){m+=this._origin;var C=$n(this,m);return C&&C.array[m&v]}return S},_t.prototype.set=function(m,S){return br(this,m,S)},_t.prototype.remove=function(m){return this.has(m)?m===0?this.shift():m===this.size-1?this.pop():this.splice(m,1):this},_t.prototype.insert=function(m,S){return this.splice(m,0,S)},_t.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=this._origin=this._capacity=0,this._level=E,this._root=this._tail=null,this.__hash=void 0,this.__altered=!0,this):Cn()},_t.prototype.push=function(){var m=arguments,S=this.size;return this.withMutations(function(C){Kt(C,0,S+m.length);for(var L=0;L<m.length;L++)C.set(S+L,m[L])})},_t.prototype.pop=function(){return Kt(this,0,-1)},_t.prototype.unshift=function(){var m=arguments;return this.withMutations(function(S){Kt(S,-m.length);for(var C=0;C<m.length;C++)S.set(C,m[C])})},_t.prototype.shift=function(){return Kt(this,1)},_t.prototype.merge=function(){return Sn(this,void 0,arguments)},_t.prototype.mergeWith=function(m){var S=t.call(arguments,1);return Sn(this,m,S)},_t.prototype.mergeDeep=function(){return Sn(this,Mt,arguments)},_t.prototype.mergeDeepWith=function(m){var S=t.call(arguments,1);return Sn(this,Ht(m),S)},_t.prototype.setSize=function(m){return Kt(this,0,m)},_t.prototype.slice=function(m,S){var C=this.size;return Y(m,S,C)?this:Kt(this,$(m,C),ee(S,C))},_t.prototype.__iterator=function(m,S){var C=0,L=jn(this,S);return new j(function(){var O=L();return O===dn?Z():ie(m,C++,O)})},_t.prototype.__iterate=function(m,S){for(var C=0,L=jn(this,S),O;(O=L())!==dn&&m(O,C++,this)!==!1;);return C},_t.prototype.__ensureOwner=function(m){return m===this.__ownerID?this:m?pn(this._origin,this._capacity,this._level,this._root,this._tail,m,this.__hash):(this.__ownerID=m,this)};function Gn(m){return!!(m&&m[zn])}_t.isList=Gn;var zn="@@__IMMUTABLE_LIST__@@",It=_t.prototype;It[zn]=!0,It[y]=It.remove,It.setIn=D.setIn,It.deleteIn=It.removeIn=D.removeIn,It.update=D.update,It.updateIn=D.updateIn,It.mergeIn=D.mergeIn,It.mergeDeepIn=D.mergeDeepIn,It.withMutations=D.withMutations,It.asMutable=D.asMutable,It.asImmutable=D.asImmutable,It.wasAltered=D.wasAltered;function Yt(m,S){this.array=m,this.ownerID=S}Yt.prototype.removeBefore=function(m,S,C){if(C===S?1<<S:this.array.length===0)return this;var L=C>>>S&v;if(L>=this.array.length)return new Yt([],m);var O=L===0,q;if(S>0){var z=this.array[L];if(q=z&&z.removeBefore(m,S-E,C),q===z&&O)return this}if(O&&!q)return this;var J=en(this,m);if(!O)for(var de=0;de<L;de++)J.array[de]=void 0;return q&&(J.array[L]=q),J},Yt.prototype.removeAfter=function(m,S,C){if(C===(S?1<<S:0)||this.array.length===0)return this;var L=C-1>>>S&v;if(L>=this.array.length)return this;var O;if(S>0){var q=this.array[L];if(O=q&&q.removeAfter(m,S-E,C),O===q&&L===this.array.length-1)return this}var z=en(this,m);return z.array.splice(L+1),O&&(z.array[L]=O),z};var dn={};function jn(m,S){var C=m._origin,L=m._capacity,O=fn(L),q=m._tail;return z(m._root,m._level,0);function z(ge,we,He){return we===0?J(ge,He):de(ge,we,He)}function J(ge,we){var He=we===O?q&&q.array:ge&&ge.array,Je=we>C?0:C-we,it=L-we;return it>b&&(it=b),function(){if(Je===it)return dn;var ot=S?--it:Je++;return He&&He[ot]}}function de(ge,we,He){var Je,it=ge&&ge.array,ot=He>C?0:C-He>>we,yt=(L-He>>we)+1;return yt>b&&(yt=b),function(){do{if(Je){var Ut=Je();if(Ut!==dn)return Ut;Je=null}if(ot===yt)return dn;var jt=S?--yt:ot++;Je=z(it&&it[jt],we-E,He+(jt<<we))}while(!0)}}}function pn(m,S,C,L,O,q,z){var J=Object.create(It);return J.size=S-m,J._origin=m,J._capacity=S,J._level=C,J._root=L,J._tail=O,J.__ownerID=q,J.__hash=z,J.__altered=!1,J}var Hn;function Cn(){return Hn||(Hn=pn(0,0,E))}function br(m,S,C){if(S=k(m,S),S!==S)return m;if(S>=m.size||S<0)return m.withMutations(function(z){S<0?Kt(z,S).set(0,C):Kt(z,0,S+1).set(S,C)});S+=m._origin;var L=m._tail,O=m._root,q=w(I);return S>=fn(m._capacity)?L=Pn(L,m.__ownerID,0,S,C,q):O=Pn(O,m.__ownerID,m._level,S,C,q),q.value?m.__ownerID?(m._root=O,m._tail=L,m.__hash=void 0,m.__altered=!0,m):pn(m._origin,m._capacity,m._level,O,L):m}function Pn(m,S,C,L,O,q){var z=L>>>C&v,J=m&&z<m.array.length;if(!J&&O===void 0)return m;var de;if(C>0){var ge=m&&m.array[z],we=Pn(ge,S,C-E,L,O,q);return we===ge?m:(de=en(m,S),de.array[z]=we,de)}return J&&m.array[z]===O?m:(R(q),de=en(m,S),O===void 0&&z===de.array.length-1?de.array.pop():de.array[z]=O,de)}function en(m,S){return S&&m&&S===m.ownerID?m:new Yt(m?m.array.slice():[],S)}function $n(m,S){if(S>=fn(m._capacity))return m._tail;if(S<1<<m._level+E){for(var C=m._root,L=m._level;C&&L>0;)C=C.array[S>>>L&v],L-=E;return C}}function Kt(m,S,C){S!==void 0&&(S=S|0),C!==void 0&&(C=C|0);var L=m.__ownerID||new A,O=m._origin,q=m._capacity,z=O+S,J=C===void 0?q:C<0?q+C:O+C;if(z===O&&J===q)return m;if(z>=J)return m.clear();for(var de=m._level,ge=m._root,we=0;z+we<0;)ge=new Yt(ge&&ge.array.length?[void 0,ge]:[],L),de+=E,we+=1<<de;we&&(z+=we,O+=we,J+=we,q+=we);for(var He=fn(q),Je=fn(J);Je>=1<<de+E;)ge=new Yt(ge&&ge.array.length?[ge]:[],L),de+=E;var it=m._tail,ot=Je<He?$n(m,J-1):Je>He?new Yt([],L):it;if(it&&Je>He&&z<q&&it.array.length){ge=en(ge,L);for(var yt=ge,Ut=de;Ut>E;Ut-=E){var jt=He>>>Ut&v;yt=yt.array[jt]=en(yt.array[jt],L)}yt.array[He>>>E&v]=it}if(J<q&&(ot=ot&&ot.removeAfter(L,0,J)),z>=Je)z-=Je,J-=Je,de=E,ge=null,ot=ot&&ot.removeBefore(L,0,z);else if(z>O||Je<He){for(we=0;ge;){var An=z>>>de&v;if(An!==Je>>>de&v)break;An&&(we+=(1<<de)*An),de-=E,ge=ge.array[An]}ge&&z>O&&(ge=ge.removeBefore(L,de,z-we)),ge&&Je<He&&(ge=ge.removeAfter(L,de,Je-we)),we&&(z-=we,J-=we)}return m.__ownerID?(m.size=J-z,m._origin=z,m._capacity=J,m._level=de,m._root=ge,m._tail=ot,m.__hash=void 0,m.__altered=!0,m):pn(z,J,de,ge,ot)}function Sn(m,S,C){for(var L=[],O=0,q=0;q<C.length;q++){var z=C[q],J=a(z);J.size>O&&(O=J.size),c(z)||(J=J.map(function(de){return je(de)})),L.push(J)}return O>m.size&&(m=m.setSize(O)),Tt(m,S,L)}function fn(m){return m<b?0:m-1>>>E<<E}n(vt,lt);function vt(m){return m==null?En():Wn(m)?m:En().withMutations(function(S){var C=o(m);wt(C.size),C.forEach(function(L,O){return S.set(O,L)})})}vt.of=function(){return this(arguments)},vt.prototype.toString=function(){return this.__toString("OrderedMap {","}")},vt.prototype.get=function(m,S){var C=this._map.get(m);return C!==void 0?this._list.get(C)[1]:S},vt.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):En()},vt.prototype.set=function(m,S){return Yn(this,m,S)},vt.prototype.remove=function(m){return Yn(this,m,M)},vt.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},vt.prototype.__iterate=function(m,S){var C=this;return this._list.__iterate(function(L){return L&&m(L[1],L[0],C)},S)},vt.prototype.__iterator=function(m,S){return this._list.fromEntrySeq().__iterator(m,S)},vt.prototype.__ensureOwner=function(m){if(m===this.__ownerID)return this;var S=this._map.__ensureOwner(m),C=this._list.__ensureOwner(m);return m?Ln(S,C,m,this.__hash):(this.__ownerID=m,this._map=S,this._list=C,this)};function Wn(m){return un(m)&&p(m)}vt.isOrderedMap=Wn,vt.prototype[x]=!0,vt.prototype[y]=vt.prototype.remove;function Ln(m,S,C,L){var O=Object.create(vt.prototype);return O.size=m?m.size:0,O._map=m,O._list=S,O.__ownerID=C,O.__hash=L,O}var Xn;function En(){return Xn||(Xn=Ln(Ze(),Cn()))}function Yn(m,S,C){var L=m._map,O=m._list,q=L.get(S),z=q!==void 0,J,de;if(C===M){if(!z)return m;O.size>=b&&O.size>=L.size*2?(de=O.filter(function(ge,we){return ge!==void 0&&q!==we}),J=de.toKeyedSeq().map(function(ge){return ge[0]}).flip().toMap(),m.__ownerID&&(J.__ownerID=de.__ownerID=m.__ownerID)):(J=L.remove(S),de=q===O.size-1?O.pop():O.set(q,void 0))}else if(z){if(C===O.get(q)[1])return m;J=L,de=O.set(q,[S,C])}else J=L.set(S,O.size),de=O.set(O.size,[S,C]);return m.__ownerID?(m.size=J.size,m._map=J,m._list=de,m.__hash=void 0,m):Ln(J,de)}n(kt,pe);function kt(m,S){this._iter=m,this._useKeys=S,this.size=m.size}kt.prototype.get=function(m,S){return this._iter.get(m,S)},kt.prototype.has=function(m){return this._iter.has(m)},kt.prototype.valueSeq=function(){return this._iter.valueSeq()},kt.prototype.reverse=function(){var m=this,S=On(this,!0);return this._useKeys||(S.valueSeq=function(){return m._iter.toSeq().reverse()}),S},kt.prototype.map=function(m,S){var C=this,L=Zn(this,m,S);return this._useKeys||(L.valueSeq=function(){return C._iter.toSeq().map(m,S)}),L},kt.prototype.__iterate=function(m,S){var C=this,L;return this._iter.__iterate(this._useKeys?function(O,q){return m(O,q,C)}:(L=S?rr(this):0,function(O){return m(O,S?--L:L++,C)}),S)},kt.prototype.__iterator=function(m,S){if(this._useKeys)return this._iter.__iterator(m,S);var C=this._iter.__iterator(F,S),L=S?rr(this):0;return new j(function(){var O=C.next();return O.done?O:ie(m,S?--L:L++,O.value,O)})},kt.prototype[x]=!0,n(tn,ae);function tn(m){this._iter=m,this.size=m.size}tn.prototype.includes=function(m){return this._iter.includes(m)},tn.prototype.__iterate=function(m,S){var C=this,L=0;return this._iter.__iterate(function(O){return m(O,L++,C)},S)},tn.prototype.__iterator=function(m,S){var C=this._iter.__iterator(F,S),L=0;return new j(function(){var O=C.next();return O.done?O:ie(m,L++,O.value,O)})},n(nn,Te);function nn(m){this._iter=m,this.size=m.size}nn.prototype.has=function(m){return this._iter.includes(m)},nn.prototype.__iterate=function(m,S){var C=this;return this._iter.__iterate(function(L){return m(L,L,C)},S)},nn.prototype.__iterator=function(m,S){var C=this._iter.__iterator(F,S);return new j(function(){var L=C.next();return L.done?L:ie(m,L.value,L.value,L)})},n(rn,pe);function rn(m){this._iter=m,this.size=m.size}rn.prototype.entrySeq=function(){return this._iter.toSeq()},rn.prototype.__iterate=function(m,S){var C=this;return this._iter.__iterate(function(L){if(L){nr(L);var O=c(L);return m(O?L.get(1):L[1],O?L.get(0):L[0],C)}},S)},rn.prototype.__iterator=function(m,S){var C=this._iter.__iterator(F,S);return new j(function(){for(;;){var L=C.next();if(L.done)return L;var O=L.value;if(O){nr(O);var q=c(O);return ie(m,q?O.get(0):O[0],q?O.get(1):O[1],L)}}})},tn.prototype.cacheResult=kt.prototype.cacheResult=nn.prototype.cacheResult=rn.prototype.cacheResult=Fn;function Kn(m){var S=Vt(m);return S._iter=m,S.size=m.size,S.flip=function(){return m},S.reverse=function(){var C=m.reverse.apply(this);return C.flip=function(){return m.reverse()},C},S.has=function(C){return m.includes(C)},S.includes=function(C){return m.has(C)},S.cacheResult=Fn,S.__iterateUncached=function(C,L){var O=this;return m.__iterate(function(q,z){return C(z,q,O)!==!1},L)},S.__iteratorUncached=function(C,L){if(C===X){var O=m.__iterator(C,L);return new j(function(){var q=O.next();if(!q.done){var z=q.value[0];q.value[0]=q.value[1],q.value[1]=z}return q})}return m.__iterator(C===F?K:F,L)},S}function Zn(m,S,C){var L=Vt(m);return L.size=m.size,L.has=function(O){return m.has(O)},L.get=function(O,q){var z=m.get(O,M);return z===M?q:S.call(C,z,O,m)},L.__iterateUncached=function(O,q){var z=this;return m.__iterate(function(J,de,ge){return O(S.call(C,J,de,ge),de,z)!==!1},q)},L.__iteratorUncached=function(O,q){var z=m.__iterator(X,q);return new j(function(){var J=z.next();if(J.done)return J;var de=J.value,ge=de[0];return ie(O,ge,S.call(C,de[1],ge,m),J)})},L}function On(m,S){var C=Vt(m);return C._iter=m,C.size=m.size,C.reverse=function(){return m},m.flip&&(C.flip=function(){var L=Kn(m);return L.reverse=function(){return m.flip()},L}),C.get=function(L,O){return m.get(S?L:-1-L,O)},C.has=function(L){return m.has(S?L:-1-L)},C.includes=function(L){return m.includes(L)},C.cacheResult=Fn,C.__iterate=function(L,O){var q=this;return m.__iterate(function(z,J){return L(z,J,q)},!O)},C.__iterator=function(L,O){return m.__iterator(L,!O)},C}function Jn(m,S,C,L){var O=Vt(m);return L&&(O.has=function(q){var z=m.get(q,M);return z!==M&&!!S.call(C,z,q,m)},O.get=function(q,z){var J=m.get(q,M);return J!==M&&S.call(C,J,q,m)?J:z}),O.__iterateUncached=function(q,z){var J=this,de=0;return m.__iterate(function(ge,we,He){if(S.call(C,ge,we,He))return de++,q(ge,L?we:de-1,J)},z),de},O.__iteratorUncached=function(q,z){var J=m.__iterator(X,z),de=0;return new j(function(){for(;;){var ge=J.next();if(ge.done)return ge;var we=ge.value,He=we[0],Je=we[1];if(S.call(C,Je,He,m))return ie(q,L?He:de++,Je,ge)}})},O}function Mr(m,S,C){var L=lt().asMutable();return m.__iterate(function(O,q){L.update(S.call(C,O,q,m),0,function(z){return z+1})}),L.asImmutable()}function Tr(m,S,C){var L=u(m),O=(p(m)?vt():lt()).asMutable();m.__iterate(function(z,J){O.update(S.call(C,z,J,m),function(de){return de=de||[],de.push(L?[J,z]:z),de})});var q=ir(m);return O.map(function(z){return pt(m,q(z))})}function Nn(m,S,C,L){var O=m.size;if(S!==void 0&&(S=S|0),C!==void 0&&(C===1/0?C=O:C=C|0),Y(S,C,O))return m;var q=$(S,O),z=ee(C,O);if(q!==q||z!==z)return Nn(m.toSeq().cacheResult(),S,C,L);var J=z-q,de;J===J&&(de=J<0?0:J);var ge=Vt(m);return ge.size=de===0?de:m.size&&de||void 0,!L&&$e(m)&&de>=0&&(ge.get=function(we,He){return we=k(this,we),we>=0&&we<de?m.get(we+q,He):He}),ge.__iterateUncached=function(we,He){var Je=this;if(de===0)return 0;if(He)return this.cacheResult().__iterate(we,He);var it=0,ot=!0,yt=0;return m.__iterate(function(Ut,jt){if(!(ot&&(ot=it++<q)))return yt++,we(Ut,L?jt:yt-1,Je)!==!1&&yt!==de}),yt},ge.__iteratorUncached=function(we,He){if(de!==0&&He)return this.cacheResult().__iterator(we,He);var Je=de!==0&&m.__iterator(we,He),it=0,ot=0;return new j(function(){for(;it++<q;)Je.next();if(++ot>de)return Z();var yt=Je.next();return L||we===F?yt:we===K?ie(we,ot-1,void 0,yt):ie(we,ot-1,yt.value[1],yt)})},ge}function Rr(m,S,C){var L=Vt(m);return L.__iterateUncached=function(O,q){var z=this;if(q)return this.cacheResult().__iterate(O,q);var J=0;return m.__iterate(function(de,ge,we){return S.call(C,de,ge,we)&&++J&&O(de,ge,z)}),J},L.__iteratorUncached=function(O,q){var z=this;if(q)return this.cacheResult().__iterator(O,q);var J=m.__iterator(X,q),de=!0;return new j(function(){if(!de)return Z();var ge=J.next();if(ge.done)return ge;var we=ge.value,He=we[0],Je=we[1];return S.call(C,Je,He,z)?O===X?ge:ie(O,He,Je,ge):(de=!1,Z())})},L}function Qn(m,S,C,L){var O=Vt(m);return O.__iterateUncached=function(q,z){var J=this;if(z)return this.cacheResult().__iterate(q,z);var de=!0,ge=0;return m.__iterate(function(we,He,Je){if(!(de&&(de=S.call(C,we,He,Je))))return ge++,q(we,L?He:ge-1,J)}),ge},O.__iteratorUncached=function(q,z){var J=this;if(z)return this.cacheResult().__iterator(q,z);var de=m.__iterator(X,z),ge=!0,we=0;return new j(function(){var He,Je,it;do{if(He=de.next(),He.done)return L||q===F?He:q===K?ie(q,we++,void 0,He):ie(q,we++,He.value[1],He);var ot=He.value;Je=ot[0],it=ot[1],ge&&(ge=S.call(C,it,Je,J))}while(ge);return q===X?He:ie(q,Je,it,He)})},O}function wr(m,S){var C=u(m),L=[m].concat(S).map(function(z){return c(z)?C&&(z=o(z)):z=C?ne(z):he(Array.isArray(z)?z:[z]),z}).filter(function(z){return z.size!==0});if(L.length===0)return m;if(L.length===1){var O=L[0];if(O===m||C&&u(O)||h(m)&&h(O))return O}var q=new ye(L);return C?q=q.toKeyedSeq():h(m)||(q=q.toSetSeq()),q=q.flatten(!0),q.size=L.reduce(function(z,J){if(z!==void 0){var de=J.size;if(de!==void 0)return z+de}},0),q}function er(m,S,C){var L=Vt(m);return L.__iterateUncached=function(O,q){var z=0,J=!1;function de(ge,we){var He=this;ge.__iterate(function(Je,it){return(!S||we<S)&&c(Je)?de(Je,we+1):O(Je,C?it:z++,He)===!1&&(J=!0),!J},q)}return de(m,0),z},L.__iteratorUncached=function(O,q){var z=m.__iterator(O,q),J=[],de=0;return new j(function(){for(;z;){var ge=z.next();if(ge.done!==!1){z=J.pop();continue}var we=ge.value;if(O===X&&(we=we[1]),(!S||J.length<S)&&c(we))J.push(z),z=we.__iterator(O,q);else return C?ge:ie(O,de++,we,ge)}return Z()})},L}function Ar(m,S,C){var L=ir(m);return m.toSeq().map(function(O,q){return L(S.call(C,O,q,m))}).flatten(!0)}function Ir(m,S){var C=Vt(m);return C.size=m.size&&m.size*2-1,C.__iterateUncached=function(L,O){var q=this,z=0;return m.__iterate(function(J,de){return(!z||L(S,z++,q)!==!1)&&L(J,z++,q)!==!1},O),z},C.__iteratorUncached=function(L,O){var q=m.__iterator(F,O),z=0,J;return new j(function(){return(!J||z%2)&&(J=q.next(),J.done)?J:z%2?ie(L,z++,S):ie(L,z++,J.value,J)})},C}function sn(m,S,C){S||(S=sr);var L=u(m),O=0,q=m.toSeq().map(function(z,J){return[J,z,O++,C?C(z,J,m):z]}).toArray();return q.sort(function(z,J){return S(z[3],J[3])||z[2]-J[2]}).forEach(L?function(z,J){q[J].length=2}:function(z,J){q[J]=z[1]}),L?pe(q):h(m)?ae(q):Te(q)}function bn(m,S,C){if(S||(S=sr),C){var L=m.toSeq().map(function(O,q){return[O,C(O,q,m)]}).reduce(function(O,q){return tr(S,O[1],q[1])?q:O});return L&&L[0]}else return m.reduce(function(O,q){return tr(S,O,q)?q:O})}function tr(m,S,C){var L=m(C,S);return L===0&&C!==S&&(C==null||C!==C)||L>0}function Dn(m,S,C){var L=Vt(m);return L.size=new ye(C).map(function(O){return O.size}).min(),L.__iterate=function(O,q){for(var z=this.__iterator(F,q),J,de=0;!(J=z.next()).done&&O(J.value,de++,this)!==!1;);return de},L.__iteratorUncached=function(O,q){var z=C.map(function(ge){return ge=s(ge),re(q?ge.reverse():ge)}),J=0,de=!1;return new j(function(){var ge;return de||(ge=z.map(function(we){return we.next()}),de=ge.some(function(we){return we.done})),de?Z():ie(O,J++,S.apply(null,ge.map(function(we){return we.value})))})},L}function pt(m,S){return $e(m)?S:m.constructor(S)}function nr(m){if(m!==Object(m))throw new TypeError("Expected [K, V] tuple: "+m)}function rr(m){return wt(m.size),B(m)}function ir(m){return u(m)?o:h(m)?a:l}function Vt(m){return Object.create((u(m)?pe:h(m)?ae:Te).prototype)}function Fn(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):V.prototype.cacheResult.call(this)}function sr(m,S){return m>S?1:m<S?-1:0}function or(m){var S=re(m);if(!S){if(!oe(m))throw new TypeError("Expected iterable or array-like: "+m);S=re(s(m))}return S}n(Nt,De);function Nt(m,S){var C,L=function(z){if(z instanceof L)return z;if(!(this instanceof L))return new L(z);if(!C){C=!0;var J=Object.keys(m);Cr(O,J),O.size=J.length,O._name=S,O._keys=J,O._defaultValues=m}this._map=lt(z)},O=L.prototype=Object.create(bt);return O.constructor=L,L}Nt.prototype.toString=function(){return this.__toString(ar(this)+" {","}")},Nt.prototype.has=function(m){return this._defaultValues.hasOwnProperty(m)},Nt.prototype.get=function(m,S){if(!this.has(m))return S;var C=this._defaultValues[m];return this._map?this._map.get(m,C):C},Nt.prototype.clear=function(){if(this.__ownerID)return this._map&&this._map.clear(),this;var m=this.constructor;return m._empty||(m._empty=Mn(this,Ze()))},Nt.prototype.set=function(m,S){if(!this.has(m))throw new Error('Cannot set unknown key "'+m+'" on '+ar(this));if(this._map&&!this._map.has(m)){var C=this._defaultValues[m];if(S===C)return this}var L=this._map&&this._map.set(m,S);return this.__ownerID||L===this._map?this:Mn(this,L)},Nt.prototype.remove=function(m){if(!this.has(m))return this;var S=this._map&&this._map.remove(m);return this.__ownerID||S===this._map?this:Mn(this,S)},Nt.prototype.wasAltered=function(){return this._map.wasAltered()},Nt.prototype.__iterator=function(m,S){var C=this;return o(this._defaultValues).map(function(L,O){return C.get(O)}).__iterator(m,S)},Nt.prototype.__iterate=function(m,S){var C=this;return o(this._defaultValues).map(function(L,O){return C.get(O)}).__iterate(m,S)},Nt.prototype.__ensureOwner=function(m){if(m===this.__ownerID)return this;var S=this._map&&this._map.__ensureOwner(m);return m?Mn(this,S,m):(this.__ownerID=m,this._map=S,this)};var bt=Nt.prototype;bt[y]=bt.remove,bt.deleteIn=bt.removeIn=D.removeIn,bt.merge=D.merge,bt.mergeWith=D.mergeWith,bt.mergeIn=D.mergeIn,bt.mergeDeep=D.mergeDeep,bt.mergeDeepWith=D.mergeDeepWith,bt.mergeDeepIn=D.mergeDeepIn,bt.setIn=D.setIn,bt.update=D.update,bt.updateIn=D.updateIn,bt.withMutations=D.withMutations,bt.asMutable=D.asMutable,bt.asImmutable=D.asImmutable;function Mn(m,S,C){var L=Object.create(Object.getPrototypeOf(m));return L._map=S,L.__ownerID=C,L}function ar(m){return m._name||m.constructor.name||"Record"}function Cr(m,S){try{S.forEach(Pr.bind(void 0,m))}catch{}}function Pr(m,S){Object.defineProperty(m,S,{get:function(){return this.get(S)},set:function(C){H(this.__ownerID,"Cannot set on an immutable record."),this.set(S,C)}})}n(xt,Ye);function xt(m){return m==null?Un():kn(m)&&!p(m)?m:Un().withMutations(function(S){var C=l(m);wt(C.size),C.forEach(function(L){return S.add(L)})})}xt.of=function(){return this(arguments)},xt.fromKeys=function(m){return this(o(m).keySeq())},xt.prototype.toString=function(){return this.__toString("Set {","}")},xt.prototype.has=function(m){return this._map.has(m)},xt.prototype.add=function(m){return Bn(this,this._map.set(m,!0))},xt.prototype.remove=function(m){return Bn(this,this._map.remove(m))},xt.prototype.clear=function(){return Bn(this,this._map.clear())},xt.prototype.union=function(){var m=t.call(arguments,0);return m=m.filter(function(S){return S.size!==0}),m.length===0?this:this.size===0&&!this.__ownerID&&m.length===1?this.constructor(m[0]):this.withMutations(function(S){for(var C=0;C<m.length;C++)l(m[C]).forEach(function(L){return S.add(L)})})},xt.prototype.intersect=function(){var m=t.call(arguments,0);if(m.length===0)return this;m=m.map(function(C){return l(C)});var S=this;return this.withMutations(function(C){S.forEach(function(L){m.every(function(O){return O.includes(L)})||C.remove(L)})})},xt.prototype.subtract=function(){var m=t.call(arguments,0);if(m.length===0)return this;m=m.map(function(C){return l(C)});var S=this;return this.withMutations(function(C){S.forEach(function(L){m.some(function(O){return O.includes(L)})&&C.remove(L)})})},xt.prototype.merge=function(){return this.union.apply(this,arguments)},xt.prototype.mergeWith=function(m){var S=t.call(arguments,1);return this.union.apply(this,S)},xt.prototype.sort=function(m){return Gt(sn(this,m))},xt.prototype.sortBy=function(m,S){return Gt(sn(this,S,m))},xt.prototype.wasAltered=function(){return this._map.wasAltered()},xt.prototype.__iterate=function(m,S){var C=this;return this._map.__iterate(function(L,O){return m(O,O,C)},S)},xt.prototype.__iterator=function(m,S){return this._map.map(function(C,L){return L}).__iterator(m,S)},xt.prototype.__ensureOwner=function(m){if(m===this.__ownerID)return this;var S=this._map.__ensureOwner(m);return m?this.__make(S,m):(this.__ownerID=m,this._map=S,this)};function kn(m){return!!(m&&m[lr])}xt.isSet=kn;var lr="@@__IMMUTABLE_SET__@@",Dt=xt.prototype;Dt[lr]=!0,Dt[y]=Dt.remove,Dt.mergeDeep=Dt.merge,Dt.mergeDeepWith=Dt.mergeWith,Dt.withMutations=D.withMutations,Dt.asMutable=D.asMutable,Dt.asImmutable=D.asImmutable,Dt.__empty=Un,Dt.__make=cr;function Bn(m,S){return m.__ownerID?(m.size=S.size,m._map=S,m):S===m._map?m:S.size===0?m.__empty():m.__make(S)}function cr(m,S){var C=Object.create(Dt);return C.size=m?m.size:0,C._map=m,C.__ownerID=S,C}var ur;function Un(){return ur||(ur=cr(Ze()))}n(Gt,xt);function Gt(m){return m==null?qn():hr(m)?m:qn().withMutations(function(S){var C=l(m);wt(C.size),C.forEach(function(L){return S.add(L)})})}Gt.of=function(){return this(arguments)},Gt.fromKeys=function(m){return this(o(m).keySeq())},Gt.prototype.toString=function(){return this.__toString("OrderedSet {","}")};function hr(m){return kn(m)&&p(m)}Gt.isOrderedSet=hr;var Tn=Gt.prototype;Tn[x]=!0,Tn.__empty=qn,Tn.__make=dr;function dr(m,S){var C=Object.create(Tn);return C.size=m?m.size:0,C._map=m,C.__ownerID=S,C}var pr;function qn(){return pr||(pr=dr(En()))}n(St,Re);function St(m){return m==null?Vn():fr(m)?m:Vn().unshiftAll(m)}St.of=function(){return this(arguments)},St.prototype.toString=function(){return this.__toString("Stack [","]")},St.prototype.get=function(m,S){var C=this._head;for(m=k(this,m);C&&m--;)C=C.next;return C?C.value:S},St.prototype.peek=function(){return this._head&&this._head.value},St.prototype.push=function(){if(arguments.length===0)return this;for(var m=this.size+arguments.length,S=this._head,C=arguments.length-1;C>=0;C--)S={value:arguments[C],next:S};return this.__ownerID?(this.size=m,this._head=S,this.__hash=void 0,this.__altered=!0,this):mn(m,S)},St.prototype.pushAll=function(m){if(m=a(m),m.size===0)return this;wt(m.size);var S=this.size,C=this._head;return m.reverse().forEach(function(L){S++,C={value:L,next:C}}),this.__ownerID?(this.size=S,this._head=C,this.__hash=void 0,this.__altered=!0,this):mn(S,C)},St.prototype.pop=function(){return this.slice(1)},St.prototype.unshift=function(){return this.push.apply(this,arguments)},St.prototype.unshiftAll=function(m){return this.pushAll(m)},St.prototype.shift=function(){return this.pop.apply(this,arguments)},St.prototype.clear=function(){return this.size===0?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Vn()},St.prototype.slice=function(m,S){if(Y(m,S,this.size))return this;var C=$(m,this.size),L=ee(S,this.size);if(L!==this.size)return Re.prototype.slice.call(this,m,S);for(var O=this.size-C,q=this._head;C--;)q=q.next;return this.__ownerID?(this.size=O,this._head=q,this.__hash=void 0,this.__altered=!0,this):mn(O,q)},St.prototype.__ensureOwner=function(m){return m===this.__ownerID?this:m?mn(this.size,this._head,m,this.__hash):(this.__ownerID=m,this.__altered=!1,this)},St.prototype.__iterate=function(m,S){if(S)return this.reverse().__iterate(m);for(var C=0,L=this._head;L&&m(L.value,C++,this)!==!1;)L=L.next;return C},St.prototype.__iterator=function(m,S){if(S)return this.reverse().__iterator(m);var C=0,L=this._head;return new j(function(){if(L){var O=L.value;return L=L.next,ie(m,C++,O)}return Z()})};function fr(m){return!!(m&&m[mr])}St.isStack=fr;var mr="@@__IMMUTABLE_STACK__@@",on=St.prototype;on[mr]=!0,on.withMutations=D.withMutations,on.asMutable=D.asMutable,on.asImmutable=D.asImmutable,on.wasAltered=D.wasAltered;function mn(m,S,C,L){var O=Object.create(on);return O.size=m,O._head=S,O.__ownerID=C,O.__hash=L,O.__altered=!1,O}var gr;function Vn(){return gr||(gr=mn(0))}function zt(m,S){var C=function(L){m.prototype[L]=S[L]};return Object.keys(S).forEach(C),Object.getOwnPropertySymbols&&Object.getOwnPropertySymbols(S).forEach(C),m}s.Iterator=j,zt(s,{toArray:function(){wt(this.size);var m=new Array(this.size||0);return this.valueSeq().__iterate(function(S,C){m[C]=S}),m},toIndexedSeq:function(){return new tn(this)},toJS:function(){return this.toSeq().map(function(m){return m&&typeof m.toJS=="function"?m.toJS():m}).__toJS()},toJSON:function(){return this.toSeq().map(function(m){return m&&typeof m.toJSON=="function"?m.toJSON():m}).__toJS()},toKeyedSeq:function(){return new kt(this,!0)},toMap:function(){return lt(this.toKeyedSeq())},toObject:function(){wt(this.size);var m={};return this.__iterate(function(S,C){m[C]=S}),m},toOrderedMap:function(){return vt(this.toKeyedSeq())},toOrderedSet:function(){return Gt(u(this)?this.valueSeq():this)},toSet:function(){return xt(u(this)?this.valueSeq():this)},toSetSeq:function(){return new nn(this)},toSeq:function(){return h(this)?this.toIndexedSeq():u(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return St(u(this)?this.valueSeq():this)},toList:function(){return _t(u(this)?this.valueSeq():this)},toString:function(){return"[Iterable]"},__toString:function(m,S){return this.size===0?m+S:m+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+S},concat:function(){var m=t.call(arguments,0);return pt(this,wr(this,m))},includes:function(m){return this.some(function(S){return Ne(S,m)})},entries:function(){return this.__iterator(X)},every:function(m,S){wt(this.size);var C=!0;return this.__iterate(function(L,O,q){if(!m.call(S,L,O,q))return C=!1,!1}),C},filter:function(m,S){return pt(this,Jn(this,m,S,!0))},find:function(m,S,C){var L=this.findEntry(m,S);return L?L[1]:C},forEach:function(m,S){return wt(this.size),this.__iterate(S?m.bind(S):m)},join:function(m){wt(this.size),m=m!==void 0?""+m:",";var S="",C=!0;return this.__iterate(function(L){C?C=!1:S+=m,S+=L!=null?L.toString():""}),S},keys:function(){return this.__iterator(K)},map:function(m,S){return pt(this,Zn(this,m,S))},reduce:function(m,S,C){wt(this.size);var L,O;return arguments.length<2?O=!0:L=S,this.__iterate(function(q,z,J){O?(O=!1,L=q):L=m.call(C,L,q,z,J)}),L},reduceRight:function(m,S,C){var L=this.toKeyedSeq().reverse();return L.reduce.apply(L,arguments)},reverse:function(){return pt(this,On(this,!0))},slice:function(m,S){return pt(this,Nn(this,m,S,!0))},some:function(m,S){return!this.every(wn(m),S)},sort:function(m){return pt(this,sn(this,m))},values:function(){return this.__iterator(F)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return this.size!==void 0?this.size===0:!this.some(function(){return!0})},count:function(m,S){return B(m?this.toSeq().filter(m,S):this)},countBy:function(m,S){return Mr(this,m,S)},equals:function(m){return Ce(this,m)},entrySeq:function(){var m=this;if(m._cache)return new ye(m._cache);var S=m.toSeq().map(Or).toIndexedSeq();return S.fromEntrySeq=function(){return m.toSeq()},S},filterNot:function(m,S){return this.filter(wn(m),S)},findEntry:function(m,S,C){var L=C;return this.__iterate(function(O,q,z){if(m.call(S,O,q,z))return L=[q,O],!1}),L},findKey:function(m,S){var C=this.findEntry(m,S);return C&&C[0]},findLast:function(m,S,C){return this.toKeyedSeq().reverse().find(m,S,C)},findLastEntry:function(m,S,C){return this.toKeyedSeq().reverse().findEntry(m,S,C)},findLastKey:function(m,S){return this.toKeyedSeq().reverse().findKey(m,S)},first:function(){return this.find(W)},flatMap:function(m,S){return pt(this,Ar(this,m,S))},flatten:function(m){return pt(this,er(this,m,!0))},fromEntrySeq:function(){return new rn(this)},get:function(m,S){return this.find(function(C,L){return Ne(L,m)},void 0,S)},getIn:function(m,S){for(var C=this,L=or(m),O;!(O=L.next()).done;){var q=O.value;if(C=C&&C.get?C.get(q,M):M,C===M)return S}return C},groupBy:function(m,S){return Tr(this,m,S)},has:function(m){return this.get(m,M)!==M},hasIn:function(m){return this.getIn(m,M)!==M},isSubset:function(m){return m=typeof m.includes=="function"?m:s(m),this.every(function(S){return m.includes(S)})},isSuperset:function(m){return m=typeof m.isSubset=="function"?m:s(m),m.isSubset(this)},keyOf:function(m){return this.findKey(function(S){return Ne(S,m)})},keySeq:function(){return this.toSeq().map(Lr).toIndexedSeq()},last:function(){return this.toSeq().reverse().first()},lastKeyOf:function(m){return this.toKeyedSeq().reverse().keyOf(m)},max:function(m){return bn(this,m)},maxBy:function(m,S){return bn(this,S,m)},min:function(m){return bn(this,m?_r(m):yr)},minBy:function(m,S){return bn(this,S?_r(S):yr,m)},rest:function(){return this.slice(1)},skip:function(m){return this.slice(Math.max(0,m))},skipLast:function(m){return pt(this,this.toSeq().reverse().skip(m).reverse())},skipWhile:function(m,S){return pt(this,Qn(this,m,S,!0))},skipUntil:function(m,S){return this.skipWhile(wn(m),S)},sortBy:function(m,S){return pt(this,sn(this,S,m))},take:function(m){return this.slice(0,Math.max(0,m))},takeLast:function(m){return pt(this,this.toSeq().reverse().take(m).reverse())},takeWhile:function(m,S){return pt(this,Rr(this,m,S))},takeUntil:function(m,S){return this.takeWhile(wn(m),S)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=Dr(this))}});var Ct=s.prototype;Ct[f]=!0,Ct[Me]=Ct.values,Ct.__toJS=Ct.toArray,Ct.__toStringMapper=xr,Ct.inspect=Ct.toSource=function(){return this.toString()},Ct.chain=Ct.flatMap,Ct.contains=Ct.includes,zt(o,{flip:function(){return pt(this,Kn(this))},mapEntries:function(m,S){var C=this,L=0;return pt(this,this.toSeq().map(function(O,q){return m.call(S,[q,O],L++,C)}).fromEntrySeq())},mapKeys:function(m,S){var C=this;return pt(this,this.toSeq().flip().map(function(L,O){return m.call(S,L,O,C)}).flip())}});var Rn=o.prototype;Rn[g]=!0,Rn[Me]=Ct.entries,Rn.__toJS=Ct.toObject,Rn.__toStringMapper=function(m,S){return JSON.stringify(S)+": "+xr(m)},zt(a,{toKeyedSeq:function(){return new kt(this,!1)},filter:function(m,S){return pt(this,Jn(this,m,S,!1))},findIndex:function(m,S){var C=this.findEntry(m,S);return C?C[0]:-1},indexOf:function(m){var S=this.keyOf(m);return S===void 0?-1:S},lastIndexOf:function(m){var S=this.lastKeyOf(m);return S===void 0?-1:S},reverse:function(){return pt(this,On(this,!1))},slice:function(m,S){return pt(this,Nn(this,m,S,!1))},splice:function(m,S){var C=arguments.length;if(S=Math.max(S|0,0),C===0||C===2&&!S)return this;m=$(m,m<0?this.count():this.size);var L=this.slice(0,m);return pt(this,C===1?L:L.concat(P(arguments,2),this.slice(m+S)))},findLastIndex:function(m,S){var C=this.findLastEntry(m,S);return C?C[0]:-1},first:function(){return this.get(0)},flatten:function(m){return pt(this,er(this,m,!1))},get:function(m,S){return m=k(this,m),m<0||this.size===1/0||this.size!==void 0&&m>this.size?S:this.find(function(C,L){return L===m},void 0,S)},has:function(m){return m=k(this,m),m>=0&&(this.size!==void 0?this.size===1/0||m<this.size:this.indexOf(m)!==-1)},interpose:function(m){return pt(this,Ir(this,m))},interleave:function(){var m=[this].concat(P(arguments)),S=Dn(this.toSeq(),ae.of,m),C=S.flatten(!0);return S.size&&(C.size=S.size*m.length),pt(this,C)},keySeq:function(){return Ee(0,this.size)},last:function(){return this.get(-1)},skipWhile:function(m,S){return pt(this,Qn(this,m,S,!1))},zip:function(){var m=[this].concat(P(arguments));return pt(this,Dn(this,Nr,m))},zipWith:function(m){var S=P(arguments);return S[0]=this,pt(this,Dn(this,m,S))}}),a.prototype[_]=!0,a.prototype[x]=!0,zt(l,{get:function(m,S){return this.has(m)?m:S},includes:function(m){return this.has(m)},keySeq:function(){return this.valueSeq()}}),l.prototype.has=Ct.includes,l.prototype.contains=l.prototype.includes,zt(pe,o.prototype),zt(ae,a.prototype),zt(Te,l.prototype),zt(De,o.prototype),zt(Re,a.prototype),zt(Ye,l.prototype);function Lr(m,S){return S}function Or(m,S){return[S,m]}function wn(m){return function(){return!m.apply(this,arguments)}}function _r(m){return function(){return-m.apply(this,arguments)}}function xr(m){return typeof m=="string"?JSON.stringify(m):String(m)}function Nr(){return P(arguments)}function yr(m,S){return m<S?1:m>S?-1:0}function Dr(m){if(m.size===1/0)return 0;var S=p(m),C=u(m),L=S?1:0,O=m.__iterate(C?S?function(q,z){L=31*L+vr(rt(q),rt(z))|0}:function(q,z){L=L+vr(rt(q),rt(z))|0}:S?function(q){L=31*L+rt(q)|0}:function(q){L=L+rt(q)|0});return Fr(O,L)}function Fr(m,S){return S=nt(S,3432918353),S=nt(S<<15|S>>>-15,461845907),S=nt(S<<13|S>>>-13,5),S=(S+3864292196|0)^m,S=nt(S^S>>>16,2246822507),S=nt(S^S>>>13,3266489909),S=ut(S^S>>>16),S}function vr(m,S){return m^S+2654435769+(m<<6)+(m>>2)|0}var kr={Iterable:s,Seq:V,Collection:Ge,Map:lt,OrderedMap:vt,List:_t,Stack:St,Set:xt,OrderedSet:Gt,Record:Nt,Range:Ee,Repeat:xe,is:Ne,fromJS:je};return kr})})(immutable$1)),immutable$1.exports}var utils$1,hasRequiredUtils$1;function requireUtils$1(){if(hasRequiredUtils$1)return utils$1;hasRequiredUtils$1=1;var i=requireImmutable(),e=function(s){return i.Iterable.isKeyed(s)},t=function(s){return i.Iterable.isIndexed(s)},n=function(s,o,a){return s==="remove"?{op:s,path:o}:{op:s,path:o,value:a}};return utils$1={isMap:e,isIndexed:t,op:n},utils$1}var lcs_1,hasRequiredLcs;function requireLcs(){if(hasRequiredLcs)return lcs_1;hasRequiredLcs=1;var i=requireImmutable(),e=function(u,h,d){for(var p=[],f=0;f<u;f++){p[f]=new Array(h);for(var g=0;g<h;g++)p[f][g]=d}return p},t=function(u,h){var d=l(u,h);return c(u,h,d)},n=i.Record({op:"=",val:null}),s=i.Record({op:"!=",val:null,newVal:null}),o=function(u,h){var d=l(u,h);return a(d,u,h,u.size||0,h.size||0)},a=function(u,h,d,p,f){for(var g=[],_=p-1,x=f-1;_>=0||x>=0;)_>=0&&x>=0&&i.is(h.get(_),d.get(x))?(g.push(new n({op:"=",val:h.get(_)})),_-=1,x-=1):_>=0&&x>=0&&_===x&&!i.is(h.get(_),d.get(x))?(g.push(new s({val:h.get(_),newVal:d.get(_)})),_-=1,x-=1):x>=0&&(_===-1||u[_+1][x]>=u[_][x+1])?(g.push(new n({op:"+",val:d.get(x)})),x-=1):_>=0&&(x===-1||u[_+1][x]<u[_][x+1])&&(g.push(new n({op:"-",val:h.get(_)})),_-=1);return g.reverse()};function l(u,h){for(var d=u.size||0,p=h.size||0,f=e(d+1,p+1,0),g=0;g<d;g++)for(var _=0;_<p;_++)i.is(u.get(g),h.get(_))?f[g+1][_+1]=f[g][_]+1:f[g+1][_+1]=Math.max(f[g+1][_],f[g][_+1]);return f}var c=function(u,h,d){for(var p=[],f=u.size,g=h.size;f!==0&&g!==0;)d[f][g]===d[f-1][g]?f--:d[f][g]===d[f][g-1]?g--:i.is(u.get(f-1),h.get(g-1))&&(p.push(u.get(f-1)),f--,g--);return p.reverse()};return lcs_1={lcs:t,computeLcsMatrix:l,diff:o},lcs_1}var path$1,hasRequiredPath$1;function requirePath$1(){if(hasRequiredPath$1)return path$1;hasRequiredPath$1=1;var i=new RegExp("/","g"),e=new RegExp("~1","g"),t=/~/g,n=/~0/g,s={escape:function(o){if(typeof o=="number")return o.toString();if(typeof o!="string")throw"param str ("+o+") is not a string";return o.replace(t,"~0").replace(i,"~1")},unescape:function(o){return typeof o=="string"?o.replace(e,"/").replace(n,"~"):o},concat:function(o,a){return o+"/"+a}};return path$1=s,path$1}var diff_1,hasRequiredDiff;function requireDiff(){if(hasRequiredDiff)return diff_1;hasRequiredDiff=1;var i=requireImmutable(),e=requireUtils$1(),t=requireLcs(),n=requirePath$1(),s=n.concat,o=n.escape,a=e.op,l=e.isMap,c=e.isIndexed,u=function(f,g,_){var x=[],y=_||"";if(i.is(f,g)||f==g==null)return x;var E=c(f)&&c(g),b=null,v=null;return f.forEach&&f.forEach(function(M,T){if(g.has(T))if(l(M)&&l(g.get(T)))x=x.concat(u(M,g.get(T),s(y,o(T))));else if(c(g.get(T))&&c(M))x=x.concat(h(M,g.get(T),s(y,o(T))));else{var I=g.get?g.get(T):g,w=M!==I;w&&x.push(a("replace",s(y,o(T)),I))}else E?(v=b!=null&&b+1===T?v:T,x.push(a("remove",s(y,o(v)))),b=T):x.push(a("remove",s(y,o(T))))}),g.forEach(function(M,T){f.has&&!f.has(T)&&x.push(a("add",s(y,o(T)),M))}),x},h=function(f,g,_){var x=[],y=_||"";if(i.is(f,g)||f==g==null)return x;if((f.count()+1)*(g.count()+1)>=1e4)return u(f,g,_);var E=t.diff(f,g),b=0;return E.forEach(function(v){if(v.op==="=")b++;else if(v.op==="!="){if(l(v.val)&&l(v.newVal)){var M=u(v.val,v.newVal,s(y,b));x=x.concat(M)}else x.push(a("replace",s(y,b),v.newVal));b++}else v.op==="+"?(x.push(a("add",s(y,b),v.val)),b++):v.op==="-"&&x.push(a("remove",s(y,b)))}),x},d=function(f,g,_){var x=_||"";return f===g?[]:[a("replace",s(x,""),g)]},p=function(f,g,_){return i.is(f,g)?i.List():f!=g&&(f==null||g==null)?i.fromJS([a("replace","/",g)]):c(f)&&c(g)?i.fromJS(h(f,g)):l(f)&&l(g)?i.fromJS(u(f,g)):i.fromJS(d(f,g,_))};return diff_1=p,diff_1}var diffExports=requireDiff();const diff$2=getDefaultExportFromCjs(diffExports),require$$0=getAugmentedNamespace(immutable_es);var path,hasRequiredPath;function requirePath(){if(hasRequiredPath)return path;hasRequiredPath=1;var i=new RegExp("/","g"),e=new RegExp("~1","g"),t=/~/g,n=/~0/g,s={escape:function(o){if(typeof o!="string")throw"param str ("+o+") is not a string";return o.replace(t,"~0").replace(i,"~1")},unescape:function(o){return typeof o=="string"?o.replace(e,"/").replace(n,"~"):o}};return path=s,path}var patch$1,hasRequiredPatch;function requirePatch(){if(hasRequiredPatch)return patch$1;hasRequiredPatch=1;var i=require$$0,e=requirePath(),t=function(h){var d=parseInt(h);return isNaN(d)?h:d},n=function(h,d){if(h==="add"||h==="replace")return d;if(h==="remove")return null},s=function(h,d,p,f,g){if(f==="add")if(p.length>0&&h.get(d)===void 0){var _=p[0].match(/^\d+$/)?i.List():i.Map();return h.set(d,l(_,p,f,g))}else return h.set(d,l(h.get(d),p,f,g));else{if(f==="replace")return p.length>0?h.set(d,l(h.get(d),p,f,g)):h.set(d,g);if(f==="remove")return p.length>0?h.set(d,l(h.get(d),p,f,g)):h.remove(d);throw new Error("map patch Error, unknown op: "+f)}},o=function(h,d,p,f,g){if(d=t(d),f==="add")if(h.get(d)===void 0)if(p.length>0){var _=p[0].match(/^\d+$/)?i.List():i.Map();return h.set(d,l(_,p,f,g))}else return d==="-"?h.splice(h.size,0,g):h.splice(d,0,g);else return p.length>0?h.set(d,l(h.get(d),p,f,g)):h.splice(d,0,g);else{if(f==="replace")return p.length>0?h.set(d,l(h.get(d),p,f,g)):h.set(d,g);if(f==="remove")return p.length>0?h.set(d,l(h.get(d),p,f,g)):h.remove(d);throw new Error("sequence patch Error, unknown op: "+f)}},a=function(h){return h!=null&&typeof h.updateIn=="function"&&typeof h.set=="function"},l=function(h,d,p,f){var g,_;return i.Iterable.isIndexed(h)?d.length===0?h:(g=d[0],_=d.slice(1),o(h,g,_,p,f)):i.Iterable.isKeyed(h)||a(h)?d.length===0?h:(g=d[0],_=d.slice(1),s(h,g,_,p,f)):d.length===0?f:n(p,f)},c=function(h,d){for(;d.size;){var p=d.get(0),d=d.slice(1),f=p.get("path").split("/").slice(1).map(e.unescape);h=l(h,f,p.get("op"),p.get("value"))}return h},u=function(h,d){if(d.size===1){var p=d.get(0);if(p.get("op")==="replace"&&p.get("path")==="/")return p.get("value")}return c(h,d)};return u.default=u,patch$1=u,patch$1}var patchExports=requirePatch();const patch=getDefaultExportFromCjs(patchExports),historyPush=(i,e)=>{if(i.last){if(i.last.hashCode()!==e.hashCode()){let t=Map$1({time:Date.now(),diff:diff$2(i.last,e)});i=i.set("last",e).set("list",i.list.push(t)).set("redoList",i.redoList.clear())}}else i=i.set("last",e);return i},historyRedo=i=>{if(i.last&&i.redoList.size){const e=i.redoList.last(),t=patch(i.last,e.get("diff"));i=i.set("last",t).set("list",i.list.push(e)).set("redoList",i.redoList.pop())}return i},historyPop=i=>{var e;if(i.last&&i.list.size){const t=i.list.last();let n=i.first;for(let s=0;s<i.list.size-1;s++)n=patch(n,(e=i.list.get(s))==null?void 0:e.get("diff"));i=i.set("last",n).set("list",i.list.pop()).set("redoList",i.redoList.push(t))}return i},SURFACE_LINE_TYPE="surface";function lineFamily(i){return i===SURFACE_LINE_TYPE?"surface":"structure"}function lineFamilyOf(i){return i?lineFamily(i.get?i.get("type"):i.type):"structure"}function vertexAcceptsFamily(i,e,t){var a;const n=(a=i==null?void 0:i.get)==null?void 0:a.call(i,"lines");if(!n||n.size===0)return!0;let s=!1,o=!1;return n.forEach(l=>{var u;const c=(u=e==null?void 0:e.getIn)==null?void 0:u.call(e,["lines",l]);c&&(s=!0,lineFamilyOf(c)===t&&(o=!0))}),s?o:!0}function areaFamily(i,e){var s,o;let t=!1,n=!1;return(o=(s=i==null?void 0:i.get)==null?void 0:s.call(i,"vertices"))==null||o.forEach(a=>{var l,c,u;(u=(c=(l=e==null?void 0:e.getIn)==null?void 0:l.call(e,["vertices",a]))==null?void 0:c.get("lines"))==null||u.forEach(h=>{const d=e.getIn(["lines",h]);d&&(lineFamilyOf(d)==="surface"?t=!0:n=!0)})}),t&&!n?"surface":"structure"}const LINE_FAMILIES=["structure","surface"];var lib={exports:{}},randomFromSeed,hasRequiredRandomFromSeed;function requireRandomFromSeed(){if(hasRequiredRandomFromSeed)return randomFromSeed;hasRequiredRandomFromSeed=1;var i=1;function e(){return i=(i*9301+49297)%233280,i/233280}function t(n){i=n}return randomFromSeed={nextValue:e,seed:t},randomFromSeed}var alphabet_1,hasRequiredAlphabet;function requireAlphabet(){if(hasRequiredAlphabet)return alphabet_1;hasRequiredAlphabet=1;var i=requireRandomFromSeed(),e="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-",t,n,s;function o(){s=!1}function a(f){if(!f){t!==e&&(t=e,o());return}if(f!==t){if(f.length!==e.length)throw new Error("Custom alphabet for shortid must be "+e.length+" unique characters. You submitted "+f.length+" characters: "+f);var g=f.split("").filter(function(_,x,y){return x!==y.lastIndexOf(_)});if(g.length)throw new Error("Custom alphabet for shortid must be "+e.length+" unique characters. These characters were not unique: "+g.join(", "));t=f,o()}}function l(f){return a(f),t}function c(f){i.seed(f),n!==f&&(o(),n=f)}function u(){t||a(e);for(var f=t.split(""),g=[],_=i.nextValue(),x;f.length>0;)_=i.nextValue(),x=Math.floor(_*f.length),g.push(f.splice(x,1)[0]);return g.join("")}function h(){return s||(s=u(),s)}function d(f){var g=h();return g[f]}function p(){return t||e}return alphabet_1={get:p,characters:l,seed:c,lookup:d,shuffled:h},alphabet_1}var randomByteBrowser,hasRequiredRandomByteBrowser;function requireRandomByteBrowser(){if(hasRequiredRandomByteBrowser)return randomByteBrowser;hasRequiredRandomByteBrowser=1;var i=typeof window=="object"&&(window.crypto||window.msCrypto),e;return!i||!i.getRandomValues?e=function(t){for(var n=[],s=0;s<t;s++)n.push(Math.floor(Math.random()*256));return n}:e=function(t){return i.getRandomValues(new Uint8Array(t))},randomByteBrowser=e,randomByteBrowser}let urlAlphabet="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",random=i=>crypto.getRandomValues(new Uint8Array(i)),customRandom=(i,e,t)=>{let n=(2<<Math.log(i.length-1)/Math.LN2)-1,s=-~(1.6*n*e/i.length);return(o=e)=>{let a="";for(;;){let l=t(s),c=s|0;for(;c--;)if(a+=i[l[c]&n]||"",a.length===o)return a}}},customAlphabet=(i,e=21)=>customRandom(i,e,random),nanoid=(i=21)=>crypto.getRandomValues(new Uint8Array(i)).reduce((e,t)=>(t&=63,t<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),"");const index_browser=Object.freeze(Object.defineProperty({__proto__:null,customAlphabet,customRandom,nanoid,random,urlAlphabet},Symbol.toStringTag,{value:"Module"})),require$$2=getAugmentedNamespace(index_browser);var generate_1,hasRequiredGenerate;function requireGenerate(){if(hasRequiredGenerate)return generate_1;hasRequiredGenerate=1;var i=requireAlphabet(),e=requireRandomByteBrowser(),t=require$$2.customRandom;function n(s){for(var o=0,a,l="";!a;)l=l+t(i.get(),1,e)(),a=s<Math.pow(16,o+1),o++;return l}return generate_1=n,generate_1}var build_1,hasRequiredBuild;function requireBuild(){if(hasRequiredBuild)return build_1;hasRequiredBuild=1;var i=requireGenerate();requireAlphabet();var e=1567752802062,t=7,n,s;function o(a){var l="",c=Math.floor((Date.now()-e)*.001);return c===s?n++:(n=0,s=c),l=l+i(t),l=l+i(a),n>0&&(l=l+i(n)),l=l+i(c),l}return build_1=o,build_1}var isValid,hasRequiredIsValid;function requireIsValid(){if(hasRequiredIsValid)return isValid;hasRequiredIsValid=1;var i=requireAlphabet();function e(t){if(!t||typeof t!="string"||t.length<6)return!1;var n=new RegExp("[^"+i.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]");return!n.test(t)}return isValid=e,isValid}var clusterWorkerIdBrowser,hasRequiredClusterWorkerIdBrowser;function requireClusterWorkerIdBrowser(){return hasRequiredClusterWorkerIdBrowser||(hasRequiredClusterWorkerIdBrowser=1,clusterWorkerIdBrowser=0),clusterWorkerIdBrowser}var hasRequiredLib;function requireLib(){return hasRequiredLib||(hasRequiredLib=1,(function(i){var e=requireAlphabet(),t=requireBuild(),n=requireIsValid(),s=requireClusterWorkerIdBrowser()||0;function o(u){return e.seed(u),i.exports}function a(u){return s=u,i.exports}function l(u){return u!==void 0&&e.characters(u),e.shuffled()}function c(){return t(s)}i.exports=c,i.exports.generate=c,i.exports.seed=o,i.exports.worker=a,i.exports.characters=l,i.exports.isValid=n})(lib)),lib.exports}var shortid$1,hasRequiredShortid;function requireShortid(){return hasRequiredShortid||(hasRequiredShortid=1,shortid$1=requireLib()),shortid$1}var shortidExports=requireShortid();const shortid=getDefaultExportFromCjs(shortidExports);class IDBroker{static acquireID(){return shortid.generate()}}class NameGenerator{static generateName(e,t){const n=typeof t=="string"&&t.length>0?t:"Element";return n.charAt(0).toUpperCase()+n.slice(1)}}class TinyQueue{constructor(e=[],t=(n,s)=>n<s?-1:n>s?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(this.length===0)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:n}=this,s=t[e];for(;e>0;){const o=e-1>>1,a=t[o];if(n(s,a)>=0)break;t[e]=a,e=o}t[e]=s}_down(e){const{data:t,compare:n}=this,s=this.length>>1,o=t[e];for(;e<s;){let a=(e<<1)+1;const l=a+1;if(l<this.length&&n(t[l],t[a])<0&&(a=l),n(t[a],o)>=0)break;t[e]=t[a],e=a}t[e]=o}}function polylabel(i,e=1,t=!1){let n=1/0,s=1/0,o=-1/0,a=-1/0;for(const[y,E]of i[0])y<n&&(n=y),E<s&&(s=E),y>o&&(o=y),E>a&&(a=E);const l=o-n,c=a-s,u=Math.max(e,Math.min(l,c));if(u===e){const y=[n,s];return y.distance=0,y}const h=new TinyQueue([],(y,E)=>E.max-y.max);let d=getCentroidCell(i);const p=new Cell(n+l/2,s+c/2,0,i);p.d>d.d&&(d=p);let f=2;function g(y,E,b){const v=new Cell(y,E,b,i);f++,v.max>d.d+e&&h.push(v),v.d>d.d&&(d=v,t&&console.log(`found best ${Math.round(1e4*v.d)/1e4} after ${f} probes`))}let _=u/2;for(let y=n;y<o;y+=u)for(let E=s;E<a;E+=u)g(y+_,E+_,_);for(;h.length;){const{max:y,x:E,y:b,h:v}=h.pop();if(y-d.d<=e)break;_=v/2,g(E-_,b-_,_),g(E+_,b-_,_),g(E-_,b+_,_),g(E+_,b+_,_)}t&&console.log(`num probes: ${f}
46
46
  best distance: ${d.d}`);const x=[d.x,d.y];return x.distance=d.d,x}function Cell(i,e,t,n){this.x=i,this.y=e,this.h=t,this.d=pointToPolygonDist(i,e,n),this.max=this.d+this.h*Math.SQRT2}function pointToPolygonDist(i,e,t){let n=!1,s=1/0;for(const o of t)for(let a=0,l=o.length,c=l-1;a<l;c=a++){const u=o[a],h=o[c];u[1]>e!=h[1]>e&&i<(h[0]-u[0])*(e-u[1])/(h[1]-u[1])+u[0]&&(n=!n),s=Math.min(s,getSegDistSq(i,e,u,h))}return s===0?0:(n?1:-1)*Math.sqrt(s)}function getCentroidCell(i){let e=0,t=0,n=0;const s=i[0];for(let a=0,l=s.length,c=l-1;a<l;c=a++){const u=s[a],h=s[c],d=u[0]*h[1]-h[0]*u[1];t+=(u[0]+h[0])*d,n+=(u[1]+h[1])*d,e+=d*3}const o=new Cell(t/e,n/e,0,i);return e===0||o.d<0?new Cell(s[0][0],s[0][1],0,i):o}function getSegDistSq(i,e,t,n){let s=t[0],o=t[1],a=n[0]-s,l=n[1]-o;if(a!==0||l!==0){const c=((i-s)*a+(e-o)*l)/(a*a+l*l);c>1?(s=n[0],o=n[1]):c>0&&(s+=a*c,o+=l*c)}return a=i-s,l=e-o,a*a+l*l}class Hole{static create(e,t,n,s,o,a){let l=IDBroker.acquireID(),c=e.catalog.factoryElement(n,{id:l,name:NameGenerator.generateName("holes",e.catalog.getIn(["elements",n,"info","title"])),type:n,prototype:"holes",offset:o,line:s},a);return e=e.setIn(["scene","layers",t,"holes",l],c),e=e.updateIn(["scene","layers",t,"lines",s,"holes"],u=>u.push(l)),{updatedState:e,hole:c}}static select(e,t,n){return e=Layer$1.select(e,t).updatedState,e=Layer$1.selectElement(e,t,"holes",n).updatedState,{updatedState:e}}static remove(e,t,n){let s=e.getIn(["scene","layers",t,"holes",n]);return e=this.unselect(e,t,n).updatedState,e=Layer$1.removeElement(e,t,"holes",n).updatedState,e=e.updateIn(["scene","layers",t,"lines",s.line,"holes"],o=>{let a=o.findIndex(l=>n===l);return a!==-1?o.remove(a):o}),e.getIn(["scene","groups"]).forEach(o=>e=Group$2.removeElement(e,o.id,t,"holes",n).updatedState),{updatedState:e}}static unselect(e,t,n){return e=Layer$1.unselect(e,t,"holes",n).updatedState,{updatedState:e}}static selectToolDrawingHole(e,t){let n=List().withMutations(s=>{let{lines:o,vertices:a}=e.getIn(["scene","layers",e.scene.selectedLayer]);o.forEach(l=>{if(l.get("type")==="surface")return;let{x:c,y:u}=a.get(l.vertices.get(0)),{x:h,y:d}=a.get(l.vertices.get(1));addLineSegmentSnap(s,c,u,h,d,20,1,l.id)})});return e=e.merge({mode:MODE_DRAWING_HOLE,snapElements:n,drawingSupport:Map$1({type:t})}),{updatedState:e}}static updateDrawingHole(e,t,n,s){let o=e.catalog,a=nearestSnap(e.snapElements,n,s,e.snapMask.merge({SNAP_SEGMENT:!0}));a&&({x:n,y:s}=a.point);let l=e.getIn(["scene","layers",t,"selected","holes"]).first();if(a){let c=a.snap.related.get(0),u=e.getIn(["scene","layers",t,"lines",c,"vertices"]),{x:h,y:d}=e.getIn(["scene","layers",t,"vertices",u.get(0)]),{x:p,y:f}=e.getIn(["scene","layers",t,"vertices",u.get(1)]),g=minVertex({x:h,y:d},{x:p,y:f}),_=maxVertex({x:h,y:d},{x:p,y:f}),x=o.factoryElement(e.drawingSupport.get("type")).properties.getIn(["width","length"]),y=pointsDistance(h,d,p,f),E=absAngleBetweenTwoPoints(h,d,p,f),b=cosWithThreshold(E,1e-7),v=sinWithThreshold(E,1e-7),M={x:g.x+x/2*b,y:g.y+x/2*v},T={x:g.x+y*b-x/2*b,y:g.y+y*v-x/2*v},I;if(n<M.x?I=pointPositionOnLineSegment(g.x,g.y,_.x,_.y,M.x,M.y):n>T.x?I=pointPositionOnLineSegment(g.x,g.y,_.x,_.y,T.x,T.y):n===M.x&&n===T.x?s<M.y?(I=pointPositionOnLineSegment(g.x,g.y,_.x,_.y,M.x,M.y),I=g.x===h&&g.y===d?I:1-I):s>T.y?(I=pointPositionOnLineSegment(g.x,g.y,_.x,_.y,T.x,T.y),I=g.x===h&&g.y===d?I:1-I):I=pointPositionOnLineSegment(h,d,p,f,n,s):I=pointPositionOnLineSegment(h,d,p,f,n,s),l&&a){e=e.mergeIn(["scene","layers",t,"holes",l],{offset:I,line:c});let w=e.getIn(["scene","layers",t,"lines"]).findEntry(A=>A.id!==c&&A.get("holes").contains(l));if(w){let A=w[1].get("holes").filter(P=>P!==l);e=e.setIn(["scene","layers",t,"lines",w[0],"holes"],A)}let R=e.getIn(["scene","layers",t,"lines",c,"holes"]);R.contains(l)||(e=e.setIn(["scene","layers",t,"lines",c,"holes"],R.push(l)))}else if(!l&&a){let{updatedState:w,hole:R}=this.create(e,t,e.drawingSupport.get("type"),c,I);e=Hole.select(w,t,R.id).updatedState}}return{updatedState:e}}static endDrawingHole(e,t,n,s){return e=this.updateDrawingHole(e,t,n,s).updatedState,e=Layer$1.unselectAll(e,t).updatedState,{updatedState:e}}static beginDraggingHole(e,t,n,s,o){let a=e.getIn(["scene","layers",t]),l=a.getIn(["holes",n]),c=a.getIn(["lines",l.line]),u=a.getIn(["vertices",c.vertices.get(0)]),h=a.getIn(["vertices",c.vertices.get(1)]),d=addLineSegmentSnap(List(),u.x,u.y,h.x,h.y,9999999,1,null);return e=e.merge({mode:MODE_DRAGGING_HOLE,snapElements:d,draggingSupport:Map$1({layerID:t,holeID:n,startPointX:s,startPointY:o})}),{updatedState:e}}static updateDraggingHole(e,t,n){let s=nearestSnap(e.snapElements,t,n,e.snapMask.merge({SNAP_SEGMENT:!0}));if(!s)return e;let{draggingSupport:o,scene:a}=e,l=o.get("layerID"),c=o.get("holeID"),u=e.getIn(["scene","layers",l]),h=u.getIn(["holes",c]),d=u.getIn(["lines",h.line]),p=u.getIn(["vertices",d.vertices.get(0)]),f=u.getIn(["vertices",d.vertices.get(1)]);({x:t,y:n}=s.point);let g=minVertex(p,f),_=maxVertex(p,f),x=h.properties.get("width").get("length"),y=pointsDistance(p.x,p.y,f.x,f.y),E=Math.atan2(Math.abs(f.y-p.y),Math.abs(f.x-p.x)),b=A=>{let P=Math.cos(A);return P<1e-7?0:P},v=A=>{let P=Math.sin(A);return P<1e-7?0:P},M=b(E),T=v(E),I={x:g.x+x/2*M,y:g.y+x/2*T},w={x:g.x+y*M-x/2*M,y:g.y+y*T-x/2*T},R;return t<I.x?R=pointPositionOnLineSegment(g.x,g.y,_.x,_.y,I.x,I.y):t>w.x?R=pointPositionOnLineSegment(g.x,g.y,_.x,_.y,w.x,w.y):t===I.x&&t===w.x?n<I.y?(R=pointPositionOnLineSegment(g.x,g.y,_.x,_.y,I.x,I.y),R=g===p?R:1-R):n>w.y?(R=pointPositionOnLineSegment(g.x,g.y,_.x,_.y,w.x,w.y),R=g===p?R:1-R):(R=pointPositionOnLineSegment(g.x,g.y,_.x,_.y,t,n),R=g===p?R:1-R):R=pointPositionOnLineSegment(g.x,g.y,_.x,_.y,t,n),h=h.set("offset",R),e=e.merge({scene:a.mergeIn(["layers",l,"holes",c],h)}),{updatedState:e}}static endDraggingHole(e,t,n){return e=this.updateDraggingHole(e,t,n).updatedState,e=e.merge({mode:MODE_IDLE$1}),{updatedState:e}}static flip(e,t,n,s="x"){const o=e.getIn(["scene","layers",t,"holes",n]);return o?s==="x"?this.mergeAttributes(e,t,n,{flipAlongWall:o.flipAlongWall!==!0}):this.setProperties(e,t,n,o.properties.set("flip_horizontal",o.properties.get("flip_horizontal")!==!0)):{updatedState:e}}static duplicate(e,t,n){const s=e.getIn(["scene","layers",t,"holes",n]);if(!s)return{updatedState:e};const o=.1,a=s.offset+o>.95?Math.max(.05,s.offset-o):s.offset+o,l=this.create(e,t,s.type,s.line,a,s.properties);return e=l.updatedState,e=this.mergeAttributes(e,t,l.hole.id,{flipAlongWall:s.flipAlongWall}).updatedState,e=this.unselect(e,t,n).updatedState,e=this.select(e,t,l.hole.id).updatedState,{updatedState:e,hole:l.hole}}static setProperties(e,t,n,s){return e=e.setIn(["scene","layers",t,"holes",n,"properties"],s),{updatedState:e}}static setJsProperties(e,t,n,s){return this.setProperties(e,t,n,fromJS(s))}static updateProperties(e,t,n,s){return s.forEach((o,a)=>{e.hasIn(["scene","layers",t,"holes",n,"properties",a])&&(e=e.mergeIn(["scene","layers",t,"holes",n,"properties",a],o))}),{updatedState:e}}static updateJsProperties(e,t,n,s){return this.updateProperties(e,t,n,fromJS(s))}static mergeAttributes(e,t,n,s){return e=e.mergeIn(["scene","layers",t,"holes",n],fromJS(s)),{updatedState:e}}static setAttributes(e,t,n,s){let o=s.toJS(),{offsetA:a,offsetB:l,offset:c}=o;delete o.offsetA,delete o.offsetB,delete o.offset;let u=Map$1({_unitA:a._unit,_unitB:l._unit});return e=e.mergeIn(["scene","layers",t,"holes",n],fromJS(o)).mergeDeepIn(["scene","layers",t,"holes",n],Map$1({offset:c,misc:u})),{updatedState:e}}}const ITEM_MIN_SCALE=.2,ITEM_MAX_SCALE=8;function getItemTransform(i){const e=Number(i.get("scale"));return{scale:Number.isFinite(e)&&e>0?e:1,flipHorizontal:i.get("flipHorizontal")===!0,flipVertical:i.get("flipVertical")===!0}}function clampItemScale(i){return Math.min(ITEM_MAX_SCALE,Math.max(ITEM_MIN_SCALE,i))}const footprints=new Map;function rememberItemFootprint(i,e){footprints.set(i,e)}function forgetItemFootprint(i){footprints.delete(i)}function getItemFootprint(i){return footprints.get(i)??null}const MITER_LIMIT=4;function miterShifts(i,e,t,n,s,o,a=MITER_LIMIT){if(!e.lines||e.lines.size<2)return{topShift:0,botShift:0};if(e.lines.size>2)return{topShift:0,botShift:0};let l=null,c=null;e.lines.forEach(p=>{if(p===i)return;const f=s.lines.get(p);if(!f)return;const[g,_]=f.vertices.toArray(),x=g===e.id?_:g,y=s.vertices.get(x);if(!y)return;const E=y.x-e.x,b=y.y-e.y,v=Math.hypot(E,b);if(v===0)return;const M={x:E/v,y:b/v},T=t.x*M.x+t.y*M.y,I=Math.acos(Math.max(-1,Math.min(1,T)));if(I>=Math.PI-.001)return;const w=n.x*M.x+n.y*M.y;w>1e-6?(l===null||I<l)&&(l=I):w<-1e-6&&(c===null||I<c)&&(c=I)});const u=p=>{const f=Math.tan(p/2);return f<=1e-6?o*a:Math.min(o/f,o*a)};let h=0,d=0;return l!==null&&c!==null?(h=u(l),d=u(c)):l!==null?(h=u(l),d=-u(l)):c!==null&&(d=u(c),h=-u(c)),{topShift:h,botShift:d}}function wallGeometry(i,e){const t=e.vertices.get(i.vertices.get(0)),n=e.vertices.get(i.vertices.get(1));if(!t||!n)return null;const s=t.x<=n.x?t:n,o=s===t?n:t,a=pointsDistance(s.x,s.y,o.x,o.y),l=i.getIn(["properties","thickness","length"])??0,c=l/2,u=a>0?{x:(o.x-s.x)/a,y:(o.y-s.y)/a}:{x:1,y:0},h={x:-u.x,y:-u.y},d={x:-u.y,y:u.x},p=miterShifts(i.id,s,u,d,e,c),f=miterShifts(i.id,o,h,d,e,c);return{vStart:s,vEnd:o,length:a,thickness:l,halfThickness:c,topStart:p.topShift,topEnd:a-f.topShift,botStart:p.botShift,botEnd:a-f.botShift}}const ITEM_WALL_SNAP_DISTANCE=25,ITEM_ITEM_SNAP_DISTANCE=ITEM_WALL_SNAP_DISTANCE,ITEM_ALIGN_RANGE=300,ITEM_ROTATION_TOLERANCE=.5,CORNER_TOLERANCE=Math.sin(20*Math.PI/180),DEG=Math.PI/180,normalizeAngle$1=i=>{const e=(i%360+360)%360;return e>180?e-360:e},isWall=(i,e)=>{var t,n;if(String(e.type).toLowerCase().includes("wall"))return!0;try{return(((n=(t=i==null?void 0:i.getElement(e.type))==null?void 0:t.info)==null?void 0:n.tag)??[]).some(o=>String(o).toLowerCase()==="wall")}catch{return!1}},wallAxes=i=>{const e=(i.vEnd.x-i.vStart.x)/i.length,t=(i.vEnd.y-i.vStart.y)/i.length;return{alongX:e,alongY:t,topX:-t,topY:e}},wallFace=(i,e,t)=>{const n=i.halfThickness*(t?1:-1),s=t?i.topStart:i.botStart,o=t?i.topEnd:i.botEnd,a=u=>({x:i.vStart.x+e.alongX*u+e.topX*n,y:i.vStart.y+e.alongY*u+e.topY*n}),l=a(s),c=a(o);return{x1:l.x,y1:l.y,x2:c.x,y2:c.y}},projectFootprint=(i,e,t,n)=>{const s=e*DEG,o=Math.cos(s)*t+Math.sin(s)*n,a=-Math.sin(s)*t+Math.cos(s)*n,l=i.width/2,c=i.height/2;return{halfExtent:Math.abs(l*o)+Math.abs(c*a),centreOffset:(i.x+l)*o+(i.y+c)*a}};function findHostWall(i,e,t,n,s,o){let a=null;return i.lines.forEach(l=>{if(!isWall(e,l))return;const c=wallGeometry(l,i);if(!c||c.length===0)return;const u=wallAxes(c),{alongX:h,alongY:d,topX:p,topY:f}=u,g=n-c.vStart.x,_=s-c.vStart.y,x=g*p+_*f>=0,y=x?p:-p,E=x?f:-f,b=Math.atan2(d,h)/DEG,v=normalizeAngle$1(b+Math.round(normalizeAngle$1(o-b)/90)*90),M=projectFootprint(t,v,y,E),T=projectFootprint(t,v,h,d),I=c.halfThickness+M.halfExtent-M.centreOffset-(g*y+_*E);if(Math.abs(I)>ITEM_WALL_SNAP_DISTANCE||a&&Math.abs(I)>=Math.abs(a.shift))return;const w=g*h+_*d+T.centreOffset,R=x?c.topStart:c.botStart,A=x?c.topEnd:c.botEnd;w+T.halfExtent<=Math.min(R,A)||w-T.halfExtent>=Math.max(R,A)||(a={lineID:l.id,wall:c,axes:u,onTopSide:x,rotation:v,shift:I,alongCentre:w,alongHalfExtent:T.halfExtent})}),a}function findCornerSnap(i,e,t){const{alongX:n,alongY:s}=t.axes,o=t.alongCentre-t.alongHalfExtent,a=t.alongCentre+t.alongHalfExtent;let l=null;return i.lines.forEach(c=>{if(c.id===t.lineID||!isWall(e,c))return;const u=wallGeometry(c,i);if(!u||u.length===0)return;const h=wallAxes(u);Math.abs(h.alongX*n+h.alongY*s)>CORNER_TOLERANCE||[!0,!1].forEach(d=>{const p=wallFace(u,h,d),f=(p.x1-t.wall.vStart.x)*n+(p.y1-t.wall.vStart.y)*s;[f-o,f-a].forEach(g=>{Math.abs(g)>ITEM_WALL_SNAP_DISTANCE||l&&Math.abs(g)>=Math.abs(l.shift)||(l={shift:g,guide:p})})})}),l}function snapItemToItems(i,e,t,n,s,o,a){const l=frameOf(o),c=a?[Math.abs(a.x*l.uX+a.y*l.uY)>=Math.abs(a.x*l.vX+a.y*l.vY)?"u":"v"]:["u","v"],u=frameBox(t,n,s,o,l),h=[];let d=0,p=0;const f=(g,_,x)=>x==="u"?{x:g*l.uX+_*l.vX,y:g*l.uY+_*l.vY}:{x:_*l.uX+g*l.vX,y:_*l.uY+g*l.vY};return c.forEach(g=>{let _=null;if(i.items.forEach(v=>{if(v.id===e||!squareToEachOther(o,v.rotation??0))return;const M=getItemFootprint(v.id);if(!M||M.width<=0||M.height<=0)return;const T=bestAxisSnap(u,frameBox(M,v.x,v.y,v.rotation??0,l),g);T&&(_&&Math.abs(T.shift)>=Math.abs(_.shift)||(_=T))}),!_)return;const x=_;u[g].centre+=x.shift;const y=f(x.shift,0,g);d+=y.x,p+=y.y;const E=f(x.at,x.from,g),b=f(x.at,x.to,g);h.push({x1:E.x,y1:E.y,x2:b.x,y2:b.y})}),h.length?{dx:d,dy:p,guides:h}:null}function snapItemToWalls(i,e,t,n,s,o){if(!t||t.width<=0||t.height<=0)return null;const a=findHostWall(i,e,t,n,s,o);if(!a)return null;const l=a.onTopSide?a.axes.topX:-a.axes.topX,c=a.onTopSide?a.axes.topY:-a.axes.topY,u=[wallFace(a.wall,a.axes,a.onTopSide)];let h=n+l*a.shift,d=s+c*a.shift;const p=findCornerSnap(i,e,a);return p&&(h+=a.axes.alongX*p.shift,d+=a.axes.alongY*p.shift,u.push(p.guide)),{x:h,y:d,rotation:a.rotation,lineID:a.lineID,guides:u,free:p?null:{x:a.axes.alongX,y:a.axes.alongY}}}function snapItem(i,e,t,n,s,o,a){if(!n||n.width<=0||n.height<=0)return null;const l=snapItemToWalls(i,e,n,s,o,a),c=l??{x:s,y:o,rotation:a,guides:[]},u=l&&!l.free?null:snapItemToItems(i,t,n,c.x,c.y,c.rotation,l?l.free:null);return!l&&!u?null:{x:c.x+((u==null?void 0:u.dx)??0),y:c.y+((u==null?void 0:u.dy)??0),rotation:c.rotation,guides:[...c.guides,...(u==null?void 0:u.guides)??[]]}}const frameOf=i=>{const e=i*DEG,t=Math.cos(e),n=Math.sin(e);return{uX:t,uY:n,vX:-n,vY:t}},frameBox=(i,e,t,n,s)=>{const o=projectFootprint(i,n,s.uX,s.uY),a=projectFootprint(i,n,s.vX,s.vY);return{u:{centre:e*s.uX+t*s.uY+o.centreOffset,half:o.halfExtent},v:{centre:e*s.vX+t*s.vY+a.centreOffset,half:a.halfExtent}}},squareToEachOther=(i,e)=>{const t=Math.abs(normalizeAngle$1(i-e))%90;return Math.min(t,90-t)<=ITEM_ROTATION_TOLERANCE};function bestAxisSnap(i,e,t){const n=t==="u"?"v":"u",s=i[t],o=e[t],a=i[n],l=e[n],c=Math.abs(a.centre-l.centre)-(a.half+l.half),u={from:Math.max(a.centre-a.half,l.centre-l.half),to:Math.min(a.centre+a.half,l.centre+l.half)},h={from:Math.min(a.centre-a.half,l.centre-l.half),to:Math.max(a.centre+a.half,l.centre+l.half)};let d=null;const p=(f,g,_)=>{const x=f-g;Math.abs(x)>ITEM_ITEM_SNAP_DISTANCE||d&&Math.abs(x)>=Math.abs(d.shift)||(d={shift:x,at:f,from:_.from,to:_.to})};return c<0&&(p(o.centre-o.half,s.centre+s.half,u),p(o.centre+o.half,s.centre-s.half,u)),c<=ITEM_ALIGN_RANGE&&(p(o.centre-o.half,s.centre-s.half,h),p(o.centre+o.half,s.centre+s.half,h),p(o.centre,s.centre,h)),d}const RIGHT_ANGLE_TOLERANCE=5,normalizeAngle=i=>{const e=(i%360+360)%360;return e>180?e-360:e},snapToRightAngle=i=>{const e=Math.round(i/90)*90;return Math.abs(i-e)<RIGHT_ANGLE_TOLERANCE?normalizeAngle(e):i},DUPLICATE_OFFSET=40,SCALE_SNAP_TOLERANCE=.03,pointerAngle=(i,e,t)=>Math.atan2(t-i.y,e-i.x)*180/Math.PI-90;let Item$1=class Sr{static create(e,t,n,s,o,a,l,c,u){let h=IDBroker.acquireID(),d=e.catalog.factoryElement(n,{id:h,name:NameGenerator.generateName("items",e.catalog.getIn(["elements",n,"info","title"])),type:n,prototype:"items",height:l,width:a,x:s,y:o,rotation:c,altitude:u});return e=e.setIn(["scene","layers",t,"items",h],d),{updatedState:e,item:d}}static select(e,t,n){return e=Layer$1.select(e,t).updatedState,e=Layer$1.selectElement(e,t,"items",n).updatedState,{updatedState:e}}static remove(e,t,n){return e=this.unselect(e,t,n).updatedState,e=Layer$1.removeElement(e,t,"items",n).updatedState,e.getIn(["scene","groups"]).forEach(s=>e=Group$2.removeElement(e,s.id,t,"items",n).updatedState),{updatedState:e}}static unselect(e,t,n){return e=Layer$1.unselect(e,t,"items",n).updatedState,{updatedState:e}}static selectToolDrawingItem(e,t){return e=e.merge({mode:MODE_DRAWING_ITEM,drawingSupport:Map$1({type:t})}),{updatedState:e}}static updateDrawingItem(e,t,n,s){if(e.hasIn(["drawingSupport","currentID"])){const o=e.getIn(["drawingSupport","currentID"]),a=e.getIn(["drawingSupport","originalRotation"])??0,l=e.snapMask.get(SNAP_SEGMENT)?snapItem(e.getIn(["scene","layers",t]),e.catalog,o,getItemFootprint(o),n,s,a):null;e=e.updateIn(["scene","layers",t,"items",o],c=>l?c.merge({x:l.x,y:l.y,rotation:l.rotation}):c.merge({x:n,y:s,rotation:a})),e=e.set("itemSnapGuides",l?l.guides:null)}else{let{updatedState:o,item:a}=this.create(e,t,e.getIn(["drawingSupport","type"]),n,s,200,100,0,0);e=Sr.select(o,t,a.id).updatedState,e=e.setIn(["drawingSupport","currentID"],a.id),e=e.setIn(["drawingSupport","originalRotation"],a.rotation)}return{updatedState:e}}static endDrawingItem(e,t,n,s){return e=this.updateDrawingItem(e,t,n,s).updatedState,e=Layer$1.unselectAll(e,t).updatedState,e=e.merge({mode:MODE_IDLE$1,drawingSupport:Map$1(),itemSnapGuides:null}),{updatedState:e}}static beginDraggingItem(e,t,n,s,o){let a=e.getIn(["scene","layers",t,"items",n]);return e=e.merge({mode:MODE_DRAGGING_ITEM,draggingSupport:Map$1({layerID:t,itemID:n,startPointX:s,startPointY:o,originalX:a.x,originalY:a.y,originalRotation:a.rotation})}),{updatedState:e}}static updateDraggingItem(e,t,n){let{draggingSupport:s,scene:o}=e,a=s.get("layerID"),l=s.get("itemID"),c=s.get("startPointX"),u=s.get("startPointY"),h=s.get("originalX"),d=s.get("originalY"),p=s.get("originalRotation")??0,f=c-t,g=u-n,_=o.getIn(["layers",a,"items",l]),x=h-f,y=d-g,E=p,b=null;if(e.snapMask.get(SNAP_SEGMENT)){const v=snapItem(o.getIn(["layers",a]),e.catalog,l,getItemFootprint(l),x,y,p);v&&(x=v.x,y=v.y,E=v.rotation,b=v.guides)}return _=_.merge({x,y,rotation:E}),e=e.merge({scene:o.mergeIn(["layers",a,"items",l],_),itemSnapGuides:b}),{updatedState:e}}static endDraggingItem(e,t,n){return e=this.updateDraggingItem(e,t,n).updatedState,e=e.merge({mode:MODE_IDLE$1,itemSnapGuides:null}),{updatedState:e}}static beginRotatingItem(e,t,n,s,o){const a=e.getIn(["scene","layers",t,"items",n]);return e=e.merge({mode:MODE_ROTATING_ITEM,rotatingSupport:Map$1({layerID:t,itemID:n,angleOffset:a?a.rotation-pointerAngle(a,s,o):0})}),{updatedState:e}}static updateRotatingItem(e,t,n){let{rotatingSupport:s,scene:o}=e,a=s.get("layerID"),l=s.get("itemID"),c=e.getIn(["scene","layers",a,"items",l]),u=s.get("angleOffset")??0,h=snapToRightAngle(normalizeAngle(pointerAngle(c,t,n)+u));return c=c.merge({rotation:h}),e=e.merge({scene:o.mergeIn(["layers",a,"items",l],c)}),{updatedState:e}}static endRotatingItem(e,t,n){return e=this.updateRotatingItem(e,t,n).updatedState,e=e.merge({mode:MODE_IDLE$1}),{updatedState:e}}static beginResizingItem(e,t,n,s,o){const a=e.getIn(["scene","layers",t,"items",n]);if(!a)return{updatedState:e};const l=Math.hypot(s-a.x,o-a.y);return e=e.merge({mode:MODE_RESIZING_ITEM,resizingSupport:Map$1({layerID:t,itemID:n,startDistance:l,startScale:getItemTransform(a).scale})}),{updatedState:e}}static updateResizingItem(e,t,n){const{resizingSupport:s}=e,o=s.get("layerID"),a=s.get("itemID"),l=s.get("startDistance"),c=s.get("startScale"),u=e.getIn(["scene","layers",o,"items",a]);if(!u||!l)return{updatedState:e};const h=Math.hypot(t-u.x,n-u.y);let d=clampItemScale(c*h/l);return Math.abs(d-1)<SCALE_SNAP_TOLERANCE&&(d=1),this.setAttributes(e,o,a,{scale:d})}static endResizingItem(e,t,n){return e=this.updateResizingItem(e,t,n).updatedState,e=e.merge({mode:MODE_IDLE$1,resizingSupport:Map$1()}),{updatedState:e}}static rotate(e,t,n,s){const o=e.getIn(["scene","layers",t,"items",n]);return o?this.setAttributes(e,t,n,{rotation:normalizeAngle(o.rotation+s)}):{updatedState:e}}static flip(e,t,n,s){const o=e.getIn(["scene","layers",t,"items",n]);if(!o)return{updatedState:e};const a=getItemTransform(o),l=s==="x"?"flipHorizontal":"flipVertical",c=s==="x"?a.flipHorizontal:a.flipVertical;return this.setAttributes(e,t,n,{[l]:!c})}static duplicate(e,t,n){const s=e.getIn(["scene","layers",t,"items",n]);if(!s)return{updatedState:e};const o=IDBroker.acquireID(),a=s.merge({id:o,name:NameGenerator.generateName("items",e.catalog.getIn(["elements",s.type,"info","title"])??s.type),x:s.x+DUPLICATE_OFFSET,y:s.y-DUPLICATE_OFFSET,selected:!1});return e=e.setIn(["scene","layers",t,"items",o],a),e=this.unselect(e,t,n).updatedState,e=this.select(e,t,o).updatedState,{updatedState:e,item:a}}static setProperties(e,t,n,s){return e=e.mergeIn(["scene","layers",t,"items",n,"properties"],s),{updatedState:e}}static setJsProperties(e,t,n,s){return this.setProperties(e,t,n,fromJS(s))}static updateProperties(e,t,n,s){return s.forEach((o,a)=>{e.hasIn(["scene","layers",t,"items",n,"properties",a])&&(e=e.mergeIn(["scene","layers",t,"items",n,"properties",a],o))}),{updatedState:e}}static updateJsProperties(e,t,n,s){return this.updateProperties(e,t,n,fromJS(s))}static setAttributes(e,t,n,s){return e=e.mergeIn(["scene","layers",t,"items",n],s),{updatedState:e}}static setJsAttributes(e,t,n,s){return s=fromJS(s),this.setAttributes(e,t,n,s)}},Group$2=class In{static select(e,t){let n=e.getIn(["scene","groups",t,"elements"]);e=Project.setAlterate(e).updatedState,n.entrySeq().forEach(([o,a])=>{e=Layer$1.unselectAll(e,o).updatedState;let l=a.get("lines"),c=a.get("holes"),u=a.get("items"),h=a.get("areas");l&&l.forEach(d=>{e=Line$2.select(e,o,d).updatedState}),c&&c.forEach(d=>{e=Hole.select(e,o,d).updatedState}),u&&u.forEach(d=>{e=Item$1.select(e,o,d).updatedState}),h&&h.forEach(d=>{e=Area$1.select(e,o,d).updatedState})}),e=Project.setAlterate(e).updatedState;let s=e.getIn(["scene","groups"]).map(o=>o.set("selected",!1));return e=e.setIn(["scene","groups"],s).setIn(["scene","groups",t,"selected"],!0),{updatedState:e}}static unselect(e,t){return e=e.getIn(["scene","groups",t,"elements"]).reduce((o,a,l)=>Layer$1.unselectAll(o,l).updatedState,e).setIn(["scene","groups",t,"selected"],!1),{updatedState:e}}static create(e){let t=IDBroker.acquireID();return e=e.setIn(["scene","groups",t],new Group$3({id:t,name:t})),{updatedState:e}}static createFromSelectedElements(e){let t=IDBroker.acquireID();return e=e.setIn(["scene","groups",t],new Group$3({id:t,name:t})),e.getIn(["scene","layers"]).forEach(n=>{let s=n.get("id"),o={lines:n.get("lines").filter(a=>a.get("selected")),items:n.get("items").filter(a=>a.get("selected")),holes:n.get("holes").filter(a=>a.get("selected")),areas:n.get("areas").filter(a=>a.get("selected"))};for(let a in o)o[a].forEach(l=>e=this.addElement(e,t,s,a,l.get("id")).updatedState)}),{updatedState:e}}static addElement(e,t,n,s,o){let a=e.getIn(["scene","groups",t,"elements",n,s])||List();return a.contains(o)||(e=e.setIn(["scene","groups",t,"elements",n,s],a.push(o)),e=this.reloadBaricenter(e,t).updatedState),{updatedState:e}}static setBarycenter(e,t,n,s){return typeof n<"u"&&(e=e.setIn(["scene","groups",t,"x"],n)),typeof s<"u"&&(e=e.setIn(["scene","groups",t,"y"],s)),{updatedState:e}}static reloadBaricenter(e,t){let n=e.getIn(["scene","groups",t,"elements"]),s=0,o=0,a=0;return n.entrySeq().forEach(([l,c])=>{e=Layer$1.unselectAll(e,l).updatedState;let u=c.get("lines"),h=c.get("holes"),d=c.get("items"),p=c.get("areas");u&&u.forEach(f=>{let g=e.getIn(["scene","layers",l,"lines",f,"vertices"]).map(M=>e.getIn(["scene","layers",l,"vertices",M])),{x:_,y:x}=g.get(0),{x:y,y:E}=g.get(1),{x:b,y:v}=midPoint(_,x,y,E);s+=b,o+=v,a++}),h&&h.forEach(f=>{let g=e.getIn(["scene","layers",l,"holes",f]),_=e.getIn(["scene","layers",l,"lines",g.line,"vertices"]).map(T=>e.getIn(["scene","layers",l,"vertices",T])),{x,y}=_.get(0),{x:E,y:b}=_.get(1),{x:v,y:M}=extendLine(x,y,E,b,g.offset*pointsDistance(x,y,E,b));s+=v,o+=M,a++}),d&&d.forEach(f=>{let{x:g,y:_}=e.getIn(["scene","layers",l,"items",f]);s+=g,o+=_,a++}),p&&p.forEach(f=>{let g=e.getIn(["scene","layers",l,"areas",f,"vertices"]).map(y=>e.getIn(["scene","layers",l,"vertices",y])).toJS(),{x:_,y:x}=verticesMidPoint(g);s+=_,o+=x,a++})}),a&&(e=this.setBarycenter(e,t,s/a,o/a).updatedState),{updatedState:e}}static removeElement(e,t,n,s,o){let a=e.getIn(["scene","groups",t,"elements",n,s]);return!a||!a.contains(o)?{updatedState:e}:(e=e.setIn(["scene","groups",t,"elements",n,s],a.filterNot(l=>l===o)),{updatedState:e})}static setAttributes(e,t,n){return e=e.mergeIn(["scene","groups",t],n),{updatedState:e}}static setProperties(e,t,n){return e=e.mergeIn(["scene","groups",t,"properties"],n),{updatedState:e}}static remove(e,t){return e=e.removeIn(["scene","groups",t]),{updatedState:e}}static removeAndDeleteElements(e,t){return e.getIn(["scene","groups",t,"elements"]).entrySeq().forEach(([s,o])=>{e=Layer$1.unselectAll(e,s).updatedState;let a=o.get("lines"),l=o.get("holes"),c=o.get("items");o.get("areas"),a&&a.forEach(u=>{e=Line$2.remove(e,s,u).updatedState,e=Layer$1.detectAndUpdateAreas(e,s).updatedState}),l&&l.forEach(u=>{e=Hole.remove(e,s,u).updatedState}),c&&c.forEach(u=>{e=Item$1.remove(e,s,u).updatedState})}),e=e.deleteIn(["scene","groups",t]),{updatedState:e}}static translate(e,t,n,s){let o=n-e.getIn(["scene","groups",t,"x"]),a=s-e.getIn(["scene","groups",t,"y"]);return e.getIn(["scene","groups",t,"elements"]).entrySeq().forEach(([c,u])=>{let h=u.get("lines"),d=u.get("items");if(h){let p={};h.forEach(f=>{let g=e.getIn(["scene","layers",c,"lines",f]);p[g.vertices.get(0)]||(p[g.vertices.get(0)]=e.getIn(["scene","layers",c,"vertices",g.vertices.get(0)])),p[g.vertices.get(1)]||(p[g.vertices.get(1)]=e.getIn(["scene","layers",c,"vertices",g.vertices.get(1)]))});for(let f in p){let{x:g,y:_}=p[f];e=Vertex$2.setAttributes(e,c,f,Map$1({x:g+o,y:_+a})).updatedState}for(let f in p)e=Vertex$2.beginDraggingVertex(e,c,f).updatedState,e=Vertex$2.endDraggingVertex(e).updatedState}d&&(e=d.map(p=>e.getIn(["scene","layers",c,"items",p])).reduce((p,f)=>{let{x:g,y:_}=f;return Item$1.setAttributes(p,c,f.id,Map$1({x:g+o,y:_+a})).updatedState},e)),e=Layer$1.detectAndUpdateAreas(e,c).updatedState}),e=this.setBarycenter(e,t,n,s).updatedState,e=In.select(e,t).updatedState,{updatedState:e}}static rotate(e,t,n){let{x:s,y:o,rotation:a}=e.getIn(["scene","groups",t]),l=n-a;return e=In.setAttributes(e,t,Map$1({rotation:n})).updatedState,e.getIn(["scene","groups",t,"elements"]).entrySeq().forEach(([u,h])=>{let d=h.get("lines"),p=h.get("items");if(d){let f={};d.forEach(g=>{let _=e.getIn(["scene","layers",u,"lines",g]);f[_.vertices.get(0)]||(f[_.vertices.get(0)]=e.getIn(["scene","layers",u,"vertices",_.vertices.get(0)])),f[_.vertices.get(1)]||(f[_.vertices.get(1)]=e.getIn(["scene","layers",u,"vertices",_.vertices.get(1)]))});for(let g in f){let{x:_,y:x}=f[g],{x:y,y:E}=rotatePointAroundPoint(_,x,s,o,l);e=Vertex$2.setAttributes(e,u,g,Map$1({x:y,y:E})).updatedState}for(let g in f)e=Vertex$2.beginDraggingVertex(e,u,g).updatedState,e=Vertex$2.endDraggingVertex(e).updatedState}p&&(e=p.map(f=>e.getIn(["scene","layers",u,"items",f])).reduce((f,g)=>{let{x:_,y:x,rotation:y}=g,{x:E,y:b}=rotatePointAroundPoint(_,x,s,o,l);return Item$1.setAttributes(f,u,g.id,Map$1({x:E,y:b,rotation:y+l})).updatedState},e)),e=Layer$1.detectAndUpdateAreas(e,u).updatedState}),e=In.select(e,t).updatedState,{updatedState:e}}},Line$2=class Ot{static create(e,t,n,s,o,a,l,c){let u=IDBroker.acquireID();const h=lineFamily(n);let{updatedState:d,vertex:p}=Vertex$2.add(e,t,s,o,"lines",u,h),{updatedState:f,vertex:g}=Vertex$2.add(d,t,a,l,"lines",u,h);e=f;let _=e.catalog.factoryElement(n,{id:u,name:NameGenerator.generateName("lines",e.catalog.getIn(["elements",n,"info","title"])),vertices:List([p.id,g.id]),type:n,prototype:"lines"},c);return e=e.setIn(["scene","layers",t,"lines",u],_),{updatedState:e,line:_}}static select(e,t,n,s){s||(e=Layer$1.select(e,t).updatedState);let o=e.getIn(["scene","layers",t,"lines",n]);return e=Layer$1.selectElement(e,t,"lines",n).updatedState,e=Layer$1.selectElement(e,t,"vertices",o.vertices.get(0)).updatedState,e=Layer$1.selectElement(e,t,"vertices",o.vertices.get(1)).updatedState,{updatedState:e}}static remove(e,t,n){let s=e.getIn(["scene","layers",t,"lines",n]);return s&&(e=this.unselect(e,t,n).updatedState,s.holes.forEach(o=>e=Hole.remove(e,t,o).updatedState),e=Layer$1.removeElement(e,t,"lines",n).updatedState,s.vertices.forEach(o=>e=Vertex$2.remove(e,t,o,"lines",n).updatedState),e.getIn(["scene","groups"]).forEach(o=>e=Group$2.removeElement(e,o.id,t,"lines",n).updatedState)),{updatedState:e}}static unselect(e,t,n){let s=e.getIn(["scene","layers",t,"lines",n]);return s&&(e=Layer$1.unselect(e,t,"vertices",s.vertices.get(0)).updatedState,e=Layer$1.unselect(e,t,"vertices",s.vertices.get(1)).updatedState,e=Layer$1.unselect(e,t,"lines",n).updatedState),{updatedState:e}}static split(e,t,n,s,o){let a=e.getIn(["scene","layers",t,"lines",n]),l=e.getIn(["scene","layers",t,"vertices",a.vertices.get(0)]),c=e.getIn(["scene","layers",t,"vertices",a.vertices.get(1)]),{x:u,y:h}=l,{x:d,y:p}=c,{updatedState:f,line:g}=Ot.create(e,t,a.type,u,h,s,o,a.get("properties")),{updatedState:_,line:x}=Ot.create(f,t,a.type,d,p,s,o,a.get("properties"));e=_;let y=pointPositionOnLineSegment(u,h,d,p,s,o),E=minVertex(l,c);return a.holes.forEach(v=>{let M=e.getIn(["scene","layers",t,"holes",v]),T=M.offset;if(E.x===d&&E.y===p&&(y=1-y,T=1-M.offset),T<y){let I=T/y;E.x===d&&E.y===p&&(I=1-I),e=Hole.create(e,t,M.type,g.id,I,M.properties).updatedState}else{let I=(T-y)/(1-y);E.x===d&&E.y===p&&(I=1-I),e=Hole.create(e,t,M.type,x.id,I,M.properties).updatedState}}),e.getIn(["scene","groups"]).filter(v=>{const M=v.getIn(["elements",t,"lines"]);return M&&M.contains(n)}).forEach(v=>{e=Group$2.addElement(e,v.id,t,"lines",g.id).updatedState,e=Group$2.addElement(e,v.id,t,"lines",x.id).updatedState}),e=Ot.remove(e,t,n).updatedState,{updatedState:e,lines:List([g,x])}}static addFromPoints(e,t,n,s,o,a){s=List(s).sort(({x:u,y:h},{x:d,y:p})=>u===d?h-p:u-d);let l=s.zip(s.skip(1)).filterNot(([{x:u,y:h},{x:d,y:p}])=>u===d&&h===p),c=[];return l.forEach(([{x:u,y:h},{x:d,y:p}])=>{let{updatedState:f,line:g}=this.create(e,t,n,u,h,d,p,o);e=f,a&&a.forEach(_=>{let{x,y}=_.offsetPosition;if(isPointOnLineSegment(u,h,d,p,x,y)){let E=pointPositionOnLineSegment(u,h,d,p,x,y);E>=0&&E<=1&&(e=Hole.create(e,t,_.hole.type,g.id,E,_.hole.properties).updatedState)}}),c.push(g)}),{updatedState:e,lines:List(c)}}static createAvoidingIntersections(e,t,n,s,o,a,l,c,u){let h=[{x:s,y:o},{x:a,y:l}];const d=lineFamily(n);e=e.getIn(["scene","layers",t,"lines"]).filter(g=>lineFamilyOf(g)===d).reduce((g,_)=>{var v,M;let[x,y]=_.vertices.map(T=>g.getIn(["scene","layers",t,"vertices"]).get(T)).toArray(),E=samePoints(x,h[0])||samePoints(x,h[1])||samePoints(y,h[0])||samePoints(y,h[1]),b=twoLineSegmentsIntersection(h[0],h[1],x,y);if(b.type==="colinear"){u||(u=[]);const[T,I]=orderVertices([x,y]);g.getIn(["scene","layers",t,"lines",_.id,"holes"]).forEach(w=>{let R=g.getIn(["scene","layers",t,"holes",w]),A=pointsDistance(T.x,T.y,I.x,I.y),P=extendLine(T.x,T.y,I.x,I.y,A*R.offset);u.push({hole:R,offsetPosition:P})}),g=this.remove(g,t,_.id).updatedState,h.push(x,y)}return b.type==="intersecting"&&!E&&(g=this.split(g,t,_.id,((v=b.point)==null?void 0:v.x)??0,((M=b.point)==null?void 0:M.y)??0).updatedState,h.push(b.point??{x:0,y:0})),g},e);let{updatedState:p,lines:f}=Ot.addFromPoints(e,t,n,h,c,u);return{updatedState:p,lines:f}}static replaceVertex(e,t,n,s,o,a){let l=e.getIn(["scene","layers",t,"lines",n,"vertices",s]);const c=lineFamilyOf(e.getIn(["scene","layers",t,"lines",n]));e=Vertex$2.remove(e,t,l,"lines",n).updatedState;let{updatedState:u,vertex:h}=Vertex$2.add(e,t,o,a,"lines",n,c);return e=u,e=e.setIn(["scene","layers",t,"lines",n,"vertices",s],h.id),e=e.setIn(["scene","layers",t,"lines",n],e.getIn(["scene","layers",t,"lines",n])),{updatedState:e,line:e.getIn(["scene","layers",t,"lines",n]),vertex:h}}static selectToolDrawingLine(e,t,n){let s=Map$1({type:t});return(n==null?void 0:n.thickness)!=null&&(s=s.set("thickness",n.thickness)),(n==null?void 0:n.height)!=null&&(s=s.set("height",n.height)),e=e.merge({mode:MODE_WAITING_DRAWING_LINE,drawingSupport:s}),{updatedState:e}}static drawingProperties(e){const t=e==null?void 0:e.get("thickness"),n=e==null?void 0:e.get("height");if(t==null&&n==null)return;const s={};return t!=null&&(s.thickness={length:t,_length:t,_unit:UNIT_CENTIMETER}),n!=null&&(s.height={length:n,_length:n,_unit:UNIT_CENTIMETER}),fromJS(s)}static beginDrawingLine(e,t,n,s){let o=sceneSnapElements(e.scene,List(),e.snapMask),a=null;e.snapMask&&!e.snapMask.isEmpty()&&(a=nearestSnap(o,n,s,e.snapMask),a&&({x:n,y:s}=a.point),o=o.withMutations(h=>{let d,p,f;({a:d,b:p,c:f}=horizontalLine(s)),addLineSnap(h,d,p,f,10,3,null),{a:d,b:p,c:f}=verticalLine(n),addLineSnap(h,d,p,f,10,3,null)}));let l=e.get("drawingSupport").set("layerID",t);e=Layer$1.unselectAll(e,t).updatedState;let{updatedState:c,line:u}=Ot.create(e,t,l.get("type"),n,s,n,s,Ot.drawingProperties(l));return e=Ot.select(c,t,u.id).updatedState,e=e.merge({mode:MODE_DRAWING_LINE,snapElements:o,activeSnapElement:a?a.snap:null,drawingSupport:l}),{updatedState:e}}static updateDrawingLine(e,t,n){let s=null;e.snapMask&&!e.snapMask.isEmpty()&&(s=nearestSnap(e.snapElements,t,n,e.snapMask),s&&({x:t,y:n}=s.point));let o=e.getIn(["drawingSupport","layerID"]),a=e.getIn(["scene","layers",o,"selected","lines"]).first(),{updatedState:l}=Ot.replaceVertex(e,o,a,1,t,n);return e=l,e=this.select(e,o,a).updatedState,e=e.merge({activeSnapElement:s?s.snap:null}),{updatedState:e}}static endDrawingLine(e,t,n){if(e.snapMask&&!e.snapMask.isEmpty()){let p=nearestSnap(e.snapElements,t,n,e.snapMask);p&&({x:t,y:n}=p.point)}const s=e.getIn(["drawingSupport","layerID"]),o=e.getIn(["scene","layers",s]),a=e.getIn(["scene","layers",s,"selected","lines"]).first(),l=e.getIn(["scene","layers",s,"lines",a]),c=o.vertices.get(l.vertices.get(0)),u=Ot.drawingProperties(e.get("drawingSupport"))??l.properties,h=e.getIn(["scene","layers",s,"areas"]).size;e=Ot.remove(e,s,a).updatedState,e=Ot.createAvoidingIntersections(e,s,l.type,c.x,c.y,t,n,u).updatedState,e=Layer$1.detectAndUpdateAreas(e,s).updatedState;const d=e.getIn(["scene","layers",s,"areas"]).size>h;return e=e.merge({mode:d?MODE_IDLE$1:MODE_WAITING_DRAWING_LINE,drawingSupport:d?Map$1():e.get("drawingSupport"),snapElements:List(),activeSnapElement:null}),{updatedState:e}}static beginDraggingLine(e,t,n,s,o){let a=sceneSnapElements(e.scene,List(),e.snapMask),l=e.scene.layers.get(t),c=l.lines.get(n),u=l.vertices.get(c.vertices.get(0)),h=l.vertices.get(c.vertices.get(1));return e=e.merge({mode:MODE_DRAGGING_LINE,snapElements:a,draggingSupport:Map$1({layerID:t,lineID:n,startPointX:s,startPointY:o,startVertex0X:u.x,startVertex0Y:u.y,startVertex1X:h.x,startVertex1Y:h.y})}),{updatedState:e}}static updateDraggingLine(e,t,n){let s=e.draggingSupport,o=e.snapElements,a=s.get("layerID"),l=s.get("lineID"),c=t-s.get("startPointX"),u=n-s.get("startPointY"),h=s.get("startVertex0X")+c,d=s.get("startVertex0Y")+u,p=s.get("startVertex1X")+c,f=s.get("startVertex1Y")+u,g=null,_=null,x=null;e.snapMask&&!e.snapMask.isEmpty()&&(_=nearestSnap(o,h,d,e.snapMask),x=nearestSnap(o,p,f,e.snapMask));let y=0,E=0;return _&&x?_.point.distance<x.point.distance?(y=_.point.x-h,E=_.point.y-d,g=_.snap):(y=x.point.x-p,E=x.point.y-f,g=x.snap):(_&&(y=_.point.x-h,E=_.point.y-d,g=_.snap),x&&(y=x.point.x-p,E=x.point.y-f,g=x.snap)),h+=y,d+=E,p+=y,f+=E,e=e.merge({activeSnapElement:g,scene:e.scene.updateIn(["layers",a],b=>b.withMutations(v=>{let M=v.getIn(["lines",l,"vertices"]);return v.updateIn(["vertices",M.get(0)],T=>T.merge({x:h,y:d})),v.updateIn(["vertices",M.get(1)],T=>T.merge({x:p,y:f})),v}))}),{updatedState:e}}static endDraggingLine(e,t,n){let{draggingSupport:s}=e,o=s.get("layerID"),a=e.scene.layers.get(o),l=s.get("lineID"),c=a.lines.get(l),u=a.vertices.get(c.vertices.get(0)),h=a.vertices.get(c.vertices.get(1)),d=maxVertex(u,h),p=minVertex(u,h),f=verticesDistance(p,d),g=Math.atan2(d.y-p.y,d.x-p.x),_=[];a.lines.get(l).holes.forEach(I=>{let w=a.holes.get(I),R=f*w.offset,A={x:R*Math.cos(g)+p.x,y:R*Math.sin(g)+p.y};_.push({hole:w,offsetPosition:A})});let x=t-s.get("startPointX"),y=n-s.get("startPointY"),E=s.get("startVertex0X")+x,b=s.get("startVertex0Y")+y,v=s.get("startVertex1X")+x,M=s.get("startVertex1Y")+y;if(e.snapMask&&!e.snapMask.isEmpty()){let I=nearestSnap(e.snapElements,E,b,e.snapMask),w=nearestSnap(e.snapElements,v,M,e.snapMask),R=0,A=0;I&&w?I.point.distance<w.point.distance?(R=I.point.x-E,A=I.point.y-b):(R=w.point.x-v,A=w.point.y-M):(I&&(R=I.point.x-E,A=I.point.y-b),w&&(R=w.point.x-v,A=w.point.y-M)),E+=R,b+=A,v+=R,M+=A}let T=e.getIn(["scene","groups"]).filter(I=>{const w=I.getIn(["elements",o,"lines"]);return w&&w.contains(l)});if(e=Layer$1.mergeEqualsVertices(e,o,c.vertices.get(0)).updatedState,e=Layer$1.mergeEqualsVertices(e,o,c.vertices.get(1)).updatedState,e=Ot.remove(e,o,l).updatedState,!samePoints({x:E,y:b},{x:v,y:M})){let I=Ot.createAvoidingIntersections(e,o,c.type,E,b,v,M,c.properties,_);e=I.updatedState,I.lines.forEach(w=>{T.forEach(R=>{e=Group$2.addElement(e,R.id,o,"lines",w.id).updatedState})})}return e=Layer$1.detectAndUpdateAreas(e,o).updatedState,e=e.merge({mode:MODE_IDLE$1,draggingSupport:null,activeSnapElement:null,snapElements:List()}),{updatedState:e}}static setProperties(e,t,n,s){return e=e.mergeIn(["scene","layers",t,"lines",n,"properties"],s),{updatedState:e}}static setJsProperties(e,t,n,s){return this.setProperties(e,t,n,fromJS(s))}static updateProperties(e,t,n,s){return s.forEach((o,a)=>{e.hasIn(["scene","layers",t,"lines",n,"properties",a])&&(e=e.mergeIn(["scene","layers",t,"lines",n,"properties",a],o))}),{updatedState:e}}static updateJsProperties(e,t,n,s){return this.updateProperties(e,t,n,fromJS(s))}static setAttributes(e,t,n,s){let o=s.toJS(),{vertexOne:a,vertexTwo:l,lineLength:c}=o;return delete o.vertexOne,delete o.vertexTwo,delete o.lineLength,e=e.mergeIn(["scene","layers",t,"lines",n],fromJS(o)).mergeIn(["scene","layers",t,"vertices",a.id],{x:a.x,y:a.y}).mergeIn(["scene","layers",t,"vertices",l.id],{x:l.x,y:l.y}).mergeIn(["scene","layers",t,"lines",n,"misc"],Map$1({_unitLength:c._unit})),e=Layer$1.mergeEqualsVertices(e,t,a.id).updatedState,a.x!=l.x&&a.y!=l.y&&(e=Layer$1.mergeEqualsVertices(e,t,l.id).updatedState),e=Layer$1.detectAndUpdateAreas(e,t).updatedState,{updatedState:e}}static setVerticesCoords(e,t,n,s,o,a,l){let c=e.getIn(["scene","layers",t,"lines",n]);return e=Vertex$2.setAttributes(e,t,c.vertices.get(0),Map$1({x:s,y:o})).updatedState,e=Vertex$2.setAttributes(e,t,c.vertices.get(1),Map$1({x:a,y:l})).updatedState,{updatedState:e}}},Vertex$2=class{static add(e,t,n,s,o,a,l){const c=e.getIn(["scene","layers",t]);let u=c.get("vertices").find(h=>samePoints(h,{x:n,y:s})&&(!l||vertexAcceptsFamily(h,c,l)));return u?u=u.update(o,h=>h.push(a)):u=new Vertex$3({id:IDBroker.acquireID(),name:"Vertex",x:n,y:s,[o]:List([a])}),e=e.setIn(["scene","layers",t,"vertices",u.id],u),{updatedState:e,vertex:u}}static setAttributes(e,t,n,s){return e=e.mergeIn(["scene","layers",t,"vertices",n],s),{updatedState:e}}static addElement(e,t,n,s,o){return e=e.updateIn(["scene","layers",t,"vertices",n,s],a=>a.push(o)),{updatedState:e}}static removeElement(e,t,n,s,o){let a=e.getIn(["scene","layers",t,"vertices",n,s]).findIndex(l=>l===o);return a!==-1&&(e=e.updateIn(["scene","layers",t,"vertices",n,s],l=>l.remove(a))),{updatedState:e}}static select(e,t,n){return e=e.setIn(["scene","layers",t,"vertices",n,"selected"],!0),e=e.updateIn(["scene","layers",t,"selected","vertices"],s=>s.push(n)),{updatedState:e}}static unselect(e,t,n){return e=e.setIn(["scene","layers",t,"vertices",n,"selected"],!1),e=e.updateIn(["scene","layers",t,"selected","vertices"],s=>s.filter(o=>o.id!==n)),{updatedState:e}}static remove(e,t,n,s,o,a){let l=e.getIn(["scene","layers",t,"vertices",n]);return l&&(s&&o&&(l=l.update(s,u=>{let h=u.findIndex(d=>o===d);return u.delete(h)})),(l.areas.size||l.lines.size)&&!a?e=e.setIn(["scene","layers",t,"vertices",n],l):e=e.deleteIn(["scene","layers",t,"vertices",n])),{updatedState:e}}static beginDraggingVertex(e,t,n){let s=sceneSnapElements(e.scene,List(),e.snapMask);return e=e.merge({mode:MODE_DRAGGING_VERTEX,snapElements:s,draggingSupport:Map$1({layerID:t,vertexID:n,previousMode:e.get("mode")})}),{updatedState:e}}static updateDraggingVertex(e,t,n){let{draggingSupport:s,snapElements:o,scene:a}=e,l=null;e.snapMask&&!e.snapMask.isEmpty()&&(l=nearestSnap(o,t,n,e.snapMask),l&&({x:t,y:n}=l.point));let c=s.get("layerID"),u=s.get("vertexID");return e=e.merge({activeSnapElement:l?l.snap:null,scene:a.mergeIn(["layers",c,"vertices",u],{x:t,y:n})}),{updatedState:e}}static endDraggingVertex(e){let{draggingSupport:t}=e,n=t.get("layerID"),s=t.get("vertexID"),o=e.getIn(["scene","layers",n,"vertices",s,"lines"]);return o&&(e=o.reduce((a,l)=>{if(!a.getIn(["scene","layers",n,"lines",l]))return a;let c=a.getIn(["scene","layers",n,"lines",l,"vertices",0]),u=a.getIn(["scene","layers",n,"lines",l,"vertices",1]),h=c===s?u:c,d=a.getIn(["scene","layers",n,"vertices",h]),p=a.getIn(["scene","layers",n,"vertices",s]),f=[],[g,_]=orderVertices([d,p]);a.getIn(["scene","layers",n,"lines",l,"holes"]).forEach(b=>{let v=a.getIn(["scene","layers",n,"holes",b]),M=pointsDistance(g.x,g.y,_.x,_.y),T=extendLine(g.x,g.y,_.x,_.y,M*v.offset);f.push({hole:v,offsetPosition:T})});let x=a.getIn(["scene","layers",n,"lines",l,"type"]),y=a.getIn(["scene","layers",n,"lines",l,"properties"]),E=a.getIn(["scene","groups"]).filter(b=>{const v=b.getIn(["elements",n,"lines"]);return v&&v.contains(l)});if(a=Layer$1.removeZeroLengthLines(a,n).updatedState,a=Layer$1.mergeEqualsVertices(a,n,s).updatedState,a=Line$2.remove(a,n,l).updatedState,!samePoints(d,p)){let b=Line$2.createAvoidingIntersections(a,n,x,d.x,d.y,p.x,p.y,y,f);a=b.updatedState,b.lines.forEach(v=>{E.forEach(M=>{a=Group$2.addElement(a,M.id,n,"lines",v.id).updatedState})})}return a},e)),e=Layer$1.detectAndUpdateAreas(e,n).updatedState,e=e.merge({mode:t.get("previousMode"),draggingSupport:null,activeSnapElement:null,snapElements:List()}),{updatedState:e}}},Area$1=class Er{static getSurfaceLines(e,t,n){const s=e.getIn(["scene","layers",t,"areas",n]),o=e.getIn(["scene","layers",t,"lines"]),a=e.getIn(["scene","layers",t,"vertices"]);let l=Set$1();return s.get("vertices").forEach(c=>{a.get(c).get("lines").forEach(h=>{o.get(h).get("type")==="surface"&&(l=l.add(h))})}),l}static center(e,t,n){const s=e.getIn(["scene","layers",t,"areas",n]);if(!s)return null;let o=0,a=0,l=0;return s.get("vertices").forEach(c=>{const u=e.getIn(["scene","layers",t,"vertices",c]);u&&(o+=u.get("x"),a+=u.get("y"),l++)}),l>0?{x:o/l,y:a/l}:null}static transform(e,t,n,s){const o=e.getIn(["scene","layers",t,"areas",n]);return o?(o.get("vertices").forEach(a=>{const l=["scene","layers",t,"vertices",a],c=e.getIn(l);if(!c)return;const u=s({x:c.get("x"),y:c.get("y")});e=e.mergeIn(l,{x:u.x,y:u.y})}),{updatedState:e}):{updatedState:e}}static rotate(e,t,n,s){const o=this.center(e,t,n);if(!o)return{updatedState:e};const a=s*Math.PI/180,l=Math.cos(a),c=Math.sin(a);return this.transform(e,t,n,({x:u,y:h})=>{const d=u-o.x,p=h-o.y;return{x:o.x+d*l-p*c,y:o.y+d*c+p*l}})}static mirror(e,t,n,s){const o=this.center(e,t,n);return o?this.transform(e,t,n,({x:a,y:l})=>({x:s==="x"?2*o.x-a:a,y:s==="y"?2*o.y-l:l})):{updatedState:e}}static add(e,t,n,s,o,a){let l,c=e.getIn(["scene","layers",t]);return c=c.withMutations(u=>{const h=IDBroker.acquireID(),d=s.map(p=>Vertex$2.add(e,t,p.x,p.y,"areas",h,a).vertex.id);l=o.factoryElement(n,{id:h,name:NameGenerator.generateName("areas",o.getIn(["elements",n,"info","title"])),type:n,prototype:"areas",vertices:d}),u.setIn(["areas",h],l)}),e=e.setIn(["scene","layers",t],c),{updatedState:e,area:l}}static select(e,t,n){let s=Er.getSurfaceLines(e,t,n);return e=Layer$1.select(e,t).updatedState,e=Layer$1.selectElement(e,t,"areas",n).updatedState,s.size>0&&s.forEach(o=>{e=Line$2.select(e,t,o,!0).updatedState}),{updatedState:e}}static remove(e,t,n){let s=e.getIn(["scene","layers",t,"areas",n]);return s.get("selected")===!0&&(e=this.unselect(e,t,n).updatedState),s.vertices.forEach(o=>{e=Vertex$2.remove(e,t,o,"areas",n).updatedState}),e=e.deleteIn(["scene","layers",t,"areas",n]),e.getIn(["scene","groups"]).forEach(o=>e=Group$2.removeElement(e,o.id,t,"areas",n).updatedState),{updatedState:e}}static unselect(e,t,n){return e=Layer$1.unselect(e,t,"areas",n).updatedState,{updatedState:e}}static setProperties(e,t,n,s){return e=e.mergeIn(["scene","layers",t,"areas",n,"properties"],s),{updatedState:e}}static setJsProperties(e,t,n,s){return this.setProperties(e,t,n,fromJS(s))}static updateProperties(e,t,n,s){return s.forEach((o,a)=>{e.hasIn(["scene","layers",t,"areas",n,"properties",a])&&(e=e.mergeIn(["scene","layers",t,"areas",n,"properties",a],o))}),{updatedState:e}}static updateJsProperties(e,t,n,s){return this.updateProperties(e,t,n,fromJS(s))}static setAttributes(e){return{updatedState:e}}};const sameSet=(i,e)=>i.size===e.size&&i.isSuperset(e)&&i.isSubset(e);function faceSignature(i){let e=0,t=0,n=0;for(let s=0;s<i.length;s++){const o=i[s],a=i[(s+1)%i.length],l=o.x*a.y-a.x*o.y;e+=l,t+=(o.x+a.x)*l,n+=(o.y+a.y)*l}return e===0?null:{area:Math.abs(e/2),x:t/(3*e),y:n/(3*e)}}const sameFace=(i,e)=>{const t=(n,s)=>Math.abs(n-s)<=1e-6*Math.max(1,Math.abs(n),Math.abs(s));return t(i.area,e.area)&&t(i.x,e.x)&&t(i.y,e.y)};function interiorPoint(i){if(i.length<3)return null;const[e,t]=polylabel([i.map(n=>[n.x,n.y])],1);return Number.isFinite(e)&&Number.isFinite(t)?{x:e,y:t}:null}let Layer$1=class{static create(e,t,n){let s=IDBroker.acquireID();t=t||`layer ${s}`,n=n||0;let o=new Layer$2({id:s,name:t,altitude:n});return e=e.setIn(["scene","selectedLayer"],s),e=e.setIn(["scene","layers",s],o),{updatedState:e}}static select(e,t){return e.get("alterate")||(e=Project.unselectAll(e).updatedState),e=e.setIn(["scene","selectedLayer"],t),{updatedState:e}}static selectElement(e,t,n,s){return e=e.setIn(["scene","layers",t,n,s,"selected"],!0),e=e.updateIn(["scene","layers",t,"selected",n],o=>o.push(s)),{updatedState:e}}static unselect(e,t,n,s){return e=e.setIn(["scene","layers",t,n,s,"selected"],!1),e=e.updateIn(["scene","layers",t,"selected",n],o=>o.filter(a=>a.id===s)),{updatedState:e}}static unselectAll(e,t){let{lines:n,holes:s,items:o,areas:a}=e.getIn(["scene","layers",t]);return n&&n.forEach(l=>{e=Line$2.unselect(e,t,l.id).updatedState}),s&&s.forEach(l=>{e=Hole.unselect(e,t,l.id).updatedState}),o&&o.forEach(l=>{e=Item$1.unselect(e,t,l.id).updatedState}),a&&a.forEach(l=>{e=Area$1.unselect(e,t,l.id).updatedState}),{updatedState:e}}static setProperties(e,t,n){return e=e.mergeIn(["scene","layers",t],n),e=e.updateIn(["scene","layers"],s=>s.sort((o,a)=>o.altitude!==a.altitude?o.altitude-a.altitude:o.order-a.order)),{updatedState:e}}static remove(e,t){return e=e.removeIn(["scene","layers",t]),e=e.setIn(["scene","selectedLayer"],e.scene.selectedLayer!==t?e.scene.selectedLayer:e.scene.layers.first().id),{updatedState:e}}static removeElement(e,t,n,s){return e=e.deleteIn(["scene","layers",t,n,s]),{updatedState:e}}static detectAndUpdateAreas(e,t){let n=[],s={},o={};e.getIn(["scene","layers",t,"vertices"]).forEach(_=>{let y=n.push([_.x,_.y])-1;s[_.id]=y,o[y]=_.id});const a=new Map;LINE_FAMILIES.forEach(_=>a.set(_,[])),e.getIn(["scene","layers",t,"lines"]).forEach(_=>{const x=_.vertices.map(y=>s[y]).toArray();x[0]!==x[1]&&a.get(lineFamilyOf(_)).push(x)});let l=List();const c=[];LINE_FAMILIES.forEach(_=>{calculateInnerCycles(n,a.get(_)).forEach(x=>{l=l.push(List(x.map(y=>o[y]))),c.push(_)})}),l=l.map(_=>isClockWiseOrder(_.map(x=>e.getIn(["scene","layers",t,"vertices",x])))?_.reverse():_);const u=[],h=[],d=[];e.getIn(["scene","layers",t,"areas"]).forEach(_=>{if(!l.some(y=>sameSet(y,_.vertices))){const y=areaFamily(_,e.getIn(["scene","layers",t])),E=_.vertices.map(v=>e.getIn(["scene","layers",t,"vertices",v])).filter(Boolean).map(v=>({x:v.x,y:v.y})).toArray(),b=faceSignature(E);b&&d.push({signature:b,polygon:E.flatMap(v=>[v.x,v.y]),properties:_.get("properties"),family:y}),e=Area$1.remove(e,t,_.id).updatedState}}),l.forEach((_,x)=>{const y=c[x];h[x]=y;const E=e.getIn(["scene","layers",t,"areas"]).find(b=>sameSet(b.vertices,_));if(E)u[x]=E.id,e=e.setIn(["scene","layers",t,"areas",u[x],"holes"],List());else{const b=_.map(w=>e.getIn(["scene","layers",t,"vertices",w])),v=Area$1.add(e,t,"area",b,e.catalog,y);u[x]=v.area.id,e=v.updatedState;const M=b.map(w=>({x:w.x,y:w.y})).toArray(),T=faceSignature(M);let I=null;if(T){const w=d.filter(A=>A.family===y),R=d.findIndex(A=>A.family===y&&sameFace(A.signature,T));if(R!==-1)[I]=d.splice(R,1);else{const A=interiorPoint(M);A&&(I=w.reduce((P,B)=>B.signature.area>T.area&&ContainsPoint(B.polygon,A.x,A.y)&&(!P||B.signature.area<P.signature.area)?B:P,null))}}I&&(e=e.mergeIn(["scene","layers",t,"areas",u[x],"properties"],I.properties))}});let p=u.map((_,x)=>{let y=e.getIn(["scene","layers",t,"areas",_]).vertices.map(E=>{let{x:b,y:v}=e.getIn(["scene","layers",t,"vertices",E]);return List([b,v])});return{id:_,vertices:y,family:h[x]}}),f,g;for(f=0;f<p.length;f++){let _=List(),x=p[f].vertices.flatten().toArray();for(g=0;g<p.length;g++)f!==g&&p[f].family===p[g].family&&ContainsPoint(x,p[g].vertices.get(0).get(0),p[g].vertices.get(0).get(1))&&(_=_.push(p[g].id));e=e.setIn(["scene","layers",t,"areas",p[f].id,"holes"],_)}return u.forEach(_=>{let x=new Set,y=e.getIn(["scene","layers",t,"areas",_,"holes"]);y.forEach(E=>{e.getIn(["scene","layers",t,"areas",E,"holes"]).forEach(v=>{y.indexOf(v)!==-1&&x.add(v)})}),x.forEach(E=>{y=y.remove(y.indexOf(E))}),e=e.setIn(["scene","layers",t,"areas",_,"holes"],y)}),{updatedState:e}}static removeZeroLengthLines(e,t){return{updatedState:e.getIn(["scene","layers",t,"lines"]).reduce((s,o)=>{let a=o.getIn(["vertices",0]),l=o.getIn(["vertices",1]),c=s.getIn(["scene","layers",t,"vertices",a]),u=s.getIn(["scene","layers",t,"vertices",l]);return verticesDistance(c,u)===0&&(s=Line$2.remove(s,t,o.id).updatedState),s},e)}}static mergeEqualsVertices(e,t,n){const s=e.getIn(["scene","layers",t]),o=s.getIn(["vertices",n]),a=LINE_FAMILIES.filter(c=>vertexAcceptsFamily(o,s,c));let l=s.get("vertices").filter(c=>c.id!==n&&samePoints(o,c)&&a.some(u=>vertexAcceptsFamily(c,s,u)));return l.isEmpty()?{updatedState:e}:(l.forEach(c=>{let u=c.lines.reduce((d,p)=>(d=d.updateIn(["scene","layers",t,"lines",p,"vertices"],f=>{if(f)return f.map(g=>g===c.id?n:g)}),d=Vertex$2.addElement(d,t,n,"lines",p).updatedState,d),e),h=c.areas.reduce((d,p)=>(d=d.updateIn(["scene","layers",t,"areas",p,"vertices"],f=>{if(f)return f.map(g=>g===c.id?n:g)}),d=Vertex$2.addElement(d,t,n,"areas",p).updatedState,d),u);e=Vertex$2.remove(h,t,c.id,null,null,!0).updatedState}),{updatedState:e})}static setPropertiesOnSelected(e,t,n){let s=e.getIn(["scene","layers",t,"selected"]);return s.lines.forEach(o=>e=Line$2.setProperties(e,t,o,n).updatedState),s.holes.forEach(o=>e=Hole.setProperties(e,t,o,n).updatedState),s.areas.forEach(o=>e=Area$1.setProperties(e,t,o,n).updatedState),s.items.forEach(o=>e=Item$1.setProperties(e,t,o,n).updatedState),{updatedState:e}}static updatePropertiesOnSelected(e,t,n){let s=e.getIn(["scene","layers",t,"selected"]);return s.lines.forEach(o=>e=Line$2.updateProperties(e,t,o,n).updatedState),s.holes.forEach(o=>e=Hole.updateProperties(e,t,o,n).updatedState),s.areas.forEach(o=>e=Area$1.updateProperties(e,t,o,n).updatedState),s.items.forEach(o=>e=Item$1.updateProperties(e,t,o,n).updatedState),{updatedState:e}}static setAttributesOnSelected(e,t,n){let s=e.getIn(["scene","layers",t,"selected"]);return s.lines.forEach(o=>e=Line$2.setAttributes(e,t,o,n).updatedState),s.holes.forEach(o=>e=Hole.setAttributes(e,t,o,n).updatedState),s.items.forEach(o=>e=Item$1.setAttributes(e,t,o,n).updatedState),{updatedState:e}}};class HorizontalGuide{static create(e,t){let n=IDBroker.acquireID();return e=e.setIn(["scene","guides","horizontal",n],t),{updatedState:e}}static remove(e,t){return e=e.deleteIn(["scene","guides","horizontal",t]),{updatedState:e}}}class VerticalGuide{static create(e,t){let n=IDBroker.acquireID();return e=e.setIn(["scene","guides","vertical",n],t),{updatedState:e}}static remove(e,t){return e=e.deleteIn(["scene","guides","vertical",t]),{updatedState:e}}}const ROLLBACK_KEEPS_SCENE=[MODE_IDLE$1,MODE_2D_PAN,MODE_2D_ZOOM_IN,MODE_2D_ZOOM_OUT,MODE_3D_VIEW,MODE_3D_FIRST_PERSON,MODE_WAITING_DRAWING_LINE,MODE_WAITING_DRAWING_SURFACE,MODE_WAITING_DRAWING_ROOM,MODE_DRAWING_ROOM];class Project{static setAlterate(e){return{updatedState:e.set("alterate",!e.alterate)}}static openCatalog(e){return e=this.setMode(e,MODE_VIEWING_CATALOG).updatedState,{updatedState:e}}static newProject(e){const t=e.get("catalog");return e=new State$1({viewer2D:e.get("viewer2D")}),e=e.set("catalog",t),{updatedState:e}}static loadProject(e,t){return e=new State$1({scene:t,catalog:e.catalog.toJS()}),{updatedState:e}}static setProperties(e,t,n){return e=Layer$1.setPropertiesOnSelected(e,t,n).updatedState,{updatedState:e}}static updateProperties(e,t,n){return e=Layer$1.updatePropertiesOnSelected(e,t,n).updatedState,{updatedState:e}}static setItemsAttributes(e,t){return e.getIn(["scene","layers"]).forEach(n=>{e=Layer$1.setAttributesOnSelected(e,n.id,t).updatedState}),{updatedState:e}}static setLinesAttributes(e,t){return e.getIn(["scene","layers"]).forEach(n=>{e=Layer$1.setAttributesOnSelected(e,n.id,t).updatedState}),{updatedState:e}}static setHolesAttributes(e,t){return e.getIn(["scene","layers"]).forEach(n=>{e=Layer$1.setAttributesOnSelected(e,n.id,t).updatedState}),{updatedState:e}}static unselectAll(e){return e.getIn(["scene","layers"]).forEach(({id:t})=>{e=Layer$1.unselectAll(e,t).updatedState}),e.getIn(["scene","groups"]).forEach(t=>{e=Group$2.unselect(e,t.get("id")).updatedState}),{updatedState:e}}static remove(e){let t=e.getIn(["scene","selectedLayer"]),{lines:n,holes:s,items:o}=e.getIn(["scene","layers",t,"selected"]);return e=Layer$1.unselectAll(e,t).updatedState,n.forEach(a=>{e=Line$2.remove(e,t,a).updatedState}),s.forEach(a=>{e=Hole.remove(e,t,a).updatedState}),o.forEach(a=>{e=Item$1.remove(e,t,a).updatedState}),e=Layer$1.detectAndUpdateAreas(e,t).updatedState,{updatedState:e}}static undo(e){let t=e.sceneHistory;return e.scene===t.last&&t.list.size>1&&(t=historyPop(t)),e=e.merge({mode:MODE_IDLE$1,scene:t.last,sceneHistory:historyPop(t)}),{updatedState:e}}static redo(e){let t=e.sceneHistory;return e.scene===t.last&&t.redoList.size>0&&(t=historyRedo(t)),e=e.merge({mode:MODE_IDLE$1,scene:t.last,sceneHistory:t}),{updatedState:e}}static rollback(e){let t=e.sceneHistory;if(!t.last&&t.list.isEmpty())return{updatedState:e};e=this.unselectAll(e).updatedState;const n={mode:MODE_IDLE$1,snapElements:List(),activeSnapElement:null,drawingSupport:Map$1(),draggingSupport:Map$1(),rotatingSupport:Map$1()};return ROLLBACK_KEEPS_SCENE.includes(e.get("mode"))?{updatedState:e.merge(n)}:(e=e.merge({...n,scene:t.last,sceneHistory:historyPush(t,t.last)}),{updatedState:e})}static setProjectProperties(e,t){let n=e.scene.merge(t);return e=e.merge({mode:MODE_IDLE$1,scene:n}),{updatedState:e}}static openProjectConfigurator(e){return e=e.merge({mode:MODE_CONFIGURING_PROJECT}),{updatedState:e}}static initCatalog(e,t){return e=e.set("catalog",new Catalog$1(t)),{updatedState:e}}static updateMouseCoord(e,t){return e=e.set("mouse",Map$1(t)),{updatedState:e}}static updateZoomScale(e,t){return e=e.set("zoom",t),{updatedState:e}}static toggleSnap(e,t){return e=e.set("snapMask",t),{updatedState:e}}static throwError(e,t){return e=e.set("errors",e.get("errors").push({date:Date.now(),error:t})),{updatedState:e}}static throwWarning(e,t){return e=e.set("warnings",e.get("warnings").push({date:Date.now(),warning:t})),{updatedState:e}}static copyProperties(e,t){return e=e.set("clipboardProperties",t),{updatedState:e}}static pasteProperties(e){return e=this.updateProperties(e,e.getIn(["scene","selectedLayer"]),e.get("clipboardProperties")).updatedState,{updatedState:e}}static pushLastSelectedCatalogElementToHistory(e,t){let n=e.selectedElementsHistory,s=n.findIndex(o=>o.name===t.name);return s!==-1&&(n=n.splice(s,1)),n=n.splice(0,0,t),e=e.set("selectedElementsHistory",n),{updatedState:e}}static changeCatalogPage(e,t,n){return e=e.setIn(["catalog","page"],n).updateIn(["catalog","path"],s=>s.push(t)),{updatedState:e}}static goBackToCatalogPage(e,t){let n=e.catalog.path.findIndex(s=>s===t);return e=e.setIn(["catalog","page"],t).updateIn(["catalog","path"],s=>s.take(n)),{updatedState:e}}static setMode(e,t){return e=e.set("mode",t),{updatedState:e}}static addHorizontalGuide(e,t){return e=HorizontalGuide.create(e,t).updatedState,{updatedState:e}}static addVerticalGuide(e,t){return e=VerticalGuide.create(e,t).updatedState,{updatedState:e}}static addCircularGuide(e,t,n,s){return console.log("adding horizontal guide at",t,n,s),{updatedState:e}}static removeHorizontalGuide(e,t){return e=HorizontalGuide.remove(e,t).updatedState,{updatedState:e}}static removeVerticalGuide(e,t){return e=VerticalGuide.remove(e,t).updatedState,{updatedState:e}}static removeCircularGuide(e,t){return console.log("removeing horizontal guide ",t),{updatedState:e}}}const CLOSE_POLYGON_RADIUS=10;class Surface{static selectToolDrawingSurface(e,t){return e=e.merge({mode:MODE_WAITING_DRAWING_SURFACE,drawingSupport:Map$1({type:t})}),{updatedState:e}}static anchorSnaps(e,t,n){let s=sceneSnapElements(e.scene,List(),e.snapMask);return!e.snapMask||e.snapMask.isEmpty()?s:s.withMutations(o=>{let{a,b:l,c}=horizontalLine(n);addLineSnap(o,a,l,c,10,3,null),{a,b:l,c}=verticalLine(t),addLineSnap(o,a,l,c,10,3,null)})}static beginDrawingSurface(e,t,n,s){let o=e.get("drawingSupport"),a=o.get("points"),l=null;a&&a.size?{x:n,y:s}=a.last():(e.snapMask&&!e.snapMask.isEmpty()&&(l=nearestSnap(sceneSnapElements(e.scene,List(),e.snapMask),n,s,e.snapMask),l&&({x:n,y:s}=l.point)),a=List([{x:n,y:s}]));const c=Surface.anchorSnaps(e,n,s),u=o.get("type");o=o.merge({layerID:t,points:a}),e=Layer$1.unselectAll(e,t).updatedState;let{updatedState:h,line:d}=Line$2.create(e,t,u,n,s,n,s);if(e=Line$2.select(h,t,d.id).updatedState,a.size>=2){const p=a.first(),f=Line$2.create(e,t,u,n,s,p.x,p.y);e=f.updatedState,o=o.set("closingLineID",f.line.id)}else o=o.delete("closingLineID");return e=e.merge({mode:MODE_DRAWING_SURFACE,snapElements:c,activeSnapElement:l?l.snap:null,drawingSupport:o}),{updatedState:e}}static updateDrawingSurface(e,t,n){const s=e.getIn(["drawingSupport","layerID"]),o=e.getIn(["drawingSupport","closingLineID"]),a=e.getIn(["scene","layers",s,"selected","lines"]).first();if(!a)return{updatedState:e};let l=null;return e.snapMask&&!e.snapMask.isEmpty()&&(l=nearestSnap(e.snapElements,t,n,e.snapMask),l&&({x:t,y:n}=l.point)),e=Line$2.replaceVertex(e,s,a,1,t,n).updatedState,e=Line$2.select(e,s,a).updatedState,o&&e.getIn(["scene","layers",s,"lines",o])&&(e=Line$2.replaceVertex(e,s,o,0,t,n).updatedState,e=Layer$1.detectAndUpdateAreas(e,s).updatedState),{updatedState:e.merge({activeSnapElement:l?l.snap:null})}}static endDrawingSurface(e,t,n){const s=e.get("drawingSupport"),o=s.get("layerID"),a=s.get("type"),l=s.get("points")??List(),c=s.get("closingLineID"),u=e.getIn(["scene","layers",o,"selected","lines"]).first();if(e.snapMask&&!e.snapMask.isEmpty()){const g=nearestSnap(e.snapElements,t,n,e.snapMask);g&&({x:t,y:n}=g.point)}u&&(e=Line$2.remove(e,o,u).updatedState),c&&(e=Line$2.remove(e,o,c).updatedState);const h=l.last()??{x:t,y:n},d=l.first(),p=l.size>=2&&!!d&&pointsDistance(d.x,d.y,t,n)<=CLOSE_POLYGON_RADIUS,f=p?{x:d.x,y:d.y}:{x:t,y:n};return samePoints(h,f)?{updatedState:e.merge({mode:MODE_WAITING_DRAWING_SURFACE,drawingSupport:s.delete("closingLineID"),snapElements:List(),activeSnapElement:null})}:(e=Line$2.createAvoidingIntersections(e,o,a,h.x,h.y,f.x,f.y).updatedState,e=Layer$1.detectAndUpdateAreas(e,o).updatedState,{updatedState:e.merge({mode:p?MODE_IDLE$1:MODE_WAITING_DRAWING_SURFACE,drawingSupport:p?Map$1():s.merge({points:l.push(f)}).delete("closingLineID"),snapElements:List(),activeSnapElement:null})})}static finishDrawingSurface(e){var h;const t=e.get("drawingSupport"),n=t==null?void 0:t.get("layerID"),s=t==null?void 0:t.get("type"),o=(t==null?void 0:t.get("points"))??List(),a=t==null?void 0:t.get("closingLineID");if(!n||!s||o.size<3)return{updatedState:e,finished:!1};const l=(h=e.getIn(["scene","layers",n,"selected","lines"]))==null?void 0:h.first();l&&(e=Line$2.remove(e,n,l).updatedState),a&&(e=Line$2.remove(e,n,a).updatedState);const c=o.first(),u=o.last();return samePoints(c,u)||(e=Line$2.createAvoidingIntersections(e,n,s,u.x,u.y,c.x,c.y).updatedState),e=Layer$1.detectAndUpdateAreas(e,n).updatedState,e=Layer$1.unselectAll(e,n).updatedState,{updatedState:e.merge({mode:MODE_IDLE$1,drawingSupport:Map$1(),snapElements:List(),activeSnapElement:null}),finished:!0}}}class Room{static selectToolDrawingRoom(e,t){return e=e.merge({mode:MODE_WAITING_DRAWING_ROOM,drawingSupport:Map$1({type:"wall",thickness:(t==null?void 0:t.thickness)??15,height:(t==null?void 0:t.height)??280})}),{updatedState:e}}static beginDrawingRoom(e,t,n,s){const o=sceneSnapElements(e.scene,List(),e.snapMask);let a=null;e.snapMask&&!e.snapMask.isEmpty()&&(a=nearestSnap(o,n,s,e.snapMask),a&&({x:n,y:s}=a.point));const l=e.get("drawingSupport").set("layerID",t).set("startX",n).set("startY",s).set("currentX",n).set("currentY",s);return e=e.merge({sceneHistory:historyPush(e.get("sceneHistory"),e.get("scene"))}),e=Layer$1.unselectAll(e,t).updatedState,e=e.merge({mode:MODE_DRAWING_ROOM,drawingSupport:l,snapElements:o,activeSnapElement:a?a.snap:null}),{updatedState:e}}static updateDrawingRoom(e,t,n){let s=null;e.snapMask&&!e.snapMask.isEmpty()&&(s=nearestSnap(e.snapElements,t,n,e.snapMask),s&&({x:t,y:n}=s.point));const o=e.get("drawingSupport").set("currentX",t).set("currentY",n);return e=e.merge({drawingSupport:o,activeSnapElement:s?s.snap:null}),{updatedState:e}}static endDrawingRoom(e,t,n){if(e.snapMask&&!e.snapMask.isEmpty()){const y=nearestSnap(e.snapElements,t,n,e.snapMask);y&&({x:t,y:n}=y.point)}const s=e.get("drawingSupport"),o=s.get("layerID"),a=s.get("startX"),l=s.get("startY"),c=s.get("thickness")??15,u=s.get("height")??280,h=Math.min(a,t),d=Math.min(l,n),p=Math.max(a,t),f=Math.max(l,n);if(p-h<1||f-d<1)return e=e.merge({mode:MODE_IDLE$1,drawingSupport:Map$1(),snapElements:List(),activeSnapElement:null}),{updatedState:e};const g=fromJS({thickness:{length:c,_length:c,_unit:"cm"},height:{length:u,_length:u,_unit:"cm"}}),_=[[h,d,p,d],[p,d,p,f],[p,f,h,f],[h,f,h,d]];let x=e;for(const[y,E,b,v]of _)x=Line$2.createAvoidingIntersections(x,o,"wall",y,E,b,v,g).updatedState;return x=Layer$1.detectAndUpdateAreas(x,o).updatedState,x=x.merge({mode:MODE_IDLE$1,drawingSupport:Map$1(),snapElements:List(),activeSnapElement:null}),{updatedState:x}}}const ROOM_CATEGORIES=[{value:"house",label:"House",types:[{value:"living",label:"Living",color:"#FFDFBF"},{value:"dining",label:"Dining",color:"#E6AC73"},{value:"kitchen",label:"Kitchen",color:"#CEDFF3"},{value:"kids-room",label:"Kid's room",color:"#90DDCD"},{value:"nursery",label:"Nursery",color:"#FFCB4D"},{value:"bedroom",label:"Bedroom",color:"#FFD1CC"},{value:"bathroom",label:"Bathroom",color:"#C3C3DA"},{value:"toilet",label:"Toilet",color:"#DCDCE6"},{value:"home-office",label:"Home Office",color:"#D7D7D7"},{value:"hallway",label:"Hallway",color:"#FFE699"},{value:"utility",label:"Utility",color:"#999999"},{value:"storage",label:"Storage",color:"#CCB799"},{value:"closet",label:"Closet",color:"#E0BF8F"},{value:"landing",label:"Landing",color:"#ED9B8D"},{value:"attic",label:"Attic",color:"#D99A8D"},{value:"balcony",label:"Balcony",color:"#A6A695"},{value:"garden",label:"Garden",color:"#CEF3D4"},{value:"patio",label:"Patio",color:"#F3E7E7"},{value:"parking",label:"Parking",color:"#F5F5EB"},{value:"porch",label:"Porch",color:"#D2D9AE"},{value:"garage",label:"Garage",color:"#F5F5EB"},{value:"shed",label:"Shed",color:"#CC7F70"},{value:"other",label:"Other",color:"#F4F4F4"},{value:"outdoor",label:"Outdoor",color:"#A4D4AC"}]},{value:"office",label:"Office",types:[{value:"office",label:"Office",color:"#D7D7D7"},{value:"conference room",label:"Conference room",color:"#9BB4B9"},{value:"meeting room",label:"Meeting room",color:"#FFDFBF"},{value:"lobby",label:"Lobby",color:"#F3C848"},{value:"toilet",label:"Toilet",color:"#DCDCE6"},{value:"admin",label:"Admin",color:"#B6CFF3"},{value:"server room",label:"Server room",color:"#F0F0F0"},{value:"reception",label:"Reception",color:"#D9C177"},{value:"presentation room",label:"Presentation room",color:"#E6A1A1"},{value:"garage",label:"Garage",color:"#F5F5EB"},{value:"parking",label:"Parking",color:"#F5F5EB"},{value:"ceo",label:"Ceo",color:"#5FBF9F"},{value:"board room",label:"Board Room",color:"#98D9CE"},{value:"storage",label:"Storage",color:"#CCB799"},{value:"kitchen",label:"Kitchen",color:"#CEEDF3"},{value:"utility",label:"Utility",color:"#999999"},{value:"lunch area",label:"Lunch area",color:"#E6AC73"},{value:"hallway",label:"Hallway",color:"#FFE699"},{value:"patio",label:"Patio",color:"#F3E7E7"},{value:"medical",label:"Medical",color:"#BFE7DA"}]},{value:"school",label:"School",types:[{value:"staff",label:"Staff",color:"#98D9CE"},{value:"hallway",label:"Hallway",color:"#FFE699"},{value:"toilet",label:"Toilet",color:"#DCDCE6"},{value:"wardrobe",label:"Wardrobe",color:"#E6CFE0"},{value:"utility",label:"Utility",color:"#999999"},{value:"lab",label:"Lab",color:"#8DAED9"},{value:"playground",label:"Playground",color:"#F8FFA6"},{value:"storage",label:"Storage",color:"#CCB799"},{value:"lockers",label:"Lockers",color:"#E0BF8F"},{value:"gym",label:"Gym",color:"#C2DBF3"},{value:"entrance",label:"Entrance",color:"#E6CC7E"},{value:"office",label:"Office",color:"#D7D7D7"},{value:"cafetaria",label:"Cafetaria",color:"#E6AC73"},{value:"library",label:"Library",color:"#FCDBB6"}]},{value:"hospitality",label:"Hospitality",types:[{value:"restaurant",label:"Restaurant",color:"#E6AC73"},{value:"bar",label:"Bar",color:"#E68A5C"},{value:"cafe",label:"Cafe",color:"#FFAA7F"},{value:"service",label:"Service",color:"#FFEFBF"},{value:"foyer",label:"Foyer",color:"#FFD966"},{value:"hallway",label:"Hallway",color:"#FFE699"},{value:"reception",label:"Reception",color:"#D9C177"},{value:"wardrobe",label:"Wardrobe",color:"#E6CFE0"},{value:"toilet",label:"Toilet",color:"#DCDCE6"},{value:"bathroom",label:"Bathroom",color:"#C3C3DA"},{value:"bedroom",label:"Bedroom",color:"#FFD1CC"},{value:"master-bedroom",label:"Master Bedroom",color:"#EBA5A5"},{value:"dorm",label:"Dorm",color:"#E6C6C3"},{value:"kitchen",label:"Kitchen",color:"#CEEDF3"},{value:"dishwashing",label:"Dishwashing",color:"#D1E6ED"},{value:"fridge",label:"Fridge",color:"#C3DCF5"},{value:"staff",label:"Staff",color:"#98D9CE"},{value:"storage",label:"Storage",color:"#CCB799"},{value:"terrace",label:"Terrace",color:"#BFBFB6"},{value:"patio",label:"Patio",color:"#F3E7E7"},{value:"parking",label:"Parking",color:"#F5F5EB"}]},{value:"party-events",label:"Party / Events",types:[{value:"reception",label:"Reception",color:"#D9C177"},{value:"restaurant",label:"Restaurant",color:"#E6AC73"},{value:"bar",label:"Bar",color:"#E68A5C"},{value:"presentation-room",label:"Presentation room",color:"#E6A1A1"},{value:"gift-room",label:"Gift room",color:"#F3E0DA"},{value:"wardrobe",label:"Wardrobe",color:"#E6CFE0"},{value:"storage",label:"Storage",color:"#CCB799"},{value:"toilet",label:"Toilet",color:"#DCDCE6"},{value:"dance-floor",label:"Dance floor",color:"#C7BCE2"},{value:"entrance",label:"Entrance",color:"#E6CC7E"},{value:"closet",label:"Closet",color:"#E0BF8F"},{value:"kitchen",label:"Kitchen",color:"#CEEDF3"},{value:"parking",label:"Parking",color:"#F5F5EB"},{value:"ceremony",label:"Ceremony",color:"#E6B6AC"},{value:"stage",label:"Stage",color:"#FFEAE6"}]},{value:"outdoor",label:"Outdoor",types:[{value:"garden",label:"Garden",color:"#CEF3D4"},{value:"street",label:"Street",color:"#CCCCC2"},{value:"path",label:"Path",color:"#99998A"},{value:"playground",label:"Playground",color:"#F8FFA6"},{value:"parking",label:"Parking",color:"#F5F5EB"},{value:"porch",label:"Porch",color:"#D2D9AE"},{value:"shrubs",label:"Shrubs",color:"#AED9B5"},{value:"border",label:"Border",color:"#74A67C"},{value:"patio",label:"Patio",color:"#F3E7E7"},{value:"lawn",label:"Lawn",color:"#D9D9C3"},{value:"paving",label:"Paving",color:"#A6A69E"},{value:"water",label:"Water",color:"#95D8E6"},{value:"seating-area",label:"Seating area",color:"#FFDFBF"},{value:"shed",label:"Shed",color:"#CC7F70"},{value:"building",label:"Building",color:"#E1E8E6"}]},{value:"gym",label:"Gym",types:[{value:"cardio",label:"Cardio",color:"#FFB9B9"},{value:"strength",label:"Strength",color:"#CCFFB9"},{value:"functional",label:"Functional",color:"#FAA072"},{value:"gym",label:"Gym",color:"#5F9EA0"},{value:"stretch",label:"Stretch",color:"#EED5B7"}]}],CATEGORY_BY_VALUE=new Map(ROOM_CATEGORIES.map(i=>[i.value,i]));function getCategory(i){if(i)return CATEGORY_BY_VALUE.get(i)}function getRoomType(i,e){const t=getCategory(i);if(!(!t||!e))return t.types.find(n=>n.value===e)}function getRoomTypeLabel(i,e){var t;return((t=getRoomType(i,e))==null?void 0:t.label)||""}function getRoomTypeColor(i,e){var t;return(t=getRoomType(i,e))==null?void 0:t.color}function getAreaKind(i,e){var s;if(!i||!e||!e.getIn)return"Area";let t=!1,n=!1;return(s=i.get("vertices"))==null||s.forEach(o=>{var l;const a=e.getIn(["vertices",o]);(l=a==null?void 0:a.get("lines"))==null||l.forEach(c=>{const u=e.getIn(["lines",c]),h=u==null?void 0:u.get("type");h==="wall"?t=!0:h==="surface"&&(n=!0)})}),!t&&n?"Surface":t?"Room":"Area"}function deriveAreaLabel(i,e,t){if(!i)return(t==null?void 0:t.defaultLabel)??"Area";const n=i.getIn?i.getIn(["properties","customName"]):void 0,s=i.getIn?i.getIn(["properties","roomCategory"]):void 0,o=i.getIn?i.getIn(["properties","roomType"]):void 0,a=getRoomTypeLabel(s,o);if(n)return n;if(a)return a;const l=getAreaKind(i,e);return l!=="Area"?l:(t==null?void 0:t.defaultLabel)??"Area"}var propTypes={exports:{}},reactIs={exports:{}},reactIs_production_min={};/** @license React v16.13.1
47
47
  * react-is.production.min.js
48
48
  *
@@ -67,7 +67,7 @@ Valid keys: `+JSON.stringify(Object.keys(F),null," "));var oe=Fe(Z,re,Me,j,ie+"
67
67
  `+c+` |
68
68
  `+o.line+" | "+u+`
69
69
  `+c+" | "+peg$padEnd("",s.column-1," ")+peg$padEnd("",d,"^")}else e+=`
70
- at `+a}return e},peg$SyntaxError.buildMessage=function(i,e){var t={literal:function(u){return'"'+s(u.text)+'"'},class:function(u){var h=u.parts.map(function(d){return Array.isArray(d)?o(d[0])+"-"+o(d[1]):o(d)});return"["+(u.inverted?"^":"")+h.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(u){return u.description}};function n(u){return u.charCodeAt(0).toString(16).toUpperCase()}function s(u){return u.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(h){return"\\x0"+n(h)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(h){return"\\x"+n(h)})}function o(u){return u.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(h){return"\\x0"+n(h)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(h){return"\\x"+n(h)})}function a(u){return t[u.type](u)}function l(u){var h=u.map(a),d,p;if(h.sort(),h.length>0){for(d=1,p=1;d<h.length;d++)h[d-1]!==h[d]&&(h[p]=h[d],p++);h.length=p}switch(h.length){case 1:return h[0];case 2:return h[0]+" or "+h[1];default:return h.slice(0,-1).join(", ")+", or "+h[h.length-1]}}function c(u){return u?'"'+s(u)+'"':"end of input"}return"Expected "+l(i)+" but "+c(e)+" found."};const MODE_IDLE="idle",MODE_PANNING="panning",MODE_ZOOMING="zooming",TOOL_AUTO="auto",TOOL_NONE="none",TOOL_PAN="pan",TOOL_ZOOM_IN="zoom-in",TOOL_ZOOM_OUT="zoom-out",POSITION_NONE="none",POSITION_TOP="top",POSITION_RIGHT="right",POSITION_BOTTOM="bottom",POSITION_LEFT="left",ACTION_ZOOM="zoom",ACTION_PAN="pan",ALIGN_CENTER="center",ALIGN_LEFT="left",ALIGN_RIGHT="right",ALIGN_TOP="top",ALIGN_BOTTOM="bottom",ALIGN_COVER="cover";function ownKeys$6(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,n)}return t}function _objectSpread$6(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ownKeys$6(Object(t),!0).forEach(function(n){_defineProperty$6(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ownKeys$6(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function _defineProperty$6(i,e,t){return(e=_toPropertyKey$6(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function _toPropertyKey$6(i){var e=_toPrimitive$6(i,"string");return typeof e=="symbol"?e:e+""}function _toPrimitive$6(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}const VERSION=3,DEFAULT_MODE=MODE_IDLE;function getDefaultValue(i,e,t,n,s,o){let a=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return set({},_objectSpread$6(_objectSpread$6({},identity()),{},{version:VERSION,mode:DEFAULT_MODE,focus:!1,pinchPointDistance:null,prePinchMode:null,viewerWidth:i,viewerHeight:e,SVGMinX:t,SVGMinY:n,SVGWidth:s,SVGHeight:o,scaleFactorMin:a,scaleFactorMax:l,startX:null,startY:null,endX:null,endY:null,miniatureOpen:!0,lastAction:null}))}function set(i,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;return i=Object.assign({},i,e,{lastAction:t}),Object.freeze(i)}function isValueValid(i){return i!==null&&typeof i=="object"&&i.hasOwnProperty("version")&&i.version===VERSION}function getSVGPoint(i,e,t){let n=fromObject(i),s=inverse(n);return applyToPoint(s,{x:e,y:t})}function decompose(i){let e=fromObject(i);return{scaleFactor:e.a,translationX:e.e,translationY:e.f}}function setFocus(i,e){return set(i,{focus:e})}function setViewerSize(i,e,t){return set(i,{viewerWidth:e,viewerHeight:t})}function setSVGViewBox(i,e,t,n,s){return set(i,{SVGMinX:e,SVGMinY:t,SVGWidth:n,SVGHeight:s})}function setZoomLevels(i,e,t){return set(i,{scaleFactorMin:e,scaleFactorMax:t})}function setPointOnViewerCenter(i,e,t,n){let{viewerWidth:s,viewerHeight:o}=i,a=transform(translate(-e+s/2,-t+o/2),translate(e,t),scale(n,n),translate(-e,-t));return set(i,_objectSpread$6({mode:MODE_IDLE},a))}function reset(i){return set(i,_objectSpread$6({mode:MODE_IDLE},identity()))}function resetMode(i){return set(i,{mode:DEFAULT_MODE,startX:null,startY:null,endX:null,endY:null})}class ViewerEvent{constructor(e,t,n){this.originalEvent=e,this.value=t,this.SVGViewer=n}get scaleFactor(){return this._cacheDecomposedValue=this._cacheDecomposedValue||decompose(this.value),this._cacheDecomposedValue.scaleFactor}get translationX(){return this._cacheDecomposedValue=this._cacheDecomposedValue||decompose(this.value),this._cacheDecomposedValue.translationX}get translationY(){return this._cacheDecomposedValue=this._cacheDecomposedValue||decompose(this.value),this._cacheDecomposedValue.translationY}preventDefault(){this.originalEvent.preventDefault()}stopPropagation(){this.originalEvent.stopPropagation()}}function ownKeys$5(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,n)}return t}function _objectSpread$5(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ownKeys$5(Object(t),!0).forEach(function(n){_defineProperty$5(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ownKeys$5(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function _defineProperty$5(i,e,t){return(e=_toPropertyKey$5(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function _toPropertyKey$5(i){var e=_toPrimitive$5(i,"string");return typeof e=="symbol"?e:e+""}function _toPrimitive$5(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function pan(i,e,t){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:void 0,s=transform(fromObject(i),translate(e,t));if(n){let[{x:o,y:a},{x:l,y:c}]=applyToPoints(s,[{x:i.SVGMinX+n,y:i.SVGMinY+n},{x:i.SVGMinX+i.SVGWidth-n,y:i.SVGMinY+i.SVGHeight-n}]),u=0;i.viewerWidth-o<0?u=i.viewerWidth-o:l<0&&(u=-l);let h=0;i.viewerHeight-a<0?h=i.viewerHeight-a:c<0&&(h=-c),s=transform(translate(u,h),s)}return set(i,_objectSpread$5({mode:MODE_IDLE},s),ACTION_PAN)}function startPanning(i,e,t){return set(i,{mode:MODE_PANNING,startX:e,startY:t,endX:e,endY:t},ACTION_PAN)}function updatePanning(i,e,t,n){if(i.mode!==MODE_PANNING)throw new Error("update pan not allowed in this mode "+i.mode);let{endX:s,endY:o}=i,a=getSVGPoint(i,s,o),l=getSVGPoint(i,e,t),c=l.x-a.x,u=l.y-a.y,h=pan(i,c,u,n);return set(h,{mode:MODE_PANNING,endX:e,endY:t},ACTION_PAN)}function stopPanning(i){return set(i,{mode:MODE_IDLE,startX:null,startY:null,endX:null,endY:null},ACTION_PAN)}function autoPanIfNeeded(i,e,t){let n=0,s=0;return t<=20&&(s=2),i.viewerWidth-e<=20&&(n=-2),i.viewerHeight-t<=20&&(s=-2),e<=20&&(n=2),n=n/i.d,s=s/i.d,n===0&&s===0?i:pan(i,n,s)}function calculateBox(i,e){if(i.x<=e.x&&i.y<=e.y)return{x:i.x,y:i.y,width:e.x-i.x,height:e.y-i.y};if(i.x>=e.x&&i.y<=e.y)return{x:e.x,y:i.y,width:i.x-e.x,height:e.y-i.y};if(i.x>=e.x&&i.y>=e.y)return{x:e.x,y:e.y,width:i.x-e.x,height:i.y-e.y};if(i.x<=e.x&&i.y>=e.y)return{x:i.x,y:e.y,width:e.x-i.x,height:i.y-e.y}}function ownKeys$4(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,n)}return t}function _objectSpread$4(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ownKeys$4(Object(t),!0).forEach(function(n){_defineProperty$4(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ownKeys$4(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function _defineProperty$4(i,e,t){return(e=_toPropertyKey$4(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function _toPropertyKey$4(i){var e=_toPrimitive$4(i,"string");return typeof e=="symbol"?e:e+""}function _toPrimitive$4(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function isZoomLevelGoingOutOfBounds(i,e){const{scaleFactor:t}=decompose(i),n=i.scaleFactorMin&&t*e<i.scaleFactorMin,s=i.scaleFactorMax&&t*e>i.scaleFactorMax;return n&&e<1||s&&e>1}function limitZoomLevel(i,e){let t=e.a;return i.scaleFactorMin!=null&&(t=Math.max(t,i.scaleFactorMin)),i.scaleFactorMax!=null&&(t=Math.min(t,i.scaleFactorMax)),set(e,{a:t,d:t})}function zoom(i,e,t,n){if(isZoomLevelGoingOutOfBounds(i,n))return i;const s=transform(fromObject(i),translate(e,t),scale(n,n),translate(-e,-t));return set(i,_objectSpread$4(_objectSpread$4({mode:MODE_IDLE},s),{},{startX:null,startY:null,endX:null,endY:null}),ACTION_ZOOM)}function fitSelection(i,e,t,n,s){let{viewerWidth:o,viewerHeight:a}=i,l=o/n,c=a/s,u=Math.min(l,c);const h=transform(scale(u,u),translate(-e,-t));return isZoomLevelGoingOutOfBounds(i,u/i.d)?set(i,{mode:MODE_IDLE,startX:null,startY:null,endX:null,endY:null}):set(i,_objectSpread$4(_objectSpread$4({mode:MODE_IDLE},limitZoomLevel(i,h)),{},{startX:null,startY:null,endX:null,endY:null}),ACTION_ZOOM)}function fitToViewer(i){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ALIGN_LEFT,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ALIGN_TOP,{viewerWidth:n,viewerHeight:s,SVGMinX:o,SVGMinY:a,SVGWidth:l,SVGHeight:c}=i,u=n/l,h=s/c,d=Math.min(u,h),p=scale(d,d),f=-o*u,g=-a*h;if(u<h){let y=s-u*c;switch(t){case ALIGN_TOP:g=-a*d;break;case ALIGN_CENTER:g=Math.round(y/2)-a*d;break;case ALIGN_BOTTOM:g=y-a*d;break;case ALIGN_COVER:p=scale(h,h);let E=n-h*l;f=o+Math.round(E/2);break}}else{let y=n-h*l;switch(e){case ALIGN_LEFT:f=-o*d;break;case ALIGN_CENTER:f=Math.round(y/2)-o*d;break;case ALIGN_RIGHT:f=y-o*d;break;case ALIGN_COVER:p=scale(u,u);let E=s-u*c;g=a+Math.round(E/2);break}}const _=translate(f,g),x=transform(_,p);return isZoomLevelGoingOutOfBounds(i,d/i.d)?set(i,{mode:MODE_IDLE,startX:null,startY:null,endX:null,endY:null}):set(i,_objectSpread$4(_objectSpread$4({mode:MODE_IDLE},limitZoomLevel(i,x)),{},{startX:null,startY:null,endX:null,endY:null}),ACTION_ZOOM)}function zoomOnViewerCenter(i,e){let{viewerWidth:t,viewerHeight:n}=i,s=getSVGPoint(i,t/2,n/2);return zoom(i,s.x,s.y,e)}function startZooming(i,e,t){return set(i,{mode:MODE_ZOOMING,startX:e,startY:t,endX:e,endY:t})}function updateZooming(i,e,t){if(i.mode!==MODE_ZOOMING)throw new Error("update selection not allowed in this mode "+i.mode);return set(i,{endX:e,endY:t})}function stopZooming(i,e,t,n){let{startX:o,startY:a}=i,l=getSVGPoint(i,o,a),c=getSVGPoint(i,e,t);if(Math.abs(o-e)>7&&Math.abs(a-t)>7){let u=calculateBox(l,c);return fitSelection(i,u.x,u.y,u.width,u.height)}else{let u=getSVGPoint(i,e,t);return zoom(i,u.x,u.y,n)}}function mapRange(i,e,t,n,s){return n+(s-n)*(i-e)/(t-e)}function getMousePosition(i,e){let{left:t,top:n}=e.getBoundingClientRect(),s=i.clientX-Math.round(t),o=i.clientY-Math.round(n);return{x:s,y:o}}function onMouseDown$1(i,e,t,n,s){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:a,y:l}=o||getMousePosition(i,e);let c=n;switch(t){case TOOL_ZOOM_OUT:let u=getSVGPoint(n,a,l);c=zoom(n,u.x,u.y,1/s.scaleFactor);break;case TOOL_ZOOM_IN:c=startZooming(n,a,l);break;case TOOL_AUTO:case TOOL_PAN:c=startPanning(n,a,l);break;default:return n}return i.preventDefault(),c}function onMouseMove$1(i,e,t,n,s){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:a,y:l}=o||getMousePosition(i,e);let c=i.buttons===0,u=n;switch(t){case TOOL_ZOOM_IN:n.mode===MODE_ZOOMING&&(u=c?stopZooming(n,a,l,s.scaleFactor):updateZooming(n,a,l));break;case TOOL_AUTO:case TOOL_PAN:n.mode===MODE_PANNING&&(u=c?stopPanning(n):updatePanning(n,a,l,s.preventPanOutside?20:void 0));break;default:return n}return i.preventDefault(),u}function onMouseUp(i,e,t,n,s){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:a,y:l}=o||getMousePosition(i,e);let c=n;switch(t){case TOOL_ZOOM_OUT:n.mode===MODE_ZOOMING&&(c=stopZooming(n,a,l,1/s.scaleFactor));break;case TOOL_ZOOM_IN:n.mode===MODE_ZOOMING&&(c=stopZooming(n,a,l,s.scaleFactor));break;case TOOL_AUTO:case TOOL_PAN:n.mode===MODE_PANNING&&(c=stopPanning(n));break;default:return n}return i.preventDefault(),c}function onDoubleClick(i,e,t,n,s){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:a,y:l}=o||getMousePosition(i,e);let c=n;if(t===TOOL_AUTO&&!s.disableDoubleClickZoomWithToolAuto){const{modifierKeys:u=[]}=s;let h=getSVGPoint(n,a,l),d=(g,_)=>g||i.getModifierState(_),f=u.reduce(d,!1)?1/s.scaleFactor:s.scaleFactor;c=zoom(n,h.x,h.y,f)}return i.preventDefault(),c}function onWheel(i,e,t,n,s){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:a,y:l}=o||getMousePosition(i,e);if(!s.detectWheel)return n;let c=Math.max(-1,Math.min(1,i.deltaY)),u=mapRange(c,-1,1,s.scaleFactorOnWheel,1/s.scaleFactorOnWheel),h=getSVGPoint(n,a,l),d=zoom(n,h.x,h.y,u);return i.preventDefault(),d}function onMouseEnterOrLeave(i,e,t,n,s){let o=setFocus(n,i.type==="mouseenter");return i.preventDefault(),o}function onInterval(i,e,t,n,s){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null,{x:a,y:l}=o;return!([TOOL_NONE,TOOL_AUTO].indexOf(t)>=0)||!s.detectAutoPan||!n.focus?n:autoPanIfNeeded(n,a,l)}class ViewerMouseEvent extends ViewerEvent{get point(){if(!this._cachePoint){const{originalEvent:e,SVGViewer:t,value:n}=this,s=getMousePosition(e,t);this._cachePoint=getSVGPoint(n,s.x,s.y)}return this._cachePoint}get x(){return this.point.x}get y(){return this.point.y}}function ownKeys$3(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,n)}return t}function _objectSpread$3(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ownKeys$3(Object(t),!0).forEach(function(n){_defineProperty$3(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ownKeys$3(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function _defineProperty$3(i,e,t){return(e=_toPropertyKey$3(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function _toPropertyKey$3(i){var e=_toPrimitive$3(i,"string");return typeof e=="symbol"?e:e+""}function _toPrimitive$3(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class ViewerTouchEvent extends ViewerEvent{get points(){return this._cachePoints||(this._cachePoints=ViewerTouchEvent.touchesToPoints(this.originalEvent.touches,this.SVGViewer,this.value)),this._cachePoints}get changedPoints(){return this._cacheChangedPoints||(this._cacheChangedPoints=ViewerTouchEvent.touchesToPoints(this.originalEvent.changedTouches,this.SVGViewer,this.value)),this._cacheChangedPoints}static touchesToPoints(e,t,n){let s=[];for(let o=0;o<e.length;o++){let a=e[o],l=t.getBoundingClientRect(),c=a.clientX-Math.round(l.left),u=a.clientY-Math.round(l.top),h=getSVGPoint(n,c,u);s.push(_objectSpread$3(_objectSpread$3({},h),{},{identifier:a.identifier}))}return s}}function eventFactory(i,e,t){let n=i.type;switch(n){case"mousemove":case"mouseup":case"mousedown":case"click":case"dblclick":return new ViewerMouseEvent(i,e,t);case"touchstart":case"touchmove":case"touchend":case"touchcancel":return new ViewerTouchEvent(i,e,t);default:throw new Error(`${n} not supported`)}}function parseViewBox(i){return i.split(/[ ,]/).filter(Boolean).map(Number)}function ownKeys$2(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,n)}return t}function _objectSpread$2(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ownKeys$2(Object(t),!0).forEach(function(n){_defineProperty$2(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ownKeys$2(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function _defineProperty$2(i,e,t){return(e=_toPropertyKey$2(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function _toPropertyKey$2(i){var e=_toPrimitive$2(i,"string");return typeof e=="symbol"?e:e+""}function _toPrimitive$2(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function getTouchPosition(i,e){let{left:t,top:n}=e.getBoundingClientRect(),s=i.clientX-Math.round(t),o=i.clientY-Math.round(n);return{x:s,y:o}}function onTouchStart$1(i,e,t,n,s){if(isMultiTouch(i,s))return onMultiTouch(i,e,t,n);if(i.touches.length!==1){if([MODE_PANNING,MODE_ZOOMING].indexOf(n.mode)>=0)return resetMode(n);if([MODE_IDLE].indexOf(n.mode)>=0)return n}return onSingleTouch(i,e,t,n,s,onMouseDown$1)}function onTouchMove$1(i,e,t,n,s){return isMultiTouch(i,s)?onMultiTouch(i,e,t,n):[MODE_PANNING,MODE_ZOOMING].indexOf(n.mode)>=0?onSingleTouch(i,e,t,n,s,onMouseMove$1):n}function onTouchEnd(i,e,t,n,s){if(!([MODE_PANNING,MODE_ZOOMING].indexOf(n.mode)>=0))return n;let o=shouldResetPinchPointDistance(i,n,s)?set(n,{pinchPointDistance:null}):n;return i.touches.length>0?o:onSingleTouch(i,e,t,o,s,onMouseUp)}function onTouchCancel(i,e,t,n,s){return i.stopPropagation(),i.preventDefault(),resetMode(n)}function hasPinchPointDistance(i){return typeof i.pinchPointDistance=="number"}function shouldResetPinchPointDistance(i,e,t){return t.detectPinchGesture&&hasPinchPointDistance(e)&&i.touches.length<2}function isMultiTouch(i,e){return e.detectPinchGesture&&i.touches.length>1}function onSingleTouch(i,e,t,n,s,o){let a=i.touches.length===0?set(n,{mode:n.prePinchMode?MODE_IDLE:n.mode,prePinchMode:null}):n,l=i.touches.length>0?i.touches[0]:i.changedTouches[0],c=getTouchPosition(l,e);switch(t){case TOOL_ZOOM_OUT:case TOOL_ZOOM_IN:case TOOL_AUTO:case TOOL_PAN:return i.stopPropagation(),i.preventDefault(),o(i,e,t,a,s,c);default:return a}}function onMultiTouch(i,e,t,n,s){const{left:o,top:a}=e.getBoundingClientRect(),l=i.touches[0].clientX-Math.round(o),c=i.touches[0].clientY-Math.round(a),u=i.touches[1].clientX-Math.round(o),h=i.touches[1].clientY-Math.round(a),d=Math.sqrt(Math.pow(u-l,2)+Math.pow(h-c,2)),p=hasPinchPointDistance(n)?n.pinchPointDistance:d,f=getSVGPoint(n,(l+u)/2,(c+h)/2);let g=d/p;if(isZoomLevelGoingOutOfBounds(n,g))return n;i.cancelable&&i.preventDefault();let _=transform(fromObject(n),translate(f.x,f.y),scale(g,g),translate(-f.x,-f.y));return set(n,set(_objectSpread$2(_objectSpread$2({mode:MODE_ZOOMING},limitZoomLevel(n,_)),{},{startX:null,startY:null,endX:null,endY:null,prePinchMode:n.prePinchMode?n.prePinchMode:n.mode,pinchPointDistance:d})))}function openMiniature(i){return set(i,{miniatureOpen:!0})}function closeMiniature(i){return set(i,{miniatureOpen:!1})}let needPrefix=i=>["zoom-in","zoom-out","grab","grabbing"].indexOf(i)>-1,userAgent=()=>navigator.userAgent.toLowerCase(),isFirefox=()=>userAgent().indexOf("firefox")>-1,isWebkit=()=>userAgent().indexOf("webkit")>-1;function cursorPolyfill(i){if(!needPrefix(i))return i;if(isFirefox())return`-moz-${i}`;if(isWebkit())return`-webkit-${i}`}function getDisplayName(i){return i.displayName||i.name||"Component"}function _extends$3(){return _extends$3=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},_extends$3.apply(null,arguments)}let uid=1;const nextUID=()=>`uid${uid++}`;function RandomUID(i){class e extends React.Component{constructor(n){super(n),this.state={uid:nextUID()}}render(){return React.createElement(i,_extends$3({_uid:this.state.uid},this.props))}}return e.displayName=`RandomUID(${getDisplayName(i)})`,e}const prefixID$1="react-svg-pan-zoom_border_gradient";function BorderGradient(i){let{direction:e,width:t,height:n,_uid:s}=i,o;switch(e){case POSITION_TOP:o=`translate(${t}, 0) rotate(90)`;break;case POSITION_RIGHT:o=`translate(${t}, ${n}) rotate(180)`;break;case POSITION_BOTTOM:o=`translate(0, ${n}) rotate(270)`;break;case POSITION_LEFT:default:o=" ";break}let a=`${prefixID$1}_gradient_${s}`,l=`${prefixID$1}_mask_${s}`;return React.createElement("g",null,React.createElement("defs",null,React.createElement("linearGradient",{id:a,x1:"0%",y1:"0%",x2:"100%",y2:"0%",spreadMethod:"pad"},React.createElement("stop",{offset:"0%",stopColor:"#fff",stopOpacity:"0.8"}),React.createElement("stop",{offset:"100%",stopColor:"#000",stopOpacity:"0.5"})),React.createElement("mask",{id:l,x:"0",y:"0",width:"20",height:Math.max(t,n)},React.createElement("rect",{x:"0",y:"0",width:"20",height:Math.max(t,n),style:{stroke:"none",fill:`url(#${a})`}}))),React.createElement("rect",{x:"0",y:"0",width:"20",height:Math.max(t,n),style:{stroke:"none",fill:"#000",mask:`url(#${l})`},transform:o}))}BorderGradient.propTypes={direction:PropTypes.oneOf([POSITION_TOP,POSITION_RIGHT,POSITION_BOTTOM,POSITION_LEFT]).isRequired,width:PropTypes.number.isRequired,height:PropTypes.number.isRequired};const BorderGradient$1=RandomUID(BorderGradient);function Selection(i){let{startX:e,startY:t,endX:n,endY:s}=i;if(!e||!t||!n||!s)return null;let o=calculateBox({x:e,y:t},{x:n,y:s});return React.createElement("rect",{stroke:"#969FFF",strokeOpacity:.7,fill:"#F3F4FF",fillOpacity:.7,x:o.x,y:o.y,width:o.width,height:o.height,style:{pointerEvents:"none"}})}Selection.propTypes={startX:PropTypes.number,startY:PropTypes.number,endX:PropTypes.number,endY:PropTypes.number};function IconCursor(){return React.createElement("svg",{width:24,height:24,stroke:"currentColor"},React.createElement("path",{d:"M10.07,14.27C10.57,14.03 11.16,14.25 11.4,14.75L13.7,19.74L15.5,18.89L13.19,13.91C12.95,13.41 13.17,12.81 13.67,12.58L13.95,12.5L16.25,12.05L8,5.12V15.9L9.82,14.43L10.07,14.27M13.64,21.97C13.14,22.21 12.54,22 12.31,21.5L10.13,16.76L7.62,18.78C7.45,18.92 7.24,19 7,19A1,1 0 0,1 6,18V3A1,1 0 0,1 7,2C7.24,2 7.47,2.09 7.64,2.23L7.65,2.22L19.14,11.86C19.57,12.22 19.62,12.85 19.27,13.27C19.12,13.45 18.91,13.57 18.7,13.61L15.54,14.23L17.74,18.96C18,19.46 17.76,20.05 17.26,20.28L13.64,21.97Z"}))}function IconPan(){return React.createElement("svg",{width:24,height:24,stroke:"currentColor"},React.createElement("path",{d:"M13,6V11H18V7.75L22.25,12L18,16.25V13H13V18H16.25L12,22.25L7.75,18H11V13H6V16.25L1.75,12L6,7.75V11H11V6H7.75L12,1.75L16.25,6H13Z"}))}function IconZoomIn(){return React.createElement("svg",{width:24,height:24,stroke:"currentColor"},React.createElement("g",null,React.createElement("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"}),React.createElement("path",{d:"M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z"})))}function IconZoomOut(){return React.createElement("svg",{width:24,height:24,stroke:"currentColor"},React.createElement("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7z"}))}function IconFit(){return React.createElement("svg",{width:24,height:24,stroke:"currentColor"},React.createElement("path",{d:"M15 3l2.3 2.3-2.89 2.87 1.42 1.42L18.7 6.7 21 9V3zM3 9l2.3-2.3 2.87 2.89 1.42-1.42L6.7 5.3 9 3H3zm6 12l-2.3-2.3 2.89-2.87-1.42-1.42L5.3 17.3 3 15v6zm12-6l-2.3 2.3-2.87-2.89-1.42 1.42 2.89 2.87L15 21h6z"}))}let ToolbarButton$1=class extends React.Component{constructor(e){super(e),this.state={hover:!1}}change(e){switch(e.preventDefault(),e.stopPropagation(),e.type){case"mouseenter":case"touchstart":this.setState({hover:!0});break;case"mouseleave":case"touchend":case"touchcancel":this.setState({hover:!1});break}}render(){let e={display:"block",width:"24px",height:"24px",margin:[POSITION_TOP,POSITION_BOTTOM].indexOf(this.props.toolbarPosition)>=0?"2px 1px":"1px 2px",color:this.props.active||this.state.hover?this.props.activeColor:"#FFF",transition:"color 200ms ease",background:"none",padding:"0px",border:"0px",outline:"0px",cursor:"pointer"};return React.createElement("button",{onMouseEnter:t=>this.change(t),onMouseLeave:t=>this.change(t),onTouchStart:t=>{this.change(t),this.props.onClick(t)},onTouchEnd:t=>this.change(t),onTouchCancel:t=>this.change(t),onClick:this.props.onClick,style:e,title:this.props.title,name:this.props.name,type:"button"},this.props.children)}};ToolbarButton$1.propTypes={title:PropTypes.string.isRequired,name:PropTypes.string.isRequired,toolbarPosition:PropTypes.string.isRequired,activeColor:PropTypes.string.isRequired,onClick:PropTypes.func.isRequired,active:PropTypes.bool.isRequired};const DEFAULT_ACTIVE_TOOL_COLOR="#1CA6FC";function Toolbar$1(i){let{tool:e,value:t,onChangeValue:n,onChangeTool:s,activeToolColor:o=DEFAULT_ACTIVE_TOOL_COLOR,position:a=POSITION_RIGHT,SVGAlignX:l=ALIGN_LEFT,SVGAlignY:c=ALIGN_TOP}=i,u=(f,g)=>{s(g),f.stopPropagation(),f.preventDefault()},h=f=>{n(fitToViewer(t,l,c)),f.stopPropagation(),f.preventDefault()},d=[POSITION_TOP,POSITION_BOTTOM].indexOf(a)>=0,p={position:"absolute",transform:[POSITION_TOP,POSITION_BOTTOM].indexOf(a)>=0?"translate(-50%, 0px)":"none",top:[POSITION_LEFT,POSITION_RIGHT,POSITION_TOP].indexOf(a)>=0?"5px":"unset",left:[POSITION_TOP,POSITION_BOTTOM].indexOf(a)>=0?"50%":POSITION_LEFT===a?"5px":"unset",right:[POSITION_RIGHT].indexOf(a)>=0?"5px":"unset",bottom:[POSITION_BOTTOM].indexOf(a)>=0?"5px":"unset",backgroundColor:"rgba(19, 20, 22, 0.90)",borderRadius:"2px",display:"flex",flexDirection:d?"row":"column",padding:d?"1px 2px":"2px 1px"};return React.createElement("div",{style:p,role:"toolbar"},React.createElement(ToolbarButton$1,{toolbarPosition:a,active:e===TOOL_NONE,activeColor:o,name:"unselect-tools",title:"Selection",onClick:f=>u(f,TOOL_NONE)},React.createElement(IconCursor,null)),React.createElement(ToolbarButton$1,{toolbarPosition:a,active:e===TOOL_PAN,activeColor:o,name:"select-tool-pan",title:"Pan",onClick:f=>u(f,TOOL_PAN)},React.createElement(IconPan,null)),React.createElement(ToolbarButton$1,{toolbarPosition:a,active:e===TOOL_ZOOM_IN,activeColor:o,name:"select-tool-zoom-in",title:"Zoom in",onClick:f=>u(f,TOOL_ZOOM_IN)},React.createElement(IconZoomIn,null)),React.createElement(ToolbarButton$1,{toolbarPosition:a,active:e===TOOL_ZOOM_OUT,activeColor:o,name:"select-tool-zoom-out",title:"Zoom out",onClick:f=>u(f,TOOL_ZOOM_OUT)},React.createElement(IconZoomOut,null)),React.createElement(ToolbarButton$1,{toolbarPosition:a,active:!1,activeColor:o,name:"fit-to-viewer",title:"Fit to viewer",onClick:f=>h(f)},React.createElement(IconFit,null)))}Toolbar$1.propTypes={tool:PropTypes.string.isRequired,onChangeTool:PropTypes.func.isRequired,value:PropTypes.object.isRequired,onChangeValue:PropTypes.func.isRequired,position:PropTypes.oneOf([POSITION_TOP,POSITION_RIGHT,POSITION_BOTTOM,POSITION_LEFT]),SVGAlignX:PropTypes.oneOf([ALIGN_CENTER,ALIGN_LEFT,ALIGN_RIGHT]),SVGAlignY:PropTypes.oneOf([ALIGN_CENTER,ALIGN_TOP,ALIGN_BOTTOM]),activeToolColor:PropTypes.string};function isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints}function IconArrow(i){let{open:e,position:t}=i,n=0;switch(t){case POSITION_LEFT:n=e?"rotate(225, 12, 13)":"rotate(45, 12, 13)";break;case POSITION_RIGHT:n=n=e?"rotate(135, 12, 13)":"rotate(-45, 12, 13)";break}return React.createElement("svg",{width:24,height:24,stroke:"currentColor"},React.createElement("g",{transform:n},React.createElement("path",{fill:"#000000",d:"M7.41,15.41L12,10.83L16.59,15.41L18,14L12,8L6,14L7.41,15.41Z"})))}IconArrow.propTypes={open:PropTypes.bool.isRequired,position:PropTypes.oneOf([POSITION_RIGHT,POSITION_LEFT]).isRequired};function MiniatureToggleButton(i){let{value:e,onChangeValue:t,position:n}=i,s={width:"24px",height:"24px",display:"block",position:"absolute",bottom:0,[n===POSITION_LEFT?"left":"right"]:"0px",background:"rgba(19, 20, 22, 0.901961)",border:0,padding:0,outline:0,color:"#fff"},o=e.miniatureOpen?closeMiniature:openMiniature;return React.createElement("button",{type:"button",style:s,onClick:()=>t(o(e))},React.createElement(IconArrow,{open:e.miniatureOpen,position:n}))}MiniatureToggleButton.propTypes={value:PropTypes.object.isRequired,onChangeValue:PropTypes.func.isRequired,position:PropTypes.oneOf([POSITION_RIGHT,POSITION_LEFT]).isRequired};const prefixID="react-svg-pan-zoom_miniature";function MiniatureMask(i){let{SVGMinX:e,SVGMinY:t,SVGWidth:n,SVGHeight:s,x1:o,y1:a,x2:l,y2:c,zoomToFit:u,_uid:h}=i;const d=`${prefixID}_mask_${h}`;return React.createElement("g",null,React.createElement("defs",null,React.createElement("mask",{id:d},React.createElement("rect",{x:e,y:t,width:n,height:s,fill:"#ffffff"}),React.createElement("rect",{x:o,y:a,width:l-o,height:c-a}))),React.createElement("rect",{x:e,y:t,width:n,height:s,style:{stroke:"none",fill:"#000",mask:`url(#${d})`,opacity:.4}}))}MiniatureMask.propTypes={SVGWidth:PropTypes.number.isRequired,SVGHeight:PropTypes.number.isRequired,SVGMinX:PropTypes.number.isRequired,SVGMinY:PropTypes.number.isRequired,x1:PropTypes.number.isRequired,y1:PropTypes.number.isRequired,x2:PropTypes.number.isRequired,y2:PropTypes.number.isRequired,zoomToFit:PropTypes.number.isRequired};const MiniatureMask$1=RandomUID(MiniatureMask),DEFAULT_BACKGROUND="#616264";function Miniature(i){let{value:e,onChangeValue:t,children:n,SVGBackground:s,background:o=DEFAULT_BACKGROUND,position:a=POSITION_LEFT,width:l=100,height:c=80}=i,{SVGMinX:u,SVGMinY:h,SVGWidth:d,SVGHeight:p,viewerWidth:f,viewerHeight:g}=e,_=p/d,x=_>=1?c/p:l/d,[{x:y,y:E},{x:b,y:v}]=applyToPoints(inverse(e),[{x:0,y:0},{x:f,y:g}]),M,T;e.miniatureOpen?(M=l,T=c):(M=24,T=24);let I={position:"absolute",overflow:"hidden",outline:"1px solid rgba(19, 20, 22, 0.90)",transition:"width 200ms ease, height 200ms ease, bottom 200ms ease",width:M+"px",height:T+"px",bottom:"6px",[a===POSITION_LEFT?"left":"right"]:"6px",background:o},w=_>=1?`translate(${(l-d*x)/2-u*x}, ${-h*x})`:`translate(${-u*x}, ${(c-p*x)/2-h*x})`;return React.createElement("div",{role:"navigation",style:I},React.createElement("svg",{width:l,height:c,style:{pointerEvents:"none"}},React.createElement("g",{transform:w},React.createElement("g",{transform:`scale(${x}, ${x})`},React.createElement("rect",{fill:s,x:u,y:h,width:d,height:p}),n,React.createElement(MiniatureMask$1,{SVGWidth:d,SVGHeight:p,SVGMinX:u,SVGMinY:h,x1:y,y1:E,x2:b,y2:v,zoomToFit:x})))),React.createElement(MiniatureToggleButton,{value:e,onChangeValue:t,position:a}))}Miniature.propTypes={value:PropTypes.object.isRequired,onChangeValue:PropTypes.func.isRequired,SVGBackground:PropTypes.string.isRequired,position:PropTypes.oneOf([POSITION_RIGHT,POSITION_LEFT]),background:PropTypes.string,width:PropTypes.number,height:PropTypes.number};function isNullOrUndefined(i){return typeof i>"u"||i===null}const github_base="https://github.com/chrvadala/react-svg-pan-zoom/blob/main",doc_v2_to_v3=github_base+"/docs/migrate-from-v2-to-v3.md";function tipControlledComponent(){console.error(`HEY! With ReactSVGPanZoom >= 3 you MUST specify value and tool props. Please read here ${doc_v2_to_v3}`)}function tipDeprecatedMiniatureProps(){console.error(`HEY! With ReactSVGPanZoom >= 3 the props miniaturePosition, miniatureBackground, miniatureWidth, miniatureHeight can be specified as key in the miniatureProps object. Please read here ${doc_v2_to_v3}`)}function tipDeprecateToolbarProps(){console.error(`HEY! With ReactSVGPanZoom >= 3 the prop toolbarPosition can be specified as key in the toolbarProps object. Please read here ${doc_v2_to_v3}`)}function printMigrationTipsRelatedToProps(i){(isNullOrUndefined(i.tool)||isNullOrUndefined(i.value))&&tipControlledComponent(),(!isNullOrUndefined(i.miniaturePosition)||!isNullOrUndefined(i.miniatureBackground)||!isNullOrUndefined(i.miniatureWidth)||!isNullOrUndefined(i.miniatureHeight))&&tipDeprecatedMiniatureProps(),isNullOrUndefined(i.toolbarPosition)||tipDeprecateToolbarProps()}function _extends$2(){return _extends$2=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},_extends$2.apply(null,arguments)}function ownKeys$1(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,n)}return t}function _objectSpread$1(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ownKeys$1(Object(t),!0).forEach(function(n){_defineProperty$1(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ownKeys$1(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function _defineProperty$1(i,e,t){return(e=_toPropertyKey$1(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function _toPropertyKey$1(i){var e=_toPrimitive$1(i,"string");return typeof e=="symbol"?e:e+""}function _toPrimitive$1(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class ReactSVGPanZoom extends React.Component{constructor(e,t){const{width:n,height:s,scaleFactorMin:o,scaleFactorMax:a,children:l}=e,{viewBox:c}=l.props;let u;if(c){const[h,d,p,f]=parseViewBox(c);u=getDefaultValue(n,s,h,d,p,f,o,a)}else{const{width:h,height:d}=l.props;u=getDefaultValue(n,s,0,0,h,d,o,a)}super(e,t),this.ViewerDOM=null,this.state={pointerX:null,pointerY:null,defaultValue:u},this.autoPanLoop=this.autoPanLoop.bind(this),this.onWheel=this.onWheel.bind(this),process.env.NODE_ENV!=="production"&&printMigrationTipsRelatedToProps(e)}componentDidUpdate(e){const t=this.getValue(),n=this.props;let s=t,o=!1;process.env.NODE_ENV!=="production"&&printMigrationTipsRelatedToProps(n);const{viewBox:a}=n.children.props;if(a){const[l,c,u,h]=parseViewBox(a);(t.SVGMinX!==l||t.SVGMinY!==c||t.SVGWidth!==u||t.SVGHeight!==h)&&(s=setSVGViewBox(s,l,c,u,h),o=!0)}else{const{width:l,height:c}=n.children.props;(t.SVGWidth!==l||t.SVGHeight!==c)&&(s=setSVGViewBox(s,0,0,l,c),o=!0)}(e.width!==n.width||e.height!==n.height)&&(s=setViewerSize(s,n.width,n.height),o=!0),(e.scaleFactorMin!==n.scaleFactorMin||e.scaleFactorMax!==n.scaleFactorMax)&&(s=setZoomLevels(s,n.scaleFactorMin,n.scaleFactorMax),o=!0),o&&this.setValue(s)}componentDidMount(){this.autoPanIsRunning=!0,requestAnimationFrame(this.autoPanLoop),this.ViewerDOM.addEventListener("wheel",this.onWheel,!1)}componentWillUnmount(){this.autoPanIsRunning=!1,this.ViewerDOM.removeEventListener("wheel",this.onWheel)}getValue(){return isValueValid(this.props.value)?this.props.value:this.state.defaultValue}getTool(){return this.props.tool?this.props.tool:TOOL_NONE}setValue(e){let{onChangeValue:t,onZoom:n,onPan:s}=this.props;t&&t(e),e.lastAction&&(n&&e.lastAction===ACTION_ZOOM&&n(e),s&&e.lastAction===ACTION_PAN&&s(e))}pan(e,t){let n=pan(this.getValue(),e,t);this.setValue(n)}zoom(e,t,n){let s=zoom(this.getValue(),e,t,n);this.setValue(s)}fitSelection(e,t,n,s){let o=fitSelection(this.getValue(),e,t,n,s);this.setValue(o)}fitToViewer(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ALIGN_LEFT,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ALIGN_TOP,n=fitToViewer(this.getValue(),e,t);this.setValue(n)}zoomOnViewerCenter(e){let t=zoomOnViewerCenter(this.getValue(),e);this.setValue(t)}setPointOnViewerCenter(e,t,n){let s=setPointOnViewerCenter(this.getValue(),e,t,n);this.setValue(s)}reset(){let e=reset(this.getValue());this.setValue(e)}openMiniature(){let e=openMiniature(this.getValue());this.setValue(e)}closeMiniature(){let e=closeMiniature(this.getValue());this.setValue(e)}handleViewerEvent(e){let{props:t,ViewerDOM:n}=this;if(!([TOOL_NONE,TOOL_AUTO].indexOf(this.getTool())>=0)||e.target===n)return;let o={click:t.onClick,dblclick:t.onDoubleClick,mousemove:t.onMouseMove,mouseup:t.onMouseUp,mousedown:t.onMouseDown,touchstart:t.onTouchStart,touchmove:t.onTouchMove,touchend:t.onTouchEnd,touchcancel:t.onTouchCancel}[e.type];o&&o(eventFactory(e,t.value,n))}autoPanLoop(){let e={x:this.state.pointerX,y:this.state.pointerY},t=onInterval(null,this.ViewerDOM,this.getTool(),this.getValue(),this.props,e);this.getValue()!==t&&this.setValue(t),this.autoPanIsRunning&&requestAnimationFrame(this.autoPanLoop)}onWheel(e){let t=onWheel(e,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==t&&this.setValue(t)}render(){let{props:e,state:{pointerX:t,pointerY:n}}=this,s=this.getTool(),o=this.getValue(),{customToolbar:a=Toolbar$1,customMiniature:l=Miniature}=e,c=s===TOOL_AUTO&&o.mode===MODE_PANNING&&o.startX!==o.endX&&o.startY!==o.endY,u;s===TOOL_PAN&&(u=cursorPolyfill(o.mode===MODE_PANNING?"grabbing":"grab")),s===TOOL_ZOOM_IN&&(u=cursorPolyfill("zoom-in")),s===TOOL_ZOOM_OUT&&(u=cursorPolyfill("zoom-out")),c&&(u=cursorPolyfill("grabbing"));let h=[TOOL_PAN,TOOL_ZOOM_IN,TOOL_ZOOM_OUT].indexOf(s)>=0;h=h||c;const d=this.props.detectPinchGesture||[TOOL_PAN,TOOL_AUTO].indexOf(this.getTool())!==-1?"none":void 0,p={display:"block",cursor:u,touchAction:d};return React.createElement("div",{style:_objectSpread$1({position:"relative",width:o.viewerWidth,height:o.viewerHeight},e.style),className:this.props.className},React.createElement("svg",{ref:f=>this.ViewerDOM=f,width:o.viewerWidth,height:o.viewerHeight,style:p,onMouseDown:f=>{let g=onMouseDown$1(f,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==g&&this.setValue(g),this.handleViewerEvent(f)},onMouseMove:f=>{let{left:g,top:_}=this.ViewerDOM.getBoundingClientRect(),x=f.clientX-Math.round(g),y=f.clientY-Math.round(_),E=onMouseMove$1(f,this.ViewerDOM,this.getTool(),this.getValue(),this.props,{x,y});this.getValue()!==E&&this.setValue(E),this.setState({pointerX:x,pointerY:y}),this.handleViewerEvent(f)},onMouseUp:f=>{let g=onMouseUp(f,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==g&&this.setValue(g),this.handleViewerEvent(f)},onClick:f=>{this.handleViewerEvent(f)},onDoubleClick:f=>{let g=onDoubleClick(f,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==g&&this.setValue(g),this.handleViewerEvent(f)},onMouseEnter:f=>{if(isTouchDevice())return;let g=onMouseEnterOrLeave(f,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==g&&this.setValue(g)},onMouseLeave:f=>{let g=onMouseEnterOrLeave(f,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==g&&this.setValue(g)},onTouchStart:f=>{let g=onTouchStart$1(f,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==g&&this.setValue(g),this.handleViewerEvent(f)},onTouchMove:f=>{let g=onTouchMove$1(f,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==g&&this.setValue(g),this.handleViewerEvent(f)},onTouchEnd:f=>{let g=onTouchEnd(f,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==g&&this.setValue(g),this.handleViewerEvent(f)},onTouchCancel:f=>{let g=onTouchCancel(f,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==g&&this.setValue(g),this.handleViewerEvent(f)}},React.createElement("rect",{fill:e.background,x:0,y:0,width:o.viewerWidth,height:o.viewerHeight,style:{pointerEvents:"none"}}),React.createElement("g",{transform:toSVG(o),style:h?{pointerEvents:"none"}:{}},React.createElement("rect",{fill:this.props.SVGBackground,style:this.props.SVGStyle,x:o.SVGMinX||0,y:o.SVGMinY||0,width:o.SVGWidth,height:o.SVGHeight}),React.createElement("g",null,e.children.props.children)),[TOOL_NONE,TOOL_AUTO].indexOf(s)>=0&&e.detectAutoPan&&o.focus?React.createElement("g",{style:{pointerEvents:"none"}},n<=20?React.createElement(BorderGradient$1,{direction:POSITION_TOP,width:o.viewerWidth,height:o.viewerHeight}):null,o.viewerWidth-t<=20?React.createElement(BorderGradient$1,{direction:POSITION_RIGHT,width:o.viewerWidth,height:o.viewerHeight}):null,o.viewerHeight-n<=20?React.createElement(BorderGradient$1,{direction:POSITION_BOTTOM,width:o.viewerWidth,height:o.viewerHeight}):null,o.focus&&t<=20?React.createElement(BorderGradient$1,{direction:POSITION_LEFT,width:o.viewerWidth,height:o.viewerHeight}):null):null,o.mode!==MODE_ZOOMING?null:React.createElement(Selection,{startX:o.startX,startY:o.startY,endX:o.endX,endY:o.endY})),e.toolbarProps.position===POSITION_NONE?null:React.createElement(a,_extends$2({},this.props.toolbarProps,{value:o,onChangeValue:f=>this.setValue(f),tool:s,onChangeTool:f=>this.props.onChangeTool(f)})),e.miniatureProps.position===POSITION_NONE?null:React.createElement(l,_extends$2({},this.props.miniatureProps,{value:o,onChangeValue:f=>this.setValue(f),SVGBackground:this.props.SVGBackground}),e.children.props.children))}}ReactSVGPanZoom.propTypes={width:PropTypes.number.isRequired,height:PropTypes.number.isRequired,value:PropTypes.oneOfType([PropTypes.object,PropTypes.shape({version:PropTypes.oneOf([2]).isRequired,mode:PropTypes.oneOf([MODE_IDLE,MODE_PANNING,MODE_ZOOMING]).isRequired,focus:PropTypes.bool.isRequired,a:PropTypes.number.isRequired,b:PropTypes.number.isRequired,c:PropTypes.number.isRequired,d:PropTypes.number.isRequired,e:PropTypes.number.isRequired,f:PropTypes.number.isRequired,viewerWidth:PropTypes.number.isRequired,viewerHeight:PropTypes.number.isRequired,SVGMinX:PropTypes.number.isRequired,SVGMinY:PropTypes.number.isRequired,SVGWidth:PropTypes.number.isRequired,SVGHeight:PropTypes.number.isRequired,startX:PropTypes.number,startY:PropTypes.number,endX:PropTypes.number,endY:PropTypes.number,miniatureOpen:PropTypes.bool.isRequired})]).isRequired,onChangeValue:PropTypes.func.isRequired,tool:PropTypes.oneOf([TOOL_AUTO,TOOL_NONE,TOOL_PAN,TOOL_ZOOM_IN,TOOL_ZOOM_OUT]).isRequired,onChangeTool:PropTypes.func.isRequired,background:PropTypes.string,SVGBackground:PropTypes.string,SVGStyle:PropTypes.object,style:PropTypes.object,className:PropTypes.string,detectWheel:PropTypes.bool,detectAutoPan:PropTypes.bool,detectPinchGesture:PropTypes.bool,onZoom:PropTypes.func,onPan:PropTypes.func,onClick:PropTypes.func,onDoubleClick:PropTypes.func,onMouseUp:PropTypes.func,onMouseMove:PropTypes.func,onMouseDown:PropTypes.func,preventPanOutside:PropTypes.bool,scaleFactor:PropTypes.number,scaleFactorOnWheel:PropTypes.number,scaleFactorMax:PropTypes.number,scaleFactorMin:PropTypes.number,modifierKeys:PropTypes.array,disableDoubleClickZoomWithToolAuto:PropTypes.bool,customMiniature:PropTypes.oneOfType([PropTypes.element,PropTypes.func]),miniatureProps:PropTypes.shape({position:PropTypes.oneOf([POSITION_NONE,POSITION_RIGHT,POSITION_LEFT]),background:PropTypes.string,width:PropTypes.number,height:PropTypes.number}),customToolbar:PropTypes.oneOfType([PropTypes.element,PropTypes.func]),toolbarProps:PropTypes.shape({position:PropTypes.oneOf([POSITION_NONE,POSITION_TOP,POSITION_RIGHT,POSITION_BOTTOM,POSITION_LEFT]),SVGAlignX:PropTypes.oneOf([ALIGN_CENTER,ALIGN_LEFT,ALIGN_RIGHT]),SVGAlignY:PropTypes.oneOf([ALIGN_CENTER,ALIGN_TOP,ALIGN_BOTTOM]),activeToolColor:PropTypes.string}),children:function(i,e,t){let n=i[e],s=["svg"];if(React.Children.count(n)!==1||s.indexOf(n.type)===-1)return new Error("`"+t+"` should have a single child of the following types: `"+s.join("`, `")+"`.");if((!n.props.hasOwnProperty("width")||!n.props.hasOwnProperty("height"))&&!n.props.hasOwnProperty("viewBox"))return new Error("SVG should have props `width` and `height` or `viewBox`")}},ReactSVGPanZoom.defaultProps={style:{},background:"#616264",SVGBackground:"#fff",SVGStyle:{},detectWheel:!0,detectAutoPan:!0,detectPinchGesture:!0,modifierKeys:["Alt","Shift","Control"],preventPanOutside:!0,scaleFactor:1.1,scaleFactorOnWheel:1.06,disableZoomWithToolAuto:!1,onZoom:null,onPan:null,toolbarProps:{},miniatureProps:{}};const _excluded$1=["width","height","onChangeTool","onChangeValue"];function _extends$1(){return _extends$1=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},_extends$1.apply(null,arguments)}function _objectWithoutProperties$1(i,e){if(i==null)return{};var t,n,s=_objectWithoutPropertiesLoose$1(i,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(i);for(n=0;n<o.length;n++)t=o[n],e.includes(t)||{}.propertyIsEnumerable.call(i,t)&&(s[t]=i[t])}return s}function _objectWithoutPropertiesLoose$1(i,e){if(i==null)return{};var t={};for(var n in i)if({}.hasOwnProperty.call(i,n)){if(e.includes(n))continue;t[n]=i[n]}return t}class UncontrolledReactSVGPanZoom extends React.Component{constructor(e){super(e),this.state={value:e.defaultValue||{},tool:e.defaultTool||TOOL_NONE},this.Viewer=null,this.changeTool=this.changeTool.bind(this),this.changeValue=this.changeValue.bind(this)}changeTool(e){this.setState({tool:e})}changeValue(e){this.setState({value:e})}pan(e,t){this.Viewer.pan(e,t)}zoom(e,t,n){this.Viewer.zoom(e,t,n)}fitSelection(e,t,n,s){this.Viewer.fitSelection(e,t,n,s)}fitToViewer(e,t){this.Viewer.fitToViewer(e,t)}zoomOnViewerCenter(e){this.Viewer.zoomOnViewerCenter(e)}setPointOnViewerCenter(e,t,n){this.Viewer.setPointOnViewerCenter(e,t,n)}reset(){this.Viewer.reset()}openMiniature(){this.Viewer.openMiniature()}closeMiniature(){this.Viewer.closeMiniature()}render(){const e=this.props,{width:t,height:n,onChangeTool:s,onChangeValue:o}=e,a=_objectWithoutProperties$1(e,_excluded$1),{tool:l,value:c}=this.state;return React.createElement(ReactSVGPanZoom,_extends$1({width:t,height:n,tool:l,onChangeTool:this.changeTool,value:c,onChangeValue:this.changeValue,ref:u=>this.Viewer=u},a))}}UncontrolledReactSVGPanZoom.propTypes={width:PropTypes.number.isRequired,height:PropTypes.number.isRequired,defaultValue:PropTypes.object,defaultTool:PropTypes.string};let activeFitAnimation=null;const SURFACE_DUPLICATE_GAP=30,leaveSurfaceTool=i=>{const e=i.get("mode");if(e!==MODE_DRAWING_SURFACE&&e!==MODE_WAITING_DRAWING_SURFACE)return null;const{updatedState:t,finished:n}=Surface.finishDrawingSurface(i);return n?t:Project.rollback(i).updatedState},exitingTools=i=>leaveSurfaceTool(i)??i,sameHover=(i,e)=>i===e?!0:!i||!e?!1:i.layerID===e.layerID&&i.prototype===e.prototype&&i.id===e.id&&i.part===e.part&&i.lineID===e.lineID,isSurfaceArea=(i,e,t)=>{const n=i.getIn(["scene","layers",e]),s=n==null?void 0:n.getIn(["areas",t]);return!!s&&getAreaKind(s,n)==="Surface"},getSelectedElement=i=>{var l,c,u,h;const e=i.getIn(["scene","selectedLayer"]);if(!e)return null;const t=i.getIn(["scene","layers",e]);if(!t)return null;const n=(l=t.getIn(["selected","items"]))==null?void 0:l.first();if(n)return{layerID:e,kind:"item",id:n};const s=(c=t.getIn(["selected","holes"]))==null?void 0:c.first();if(s)return{layerID:e,kind:"hole",id:s};const o=(u=t.getIn(["selected","areas"]))==null?void 0:u.first();if(o){const d=t.getIn(["areas",o]);return getAreaKind(d,t)==="Surface"?{layerID:e,kind:"surface",id:o}:null}const a=(h=t.getIn(["selected","lines"]))==null?void 0:h.find(d=>t.getIn(["lines",d,"type"])==="wall");return a?{layerID:e,kind:"wall",id:a}:null},easeOutCubic=i=>1-Math.pow(1-i,3);function fitSelectionMatrix(i,e,t,n,s){var u;if(!i||typeof i.setValue!="function")return null;const o=(u=i.getValue)==null?void 0:u.call(i);if(!o)return null;const{viewerWidth:a,viewerHeight:l}=o;if(!a||!l)return null;const c=Math.min(a/n,l/s);return{start:o,scale:c,e:-e*c,f:-t*c}}function applyFitSelection(i,e,t,n,s){const o=fitSelectionMatrix(i,e,t,n,s);o&&(activeFitAnimation!==null&&(cancelAnimationFrame(activeFitAnimation),activeFitAnimation=null),i.setValue({...o.start,a:o.scale,b:0,c:0,d:o.scale,e:o.e,f:o.f,mode:"idle"}))}function animateFitSelection(i,e,t,n,s,o=350){const a=fitSelectionMatrix(i,e,t,n,s);if(!a)return;const{start:l,scale:c,e:u,f:h}=a,d=l.a??1,p=l.e??0,f=l.f??0;if(Math.abs(d-c)<.001&&Math.abs(p-u)<.5&&Math.abs(f-h)<.5)return;activeFitAnimation!==null&&(cancelAnimationFrame(activeFitAnimation),activeFitAnimation=null);const _=performance.now(),x=y=>{const E=Math.min(1,(y-_)/o),b=easeOutCubic(E),v=d+(c-d)*b,M=p+(u-p)*b,T=f+(h-f)*b;i.setValue({...l,a:v,b:0,c:0,d:v,e:M,f:T,mode:"idle"}),E<1?activeFitAnimation=requestAnimationFrame(x):activeFitAnimation=null};activeFitAnimation=requestAnimationFrame(x)}const useReactPlannerStore=create((i,e)=>({planner:new State$1,viewer:null,viewer3D:null,plan:null,toast:null,showDimensions:!1,showGrid:!1,activeFloor:0,theme:typeof window<"u"&&localStorage.getItem("fp-theme")||"dark",setViewer:t=>{i(n=>({...n,viewer:t}))},setViewer3D:t=>{i(n=>({...n,viewer3D:t}))},setToast:t=>{i(n=>({...n,toast:t}))},setActiveFloor:t=>{i(n=>({...n,activeFloor:t}))},newProject:()=>{i(t=>({...t,planner:Project.newProject(t.planner).updatedState}))},selectTool3DView:()=>{i(t=>{const s=Project.unselectAll(exitingTools(t.planner)).updatedState.set("mode",MODE_3D_VIEW);return{...t,planner:s,showDimensions:!1}})},selectTool3DFirstPerson:()=>{i(t=>{const s=Project.rollback(exitingTools(t.planner)).updatedState.set("mode",MODE_3D_FIRST_PERSON);return{...t,planner:s}})},loadProject:t=>{i(n=>{const s=new State$1({scene:t,catalog:n.planner.catalog.toJS()});return{...n,planner:s}})},undo:()=>{i(t=>{const n=Project.undo(t.planner).updatedState;return{...t,planner:n}})},redo:()=>{i(t=>{const n=Project.redo(t.planner).updatedState;return{...t,planner:n}})},addLayer:(t,n)=>{i(s=>{const o=Layer$1.create(s.planner,t,n).updatedState;return{...s,planner:o}})},removeLayer:t=>{i(n=>{const s=Layer$1.remove(n.planner,t).updatedState;return{...n,planner:s}})},addGroup:()=>{i(t=>{const n=Group$2.create(t.planner).updatedState;return{...t,planner:n}})},selectGroup:t=>{i(n=>{const s=Group$2.select(n.planner,t).updatedState;return{...n,planner:s}})},setGroupProperties:(t,n)=>{i(s=>{const o=Group$2.setProperties(s.planner,t,n).updatedState;return{...s,planner:o}})},addToGroup:(t,n,s,o)=>{i(a=>{const l=Group$2.addElement(a.planner,t,n,s,o).updatedState;return{...a,planner:l}})},removeGroup:t=>{i(n=>{const s=Group$2.remove(n.planner,t).updatedState;return{...n,planner:s}})},setGroupAttributes:(t,n)=>{i(s=>{const o=Group$2.setAttributes(s.planner,t,n).updatedState;return{...s,planner:o}})},groupTranslate:(t,n,s)=>{i(o=>{const a=Group$2.translate(o.planner,t,n,s).updatedState;return{...o,planner:a}})},removeFromGroup:(t,n,s,o)=>{i(a=>{const l=Group$2.removeElement(a.planner,t,n,s,o).updatedState;return{...a,planner:l}})},groupRotate:(t,n)=>{i(s=>{const o=Group$2.rotate(s.planner,t,n).updatedState;return{...s,planner:o}})},removeGroupAndDeleteElements:t=>{i(n=>{const s=Group$2.removeAndDeleteElements(n.planner,t).updatedState;return{...n,planner:s}})},addGroupFromSelected:()=>{i(t=>{const n=Group$2.createFromSelectedElements(t.planner).updatedState;return{...t,planner:n}})},copyProperties:t=>{i(n=>({...n,planner:Project.copyProperties(n.planner,t).updatedState}))},setProjectProperties:t=>{i(n=>({...n,planner:Project.setProjectProperties(n.planner,t).updatedState}))},pasteProperties:()=>{i(t=>{const n=t.planner.merge({sceneHistory:historyPush(t.planner.sceneHistory,t.planner.scene)});return{...t,planner:Project.pasteProperties(n).updatedState}})},setProperties:t=>{i(n=>{const s=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});return{...n,planner:Project.setProperties(s,s.getIn(["scene","selectedLayer"]),t).updatedState}})},setHolesAttributes:t=>{i(n=>{const s=t.set("offset",parseFloat(t.get("offset"))),o=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});return{...n,planner:Project.setHolesAttributes(o,s).updatedState}})},setLinesAttributes:t=>{i(n=>{const s=t.withMutations(a=>{a.setIn(["vertexOne","x"],parseFloat(t.getIn(["vertexOne","x"]))),a.setIn(["vertexOne","y"],parseFloat(t.getIn(["vertexOne","y"]))),a.setIn(["vertexTwo","x"],parseFloat(t.getIn(["vertexTwo","x"]))),a.setIn(["vertexTwo","y"],parseFloat(t.getIn(["vertexTwo","y"])))}),o=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});return{...n,planner:Project.setLinesAttributes(o,s).updatedState}})},setItemsAttributes:t=>{i(n=>{const s=t.set("rotation",parseFloat(t.get("rotation"))),o=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});return{...n,planner:Project.setItemsAttributes(o,s).updatedState}})},selectLine:(t,n)=>{i(s=>{const o=Line$2.select(s.planner,t,n).updatedState;return{...s,planner:o}})},selectHole:(t,n)=>{i(s=>{const o=Hole.select(s.planner,t,n).updatedState;return{...s,planner:o}})},selectItem:(t,n)=>{i(s=>{const o=Item$1.select(s.planner,t,n).updatedState;return{...s,planner:o}})},selectLayer:t=>{i(n=>{const s=Layer$1.select(n.planner,t).updatedState;return{...n,planner:s}})},setLayerProperties:(t,n)=>{i(s=>{const o=Layer$1.setProperties(s.planner,t,n).updatedState;return{...s,planner:o}})},addVerticalGuide:t=>{i(n=>{const s=VerticalGuide.create(n.planner,t).updatedState;return{...n,planner:s}})},addHorizontalGuide:t=>{i(n=>{const s=HorizontalGuide.create(n.planner,t).updatedState;return{...n,planner:s}})},removeVerticalGuide:t=>{i(n=>{const s=VerticalGuide.remove(n.planner,t).updatedState;return{...n,planner:s}})},removeHorizontalGuide:t=>{i(n=>{const s=HorizontalGuide.remove(n.planner,t).updatedState;return{...n,planner:s}})},toggleSnap:t=>{i(n=>{const s=Project.toggleSnap(n.planner,t).updatedState;return{...n,planner:s}})},openProjectConfigurator:()=>{i(t=>{const n=Project.openProjectConfigurator(exitingTools(t.planner)).updatedState;return{...t,planner:n}})},setMode:t=>{i(n=>{const s=exitingTools(n.planner).set("mode",t);return{...n,planner:s}})},updateZoomScale:t=>{i(n=>({...n,planner:Project.updateZoomScale(n.planner,t).updatedState}))},updateCameraView:t=>{i(n=>{const s=n.planner.update("viewer2D",o=>o.merge(fromJS(t)));return{...n,planner:s}})},selectToolPan:()=>{i(t=>{const n=exitingTools(t.planner).set("mode",MODE_2D_PAN);return{...t,planner:n}})},selectToolEdit:()=>{i(t=>({...t,planner:Project.setMode(exitingTools(t.planner),MODE_IDLE$1).updatedState}))},selectToolZoomIn:()=>{i(t=>{const n=exitingTools(t.planner).set("mode",MODE_2D_ZOOM_IN);return{...t,planner:n}})},selectToolZoomOut:()=>{i(t=>{const n=exitingTools(t.planner).set("mode",MODE_2D_ZOOM_OUT);return{...t,planner:n}})},updateDrawingLine:(t,n)=>{i(s=>({...s,planner:Line$2.updateDrawingLine(s.planner,t,n).updatedState}))},updateDrawingSurface:(t,n)=>{i(s=>({...s,planner:Surface.updateDrawingSurface(s.planner,t,n).updatedState}))},updateMouseCoord:t=>{i(n=>({...n,planner:Project.updateMouseCoord(n.planner,t).updatedState}))},openCatalog:()=>{i(t=>{const n=exitingTools(t.planner).set("mode",MODE_VIEWING_CATALOG);return{...t,planner:n}})},updateDrawingHole:(t,n,s)=>{i(o=>({...o,planner:Hole.updateDrawingHole(o.planner,t,n,s).updatedState}))},updateDrawingItem:(t,n,s)=>{i(o=>({...o,planner:Item$1.updateDrawingItem(o.planner,t,n,s).updatedState}))},blur:()=>{i(t=>{const n=t.planner.merge({mode:MODE_IDLE$1,activeSnapElement:null});return{...t,planner:n}})},updateDraggingHole:(t,n)=>{i(s=>({...s,planner:Hole.updateDraggingHole(s.planner,t,n).updatedState}))},updateDraggingLine:(t,n)=>{i(s=>({...s,planner:Line$2.updateDraggingLine(s.planner,t,n).updatedState}))},updateDraggingVertex:(t,n)=>{i(s=>({...s,planner:Vertex$2.updateDraggingVertex(s.planner,t,n).updatedState}))},updateDraggingItem:(t,n)=>{i(s=>({...s,planner:Item$1.updateDraggingItem(s.planner,t,n).updatedState}))},updateRotatingItem:(t,n)=>{i(s=>({...s,planner:Item$1.updateRotatingItem(s.planner,t,n).updatedState}))},beginDraggingLine:(t,n,s,o)=>{i(a=>{const l=a.planner.merge({sceneHistory:historyPush(a.planner.sceneHistory,a.planner.scene)});return{...a,planner:Line$2.beginDraggingLine(l,t,n,s,o).updatedState}})},endDraggingLine:(t,n)=>{i(s=>({...s,planner:Line$2.endDraggingLine(s.planner,t,n).updatedState}))},beginDraggingVertex:(t,n)=>{i(s=>{const o=s.planner.merge({sceneHistory:historyPush(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Vertex$2.beginDraggingVertex(o,t,n).updatedState}})},endDraggingVertex:()=>{i(t=>({...t,planner:Vertex$2.endDraggingVertex(t.planner).updatedState}))},resizeHandlesFor:null,setResizeHandlesFor:t=>{i(n=>({...n,resizeHandlesFor:t}))},hoveredElement:null,setHoveredElement:t=>{sameHover(e().hoveredElement,t)||i(n=>({...n,hoveredElement:t}))},duplicateSelected:()=>{const t=getSelectedElement(e().planner);if(t){if(t.kind==="surface"){e().duplicateSurface(t.id);return}t.kind!=="wall"&&i(n=>{const s=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});return{...n,planner:t.kind==="item"?Item$1.duplicate(s,t.layerID,t.id).updatedState:Hole.duplicate(s,t.layerID,t.id).updatedState}})}},duplicateItem:t=>{i(n=>{const s=n.planner.getIn(["scene","selectedLayer"]);if(!s)return n;const o=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});return{...n,planner:Item$1.duplicate(o,s,t).updatedState}})},duplicateHole:t=>{i(n=>{const s=n.planner.getIn(["scene","selectedLayer"]);if(!s)return n;const o=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});return{...n,planner:Hole.duplicate(o,s,t).updatedState}})},setItemAttributes:(t,n)=>{i(s=>{const o=s.planner.getIn(["scene","selectedLayer"]);if(!o||!s.planner.getIn(["scene","layers",o,"items",t]))return s;const a=s.planner.merge({sceneHistory:historyPush(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Item$1.setAttributes(a,o,t,n).updatedState}})},setHoleAttributes:(t,n)=>{i(s=>{const o=s.planner.getIn(["scene","selectedLayer"]);if(!o||!s.planner.getIn(["scene","layers",o,"holes",t]))return s;const a=s.planner.merge({sceneHistory:historyPush(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Hole.mergeAttributes(a,o,t,n).updatedState}})},moveHole:(t,n)=>{i(s=>{const o=s.planner.getIn(["scene","selectedLayer"]);if(!o||!s.planner.getIn(["scene","layers",o,"holes",t]))return s;const a=s.planner.merge({sceneHistory:historyPush(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Hole.mergeAttributes(a,o,t,{offset:Math.min(1,Math.max(0,n))}).updatedState}})},setHoleProperties:(t,n)=>{i(s=>{const o=s.planner.getIn(["scene","selectedLayer"]);if(!o)return s;const a=s.planner.getIn(["scene","layers",o,"holes",t]);if(!a)return s;const l=s.planner.merge({sceneHistory:historyPush(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Hole.setProperties(l,o,t,a.properties.merge(fromJS(n))).updatedState}})},rotateSelected:t=>{i(n=>{const s=getSelectedElement(n.planner);if(!s||s.kind!=="item"&&s.kind!=="surface")return n;const o=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});return{...n,planner:s.kind==="item"?Item$1.rotate(o,s.layerID,s.id,t).updatedState:Area$1.rotate(o,s.layerID,s.id,-t).updatedState}})},flipSelected:t=>{i(n=>{const s=getSelectedElement(n.planner);if(!s||s.kind==="wall")return n;const o=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)}),{layerID:a,id:l}=s;let c;return s.kind==="item"?c=Item$1.flip(o,a,l,t).updatedState:s.kind==="hole"?c=Hole.flip(o,a,l,t).updatedState:c=Area$1.mirror(o,a,l,t).updatedState,{...n,planner:c}})},rotateArea:(t,n)=>{i(s=>{const o=s.planner.getIn(["scene","selectedLayer"]);if(!o||!isSurfaceArea(s.planner,o,t))return s;const a=s.planner.merge({sceneHistory:historyPush(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Area$1.rotate(a,o,t,-n).updatedState}})},mirrorArea:(t,n)=>{i(s=>{const o=s.planner.getIn(["scene","selectedLayer"]);if(!o||!isSurfaceArea(s.planner,o,t))return s;const a=s.planner.merge({sceneHistory:historyPush(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Area$1.mirror(a,o,t,n).updatedState}})},duplicateSurface:t=>{i(n=>{const s=n.planner.getIn(["scene","selectedLayer"]);if(!s)return n;const o=n.planner.getIn(["scene","layers",s]),a=o==null?void 0:o.getIn(["areas",t]);if(!a)return n;const c=a.get("vertices").toArray().map(E=>o.getIn(["vertices",E])).filter(Boolean).map(E=>({x:E.get("x"),y:E.get("y")}));if(c.length<3)return n;const u=c.map(E=>E.x),h=Math.max(...u)-Math.min(...u)+SURFACE_DUPLICATE_GAP,d=c.map(E=>({x:E.x+h,y:E.y})),p=Area$1.getSurfaceLines(n.planner,s,t).first(),f=p&&o.getIn(["lines",p,"type"])||"surface",g=new Set(o.get("areas").keySeq().toArray());let _=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});for(let E=0;E<d.length;E++){const b=d[E],v=d[(E+1)%d.length];_=Line$2.createAvoidingIntersections(_,s,f,b.x,b.y,v.x,v.y).updatedState}_=Layer$1.detectAndUpdateAreas(_,s).updatedState;const x=a.get("properties"),y=[];_.getIn(["scene","layers",s,"areas"]).keySeq().forEach(E=>{g.has(E)||y.push(E)});for(const E of y)_=Area$1.setProperties(_,s,E,x).updatedState;return y.length>0&&(_=Area$1.unselect(_,s,t).updatedState,_=Area$1.select(_,s,y[0]).updatedState),{...n,planner:_}})},beginResizingItem:(t,n,s,o)=>{i(a=>{const l=a.planner.merge({sceneHistory:historyPush(a.planner.sceneHistory,a.planner.scene)});return{...a,planner:Item$1.beginResizingItem(l,t,n,s,o).updatedState}})},updateResizingItem:(t,n)=>{i(s=>({...s,planner:Item$1.updateResizingItem(s.planner,t,n).updatedState}))},endResizingItem:(t,n)=>{i(s=>({...s,planner:Item$1.endResizingItem(s.planner,t,n).updatedState}))},beginRotatingItem:(t,n,s,o)=>{i(a=>{const l=a.planner.merge({sceneHistory:historyPush(a.planner.sceneHistory,a.planner.scene)});return{...a,planner:Item$1.beginRotatingItem(l,t,n,s,o).updatedState}})},endRotatingItem:(t,n)=>{i(s=>({...s,planner:Item$1.endRotatingItem(s.planner,t,n).updatedState}))},beginDraggingItem:(t,n,s,o)=>{i(a=>{const l=a.planner.merge({sceneHistory:historyPush(a.planner.sceneHistory,a.planner.scene)});return{...a,planner:Item$1.beginDraggingItem(l,t,n,s,o).updatedState}})},endDraggingItem:(t,n)=>{i(s=>({...s,planner:Item$1.endDraggingItem(s.planner,t,n).updatedState}))},beginDraggingHole:(t,n,s,o)=>{i(a=>{const l=a.planner.merge({sceneHistory:historyPush(a.planner.sceneHistory,a.planner.scene)});return{...a,planner:Hole.beginDraggingHole(l,t,n,s,o).updatedState}})},endDraggingHole:(t,n)=>{i(s=>({...s,planner:Hole.endDraggingHole(s.planner,t,n).updatedState}))},beginDrawingLine:(t,n,s)=>{i(o=>{const a=o.planner.merge({sceneHistory:historyPush(o.planner.sceneHistory,o.planner.scene)});return{...o,planner:Line$2.beginDrawingLine(a,t,n,s).updatedState}})},endDrawingLine:(t,n)=>{i(s=>({...s,planner:Line$2.endDrawingLine(s.planner,t,n).updatedState}))},beginDrawingSurface:(t,n,s)=>{i(o=>{const a=o.planner.getIn(["drawingSupport","points"]),l=a&&a.size?o.planner:o.planner.merge({sceneHistory:historyPush(o.planner.sceneHistory,o.planner.scene)});return{...o,planner:Surface.beginDrawingSurface(l,t,n,s).updatedState}})},endDrawingSurface:(t,n)=>{i(s=>({...s,planner:Surface.endDrawingSurface(s.planner,t,n).updatedState}))},endDrawingHole:(t,n,s)=>{i(o=>{const a=o.planner.merge({sceneHistory:historyPush(o.planner.sceneHistory,o.planner.scene)});return{...o,planner:Hole.endDrawingHole(a,t,n,s).updatedState}})},endDrawingItem:(t,n,s)=>{i(o=>{const a=o.planner.merge({sceneHistory:historyPush(o.planner.sceneHistory,o.planner.scene)});return{...o,planner:Item$1.endDrawingItem(a,t,n,s).updatedState}})},selectArea:(t,n)=>{i(s=>({...s,planner:Area$1.select(s.planner,t,n).updatedState}))},initCatalog:t=>{i(n=>({...n,planner:Project.initCatalog(n.planner,t).updatedState}))},goBackToCatalogPage:t=>{i(n=>({...n,planner:Project.goBackToCatalogPage(n.planner,t).updatedState}))},pushLastSelectedCatalogElementToHistory:t=>{i(n=>({...n,planner:Project.pushLastSelectedCatalogElementToHistory(n.planner,t).updatedState}))},selectToolDrawingLine:(t,n)=>{i(s=>({...s,planner:Line$2.selectToolDrawingLine(exitingTools(s.planner),t,n).updatedState}))},selectToolDrawingSurface:t=>{i(n=>({...n,planner:Surface.selectToolDrawingSurface(exitingTools(n.planner),t).updatedState}))},selectToolDrawingItem:t=>{i(n=>{const s=exitingTools(n.planner),o=s.merge({sceneHistory:historyPush(s.sceneHistory,s.scene)});return{...n,planner:Item$1.selectToolDrawingItem(o,t).updatedState}})},selectToolDrawingHole:t=>{i(n=>{const s=exitingTools(n.planner),o=s.merge({sceneHistory:historyPush(s.sceneHistory,s.scene)});return{...n,planner:Hole.selectToolDrawingHole(o,t).updatedState}})},changeCatalogPage:(t,n)=>{i(s=>({...s,planner:Project.changeCatalogPage(s.planner,n,t).updatedState}))},remove:()=>{i(t=>{const n=t.planner.merge({sceneHistory:historyPush(t.planner.sceneHistory,t.planner.scene)});return{...t,planner:Project.remove(n).updatedState}})},rollback:()=>{i(t=>({...t,planner:leaveSurfaceTool(t.planner)??Project.rollback(t.planner).updatedState}))},setAlterateState:()=>{i(t=>({...t,planner:Project.setAlterate(t.planner).updatedState}))},setPlan:t=>{i(n=>({...n,plan:t}))},unselectAll:()=>{i(t=>({...t,planner:Project.unselectAll(t.planner).updatedState}))},setShowDimensions:t=>{i(n=>({...n,showDimensions:t}))},setShowGrid:t=>{i(n=>({...n,showGrid:t}))},setTheme:t=>{if(typeof window<"u")try{localStorage.setItem("fp-theme",t)}catch{}i(n=>({...n,theme:t}))},addHoleOnLine:(t,n,s)=>{let o;return i(a=>{const l=a.planner.getIn(["scene","selectedLayer"]);if(!l)return a;const c=a.planner.merge({sceneHistory:historyPush(a.planner.sceneHistory,a.planner.scene)}),u=Math.max(.05,Math.min(.95,s)),{updatedState:h,hole:d}=Hole.create(c,l,n,t,u);return o=d==null?void 0:d.id,{...a,planner:h}}),o},setAreaProperties:(t,n)=>{i(s=>{const o=s.planner.getIn(["scene","selectedLayer"]);if(!o)return s;const a=s.planner.merge({sceneHistory:historyPush(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Area$1.setJsProperties(a,o,t,n).updatedState}})},setLineProperties:(t,n)=>{i(s=>{const o=s.planner.getIn(["scene","selectedLayer"]);if(!o||!s.planner.getIn(["scene","layers",o,"lines",t]))return s;const l=s.planner.merge({sceneHistory:historyPush(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Line$2.setJsProperties(l,o,t,n).updatedState}})},moveVertex:(t,n,s)=>{i(o=>{const a=o.planner.getIn(["scene","selectedLayer"]);if(!a||!o.planner.getIn(["scene","layers",a,"vertices",t]))return o;const u=o.planner.merge({sceneHistory:historyPush(o.planner.sceneHistory,o.planner.scene)}).setIn(["scene","layers",a,"vertices",t,"x"],n).setIn(["scene","layers",a,"vertices",t,"y"],s);return{...o,planner:Layer$1.detectAndUpdateAreas(u,a).updatedState}})},removeLine:t=>{i(n=>{const s=n.planner.getIn(["scene","selectedLayer"]);if(!s||!n.planner.getIn(["scene","layers",s,"lines",t]))return n;const o=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)}),a=Line$2.remove(o,s,t).updatedState;return{...n,planner:Layer$1.detectAndUpdateAreas(a,s).updatedState}})},removeArea:t=>{i(n=>{const s=n.planner.getIn(["scene","selectedLayer"]);if(!s)return n;const o=n.planner.getIn(["scene","layers",s,"areas",t]);if(!o)return n;const a=new Set(o.get("vertices").toArray()),l=n.planner.getIn(["scene","layers",s,"lines"]),c=[];if(l.forEach((d,p)=>{const f=d.get("vertices").toArray();a.has(f[0])&&a.has(f[1])&&c.push(p)}),c.length===0)return n;let h=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});for(const d of c)h=Line$2.remove(h,s,d).updatedState;return{...n,planner:Layer$1.detectAndUpdateAreas(h,s).updatedState}})},removeItem:t=>{i(n=>{const s=n.planner.getIn(["scene","selectedLayer"]);if(!s||!n.planner.getIn(["scene","layers",s,"items",t]))return n;const a=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});return{...n,planner:Item$1.remove(a,s,t).updatedState}})},removeHole:t=>{i(n=>{const s=n.planner.getIn(["scene","selectedLayer"]);if(!s||!n.planner.getIn(["scene","layers",s,"holes",t]))return n;const a=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});return{...n,planner:Hole.remove(a,s,t).updatedState}})},fitViewerToScene:t=>{var I;const n=e().viewer;if(!n)return;const s=(t==null?void 0:t.animate)!==!1,a=e().planner.get("scene"),l=a.get("layers"),c=a.get("height");let u=1/0,h=1/0,d=-1/0,p=-1/0,f=!1;const g=(w,R)=>{typeof w!="number"||typeof R!="number"||!isFinite(w)||!isFinite(R)||(u=Math.min(u,w),h=Math.min(h,R),d=Math.max(d,w),p=Math.max(p,R),f=!0)};if(l.forEach(w=>{const R=w.get("vertices");w.get("lines").forEach(A=>{A.get("vertices").forEach(P=>{const B=R.get(P);B&&g(B.get("x"),B.get("y"))})}),w.get("items").forEach(A=>{g(A.get("x"),A.get("y"))})}),!f||!isFinite(u)){typeof n.fitToViewer=="function"&&n.fitToViewer();return}const _=Math.max(1,d-u),x=Math.max(1,p-h),y=Math.max(_,x)*.4+150;let E=u-y,b=c-p-y,v=_+y*2,M=x+y*2;const T=(I=n.getValue)==null?void 0:I.call(n);if(T&&T.viewerWidth&&T.viewerHeight){const w=T.viewerWidth/T.viewerHeight,R=v/M;if(w>R){const A=M*w;E-=(A-v)/2,v=A}else{const A=v/w;b-=(A-M)/2,M=A}}s?animateFitSelection(n,E,b,v,M):applyFitSelection(n,E,b,v,M)},focusOnArea:(t,n)=>{var T;const s=e().viewer;if(!s)return;const a=e().planner.get("scene"),l=a.get("height"),c=a.getIn(["layers",t]),u=c&&c.getIn(["areas",n]);if(!u)return;let h=1/0,d=1/0,p=-1/0,f=-1/0;if(u.get("vertices").forEach(I=>{const w=c.getIn(["vertices",I]);if(!w)return;const R=w.get("x"),A=w.get("y");typeof R!="number"||typeof A!="number"||(h=Math.min(h,R),d=Math.min(d,A),p=Math.max(p,R),f=Math.max(f,A))}),!isFinite(h))return;const g=Math.max(1,p-h),_=Math.max(1,f-d),x=Math.max(g,_)*.4+100;let y=h-x,E=l-f-x,b=g+x*2,v=_+x*2;const M=(T=s.getValue)==null?void 0:T.call(s);if(M&&M.viewerWidth&&M.viewerHeight){const I=M.viewerWidth/M.viewerHeight,w=b/v;if(I>w){const R=v*I;y-=(R-b)/2,b=R}else{const R=b/I;E-=(R-v)/2,v=R}}animateFitSelection(s,y,E,b,v)},addWallByCoords:(t,n,s,o)=>{let a;return i(l=>{var p,f;const c=l.planner.getIn(["scene","selectedLayer"]);if(!c)return l;const u=l.planner.merge({sceneHistory:historyPush(l.planner.sceneHistory,l.planner.scene)}),{updatedState:h,lines:d}=Line$2.createAvoidingIntersections(u,c,"wall",t,n,s,o);return a=(f=(p=d==null?void 0:d.last)==null?void 0:p.call(d))==null?void 0:f.id,{...l,planner:Layer$1.detectAndUpdateAreas(h,c).updatedState}}),a},addSurfaceByPoints:(t,n="surface")=>{i(s=>{const o=s.planner.getIn(["scene","selectedLayer"]);if(!o||!t||t.length<3)return s;const a=s.planner.getIn(["catalog","elements"]),l=a&&a.get(n);if(!l||l.get("prototype")!=="lines")return s;let c=s.planner.merge({sceneHistory:historyPush(s.planner.sceneHistory,s.planner.scene)});for(let u=0;u<t.length;u++){const h=t[u],d=t[(u+1)%t.length];!h||!d||(c=Line$2.createAvoidingIntersections(c,o,n,h.x,h.y,d.x,d.y).updatedState)}return c=Layer$1.detectAndUpdateAreas(c,o).updatedState,{...s,planner:c}})},addRoom:(t,n,s,o,a)=>{i(l=>{const c=l.planner.getIn(["scene","selectedLayer"]);if(!c)return l;const u=a&&(a.thickness!=null||a.height!=null)?fromJS({...a.thickness!=null&&{thickness:{length:a.thickness,_length:a.thickness,_unit:"cm"}},...a.height!=null&&{height:{length:a.height,_length:a.height,_unit:"cm"}}}):void 0;let h=l.planner.merge({sceneHistory:historyPush(l.planner.sceneHistory,l.planner.scene)});const d=[[t,n,s,n],[s,n,s,o],[s,o,t,o],[t,o,t,n]];for(const[p,f,g,_]of d)h=Line$2.createAvoidingIntersections(h,c,"wall",p,f,g,_,u).updatedState;return{...l,planner:Layer$1.detectAndUpdateAreas(h,c).updatedState}})},selectToolDrawingRoom:t=>{i(n=>({...n,planner:Room.selectToolDrawingRoom(exitingTools(n.planner),t).updatedState}))},updateRoomDrawingProperties:t=>{i(n=>{const s={};t.thickness!=null&&(s.thickness=t.thickness),t.height!=null&&(s.height=t.height);const o=n.planner.get("drawingSupport");return o?{...n,planner:n.planner.set("drawingSupport",o.merge(s))}:n})},beginDrawingRoom:(t,n,s)=>{i(o=>({...o,planner:Room.beginDrawingRoom(o.planner,t,n,s).updatedState}))},updateDrawingRoom:(t,n)=>{i(s=>({...s,planner:Room.updateDrawingRoom(s.planner,t,n).updatedState}))},endDrawingRoom:(t,n)=>{i(s=>({...s,planner:Room.endDrawingRoom(s.planner,t,n).updatedState}))},addItemByCoords:(t,n,s,o=200,a=100,l=0)=>{let c;return i(u=>{const h=u.planner.getIn(["scene","selectedLayer"]);if(!h)return u;const d=u.planner.merge({sceneHistory:historyPush(u.planner.sceneHistory,u.planner.scene)}),{updatedState:p,item:f}=Item$1.create(d,h,t,n,s,o,a,l,0);return c=f==null?void 0:f.id,{...u,planner:p}}),c}})),STYLE$4={stroke:"#1ca6fc",strokeWidth:"1px"};function Snap({snap:i,width:e,height:t}){switch(i.type){case"point":return jsxRuntimeExports.jsxs("g",{transform:`translate(${i.x} ${i.y})`,children:[jsxRuntimeExports.jsx("line",{x1:"0",y1:"-30",x2:"0",y2:"30",style:STYLE$4}),jsxRuntimeExports.jsx("line",{x1:"-30",y1:"0",x2:"30",y2:"0",style:STYLE$4})]});case"line":let n=horizontalLine(0),s=horizontalLine(t),o=twoLinesIntersection(i.a,i.b,i.c,n.a,n.b,n.c),a=twoLinesIntersection(i.a,i.b,i.c,s.a,s.b,s.c),l=verticalLine(0),c=verticalLine(e),u=twoLinesIntersection(i.a,i.b,i.c,l.a,l.b,l.c),h=twoLinesIntersection(i.a,i.b,i.c,c.a,c.b,c.c);return o&&a?jsxRuntimeExports.jsx("line",{x1:o.x,y1:o.y,x2:a.x,y2:a.y,style:STYLE$4}):u&&h?jsxRuntimeExports.jsx("line",{x1:u.x,y1:u.y,x2:h.x,y2:h.y,style:STYLE$4}):null;case"line-segment":return jsxRuntimeExports.jsx("line",{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,style:STYLE$4});default:return null}}const COLORS={white:"#FFFFFF",black:"#000000",wall:"#FFFFFF",threeBG:"#F1F0EE",canvasBG:"#F1F0EE"},MATERIAL_COLORS={500:{orange:"#FF9800"}},PRIMARY_COLOR={alt:"#2E2F33",text_main:COLORS.white},SECONDARY_COLOR={main:"#1CA6FC"},MESH_SELECTED="#99C3FB",AREA_MESH_COLOR={selected:MESH_SELECTED,unselected:"#F5EADA"},LINE_MESH_COLOR={selected:MESH_SELECTED},SharedStyle={COLORS,PRIMARY_COLOR,SECONDARY_COLOR,MESH_SELECTED,AREA_MESH_COLOR,LINE_MESH_COLOR};function areapolygon(i,e){var t=i.length,n=0;i=i.map(normalize$2),i[0]!=i[i.length-1]&&(i=i.concat(i[0]));for(var s=0;s<t;s++)n+=i[s].x*i[s+1].y-i[s].y*i[s+1].x;return Math.abs(n)/2}function normalize$2(i){return Array.isArray(i)?{x:i[0],y:i[1]}:i}const STYLE_TEXT$1={textAnchor:"middle",fontSize:"13px",fontFamily:'"Courier New", Courier, monospace',pointerEvents:"none",fontWeight:"bold",WebkitTouchCallout:"none",WebkitUserSelect:"none",MozUserSelect:"none",userSelect:"none"},STYLE_NAME={...STYLE_TEXT$1,fontSize:"18px",fontWeight:500,fontFamily:"inherit"};function Area({layer:i,area:e,catalog:t,part:n="fill"}){if(n==="fill")return jsxRuntimeExports.jsx("g",{"data-element-root":!0,"data-prototype":e.prototype,"data-id":e.id,"data-selected":e.selected,"data-layer":i.id,children:t.getElement(e.type).render2D(e,i)});const s=e.properties.get("customName")||"",o=e.properties.get("roomCategory"),a=e.properties.get("roomType"),l=e.properties.get("showName")??!0,c=e.properties.get("showSurfaceArea")??!1,u=s||getRoomTypeLabel(o,a),h=l&&!!u;if(!h&&!c)return null;const d=e.vertices.toArray().map(_=>{const{x,y}=i.vertices.get(_);return[x,y]});let p=d;e.holes.forEach(_=>{const x=i.areas.get(_).vertices.toArray().map(y=>{const{x:E,y:b}=i.vertices.get(y);return[E,b]});p=p.concat(x.reverse())});const f=polylabel([p],1);let g=areapolygon(d);return e.holes.forEach(_=>{const y=i.areas.get(_).vertices.toArray().map(E=>{const{x:b,y:v}=i.vertices.get(E);return[b,v]});g-=areapolygon(y)}),jsxRuntimeExports.jsxs("g",{pointerEvents:"none",children:[h&&jsxRuntimeExports.jsx("text",{x:"0",y:"0",transform:`translate(${f[0]} ${f[1]}) scale(1, -1)`,style:STYLE_NAME,children:u}),c&&jsxRuntimeExports.jsxs("text",{x:"0",y:"0",transform:`translate(${f[0]} ${f[1]-(h?20:0)}) scale(1, -1)`,style:STYLE_TEXT$1,children:[(g/1e4).toFixed(2)," m","²"]})]})}const cx=0,cy=0,radius=5,STYLE_CIRCLE={fill:MATERIAL_COLORS[500].orange,stroke:MATERIAL_COLORS[500].orange,cursor:"default"};function Group$1({layer:i,group:e}){return jsxRuntimeExports.jsx("g",{"data-element-root":!0,"data-prototype":e.prototype,"data-id":e.id,"data-selected":e.selected,"data-layer":i.id,style:e.selected?{cursor:"move"}:{},transform:`translate(${e.x},${e.y}) rotate(${e.rotation})`,children:e.selected&&jsxRuntimeExports.jsx("g",{"data-element-root":!0,"data-prototype":e.prototype,"data-id":e.id,"data-selected":e.selected,"data-layer":i.id,"data-part":"rotation-anchor",children:jsxRuntimeExports.jsx("circle",{cx,cy,r:radius,style:STYLE_CIRCLE,children:jsxRuntimeExports.jsx("title",{children:"Group's Barycenter"})})})})}const SOLID_ALPHA=96,MIN_COVERAGE=.02,MAX_SCAN_SIZE=192,cache=new Map,warned=new Set,warnOnce$1=i=>{warned.has(i)||(warned.add(i),console.warn(i))};function scan(i){return new Promise(e=>{const t=new Image;t.crossOrigin="anonymous",t.onerror=()=>{warnOnce$1(`[floor-planner] couldn't load "${i}" for snapping; items using it will snap to the edge of their image rather than to the object drawn in it.`),e(null)},t.onload=()=>{const n=t.naturalWidth,s=t.naturalHeight;if(!n||!s)return e(null);const o=Math.min(1,MAX_SCAN_SIZE/Math.max(n,s)),a=Math.max(1,Math.round(n*o)),l=Math.max(1,Math.round(s*o)),c=document.createElement("canvas");c.width=a,c.height=l;const u=c.getContext("2d",{willReadFrequently:!0});if(!u)return e(null);u.drawImage(t,0,0,a,l);let h;try{h=u.getImageData(0,0,a,l).data}catch{return warnOnce$1(`[floor-planner] can't measure "${i}" for snapping: the image is cross-origin and served without an Access-Control-Allow-Origin header, so items using it snap to the edge of their image rather than to the object drawn in it.`),e(null)}const d=new Uint32Array(a),p=new Uint32Array(l);for(let x=0;x<l;x++)for(let y=0;y<a;y++)h[(x*a+y)*4+3]<SOLID_ALPHA||(d[y]++,p[x]++);const f=(x,y)=>{const E=Math.max(1,Math.round(y*MIN_COVERAGE));let b=-1,v=-1;for(let M=0;M<x.length;M++)x[M]<E||(b<0&&(b=M),v=M);return{first:b,last:v}},g=f(d,l),_=f(p,a);if(g.first<0||_.first<0)return e(null);e({left:g.first/a,top:_.first/l,right:(g.last+1)/a,bottom:(_.last+1)/l,naturalWidth:n,naturalHeight:s})},t.src=i})}function measure(i){let e=cache.get(i);return e||(e=scan(i),cache.set(i,e)),e}function fitRect(i,e,t,n){const s=n.trim().split(/\s+/).filter(Boolean),o=s.find(p=>p.startsWith("x")||p==="none"),a=s.find(p=>p==="meet"||p==="slice");if(o==="none")return i;if(a==="slice")return null;const l=Math.min(i.width/e,i.height/t),c=e*l,u=t*l,h=o??"xMidYMid",d=(p,f,g)=>g==="Min"?0:g==="Max"?p-f:(p-f)/2;return{x:i.x+d(i.width,c,h.slice(1,4)),y:i.y+d(i.height,u,h.slice(5,8)),width:c,height:u}}async function visibleImageRect(i,e,t){const n=await measure(i);if(!n)return null;const s=fitRect(e,n.naturalWidth,n.naturalHeight,t);return s?{x:s.x+n.left*s.width,y:s.y+n.top*s.height,width:(n.right-n.left)*s.width,height:(n.bottom-n.top)*s.height}:null}const HANDLE_COLOR$1="var(--dark-blue, #1ca6fc)",ROTATE_GAP=26,ROTATE_ARC_HALF_WIDTH=14,ROTATE_ARC_BULGE=8,ROTATE_DOT_RADIUS=5,ROTATE_HIT_RADIUS=16,ARROW_SIZE=5,RESIZE_HANDLE_SIZE=9,NAME_GAP=12,NAME_FONT_SIZE=13,NAME_STYLE={textAnchor:"middle",fontFamily:"'Courier New', Courier, monospace",fontWeight:"bold",fill:"#3A3A3C",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none"};async function trimmedFootprint(i){const e=i.querySelectorAll("image");if(e.length!==1)return null;const t=e[0],n=t.getAttribute("href")??t.getAttribute("xlink:href");if(!n)return null;let s,o;try{s=t.getBBox();const p=i.getCTM(),f=t.getCTM();if(!p||!f)return null;o=p.inverse().multiply(f)}catch{return null}const a=await visibleImageRect(n,s,t.getAttribute("preserveAspectRatio")??"");if(!a)return null;const l=[new DOMPoint(a.x,a.y),new DOMPoint(a.x+a.width,a.y),new DOMPoint(a.x+a.width,a.y+a.height),new DOMPoint(a.x,a.y+a.height)].map(p=>p.matrixTransform(o)),c=l.map(p=>p.x),u=l.map(p=>p.y),h=Math.min(...c),d=Math.min(...u);return{x:h,y:d,width:Math.max(...c)-h,height:Math.max(...u)-d}}const arrowPoints=(i,e,t,n,s)=>{const o=Math.hypot(t,n)||1,a=t/o,l=n/o,c=-l,u=a;return[`${i+a*s},${e+l*s}`,`${i-a*s*.3+c*s*.75},${e-l*s*.3+u*s*.75}`,`${i-a*s*.3-c*s*.75},${e-l*s*.3-u*s*.75}`].join(" ")};function Item({layer:i,item:e,scene:t,catalog:n}){var A;const{x:s,y:o,rotation:a}=e,l=useReactPlannerStore(P=>P.planner.zoom||P.planner.viewer2D.get("a")||1),c=useReactPlannerStore(P=>P.resizeHandlesFor),u=React.useRef(null),[h,d]=React.useState(null),{scale:p,flipHorizontal:f,flipVertical:g}=getItemTransform(e),_=p*(f?-1:1),x=p*(g?-1:1);React.useLayoutEffect(()=>{if(!u.current)return;let P;try{P=u.current.getBBox()}catch{return}const B={x:P.x,y:P.y,width:P.width,height:P.height};rememberItemFootprint(e.id,B),d(k=>k&&k.x===B.x&&k.y===B.y&&k.width===B.width&&k.height===B.height?k:B)},[e.id,e.type,_,x]),React.useEffect(()=>{const P=u.current;if(!P||!h)return;let B=!1;return trimmedFootprint(P).then(k=>{!B&&k&&rememberItemFootprint(e.id,k)}),()=>{B=!0}},[e.id,e.type,_,x,h]),React.useEffect(()=>()=>forgetItemFootprint(e.id),[e.id]);const y=n.getElement(e.type).render2D(e,i,t),E={"data-element-root":!0,"data-prototype":e.prototype,"data-id":e.id,"data-selected":e.selected,"data-layer":i.id},b=l>0?1/l:1,v=e.selected&&h!==null,M=(A=e.properties)!=null&&A.get("showName")?e.properties.get("customName")||e.name:null,T=v&&c===e.id,I=h?h.y-ROTATE_GAP*b:0,w=ROTATE_ARC_HALF_WIDTH*b,R=ROTATE_ARC_BULGE*b;return jsxRuntimeExports.jsxs("g",{style:e.selected?{cursor:"move"}:{},transform:`translate(${s},${o}) rotate(${a})`,children:[jsxRuntimeExports.jsx("g",{ref:u,children:jsxRuntimeExports.jsx("g",{...E,transform:`scale(${_},${x})`,children:y})}),M&&h&&jsxRuntimeExports.jsx("text",{x:0,y:-(h.y-NAME_GAP*b),transform:"scale(1,-1)",style:{...NAME_STYLE,fontSize:NAME_FONT_SIZE*b},children:M}),v&&jsxRuntimeExports.jsxs("g",{...E,"data-part":"rotation-anchor",children:[jsxRuntimeExports.jsx("path",{d:`M ${-w},${I} Q 0,${I-R} ${w},${I}`,fill:"none",stroke:HANDLE_COLOR$1,strokeWidth:2*b,strokeLinecap:"round"}),jsxRuntimeExports.jsx("polygon",{points:arrowPoints(-w,I,-w,R,ARROW_SIZE*b),fill:HANDLE_COLOR$1}),jsxRuntimeExports.jsx("polygon",{points:arrowPoints(w,I,w,R,ARROW_SIZE*b),fill:HANDLE_COLOR$1}),jsxRuntimeExports.jsx("circle",{cx:0,cy:I-R/2,r:ROTATE_DOT_RADIUS*b,fill:HANDLE_COLOR$1}),jsxRuntimeExports.jsx("circle",{cx:0,cy:I-R/2,r:ROTATE_HIT_RADIUS*b,fill:"transparent",style:{cursor:"grab"}})]}),T&&h&&[[h.x,h.y,"nesw-resize"],[h.x+h.width,h.y,"nwse-resize"],[h.x+h.width,h.y+h.height,"nesw-resize"],[h.x,h.y+h.height,"nwse-resize"]].map(([P,B,k],W)=>jsxRuntimeExports.jsx("rect",{...E,"data-part":"resize-anchor",x:P-RESIZE_HANDLE_SIZE/2*b,y:B-RESIZE_HANDLE_SIZE/2*b,width:RESIZE_HANDLE_SIZE*b,height:RESIZE_HANDLE_SIZE*b,rx:1.5*b,fill:"#ffffff",stroke:HANDLE_COLOR$1,strokeWidth:1.5*b,style:{cursor:k}},W))]})}const metric$a={mm:{name:{singular:"Millimeter",plural:"Millimeters"},to_anchor:1/1e3},cm:{name:{singular:"Centimeter",plural:"Centimeters"},to_anchor:1/100},m:{name:{singular:"Meter",plural:"Meters"},to_anchor:1},km:{name:{singular:"Kilometer",plural:"Kilometers"},to_anchor:1e3}},imperial$8={in:{name:{singular:"Inch",plural:"Inches"},to_anchor:1/12},yd:{name:{singular:"Yard",plural:"Yards"},to_anchor:3},"ft-us":{name:{singular:"US Survey Foot",plural:"US Survey Feet"},to_anchor:1.000002},ft:{name:{singular:"Foot",plural:"Feet"},to_anchor:1},mi:{name:{singular:"Mile",plural:"Miles"},to_anchor:5280}},length={metric:metric$a,imperial:imperial$8,_anchors:{metric:{unit:"m",ratio:3.28084},imperial:{unit:"ft",ratio:1/3.28084}}},metric$9={mm2:{name:{singular:"Square Millimeter",plural:"Square Millimeters"},to_anchor:1/1e6},cm2:{name:{singular:"Centimeter",plural:"Centimeters"},to_anchor:1/1e4},m2:{name:{singular:"Square Meter",plural:"Square Meters"},to_anchor:1},ha:{name:{singular:"Hectare",plural:"Hectares"},to_anchor:1e4},km2:{name:{singular:"Square Kilometer",plural:"Square Kilometers"},to_anchor:1e6}},imperial$7={in2:{name:{singular:"Square Inch",plural:"Square Inches"},to_anchor:1/144},yd2:{name:{singular:"Square Yard",plural:"Square Yards"},to_anchor:9},ft2:{name:{singular:"Square Foot",plural:"Square Feet"},to_anchor:1},ac:{name:{singular:"Acre",plural:"Acres"},to_anchor:43560},mi2:{name:{singular:"Square Mile",plural:"Square Miles"},to_anchor:27878400}},area$1={metric:metric$9,imperial:imperial$7,_anchors:{metric:{unit:"m2",ratio:10.7639},imperial:{unit:"ft2",ratio:1/10.7639}}},metric$8={mcg:{name:{singular:"Microgram",plural:"Micrograms"},to_anchor:1/1e6},mg:{name:{singular:"Milligram",plural:"Milligrams"},to_anchor:1/1e3},g:{name:{singular:"Gram",plural:"Grams"},to_anchor:1},kg:{name:{singular:"Kilogram",plural:"Kilograms"},to_anchor:1e3},mt:{name:{singular:"Metric Tonne",plural:"Metric Tonnes"},to_anchor:1e6}},imperial$6={oz:{name:{singular:"Ounce",plural:"Ounces"},to_anchor:1/16},lb:{name:{singular:"Pound",plural:"Pounds"},to_anchor:1},t:{name:{singular:"Ton",plural:"Tons"},to_anchor:2e3}},mass={metric:metric$8,imperial:imperial$6,_anchors:{metric:{unit:"g",ratio:1/453.592},imperial:{unit:"lb",ratio:453.592}}},metric$7={mm3:{name:{singular:"Cubic Millimeter",plural:"Cubic Millimeters"},to_anchor:1/1e6},cm3:{name:{singular:"Cubic Centimeter",plural:"Cubic Centimeters"},to_anchor:1/1e3},ml:{name:{singular:"Millilitre",plural:"Millilitres"},to_anchor:1/1e3},cl:{name:{singular:"Centilitre",plural:"Centilitres"},to_anchor:1/100},dl:{name:{singular:"Decilitre",plural:"Decilitres"},to_anchor:1/10},l:{name:{singular:"Litre",plural:"Litres"},to_anchor:1},kl:{name:{singular:"Kilolitre",plural:"Kilolitres"},to_anchor:1e3},m3:{name:{singular:"Cubic meter",plural:"Cubic meters"},to_anchor:1e3},km3:{name:{singular:"Cubic kilometer",plural:"Cubic kilometers"},to_anchor:1e12},krm:{name:{singular:"Matsked",plural:"Matskedar"},to_anchor:1/1e3},tsk:{name:{singular:"Tesked",plural:"Teskedar"},to_anchor:5/1e3},msk:{name:{singular:"Matsked",plural:"Matskedar"},to_anchor:15/1e3},kkp:{name:{singular:"Kaffekopp",plural:"Kaffekoppar"},to_anchor:150/1e3},glas:{name:{singular:"Glas",plural:"Glas"},to_anchor:200/1e3},kanna:{name:{singular:"Kanna",plural:"Kannor"},to_anchor:2.617}},imperial$5={tsp:{name:{singular:"Teaspoon",plural:"Teaspoons"},to_anchor:1/6},Tbs:{name:{singular:"Tablespoon",plural:"Tablespoons"},to_anchor:1/2},in3:{name:{singular:"Cubic inch",plural:"Cubic inches"},to_anchor:.55411},"fl-oz":{name:{singular:"Fluid Ounce",plural:"Fluid Ounces"},to_anchor:1},cup:{name:{singular:"Cup",plural:"Cups"},to_anchor:8},pnt:{name:{singular:"Pint",plural:"Pints"},to_anchor:16},qt:{name:{singular:"Quart",plural:"Quarts"},to_anchor:32},gal:{name:{singular:"Gallon",plural:"Gallons"},to_anchor:128},ft3:{name:{singular:"Cubic foot",plural:"Cubic feet"},to_anchor:957.506},yd3:{name:{singular:"Cubic yard",plural:"Cubic yards"},to_anchor:25852.7}},volume={metric:metric$7,imperial:imperial$5,_anchors:{metric:{unit:"l",ratio:33.8140226},imperial:{unit:"fl-oz",ratio:1/33.8140226}}},metric$6={ea:{name:{singular:"Each",plural:"Each"},to_anchor:1},dz:{name:{singular:"Dozen",plural:"Dozens"},to_anchor:12}},each={metric:metric$6,imperial:{},_anchors:{metric:{unit:"ea",ratio:1}}},metric$5={C:{name:{singular:"degree Celsius",plural:"degrees Celsius"},to_anchor:1,anchor_shift:0},K:{name:{singular:"degree Kelvin",plural:"degrees Kelvin"},to_anchor:1,anchor_shift:273.15}},imperial$4={F:{name:{singular:"degree Fahrenheit",plural:"degrees Fahrenheit"},to_anchor:1},R:{name:{singular:"degree Rankine",plural:"degrees Rankine"},to_anchor:1,anchor_shift:459.67}},temperature={metric:metric$5,imperial:imperial$4,_anchors:{metric:{unit:"C",transform:function(i){return i/(5/9)+32}},imperial:{unit:"F",transform:function(i){return(i-32)*(5/9)}}}},daysInYear=365.25,time={ns:{name:{singular:"Nanosecond",plural:"Nanoseconds"},to_anchor:1/1e9},mu:{name:{singular:"Microsecond",plural:"Microseconds"},to_anchor:1/1e6},ms:{name:{singular:"Millisecond",plural:"Milliseconds"},to_anchor:1/1e3},s:{name:{singular:"Second",plural:"Seconds"},to_anchor:1},min:{name:{singular:"Minute",plural:"Minutes"},to_anchor:60},h:{name:{singular:"Hour",plural:"Hours"},to_anchor:3600},d:{name:{singular:"Day",plural:"Days"},to_anchor:3600*24},week:{name:{singular:"Week",plural:"Weeks"},to_anchor:3600*24*7},month:{name:{singular:"Month",plural:"Months"},to_anchor:3600*24*daysInYear/12},year:{name:{singular:"Year",plural:"Years"},to_anchor:3600*24*daysInYear}},time$1={metric:time,_anchors:{metric:{unit:"s",ratio:1}}},bits={b:{name:{singular:"Bit",plural:"Bits"},to_anchor:1},Kb:{name:{singular:"Kilobit",plural:"Kilobits"},to_anchor:1024},Mb:{name:{singular:"Megabit",plural:"Megabits"},to_anchor:1048576},Gb:{name:{singular:"Gigabit",plural:"Gigabits"},to_anchor:1073741824},Tb:{name:{singular:"Terabit",plural:"Terabits"},to_anchor:1099511627776}},bytes={B:{name:{singular:"Byte",plural:"Bytes"},to_anchor:1},KB:{name:{singular:"Kilobyte",plural:"Kilobytes"},to_anchor:1024},MB:{name:{singular:"Megabyte",plural:"Megabytes"},to_anchor:1048576},GB:{name:{singular:"Gigabyte",plural:"Gigabytes"},to_anchor:1073741824},TB:{name:{singular:"Terabyte",plural:"Terabytes"},to_anchor:1099511627776}},digital={bits,bytes,_anchors:{bits:{unit:"b",ratio:1/8},bytes:{unit:"B",ratio:8}}},metric$4={ppm:{name:{singular:"Part-per Million",plural:"Parts-per Million"},to_anchor:1},ppb:{name:{singular:"Part-per Billion",plural:"Parts-per Billion"},to_anchor:.001},ppt:{name:{singular:"Part-per Trillion",plural:"Parts-per Trillion"},to_anchor:1e-6},ppq:{name:{singular:"Part-per Quadrillion",plural:"Parts-per Quadrillion"},to_anchor:1e-9}},partsPer={metric:metric$4,imperial:{},_anchors:{metric:{unit:"ppm",ratio:1e-6}}},metric$3={"m/s":{name:{singular:"Metre per second",plural:"Metres per second"},to_anchor:3.6},"km/h":{name:{singular:"Kilometre per hour",plural:"Kilometres per hour"},to_anchor:1}},imperial$3={"m/h":{name:{singular:"Mile per hour",plural:"Miles per hour"},to_anchor:1},knot:{name:{singular:"Knot",plural:"Knots"},to_anchor:1.150779},"ft/s":{name:{singular:"Foot per second",plural:"Feet per second"},to_anchor:.681818}},speed={metric:metric$3,imperial:imperial$3,_anchors:{metric:{unit:"km/h",ratio:1/1.609344},imperial:{unit:"m/h",ratio:1.609344}}},metric$2={Pa:{name:{singular:"pascal",plural:"pascals"},to_anchor:1/1e3},kPa:{name:{singular:"kilopascal",plural:"kilopascals"},to_anchor:1},MPa:{name:{singular:"megapascal",plural:"megapascals"},to_anchor:1e3},hPa:{name:{singular:"hectopascal",plural:"hectopascals"},to_anchor:1/10},bar:{name:{singular:"bar",plural:"bar"},to_anchor:100},torr:{name:{singular:"torr",plural:"torr"},to_anchor:101325/76e4}},imperial$2={psi:{name:{singular:"pound per square inch",plural:"pounds per square inch"},to_anchor:1/1e3},ksi:{name:{singular:"kilopound per square inch",plural:"kilopound per square inch"},to_anchor:1}},pressure={metric:metric$2,imperial:imperial$2,_anchors:{metric:{unit:"kPa",ratio:.00014503768078},imperial:{unit:"psi",ratio:1/.00014503768078}}},current={A:{name:{singular:"Ampere",plural:"Amperes"},to_anchor:1},mA:{name:{singular:"Milliampere",plural:"Milliamperes"},to_anchor:.001},kA:{name:{singular:"Kiloampere",plural:"Kiloamperes"},to_anchor:1e3}},current$1={metric:current,_anchors:{metric:{unit:"A",ratio:1}}},voltage={V:{name:{singular:"Volt",plural:"Volts"},to_anchor:1},mV:{name:{singular:"Millivolt",plural:"Millivolts"},to_anchor:.001},kV:{name:{singular:"Kilovolt",plural:"Kilovolts"},to_anchor:1e3}},voltage$1={metric:voltage,_anchors:{metric:{unit:"V",ratio:1}}},power={W:{name:{singular:"Watt",plural:"Watts"},to_anchor:1},mW:{name:{singular:"Milliwatt",plural:"Milliwatts"},to_anchor:.001},kW:{name:{singular:"Kilowatt",plural:"Kilowatts"},to_anchor:1e3},MW:{name:{singular:"Megawatt",plural:"Megawatts"},to_anchor:1e6},GW:{name:{singular:"Gigawatt",plural:"Gigawatts"},to_anchor:1e9}},power$1={metric:power,_anchors:{metric:{unit:"W",ratio:1}}},reactivePower={VAR:{name:{singular:"Volt-Ampere Reactive",plural:"Volt-Amperes Reactive"},to_anchor:1},mVAR:{name:{singular:"Millivolt-Ampere Reactive",plural:"Millivolt-Amperes Reactive"},to_anchor:.001},kVAR:{name:{singular:"Kilovolt-Ampere Reactive",plural:"Kilovolt-Amperes Reactive"},to_anchor:1e3},MVAR:{name:{singular:"Megavolt-Ampere Reactive",plural:"Megavolt-Amperes Reactive"},to_anchor:1e6},GVAR:{name:{singular:"Gigavolt-Ampere Reactive",plural:"Gigavolt-Amperes Reactive"},to_anchor:1e9}},reactivePower$1={metric:reactivePower,_anchors:{metric:{unit:"VAR",ratio:1}}},apparentPower={VA:{name:{singular:"Volt-Ampere",plural:"Volt-Amperes"},to_anchor:1},mVA:{name:{singular:"Millivolt-Ampere",plural:"Millivolt-Amperes"},to_anchor:.001},kVA:{name:{singular:"Kilovolt-Ampere",plural:"Kilovolt-Amperes"},to_anchor:1e3},MVA:{name:{singular:"Megavolt-Ampere",plural:"Megavolt-Amperes"},to_anchor:1e6},GVA:{name:{singular:"Gigavolt-Ampere",plural:"Gigavolt-Amperes"},to_anchor:1e9}},apparentPower$1={metric:apparentPower,_anchors:{metric:{unit:"VA",ratio:1}}},energy={Wh:{name:{singular:"Watt-hour",plural:"Watt-hours"},to_anchor:3600},mWh:{name:{singular:"Milliwatt-hour",plural:"Milliwatt-hours"},to_anchor:3.6},kWh:{name:{singular:"Kilowatt-hour",plural:"Kilowatt-hours"},to_anchor:36e5},MWh:{name:{singular:"Megawatt-hour",plural:"Megawatt-hours"},to_anchor:36e8},GWh:{name:{singular:"Gigawatt-hour",plural:"Gigawatt-hours"},to_anchor:36e11},J:{name:{singular:"Joule",plural:"Joules"},to_anchor:1},kJ:{name:{singular:"Kilojoule",plural:"Kilojoules"},to_anchor:1e3}},energy$1={metric:energy,_anchors:{metric:{unit:"J",ratio:1}}},reactiveEnergy={VARh:{name:{singular:"Volt-Ampere Reactive Hour",plural:"Volt-Amperes Reactive Hour"},to_anchor:1},mVARh:{name:{singular:"Millivolt-Ampere Reactive Hour",plural:"Millivolt-Amperes Reactive Hour"},to_anchor:.001},kVARh:{name:{singular:"Kilovolt-Ampere Reactive Hour",plural:"Kilovolt-Amperes Reactive Hour"},to_anchor:1e3},MVARh:{name:{singular:"Megavolt-Ampere Reactive Hour",plural:"Megavolt-Amperes Reactive Hour"},to_anchor:1e6},GVARh:{name:{singular:"Gigavolt-Ampere Reactive Hour",plural:"Gigavolt-Amperes Reactive Hour"},to_anchor:1e9}},reactiveEnergy$1={metric:reactiveEnergy,_anchors:{metric:{unit:"VARh",ratio:1}}},metric$1={"mm3/s":{name:{singular:"Cubic Millimeter per second",plural:"Cubic Millimeters per second"},to_anchor:1/1e6},"cm3/s":{name:{singular:"Cubic Centimeter per second",plural:"Cubic Centimeters per second"},to_anchor:1/1e3},"ml/s":{name:{singular:"Millilitre per second",plural:"Millilitres per second"},to_anchor:1/1e3},"cl/s":{name:{singular:"Centilitre per second",plural:"Centilitres per second"},to_anchor:1/100},"dl/s":{name:{singular:"Decilitre per second",plural:"Decilitres per second"},to_anchor:1/10},"l/s":{name:{singular:"Litre per second",plural:"Litres per second"},to_anchor:1},"l/min":{name:{singular:"Litre per minute",plural:"Litres per minute"},to_anchor:1/60},"l/h":{name:{singular:"Litre per hour",plural:"Litres per hour"},to_anchor:1/3600},"kl/s":{name:{singular:"Kilolitre per second",plural:"Kilolitres per second"},to_anchor:1e3},"kl/min":{name:{singular:"Kilolitre per minute",plural:"Kilolitres per minute"},to_anchor:50/3},"kl/h":{name:{singular:"Kilolitre per hour",plural:"Kilolitres per hour"},to_anchor:5/18},"m3/s":{name:{singular:"Cubic meter per second",plural:"Cubic meters per second"},to_anchor:1e3},"m3/min":{name:{singular:"Cubic meter per minute",plural:"Cubic meters per minute"},to_anchor:50/3},"m3/h":{name:{singular:"Cubic meter per hour",plural:"Cubic meters per hour"},to_anchor:5/18},"km3/s":{name:{singular:"Cubic kilometer per second",plural:"Cubic kilometers per second"},to_anchor:1e12}},imperial$1={"tsp/s":{name:{singular:"Teaspoon per second",plural:"Teaspoons per second"},to_anchor:1/6},"Tbs/s":{name:{singular:"Tablespoon per second",plural:"Tablespoons per second"},to_anchor:1/2},"in3/s":{name:{singular:"Cubic inch per second",plural:"Cubic inches per second"},to_anchor:.55411},"in3/min":{name:{singular:"Cubic inch per minute",plural:"Cubic inches per minute"},to_anchor:.55411/60},"in3/h":{name:{singular:"Cubic inch per hour",plural:"Cubic inches per hour"},to_anchor:.55411/3600},"fl-oz/s":{name:{singular:"Fluid Ounce per second",plural:"Fluid Ounces per second"},to_anchor:1},"fl-oz/min":{name:{singular:"Fluid Ounce per minute",plural:"Fluid Ounces per minute"},to_anchor:1/60},"fl-oz/h":{name:{singular:"Fluid Ounce per hour",plural:"Fluid Ounces per hour"},to_anchor:1/3600},"cup/s":{name:{singular:"Cup per second",plural:"Cups per second"},to_anchor:8},"pnt/s":{name:{singular:"Pint per second",plural:"Pints per second"},to_anchor:16},"pnt/min":{name:{singular:"Pint per minute",plural:"Pints per minute"},to_anchor:4/15},"pnt/h":{name:{singular:"Pint per hour",plural:"Pints per hour"},to_anchor:1/225},"qt/s":{name:{singular:"Quart per second",plural:"Quarts per second"},to_anchor:32},"gal/s":{name:{singular:"Gallon per second",plural:"Gallons per second"},to_anchor:128},"gal/min":{name:{singular:"Gallon per minute",plural:"Gallons per minute"},to_anchor:32/15},"gal/h":{name:{singular:"Gallon per hour",plural:"Gallons per hour"},to_anchor:8/225},"ft3/s":{name:{singular:"Cubic foot per second",plural:"Cubic feet per second"},to_anchor:957.506},"ft3/min":{name:{singular:"Cubic foot per minute",plural:"Cubic feet per minute"},to_anchor:957.506/60},"ft3/h":{name:{singular:"Cubic foot per hour",plural:"Cubic feet per hour"},to_anchor:957.506/3600},"yd3/s":{name:{singular:"Cubic yard per second",plural:"Cubic yards per second"},to_anchor:25852.7},"yd3/min":{name:{singular:"Cubic yard per minute",plural:"Cubic yards per minute"},to_anchor:25852.7/60},"yd3/h":{name:{singular:"Cubic yard per hour",plural:"Cubic yards per hour"},to_anchor:25852.7/3600}},volumeFlowRate={metric:metric$1,imperial:imperial$1,_anchors:{metric:{unit:"l/s",ratio:33.8140227},imperial:{unit:"fl-oz/s",ratio:1/33.8140227}}},metric={lx:{name:{singular:"Lux",plural:"Lux"},to_anchor:1}},imperial={"ft-cd":{name:{singular:"Foot-candle",plural:"Foot-candles"},to_anchor:1}},illuminance={metric,imperial,_anchors:{metric:{unit:"lx",ratio:1/10.76391},imperial:{unit:"ft-cd",ratio:10.76391}}},frequency={mHz:{name:{singular:"millihertz",plural:"millihertz"},to_anchor:1/1e3},Hz:{name:{singular:"hertz",plural:"hertz"},to_anchor:1},kHz:{name:{singular:"kilohertz",plural:"kilohertz"},to_anchor:1e3},MHz:{name:{singular:"megahertz",plural:"megahertz"},to_anchor:1e3*1e3},GHz:{name:{singular:"gigahertz",plural:"gigahertz"},to_anchor:1e3*1e3*1e3},THz:{name:{singular:"terahertz",plural:"terahertz"},to_anchor:1e3*1e3*1e3*1e3},rpm:{name:{singular:"rotation per minute",plural:"rotations per minute"},to_anchor:1/60},"deg/s":{name:{singular:"degree per second",plural:"degrees per second"},to_anchor:1/360},"rad/s":{name:{singular:"radian per second",plural:"radians per second"},to_anchor:1/(Math.PI*2)}},frequency$1={metric:frequency,_anchors:{frequency:{unit:"hz",ratio:1}}},measures={length,area:area$1,mass,volume,each,temperature,time:time$1,digital,partsPer,speed,pressure,current:current$1,voltage:voltage$1,power:power$1,reactivePower:reactivePower$1,apparentPower:apparentPower$1,energy:energy$1,reactiveEnergy:reactiveEnergy$1,volumeFlowRate,illuminance,frequency:frequency$1};function _keys(i){return Object.keys(i)}function _describe(i){return{abbr:i.abbr,measure:i.measure,system:i.system,singular:i.unit.name.singular,plural:i.unit.name.plural}}function _each(i,e){if(Array.isArray(i))for(let t=0;t<i.length;t++)e(i[t],t,i);else if(i&&typeof i=="object")for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&e(i[t],t,i)}class Converter{constructor(e,t){ze(this,"val");ze(this,"destination");ze(this,"origin");this.val=t?e/t:e}from(e){if(this.destination)throw new Error(".from must be called before .to");return this.origin=this.getUnit(e),this.origin||this.throwUnsupportedUnitError(e),this}to(e){if(!this.origin)throw new Error(".to must be called after .from");if(this.destination=this.getUnit(e),this.destination||this.throwUnsupportedUnitError(e),this.origin.abbr===this.destination.abbr)return this.val;if(this.destination.measure!==this.origin.measure)throw new Error(`Cannot convert incompatible measures of ${this.destination.measure} and ${this.origin.measure}`);let t=this.val*this.origin.unit.to_anchor;if(this.origin.unit.anchor_shift&&(t-=this.origin.unit.anchor_shift),this.origin.system!==this.destination.system){const n=measures[this.origin.measure]._anchors[this.origin.system];t=typeof n.transform=="function"?n.transform(t):t*n.ratio}return this.destination.unit.anchor_shift&&(t+=this.destination.unit.anchor_shift),t/this.destination.unit.to_anchor}toBest(e){if(!this.origin)throw new Error(".toBest must be called after .from");const t={exclude:[],cutOffNumber:1,...e};let n=null;return _each(this.possibilities(),s=>{if(t.exclude.includes(s))return;const o=this.describe(s);if(o.system!==this.origin.system)return;const a=this.to(s);(!n||a>=t.cutOffNumber&&a<n.val)&&(n={val:a,unit:s,singular:o.singular,plural:o.plural})}),n}getUnit(e){let t=null;return _each(measures,(n,s)=>{_each(n,(o,a)=>{a!=="_anchors"&&_each(o,(l,c)=>{c===e&&(t={abbr:e,measure:s,system:a,unit:l})})})}),t}describe(e){const t=this.getUnit(e);return t||this.throwUnsupportedUnitError(e),_describe(t)}list(e){const t=[];return _each(measures,(n,s)=>{e&&e!==s||_each(n,(o,a)=>{a!=="_anchors"&&_each(o,(l,c)=>{t.push(_describe({abbr:c,measure:s,system:a,unit:l}))})})}),t}throwUnsupportedUnitError(e){const t=[];throw _each(measures,n=>{_each(n,(s,o)=>{o!=="_anchors"&&t.push(..._keys(s))})}),new Error(`Unsupported unit ${e}, use one of: ${t.join(", ")}`)}possibilities(e){const t=[];if(!this.origin&&!e)_each(_keys(measures),n=>{_each(measures[n],(s,o)=>{o!=="_anchors"&&t.push(..._keys(s))})});else{const n=e||this.origin.measure;_each(measures[n],(s,o)=>{o!=="_anchors"&&t.push(..._keys(s))})}return t}measures(){return _keys(measures)}}function convert(i){return new Converter(i)}const STYLE$3={stroke:"#0096fd",strokeWidth:1},STYLE_TEXT={textAnchor:"middle",fontSize:15,fontFamily:"'Courier New', Courier, monospace",pointerEvents:"none",fontWeight:"bold",userSelect:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none",MozUserSelect:"none"},formatDistance=(i,e)=>e===UNIT_CENTIMETER?`${i.toFixed(2)} ${e}`:e==="ft"?formatArchitectural(i):`${convert(i).from(UNIT_CENTIMETER).to(e).toFixed(2)} ${e}`,formatArchitectural=i=>{const e=convert(i).from(UNIT_CENTIMETER).to("in");let t=Math.floor(e/12),n=Math.floor(e%12);const s=Math.round(e%1*8);let o="";return s===8?n+=1:s>0&&(o=` ${{1:"1/8",2:"1/4",3:"3/8",4:"1/2",5:"5/8",6:"3/4",7:"7/8"}[s]}`),n===12&&(t+=1,n=0),`${t}' ${n}${o}"`};function Ruler({length:i,unit:e,transform:t,labelPlacement:n="above"}){const s=React.useMemo(()=>formatDistance(i,e),[i,e]),o=React.useMemo(()=>`M0,-5 L0,5 M${i},-5 L${i},5 M0,0 L${i},0`,[i]),a=n==="below"?24:-12;return jsxRuntimeExports.jsxs("g",{transform:t,children:[jsxRuntimeExports.jsx("text",{x:i/2,y:a,transform:"scale(1,-1)",style:STYLE_TEXT,children:s}),jsxRuntimeExports.jsx("path",{d:o,style:STYLE$3})]})}const Ruler$1=React.memo(Ruler),RULER_GAP=10,HOLE_NAME_GAP=16,HOLE_NAME_STYLE={textAnchor:"middle",fontSize:13,fontFamily:"'Courier New', Courier, monospace",fontWeight:"bold",fill:"#3A3A3C",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none"},Line$1=({line:i,layer:e,scene:t,catalog:n,mode:s,showDimensions:o})=>{const a=useReactPlannerStore(B=>{var k;return((k=B.hoveredElement)==null?void 0:k.lineID)===i.id}),l=useReactPlannerStore(B=>{var k,W;return((k=B.hoveredElement)==null?void 0:k.lineID)===i.id&&((W=B.hoveredElement)==null?void 0:W.prototype)==="vertices"}),c=useReactPlannerStore(B=>{var k;return B.planner.mode===MODE_DRAGGING_VERTEX?((k=B.planner.draggingSupport)==null?void 0:k.get("vertexID"))??null:null});let u=e.vertices.get(i.vertices.get(0)),h=e.vertices.get(i.vertices.get(1));if(u.id===h.id||samePoints(u,h))return null;let{x:d,y:p}=u,{x:f,y:g}=h;d>f&&({x:d,y:p}=h,{x:f,y:g}=u);let _=pointsDistance(d,p,f,g),x=angleBetweenTwoPointsAndOrigin(d,p,f,g);const y=i.getIn(["properties","thickness","length"])??0;let E=i.holes.map(B=>{var G;let k=e.holes.get(B),W=_*k.offset,Y=n.getElement(k.type).render2D(k,e,t);const $=(G=k.properties)!=null&&G.get("showName")?k.properties.get("customName")||k.name:null,ee=k.flipAlongWall?" scale(-1, 1)":"";return jsxRuntimeExports.jsxs("g",{children:[jsxRuntimeExports.jsx("g",{transform:`translate(${W}, 0)${ee}`,"data-element-root":!0,"data-prototype":k.prototype,"data-id":k.id,"data-selected":k.selected,"data-layer":e.id,children:Y}),$&&jsxRuntimeExports.jsx("g",{transform:`translate(${W}, ${-(y/2+HOLE_NAME_GAP)})`,children:jsxRuntimeExports.jsx("text",{transform:"scale(1,-1)",style:HOLE_NAME_STYLE,children:$})})]},B)}),b=i.getIn(["properties","thickness","length"])??0,v=b/2;const M=a&&!l&&!i.selected;let T=n.getElement(i.type).render2D(M?i.set("selected",!0):i,e,t,s);const I=a&&(s===MODE_DRAGGING_LINE||s===MODE_DRAGGING_VERTEX),w=c!==null&&i.vertices.includes(c),R=i.selected||o||w||a&&(!l||I),A=R&&b>0?wallGeometry(i,e):null,P=R?A?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[A.topEnd>A.topStart&&jsxRuntimeExports.jsx(Ruler$1,{unit:t.unit,length:A.topEnd-A.topStart,transform:`translate(${A.topStart}, ${v+RULER_GAP})`}),A.botEnd>A.botStart&&jsxRuntimeExports.jsx(Ruler$1,{unit:t.unit,length:A.botEnd-A.botStart,transform:`translate(${A.botStart}, ${-(v+RULER_GAP)})`,labelPlacement:"below"})]}):jsxRuntimeExports.jsx(Ruler$1,{unit:t.unit,length:_,transform:`translate(0, ${v+RULER_GAP} )`}):null;return jsxRuntimeExports.jsxs("g",{transform:`translate(${d}, ${p}) rotate(${x}, 0, 0)`,"data-element-root":!0,"data-prototype":i.prototype,"data-id":i.id,"data-selected":i.selected,"data-layer":e.id,style:i.selected||a?{cursor:"move"}:{},children:[P,T,E]})},STYLE$2={fill:"#0096fd",stroke:SharedStyle.COLORS.white,cursor:"move"},Vertex$1=({vertex:i,layer:e})=>{const t=useReactPlannerStore(n=>{var s,o;return((s=n.hoveredElement)==null?void 0:s.prototype)==="vertices"&&((o=n.hoveredElement)==null?void 0:o.id)===i.id});return jsxRuntimeExports.jsx("g",{transform:`translate(${i.x}, ${i.y})`,"data-element-root":!0,"data-prototype":i.prototype,"data-id":i.id,"data-selected":i.selected,"data-layer":e.id,children:jsxRuntimeExports.jsx("circle",{cx:"0",cy:"0",r:t?10:7,style:STYLE$2})})},HANDLE_COLOR="var(--dark-blue, #1ca6fc)",HANDLE_RADIUS=3,HANDLE_HOVER_RADIUS=11,HANDLE_HIT_RADIUS=15;function WallHoverHandles({layer:i}){const e=useReactPlannerStore(l=>l.hoveredElement),t=useReactPlannerStore(l=>l.planner.zoom||l.planner.viewer2D.get("a")||1);if(!e||e.layerID!==i.id||!e.lineID)return null;const n=i.lines.get(e.lineID);if(!n||n.selected)return null;const s=t>0?1/t:1,o=e.prototype==="vertices"?e.id:null,a=o?[o]:n.vertices.toArray();return jsxRuntimeExports.jsx("g",{children:a.map(l=>{const c=i.vertices.get(l);if(!c)return null;const u=o===l;return jsxRuntimeExports.jsxs("g",{transform:`translate(${c.x}, ${c.y})`,"data-element-root":!0,"data-prototype":"vertices","data-id":c.id,"data-selected":c.selected,"data-layer":i.id,"data-line":n.id,style:{cursor:"move"},children:[jsxRuntimeExports.jsx("circle",{cx:0,cy:0,r:HANDLE_HIT_RADIUS*s,fill:"transparent"}),jsxRuntimeExports.jsx("circle",{cx:0,cy:0,r:(u?HANDLE_HOVER_RADIUS:HANDLE_RADIUS)*s,fill:u?HANDLE_COLOR:"#ffffff",stroke:u?"none":HANDLE_COLOR,strokeWidth:1.5*s})]},l)})})}const SPOTLIGHT_EXTENT=4e6,SPOTLIGHT_FILL="#ffffff",SPOTLIGHT_OPACITY=.5,AREA_INSET=5;function signedArea$1(i){let e=0;for(let t=0;t<i.length;t++){const n=i[t],s=i[(t+1)%i.length];e+=n.x*s.y-s.x*n.y}return e/2}function insetPolygon(i,e){const t=i.length;if(t<3)return i;const n=signedArea$1(i)>0?1:-1,s=[];for(let o=0;o<t;o++){const a=i[(o-1+t)%t],l=i[o],c=i[(o+1)%t],u=l.x-a.x,h=l.y-a.y,d=c.x-l.x,p=c.y-l.y,f=Math.hypot(u,h)||1,g=Math.hypot(d,p)||1,_=-h/f*n,x=u/f*n,y=-p/g*n,E=d/g*n,b=_+y,v=x+E,M=Math.hypot(b,v);if(M<1e-6){s.push({x:l.x+_*e,y:l.y+x*e});continue}const T=(_*b+x*v)/M,I=e/Math.max(T,.15);s.push({x:l.x+b/M*I,y:l.y+v/M*I})}return s}function Layer({layer:i,scene:e,catalog:t,mode:n,showDimensions:s}){var E,b;const{groups:o}=e,{lines:a,areas:l,vertices:c,id:u,items:h,opacity:d}=i,p=[];(b=(E=i.get("selected"))==null?void 0:E.get("areas"))==null||b.forEach(v=>p.push(v));const f=p.length>0,g=new Map;if(f)for(const v of p){const M=l.get(v);if(!M)continue;const T=M.get("vertices").toArray().map(P=>c.get(P)).filter(Boolean).map(P=>({x:P.get("x"),y:P.get("y")}));if(T.length<3)continue;const w=getAreaKind(M,i)==="Room"?AREA_INSET:0,A=(w>0?insetPolygon(T,w):T).map(P=>`${P.x},${P.y}`).join(" ");A&&g.set(v,A)}const _=`fp-focus-mask-${u}`,x=`fp-focus-clip-${u}`,y=l.valueSeq().toArray().sort((v,M)=>+(getAreaKind(v,i)==="Surface")-+(getAreaKind(M,i)==="Surface"));return jsxRuntimeExports.jsxs("g",{opacity:d,children:[f&&jsxRuntimeExports.jsxs("defs",{children:[jsxRuntimeExports.jsxs("mask",{id:_,children:[jsxRuntimeExports.jsx("rect",{x:-SPOTLIGHT_EXTENT,y:-SPOTLIGHT_EXTENT,width:SPOTLIGHT_EXTENT*2,height:SPOTLIGHT_EXTENT*2,fill:"white"}),Array.from(g.entries()).map(([v,M])=>jsxRuntimeExports.jsx("polygon",{points:M,fill:"black"},v))]}),jsxRuntimeExports.jsx("clipPath",{id:x,children:Array.from(g.entries()).map(([v,M])=>jsxRuntimeExports.jsx("polygon",{points:M},v))})]}),y.map(v=>jsxRuntimeExports.jsx(Area,{part:"fill",layer:i,area:v,catalog:t},v.id)),y.map(v=>jsxRuntimeExports.jsx(Area,{part:"label",layer:i,area:v,catalog:t},`label-${v.id}`)),a.valueSeq().map(v=>jsxRuntimeExports.jsx(Line$1,{mode:n,showDimensions:s,layer:i,line:v,scene:e,catalog:t},v.id)),h.valueSeq().map(v=>jsxRuntimeExports.jsx(Item,{layer:i,item:v,scene:e,catalog:t},v.id)),c.valueSeq().filter(v=>v.selected).map(v=>jsxRuntimeExports.jsx(Vertex$1,{layer:i,vertex:v},v.id)),o.valueSeq().filter(v=>v.hasIn(["elements",u])&&v.get("selected")).map(v=>jsxRuntimeExports.jsx(Group$1,{layer:i,group:v,scene:e,catalog:t},v.get("id"))),f&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("rect",{x:-SPOTLIGHT_EXTENT,y:-SPOTLIGHT_EXTENT,width:SPOTLIGHT_EXTENT*3,height:SPOTLIGHT_EXTENT*2,fill:SPOTLIGHT_FILL,opacity:SPOTLIGHT_OPACITY,mask:`url(#${_})`,pointerEvents:"none"}),jsxRuntimeExports.jsx("g",{clipPath:`url(#${x})`,children:Array.from(g.entries()).map(([v,M])=>jsxRuntimeExports.jsx("polygon",{points:M,fill:"none",stroke:"var(--dark-blue, #1ca6fc)",strokeWidth:6,vectorEffect:"non-scaling-stroke",pointerEvents:"none"},`sel-${v}`))})]}),jsxRuntimeExports.jsx(WallHoverHandles,{layer:i})]})}const Scene$1=({scene:i,catalog:e,mode:t,showDimensions:n})=>{const{layers:s}=i,o=s.get(i.selectedLayer);return jsxRuntimeExports.jsxs("g",{children:[jsxRuntimeExports.jsx("g",{style:{pointerEvents:"none"},children:s.entrySeq().filter(([a,l])=>a!==i.selectedLayer&&l.visible).map(([a,l])=>jsxRuntimeExports.jsx(Layer,{mode:t,layer:l,scene:i,showDimensions:n,catalog:e},a))}),jsxRuntimeExports.jsx(Layer,{mode:t,layer:o,scene:i,showDimensions:n,catalog:e},o.id)]})},Scene$2=React.memo(Scene$1,(i,e)=>i.scene.hashCode()===e.scene.hashCode()&&i.mode===e.mode&&i.showDimensions===e.showDimensions),HUGE=4e6;function Grids({scene:i}){var u,h,d,p;const e=i.get?i.get("grids"):i.grids,t=((u=e==null?void 0:e.first)==null?void 0:u.call(e))??((p=(h=e==null?void 0:e.valueSeq)==null?void 0:(d=h.call(e)).first)==null?void 0:p.call(d));if(!t)return null;const n=t.properties,s=n.get("step")||20;let o;if(n.has("color"))o=[n.get("color")];else{const f=n.get("colors");o=f&&typeof f.toArray=="function"?f.toArray():f||[]}o.length===0&&(o=["#808080","#dddddd"]);const a=o[0],l=o[1]??o[0],c=s*o.length;return jsxRuntimeExports.jsxs("g",{pointerEvents:"none",children:[jsxRuntimeExports.jsxs("defs",{children:[jsxRuntimeExports.jsx("pattern",{id:"fp-grid-minor",width:s,height:s,patternUnits:"userSpaceOnUse",children:jsxRuntimeExports.jsx("path",{d:`M ${s} 0 L 0 0 0 ${s}`,fill:"none",stroke:l,strokeWidth:1,vectorEffect:"non-scaling-stroke"})}),jsxRuntimeExports.jsxs("pattern",{id:"fp-grid-major",width:c,height:c,patternUnits:"userSpaceOnUse",children:[jsxRuntimeExports.jsx("rect",{width:c,height:c,fill:"url(#fp-grid-minor)"}),jsxRuntimeExports.jsx("path",{d:`M ${c} 0 L 0 0 0 ${c}`,fill:"none",stroke:a,strokeWidth:1,vectorEffect:"non-scaling-stroke"})]})]}),jsxRuntimeExports.jsx("rect",{x:-HUGE,y:-HUGE,width:HUGE*2,height:HUGE*2,fill:"url(#fp-grid-major)"})]})}const guideStyle={stroke:SharedStyle.SECONDARY_COLOR.main,strokeWidth:"2.5px"},State=({catalog:i})=>{const{planner:e,showDimensions:t,showGrid:n}=useReactPlannerStore(),{activeSnapElement:s,snapElements:o,scene:a,mode:l,drawingSupport:c,itemSnapGuides:u}=e,{width:h,height:d}=a,p=e.zoom||e.viewer2D.get("a")||1,f=l===MODE_DRAWING_ROOM?{x0:c.get("startX"),y0:c.get("startY"),x1:c.get("currentX"),y1:c.get("currentY"),thickness:c.get("thickness")??15}:null;return jsxRuntimeExports.jsxs("g",{children:[n&&jsxRuntimeExports.jsx(Grids,{scene:a}),jsxRuntimeExports.jsxs("g",{transform:`translate(0, ${a.height}) scale(1, -1)`,id:"svg-drawing-paper",children:[jsxRuntimeExports.jsx(Scene$2,{scene:a,mode:l,catalog:i,showDimensions:t}),a.getIn(["guides","horizontal"]).entrySeq().map(([g,_])=>jsxRuntimeExports.jsx("line",{id:"hGuide"+g,x1:0,y1:_,x2:h,y2:_,style:guideStyle},g)),a.getIn(["guides","vertical"]).entrySeq().map(([g,_])=>jsxRuntimeExports.jsx("line",{x1:_,y1:0,x2:_,y2:d,style:guideStyle},g)),s?jsxRuntimeExports.jsx(Snap,{snap:s,width:a.width,height:a.height}):null,o?null:jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{}),u==null?void 0:u.map((g,_)=>jsxRuntimeExports.jsx(ItemSnapGuide,{guide:g,zoom:p},_)),f&&jsxRuntimeExports.jsx(RoomPreview,{preview:f,unit:a.unit})]})]})},ItemSnapGuide=({guide:i,zoom:e})=>{const t=e>0?1/e:1;return jsxRuntimeExports.jsx("line",{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:"var(--dark-blue, #1ca6fc)",strokeWidth:3*t,strokeDasharray:`${8*t} ${6*t}`,strokeLinecap:"butt",pointerEvents:"none"})},RoomPreview=({preview:i,unit:e})=>{const t=Math.min(i.x0,i.x1),n=Math.max(i.x0,i.x1),s=Math.min(i.y0,i.y1),o=Math.max(i.y0,i.y1),a=n-t,l=o-s;if(a<=0||l<=0)return null;const c=i.thickness,u=c/2+12;return jsxRuntimeExports.jsxs("g",{pointerEvents:"none",children:[jsxRuntimeExports.jsx("rect",{x:t,y:s,width:a,height:l,fill:"none",stroke:SharedStyle.COLORS.black,strokeWidth:c,strokeLinejoin:"miter"}),jsxRuntimeExports.jsx(DimensionLabel,{length:a,unit:e,transform:`translate(${t+a/2}, ${s-u})`}),jsxRuntimeExports.jsx(DimensionLabel,{length:a,unit:e,transform:`translate(${t+a/2}, ${o+u})`}),jsxRuntimeExports.jsx(DimensionLabel,{length:l,unit:e,transform:`translate(${n+u}, ${s+l/2}) rotate(90)`}),jsxRuntimeExports.jsx(DimensionLabel,{length:l,unit:e,transform:`translate(${t-u}, ${s+l/2}) rotate(-90)`})]})},LABEL_STYLE={textAnchor:"middle",dominantBaseline:"middle",fontSize:14,fontFamily:"'Courier New', Courier, monospace",fontWeight:"bold",fill:SharedStyle.COLORS.black,pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none"},DimensionLabel=({length:i,unit:e,transform:t})=>jsxRuntimeExports.jsx("g",{transform:t,children:jsxRuntimeExports.jsx("text",{transform:"scale(1,-1)",style:LABEL_STYLE,children:formatDistance(i,e)})}),MIN_ZOOM=.25,MAX_ZOOM=5,SVG_MIN_ZOOM=.25,SVG_MAX_ZOOM=5;var DefaultContext={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},IconContext=React.createContext&&React.createContext(DefaultContext),_excluded=["attr","size","title"];function _objectWithoutProperties(i,e){if(i==null)return{};var t=_objectWithoutPropertiesLoose(i,e),n,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(i);for(s=0;s<o.length;s++)n=o[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(i,n)&&(t[n]=i[n])}return t}function _objectWithoutPropertiesLoose(i,e){if(i==null)return{};var t={};for(var n in i)if(Object.prototype.hasOwnProperty.call(i,n)){if(e.indexOf(n)>=0)continue;t[n]=i[n]}return t}function _extends(){return _extends=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},_extends.apply(this,arguments)}function ownKeys(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,n)}return t}function _objectSpread(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ownKeys(Object(t),!0).forEach(function(n){_defineProperty(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function _defineProperty(i,e,t){return e=_toPropertyKey(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function _toPropertyKey(i){var e=_toPrimitive(i,"string");return typeof e=="symbol"?e:e+""}function _toPrimitive(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function Tree2Element(i){return i&&i.map((e,t)=>React.createElement(e.tag,_objectSpread({key:t},e.attr),Tree2Element(e.child)))}function GenIcon(i){return e=>React.createElement(IconBase,_extends({attr:_objectSpread({},i.attr)},e),Tree2Element(i.child))}function IconBase(i){var e=t=>{var{attr:n,size:s,title:o}=i,a=_objectWithoutProperties(i,_excluded),l=s||t.size||"1em",c;return t.className&&(c=t.className),i.className&&(c=(c?c+" ":"")+i.className),React.createElement("svg",_extends({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,n,a,{className:c,style:_objectSpread(_objectSpread({color:i.color||t.color},t.style),i.style),height:l,width:l,xmlns:"http://www.w3.org/2000/svg"}),o&&React.createElement("title",null,o),i.children)};return IconContext!==void 0?React.createElement(IconContext.Consumer,null,t=>e(t)):e(DefaultContext)}function LuArrowUp(i){return GenIcon({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"m5 12 7-7 7 7"},child:[]},{tag:"path",attr:{d:"M12 19V5"},child:[]}]})(i)}function LuBot(i){return GenIcon({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 8V4H8"},child:[]},{tag:"rect",attr:{width:"16",height:"12",x:"4",y:"8",rx:"2"},child:[]},{tag:"path",attr:{d:"M2 14h2"},child:[]},{tag:"path",attr:{d:"M20 14h2"},child:[]},{tag:"path",attr:{d:"M15 13v2"},child:[]},{tag:"path",attr:{d:"M9 13v2"},child:[]}]})(i)}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 LuCopy(i){return GenIcon({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"},child:[]},{tag:"path",attr:{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"},child:[]}]})(i)}function LuMic(i){return GenIcon({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"},child:[]},{tag:"path",attr:{d:"M19 10v2a7 7 0 0 1-14 0v-2"},child:[]},{tag:"line",attr:{x1:"12",x2:"12",y1:"19",y2:"22"},child:[]}]})(i)}function LuRotateCcw(i){return GenIcon({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"},child:[]},{tag:"path",attr:{d:"M3 3v5h5"},child:[]}]})(i)}function LuRotateCw(i){return GenIcon({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"},child:[]},{tag:"path",attr:{d:"M21 3v5h-5"},child:[]}]})(i)}function LuSquare(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:[]}]})(i)}function LuTrash2(i){return GenIcon({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3 6h18"},child:[]},{tag:"path",attr:{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"},child:[]},{tag:"path",attr:{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"},child:[]},{tag:"line",attr:{x1:"10",x2:"10",y1:"11",y2:"17"},child:[]},{tag:"line",attr:{x1:"14",x2:"14",y1:"11",y2:"17"},child:[]}]})(i)}function MdUpdate(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M21 10.12h-6.78l2.74-2.82c-2.73-2.7-7.15-2.8-9.88-.1-2.73 2.71-2.73 7.08 0 9.79s7.15 2.71 9.88 0C18.32 15.65 19 14.08 19 12.1h2c0 1.98-.88 4.55-2.64 6.29-3.51 3.48-9.21 3.48-12.72 0-3.5-3.47-3.53-9.11-.02-12.58s9.14-3.47 12.65 0L21 3v7.12zM12.5 8v4.25l3.5 2.08-.72 1.21L11 13V8h1.5z"},child:[]}]})(i)}function MdNavigateBefore(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M15.41 7.41 14 6l-6 6 6 6 1.41-1.41L10.83 12z"},child:[]}]})(i)}function MdMyLocation(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm8.94 3A8.994 8.994 0 0 0 13 3.06V1h-2v2.06A8.994 8.994 0 0 0 3.06 11H1v2h2.06A8.994 8.994 0 0 0 11 20.94V23h2v-2.06A8.994 8.994 0 0 0 20.94 13H23v-2h-2.06zM12 19c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z"},child:[]}]})(i)}function MdArrowBack(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"},child:[]}]})(i)}function MdOutlinePhotoSizeSelectSmall(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M23 15h-2v2h2v-2zm0-4h-2v2h2v-2zm0 8h-2v2c1 0 2-1 2-2zM15 3h-2v2h2V3zm8 4h-2v2h2V7zm-2-4v2h2c0-1-1-2-2-2zM3 21h8v-6H1v4c0 1.1.9 2 2 2zM3 7H1v2h2V7zm12 12h-2v2h2v-2zm4-16h-2v2h2V3zm0 16h-2v2h2v-2zM3 3C2 3 1 4 1 5h2V3zm0 8H1v2h2v-2zm8-8H9v2h2V3zM7 3H5v2h2V3z"},child:[]}]})(i)}function MdOutlineChair(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M20 8V6c0-1.65-1.35-3-3-3H7C5.35 3 4 4.35 4 6v2c-1.65 0-3 1.35-3 3v5c0 1.65 1.35 3 3 3v1c0 .55.45 1 1 1s1-.45 1-1v-1h12v1c0 .55.45 1 1 1s1-.45 1-1v-1c1.65 0 3-1.35 3-3v-5c0-1.65-1.35-3-3-3zM6 6c0-.55.45-1 1-1h10c.55 0 1 .45 1 1v2.78c-.61.55-1 1.34-1 2.22v2H7v-2c0-.88-.39-1.67-1-2.22V6zm15 10c0 .55-.45 1-1 1H4c-.55 0-1-.45-1-1v-5c0-.55.45-1 1-1s1 .45 1 1v4h14v-4c0-.55.45-1 1-1s1 .45 1 1v5z"},child:[]}]})(i)}function MdOutlineDoorFront(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M19 19V5c0-1.1-.9-2-2-2H7c-1.1 0-2 .9-2 2v14H3v2h18v-2h-2zm-2 0H7V5h10v14zm-4-8h2v2h-2v-2z"},child:[]}]})(i)}function MdOutlineWindow(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 8h-6V5h6v6zm-8-6v6H5V5h6zm-6 8h6v6H5v-6zm8 6v-6h6v6h-6z"},child:[]}]})(i)}function PiFlipHorizontalBold(i){return GenIcon({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M104,20.41a19.83,19.83,0,0,0-22.4,11.81c-.07.15-.13.31-.19.46L21.47,192.49A20,20,0,0,0,40,220h60a20,20,0,0,0,20-20V40A19.83,19.83,0,0,0,104,20.41ZM96,196H45.79L96,62.09Zm138.53-3.51L174.61,32.68c-.06-.15-.12-.31-.19-.46A20,20,0,0,0,136,40V200a20,20,0,0,0,20,20h60a20,20,0,0,0,18.54-27.51ZM160,196V62.09L210.21,196Z"},child:[]}]})(i)}function PiFlipVerticalBold(i){return GenIcon({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M56,120H216a20,20,0,0,0,7.79-38.42l-.46-.19L63.51,21.47A20,20,0,0,0,36,40v60A20,20,0,0,0,56,120Zm4-74.21L193.91,96H60ZM216,136H56a20,20,0,0,0-20,20v60a20,20,0,0,0,27.51,18.54l159.81-59.92.46-.19A20,20,0,0,0,216,136ZM60,210.22V160H193.91Z"},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)}function r(i){var e,t,n="";if(typeof i=="string"||typeof i=="number")n+=i;else if(typeof i=="object")if(Array.isArray(i)){var s=i.length;for(e=0;e<s;e++)i[e]&&(t=r(i[e]))&&(n&&(n+=" "),n+=t)}else for(t in i)i[t]&&(n&&(n+=" "),n+=t);return n}function clsx(){for(var i,e,t=0,n="",s=arguments.length;t<s;t++)(i=arguments[t])&&(e=r(i))&&(n&&(n+=" "),n+=e);return n}const CLASS_PART_SEPARATOR="-",createClassGroupUtils=i=>{const e=createClassMap(i),{conflictingClassGroups:t,conflictingClassGroupModifiers:n}=i;return{getClassGroupId:a=>{const l=a.split(CLASS_PART_SEPARATOR);return l[0]===""&&l.length!==1&&l.shift(),getGroupRecursive(l,e)||getGroupIdForArbitraryProperty(a)},getConflictingClassGroupIds:(a,l)=>{const c=t[a]||[];return l&&n[a]?[...c,...n[a]]:c}}},getGroupRecursive=(i,e)=>{var a;if(i.length===0)return e.classGroupId;const t=i[0],n=e.nextPart.get(t),s=n?getGroupRecursive(i.slice(1),n):void 0;if(s)return s;if(e.validators.length===0)return;const o=i.join(CLASS_PART_SEPARATOR);return(a=e.validators.find(({validator:l})=>l(o)))==null?void 0:a.classGroupId},arbitraryPropertyRegex=/^\[(.+)\]$/,getGroupIdForArbitraryProperty=i=>{if(arbitraryPropertyRegex.test(i)){const e=arbitraryPropertyRegex.exec(i)[1],t=e==null?void 0:e.substring(0,e.indexOf(":"));if(t)return"arbitrary.."+t}},createClassMap=i=>{const{theme:e,classGroups:t}=i,n={nextPart:new Map,validators:[]};for(const s in t)processClassesRecursively(t[s],n,s,e);return n},processClassesRecursively=(i,e,t,n)=>{i.forEach(s=>{if(typeof s=="string"){const o=s===""?e:getPart(e,s);o.classGroupId=t;return}if(typeof s=="function"){if(isThemeGetter(s)){processClassesRecursively(s(n),e,t,n);return}e.validators.push({validator:s,classGroupId:t});return}Object.entries(s).forEach(([o,a])=>{processClassesRecursively(a,getPart(e,o),t,n)})})},getPart=(i,e)=>{let t=i;return e.split(CLASS_PART_SEPARATOR).forEach(n=>{t.nextPart.has(n)||t.nextPart.set(n,{nextPart:new Map,validators:[]}),t=t.nextPart.get(n)}),t},isThemeGetter=i=>i.isThemeGetter,createLruCache=i=>{if(i<1)return{get:()=>{},set:()=>{}};let e=0,t=new Map,n=new Map;const s=(o,a)=>{t.set(o,a),e++,e>i&&(e=0,n=t,t=new Map)};return{get(o){let a=t.get(o);if(a!==void 0)return a;if((a=n.get(o))!==void 0)return s(o,a),a},set(o,a){t.has(o)?t.set(o,a):s(o,a)}}},IMPORTANT_MODIFIER="!",MODIFIER_SEPARATOR=":",MODIFIER_SEPARATOR_LENGTH=MODIFIER_SEPARATOR.length,createParseClassName=i=>{const{prefix:e,experimentalParseClassName:t}=i;let n=s=>{const o=[];let a=0,l=0,c=0,u;for(let g=0;g<s.length;g++){let _=s[g];if(a===0&&l===0){if(_===MODIFIER_SEPARATOR){o.push(s.slice(c,g)),c=g+MODIFIER_SEPARATOR_LENGTH;continue}if(_==="/"){u=g;continue}}_==="["?a++:_==="]"?a--:_==="("?l++:_===")"&&l--}const h=o.length===0?s:s.substring(c),d=stripImportantModifier(h),p=d!==h,f=u&&u>c?u-c:void 0;return{modifiers:o,hasImportantModifier:p,baseClassName:d,maybePostfixModifierPosition:f}};if(e){const s=e+MODIFIER_SEPARATOR,o=n;n=a=>a.startsWith(s)?o(a.substring(s.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:a,maybePostfixModifierPosition:void 0}}if(t){const s=n;n=o=>t({className:o,parseClassName:s})}return n},stripImportantModifier=i=>i.endsWith(IMPORTANT_MODIFIER)?i.substring(0,i.length-1):i.startsWith(IMPORTANT_MODIFIER)?i.substring(1):i,createSortModifiers=i=>{const e=Object.fromEntries(i.orderSensitiveModifiers.map(n=>[n,!0]));return n=>{if(n.length<=1)return n;const s=[];let o=[];return n.forEach(a=>{a[0]==="["||e[a]?(s.push(...o.sort(),a),o=[]):o.push(a)}),s.push(...o.sort()),s}},createConfigUtils=i=>({cache:createLruCache(i.cacheSize),parseClassName:createParseClassName(i),sortModifiers:createSortModifiers(i),...createClassGroupUtils(i)}),SPLIT_CLASSES_REGEX=/\s+/,mergeClassList=(i,e)=>{const{parseClassName:t,getClassGroupId:n,getConflictingClassGroupIds:s,sortModifiers:o}=e,a=[],l=i.trim().split(SPLIT_CLASSES_REGEX);let c="";for(let u=l.length-1;u>=0;u-=1){const h=l[u],{isExternal:d,modifiers:p,hasImportantModifier:f,baseClassName:g,maybePostfixModifierPosition:_}=t(h);if(d){c=h+(c.length>0?" "+c:c);continue}let x=!!_,y=n(x?g.substring(0,_):g);if(!y){if(!x){c=h+(c.length>0?" "+c:c);continue}if(y=n(g),!y){c=h+(c.length>0?" "+c:c);continue}x=!1}const E=o(p).join(":"),b=f?E+IMPORTANT_MODIFIER:E,v=b+y;if(a.includes(v))continue;a.push(v);const M=s(y,x);for(let T=0;T<M.length;++T){const I=M[T];a.push(b+I)}c=h+(c.length>0?" "+c:c)}return c};function twJoin(){let i=0,e,t,n="";for(;i<arguments.length;)(e=arguments[i++])&&(t=toValue(e))&&(n&&(n+=" "),n+=t);return n}const toValue=i=>{if(typeof i=="string")return i;let e,t="";for(let n=0;n<i.length;n++)i[n]&&(e=toValue(i[n]))&&(t&&(t+=" "),t+=e);return t};function createTailwindMerge(i,...e){let t,n,s,o=a;function a(c){const u=e.reduce((h,d)=>d(h),i());return t=createConfigUtils(u),n=t.cache.get,s=t.cache.set,o=l,l(c)}function l(c){const u=n(c);if(u)return u;const h=mergeClassList(c,t);return s(c,h),h}return function(){return o(twJoin.apply(null,arguments))}}const fromTheme=i=>{const e=t=>t[i]||[];return e.isThemeGetter=!0,e},arbitraryValueRegex=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,arbitraryVariableRegex=/^\((?:(\w[\w-]*):)?(.+)\)$/i,fractionRegex=/^\d+\/\d+$/,tshirtUnitRegex=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,lengthUnitRegex=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,colorFunctionRegex=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,shadowRegex=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,imageRegex=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,isFraction=i=>fractionRegex.test(i),isNumber=i=>!!i&&!Number.isNaN(Number(i)),isInteger=i=>!!i&&Number.isInteger(Number(i)),isPercent=i=>i.endsWith("%")&&isNumber(i.slice(0,-1)),isTshirtSize=i=>tshirtUnitRegex.test(i),isAny=()=>!0,isLengthOnly=i=>lengthUnitRegex.test(i)&&!colorFunctionRegex.test(i),isNever=()=>!1,isShadow=i=>shadowRegex.test(i),isImage=i=>imageRegex.test(i),isAnyNonArbitrary=i=>!isArbitraryValue(i)&&!isArbitraryVariable(i),isArbitrarySize=i=>getIsArbitraryValue(i,isLabelSize,isNever),isArbitraryValue=i=>arbitraryValueRegex.test(i),isArbitraryLength=i=>getIsArbitraryValue(i,isLabelLength,isLengthOnly),isArbitraryNumber=i=>getIsArbitraryValue(i,isLabelNumber,isNumber),isArbitraryPosition=i=>getIsArbitraryValue(i,isLabelPosition,isNever),isArbitraryImage=i=>getIsArbitraryValue(i,isLabelImage,isImage),isArbitraryShadow=i=>getIsArbitraryValue(i,isLabelShadow,isShadow),isArbitraryVariable=i=>arbitraryVariableRegex.test(i),isArbitraryVariableLength=i=>getIsArbitraryVariable(i,isLabelLength),isArbitraryVariableFamilyName=i=>getIsArbitraryVariable(i,isLabelFamilyName),isArbitraryVariablePosition=i=>getIsArbitraryVariable(i,isLabelPosition),isArbitraryVariableSize=i=>getIsArbitraryVariable(i,isLabelSize),isArbitraryVariableImage=i=>getIsArbitraryVariable(i,isLabelImage),isArbitraryVariableShadow=i=>getIsArbitraryVariable(i,isLabelShadow,!0),getIsArbitraryValue=(i,e,t)=>{const n=arbitraryValueRegex.exec(i);return n?n[1]?e(n[1]):t(n[2]):!1},getIsArbitraryVariable=(i,e,t=!1)=>{const n=arbitraryVariableRegex.exec(i);return n?n[1]?e(n[1]):t:!1},isLabelPosition=i=>i==="position"||i==="percentage",isLabelImage=i=>i==="image"||i==="url",isLabelSize=i=>i==="length"||i==="size"||i==="bg-size",isLabelLength=i=>i==="length",isLabelNumber=i=>i==="number",isLabelFamilyName=i=>i==="family-name",isLabelShadow=i=>i==="shadow",getDefaultConfig=()=>{const i=fromTheme("color"),e=fromTheme("font"),t=fromTheme("text"),n=fromTheme("font-weight"),s=fromTheme("tracking"),o=fromTheme("leading"),a=fromTheme("breakpoint"),l=fromTheme("container"),c=fromTheme("spacing"),u=fromTheme("radius"),h=fromTheme("shadow"),d=fromTheme("inset-shadow"),p=fromTheme("text-shadow"),f=fromTheme("drop-shadow"),g=fromTheme("blur"),_=fromTheme("perspective"),x=fromTheme("aspect"),y=fromTheme("ease"),E=fromTheme("animate"),b=()=>["auto","avoid","all","avoid-page","page","left","right","column"],v=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],M=()=>[...v(),isArbitraryVariable,isArbitraryValue],T=()=>["auto","hidden","clip","visible","scroll"],I=()=>["auto","contain","none"],w=()=>[isArbitraryVariable,isArbitraryValue,c],R=()=>[isFraction,"full","auto",...w()],A=()=>[isInteger,"none","subgrid",isArbitraryVariable,isArbitraryValue],P=()=>["auto",{span:["full",isInteger,isArbitraryVariable,isArbitraryValue]},isInteger,isArbitraryVariable,isArbitraryValue],B=()=>[isInteger,"auto",isArbitraryVariable,isArbitraryValue],k=()=>["auto","min","max","fr",isArbitraryVariable,isArbitraryValue],W=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],Y=()=>["start","end","center","stretch","center-safe","end-safe"],$=()=>["auto",...w()],ee=()=>[isFraction,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...w()],G=()=>[i,isArbitraryVariable,isArbitraryValue],K=()=>[...v(),isArbitraryVariablePosition,isArbitraryPosition,{position:[isArbitraryVariable,isArbitraryValue]}],F=()=>["no-repeat",{repeat:["","x","y","space","round"]}],X=()=>["auto","cover","contain",isArbitraryVariableSize,isArbitrarySize,{size:[isArbitraryVariable,isArbitraryValue]}],se=()=>[isPercent,isArbitraryVariableLength,isArbitraryLength],me=()=>["","none","full",u,isArbitraryVariable,isArbitraryValue],Me=()=>["",isNumber,isArbitraryVariableLength,isArbitraryLength],j=()=>["solid","dashed","dotted","double"],ie=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Z=()=>[isNumber,isPercent,isArbitraryVariablePosition,isArbitraryPosition],ue=()=>["","none",g,isArbitraryVariable,isArbitraryValue],be=()=>["none",isNumber,isArbitraryVariable,isArbitraryValue],re=()=>["none",isNumber,isArbitraryVariable,isArbitraryValue],Fe=()=>[isNumber,isArbitraryVariable,isArbitraryValue],oe=()=>[isFraction,"full",...w()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[isTshirtSize],breakpoint:[isTshirtSize],color:[isAny],container:[isTshirtSize],"drop-shadow":[isTshirtSize],ease:["in","out","in-out"],font:[isAnyNonArbitrary],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[isTshirtSize],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[isTshirtSize],shadow:[isTshirtSize],spacing:["px",isNumber],text:[isTshirtSize],"text-shadow":[isTshirtSize],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",isFraction,isArbitraryValue,isArbitraryVariable,x]}],container:["container"],columns:[{columns:[isNumber,isArbitraryValue,isArbitraryVariable,l]}],"break-after":[{"break-after":b()}],"break-before":[{"break-before":b()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:M()}],overflow:[{overflow:T()}],"overflow-x":[{"overflow-x":T()}],"overflow-y":[{"overflow-y":T()}],overscroll:[{overscroll:I()}],"overscroll-x":[{"overscroll-x":I()}],"overscroll-y":[{"overscroll-y":I()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:R()}],"inset-x":[{"inset-x":R()}],"inset-y":[{"inset-y":R()}],start:[{start:R()}],end:[{end:R()}],top:[{top:R()}],right:[{right:R()}],bottom:[{bottom:R()}],left:[{left:R()}],visibility:["visible","invisible","collapse"],z:[{z:[isInteger,"auto",isArbitraryVariable,isArbitraryValue]}],basis:[{basis:[isFraction,"full","auto",l,...w()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[isNumber,isFraction,"auto","initial","none",isArbitraryValue]}],grow:[{grow:["",isNumber,isArbitraryVariable,isArbitraryValue]}],shrink:[{shrink:["",isNumber,isArbitraryVariable,isArbitraryValue]}],order:[{order:[isInteger,"first","last","none",isArbitraryVariable,isArbitraryValue]}],"grid-cols":[{"grid-cols":A()}],"col-start-end":[{col:P()}],"col-start":[{"col-start":B()}],"col-end":[{"col-end":B()}],"grid-rows":[{"grid-rows":A()}],"row-start-end":[{row:P()}],"row-start":[{"row-start":B()}],"row-end":[{"row-end":B()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...W(),"normal"]}],"justify-items":[{"justify-items":[...Y(),"normal"]}],"justify-self":[{"justify-self":["auto",...Y()]}],"align-content":[{content:["normal",...W()]}],"align-items":[{items:[...Y(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...Y(),{baseline:["","last"]}]}],"place-content":[{"place-content":W()}],"place-items":[{"place-items":[...Y(),"baseline"]}],"place-self":[{"place-self":["auto",...Y()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:$()}],mx:[{mx:$()}],my:[{my:$()}],ms:[{ms:$()}],me:[{me:$()}],mt:[{mt:$()}],mr:[{mr:$()}],mb:[{mb:$()}],ml:[{ml:$()}],"space-x":[{"space-x":w()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":w()}],"space-y-reverse":["space-y-reverse"],size:[{size:ee()}],w:[{w:[l,"screen",...ee()]}],"min-w":[{"min-w":[l,"screen","none",...ee()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[a]},...ee()]}],h:[{h:["screen","lh",...ee()]}],"min-h":[{"min-h":["screen","lh","none",...ee()]}],"max-h":[{"max-h":["screen","lh",...ee()]}],"font-size":[{text:["base",t,isArbitraryVariableLength,isArbitraryLength]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,isArbitraryVariable,isArbitraryNumber]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",isPercent,isArbitraryValue]}],"font-family":[{font:[isArbitraryVariableFamilyName,isArbitraryValue,e]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,isArbitraryVariable,isArbitraryValue]}],"line-clamp":[{"line-clamp":[isNumber,"none",isArbitraryVariable,isArbitraryNumber]}],leading:[{leading:[o,...w()]}],"list-image":[{"list-image":["none",isArbitraryVariable,isArbitraryValue]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",isArbitraryVariable,isArbitraryValue]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:G()}],"text-color":[{text:G()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...j(),"wavy"]}],"text-decoration-thickness":[{decoration:[isNumber,"from-font","auto",isArbitraryVariable,isArbitraryLength]}],"text-decoration-color":[{decoration:G()}],"underline-offset":[{"underline-offset":[isNumber,"auto",isArbitraryVariable,isArbitraryValue]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:w()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",isArbitraryVariable,isArbitraryValue]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",isArbitraryVariable,isArbitraryValue]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:K()}],"bg-repeat":[{bg:F()}],"bg-size":[{bg:X()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},isInteger,isArbitraryVariable,isArbitraryValue],radial:["",isArbitraryVariable,isArbitraryValue],conic:[isInteger,isArbitraryVariable,isArbitraryValue]},isArbitraryVariableImage,isArbitraryImage]}],"bg-color":[{bg:G()}],"gradient-from-pos":[{from:se()}],"gradient-via-pos":[{via:se()}],"gradient-to-pos":[{to:se()}],"gradient-from":[{from:G()}],"gradient-via":[{via:G()}],"gradient-to":[{to:G()}],rounded:[{rounded:me()}],"rounded-s":[{"rounded-s":me()}],"rounded-e":[{"rounded-e":me()}],"rounded-t":[{"rounded-t":me()}],"rounded-r":[{"rounded-r":me()}],"rounded-b":[{"rounded-b":me()}],"rounded-l":[{"rounded-l":me()}],"rounded-ss":[{"rounded-ss":me()}],"rounded-se":[{"rounded-se":me()}],"rounded-ee":[{"rounded-ee":me()}],"rounded-es":[{"rounded-es":me()}],"rounded-tl":[{"rounded-tl":me()}],"rounded-tr":[{"rounded-tr":me()}],"rounded-br":[{"rounded-br":me()}],"rounded-bl":[{"rounded-bl":me()}],"border-w":[{border:Me()}],"border-w-x":[{"border-x":Me()}],"border-w-y":[{"border-y":Me()}],"border-w-s":[{"border-s":Me()}],"border-w-e":[{"border-e":Me()}],"border-w-t":[{"border-t":Me()}],"border-w-r":[{"border-r":Me()}],"border-w-b":[{"border-b":Me()}],"border-w-l":[{"border-l":Me()}],"divide-x":[{"divide-x":Me()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":Me()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...j(),"hidden","none"]}],"divide-style":[{divide:[...j(),"hidden","none"]}],"border-color":[{border:G()}],"border-color-x":[{"border-x":G()}],"border-color-y":[{"border-y":G()}],"border-color-s":[{"border-s":G()}],"border-color-e":[{"border-e":G()}],"border-color-t":[{"border-t":G()}],"border-color-r":[{"border-r":G()}],"border-color-b":[{"border-b":G()}],"border-color-l":[{"border-l":G()}],"divide-color":[{divide:G()}],"outline-style":[{outline:[...j(),"none","hidden"]}],"outline-offset":[{"outline-offset":[isNumber,isArbitraryVariable,isArbitraryValue]}],"outline-w":[{outline:["",isNumber,isArbitraryVariableLength,isArbitraryLength]}],"outline-color":[{outline:G()}],shadow:[{shadow:["","none",h,isArbitraryVariableShadow,isArbitraryShadow]}],"shadow-color":[{shadow:G()}],"inset-shadow":[{"inset-shadow":["none",d,isArbitraryVariableShadow,isArbitraryShadow]}],"inset-shadow-color":[{"inset-shadow":G()}],"ring-w":[{ring:Me()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:G()}],"ring-offset-w":[{"ring-offset":[isNumber,isArbitraryLength]}],"ring-offset-color":[{"ring-offset":G()}],"inset-ring-w":[{"inset-ring":Me()}],"inset-ring-color":[{"inset-ring":G()}],"text-shadow":[{"text-shadow":["none",p,isArbitraryVariableShadow,isArbitraryShadow]}],"text-shadow-color":[{"text-shadow":G()}],opacity:[{opacity:[isNumber,isArbitraryVariable,isArbitraryValue]}],"mix-blend":[{"mix-blend":[...ie(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ie()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[isNumber]}],"mask-image-linear-from-pos":[{"mask-linear-from":Z()}],"mask-image-linear-to-pos":[{"mask-linear-to":Z()}],"mask-image-linear-from-color":[{"mask-linear-from":G()}],"mask-image-linear-to-color":[{"mask-linear-to":G()}],"mask-image-t-from-pos":[{"mask-t-from":Z()}],"mask-image-t-to-pos":[{"mask-t-to":Z()}],"mask-image-t-from-color":[{"mask-t-from":G()}],"mask-image-t-to-color":[{"mask-t-to":G()}],"mask-image-r-from-pos":[{"mask-r-from":Z()}],"mask-image-r-to-pos":[{"mask-r-to":Z()}],"mask-image-r-from-color":[{"mask-r-from":G()}],"mask-image-r-to-color":[{"mask-r-to":G()}],"mask-image-b-from-pos":[{"mask-b-from":Z()}],"mask-image-b-to-pos":[{"mask-b-to":Z()}],"mask-image-b-from-color":[{"mask-b-from":G()}],"mask-image-b-to-color":[{"mask-b-to":G()}],"mask-image-l-from-pos":[{"mask-l-from":Z()}],"mask-image-l-to-pos":[{"mask-l-to":Z()}],"mask-image-l-from-color":[{"mask-l-from":G()}],"mask-image-l-to-color":[{"mask-l-to":G()}],"mask-image-x-from-pos":[{"mask-x-from":Z()}],"mask-image-x-to-pos":[{"mask-x-to":Z()}],"mask-image-x-from-color":[{"mask-x-from":G()}],"mask-image-x-to-color":[{"mask-x-to":G()}],"mask-image-y-from-pos":[{"mask-y-from":Z()}],"mask-image-y-to-pos":[{"mask-y-to":Z()}],"mask-image-y-from-color":[{"mask-y-from":G()}],"mask-image-y-to-color":[{"mask-y-to":G()}],"mask-image-radial":[{"mask-radial":[isArbitraryVariable,isArbitraryValue]}],"mask-image-radial-from-pos":[{"mask-radial-from":Z()}],"mask-image-radial-to-pos":[{"mask-radial-to":Z()}],"mask-image-radial-from-color":[{"mask-radial-from":G()}],"mask-image-radial-to-color":[{"mask-radial-to":G()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":v()}],"mask-image-conic-pos":[{"mask-conic":[isNumber]}],"mask-image-conic-from-pos":[{"mask-conic-from":Z()}],"mask-image-conic-to-pos":[{"mask-conic-to":Z()}],"mask-image-conic-from-color":[{"mask-conic-from":G()}],"mask-image-conic-to-color":[{"mask-conic-to":G()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:K()}],"mask-repeat":[{mask:F()}],"mask-size":[{mask:X()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",isArbitraryVariable,isArbitraryValue]}],filter:[{filter:["","none",isArbitraryVariable,isArbitraryValue]}],blur:[{blur:ue()}],brightness:[{brightness:[isNumber,isArbitraryVariable,isArbitraryValue]}],contrast:[{contrast:[isNumber,isArbitraryVariable,isArbitraryValue]}],"drop-shadow":[{"drop-shadow":["","none",f,isArbitraryVariableShadow,isArbitraryShadow]}],"drop-shadow-color":[{"drop-shadow":G()}],grayscale:[{grayscale:["",isNumber,isArbitraryVariable,isArbitraryValue]}],"hue-rotate":[{"hue-rotate":[isNumber,isArbitraryVariable,isArbitraryValue]}],invert:[{invert:["",isNumber,isArbitraryVariable,isArbitraryValue]}],saturate:[{saturate:[isNumber,isArbitraryVariable,isArbitraryValue]}],sepia:[{sepia:["",isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-filter":[{"backdrop-filter":["","none",isArbitraryVariable,isArbitraryValue]}],"backdrop-blur":[{"backdrop-blur":ue()}],"backdrop-brightness":[{"backdrop-brightness":[isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-contrast":[{"backdrop-contrast":[isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-grayscale":[{"backdrop-grayscale":["",isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-invert":[{"backdrop-invert":["",isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-opacity":[{"backdrop-opacity":[isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-saturate":[{"backdrop-saturate":[isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-sepia":[{"backdrop-sepia":["",isNumber,isArbitraryVariable,isArbitraryValue]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",isArbitraryVariable,isArbitraryValue]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[isNumber,"initial",isArbitraryVariable,isArbitraryValue]}],ease:[{ease:["linear","initial",y,isArbitraryVariable,isArbitraryValue]}],delay:[{delay:[isNumber,isArbitraryVariable,isArbitraryValue]}],animate:[{animate:["none",E,isArbitraryVariable,isArbitraryValue]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[_,isArbitraryVariable,isArbitraryValue]}],"perspective-origin":[{"perspective-origin":M()}],rotate:[{rotate:be()}],"rotate-x":[{"rotate-x":be()}],"rotate-y":[{"rotate-y":be()}],"rotate-z":[{"rotate-z":be()}],scale:[{scale:re()}],"scale-x":[{"scale-x":re()}],"scale-y":[{"scale-y":re()}],"scale-z":[{"scale-z":re()}],"scale-3d":["scale-3d"],skew:[{skew:Fe()}],"skew-x":[{"skew-x":Fe()}],"skew-y":[{"skew-y":Fe()}],transform:[{transform:[isArbitraryVariable,isArbitraryValue,"","none","gpu","cpu"]}],"transform-origin":[{origin:M()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:oe()}],"translate-x":[{"translate-x":oe()}],"translate-y":[{"translate-y":oe()}],"translate-z":[{"translate-z":oe()}],"translate-none":["translate-none"],accent:[{accent:G()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:G()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",isArbitraryVariable,isArbitraryValue]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",isArbitraryVariable,isArbitraryValue]}],fill:[{fill:["none",...G()]}],"stroke-w":[{stroke:[isNumber,isArbitraryVariableLength,isArbitraryLength,isArbitraryNumber]}],stroke:[{stroke:["none",...G()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},twMerge=createTailwindMerge(getDefaultConfig);function cn(...i){return twMerge(clsx(i))}const Tooltip=({anchorEl:i,title:e,position:t="right",visible:n,collisionPadding:s=8})=>{const o=React.useRef(null);return React.useLayoutEffect(()=>{if(!i||!o.current)return;const a=o.current;if(!n){a.style.opacity="0",a.style.transform="scale(0.95)",a.style.pointerEvents="none";return}a.style.visibility="hidden",a.style.top="-9999px",a.style.left="-9999px",a.style.opacity="0",a.style.transform="scale(0.95)";const l=a.getBoundingClientRect(),c=i.getBoundingClientRect(),u=8,h=window.innerWidth,d=window.innerHeight,p={right:h-c.right>=l.width+u+s,left:c.left>=l.width+u+s,top:c.top>=l.height+u+s,bottom:d-c.bottom>=l.height+u+s};let f=t;p[t]||(f=["right","left","top","bottom"].find(y=>p[y])??t);let g=0,_=0;switch(f){case"right":g=c.top+c.height/2-l.height/2,_=c.right+u;break;case"left":g=c.top+c.height/2-l.height/2,_=c.left-l.width-u;break;case"top":g=c.top-l.height-u,_=c.left+c.width/2-l.width/2;break;case"bottom":g=c.bottom+u,_=c.left+c.width/2-l.width/2;break}const x=(y,E,b)=>Math.min(Math.max(y,E),b);a.style.position="fixed",a.style.top=`${x(g,s,d-l.height-s)}px`,a.style.left=`${x(_,s,h-l.width-s)}px`,a.style.visibility="visible",a.style.opacity="1",a.style.transform="scale(1)",a.style.pointerEvents="none"},[n,i,t,s]),reactDom.createPortal(jsxRuntimeExports.jsx("div",{ref:o,className:`
70
+ at `+a}return e},peg$SyntaxError.buildMessage=function(i,e){var t={literal:function(u){return'"'+s(u.text)+'"'},class:function(u){var h=u.parts.map(function(d){return Array.isArray(d)?o(d[0])+"-"+o(d[1]):o(d)});return"["+(u.inverted?"^":"")+h.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(u){return u.description}};function n(u){return u.charCodeAt(0).toString(16).toUpperCase()}function s(u){return u.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(h){return"\\x0"+n(h)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(h){return"\\x"+n(h)})}function o(u){return u.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(h){return"\\x0"+n(h)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(h){return"\\x"+n(h)})}function a(u){return t[u.type](u)}function l(u){var h=u.map(a),d,p;if(h.sort(),h.length>0){for(d=1,p=1;d<h.length;d++)h[d-1]!==h[d]&&(h[p]=h[d],p++);h.length=p}switch(h.length){case 1:return h[0];case 2:return h[0]+" or "+h[1];default:return h.slice(0,-1).join(", ")+", or "+h[h.length-1]}}function c(u){return u?'"'+s(u)+'"':"end of input"}return"Expected "+l(i)+" but "+c(e)+" found."};const MODE_IDLE="idle",MODE_PANNING="panning",MODE_ZOOMING="zooming",TOOL_AUTO="auto",TOOL_NONE="none",TOOL_PAN="pan",TOOL_ZOOM_IN="zoom-in",TOOL_ZOOM_OUT="zoom-out",POSITION_NONE="none",POSITION_TOP="top",POSITION_RIGHT="right",POSITION_BOTTOM="bottom",POSITION_LEFT="left",ACTION_ZOOM="zoom",ACTION_PAN="pan",ALIGN_CENTER="center",ALIGN_LEFT="left",ALIGN_RIGHT="right",ALIGN_TOP="top",ALIGN_BOTTOM="bottom",ALIGN_COVER="cover";function ownKeys$6(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,n)}return t}function _objectSpread$6(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ownKeys$6(Object(t),!0).forEach(function(n){_defineProperty$6(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ownKeys$6(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function _defineProperty$6(i,e,t){return(e=_toPropertyKey$6(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function _toPropertyKey$6(i){var e=_toPrimitive$6(i,"string");return typeof e=="symbol"?e:e+""}function _toPrimitive$6(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}const VERSION=3,DEFAULT_MODE=MODE_IDLE;function getDefaultValue(i,e,t,n,s,o){let a=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,l=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null;return set({},_objectSpread$6(_objectSpread$6({},identity()),{},{version:VERSION,mode:DEFAULT_MODE,focus:!1,pinchPointDistance:null,prePinchMode:null,viewerWidth:i,viewerHeight:e,SVGMinX:t,SVGMinY:n,SVGWidth:s,SVGHeight:o,scaleFactorMin:a,scaleFactorMax:l,startX:null,startY:null,endX:null,endY:null,miniatureOpen:!0,lastAction:null}))}function set(i,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;return i=Object.assign({},i,e,{lastAction:t}),Object.freeze(i)}function isValueValid(i){return i!==null&&typeof i=="object"&&i.hasOwnProperty("version")&&i.version===VERSION}function getSVGPoint(i,e,t){let n=fromObject(i),s=inverse(n);return applyToPoint(s,{x:e,y:t})}function decompose(i){let e=fromObject(i);return{scaleFactor:e.a,translationX:e.e,translationY:e.f}}function setFocus(i,e){return set(i,{focus:e})}function setViewerSize(i,e,t){return set(i,{viewerWidth:e,viewerHeight:t})}function setSVGViewBox(i,e,t,n,s){return set(i,{SVGMinX:e,SVGMinY:t,SVGWidth:n,SVGHeight:s})}function setZoomLevels(i,e,t){return set(i,{scaleFactorMin:e,scaleFactorMax:t})}function setPointOnViewerCenter(i,e,t,n){let{viewerWidth:s,viewerHeight:o}=i,a=transform(translate(-e+s/2,-t+o/2),translate(e,t),scale(n,n),translate(-e,-t));return set(i,_objectSpread$6({mode:MODE_IDLE},a))}function reset(i){return set(i,_objectSpread$6({mode:MODE_IDLE},identity()))}function resetMode(i){return set(i,{mode:DEFAULT_MODE,startX:null,startY:null,endX:null,endY:null})}class ViewerEvent{constructor(e,t,n){this.originalEvent=e,this.value=t,this.SVGViewer=n}get scaleFactor(){return this._cacheDecomposedValue=this._cacheDecomposedValue||decompose(this.value),this._cacheDecomposedValue.scaleFactor}get translationX(){return this._cacheDecomposedValue=this._cacheDecomposedValue||decompose(this.value),this._cacheDecomposedValue.translationX}get translationY(){return this._cacheDecomposedValue=this._cacheDecomposedValue||decompose(this.value),this._cacheDecomposedValue.translationY}preventDefault(){this.originalEvent.preventDefault()}stopPropagation(){this.originalEvent.stopPropagation()}}function ownKeys$5(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,n)}return t}function _objectSpread$5(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ownKeys$5(Object(t),!0).forEach(function(n){_defineProperty$5(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ownKeys$5(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function _defineProperty$5(i,e,t){return(e=_toPropertyKey$5(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function _toPropertyKey$5(i){var e=_toPrimitive$5(i,"string");return typeof e=="symbol"?e:e+""}function _toPrimitive$5(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function pan(i,e,t){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:void 0,s=transform(fromObject(i),translate(e,t));if(n){let[{x:o,y:a},{x:l,y:c}]=applyToPoints(s,[{x:i.SVGMinX+n,y:i.SVGMinY+n},{x:i.SVGMinX+i.SVGWidth-n,y:i.SVGMinY+i.SVGHeight-n}]),u=0;i.viewerWidth-o<0?u=i.viewerWidth-o:l<0&&(u=-l);let h=0;i.viewerHeight-a<0?h=i.viewerHeight-a:c<0&&(h=-c),s=transform(translate(u,h),s)}return set(i,_objectSpread$5({mode:MODE_IDLE},s),ACTION_PAN)}function startPanning(i,e,t){return set(i,{mode:MODE_PANNING,startX:e,startY:t,endX:e,endY:t},ACTION_PAN)}function updatePanning(i,e,t,n){if(i.mode!==MODE_PANNING)throw new Error("update pan not allowed in this mode "+i.mode);let{endX:s,endY:o}=i,a=getSVGPoint(i,s,o),l=getSVGPoint(i,e,t),c=l.x-a.x,u=l.y-a.y,h=pan(i,c,u,n);return set(h,{mode:MODE_PANNING,endX:e,endY:t},ACTION_PAN)}function stopPanning(i){return set(i,{mode:MODE_IDLE,startX:null,startY:null,endX:null,endY:null},ACTION_PAN)}function autoPanIfNeeded(i,e,t){let n=0,s=0;return t<=20&&(s=2),i.viewerWidth-e<=20&&(n=-2),i.viewerHeight-t<=20&&(s=-2),e<=20&&(n=2),n=n/i.d,s=s/i.d,n===0&&s===0?i:pan(i,n,s)}function calculateBox(i,e){if(i.x<=e.x&&i.y<=e.y)return{x:i.x,y:i.y,width:e.x-i.x,height:e.y-i.y};if(i.x>=e.x&&i.y<=e.y)return{x:e.x,y:i.y,width:i.x-e.x,height:e.y-i.y};if(i.x>=e.x&&i.y>=e.y)return{x:e.x,y:e.y,width:i.x-e.x,height:i.y-e.y};if(i.x<=e.x&&i.y>=e.y)return{x:i.x,y:e.y,width:e.x-i.x,height:i.y-e.y}}function ownKeys$4(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,n)}return t}function _objectSpread$4(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ownKeys$4(Object(t),!0).forEach(function(n){_defineProperty$4(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ownKeys$4(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function _defineProperty$4(i,e,t){return(e=_toPropertyKey$4(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function _toPropertyKey$4(i){var e=_toPrimitive$4(i,"string");return typeof e=="symbol"?e:e+""}function _toPrimitive$4(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function isZoomLevelGoingOutOfBounds(i,e){const{scaleFactor:t}=decompose(i),n=i.scaleFactorMin&&t*e<i.scaleFactorMin,s=i.scaleFactorMax&&t*e>i.scaleFactorMax;return n&&e<1||s&&e>1}function limitZoomLevel(i,e){let t=e.a;return i.scaleFactorMin!=null&&(t=Math.max(t,i.scaleFactorMin)),i.scaleFactorMax!=null&&(t=Math.min(t,i.scaleFactorMax)),set(e,{a:t,d:t})}function zoom(i,e,t,n){if(isZoomLevelGoingOutOfBounds(i,n))return i;const s=transform(fromObject(i),translate(e,t),scale(n,n),translate(-e,-t));return set(i,_objectSpread$4(_objectSpread$4({mode:MODE_IDLE},s),{},{startX:null,startY:null,endX:null,endY:null}),ACTION_ZOOM)}function fitSelection(i,e,t,n,s){let{viewerWidth:o,viewerHeight:a}=i,l=o/n,c=a/s,u=Math.min(l,c);const h=transform(scale(u,u),translate(-e,-t));return isZoomLevelGoingOutOfBounds(i,u/i.d)?set(i,{mode:MODE_IDLE,startX:null,startY:null,endX:null,endY:null}):set(i,_objectSpread$4(_objectSpread$4({mode:MODE_IDLE},limitZoomLevel(i,h)),{},{startX:null,startY:null,endX:null,endY:null}),ACTION_ZOOM)}function fitToViewer(i){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ALIGN_LEFT,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ALIGN_TOP,{viewerWidth:n,viewerHeight:s,SVGMinX:o,SVGMinY:a,SVGWidth:l,SVGHeight:c}=i,u=n/l,h=s/c,d=Math.min(u,h),p=scale(d,d),f=-o*u,g=-a*h;if(u<h){let y=s-u*c;switch(t){case ALIGN_TOP:g=-a*d;break;case ALIGN_CENTER:g=Math.round(y/2)-a*d;break;case ALIGN_BOTTOM:g=y-a*d;break;case ALIGN_COVER:p=scale(h,h);let E=n-h*l;f=o+Math.round(E/2);break}}else{let y=n-h*l;switch(e){case ALIGN_LEFT:f=-o*d;break;case ALIGN_CENTER:f=Math.round(y/2)-o*d;break;case ALIGN_RIGHT:f=y-o*d;break;case ALIGN_COVER:p=scale(u,u);let E=s-u*c;g=a+Math.round(E/2);break}}const _=translate(f,g),x=transform(_,p);return isZoomLevelGoingOutOfBounds(i,d/i.d)?set(i,{mode:MODE_IDLE,startX:null,startY:null,endX:null,endY:null}):set(i,_objectSpread$4(_objectSpread$4({mode:MODE_IDLE},limitZoomLevel(i,x)),{},{startX:null,startY:null,endX:null,endY:null}),ACTION_ZOOM)}function zoomOnViewerCenter(i,e){let{viewerWidth:t,viewerHeight:n}=i,s=getSVGPoint(i,t/2,n/2);return zoom(i,s.x,s.y,e)}function startZooming(i,e,t){return set(i,{mode:MODE_ZOOMING,startX:e,startY:t,endX:e,endY:t})}function updateZooming(i,e,t){if(i.mode!==MODE_ZOOMING)throw new Error("update selection not allowed in this mode "+i.mode);return set(i,{endX:e,endY:t})}function stopZooming(i,e,t,n){let{startX:o,startY:a}=i,l=getSVGPoint(i,o,a),c=getSVGPoint(i,e,t);if(Math.abs(o-e)>7&&Math.abs(a-t)>7){let u=calculateBox(l,c);return fitSelection(i,u.x,u.y,u.width,u.height)}else{let u=getSVGPoint(i,e,t);return zoom(i,u.x,u.y,n)}}function mapRange(i,e,t,n,s){return n+(s-n)*(i-e)/(t-e)}function getMousePosition(i,e){let{left:t,top:n}=e.getBoundingClientRect(),s=i.clientX-Math.round(t),o=i.clientY-Math.round(n);return{x:s,y:o}}function onMouseDown$1(i,e,t,n,s){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:a,y:l}=o||getMousePosition(i,e);let c=n;switch(t){case TOOL_ZOOM_OUT:let u=getSVGPoint(n,a,l);c=zoom(n,u.x,u.y,1/s.scaleFactor);break;case TOOL_ZOOM_IN:c=startZooming(n,a,l);break;case TOOL_AUTO:case TOOL_PAN:c=startPanning(n,a,l);break;default:return n}return i.preventDefault(),c}function onMouseMove$1(i,e,t,n,s){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:a,y:l}=o||getMousePosition(i,e);let c=i.buttons===0,u=n;switch(t){case TOOL_ZOOM_IN:n.mode===MODE_ZOOMING&&(u=c?stopZooming(n,a,l,s.scaleFactor):updateZooming(n,a,l));break;case TOOL_AUTO:case TOOL_PAN:n.mode===MODE_PANNING&&(u=c?stopPanning(n):updatePanning(n,a,l,s.preventPanOutside?20:void 0));break;default:return n}return i.preventDefault(),u}function onMouseUp(i,e,t,n,s){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:a,y:l}=o||getMousePosition(i,e);let c=n;switch(t){case TOOL_ZOOM_OUT:n.mode===MODE_ZOOMING&&(c=stopZooming(n,a,l,1/s.scaleFactor));break;case TOOL_ZOOM_IN:n.mode===MODE_ZOOMING&&(c=stopZooming(n,a,l,s.scaleFactor));break;case TOOL_AUTO:case TOOL_PAN:n.mode===MODE_PANNING&&(c=stopPanning(n));break;default:return n}return i.preventDefault(),c}function onDoubleClick(i,e,t,n,s){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:a,y:l}=o||getMousePosition(i,e);let c=n;if(t===TOOL_AUTO&&!s.disableDoubleClickZoomWithToolAuto){const{modifierKeys:u=[]}=s;let h=getSVGPoint(n,a,l),d=(g,_)=>g||i.getModifierState(_),f=u.reduce(d,!1)?1/s.scaleFactor:s.scaleFactor;c=zoom(n,h.x,h.y,f)}return i.preventDefault(),c}function onWheel(i,e,t,n,s){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null;const{x:a,y:l}=o||getMousePosition(i,e);if(!s.detectWheel)return n;let c=Math.max(-1,Math.min(1,i.deltaY)),u=mapRange(c,-1,1,s.scaleFactorOnWheel,1/s.scaleFactorOnWheel),h=getSVGPoint(n,a,l),d=zoom(n,h.x,h.y,u);return i.preventDefault(),d}function onMouseEnterOrLeave(i,e,t,n,s){let o=setFocus(n,i.type==="mouseenter");return i.preventDefault(),o}function onInterval(i,e,t,n,s){let o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null,{x:a,y:l}=o;return!([TOOL_NONE,TOOL_AUTO].indexOf(t)>=0)||!s.detectAutoPan||!n.focus?n:autoPanIfNeeded(n,a,l)}class ViewerMouseEvent extends ViewerEvent{get point(){if(!this._cachePoint){const{originalEvent:e,SVGViewer:t,value:n}=this,s=getMousePosition(e,t);this._cachePoint=getSVGPoint(n,s.x,s.y)}return this._cachePoint}get x(){return this.point.x}get y(){return this.point.y}}function ownKeys$3(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,n)}return t}function _objectSpread$3(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ownKeys$3(Object(t),!0).forEach(function(n){_defineProperty$3(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ownKeys$3(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function _defineProperty$3(i,e,t){return(e=_toPropertyKey$3(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function _toPropertyKey$3(i){var e=_toPrimitive$3(i,"string");return typeof e=="symbol"?e:e+""}function _toPrimitive$3(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class ViewerTouchEvent extends ViewerEvent{get points(){return this._cachePoints||(this._cachePoints=ViewerTouchEvent.touchesToPoints(this.originalEvent.touches,this.SVGViewer,this.value)),this._cachePoints}get changedPoints(){return this._cacheChangedPoints||(this._cacheChangedPoints=ViewerTouchEvent.touchesToPoints(this.originalEvent.changedTouches,this.SVGViewer,this.value)),this._cacheChangedPoints}static touchesToPoints(e,t,n){let s=[];for(let o=0;o<e.length;o++){let a=e[o],l=t.getBoundingClientRect(),c=a.clientX-Math.round(l.left),u=a.clientY-Math.round(l.top),h=getSVGPoint(n,c,u);s.push(_objectSpread$3(_objectSpread$3({},h),{},{identifier:a.identifier}))}return s}}function eventFactory(i,e,t){let n=i.type;switch(n){case"mousemove":case"mouseup":case"mousedown":case"click":case"dblclick":return new ViewerMouseEvent(i,e,t);case"touchstart":case"touchmove":case"touchend":case"touchcancel":return new ViewerTouchEvent(i,e,t);default:throw new Error(`${n} not supported`)}}function parseViewBox(i){return i.split(/[ ,]/).filter(Boolean).map(Number)}function ownKeys$2(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,n)}return t}function _objectSpread$2(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ownKeys$2(Object(t),!0).forEach(function(n){_defineProperty$2(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ownKeys$2(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function _defineProperty$2(i,e,t){return(e=_toPropertyKey$2(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function _toPropertyKey$2(i){var e=_toPrimitive$2(i,"string");return typeof e=="symbol"?e:e+""}function _toPrimitive$2(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function getTouchPosition(i,e){let{left:t,top:n}=e.getBoundingClientRect(),s=i.clientX-Math.round(t),o=i.clientY-Math.round(n);return{x:s,y:o}}function onTouchStart$1(i,e,t,n,s){if(isMultiTouch(i,s))return onMultiTouch(i,e,t,n);if(i.touches.length!==1){if([MODE_PANNING,MODE_ZOOMING].indexOf(n.mode)>=0)return resetMode(n);if([MODE_IDLE].indexOf(n.mode)>=0)return n}return onSingleTouch(i,e,t,n,s,onMouseDown$1)}function onTouchMove$1(i,e,t,n,s){return isMultiTouch(i,s)?onMultiTouch(i,e,t,n):[MODE_PANNING,MODE_ZOOMING].indexOf(n.mode)>=0?onSingleTouch(i,e,t,n,s,onMouseMove$1):n}function onTouchEnd(i,e,t,n,s){if(!([MODE_PANNING,MODE_ZOOMING].indexOf(n.mode)>=0))return n;let o=shouldResetPinchPointDistance(i,n,s)?set(n,{pinchPointDistance:null}):n;return i.touches.length>0?o:onSingleTouch(i,e,t,o,s,onMouseUp)}function onTouchCancel(i,e,t,n,s){return i.stopPropagation(),i.preventDefault(),resetMode(n)}function hasPinchPointDistance(i){return typeof i.pinchPointDistance=="number"}function shouldResetPinchPointDistance(i,e,t){return t.detectPinchGesture&&hasPinchPointDistance(e)&&i.touches.length<2}function isMultiTouch(i,e){return e.detectPinchGesture&&i.touches.length>1}function onSingleTouch(i,e,t,n,s,o){let a=i.touches.length===0?set(n,{mode:n.prePinchMode?MODE_IDLE:n.mode,prePinchMode:null}):n,l=i.touches.length>0?i.touches[0]:i.changedTouches[0],c=getTouchPosition(l,e);switch(t){case TOOL_ZOOM_OUT:case TOOL_ZOOM_IN:case TOOL_AUTO:case TOOL_PAN:return i.stopPropagation(),i.preventDefault(),o(i,e,t,a,s,c);default:return a}}function onMultiTouch(i,e,t,n,s){const{left:o,top:a}=e.getBoundingClientRect(),l=i.touches[0].clientX-Math.round(o),c=i.touches[0].clientY-Math.round(a),u=i.touches[1].clientX-Math.round(o),h=i.touches[1].clientY-Math.round(a),d=Math.sqrt(Math.pow(u-l,2)+Math.pow(h-c,2)),p=hasPinchPointDistance(n)?n.pinchPointDistance:d,f=getSVGPoint(n,(l+u)/2,(c+h)/2);let g=d/p;if(isZoomLevelGoingOutOfBounds(n,g))return n;i.cancelable&&i.preventDefault();let _=transform(fromObject(n),translate(f.x,f.y),scale(g,g),translate(-f.x,-f.y));return set(n,set(_objectSpread$2(_objectSpread$2({mode:MODE_ZOOMING},limitZoomLevel(n,_)),{},{startX:null,startY:null,endX:null,endY:null,prePinchMode:n.prePinchMode?n.prePinchMode:n.mode,pinchPointDistance:d})))}function openMiniature(i){return set(i,{miniatureOpen:!0})}function closeMiniature(i){return set(i,{miniatureOpen:!1})}let needPrefix=i=>["zoom-in","zoom-out","grab","grabbing"].indexOf(i)>-1,userAgent=()=>navigator.userAgent.toLowerCase(),isFirefox=()=>userAgent().indexOf("firefox")>-1,isWebkit=()=>userAgent().indexOf("webkit")>-1;function cursorPolyfill(i){if(!needPrefix(i))return i;if(isFirefox())return`-moz-${i}`;if(isWebkit())return`-webkit-${i}`}function getDisplayName(i){return i.displayName||i.name||"Component"}function _extends$3(){return _extends$3=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},_extends$3.apply(null,arguments)}let uid=1;const nextUID=()=>`uid${uid++}`;function RandomUID(i){class e extends React.Component{constructor(n){super(n),this.state={uid:nextUID()}}render(){return React.createElement(i,_extends$3({_uid:this.state.uid},this.props))}}return e.displayName=`RandomUID(${getDisplayName(i)})`,e}const prefixID$1="react-svg-pan-zoom_border_gradient";function BorderGradient(i){let{direction:e,width:t,height:n,_uid:s}=i,o;switch(e){case POSITION_TOP:o=`translate(${t}, 0) rotate(90)`;break;case POSITION_RIGHT:o=`translate(${t}, ${n}) rotate(180)`;break;case POSITION_BOTTOM:o=`translate(0, ${n}) rotate(270)`;break;case POSITION_LEFT:default:o=" ";break}let a=`${prefixID$1}_gradient_${s}`,l=`${prefixID$1}_mask_${s}`;return React.createElement("g",null,React.createElement("defs",null,React.createElement("linearGradient",{id:a,x1:"0%",y1:"0%",x2:"100%",y2:"0%",spreadMethod:"pad"},React.createElement("stop",{offset:"0%",stopColor:"#fff",stopOpacity:"0.8"}),React.createElement("stop",{offset:"100%",stopColor:"#000",stopOpacity:"0.5"})),React.createElement("mask",{id:l,x:"0",y:"0",width:"20",height:Math.max(t,n)},React.createElement("rect",{x:"0",y:"0",width:"20",height:Math.max(t,n),style:{stroke:"none",fill:`url(#${a})`}}))),React.createElement("rect",{x:"0",y:"0",width:"20",height:Math.max(t,n),style:{stroke:"none",fill:"#000",mask:`url(#${l})`},transform:o}))}BorderGradient.propTypes={direction:PropTypes.oneOf([POSITION_TOP,POSITION_RIGHT,POSITION_BOTTOM,POSITION_LEFT]).isRequired,width:PropTypes.number.isRequired,height:PropTypes.number.isRequired};const BorderGradient$1=RandomUID(BorderGradient);function Selection(i){let{startX:e,startY:t,endX:n,endY:s}=i;if(!e||!t||!n||!s)return null;let o=calculateBox({x:e,y:t},{x:n,y:s});return React.createElement("rect",{stroke:"#969FFF",strokeOpacity:.7,fill:"#F3F4FF",fillOpacity:.7,x:o.x,y:o.y,width:o.width,height:o.height,style:{pointerEvents:"none"}})}Selection.propTypes={startX:PropTypes.number,startY:PropTypes.number,endX:PropTypes.number,endY:PropTypes.number};function IconCursor(){return React.createElement("svg",{width:24,height:24,stroke:"currentColor"},React.createElement("path",{d:"M10.07,14.27C10.57,14.03 11.16,14.25 11.4,14.75L13.7,19.74L15.5,18.89L13.19,13.91C12.95,13.41 13.17,12.81 13.67,12.58L13.95,12.5L16.25,12.05L8,5.12V15.9L9.82,14.43L10.07,14.27M13.64,21.97C13.14,22.21 12.54,22 12.31,21.5L10.13,16.76L7.62,18.78C7.45,18.92 7.24,19 7,19A1,1 0 0,1 6,18V3A1,1 0 0,1 7,2C7.24,2 7.47,2.09 7.64,2.23L7.65,2.22L19.14,11.86C19.57,12.22 19.62,12.85 19.27,13.27C19.12,13.45 18.91,13.57 18.7,13.61L15.54,14.23L17.74,18.96C18,19.46 17.76,20.05 17.26,20.28L13.64,21.97Z"}))}function IconPan(){return React.createElement("svg",{width:24,height:24,stroke:"currentColor"},React.createElement("path",{d:"M13,6V11H18V7.75L22.25,12L18,16.25V13H13V18H16.25L12,22.25L7.75,18H11V13H6V16.25L1.75,12L6,7.75V11H11V6H7.75L12,1.75L16.25,6H13Z"}))}function IconZoomIn(){return React.createElement("svg",{width:24,height:24,stroke:"currentColor"},React.createElement("g",null,React.createElement("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"}),React.createElement("path",{d:"M12 10h-2v2H9v-2H7V9h2V7h1v2h2v1z"})))}function IconZoomOut(){return React.createElement("svg",{width:24,height:24,stroke:"currentColor"},React.createElement("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14zM7 9h5v1H7z"}))}function IconFit(){return React.createElement("svg",{width:24,height:24,stroke:"currentColor"},React.createElement("path",{d:"M15 3l2.3 2.3-2.89 2.87 1.42 1.42L18.7 6.7 21 9V3zM3 9l2.3-2.3 2.87 2.89 1.42-1.42L6.7 5.3 9 3H3zm6 12l-2.3-2.3 2.89-2.87-1.42-1.42L5.3 17.3 3 15v6zm12-6l-2.3 2.3-2.87-2.89-1.42 1.42 2.89 2.87L15 21h6z"}))}let ToolbarButton$1=class extends React.Component{constructor(e){super(e),this.state={hover:!1}}change(e){switch(e.preventDefault(),e.stopPropagation(),e.type){case"mouseenter":case"touchstart":this.setState({hover:!0});break;case"mouseleave":case"touchend":case"touchcancel":this.setState({hover:!1});break}}render(){let e={display:"block",width:"24px",height:"24px",margin:[POSITION_TOP,POSITION_BOTTOM].indexOf(this.props.toolbarPosition)>=0?"2px 1px":"1px 2px",color:this.props.active||this.state.hover?this.props.activeColor:"#FFF",transition:"color 200ms ease",background:"none",padding:"0px",border:"0px",outline:"0px",cursor:"pointer"};return React.createElement("button",{onMouseEnter:t=>this.change(t),onMouseLeave:t=>this.change(t),onTouchStart:t=>{this.change(t),this.props.onClick(t)},onTouchEnd:t=>this.change(t),onTouchCancel:t=>this.change(t),onClick:this.props.onClick,style:e,title:this.props.title,name:this.props.name,type:"button"},this.props.children)}};ToolbarButton$1.propTypes={title:PropTypes.string.isRequired,name:PropTypes.string.isRequired,toolbarPosition:PropTypes.string.isRequired,activeColor:PropTypes.string.isRequired,onClick:PropTypes.func.isRequired,active:PropTypes.bool.isRequired};const DEFAULT_ACTIVE_TOOL_COLOR="#1CA6FC";function Toolbar$1(i){let{tool:e,value:t,onChangeValue:n,onChangeTool:s,activeToolColor:o=DEFAULT_ACTIVE_TOOL_COLOR,position:a=POSITION_RIGHT,SVGAlignX:l=ALIGN_LEFT,SVGAlignY:c=ALIGN_TOP}=i,u=(f,g)=>{s(g),f.stopPropagation(),f.preventDefault()},h=f=>{n(fitToViewer(t,l,c)),f.stopPropagation(),f.preventDefault()},d=[POSITION_TOP,POSITION_BOTTOM].indexOf(a)>=0,p={position:"absolute",transform:[POSITION_TOP,POSITION_BOTTOM].indexOf(a)>=0?"translate(-50%, 0px)":"none",top:[POSITION_LEFT,POSITION_RIGHT,POSITION_TOP].indexOf(a)>=0?"5px":"unset",left:[POSITION_TOP,POSITION_BOTTOM].indexOf(a)>=0?"50%":POSITION_LEFT===a?"5px":"unset",right:[POSITION_RIGHT].indexOf(a)>=0?"5px":"unset",bottom:[POSITION_BOTTOM].indexOf(a)>=0?"5px":"unset",backgroundColor:"rgba(19, 20, 22, 0.90)",borderRadius:"2px",display:"flex",flexDirection:d?"row":"column",padding:d?"1px 2px":"2px 1px"};return React.createElement("div",{style:p,role:"toolbar"},React.createElement(ToolbarButton$1,{toolbarPosition:a,active:e===TOOL_NONE,activeColor:o,name:"unselect-tools",title:"Selection",onClick:f=>u(f,TOOL_NONE)},React.createElement(IconCursor,null)),React.createElement(ToolbarButton$1,{toolbarPosition:a,active:e===TOOL_PAN,activeColor:o,name:"select-tool-pan",title:"Pan",onClick:f=>u(f,TOOL_PAN)},React.createElement(IconPan,null)),React.createElement(ToolbarButton$1,{toolbarPosition:a,active:e===TOOL_ZOOM_IN,activeColor:o,name:"select-tool-zoom-in",title:"Zoom in",onClick:f=>u(f,TOOL_ZOOM_IN)},React.createElement(IconZoomIn,null)),React.createElement(ToolbarButton$1,{toolbarPosition:a,active:e===TOOL_ZOOM_OUT,activeColor:o,name:"select-tool-zoom-out",title:"Zoom out",onClick:f=>u(f,TOOL_ZOOM_OUT)},React.createElement(IconZoomOut,null)),React.createElement(ToolbarButton$1,{toolbarPosition:a,active:!1,activeColor:o,name:"fit-to-viewer",title:"Fit to viewer",onClick:f=>h(f)},React.createElement(IconFit,null)))}Toolbar$1.propTypes={tool:PropTypes.string.isRequired,onChangeTool:PropTypes.func.isRequired,value:PropTypes.object.isRequired,onChangeValue:PropTypes.func.isRequired,position:PropTypes.oneOf([POSITION_TOP,POSITION_RIGHT,POSITION_BOTTOM,POSITION_LEFT]),SVGAlignX:PropTypes.oneOf([ALIGN_CENTER,ALIGN_LEFT,ALIGN_RIGHT]),SVGAlignY:PropTypes.oneOf([ALIGN_CENTER,ALIGN_TOP,ALIGN_BOTTOM]),activeToolColor:PropTypes.string};function isTouchDevice(){return"ontouchstart"in window||navigator.maxTouchPoints}function IconArrow(i){let{open:e,position:t}=i,n=0;switch(t){case POSITION_LEFT:n=e?"rotate(225, 12, 13)":"rotate(45, 12, 13)";break;case POSITION_RIGHT:n=n=e?"rotate(135, 12, 13)":"rotate(-45, 12, 13)";break}return React.createElement("svg",{width:24,height:24,stroke:"currentColor"},React.createElement("g",{transform:n},React.createElement("path",{fill:"#000000",d:"M7.41,15.41L12,10.83L16.59,15.41L18,14L12,8L6,14L7.41,15.41Z"})))}IconArrow.propTypes={open:PropTypes.bool.isRequired,position:PropTypes.oneOf([POSITION_RIGHT,POSITION_LEFT]).isRequired};function MiniatureToggleButton(i){let{value:e,onChangeValue:t,position:n}=i,s={width:"24px",height:"24px",display:"block",position:"absolute",bottom:0,[n===POSITION_LEFT?"left":"right"]:"0px",background:"rgba(19, 20, 22, 0.901961)",border:0,padding:0,outline:0,color:"#fff"},o=e.miniatureOpen?closeMiniature:openMiniature;return React.createElement("button",{type:"button",style:s,onClick:()=>t(o(e))},React.createElement(IconArrow,{open:e.miniatureOpen,position:n}))}MiniatureToggleButton.propTypes={value:PropTypes.object.isRequired,onChangeValue:PropTypes.func.isRequired,position:PropTypes.oneOf([POSITION_RIGHT,POSITION_LEFT]).isRequired};const prefixID="react-svg-pan-zoom_miniature";function MiniatureMask(i){let{SVGMinX:e,SVGMinY:t,SVGWidth:n,SVGHeight:s,x1:o,y1:a,x2:l,y2:c,zoomToFit:u,_uid:h}=i;const d=`${prefixID}_mask_${h}`;return React.createElement("g",null,React.createElement("defs",null,React.createElement("mask",{id:d},React.createElement("rect",{x:e,y:t,width:n,height:s,fill:"#ffffff"}),React.createElement("rect",{x:o,y:a,width:l-o,height:c-a}))),React.createElement("rect",{x:e,y:t,width:n,height:s,style:{stroke:"none",fill:"#000",mask:`url(#${d})`,opacity:.4}}))}MiniatureMask.propTypes={SVGWidth:PropTypes.number.isRequired,SVGHeight:PropTypes.number.isRequired,SVGMinX:PropTypes.number.isRequired,SVGMinY:PropTypes.number.isRequired,x1:PropTypes.number.isRequired,y1:PropTypes.number.isRequired,x2:PropTypes.number.isRequired,y2:PropTypes.number.isRequired,zoomToFit:PropTypes.number.isRequired};const MiniatureMask$1=RandomUID(MiniatureMask),DEFAULT_BACKGROUND="#616264";function Miniature(i){let{value:e,onChangeValue:t,children:n,SVGBackground:s,background:o=DEFAULT_BACKGROUND,position:a=POSITION_LEFT,width:l=100,height:c=80}=i,{SVGMinX:u,SVGMinY:h,SVGWidth:d,SVGHeight:p,viewerWidth:f,viewerHeight:g}=e,_=p/d,x=_>=1?c/p:l/d,[{x:y,y:E},{x:b,y:v}]=applyToPoints(inverse(e),[{x:0,y:0},{x:f,y:g}]),M,T;e.miniatureOpen?(M=l,T=c):(M=24,T=24);let I={position:"absolute",overflow:"hidden",outline:"1px solid rgba(19, 20, 22, 0.90)",transition:"width 200ms ease, height 200ms ease, bottom 200ms ease",width:M+"px",height:T+"px",bottom:"6px",[a===POSITION_LEFT?"left":"right"]:"6px",background:o},w=_>=1?`translate(${(l-d*x)/2-u*x}, ${-h*x})`:`translate(${-u*x}, ${(c-p*x)/2-h*x})`;return React.createElement("div",{role:"navigation",style:I},React.createElement("svg",{width:l,height:c,style:{pointerEvents:"none"}},React.createElement("g",{transform:w},React.createElement("g",{transform:`scale(${x}, ${x})`},React.createElement("rect",{fill:s,x:u,y:h,width:d,height:p}),n,React.createElement(MiniatureMask$1,{SVGWidth:d,SVGHeight:p,SVGMinX:u,SVGMinY:h,x1:y,y1:E,x2:b,y2:v,zoomToFit:x})))),React.createElement(MiniatureToggleButton,{value:e,onChangeValue:t,position:a}))}Miniature.propTypes={value:PropTypes.object.isRequired,onChangeValue:PropTypes.func.isRequired,SVGBackground:PropTypes.string.isRequired,position:PropTypes.oneOf([POSITION_RIGHT,POSITION_LEFT]),background:PropTypes.string,width:PropTypes.number,height:PropTypes.number};function isNullOrUndefined(i){return typeof i>"u"||i===null}const github_base="https://github.com/chrvadala/react-svg-pan-zoom/blob/main",doc_v2_to_v3=github_base+"/docs/migrate-from-v2-to-v3.md";function tipControlledComponent(){console.error(`HEY! With ReactSVGPanZoom >= 3 you MUST specify value and tool props. Please read here ${doc_v2_to_v3}`)}function tipDeprecatedMiniatureProps(){console.error(`HEY! With ReactSVGPanZoom >= 3 the props miniaturePosition, miniatureBackground, miniatureWidth, miniatureHeight can be specified as key in the miniatureProps object. Please read here ${doc_v2_to_v3}`)}function tipDeprecateToolbarProps(){console.error(`HEY! With ReactSVGPanZoom >= 3 the prop toolbarPosition can be specified as key in the toolbarProps object. Please read here ${doc_v2_to_v3}`)}function printMigrationTipsRelatedToProps(i){(isNullOrUndefined(i.tool)||isNullOrUndefined(i.value))&&tipControlledComponent(),(!isNullOrUndefined(i.miniaturePosition)||!isNullOrUndefined(i.miniatureBackground)||!isNullOrUndefined(i.miniatureWidth)||!isNullOrUndefined(i.miniatureHeight))&&tipDeprecatedMiniatureProps(),isNullOrUndefined(i.toolbarPosition)||tipDeprecateToolbarProps()}function _extends$2(){return _extends$2=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},_extends$2.apply(null,arguments)}function ownKeys$1(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,n)}return t}function _objectSpread$1(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ownKeys$1(Object(t),!0).forEach(function(n){_defineProperty$1(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ownKeys$1(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function _defineProperty$1(i,e,t){return(e=_toPropertyKey$1(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function _toPropertyKey$1(i){var e=_toPrimitive$1(i,"string");return typeof e=="symbol"?e:e+""}function _toPrimitive$1(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class ReactSVGPanZoom extends React.Component{constructor(e,t){const{width:n,height:s,scaleFactorMin:o,scaleFactorMax:a,children:l}=e,{viewBox:c}=l.props;let u;if(c){const[h,d,p,f]=parseViewBox(c);u=getDefaultValue(n,s,h,d,p,f,o,a)}else{const{width:h,height:d}=l.props;u=getDefaultValue(n,s,0,0,h,d,o,a)}super(e,t),this.ViewerDOM=null,this.state={pointerX:null,pointerY:null,defaultValue:u},this.autoPanLoop=this.autoPanLoop.bind(this),this.onWheel=this.onWheel.bind(this),process.env.NODE_ENV!=="production"&&printMigrationTipsRelatedToProps(e)}componentDidUpdate(e){const t=this.getValue(),n=this.props;let s=t,o=!1;process.env.NODE_ENV!=="production"&&printMigrationTipsRelatedToProps(n);const{viewBox:a}=n.children.props;if(a){const[l,c,u,h]=parseViewBox(a);(t.SVGMinX!==l||t.SVGMinY!==c||t.SVGWidth!==u||t.SVGHeight!==h)&&(s=setSVGViewBox(s,l,c,u,h),o=!0)}else{const{width:l,height:c}=n.children.props;(t.SVGWidth!==l||t.SVGHeight!==c)&&(s=setSVGViewBox(s,0,0,l,c),o=!0)}(e.width!==n.width||e.height!==n.height)&&(s=setViewerSize(s,n.width,n.height),o=!0),(e.scaleFactorMin!==n.scaleFactorMin||e.scaleFactorMax!==n.scaleFactorMax)&&(s=setZoomLevels(s,n.scaleFactorMin,n.scaleFactorMax),o=!0),o&&this.setValue(s)}componentDidMount(){this.autoPanIsRunning=!0,requestAnimationFrame(this.autoPanLoop),this.ViewerDOM.addEventListener("wheel",this.onWheel,!1)}componentWillUnmount(){this.autoPanIsRunning=!1,this.ViewerDOM.removeEventListener("wheel",this.onWheel)}getValue(){return isValueValid(this.props.value)?this.props.value:this.state.defaultValue}getTool(){return this.props.tool?this.props.tool:TOOL_NONE}setValue(e){let{onChangeValue:t,onZoom:n,onPan:s}=this.props;t&&t(e),e.lastAction&&(n&&e.lastAction===ACTION_ZOOM&&n(e),s&&e.lastAction===ACTION_PAN&&s(e))}pan(e,t){let n=pan(this.getValue(),e,t);this.setValue(n)}zoom(e,t,n){let s=zoom(this.getValue(),e,t,n);this.setValue(s)}fitSelection(e,t,n,s){let o=fitSelection(this.getValue(),e,t,n,s);this.setValue(o)}fitToViewer(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ALIGN_LEFT,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ALIGN_TOP,n=fitToViewer(this.getValue(),e,t);this.setValue(n)}zoomOnViewerCenter(e){let t=zoomOnViewerCenter(this.getValue(),e);this.setValue(t)}setPointOnViewerCenter(e,t,n){let s=setPointOnViewerCenter(this.getValue(),e,t,n);this.setValue(s)}reset(){let e=reset(this.getValue());this.setValue(e)}openMiniature(){let e=openMiniature(this.getValue());this.setValue(e)}closeMiniature(){let e=closeMiniature(this.getValue());this.setValue(e)}handleViewerEvent(e){let{props:t,ViewerDOM:n}=this;if(!([TOOL_NONE,TOOL_AUTO].indexOf(this.getTool())>=0)||e.target===n)return;let o={click:t.onClick,dblclick:t.onDoubleClick,mousemove:t.onMouseMove,mouseup:t.onMouseUp,mousedown:t.onMouseDown,touchstart:t.onTouchStart,touchmove:t.onTouchMove,touchend:t.onTouchEnd,touchcancel:t.onTouchCancel}[e.type];o&&o(eventFactory(e,t.value,n))}autoPanLoop(){let e={x:this.state.pointerX,y:this.state.pointerY},t=onInterval(null,this.ViewerDOM,this.getTool(),this.getValue(),this.props,e);this.getValue()!==t&&this.setValue(t),this.autoPanIsRunning&&requestAnimationFrame(this.autoPanLoop)}onWheel(e){let t=onWheel(e,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==t&&this.setValue(t)}render(){let{props:e,state:{pointerX:t,pointerY:n}}=this,s=this.getTool(),o=this.getValue(),{customToolbar:a=Toolbar$1,customMiniature:l=Miniature}=e,c=s===TOOL_AUTO&&o.mode===MODE_PANNING&&o.startX!==o.endX&&o.startY!==o.endY,u;s===TOOL_PAN&&(u=cursorPolyfill(o.mode===MODE_PANNING?"grabbing":"grab")),s===TOOL_ZOOM_IN&&(u=cursorPolyfill("zoom-in")),s===TOOL_ZOOM_OUT&&(u=cursorPolyfill("zoom-out")),c&&(u=cursorPolyfill("grabbing"));let h=[TOOL_PAN,TOOL_ZOOM_IN,TOOL_ZOOM_OUT].indexOf(s)>=0;h=h||c;const d=this.props.detectPinchGesture||[TOOL_PAN,TOOL_AUTO].indexOf(this.getTool())!==-1?"none":void 0,p={display:"block",cursor:u,touchAction:d};return React.createElement("div",{style:_objectSpread$1({position:"relative",width:o.viewerWidth,height:o.viewerHeight},e.style),className:this.props.className},React.createElement("svg",{ref:f=>this.ViewerDOM=f,width:o.viewerWidth,height:o.viewerHeight,style:p,onMouseDown:f=>{let g=onMouseDown$1(f,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==g&&this.setValue(g),this.handleViewerEvent(f)},onMouseMove:f=>{let{left:g,top:_}=this.ViewerDOM.getBoundingClientRect(),x=f.clientX-Math.round(g),y=f.clientY-Math.round(_),E=onMouseMove$1(f,this.ViewerDOM,this.getTool(),this.getValue(),this.props,{x,y});this.getValue()!==E&&this.setValue(E),this.setState({pointerX:x,pointerY:y}),this.handleViewerEvent(f)},onMouseUp:f=>{let g=onMouseUp(f,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==g&&this.setValue(g),this.handleViewerEvent(f)},onClick:f=>{this.handleViewerEvent(f)},onDoubleClick:f=>{let g=onDoubleClick(f,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==g&&this.setValue(g),this.handleViewerEvent(f)},onMouseEnter:f=>{if(isTouchDevice())return;let g=onMouseEnterOrLeave(f,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==g&&this.setValue(g)},onMouseLeave:f=>{let g=onMouseEnterOrLeave(f,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==g&&this.setValue(g)},onTouchStart:f=>{let g=onTouchStart$1(f,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==g&&this.setValue(g),this.handleViewerEvent(f)},onTouchMove:f=>{let g=onTouchMove$1(f,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==g&&this.setValue(g),this.handleViewerEvent(f)},onTouchEnd:f=>{let g=onTouchEnd(f,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==g&&this.setValue(g),this.handleViewerEvent(f)},onTouchCancel:f=>{let g=onTouchCancel(f,this.ViewerDOM,this.getTool(),this.getValue(),this.props);this.getValue()!==g&&this.setValue(g),this.handleViewerEvent(f)}},React.createElement("rect",{fill:e.background,x:0,y:0,width:o.viewerWidth,height:o.viewerHeight,style:{pointerEvents:"none"}}),React.createElement("g",{transform:toSVG(o),style:h?{pointerEvents:"none"}:{}},React.createElement("rect",{fill:this.props.SVGBackground,style:this.props.SVGStyle,x:o.SVGMinX||0,y:o.SVGMinY||0,width:o.SVGWidth,height:o.SVGHeight}),React.createElement("g",null,e.children.props.children)),[TOOL_NONE,TOOL_AUTO].indexOf(s)>=0&&e.detectAutoPan&&o.focus?React.createElement("g",{style:{pointerEvents:"none"}},n<=20?React.createElement(BorderGradient$1,{direction:POSITION_TOP,width:o.viewerWidth,height:o.viewerHeight}):null,o.viewerWidth-t<=20?React.createElement(BorderGradient$1,{direction:POSITION_RIGHT,width:o.viewerWidth,height:o.viewerHeight}):null,o.viewerHeight-n<=20?React.createElement(BorderGradient$1,{direction:POSITION_BOTTOM,width:o.viewerWidth,height:o.viewerHeight}):null,o.focus&&t<=20?React.createElement(BorderGradient$1,{direction:POSITION_LEFT,width:o.viewerWidth,height:o.viewerHeight}):null):null,o.mode!==MODE_ZOOMING?null:React.createElement(Selection,{startX:o.startX,startY:o.startY,endX:o.endX,endY:o.endY})),e.toolbarProps.position===POSITION_NONE?null:React.createElement(a,_extends$2({},this.props.toolbarProps,{value:o,onChangeValue:f=>this.setValue(f),tool:s,onChangeTool:f=>this.props.onChangeTool(f)})),e.miniatureProps.position===POSITION_NONE?null:React.createElement(l,_extends$2({},this.props.miniatureProps,{value:o,onChangeValue:f=>this.setValue(f),SVGBackground:this.props.SVGBackground}),e.children.props.children))}}ReactSVGPanZoom.propTypes={width:PropTypes.number.isRequired,height:PropTypes.number.isRequired,value:PropTypes.oneOfType([PropTypes.object,PropTypes.shape({version:PropTypes.oneOf([2]).isRequired,mode:PropTypes.oneOf([MODE_IDLE,MODE_PANNING,MODE_ZOOMING]).isRequired,focus:PropTypes.bool.isRequired,a:PropTypes.number.isRequired,b:PropTypes.number.isRequired,c:PropTypes.number.isRequired,d:PropTypes.number.isRequired,e:PropTypes.number.isRequired,f:PropTypes.number.isRequired,viewerWidth:PropTypes.number.isRequired,viewerHeight:PropTypes.number.isRequired,SVGMinX:PropTypes.number.isRequired,SVGMinY:PropTypes.number.isRequired,SVGWidth:PropTypes.number.isRequired,SVGHeight:PropTypes.number.isRequired,startX:PropTypes.number,startY:PropTypes.number,endX:PropTypes.number,endY:PropTypes.number,miniatureOpen:PropTypes.bool.isRequired})]).isRequired,onChangeValue:PropTypes.func.isRequired,tool:PropTypes.oneOf([TOOL_AUTO,TOOL_NONE,TOOL_PAN,TOOL_ZOOM_IN,TOOL_ZOOM_OUT]).isRequired,onChangeTool:PropTypes.func.isRequired,background:PropTypes.string,SVGBackground:PropTypes.string,SVGStyle:PropTypes.object,style:PropTypes.object,className:PropTypes.string,detectWheel:PropTypes.bool,detectAutoPan:PropTypes.bool,detectPinchGesture:PropTypes.bool,onZoom:PropTypes.func,onPan:PropTypes.func,onClick:PropTypes.func,onDoubleClick:PropTypes.func,onMouseUp:PropTypes.func,onMouseMove:PropTypes.func,onMouseDown:PropTypes.func,preventPanOutside:PropTypes.bool,scaleFactor:PropTypes.number,scaleFactorOnWheel:PropTypes.number,scaleFactorMax:PropTypes.number,scaleFactorMin:PropTypes.number,modifierKeys:PropTypes.array,disableDoubleClickZoomWithToolAuto:PropTypes.bool,customMiniature:PropTypes.oneOfType([PropTypes.element,PropTypes.func]),miniatureProps:PropTypes.shape({position:PropTypes.oneOf([POSITION_NONE,POSITION_RIGHT,POSITION_LEFT]),background:PropTypes.string,width:PropTypes.number,height:PropTypes.number}),customToolbar:PropTypes.oneOfType([PropTypes.element,PropTypes.func]),toolbarProps:PropTypes.shape({position:PropTypes.oneOf([POSITION_NONE,POSITION_TOP,POSITION_RIGHT,POSITION_BOTTOM,POSITION_LEFT]),SVGAlignX:PropTypes.oneOf([ALIGN_CENTER,ALIGN_LEFT,ALIGN_RIGHT]),SVGAlignY:PropTypes.oneOf([ALIGN_CENTER,ALIGN_TOP,ALIGN_BOTTOM]),activeToolColor:PropTypes.string}),children:function(i,e,t){let n=i[e],s=["svg"];if(React.Children.count(n)!==1||s.indexOf(n.type)===-1)return new Error("`"+t+"` should have a single child of the following types: `"+s.join("`, `")+"`.");if((!n.props.hasOwnProperty("width")||!n.props.hasOwnProperty("height"))&&!n.props.hasOwnProperty("viewBox"))return new Error("SVG should have props `width` and `height` or `viewBox`")}},ReactSVGPanZoom.defaultProps={style:{},background:"#616264",SVGBackground:"#fff",SVGStyle:{},detectWheel:!0,detectAutoPan:!0,detectPinchGesture:!0,modifierKeys:["Alt","Shift","Control"],preventPanOutside:!0,scaleFactor:1.1,scaleFactorOnWheel:1.06,disableZoomWithToolAuto:!1,onZoom:null,onPan:null,toolbarProps:{},miniatureProps:{}};const _excluded$1=["width","height","onChangeTool","onChangeValue"];function _extends$1(){return _extends$1=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},_extends$1.apply(null,arguments)}function _objectWithoutProperties$1(i,e){if(i==null)return{};var t,n,s=_objectWithoutPropertiesLoose$1(i,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(i);for(n=0;n<o.length;n++)t=o[n],e.includes(t)||{}.propertyIsEnumerable.call(i,t)&&(s[t]=i[t])}return s}function _objectWithoutPropertiesLoose$1(i,e){if(i==null)return{};var t={};for(var n in i)if({}.hasOwnProperty.call(i,n)){if(e.includes(n))continue;t[n]=i[n]}return t}class UncontrolledReactSVGPanZoom extends React.Component{constructor(e){super(e),this.state={value:e.defaultValue||{},tool:e.defaultTool||TOOL_NONE},this.Viewer=null,this.changeTool=this.changeTool.bind(this),this.changeValue=this.changeValue.bind(this)}changeTool(e){this.setState({tool:e})}changeValue(e){this.setState({value:e})}pan(e,t){this.Viewer.pan(e,t)}zoom(e,t,n){this.Viewer.zoom(e,t,n)}fitSelection(e,t,n,s){this.Viewer.fitSelection(e,t,n,s)}fitToViewer(e,t){this.Viewer.fitToViewer(e,t)}zoomOnViewerCenter(e){this.Viewer.zoomOnViewerCenter(e)}setPointOnViewerCenter(e,t,n){this.Viewer.setPointOnViewerCenter(e,t,n)}reset(){this.Viewer.reset()}openMiniature(){this.Viewer.openMiniature()}closeMiniature(){this.Viewer.closeMiniature()}render(){const e=this.props,{width:t,height:n,onChangeTool:s,onChangeValue:o}=e,a=_objectWithoutProperties$1(e,_excluded$1),{tool:l,value:c}=this.state;return React.createElement(ReactSVGPanZoom,_extends$1({width:t,height:n,tool:l,onChangeTool:this.changeTool,value:c,onChangeValue:this.changeValue,ref:u=>this.Viewer=u},a))}}UncontrolledReactSVGPanZoom.propTypes={width:PropTypes.number.isRequired,height:PropTypes.number.isRequired,defaultValue:PropTypes.object,defaultTool:PropTypes.string};let activeFitAnimation=null;const SURFACE_DUPLICATE_GAP=30,leaveSurfaceTool=i=>{const e=i.get("mode");if(e!==MODE_DRAWING_SURFACE&&e!==MODE_WAITING_DRAWING_SURFACE)return null;const{updatedState:t,finished:n}=Surface.finishDrawingSurface(i);return n?t:Project.rollback(i).updatedState},exitingTools=i=>leaveSurfaceTool(i)??i,sameHover=(i,e)=>i===e?!0:!i||!e?!1:i.layerID===e.layerID&&i.prototype===e.prototype&&i.id===e.id&&i.part===e.part&&i.lineID===e.lineID,isSurfaceArea=(i,e,t)=>{const n=i.getIn(["scene","layers",e]),s=n==null?void 0:n.getIn(["areas",t]);return!!s&&getAreaKind(s,n)==="Surface"},getSelectedElement=i=>{var l,c,u,h;const e=i.getIn(["scene","selectedLayer"]);if(!e)return null;const t=i.getIn(["scene","layers",e]);if(!t)return null;const n=(l=t.getIn(["selected","items"]))==null?void 0:l.first();if(n)return{layerID:e,kind:"item",id:n};const s=(c=t.getIn(["selected","holes"]))==null?void 0:c.first();if(s)return{layerID:e,kind:"hole",id:s};const o=(u=t.getIn(["selected","areas"]))==null?void 0:u.first();if(o){const d=t.getIn(["areas",o]);return getAreaKind(d,t)==="Surface"?{layerID:e,kind:"surface",id:o}:null}const a=(h=t.getIn(["selected","lines"]))==null?void 0:h.find(d=>t.getIn(["lines",d,"type"])==="wall");return a?{layerID:e,kind:"wall",id:a}:null},easeOutCubic=i=>1-Math.pow(1-i,3);function fitSelectionMatrix(i,e,t,n,s){var u;if(!i||typeof i.setValue!="function")return null;const o=(u=i.getValue)==null?void 0:u.call(i);if(!o)return null;const{viewerWidth:a,viewerHeight:l}=o;if(!a||!l)return null;const c=Math.min(a/n,l/s);return{start:o,scale:c,e:-e*c,f:-t*c}}function applyFitSelection(i,e,t,n,s){const o=fitSelectionMatrix(i,e,t,n,s);o&&(activeFitAnimation!==null&&(cancelAnimationFrame(activeFitAnimation),activeFitAnimation=null),i.setValue({...o.start,a:o.scale,b:0,c:0,d:o.scale,e:o.e,f:o.f,mode:"idle"}))}function animateFitSelection(i,e,t,n,s,o=350){const a=fitSelectionMatrix(i,e,t,n,s);if(!a)return;const{start:l,scale:c,e:u,f:h}=a,d=l.a??1,p=l.e??0,f=l.f??0;if(Math.abs(d-c)<.001&&Math.abs(p-u)<.5&&Math.abs(f-h)<.5)return;activeFitAnimation!==null&&(cancelAnimationFrame(activeFitAnimation),activeFitAnimation=null);const _=performance.now(),x=y=>{const E=Math.min(1,(y-_)/o),b=easeOutCubic(E),v=d+(c-d)*b,M=p+(u-p)*b,T=f+(h-f)*b;i.setValue({...l,a:v,b:0,c:0,d:v,e:M,f:T,mode:"idle"}),E<1?activeFitAnimation=requestAnimationFrame(x):activeFitAnimation=null};activeFitAnimation=requestAnimationFrame(x)}const useReactPlannerStore=create((i,e)=>({planner:new State$1,viewer:null,viewer3D:null,plan:null,toast:null,showDimensions:!1,showGrid:!1,activeFloor:0,theme:typeof window<"u"&&localStorage.getItem("fp-theme")||"dark",setViewer:t=>{i(n=>({...n,viewer:t}))},setViewer3D:t=>{i(n=>({...n,viewer3D:t}))},setToast:t=>{i(n=>({...n,toast:t}))},setActiveFloor:t=>{i(n=>({...n,activeFloor:t}))},newProject:()=>{i(t=>({...t,planner:Project.newProject(t.planner).updatedState}))},selectTool3DView:()=>{i(t=>{const s=Project.unselectAll(exitingTools(t.planner)).updatedState.set("mode",MODE_3D_VIEW);return{...t,planner:s,showDimensions:!1}})},selectTool3DFirstPerson:()=>{i(t=>{const s=Project.rollback(exitingTools(t.planner)).updatedState.set("mode",MODE_3D_FIRST_PERSON);return{...t,planner:s}})},loadProject:t=>{i(n=>{const s=new State$1({scene:t,catalog:n.planner.catalog.toJS()});return{...n,planner:s}})},undo:()=>{i(t=>{const n=Project.undo(t.planner).updatedState;return{...t,planner:n}})},redo:()=>{i(t=>{const n=Project.redo(t.planner).updatedState;return{...t,planner:n}})},addLayer:(t,n)=>{i(s=>{const o=Layer$1.create(s.planner,t,n).updatedState;return{...s,planner:o}})},removeLayer:t=>{i(n=>{const s=Layer$1.remove(n.planner,t).updatedState;return{...n,planner:s}})},addGroup:()=>{i(t=>{const n=Group$2.create(t.planner).updatedState;return{...t,planner:n}})},selectGroup:t=>{i(n=>{const s=Group$2.select(n.planner,t).updatedState;return{...n,planner:s}})},setGroupProperties:(t,n)=>{i(s=>{const o=Group$2.setProperties(s.planner,t,n).updatedState;return{...s,planner:o}})},addToGroup:(t,n,s,o)=>{i(a=>{const l=Group$2.addElement(a.planner,t,n,s,o).updatedState;return{...a,planner:l}})},removeGroup:t=>{i(n=>{const s=Group$2.remove(n.planner,t).updatedState;return{...n,planner:s}})},setGroupAttributes:(t,n)=>{i(s=>{const o=Group$2.setAttributes(s.planner,t,n).updatedState;return{...s,planner:o}})},groupTranslate:(t,n,s)=>{i(o=>{const a=Group$2.translate(o.planner,t,n,s).updatedState;return{...o,planner:a}})},removeFromGroup:(t,n,s,o)=>{i(a=>{const l=Group$2.removeElement(a.planner,t,n,s,o).updatedState;return{...a,planner:l}})},groupRotate:(t,n)=>{i(s=>{const o=Group$2.rotate(s.planner,t,n).updatedState;return{...s,planner:o}})},removeGroupAndDeleteElements:t=>{i(n=>{const s=Group$2.removeAndDeleteElements(n.planner,t).updatedState;return{...n,planner:s}})},addGroupFromSelected:()=>{i(t=>{const n=Group$2.createFromSelectedElements(t.planner).updatedState;return{...t,planner:n}})},copyProperties:t=>{i(n=>({...n,planner:Project.copyProperties(n.planner,t).updatedState}))},setProjectProperties:t=>{i(n=>({...n,planner:Project.setProjectProperties(n.planner,t).updatedState}))},pasteProperties:()=>{i(t=>{const n=t.planner.merge({sceneHistory:historyPush(t.planner.sceneHistory,t.planner.scene)});return{...t,planner:Project.pasteProperties(n).updatedState}})},setProperties:t=>{i(n=>{const s=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});return{...n,planner:Project.setProperties(s,s.getIn(["scene","selectedLayer"]),t).updatedState}})},setHolesAttributes:t=>{i(n=>{const s=t.set("offset",parseFloat(t.get("offset"))),o=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});return{...n,planner:Project.setHolesAttributes(o,s).updatedState}})},setLinesAttributes:t=>{i(n=>{const s=t.withMutations(a=>{a.setIn(["vertexOne","x"],parseFloat(t.getIn(["vertexOne","x"]))),a.setIn(["vertexOne","y"],parseFloat(t.getIn(["vertexOne","y"]))),a.setIn(["vertexTwo","x"],parseFloat(t.getIn(["vertexTwo","x"]))),a.setIn(["vertexTwo","y"],parseFloat(t.getIn(["vertexTwo","y"])))}),o=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});return{...n,planner:Project.setLinesAttributes(o,s).updatedState}})},setItemsAttributes:t=>{i(n=>{const s=t.set("rotation",parseFloat(t.get("rotation"))),o=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});return{...n,planner:Project.setItemsAttributes(o,s).updatedState}})},selectLine:(t,n)=>{i(s=>{const o=Line$2.select(s.planner,t,n).updatedState;return{...s,planner:o}})},selectHole:(t,n)=>{i(s=>{const o=Hole.select(s.planner,t,n).updatedState;return{...s,planner:o}})},selectItem:(t,n)=>{i(s=>{const o=Item$1.select(s.planner,t,n).updatedState;return{...s,planner:o}})},selectLayer:t=>{i(n=>{const s=Layer$1.select(n.planner,t).updatedState;return{...n,planner:s}})},setLayerProperties:(t,n)=>{i(s=>{const o=Layer$1.setProperties(s.planner,t,n).updatedState;return{...s,planner:o}})},addVerticalGuide:t=>{i(n=>{const s=VerticalGuide.create(n.planner,t).updatedState;return{...n,planner:s}})},addHorizontalGuide:t=>{i(n=>{const s=HorizontalGuide.create(n.planner,t).updatedState;return{...n,planner:s}})},removeVerticalGuide:t=>{i(n=>{const s=VerticalGuide.remove(n.planner,t).updatedState;return{...n,planner:s}})},removeHorizontalGuide:t=>{i(n=>{const s=HorizontalGuide.remove(n.planner,t).updatedState;return{...n,planner:s}})},toggleSnap:t=>{i(n=>{const s=Project.toggleSnap(n.planner,t).updatedState;return{...n,planner:s}})},openProjectConfigurator:()=>{i(t=>{const n=Project.openProjectConfigurator(exitingTools(t.planner)).updatedState;return{...t,planner:n}})},setMode:t=>{i(n=>{const s=exitingTools(n.planner).set("mode",t);return{...n,planner:s}})},updateZoomScale:t=>{i(n=>({...n,planner:Project.updateZoomScale(n.planner,t).updatedState}))},updateCameraView:t=>{i(n=>{const s=n.planner.update("viewer2D",o=>o.merge(fromJS(t)));return{...n,planner:s}})},selectToolPan:()=>{i(t=>{const n=exitingTools(t.planner).set("mode",MODE_2D_PAN);return{...t,planner:n}})},selectToolEdit:()=>{i(t=>({...t,planner:Project.setMode(exitingTools(t.planner),MODE_IDLE$1).updatedState}))},selectToolZoomIn:()=>{i(t=>{const n=exitingTools(t.planner).set("mode",MODE_2D_ZOOM_IN);return{...t,planner:n}})},selectToolZoomOut:()=>{i(t=>{const n=exitingTools(t.planner).set("mode",MODE_2D_ZOOM_OUT);return{...t,planner:n}})},updateDrawingLine:(t,n)=>{i(s=>({...s,planner:Line$2.updateDrawingLine(s.planner,t,n).updatedState}))},updateDrawingSurface:(t,n)=>{i(s=>({...s,planner:Surface.updateDrawingSurface(s.planner,t,n).updatedState}))},updateMouseCoord:t=>{i(n=>({...n,planner:Project.updateMouseCoord(n.planner,t).updatedState}))},openCatalog:()=>{i(t=>{const n=exitingTools(t.planner).set("mode",MODE_VIEWING_CATALOG);return{...t,planner:n}})},updateDrawingHole:(t,n,s)=>{i(o=>({...o,planner:Hole.updateDrawingHole(o.planner,t,n,s).updatedState}))},updateDrawingItem:(t,n,s)=>{i(o=>({...o,planner:Item$1.updateDrawingItem(o.planner,t,n,s).updatedState}))},blur:()=>{i(t=>{const n=t.planner.merge({mode:MODE_IDLE$1,activeSnapElement:null});return{...t,planner:n}})},updateDraggingHole:(t,n)=>{i(s=>({...s,planner:Hole.updateDraggingHole(s.planner,t,n).updatedState}))},updateDraggingLine:(t,n)=>{i(s=>({...s,planner:Line$2.updateDraggingLine(s.planner,t,n).updatedState}))},updateDraggingVertex:(t,n)=>{i(s=>({...s,planner:Vertex$2.updateDraggingVertex(s.planner,t,n).updatedState}))},updateDraggingItem:(t,n)=>{i(s=>({...s,planner:Item$1.updateDraggingItem(s.planner,t,n).updatedState}))},updateRotatingItem:(t,n)=>{i(s=>({...s,planner:Item$1.updateRotatingItem(s.planner,t,n).updatedState}))},beginDraggingLine:(t,n,s,o)=>{i(a=>{const l=a.planner.merge({sceneHistory:historyPush(a.planner.sceneHistory,a.planner.scene)});return{...a,planner:Line$2.beginDraggingLine(l,t,n,s,o).updatedState}})},endDraggingLine:(t,n)=>{i(s=>({...s,planner:Line$2.endDraggingLine(s.planner,t,n).updatedState}))},beginDraggingVertex:(t,n)=>{i(s=>{const o=s.planner.merge({sceneHistory:historyPush(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Vertex$2.beginDraggingVertex(o,t,n).updatedState}})},endDraggingVertex:()=>{i(t=>({...t,planner:Vertex$2.endDraggingVertex(t.planner).updatedState}))},resizeHandlesFor:null,setResizeHandlesFor:t=>{i(n=>({...n,resizeHandlesFor:t}))},hoveredElement:null,setHoveredElement:t=>{sameHover(e().hoveredElement,t)||i(n=>({...n,hoveredElement:t}))},duplicateSelected:()=>{const t=getSelectedElement(e().planner);if(t){if(t.kind==="surface"){e().duplicateSurface(t.id);return}t.kind!=="wall"&&i(n=>{const s=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});return{...n,planner:t.kind==="item"?Item$1.duplicate(s,t.layerID,t.id).updatedState:Hole.duplicate(s,t.layerID,t.id).updatedState}})}},duplicateItem:t=>{i(n=>{const s=n.planner.getIn(["scene","selectedLayer"]);if(!s)return n;const o=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});return{...n,planner:Item$1.duplicate(o,s,t).updatedState}})},duplicateHole:t=>{i(n=>{const s=n.planner.getIn(["scene","selectedLayer"]);if(!s)return n;const o=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});return{...n,planner:Hole.duplicate(o,s,t).updatedState}})},setItemAttributes:(t,n)=>{i(s=>{const o=s.planner.getIn(["scene","selectedLayer"]);if(!o||!s.planner.getIn(["scene","layers",o,"items",t]))return s;const a=s.planner.merge({sceneHistory:historyPush(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Item$1.setAttributes(a,o,t,n).updatedState}})},setHoleAttributes:(t,n)=>{i(s=>{const o=s.planner.getIn(["scene","selectedLayer"]);if(!o||!s.planner.getIn(["scene","layers",o,"holes",t]))return s;const a=s.planner.merge({sceneHistory:historyPush(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Hole.mergeAttributes(a,o,t,n).updatedState}})},moveHole:(t,n)=>{i(s=>{const o=s.planner.getIn(["scene","selectedLayer"]);if(!o||!s.planner.getIn(["scene","layers",o,"holes",t]))return s;const a=s.planner.merge({sceneHistory:historyPush(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Hole.mergeAttributes(a,o,t,{offset:Math.min(1,Math.max(0,n))}).updatedState}})},setHoleProperties:(t,n)=>{i(s=>{const o=s.planner.getIn(["scene","selectedLayer"]);if(!o)return s;const a=s.planner.getIn(["scene","layers",o,"holes",t]);if(!a)return s;const l=s.planner.merge({sceneHistory:historyPush(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Hole.setProperties(l,o,t,a.properties.merge(fromJS(n))).updatedState}})},rotateSelected:t=>{i(n=>{const s=getSelectedElement(n.planner);if(!s||s.kind!=="item"&&s.kind!=="surface")return n;const o=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});return{...n,planner:s.kind==="item"?Item$1.rotate(o,s.layerID,s.id,t).updatedState:Area$1.rotate(o,s.layerID,s.id,-t).updatedState}})},flipSelected:t=>{i(n=>{const s=getSelectedElement(n.planner);if(!s||s.kind==="wall")return n;const o=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)}),{layerID:a,id:l}=s;let c;return s.kind==="item"?c=Item$1.flip(o,a,l,t).updatedState:s.kind==="hole"?c=Hole.flip(o,a,l,t).updatedState:c=Area$1.mirror(o,a,l,t).updatedState,{...n,planner:c}})},rotateArea:(t,n)=>{i(s=>{const o=s.planner.getIn(["scene","selectedLayer"]);if(!o||!isSurfaceArea(s.planner,o,t))return s;const a=s.planner.merge({sceneHistory:historyPush(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Area$1.rotate(a,o,t,-n).updatedState}})},mirrorArea:(t,n)=>{i(s=>{const o=s.planner.getIn(["scene","selectedLayer"]);if(!o||!isSurfaceArea(s.planner,o,t))return s;const a=s.planner.merge({sceneHistory:historyPush(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Area$1.mirror(a,o,t,n).updatedState}})},duplicateSurface:t=>{i(n=>{const s=n.planner.getIn(["scene","selectedLayer"]);if(!s)return n;const o=n.planner.getIn(["scene","layers",s]),a=o==null?void 0:o.getIn(["areas",t]);if(!a)return n;const c=a.get("vertices").toArray().map(E=>o.getIn(["vertices",E])).filter(Boolean).map(E=>({x:E.get("x"),y:E.get("y")}));if(c.length<3)return n;const u=c.map(E=>E.x),h=Math.max(...u)-Math.min(...u)+SURFACE_DUPLICATE_GAP,d=c.map(E=>({x:E.x+h,y:E.y})),p=Area$1.getSurfaceLines(n.planner,s,t).first(),f=p&&o.getIn(["lines",p,"type"])||"surface",g=new Set(o.get("areas").keySeq().toArray());let _=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});for(let E=0;E<d.length;E++){const b=d[E],v=d[(E+1)%d.length];_=Line$2.createAvoidingIntersections(_,s,f,b.x,b.y,v.x,v.y).updatedState}_=Layer$1.detectAndUpdateAreas(_,s).updatedState;const x=a.get("properties"),y=[];_.getIn(["scene","layers",s,"areas"]).keySeq().forEach(E=>{g.has(E)||y.push(E)});for(const E of y)_=Area$1.setProperties(_,s,E,x).updatedState;return y.length>0&&(_=Area$1.unselect(_,s,t).updatedState,_=Area$1.select(_,s,y[0]).updatedState),{...n,planner:_}})},beginResizingItem:(t,n,s,o)=>{i(a=>{const l=a.planner.merge({sceneHistory:historyPush(a.planner.sceneHistory,a.planner.scene)});return{...a,planner:Item$1.beginResizingItem(l,t,n,s,o).updatedState}})},updateResizingItem:(t,n)=>{i(s=>({...s,planner:Item$1.updateResizingItem(s.planner,t,n).updatedState}))},endResizingItem:(t,n)=>{i(s=>({...s,planner:Item$1.endResizingItem(s.planner,t,n).updatedState}))},beginRotatingItem:(t,n,s,o)=>{i(a=>{const l=a.planner.merge({sceneHistory:historyPush(a.planner.sceneHistory,a.planner.scene)});return{...a,planner:Item$1.beginRotatingItem(l,t,n,s,o).updatedState}})},endRotatingItem:(t,n)=>{i(s=>({...s,planner:Item$1.endRotatingItem(s.planner,t,n).updatedState}))},beginDraggingItem:(t,n,s,o)=>{i(a=>{const l=a.planner.merge({sceneHistory:historyPush(a.planner.sceneHistory,a.planner.scene)});return{...a,planner:Item$1.beginDraggingItem(l,t,n,s,o).updatedState}})},endDraggingItem:(t,n)=>{i(s=>({...s,planner:Item$1.endDraggingItem(s.planner,t,n).updatedState}))},beginDraggingHole:(t,n,s,o)=>{i(a=>{const l=a.planner.merge({sceneHistory:historyPush(a.planner.sceneHistory,a.planner.scene)});return{...a,planner:Hole.beginDraggingHole(l,t,n,s,o).updatedState}})},endDraggingHole:(t,n)=>{i(s=>({...s,planner:Hole.endDraggingHole(s.planner,t,n).updatedState}))},beginDrawingLine:(t,n,s)=>{i(o=>{const a=o.planner.merge({sceneHistory:historyPush(o.planner.sceneHistory,o.planner.scene)});return{...o,planner:Line$2.beginDrawingLine(a,t,n,s).updatedState}})},endDrawingLine:(t,n)=>{i(s=>({...s,planner:Line$2.endDrawingLine(s.planner,t,n).updatedState}))},beginDrawingSurface:(t,n,s)=>{i(o=>{const a=o.planner.getIn(["drawingSupport","points"]),l=a&&a.size?o.planner:o.planner.merge({sceneHistory:historyPush(o.planner.sceneHistory,o.planner.scene)});return{...o,planner:Surface.beginDrawingSurface(l,t,n,s).updatedState}})},endDrawingSurface:(t,n)=>{i(s=>({...s,planner:Surface.endDrawingSurface(s.planner,t,n).updatedState}))},endDrawingHole:(t,n,s)=>{i(o=>{const a=o.planner.merge({sceneHistory:historyPush(o.planner.sceneHistory,o.planner.scene)});return{...o,planner:Hole.endDrawingHole(a,t,n,s).updatedState}})},endDrawingItem:(t,n,s)=>{i(o=>{const a=o.planner.merge({sceneHistory:historyPush(o.planner.sceneHistory,o.planner.scene)});return{...o,planner:Item$1.endDrawingItem(a,t,n,s).updatedState}})},selectArea:(t,n)=>{i(s=>({...s,planner:Area$1.select(s.planner,t,n).updatedState}))},initCatalog:t=>{i(n=>({...n,planner:Project.initCatalog(n.planner,t).updatedState}))},goBackToCatalogPage:t=>{i(n=>({...n,planner:Project.goBackToCatalogPage(n.planner,t).updatedState}))},pushLastSelectedCatalogElementToHistory:t=>{i(n=>({...n,planner:Project.pushLastSelectedCatalogElementToHistory(n.planner,t).updatedState}))},selectToolDrawingLine:(t,n)=>{i(s=>({...s,planner:Line$2.selectToolDrawingLine(exitingTools(s.planner),t,n).updatedState}))},selectToolDrawingSurface:t=>{i(n=>({...n,planner:Surface.selectToolDrawingSurface(exitingTools(n.planner),t).updatedState}))},selectToolDrawingItem:t=>{i(n=>{const s=exitingTools(n.planner),o=s.merge({sceneHistory:historyPush(s.sceneHistory,s.scene)});return{...n,planner:Item$1.selectToolDrawingItem(o,t).updatedState}})},selectToolDrawingHole:t=>{i(n=>{const s=exitingTools(n.planner),o=s.merge({sceneHistory:historyPush(s.sceneHistory,s.scene)});return{...n,planner:Hole.selectToolDrawingHole(o,t).updatedState}})},changeCatalogPage:(t,n)=>{i(s=>({...s,planner:Project.changeCatalogPage(s.planner,n,t).updatedState}))},remove:()=>{i(t=>{const n=t.planner.merge({sceneHistory:historyPush(t.planner.sceneHistory,t.planner.scene)});return{...t,planner:Project.remove(n).updatedState}})},rollback:()=>{i(t=>({...t,planner:leaveSurfaceTool(t.planner)??Project.rollback(t.planner).updatedState}))},setAlterateState:()=>{i(t=>({...t,planner:Project.setAlterate(t.planner).updatedState}))},setPlan:t=>{i(n=>({...n,plan:t}))},unselectAll:()=>{i(t=>({...t,planner:Project.unselectAll(t.planner).updatedState}))},setShowDimensions:t=>{i(n=>({...n,showDimensions:t}))},setShowGrid:t=>{i(n=>({...n,showGrid:t}))},setTheme:t=>{if(typeof window<"u")try{localStorage.setItem("fp-theme",t)}catch{}i(n=>({...n,theme:t}))},addHoleOnLine:(t,n,s)=>{let o;return i(a=>{const l=a.planner.getIn(["scene","selectedLayer"]);if(!l)return a;const c=a.planner.merge({sceneHistory:historyPush(a.planner.sceneHistory,a.planner.scene)}),u=Math.max(.05,Math.min(.95,s)),{updatedState:h,hole:d}=Hole.create(c,l,n,t,u);return o=d==null?void 0:d.id,{...a,planner:h}}),o},setAreaProperties:(t,n)=>{i(s=>{const o=s.planner.getIn(["scene","selectedLayer"]);if(!o)return s;const a=s.planner.merge({sceneHistory:historyPush(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Area$1.setJsProperties(a,o,t,n).updatedState}})},setLineProperties:(t,n)=>{i(s=>{const o=s.planner.getIn(["scene","selectedLayer"]);if(!o||!s.planner.getIn(["scene","layers",o,"lines",t]))return s;const l=s.planner.merge({sceneHistory:historyPush(s.planner.sceneHistory,s.planner.scene)});return{...s,planner:Line$2.setJsProperties(l,o,t,n).updatedState}})},moveVertex:(t,n,s)=>{i(o=>{const a=o.planner.getIn(["scene","selectedLayer"]);if(!a||!o.planner.getIn(["scene","layers",a,"vertices",t]))return o;const u=o.planner.merge({sceneHistory:historyPush(o.planner.sceneHistory,o.planner.scene)}).setIn(["scene","layers",a,"vertices",t,"x"],n).setIn(["scene","layers",a,"vertices",t,"y"],s);return{...o,planner:Layer$1.detectAndUpdateAreas(u,a).updatedState}})},removeLine:t=>{i(n=>{const s=n.planner.getIn(["scene","selectedLayer"]);if(!s||!n.planner.getIn(["scene","layers",s,"lines",t]))return n;const o=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)}),a=Line$2.remove(o,s,t).updatedState;return{...n,planner:Layer$1.detectAndUpdateAreas(a,s).updatedState}})},removeArea:t=>{i(n=>{const s=n.planner.getIn(["scene","selectedLayer"]);if(!s)return n;const o=n.planner.getIn(["scene","layers",s,"areas",t]);if(!o)return n;const a=new Set(o.get("vertices").toArray()),l=n.planner.getIn(["scene","layers",s,"lines"]),c=[];if(l.forEach((d,p)=>{const f=d.get("vertices").toArray();a.has(f[0])&&a.has(f[1])&&c.push(p)}),c.length===0)return n;let h=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});for(const d of c)h=Line$2.remove(h,s,d).updatedState;return{...n,planner:Layer$1.detectAndUpdateAreas(h,s).updatedState}})},removeItem:t=>{i(n=>{const s=n.planner.getIn(["scene","selectedLayer"]);if(!s||!n.planner.getIn(["scene","layers",s,"items",t]))return n;const a=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});return{...n,planner:Item$1.remove(a,s,t).updatedState}})},removeHole:t=>{i(n=>{const s=n.planner.getIn(["scene","selectedLayer"]);if(!s||!n.planner.getIn(["scene","layers",s,"holes",t]))return n;const a=n.planner.merge({sceneHistory:historyPush(n.planner.sceneHistory,n.planner.scene)});return{...n,planner:Hole.remove(a,s,t).updatedState}})},fitViewerToScene:t=>{var I;const n=e().viewer;if(!n)return;const s=(t==null?void 0:t.animate)!==!1,a=e().planner.get("scene"),l=a.get("layers"),c=a.get("height");let u=1/0,h=1/0,d=-1/0,p=-1/0,f=!1;const g=(w,R)=>{typeof w!="number"||typeof R!="number"||!isFinite(w)||!isFinite(R)||(u=Math.min(u,w),h=Math.min(h,R),d=Math.max(d,w),p=Math.max(p,R),f=!0)};if(l.forEach(w=>{const R=w.get("vertices");w.get("lines").forEach(A=>{A.get("vertices").forEach(P=>{const B=R.get(P);B&&g(B.get("x"),B.get("y"))})}),w.get("items").forEach(A=>{g(A.get("x"),A.get("y"))})}),!f||!isFinite(u)){typeof n.fitToViewer=="function"&&n.fitToViewer();return}const _=Math.max(1,d-u),x=Math.max(1,p-h),y=Math.max(_,x)*.4+150;let E=u-y,b=c-p-y,v=_+y*2,M=x+y*2;const T=(I=n.getValue)==null?void 0:I.call(n);if(T&&T.viewerWidth&&T.viewerHeight){const w=T.viewerWidth/T.viewerHeight,R=v/M;if(w>R){const A=M*w;E-=(A-v)/2,v=A}else{const A=v/w;b-=(A-M)/2,M=A}}s?animateFitSelection(n,E,b,v,M):applyFitSelection(n,E,b,v,M)},focusOnArea:(t,n)=>{var T;const s=e().viewer;if(!s)return;const a=e().planner.get("scene"),l=a.get("height"),c=a.getIn(["layers",t]),u=c&&c.getIn(["areas",n]);if(!u)return;let h=1/0,d=1/0,p=-1/0,f=-1/0;if(u.get("vertices").forEach(I=>{const w=c.getIn(["vertices",I]);if(!w)return;const R=w.get("x"),A=w.get("y");typeof R!="number"||typeof A!="number"||(h=Math.min(h,R),d=Math.min(d,A),p=Math.max(p,R),f=Math.max(f,A))}),!isFinite(h))return;const g=Math.max(1,p-h),_=Math.max(1,f-d),x=Math.max(g,_)*.4+100;let y=h-x,E=l-f-x,b=g+x*2,v=_+x*2;const M=(T=s.getValue)==null?void 0:T.call(s);if(M&&M.viewerWidth&&M.viewerHeight){const I=M.viewerWidth/M.viewerHeight,w=b/v;if(I>w){const R=v*I;y-=(R-b)/2,b=R}else{const R=b/I;E-=(R-v)/2,v=R}}animateFitSelection(s,y,E,b,v)},addWallByCoords:(t,n,s,o)=>{let a;return i(l=>{var p,f;const c=l.planner.getIn(["scene","selectedLayer"]);if(!c)return l;const u=l.planner.merge({sceneHistory:historyPush(l.planner.sceneHistory,l.planner.scene)}),{updatedState:h,lines:d}=Line$2.createAvoidingIntersections(u,c,"wall",t,n,s,o);return a=(f=(p=d==null?void 0:d.last)==null?void 0:p.call(d))==null?void 0:f.id,{...l,planner:Layer$1.detectAndUpdateAreas(h,c).updatedState}}),a},addSurfaceByPoints:(t,n="surface")=>{i(s=>{const o=s.planner.getIn(["scene","selectedLayer"]);if(!o||!t||t.length<3)return s;const a=s.planner.getIn(["catalog","elements"]),l=a&&a.get(n);if(!l||l.get("prototype")!=="lines")return s;let c=s.planner.merge({sceneHistory:historyPush(s.planner.sceneHistory,s.planner.scene)});for(let u=0;u<t.length;u++){const h=t[u],d=t[(u+1)%t.length];!h||!d||(c=Line$2.createAvoidingIntersections(c,o,n,h.x,h.y,d.x,d.y).updatedState)}return c=Layer$1.detectAndUpdateAreas(c,o).updatedState,{...s,planner:c}})},addRoom:(t,n,s,o,a)=>{i(l=>{const c=l.planner.getIn(["scene","selectedLayer"]);if(!c)return l;const u=a&&(a.thickness!=null||a.height!=null)?fromJS({...a.thickness!=null&&{thickness:{length:a.thickness,_length:a.thickness,_unit:"cm"}},...a.height!=null&&{height:{length:a.height,_length:a.height,_unit:"cm"}}}):void 0;let h=l.planner.merge({sceneHistory:historyPush(l.planner.sceneHistory,l.planner.scene)});const d=[[t,n,s,n],[s,n,s,o],[s,o,t,o],[t,o,t,n]];for(const[p,f,g,_]of d)h=Line$2.createAvoidingIntersections(h,c,"wall",p,f,g,_,u).updatedState;return{...l,planner:Layer$1.detectAndUpdateAreas(h,c).updatedState}})},selectToolDrawingRoom:t=>{i(n=>({...n,planner:Room.selectToolDrawingRoom(exitingTools(n.planner),t).updatedState}))},updateRoomDrawingProperties:t=>{i(n=>{const s={};t.thickness!=null&&(s.thickness=t.thickness),t.height!=null&&(s.height=t.height);const o=n.planner.get("drawingSupport");return o?{...n,planner:n.planner.set("drawingSupport",o.merge(s))}:n})},beginDrawingRoom:(t,n,s)=>{i(o=>({...o,planner:Room.beginDrawingRoom(o.planner,t,n,s).updatedState}))},updateDrawingRoom:(t,n)=>{i(s=>({...s,planner:Room.updateDrawingRoom(s.planner,t,n).updatedState}))},endDrawingRoom:(t,n)=>{i(s=>({...s,planner:Room.endDrawingRoom(s.planner,t,n).updatedState}))},addItemByCoords:(t,n,s,o=200,a=100,l=0)=>{let c;return i(u=>{const h=u.planner.getIn(["scene","selectedLayer"]);if(!h)return u;const d=u.planner.merge({sceneHistory:historyPush(u.planner.sceneHistory,u.planner.scene)}),{updatedState:p,item:f}=Item$1.create(d,h,t,n,s,o,a,l,0);return c=f==null?void 0:f.id,{...u,planner:p}}),c}})),STYLE$4={stroke:"#1ca6fc",strokeWidth:"1px"};function Snap({snap:i,width:e,height:t}){switch(i.type){case"point":return jsxRuntimeExports.jsxs("g",{transform:`translate(${i.x} ${i.y})`,children:[jsxRuntimeExports.jsx("line",{x1:"0",y1:"-30",x2:"0",y2:"30",style:STYLE$4}),jsxRuntimeExports.jsx("line",{x1:"-30",y1:"0",x2:"30",y2:"0",style:STYLE$4})]});case"line":let n=horizontalLine(0),s=horizontalLine(t),o=twoLinesIntersection(i.a,i.b,i.c,n.a,n.b,n.c),a=twoLinesIntersection(i.a,i.b,i.c,s.a,s.b,s.c),l=verticalLine(0),c=verticalLine(e),u=twoLinesIntersection(i.a,i.b,i.c,l.a,l.b,l.c),h=twoLinesIntersection(i.a,i.b,i.c,c.a,c.b,c.c);return o&&a?jsxRuntimeExports.jsx("line",{x1:o.x,y1:o.y,x2:a.x,y2:a.y,style:STYLE$4}):u&&h?jsxRuntimeExports.jsx("line",{x1:u.x,y1:u.y,x2:h.x,y2:h.y,style:STYLE$4}):null;case"line-segment":return jsxRuntimeExports.jsx("line",{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,style:STYLE$4});default:return null}}const COLORS={white:"#FFFFFF",black:"#000000",wall:"#FFFFFF",threeBG:"#F1F0EE",canvasBG:"#F1F0EE"},MATERIAL_COLORS={500:{orange:"#FF9800"}},PRIMARY_COLOR={alt:"#2E2F33",text_main:COLORS.white},SECONDARY_COLOR={main:"#1CA6FC"},MESH_SELECTED="#99C3FB",AREA_MESH_COLOR={selected:MESH_SELECTED,unselected:"#F5EADA"},LINE_MESH_COLOR={selected:MESH_SELECTED},SharedStyle={COLORS,PRIMARY_COLOR,SECONDARY_COLOR,MESH_SELECTED,AREA_MESH_COLOR,LINE_MESH_COLOR};function areapolygon(i,e){var t=i.length,n=0;i=i.map(normalize$2),i[0]!=i[i.length-1]&&(i=i.concat(i[0]));for(var s=0;s<t;s++)n+=i[s].x*i[s+1].y-i[s].y*i[s+1].x;return Math.abs(n)/2}function normalize$2(i){return Array.isArray(i)?{x:i[0],y:i[1]}:i}const STYLE_TEXT$1={textAnchor:"middle",fontSize:"13px",fontFamily:'"Courier New", Courier, monospace',pointerEvents:"none",fontWeight:"bold",WebkitTouchCallout:"none",WebkitUserSelect:"none",MozUserSelect:"none",userSelect:"none"},STYLE_NAME={...STYLE_TEXT$1,fontSize:"18px",fontWeight:500,fontFamily:"inherit"};function Area({layer:i,area:e,catalog:t,part:n="fill"}){if(n==="fill")return jsxRuntimeExports.jsx("g",{"data-element-root":!0,"data-prototype":e.prototype,"data-id":e.id,"data-selected":e.selected,"data-layer":i.id,children:t.getElement(e.type).render2D(e,i)});const s=e.properties.get("customName")||"",o=e.properties.get("roomCategory"),a=e.properties.get("roomType"),l=e.properties.get("showName")??!0,c=e.properties.get("showSurfaceArea")??!1,u=s||getRoomTypeLabel(o,a),h=l&&!!u;if(!h&&!c)return null;const d=e.vertices.toArray().map(_=>{const{x,y}=i.vertices.get(_);return[x,y]});let p=d;e.holes.forEach(_=>{const x=i.areas.get(_).vertices.toArray().map(y=>{const{x:E,y:b}=i.vertices.get(y);return[E,b]});p=p.concat(x.reverse())});const f=polylabel([p],1);let g=areapolygon(d);return e.holes.forEach(_=>{const y=i.areas.get(_).vertices.toArray().map(E=>{const{x:b,y:v}=i.vertices.get(E);return[b,v]});g-=areapolygon(y)}),jsxRuntimeExports.jsxs("g",{pointerEvents:"none",children:[h&&jsxRuntimeExports.jsx("text",{x:"0",y:"0",transform:`translate(${f[0]} ${f[1]}) scale(1, -1)`,style:STYLE_NAME,children:u}),c&&jsxRuntimeExports.jsxs("text",{x:"0",y:"0",transform:`translate(${f[0]} ${f[1]-(h?20:0)}) scale(1, -1)`,style:STYLE_TEXT$1,children:[(g/1e4).toFixed(2)," m","²"]})]})}const cx=0,cy=0,radius=5,STYLE_CIRCLE={fill:MATERIAL_COLORS[500].orange,stroke:MATERIAL_COLORS[500].orange,cursor:"default"};function Group$1({layer:i,group:e}){return jsxRuntimeExports.jsx("g",{"data-element-root":!0,"data-prototype":e.prototype,"data-id":e.id,"data-selected":e.selected,"data-layer":i.id,style:e.selected?{cursor:"move"}:{},transform:`translate(${e.x},${e.y}) rotate(${e.rotation})`,children:e.selected&&jsxRuntimeExports.jsx("g",{"data-element-root":!0,"data-prototype":e.prototype,"data-id":e.id,"data-selected":e.selected,"data-layer":i.id,"data-part":"rotation-anchor",children:jsxRuntimeExports.jsx("circle",{cx,cy,r:radius,style:STYLE_CIRCLE,children:jsxRuntimeExports.jsx("title",{children:"Group's Barycenter"})})})})}const SOLID_ALPHA=96,MIN_COVERAGE=.02,MAX_SCAN_SIZE=192,cache=new Map,warned=new Set,warnOnce$1=i=>{warned.has(i)||(warned.add(i),console.warn(i))};function scan(i){return new Promise(e=>{const t=new Image;t.crossOrigin="anonymous",t.onerror=()=>{warnOnce$1(`[floor-planner] couldn't load "${i}" for snapping; items using it will snap to the edge of their image rather than to the object drawn in it.`),e(null)},t.onload=()=>{const n=t.naturalWidth,s=t.naturalHeight;if(!n||!s)return e(null);const o=Math.min(1,MAX_SCAN_SIZE/Math.max(n,s)),a=Math.max(1,Math.round(n*o)),l=Math.max(1,Math.round(s*o)),c=document.createElement("canvas");c.width=a,c.height=l;const u=c.getContext("2d",{willReadFrequently:!0});if(!u)return e(null);u.drawImage(t,0,0,a,l);let h;try{h=u.getImageData(0,0,a,l).data}catch{return warnOnce$1(`[floor-planner] can't measure "${i}" for snapping: the image is cross-origin and served without an Access-Control-Allow-Origin header, so items using it snap to the edge of their image rather than to the object drawn in it.`),e(null)}const d=new Uint32Array(a),p=new Uint32Array(l);for(let x=0;x<l;x++)for(let y=0;y<a;y++)h[(x*a+y)*4+3]<SOLID_ALPHA||(d[y]++,p[x]++);const f=(x,y)=>{const E=Math.max(1,Math.round(y*MIN_COVERAGE));let b=-1,v=-1;for(let M=0;M<x.length;M++)x[M]<E||(b<0&&(b=M),v=M);return{first:b,last:v}},g=f(d,l),_=f(p,a);if(g.first<0||_.first<0)return e(null);e({left:g.first/a,top:_.first/l,right:(g.last+1)/a,bottom:(_.last+1)/l,naturalWidth:n,naturalHeight:s})},t.src=i})}function measure(i){let e=cache.get(i);return e||(e=scan(i),cache.set(i,e)),e}function fitRect(i,e,t,n){const s=n.trim().split(/\s+/).filter(Boolean),o=s.find(p=>p.startsWith("x")||p==="none"),a=s.find(p=>p==="meet"||p==="slice");if(o==="none")return i;if(a==="slice")return null;const l=Math.min(i.width/e,i.height/t),c=e*l,u=t*l,h=o??"xMidYMid",d=(p,f,g)=>g==="Min"?0:g==="Max"?p-f:(p-f)/2;return{x:i.x+d(i.width,c,h.slice(1,4)),y:i.y+d(i.height,u,h.slice(5,8)),width:c,height:u}}async function visibleImageRect(i,e,t){const n=await measure(i);if(!n)return null;const s=fitRect(e,n.naturalWidth,n.naturalHeight,t);return s?{x:s.x+n.left*s.width,y:s.y+n.top*s.height,width:(n.right-n.left)*s.width,height:(n.bottom-n.top)*s.height}:null}const HANDLE_COLOR$1="var(--dark-blue, #1ca6fc)",ROTATE_GAP=26,ROTATE_ARC_HALF_WIDTH=14,ROTATE_ARC_BULGE=8,ROTATE_DOT_RADIUS=5,ROTATE_HIT_RADIUS=16,ARROW_SIZE=5,RESIZE_HANDLE_SIZE=9,NAME_GAP=12,NAME_FONT_SIZE=13,NAME_STYLE={textAnchor:"middle",fontFamily:"'Courier New', Courier, monospace",fontWeight:"bold",fill:"#3A3A3C",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none"};async function trimmedFootprint(i){const e=i.querySelectorAll("image");if(e.length!==1)return null;const t=e[0],n=t.getAttribute("href")??t.getAttribute("xlink:href");if(!n)return null;let s,o;try{s=t.getBBox();const p=i.getCTM(),f=t.getCTM();if(!p||!f)return null;o=p.inverse().multiply(f)}catch{return null}const a=await visibleImageRect(n,s,t.getAttribute("preserveAspectRatio")??"");if(!a)return null;const l=[new DOMPoint(a.x,a.y),new DOMPoint(a.x+a.width,a.y),new DOMPoint(a.x+a.width,a.y+a.height),new DOMPoint(a.x,a.y+a.height)].map(p=>p.matrixTransform(o)),c=l.map(p=>p.x),u=l.map(p=>p.y),h=Math.min(...c),d=Math.min(...u);return{x:h,y:d,width:Math.max(...c)-h,height:Math.max(...u)-d}}const arrowPoints=(i,e,t,n,s)=>{const o=Math.hypot(t,n)||1,a=t/o,l=n/o,c=-l,u=a;return[`${i+a*s},${e+l*s}`,`${i-a*s*.3+c*s*.75},${e-l*s*.3+u*s*.75}`,`${i-a*s*.3-c*s*.75},${e-l*s*.3-u*s*.75}`].join(" ")};function Item({layer:i,item:e,scene:t,catalog:n}){var A;const{x:s,y:o,rotation:a}=e,l=useReactPlannerStore(P=>P.planner.zoom||P.planner.viewer2D.get("a")||1),c=useReactPlannerStore(P=>P.resizeHandlesFor),u=React.useRef(null),[h,d]=React.useState(null),{scale:p,flipHorizontal:f,flipVertical:g}=getItemTransform(e),_=p*(f?-1:1),x=p*(g?-1:1);React.useLayoutEffect(()=>{if(!u.current)return;let P;try{P=u.current.getBBox()}catch{return}const B={x:P.x,y:P.y,width:P.width,height:P.height};rememberItemFootprint(e.id,B),d(k=>k&&k.x===B.x&&k.y===B.y&&k.width===B.width&&k.height===B.height?k:B)},[e.id,e.type,_,x]),React.useEffect(()=>{const P=u.current;if(!P||!h)return;let B=!1;return trimmedFootprint(P).then(k=>{!B&&k&&rememberItemFootprint(e.id,k)}),()=>{B=!0}},[e.id,e.type,_,x,h]),React.useEffect(()=>()=>forgetItemFootprint(e.id),[e.id]);const y=n.getElement(e.type).render2D(e,i,t),E={"data-element-root":!0,"data-prototype":e.prototype,"data-id":e.id,"data-selected":e.selected,"data-layer":i.id},b=l>0?1/l:1,v=e.selected&&h!==null,M=(A=e.properties)!=null&&A.get("showName")?e.properties.get("customName")||e.name:null,T=v&&c===e.id,I=h?h.y-ROTATE_GAP*b:0,w=ROTATE_ARC_HALF_WIDTH*b,R=ROTATE_ARC_BULGE*b;return jsxRuntimeExports.jsxs("g",{style:e.selected?{cursor:"move"}:{},transform:`translate(${s},${o}) rotate(${a})`,children:[jsxRuntimeExports.jsx("g",{ref:u,children:jsxRuntimeExports.jsx("g",{...E,transform:`scale(${_},${x})`,children:y})}),M&&h&&jsxRuntimeExports.jsx("text",{x:0,y:-(h.y-NAME_GAP*b),transform:"scale(1,-1)",style:{...NAME_STYLE,fontSize:NAME_FONT_SIZE*b},children:M}),v&&jsxRuntimeExports.jsxs("g",{...E,"data-part":"rotation-anchor",children:[jsxRuntimeExports.jsx("path",{d:`M ${-w},${I} Q 0,${I-R} ${w},${I}`,fill:"none",stroke:HANDLE_COLOR$1,strokeWidth:2*b,strokeLinecap:"round"}),jsxRuntimeExports.jsx("polygon",{points:arrowPoints(-w,I,-w,R,ARROW_SIZE*b),fill:HANDLE_COLOR$1}),jsxRuntimeExports.jsx("polygon",{points:arrowPoints(w,I,w,R,ARROW_SIZE*b),fill:HANDLE_COLOR$1}),jsxRuntimeExports.jsx("circle",{cx:0,cy:I-R/2,r:ROTATE_DOT_RADIUS*b,fill:HANDLE_COLOR$1}),jsxRuntimeExports.jsx("circle",{cx:0,cy:I-R/2,r:ROTATE_HIT_RADIUS*b,fill:"transparent",style:{cursor:"grab"}})]}),T&&h&&[[h.x,h.y,"nesw-resize"],[h.x+h.width,h.y,"nwse-resize"],[h.x+h.width,h.y+h.height,"nesw-resize"],[h.x,h.y+h.height,"nwse-resize"]].map(([P,B,k],W)=>jsxRuntimeExports.jsx("rect",{...E,"data-part":"resize-anchor",x:P-RESIZE_HANDLE_SIZE/2*b,y:B-RESIZE_HANDLE_SIZE/2*b,width:RESIZE_HANDLE_SIZE*b,height:RESIZE_HANDLE_SIZE*b,rx:1.5*b,fill:"#ffffff",stroke:HANDLE_COLOR$1,strokeWidth:1.5*b,style:{cursor:k}},W))]})}const metric$a={mm:{name:{singular:"Millimeter",plural:"Millimeters"},to_anchor:1/1e3},cm:{name:{singular:"Centimeter",plural:"Centimeters"},to_anchor:1/100},m:{name:{singular:"Meter",plural:"Meters"},to_anchor:1},km:{name:{singular:"Kilometer",plural:"Kilometers"},to_anchor:1e3}},imperial$8={in:{name:{singular:"Inch",plural:"Inches"},to_anchor:1/12},yd:{name:{singular:"Yard",plural:"Yards"},to_anchor:3},"ft-us":{name:{singular:"US Survey Foot",plural:"US Survey Feet"},to_anchor:1.000002},ft:{name:{singular:"Foot",plural:"Feet"},to_anchor:1},mi:{name:{singular:"Mile",plural:"Miles"},to_anchor:5280}},length={metric:metric$a,imperial:imperial$8,_anchors:{metric:{unit:"m",ratio:3.28084},imperial:{unit:"ft",ratio:1/3.28084}}},metric$9={mm2:{name:{singular:"Square Millimeter",plural:"Square Millimeters"},to_anchor:1/1e6},cm2:{name:{singular:"Centimeter",plural:"Centimeters"},to_anchor:1/1e4},m2:{name:{singular:"Square Meter",plural:"Square Meters"},to_anchor:1},ha:{name:{singular:"Hectare",plural:"Hectares"},to_anchor:1e4},km2:{name:{singular:"Square Kilometer",plural:"Square Kilometers"},to_anchor:1e6}},imperial$7={in2:{name:{singular:"Square Inch",plural:"Square Inches"},to_anchor:1/144},yd2:{name:{singular:"Square Yard",plural:"Square Yards"},to_anchor:9},ft2:{name:{singular:"Square Foot",plural:"Square Feet"},to_anchor:1},ac:{name:{singular:"Acre",plural:"Acres"},to_anchor:43560},mi2:{name:{singular:"Square Mile",plural:"Square Miles"},to_anchor:27878400}},area$1={metric:metric$9,imperial:imperial$7,_anchors:{metric:{unit:"m2",ratio:10.7639},imperial:{unit:"ft2",ratio:1/10.7639}}},metric$8={mcg:{name:{singular:"Microgram",plural:"Micrograms"},to_anchor:1/1e6},mg:{name:{singular:"Milligram",plural:"Milligrams"},to_anchor:1/1e3},g:{name:{singular:"Gram",plural:"Grams"},to_anchor:1},kg:{name:{singular:"Kilogram",plural:"Kilograms"},to_anchor:1e3},mt:{name:{singular:"Metric Tonne",plural:"Metric Tonnes"},to_anchor:1e6}},imperial$6={oz:{name:{singular:"Ounce",plural:"Ounces"},to_anchor:1/16},lb:{name:{singular:"Pound",plural:"Pounds"},to_anchor:1},t:{name:{singular:"Ton",plural:"Tons"},to_anchor:2e3}},mass={metric:metric$8,imperial:imperial$6,_anchors:{metric:{unit:"g",ratio:1/453.592},imperial:{unit:"lb",ratio:453.592}}},metric$7={mm3:{name:{singular:"Cubic Millimeter",plural:"Cubic Millimeters"},to_anchor:1/1e6},cm3:{name:{singular:"Cubic Centimeter",plural:"Cubic Centimeters"},to_anchor:1/1e3},ml:{name:{singular:"Millilitre",plural:"Millilitres"},to_anchor:1/1e3},cl:{name:{singular:"Centilitre",plural:"Centilitres"},to_anchor:1/100},dl:{name:{singular:"Decilitre",plural:"Decilitres"},to_anchor:1/10},l:{name:{singular:"Litre",plural:"Litres"},to_anchor:1},kl:{name:{singular:"Kilolitre",plural:"Kilolitres"},to_anchor:1e3},m3:{name:{singular:"Cubic meter",plural:"Cubic meters"},to_anchor:1e3},km3:{name:{singular:"Cubic kilometer",plural:"Cubic kilometers"},to_anchor:1e12},krm:{name:{singular:"Matsked",plural:"Matskedar"},to_anchor:1/1e3},tsk:{name:{singular:"Tesked",plural:"Teskedar"},to_anchor:5/1e3},msk:{name:{singular:"Matsked",plural:"Matskedar"},to_anchor:15/1e3},kkp:{name:{singular:"Kaffekopp",plural:"Kaffekoppar"},to_anchor:150/1e3},glas:{name:{singular:"Glas",plural:"Glas"},to_anchor:200/1e3},kanna:{name:{singular:"Kanna",plural:"Kannor"},to_anchor:2.617}},imperial$5={tsp:{name:{singular:"Teaspoon",plural:"Teaspoons"},to_anchor:1/6},Tbs:{name:{singular:"Tablespoon",plural:"Tablespoons"},to_anchor:1/2},in3:{name:{singular:"Cubic inch",plural:"Cubic inches"},to_anchor:.55411},"fl-oz":{name:{singular:"Fluid Ounce",plural:"Fluid Ounces"},to_anchor:1},cup:{name:{singular:"Cup",plural:"Cups"},to_anchor:8},pnt:{name:{singular:"Pint",plural:"Pints"},to_anchor:16},qt:{name:{singular:"Quart",plural:"Quarts"},to_anchor:32},gal:{name:{singular:"Gallon",plural:"Gallons"},to_anchor:128},ft3:{name:{singular:"Cubic foot",plural:"Cubic feet"},to_anchor:957.506},yd3:{name:{singular:"Cubic yard",plural:"Cubic yards"},to_anchor:25852.7}},volume={metric:metric$7,imperial:imperial$5,_anchors:{metric:{unit:"l",ratio:33.8140226},imperial:{unit:"fl-oz",ratio:1/33.8140226}}},metric$6={ea:{name:{singular:"Each",plural:"Each"},to_anchor:1},dz:{name:{singular:"Dozen",plural:"Dozens"},to_anchor:12}},each={metric:metric$6,imperial:{},_anchors:{metric:{unit:"ea",ratio:1}}},metric$5={C:{name:{singular:"degree Celsius",plural:"degrees Celsius"},to_anchor:1,anchor_shift:0},K:{name:{singular:"degree Kelvin",plural:"degrees Kelvin"},to_anchor:1,anchor_shift:273.15}},imperial$4={F:{name:{singular:"degree Fahrenheit",plural:"degrees Fahrenheit"},to_anchor:1},R:{name:{singular:"degree Rankine",plural:"degrees Rankine"},to_anchor:1,anchor_shift:459.67}},temperature={metric:metric$5,imperial:imperial$4,_anchors:{metric:{unit:"C",transform:function(i){return i/(5/9)+32}},imperial:{unit:"F",transform:function(i){return(i-32)*(5/9)}}}},daysInYear=365.25,time={ns:{name:{singular:"Nanosecond",plural:"Nanoseconds"},to_anchor:1/1e9},mu:{name:{singular:"Microsecond",plural:"Microseconds"},to_anchor:1/1e6},ms:{name:{singular:"Millisecond",plural:"Milliseconds"},to_anchor:1/1e3},s:{name:{singular:"Second",plural:"Seconds"},to_anchor:1},min:{name:{singular:"Minute",plural:"Minutes"},to_anchor:60},h:{name:{singular:"Hour",plural:"Hours"},to_anchor:3600},d:{name:{singular:"Day",plural:"Days"},to_anchor:3600*24},week:{name:{singular:"Week",plural:"Weeks"},to_anchor:3600*24*7},month:{name:{singular:"Month",plural:"Months"},to_anchor:3600*24*daysInYear/12},year:{name:{singular:"Year",plural:"Years"},to_anchor:3600*24*daysInYear}},time$1={metric:time,_anchors:{metric:{unit:"s",ratio:1}}},bits={b:{name:{singular:"Bit",plural:"Bits"},to_anchor:1},Kb:{name:{singular:"Kilobit",plural:"Kilobits"},to_anchor:1024},Mb:{name:{singular:"Megabit",plural:"Megabits"},to_anchor:1048576},Gb:{name:{singular:"Gigabit",plural:"Gigabits"},to_anchor:1073741824},Tb:{name:{singular:"Terabit",plural:"Terabits"},to_anchor:1099511627776}},bytes={B:{name:{singular:"Byte",plural:"Bytes"},to_anchor:1},KB:{name:{singular:"Kilobyte",plural:"Kilobytes"},to_anchor:1024},MB:{name:{singular:"Megabyte",plural:"Megabytes"},to_anchor:1048576},GB:{name:{singular:"Gigabyte",plural:"Gigabytes"},to_anchor:1073741824},TB:{name:{singular:"Terabyte",plural:"Terabytes"},to_anchor:1099511627776}},digital={bits,bytes,_anchors:{bits:{unit:"b",ratio:1/8},bytes:{unit:"B",ratio:8}}},metric$4={ppm:{name:{singular:"Part-per Million",plural:"Parts-per Million"},to_anchor:1},ppb:{name:{singular:"Part-per Billion",plural:"Parts-per Billion"},to_anchor:.001},ppt:{name:{singular:"Part-per Trillion",plural:"Parts-per Trillion"},to_anchor:1e-6},ppq:{name:{singular:"Part-per Quadrillion",plural:"Parts-per Quadrillion"},to_anchor:1e-9}},partsPer={metric:metric$4,imperial:{},_anchors:{metric:{unit:"ppm",ratio:1e-6}}},metric$3={"m/s":{name:{singular:"Metre per second",plural:"Metres per second"},to_anchor:3.6},"km/h":{name:{singular:"Kilometre per hour",plural:"Kilometres per hour"},to_anchor:1}},imperial$3={"m/h":{name:{singular:"Mile per hour",plural:"Miles per hour"},to_anchor:1},knot:{name:{singular:"Knot",plural:"Knots"},to_anchor:1.150779},"ft/s":{name:{singular:"Foot per second",plural:"Feet per second"},to_anchor:.681818}},speed={metric:metric$3,imperial:imperial$3,_anchors:{metric:{unit:"km/h",ratio:1/1.609344},imperial:{unit:"m/h",ratio:1.609344}}},metric$2={Pa:{name:{singular:"pascal",plural:"pascals"},to_anchor:1/1e3},kPa:{name:{singular:"kilopascal",plural:"kilopascals"},to_anchor:1},MPa:{name:{singular:"megapascal",plural:"megapascals"},to_anchor:1e3},hPa:{name:{singular:"hectopascal",plural:"hectopascals"},to_anchor:1/10},bar:{name:{singular:"bar",plural:"bar"},to_anchor:100},torr:{name:{singular:"torr",plural:"torr"},to_anchor:101325/76e4}},imperial$2={psi:{name:{singular:"pound per square inch",plural:"pounds per square inch"},to_anchor:1/1e3},ksi:{name:{singular:"kilopound per square inch",plural:"kilopound per square inch"},to_anchor:1}},pressure={metric:metric$2,imperial:imperial$2,_anchors:{metric:{unit:"kPa",ratio:.00014503768078},imperial:{unit:"psi",ratio:1/.00014503768078}}},current={A:{name:{singular:"Ampere",plural:"Amperes"},to_anchor:1},mA:{name:{singular:"Milliampere",plural:"Milliamperes"},to_anchor:.001},kA:{name:{singular:"Kiloampere",plural:"Kiloamperes"},to_anchor:1e3}},current$1={metric:current,_anchors:{metric:{unit:"A",ratio:1}}},voltage={V:{name:{singular:"Volt",plural:"Volts"},to_anchor:1},mV:{name:{singular:"Millivolt",plural:"Millivolts"},to_anchor:.001},kV:{name:{singular:"Kilovolt",plural:"Kilovolts"},to_anchor:1e3}},voltage$1={metric:voltage,_anchors:{metric:{unit:"V",ratio:1}}},power={W:{name:{singular:"Watt",plural:"Watts"},to_anchor:1},mW:{name:{singular:"Milliwatt",plural:"Milliwatts"},to_anchor:.001},kW:{name:{singular:"Kilowatt",plural:"Kilowatts"},to_anchor:1e3},MW:{name:{singular:"Megawatt",plural:"Megawatts"},to_anchor:1e6},GW:{name:{singular:"Gigawatt",plural:"Gigawatts"},to_anchor:1e9}},power$1={metric:power,_anchors:{metric:{unit:"W",ratio:1}}},reactivePower={VAR:{name:{singular:"Volt-Ampere Reactive",plural:"Volt-Amperes Reactive"},to_anchor:1},mVAR:{name:{singular:"Millivolt-Ampere Reactive",plural:"Millivolt-Amperes Reactive"},to_anchor:.001},kVAR:{name:{singular:"Kilovolt-Ampere Reactive",plural:"Kilovolt-Amperes Reactive"},to_anchor:1e3},MVAR:{name:{singular:"Megavolt-Ampere Reactive",plural:"Megavolt-Amperes Reactive"},to_anchor:1e6},GVAR:{name:{singular:"Gigavolt-Ampere Reactive",plural:"Gigavolt-Amperes Reactive"},to_anchor:1e9}},reactivePower$1={metric:reactivePower,_anchors:{metric:{unit:"VAR",ratio:1}}},apparentPower={VA:{name:{singular:"Volt-Ampere",plural:"Volt-Amperes"},to_anchor:1},mVA:{name:{singular:"Millivolt-Ampere",plural:"Millivolt-Amperes"},to_anchor:.001},kVA:{name:{singular:"Kilovolt-Ampere",plural:"Kilovolt-Amperes"},to_anchor:1e3},MVA:{name:{singular:"Megavolt-Ampere",plural:"Megavolt-Amperes"},to_anchor:1e6},GVA:{name:{singular:"Gigavolt-Ampere",plural:"Gigavolt-Amperes"},to_anchor:1e9}},apparentPower$1={metric:apparentPower,_anchors:{metric:{unit:"VA",ratio:1}}},energy={Wh:{name:{singular:"Watt-hour",plural:"Watt-hours"},to_anchor:3600},mWh:{name:{singular:"Milliwatt-hour",plural:"Milliwatt-hours"},to_anchor:3.6},kWh:{name:{singular:"Kilowatt-hour",plural:"Kilowatt-hours"},to_anchor:36e5},MWh:{name:{singular:"Megawatt-hour",plural:"Megawatt-hours"},to_anchor:36e8},GWh:{name:{singular:"Gigawatt-hour",plural:"Gigawatt-hours"},to_anchor:36e11},J:{name:{singular:"Joule",plural:"Joules"},to_anchor:1},kJ:{name:{singular:"Kilojoule",plural:"Kilojoules"},to_anchor:1e3}},energy$1={metric:energy,_anchors:{metric:{unit:"J",ratio:1}}},reactiveEnergy={VARh:{name:{singular:"Volt-Ampere Reactive Hour",plural:"Volt-Amperes Reactive Hour"},to_anchor:1},mVARh:{name:{singular:"Millivolt-Ampere Reactive Hour",plural:"Millivolt-Amperes Reactive Hour"},to_anchor:.001},kVARh:{name:{singular:"Kilovolt-Ampere Reactive Hour",plural:"Kilovolt-Amperes Reactive Hour"},to_anchor:1e3},MVARh:{name:{singular:"Megavolt-Ampere Reactive Hour",plural:"Megavolt-Amperes Reactive Hour"},to_anchor:1e6},GVARh:{name:{singular:"Gigavolt-Ampere Reactive Hour",plural:"Gigavolt-Amperes Reactive Hour"},to_anchor:1e9}},reactiveEnergy$1={metric:reactiveEnergy,_anchors:{metric:{unit:"VARh",ratio:1}}},metric$1={"mm3/s":{name:{singular:"Cubic Millimeter per second",plural:"Cubic Millimeters per second"},to_anchor:1/1e6},"cm3/s":{name:{singular:"Cubic Centimeter per second",plural:"Cubic Centimeters per second"},to_anchor:1/1e3},"ml/s":{name:{singular:"Millilitre per second",plural:"Millilitres per second"},to_anchor:1/1e3},"cl/s":{name:{singular:"Centilitre per second",plural:"Centilitres per second"},to_anchor:1/100},"dl/s":{name:{singular:"Decilitre per second",plural:"Decilitres per second"},to_anchor:1/10},"l/s":{name:{singular:"Litre per second",plural:"Litres per second"},to_anchor:1},"l/min":{name:{singular:"Litre per minute",plural:"Litres per minute"},to_anchor:1/60},"l/h":{name:{singular:"Litre per hour",plural:"Litres per hour"},to_anchor:1/3600},"kl/s":{name:{singular:"Kilolitre per second",plural:"Kilolitres per second"},to_anchor:1e3},"kl/min":{name:{singular:"Kilolitre per minute",plural:"Kilolitres per minute"},to_anchor:50/3},"kl/h":{name:{singular:"Kilolitre per hour",plural:"Kilolitres per hour"},to_anchor:5/18},"m3/s":{name:{singular:"Cubic meter per second",plural:"Cubic meters per second"},to_anchor:1e3},"m3/min":{name:{singular:"Cubic meter per minute",plural:"Cubic meters per minute"},to_anchor:50/3},"m3/h":{name:{singular:"Cubic meter per hour",plural:"Cubic meters per hour"},to_anchor:5/18},"km3/s":{name:{singular:"Cubic kilometer per second",plural:"Cubic kilometers per second"},to_anchor:1e12}},imperial$1={"tsp/s":{name:{singular:"Teaspoon per second",plural:"Teaspoons per second"},to_anchor:1/6},"Tbs/s":{name:{singular:"Tablespoon per second",plural:"Tablespoons per second"},to_anchor:1/2},"in3/s":{name:{singular:"Cubic inch per second",plural:"Cubic inches per second"},to_anchor:.55411},"in3/min":{name:{singular:"Cubic inch per minute",plural:"Cubic inches per minute"},to_anchor:.55411/60},"in3/h":{name:{singular:"Cubic inch per hour",plural:"Cubic inches per hour"},to_anchor:.55411/3600},"fl-oz/s":{name:{singular:"Fluid Ounce per second",plural:"Fluid Ounces per second"},to_anchor:1},"fl-oz/min":{name:{singular:"Fluid Ounce per minute",plural:"Fluid Ounces per minute"},to_anchor:1/60},"fl-oz/h":{name:{singular:"Fluid Ounce per hour",plural:"Fluid Ounces per hour"},to_anchor:1/3600},"cup/s":{name:{singular:"Cup per second",plural:"Cups per second"},to_anchor:8},"pnt/s":{name:{singular:"Pint per second",plural:"Pints per second"},to_anchor:16},"pnt/min":{name:{singular:"Pint per minute",plural:"Pints per minute"},to_anchor:4/15},"pnt/h":{name:{singular:"Pint per hour",plural:"Pints per hour"},to_anchor:1/225},"qt/s":{name:{singular:"Quart per second",plural:"Quarts per second"},to_anchor:32},"gal/s":{name:{singular:"Gallon per second",plural:"Gallons per second"},to_anchor:128},"gal/min":{name:{singular:"Gallon per minute",plural:"Gallons per minute"},to_anchor:32/15},"gal/h":{name:{singular:"Gallon per hour",plural:"Gallons per hour"},to_anchor:8/225},"ft3/s":{name:{singular:"Cubic foot per second",plural:"Cubic feet per second"},to_anchor:957.506},"ft3/min":{name:{singular:"Cubic foot per minute",plural:"Cubic feet per minute"},to_anchor:957.506/60},"ft3/h":{name:{singular:"Cubic foot per hour",plural:"Cubic feet per hour"},to_anchor:957.506/3600},"yd3/s":{name:{singular:"Cubic yard per second",plural:"Cubic yards per second"},to_anchor:25852.7},"yd3/min":{name:{singular:"Cubic yard per minute",plural:"Cubic yards per minute"},to_anchor:25852.7/60},"yd3/h":{name:{singular:"Cubic yard per hour",plural:"Cubic yards per hour"},to_anchor:25852.7/3600}},volumeFlowRate={metric:metric$1,imperial:imperial$1,_anchors:{metric:{unit:"l/s",ratio:33.8140227},imperial:{unit:"fl-oz/s",ratio:1/33.8140227}}},metric={lx:{name:{singular:"Lux",plural:"Lux"},to_anchor:1}},imperial={"ft-cd":{name:{singular:"Foot-candle",plural:"Foot-candles"},to_anchor:1}},illuminance={metric,imperial,_anchors:{metric:{unit:"lx",ratio:1/10.76391},imperial:{unit:"ft-cd",ratio:10.76391}}},frequency={mHz:{name:{singular:"millihertz",plural:"millihertz"},to_anchor:1/1e3},Hz:{name:{singular:"hertz",plural:"hertz"},to_anchor:1},kHz:{name:{singular:"kilohertz",plural:"kilohertz"},to_anchor:1e3},MHz:{name:{singular:"megahertz",plural:"megahertz"},to_anchor:1e3*1e3},GHz:{name:{singular:"gigahertz",plural:"gigahertz"},to_anchor:1e3*1e3*1e3},THz:{name:{singular:"terahertz",plural:"terahertz"},to_anchor:1e3*1e3*1e3*1e3},rpm:{name:{singular:"rotation per minute",plural:"rotations per minute"},to_anchor:1/60},"deg/s":{name:{singular:"degree per second",plural:"degrees per second"},to_anchor:1/360},"rad/s":{name:{singular:"radian per second",plural:"radians per second"},to_anchor:1/(Math.PI*2)}},frequency$1={metric:frequency,_anchors:{frequency:{unit:"hz",ratio:1}}},measures={length,area:area$1,mass,volume,each,temperature,time:time$1,digital,partsPer,speed,pressure,current:current$1,voltage:voltage$1,power:power$1,reactivePower:reactivePower$1,apparentPower:apparentPower$1,energy:energy$1,reactiveEnergy:reactiveEnergy$1,volumeFlowRate,illuminance,frequency:frequency$1};function _keys(i){return Object.keys(i)}function _describe(i){return{abbr:i.abbr,measure:i.measure,system:i.system,singular:i.unit.name.singular,plural:i.unit.name.plural}}function _each(i,e){if(Array.isArray(i))for(let t=0;t<i.length;t++)e(i[t],t,i);else if(i&&typeof i=="object")for(let t in i)Object.prototype.hasOwnProperty.call(i,t)&&e(i[t],t,i)}class Converter{constructor(e,t){ze(this,"val");ze(this,"destination");ze(this,"origin");this.val=t?e/t:e}from(e){if(this.destination)throw new Error(".from must be called before .to");return this.origin=this.getUnit(e),this.origin||this.throwUnsupportedUnitError(e),this}to(e){if(!this.origin)throw new Error(".to must be called after .from");if(this.destination=this.getUnit(e),this.destination||this.throwUnsupportedUnitError(e),this.origin.abbr===this.destination.abbr)return this.val;if(this.destination.measure!==this.origin.measure)throw new Error(`Cannot convert incompatible measures of ${this.destination.measure} and ${this.origin.measure}`);let t=this.val*this.origin.unit.to_anchor;if(this.origin.unit.anchor_shift&&(t-=this.origin.unit.anchor_shift),this.origin.system!==this.destination.system){const n=measures[this.origin.measure]._anchors[this.origin.system];t=typeof n.transform=="function"?n.transform(t):t*n.ratio}return this.destination.unit.anchor_shift&&(t+=this.destination.unit.anchor_shift),t/this.destination.unit.to_anchor}toBest(e){if(!this.origin)throw new Error(".toBest must be called after .from");const t={exclude:[],cutOffNumber:1,...e};let n=null;return _each(this.possibilities(),s=>{if(t.exclude.includes(s))return;const o=this.describe(s);if(o.system!==this.origin.system)return;const a=this.to(s);(!n||a>=t.cutOffNumber&&a<n.val)&&(n={val:a,unit:s,singular:o.singular,plural:o.plural})}),n}getUnit(e){let t=null;return _each(measures,(n,s)=>{_each(n,(o,a)=>{a!=="_anchors"&&_each(o,(l,c)=>{c===e&&(t={abbr:e,measure:s,system:a,unit:l})})})}),t}describe(e){const t=this.getUnit(e);return t||this.throwUnsupportedUnitError(e),_describe(t)}list(e){const t=[];return _each(measures,(n,s)=>{e&&e!==s||_each(n,(o,a)=>{a!=="_anchors"&&_each(o,(l,c)=>{t.push(_describe({abbr:c,measure:s,system:a,unit:l}))})})}),t}throwUnsupportedUnitError(e){const t=[];throw _each(measures,n=>{_each(n,(s,o)=>{o!=="_anchors"&&t.push(..._keys(s))})}),new Error(`Unsupported unit ${e}, use one of: ${t.join(", ")}`)}possibilities(e){const t=[];if(!this.origin&&!e)_each(_keys(measures),n=>{_each(measures[n],(s,o)=>{o!=="_anchors"&&t.push(..._keys(s))})});else{const n=e||this.origin.measure;_each(measures[n],(s,o)=>{o!=="_anchors"&&t.push(..._keys(s))})}return t}measures(){return _keys(measures)}}function convert(i){return new Converter(i)}const STYLE$3={stroke:"#0096fd",strokeWidth:1},STYLE_TEXT={textAnchor:"middle",fontSize:15,fontFamily:"'Courier New', Courier, monospace",pointerEvents:"none",fontWeight:"bold",userSelect:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none",MozUserSelect:"none"},formatDistance=(i,e)=>e===UNIT_CENTIMETER?`${i.toFixed(2)} ${e}`:e==="ft"?formatArchitectural(i):`${convert(i).from(UNIT_CENTIMETER).to(e).toFixed(2)} ${e}`,formatArchitectural=i=>{const e=convert(i).from(UNIT_CENTIMETER).to("in");let t=Math.floor(e/12),n=Math.floor(e%12);const s=Math.round(e%1*8);let o="";return s===8?n+=1:s>0&&(o=` ${{1:"1/8",2:"1/4",3:"3/8",4:"1/2",5:"5/8",6:"3/4",7:"7/8"}[s]}`),n===12&&(t+=1,n=0),`${t}' ${n}${o}"`};function Ruler({length:i,unit:e,transform:t,labelPlacement:n="above"}){const s=React.useMemo(()=>formatDistance(i,e),[i,e]),o=React.useMemo(()=>`M0,-5 L0,5 M${i},-5 L${i},5 M0,0 L${i},0`,[i]),a=n==="below"?24:-12;return jsxRuntimeExports.jsxs("g",{transform:t,children:[jsxRuntimeExports.jsx("text",{x:i/2,y:a,transform:"scale(1,-1)",style:STYLE_TEXT,children:s}),jsxRuntimeExports.jsx("path",{d:o,style:STYLE$3})]})}const Ruler$1=React.memo(Ruler),RULER_GAP=10,HOLE_NAME_GAP=16,HOLE_NAME_STYLE={textAnchor:"middle",fontSize:13,fontFamily:"'Courier New', Courier, monospace",fontWeight:"bold",fill:"#3A3A3C",pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none"},Line$1=({line:i,layer:e,scene:t,catalog:n,mode:s,showDimensions:o})=>{const a=useReactPlannerStore(B=>{var k;return((k=B.hoveredElement)==null?void 0:k.lineID)===i.id}),l=useReactPlannerStore(B=>{var k,W;return((k=B.hoveredElement)==null?void 0:k.lineID)===i.id&&((W=B.hoveredElement)==null?void 0:W.prototype)==="vertices"}),c=useReactPlannerStore(B=>{var k;return B.planner.mode===MODE_DRAGGING_VERTEX?((k=B.planner.draggingSupport)==null?void 0:k.get("vertexID"))??null:null});let u=e.vertices.get(i.vertices.get(0)),h=e.vertices.get(i.vertices.get(1));if(u.id===h.id||samePoints(u,h))return null;let{x:d,y:p}=u,{x:f,y:g}=h;d>f&&({x:d,y:p}=h,{x:f,y:g}=u);let _=pointsDistance(d,p,f,g),x=angleBetweenTwoPointsAndOrigin(d,p,f,g);const y=i.getIn(["properties","thickness","length"])??0;let E=i.holes.map(B=>{var G;let k=e.holes.get(B),W=_*k.offset,Y=n.getElement(k.type).render2D(k,e,t);const $=(G=k.properties)!=null&&G.get("showName")?k.properties.get("customName")||k.name:null,ee=k.flipAlongWall?" scale(-1, 1)":"";return jsxRuntimeExports.jsxs("g",{children:[jsxRuntimeExports.jsx("g",{transform:`translate(${W}, 0)${ee}`,"data-element-root":!0,"data-prototype":k.prototype,"data-id":k.id,"data-selected":k.selected,"data-layer":e.id,children:Y}),$&&jsxRuntimeExports.jsx("g",{transform:`translate(${W}, ${-(y/2+HOLE_NAME_GAP)})`,children:jsxRuntimeExports.jsx("text",{transform:"scale(1,-1)",style:HOLE_NAME_STYLE,children:$})})]},B)}),b=i.getIn(["properties","thickness","length"])??0,v=b/2;const M=a&&!l&&!i.selected;let T=n.getElement(i.type).render2D(M?i.set("selected",!0):i,e,t,s);const I=a&&(s===MODE_DRAGGING_LINE||s===MODE_DRAGGING_VERTEX),w=c!==null&&i.vertices.includes(c),R=i.selected||o||w||a&&(!l||I),A=R&&b>0?wallGeometry(i,e):null,P=R?A?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[A.topEnd>A.topStart&&jsxRuntimeExports.jsx(Ruler$1,{unit:t.unit,length:A.topEnd-A.topStart,transform:`translate(${A.topStart}, ${v+RULER_GAP})`}),A.botEnd>A.botStart&&jsxRuntimeExports.jsx(Ruler$1,{unit:t.unit,length:A.botEnd-A.botStart,transform:`translate(${A.botStart}, ${-(v+RULER_GAP)})`,labelPlacement:"below"})]}):jsxRuntimeExports.jsx(Ruler$1,{unit:t.unit,length:_,transform:`translate(0, ${v+RULER_GAP} )`}):null;return jsxRuntimeExports.jsxs("g",{transform:`translate(${d}, ${p}) rotate(${x}, 0, 0)`,"data-element-root":!0,"data-prototype":i.prototype,"data-id":i.id,"data-selected":i.selected,"data-layer":e.id,style:i.selected||a?{cursor:"move"}:{},children:[P,T,E]})},STYLE$2={fill:"#0096fd",stroke:SharedStyle.COLORS.white,cursor:"move"},Vertex$1=({vertex:i,layer:e})=>{const t=useReactPlannerStore(n=>{var s,o;return((s=n.hoveredElement)==null?void 0:s.prototype)==="vertices"&&((o=n.hoveredElement)==null?void 0:o.id)===i.id});return jsxRuntimeExports.jsx("g",{transform:`translate(${i.x}, ${i.y})`,"data-element-root":!0,"data-prototype":i.prototype,"data-id":i.id,"data-selected":i.selected,"data-layer":e.id,children:jsxRuntimeExports.jsx("circle",{cx:"0",cy:"0",r:t?10:7,style:STYLE$2})})},HANDLE_COLOR="var(--dark-blue, #1ca6fc)",HANDLE_RADIUS=3,HANDLE_HOVER_RADIUS=11,HANDLE_HIT_RADIUS=15;function WallHoverHandles({layer:i}){const e=useReactPlannerStore(l=>l.hoveredElement),t=useReactPlannerStore(l=>l.planner.zoom||l.planner.viewer2D.get("a")||1);if(!e||e.layerID!==i.id||!e.lineID)return null;const n=i.lines.get(e.lineID);if(!n||n.selected)return null;const s=t>0?1/t:1,o=e.prototype==="vertices"?e.id:null,a=o?[o]:n.vertices.toArray();return jsxRuntimeExports.jsx("g",{children:a.map(l=>{const c=i.vertices.get(l);if(!c)return null;const u=o===l;return jsxRuntimeExports.jsxs("g",{transform:`translate(${c.x}, ${c.y})`,"data-element-root":!0,"data-prototype":"vertices","data-id":c.id,"data-selected":c.selected,"data-layer":i.id,"data-line":n.id,style:{cursor:"move"},children:[jsxRuntimeExports.jsx("circle",{cx:0,cy:0,r:HANDLE_HIT_RADIUS*s,fill:"transparent"}),jsxRuntimeExports.jsx("circle",{cx:0,cy:0,r:(u?HANDLE_HOVER_RADIUS:HANDLE_RADIUS)*s,fill:u?HANDLE_COLOR:"#ffffff",stroke:u?"none":HANDLE_COLOR,strokeWidth:1.5*s})]},l)})})}const SPOTLIGHT_EXTENT=4e6,SPOTLIGHT_FILL="#ffffff",SPOTLIGHT_OPACITY=.5,AREA_INSET=5;function signedArea$1(i){let e=0;for(let t=0;t<i.length;t++){const n=i[t],s=i[(t+1)%i.length];e+=n.x*s.y-s.x*n.y}return e/2}function insetPolygon(i,e){const t=i.length;if(t<3)return i;const n=signedArea$1(i)>0?1:-1,s=[];for(let o=0;o<t;o++){const a=i[(o-1+t)%t],l=i[o],c=i[(o+1)%t],u=l.x-a.x,h=l.y-a.y,d=c.x-l.x,p=c.y-l.y,f=Math.hypot(u,h)||1,g=Math.hypot(d,p)||1,_=-h/f*n,x=u/f*n,y=-p/g*n,E=d/g*n,b=_+y,v=x+E,M=Math.hypot(b,v);if(M<1e-6){s.push({x:l.x+_*e,y:l.y+x*e});continue}const T=(_*b+x*v)/M,I=e/Math.max(T,.15);s.push({x:l.x+b/M*I,y:l.y+v/M*I})}return s}function Layer({layer:i,scene:e,catalog:t,mode:n,showDimensions:s}){var E,b;const{groups:o}=e,{lines:a,areas:l,vertices:c,id:u,items:h,opacity:d}=i,p=[];(b=(E=i.get("selected"))==null?void 0:E.get("areas"))==null||b.forEach(v=>p.push(v));const f=p.length>0,g=new Map;if(f)for(const v of p){const M=l.get(v);if(!M)continue;const T=M.get("vertices").toArray().map(P=>c.get(P)).filter(Boolean).map(P=>({x:P.get("x"),y:P.get("y")}));if(T.length<3)continue;const w=getAreaKind(M,i)==="Room"?AREA_INSET:0,A=(w>0?insetPolygon(T,w):T).map(P=>`${P.x},${P.y}`).join(" ");A&&g.set(v,A)}const _=`fp-focus-mask-${u}`,x=`fp-focus-clip-${u}`,y=l.valueSeq().toArray().sort((v,M)=>+(getAreaKind(v,i)==="Surface")-+(getAreaKind(M,i)==="Surface"));return jsxRuntimeExports.jsxs("g",{opacity:d,children:[f&&jsxRuntimeExports.jsxs("defs",{children:[jsxRuntimeExports.jsxs("mask",{id:_,children:[jsxRuntimeExports.jsx("rect",{x:-SPOTLIGHT_EXTENT,y:-SPOTLIGHT_EXTENT,width:SPOTLIGHT_EXTENT*2,height:SPOTLIGHT_EXTENT*2,fill:"white"}),Array.from(g.entries()).map(([v,M])=>jsxRuntimeExports.jsx("polygon",{points:M,fill:"black"},v))]}),jsxRuntimeExports.jsx("clipPath",{id:x,children:Array.from(g.entries()).map(([v,M])=>jsxRuntimeExports.jsx("polygon",{points:M},v))})]}),y.map(v=>jsxRuntimeExports.jsx(Area,{part:"fill",layer:i,area:v,catalog:t},v.id)),y.map(v=>jsxRuntimeExports.jsx(Area,{part:"label",layer:i,area:v,catalog:t},`label-${v.id}`)),a.valueSeq().map(v=>jsxRuntimeExports.jsx(Line$1,{mode:n,showDimensions:s,layer:i,line:v,scene:e,catalog:t},v.id)),h.valueSeq().map(v=>jsxRuntimeExports.jsx(Item,{layer:i,item:v,scene:e,catalog:t},v.id)),c.valueSeq().filter(v=>v.selected).map(v=>jsxRuntimeExports.jsx(Vertex$1,{layer:i,vertex:v},v.id)),o.valueSeq().filter(v=>v.hasIn(["elements",u])&&v.get("selected")).map(v=>jsxRuntimeExports.jsx(Group$1,{layer:i,group:v,scene:e,catalog:t},v.get("id"))),f&&jsxRuntimeExports.jsxs("g",{"data-fp-screenshot":"omit",children:[jsxRuntimeExports.jsx("rect",{x:-SPOTLIGHT_EXTENT,y:-SPOTLIGHT_EXTENT,width:SPOTLIGHT_EXTENT*3,height:SPOTLIGHT_EXTENT*2,fill:SPOTLIGHT_FILL,opacity:SPOTLIGHT_OPACITY,mask:`url(#${_})`,pointerEvents:"none"}),jsxRuntimeExports.jsx("g",{clipPath:`url(#${x})`,children:Array.from(g.entries()).map(([v,M])=>jsxRuntimeExports.jsx("polygon",{points:M,fill:"none",stroke:"var(--dark-blue, #1ca6fc)",strokeWidth:6,vectorEffect:"non-scaling-stroke",pointerEvents:"none"},`sel-${v}`))})]}),jsxRuntimeExports.jsx("g",{"data-fp-screenshot":"omit",children:jsxRuntimeExports.jsx(WallHoverHandles,{layer:i})})]})}const Scene$1=({scene:i,catalog:e,mode:t,showDimensions:n})=>{const{layers:s}=i,o=s.get(i.selectedLayer);return jsxRuntimeExports.jsxs("g",{children:[jsxRuntimeExports.jsx("g",{style:{pointerEvents:"none"},children:s.entrySeq().filter(([a,l])=>a!==i.selectedLayer&&l.visible).map(([a,l])=>jsxRuntimeExports.jsx(Layer,{mode:t,layer:l,scene:i,showDimensions:n,catalog:e},a))}),jsxRuntimeExports.jsx(Layer,{mode:t,layer:o,scene:i,showDimensions:n,catalog:e},o.id)]})},Scene$2=React.memo(Scene$1,(i,e)=>i.scene.hashCode()===e.scene.hashCode()&&i.mode===e.mode&&i.showDimensions===e.showDimensions),HUGE=4e6;function Grids({scene:i}){var u,h,d,p;const e=i.get?i.get("grids"):i.grids,t=((u=e==null?void 0:e.first)==null?void 0:u.call(e))??((p=(h=e==null?void 0:e.valueSeq)==null?void 0:(d=h.call(e)).first)==null?void 0:p.call(d));if(!t)return null;const n=t.properties,s=n.get("step")||20;let o;if(n.has("color"))o=[n.get("color")];else{const f=n.get("colors");o=f&&typeof f.toArray=="function"?f.toArray():f||[]}o.length===0&&(o=["#808080","#dddddd"]);const a=o[0],l=o[1]??o[0],c=s*o.length;return jsxRuntimeExports.jsxs("g",{pointerEvents:"none",children:[jsxRuntimeExports.jsxs("defs",{children:[jsxRuntimeExports.jsx("pattern",{id:"fp-grid-minor",width:s,height:s,patternUnits:"userSpaceOnUse",children:jsxRuntimeExports.jsx("path",{d:`M ${s} 0 L 0 0 0 ${s}`,fill:"none",stroke:l,strokeWidth:1,vectorEffect:"non-scaling-stroke"})}),jsxRuntimeExports.jsxs("pattern",{id:"fp-grid-major",width:c,height:c,patternUnits:"userSpaceOnUse",children:[jsxRuntimeExports.jsx("rect",{width:c,height:c,fill:"url(#fp-grid-minor)"}),jsxRuntimeExports.jsx("path",{d:`M ${c} 0 L 0 0 0 ${c}`,fill:"none",stroke:a,strokeWidth:1,vectorEffect:"non-scaling-stroke"})]})]}),jsxRuntimeExports.jsx("rect",{x:-HUGE,y:-HUGE,width:HUGE*2,height:HUGE*2,fill:"url(#fp-grid-major)"})]})}const guideStyle={stroke:SharedStyle.SECONDARY_COLOR.main,strokeWidth:"2.5px"},State=({catalog:i})=>{const{planner:e,showDimensions:t,showGrid:n}=useReactPlannerStore(),{activeSnapElement:s,snapElements:o,scene:a,mode:l,drawingSupport:c,itemSnapGuides:u}=e,{width:h,height:d}=a,p=e.zoom||e.viewer2D.get("a")||1,f=l===MODE_DRAWING_ROOM?{x0:c.get("startX"),y0:c.get("startY"),x1:c.get("currentX"),y1:c.get("currentY"),thickness:c.get("thickness")??15}:null;return jsxRuntimeExports.jsxs("g",{children:[n&&jsxRuntimeExports.jsx(Grids,{scene:a}),jsxRuntimeExports.jsxs("g",{transform:`translate(0, ${a.height}) scale(1, -1)`,id:"svg-drawing-paper",children:[jsxRuntimeExports.jsx(Scene$2,{scene:a,mode:l,catalog:i,showDimensions:t}),a.getIn(["guides","horizontal"]).entrySeq().map(([g,_])=>jsxRuntimeExports.jsx("line",{id:"hGuide"+g,x1:0,y1:_,x2:h,y2:_,style:guideStyle},g)),a.getIn(["guides","vertical"]).entrySeq().map(([g,_])=>jsxRuntimeExports.jsx("line",{x1:_,y1:0,x2:_,y2:d,style:guideStyle},g)),s?jsxRuntimeExports.jsx(Snap,{snap:s,width:a.width,height:a.height}):null,o?null:jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{}),u==null?void 0:u.map((g,_)=>jsxRuntimeExports.jsx(ItemSnapGuide,{guide:g,zoom:p},_)),f&&jsxRuntimeExports.jsx(RoomPreview,{preview:f,unit:a.unit})]})]})},ItemSnapGuide=({guide:i,zoom:e})=>{const t=e>0?1/e:1;return jsxRuntimeExports.jsx("line",{x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2,stroke:"var(--dark-blue, #1ca6fc)",strokeWidth:3*t,strokeDasharray:`${8*t} ${6*t}`,strokeLinecap:"butt",pointerEvents:"none"})},RoomPreview=({preview:i,unit:e})=>{const t=Math.min(i.x0,i.x1),n=Math.max(i.x0,i.x1),s=Math.min(i.y0,i.y1),o=Math.max(i.y0,i.y1),a=n-t,l=o-s;if(a<=0||l<=0)return null;const c=i.thickness,u=c/2+12;return jsxRuntimeExports.jsxs("g",{pointerEvents:"none",children:[jsxRuntimeExports.jsx("rect",{x:t,y:s,width:a,height:l,fill:"none",stroke:SharedStyle.COLORS.black,strokeWidth:c,strokeLinejoin:"miter"}),jsxRuntimeExports.jsx(DimensionLabel,{length:a,unit:e,transform:`translate(${t+a/2}, ${s-u})`}),jsxRuntimeExports.jsx(DimensionLabel,{length:a,unit:e,transform:`translate(${t+a/2}, ${o+u})`}),jsxRuntimeExports.jsx(DimensionLabel,{length:l,unit:e,transform:`translate(${n+u}, ${s+l/2}) rotate(90)`}),jsxRuntimeExports.jsx(DimensionLabel,{length:l,unit:e,transform:`translate(${t-u}, ${s+l/2}) rotate(-90)`})]})},LABEL_STYLE={textAnchor:"middle",dominantBaseline:"middle",fontSize:14,fontFamily:"'Courier New', Courier, monospace",fontWeight:"bold",fill:SharedStyle.COLORS.black,pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none"},DimensionLabel=({length:i,unit:e,transform:t})=>jsxRuntimeExports.jsx("g",{transform:t,children:jsxRuntimeExports.jsx("text",{transform:"scale(1,-1)",style:LABEL_STYLE,children:formatDistance(i,e)})}),MIN_ZOOM=.25,MAX_ZOOM=5,SVG_MIN_ZOOM=.25,SVG_MAX_ZOOM=5;var DefaultContext={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},IconContext=React.createContext&&React.createContext(DefaultContext),_excluded=["attr","size","title"];function _objectWithoutProperties(i,e){if(i==null)return{};var t=_objectWithoutPropertiesLoose(i,e),n,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(i);for(s=0;s<o.length;s++)n=o[s],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(i,n)&&(t[n]=i[n])}return t}function _objectWithoutPropertiesLoose(i,e){if(i==null)return{};var t={};for(var n in i)if(Object.prototype.hasOwnProperty.call(i,n)){if(e.indexOf(n)>=0)continue;t[n]=i[n]}return t}function _extends(){return _extends=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},_extends.apply(this,arguments)}function ownKeys(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,n)}return t}function _objectSpread(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ownKeys(Object(t),!0).forEach(function(n){_defineProperty(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function _defineProperty(i,e,t){return e=_toPropertyKey(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function _toPropertyKey(i){var e=_toPrimitive(i,"string");return typeof e=="symbol"?e:e+""}function _toPrimitive(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function Tree2Element(i){return i&&i.map((e,t)=>React.createElement(e.tag,_objectSpread({key:t},e.attr),Tree2Element(e.child)))}function GenIcon(i){return e=>React.createElement(IconBase,_extends({attr:_objectSpread({},i.attr)},e),Tree2Element(i.child))}function IconBase(i){var e=t=>{var{attr:n,size:s,title:o}=i,a=_objectWithoutProperties(i,_excluded),l=s||t.size||"1em",c;return t.className&&(c=t.className),i.className&&(c=(c?c+" ":"")+i.className),React.createElement("svg",_extends({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},t.attr,n,a,{className:c,style:_objectSpread(_objectSpread({color:i.color||t.color},t.style),i.style),height:l,width:l,xmlns:"http://www.w3.org/2000/svg"}),o&&React.createElement("title",null,o),i.children)};return IconContext!==void 0?React.createElement(IconContext.Consumer,null,t=>e(t)):e(DefaultContext)}function LuArrowUp(i){return GenIcon({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"m5 12 7-7 7 7"},child:[]},{tag:"path",attr:{d:"M12 19V5"},child:[]}]})(i)}function LuBot(i){return GenIcon({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 8V4H8"},child:[]},{tag:"rect",attr:{width:"16",height:"12",x:"4",y:"8",rx:"2"},child:[]},{tag:"path",attr:{d:"M2 14h2"},child:[]},{tag:"path",attr:{d:"M20 14h2"},child:[]},{tag:"path",attr:{d:"M15 13v2"},child:[]},{tag:"path",attr:{d:"M9 13v2"},child:[]}]})(i)}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 LuCopy(i){return GenIcon({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2"},child:[]},{tag:"path",attr:{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"},child:[]}]})(i)}function LuMic(i){return GenIcon({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"},child:[]},{tag:"path",attr:{d:"M19 10v2a7 7 0 0 1-14 0v-2"},child:[]},{tag:"line",attr:{x1:"12",x2:"12",y1:"19",y2:"22"},child:[]}]})(i)}function LuRotateCcw(i){return GenIcon({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"},child:[]},{tag:"path",attr:{d:"M3 3v5h5"},child:[]}]})(i)}function LuRotateCw(i){return GenIcon({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"},child:[]},{tag:"path",attr:{d:"M21 3v5h-5"},child:[]}]})(i)}function LuSquare(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:[]}]})(i)}function LuTrash2(i){return GenIcon({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3 6h18"},child:[]},{tag:"path",attr:{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"},child:[]},{tag:"path",attr:{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"},child:[]},{tag:"line",attr:{x1:"10",x2:"10",y1:"11",y2:"17"},child:[]},{tag:"line",attr:{x1:"14",x2:"14",y1:"11",y2:"17"},child:[]}]})(i)}function MdUpdate(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M21 10.12h-6.78l2.74-2.82c-2.73-2.7-7.15-2.8-9.88-.1-2.73 2.71-2.73 7.08 0 9.79s7.15 2.71 9.88 0C18.32 15.65 19 14.08 19 12.1h2c0 1.98-.88 4.55-2.64 6.29-3.51 3.48-9.21 3.48-12.72 0-3.5-3.47-3.53-9.11-.02-12.58s9.14-3.47 12.65 0L21 3v7.12zM12.5 8v4.25l3.5 2.08-.72 1.21L11 13V8h1.5z"},child:[]}]})(i)}function MdNavigateBefore(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M15.41 7.41 14 6l-6 6 6 6 1.41-1.41L10.83 12z"},child:[]}]})(i)}function MdMyLocation(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm8.94 3A8.994 8.994 0 0 0 13 3.06V1h-2v2.06A8.994 8.994 0 0 0 3.06 11H1v2h2.06A8.994 8.994 0 0 0 11 20.94V23h2v-2.06A8.994 8.994 0 0 0 20.94 13H23v-2h-2.06zM12 19c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z"},child:[]}]})(i)}function MdArrowBack(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"},child:[]}]})(i)}function MdOutlinePhotoSizeSelectSmall(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M23 15h-2v2h2v-2zm0-4h-2v2h2v-2zm0 8h-2v2c1 0 2-1 2-2zM15 3h-2v2h2V3zm8 4h-2v2h2V7zm-2-4v2h2c0-1-1-2-2-2zM3 21h8v-6H1v4c0 1.1.9 2 2 2zM3 7H1v2h2V7zm12 12h-2v2h2v-2zm4-16h-2v2h2V3zm0 16h-2v2h2v-2zM3 3C2 3 1 4 1 5h2V3zm0 8H1v2h2v-2zm8-8H9v2h2V3zM7 3H5v2h2V3z"},child:[]}]})(i)}function MdOutlineChair(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M20 8V6c0-1.65-1.35-3-3-3H7C5.35 3 4 4.35 4 6v2c-1.65 0-3 1.35-3 3v5c0 1.65 1.35 3 3 3v1c0 .55.45 1 1 1s1-.45 1-1v-1h12v1c0 .55.45 1 1 1s1-.45 1-1v-1c1.65 0 3-1.35 3-3v-5c0-1.65-1.35-3-3-3zM6 6c0-.55.45-1 1-1h10c.55 0 1 .45 1 1v2.78c-.61.55-1 1.34-1 2.22v2H7v-2c0-.88-.39-1.67-1-2.22V6zm15 10c0 .55-.45 1-1 1H4c-.55 0-1-.45-1-1v-5c0-.55.45-1 1-1s1 .45 1 1v4h14v-4c0-.55.45-1 1-1s1 .45 1 1v5z"},child:[]}]})(i)}function MdOutlineDoorFront(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M19 19V5c0-1.1-.9-2-2-2H7c-1.1 0-2 .9-2 2v14H3v2h18v-2h-2zm-2 0H7V5h10v14zm-4-8h2v2h-2v-2z"},child:[]}]})(i)}function MdOutlineWindow(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0z"},child:[]},{tag:"path",attr:{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 8h-6V5h6v6zm-8-6v6H5V5h6zm-6 8h6v6H5v-6zm8 6v-6h6v6h-6z"},child:[]}]})(i)}function PiFlipHorizontalBold(i){return GenIcon({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M104,20.41a19.83,19.83,0,0,0-22.4,11.81c-.07.15-.13.31-.19.46L21.47,192.49A20,20,0,0,0,40,220h60a20,20,0,0,0,20-20V40A19.83,19.83,0,0,0,104,20.41ZM96,196H45.79L96,62.09Zm138.53-3.51L174.61,32.68c-.06-.15-.12-.31-.19-.46A20,20,0,0,0,136,40V200a20,20,0,0,0,20,20h60a20,20,0,0,0,18.54-27.51ZM160,196V62.09L210.21,196Z"},child:[]}]})(i)}function PiFlipVerticalBold(i){return GenIcon({attr:{viewBox:"0 0 256 256",fill:"currentColor"},child:[{tag:"path",attr:{d:"M56,120H216a20,20,0,0,0,7.79-38.42l-.46-.19L63.51,21.47A20,20,0,0,0,36,40v60A20,20,0,0,0,56,120Zm4-74.21L193.91,96H60ZM216,136H56a20,20,0,0,0-20,20v60a20,20,0,0,0,27.51,18.54l159.81-59.92.46-.19A20,20,0,0,0,216,136ZM60,210.22V160H193.91Z"},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)}function r(i){var e,t,n="";if(typeof i=="string"||typeof i=="number")n+=i;else if(typeof i=="object")if(Array.isArray(i)){var s=i.length;for(e=0;e<s;e++)i[e]&&(t=r(i[e]))&&(n&&(n+=" "),n+=t)}else for(t in i)i[t]&&(n&&(n+=" "),n+=t);return n}function clsx(){for(var i,e,t=0,n="",s=arguments.length;t<s;t++)(i=arguments[t])&&(e=r(i))&&(n&&(n+=" "),n+=e);return n}const CLASS_PART_SEPARATOR="-",createClassGroupUtils=i=>{const e=createClassMap(i),{conflictingClassGroups:t,conflictingClassGroupModifiers:n}=i;return{getClassGroupId:a=>{const l=a.split(CLASS_PART_SEPARATOR);return l[0]===""&&l.length!==1&&l.shift(),getGroupRecursive(l,e)||getGroupIdForArbitraryProperty(a)},getConflictingClassGroupIds:(a,l)=>{const c=t[a]||[];return l&&n[a]?[...c,...n[a]]:c}}},getGroupRecursive=(i,e)=>{var a;if(i.length===0)return e.classGroupId;const t=i[0],n=e.nextPart.get(t),s=n?getGroupRecursive(i.slice(1),n):void 0;if(s)return s;if(e.validators.length===0)return;const o=i.join(CLASS_PART_SEPARATOR);return(a=e.validators.find(({validator:l})=>l(o)))==null?void 0:a.classGroupId},arbitraryPropertyRegex=/^\[(.+)\]$/,getGroupIdForArbitraryProperty=i=>{if(arbitraryPropertyRegex.test(i)){const e=arbitraryPropertyRegex.exec(i)[1],t=e==null?void 0:e.substring(0,e.indexOf(":"));if(t)return"arbitrary.."+t}},createClassMap=i=>{const{theme:e,classGroups:t}=i,n={nextPart:new Map,validators:[]};for(const s in t)processClassesRecursively(t[s],n,s,e);return n},processClassesRecursively=(i,e,t,n)=>{i.forEach(s=>{if(typeof s=="string"){const o=s===""?e:getPart(e,s);o.classGroupId=t;return}if(typeof s=="function"){if(isThemeGetter(s)){processClassesRecursively(s(n),e,t,n);return}e.validators.push({validator:s,classGroupId:t});return}Object.entries(s).forEach(([o,a])=>{processClassesRecursively(a,getPart(e,o),t,n)})})},getPart=(i,e)=>{let t=i;return e.split(CLASS_PART_SEPARATOR).forEach(n=>{t.nextPart.has(n)||t.nextPart.set(n,{nextPart:new Map,validators:[]}),t=t.nextPart.get(n)}),t},isThemeGetter=i=>i.isThemeGetter,createLruCache=i=>{if(i<1)return{get:()=>{},set:()=>{}};let e=0,t=new Map,n=new Map;const s=(o,a)=>{t.set(o,a),e++,e>i&&(e=0,n=t,t=new Map)};return{get(o){let a=t.get(o);if(a!==void 0)return a;if((a=n.get(o))!==void 0)return s(o,a),a},set(o,a){t.has(o)?t.set(o,a):s(o,a)}}},IMPORTANT_MODIFIER="!",MODIFIER_SEPARATOR=":",MODIFIER_SEPARATOR_LENGTH=MODIFIER_SEPARATOR.length,createParseClassName=i=>{const{prefix:e,experimentalParseClassName:t}=i;let n=s=>{const o=[];let a=0,l=0,c=0,u;for(let g=0;g<s.length;g++){let _=s[g];if(a===0&&l===0){if(_===MODIFIER_SEPARATOR){o.push(s.slice(c,g)),c=g+MODIFIER_SEPARATOR_LENGTH;continue}if(_==="/"){u=g;continue}}_==="["?a++:_==="]"?a--:_==="("?l++:_===")"&&l--}const h=o.length===0?s:s.substring(c),d=stripImportantModifier(h),p=d!==h,f=u&&u>c?u-c:void 0;return{modifiers:o,hasImportantModifier:p,baseClassName:d,maybePostfixModifierPosition:f}};if(e){const s=e+MODIFIER_SEPARATOR,o=n;n=a=>a.startsWith(s)?o(a.substring(s.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:a,maybePostfixModifierPosition:void 0}}if(t){const s=n;n=o=>t({className:o,parseClassName:s})}return n},stripImportantModifier=i=>i.endsWith(IMPORTANT_MODIFIER)?i.substring(0,i.length-1):i.startsWith(IMPORTANT_MODIFIER)?i.substring(1):i,createSortModifiers=i=>{const e=Object.fromEntries(i.orderSensitiveModifiers.map(n=>[n,!0]));return n=>{if(n.length<=1)return n;const s=[];let o=[];return n.forEach(a=>{a[0]==="["||e[a]?(s.push(...o.sort(),a),o=[]):o.push(a)}),s.push(...o.sort()),s}},createConfigUtils=i=>({cache:createLruCache(i.cacheSize),parseClassName:createParseClassName(i),sortModifiers:createSortModifiers(i),...createClassGroupUtils(i)}),SPLIT_CLASSES_REGEX=/\s+/,mergeClassList=(i,e)=>{const{parseClassName:t,getClassGroupId:n,getConflictingClassGroupIds:s,sortModifiers:o}=e,a=[],l=i.trim().split(SPLIT_CLASSES_REGEX);let c="";for(let u=l.length-1;u>=0;u-=1){const h=l[u],{isExternal:d,modifiers:p,hasImportantModifier:f,baseClassName:g,maybePostfixModifierPosition:_}=t(h);if(d){c=h+(c.length>0?" "+c:c);continue}let x=!!_,y=n(x?g.substring(0,_):g);if(!y){if(!x){c=h+(c.length>0?" "+c:c);continue}if(y=n(g),!y){c=h+(c.length>0?" "+c:c);continue}x=!1}const E=o(p).join(":"),b=f?E+IMPORTANT_MODIFIER:E,v=b+y;if(a.includes(v))continue;a.push(v);const M=s(y,x);for(let T=0;T<M.length;++T){const I=M[T];a.push(b+I)}c=h+(c.length>0?" "+c:c)}return c};function twJoin(){let i=0,e,t,n="";for(;i<arguments.length;)(e=arguments[i++])&&(t=toValue(e))&&(n&&(n+=" "),n+=t);return n}const toValue=i=>{if(typeof i=="string")return i;let e,t="";for(let n=0;n<i.length;n++)i[n]&&(e=toValue(i[n]))&&(t&&(t+=" "),t+=e);return t};function createTailwindMerge(i,...e){let t,n,s,o=a;function a(c){const u=e.reduce((h,d)=>d(h),i());return t=createConfigUtils(u),n=t.cache.get,s=t.cache.set,o=l,l(c)}function l(c){const u=n(c);if(u)return u;const h=mergeClassList(c,t);return s(c,h),h}return function(){return o(twJoin.apply(null,arguments))}}const fromTheme=i=>{const e=t=>t[i]||[];return e.isThemeGetter=!0,e},arbitraryValueRegex=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,arbitraryVariableRegex=/^\((?:(\w[\w-]*):)?(.+)\)$/i,fractionRegex=/^\d+\/\d+$/,tshirtUnitRegex=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,lengthUnitRegex=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,colorFunctionRegex=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,shadowRegex=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,imageRegex=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,isFraction=i=>fractionRegex.test(i),isNumber=i=>!!i&&!Number.isNaN(Number(i)),isInteger=i=>!!i&&Number.isInteger(Number(i)),isPercent=i=>i.endsWith("%")&&isNumber(i.slice(0,-1)),isTshirtSize=i=>tshirtUnitRegex.test(i),isAny=()=>!0,isLengthOnly=i=>lengthUnitRegex.test(i)&&!colorFunctionRegex.test(i),isNever=()=>!1,isShadow=i=>shadowRegex.test(i),isImage=i=>imageRegex.test(i),isAnyNonArbitrary=i=>!isArbitraryValue(i)&&!isArbitraryVariable(i),isArbitrarySize=i=>getIsArbitraryValue(i,isLabelSize,isNever),isArbitraryValue=i=>arbitraryValueRegex.test(i),isArbitraryLength=i=>getIsArbitraryValue(i,isLabelLength,isLengthOnly),isArbitraryNumber=i=>getIsArbitraryValue(i,isLabelNumber,isNumber),isArbitraryPosition=i=>getIsArbitraryValue(i,isLabelPosition,isNever),isArbitraryImage=i=>getIsArbitraryValue(i,isLabelImage,isImage),isArbitraryShadow=i=>getIsArbitraryValue(i,isLabelShadow,isShadow),isArbitraryVariable=i=>arbitraryVariableRegex.test(i),isArbitraryVariableLength=i=>getIsArbitraryVariable(i,isLabelLength),isArbitraryVariableFamilyName=i=>getIsArbitraryVariable(i,isLabelFamilyName),isArbitraryVariablePosition=i=>getIsArbitraryVariable(i,isLabelPosition),isArbitraryVariableSize=i=>getIsArbitraryVariable(i,isLabelSize),isArbitraryVariableImage=i=>getIsArbitraryVariable(i,isLabelImage),isArbitraryVariableShadow=i=>getIsArbitraryVariable(i,isLabelShadow,!0),getIsArbitraryValue=(i,e,t)=>{const n=arbitraryValueRegex.exec(i);return n?n[1]?e(n[1]):t(n[2]):!1},getIsArbitraryVariable=(i,e,t=!1)=>{const n=arbitraryVariableRegex.exec(i);return n?n[1]?e(n[1]):t:!1},isLabelPosition=i=>i==="position"||i==="percentage",isLabelImage=i=>i==="image"||i==="url",isLabelSize=i=>i==="length"||i==="size"||i==="bg-size",isLabelLength=i=>i==="length",isLabelNumber=i=>i==="number",isLabelFamilyName=i=>i==="family-name",isLabelShadow=i=>i==="shadow",getDefaultConfig=()=>{const i=fromTheme("color"),e=fromTheme("font"),t=fromTheme("text"),n=fromTheme("font-weight"),s=fromTheme("tracking"),o=fromTheme("leading"),a=fromTheme("breakpoint"),l=fromTheme("container"),c=fromTheme("spacing"),u=fromTheme("radius"),h=fromTheme("shadow"),d=fromTheme("inset-shadow"),p=fromTheme("text-shadow"),f=fromTheme("drop-shadow"),g=fromTheme("blur"),_=fromTheme("perspective"),x=fromTheme("aspect"),y=fromTheme("ease"),E=fromTheme("animate"),b=()=>["auto","avoid","all","avoid-page","page","left","right","column"],v=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],M=()=>[...v(),isArbitraryVariable,isArbitraryValue],T=()=>["auto","hidden","clip","visible","scroll"],I=()=>["auto","contain","none"],w=()=>[isArbitraryVariable,isArbitraryValue,c],R=()=>[isFraction,"full","auto",...w()],A=()=>[isInteger,"none","subgrid",isArbitraryVariable,isArbitraryValue],P=()=>["auto",{span:["full",isInteger,isArbitraryVariable,isArbitraryValue]},isInteger,isArbitraryVariable,isArbitraryValue],B=()=>[isInteger,"auto",isArbitraryVariable,isArbitraryValue],k=()=>["auto","min","max","fr",isArbitraryVariable,isArbitraryValue],W=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],Y=()=>["start","end","center","stretch","center-safe","end-safe"],$=()=>["auto",...w()],ee=()=>[isFraction,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...w()],G=()=>[i,isArbitraryVariable,isArbitraryValue],K=()=>[...v(),isArbitraryVariablePosition,isArbitraryPosition,{position:[isArbitraryVariable,isArbitraryValue]}],F=()=>["no-repeat",{repeat:["","x","y","space","round"]}],X=()=>["auto","cover","contain",isArbitraryVariableSize,isArbitrarySize,{size:[isArbitraryVariable,isArbitraryValue]}],se=()=>[isPercent,isArbitraryVariableLength,isArbitraryLength],me=()=>["","none","full",u,isArbitraryVariable,isArbitraryValue],Me=()=>["",isNumber,isArbitraryVariableLength,isArbitraryLength],j=()=>["solid","dashed","dotted","double"],ie=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Z=()=>[isNumber,isPercent,isArbitraryVariablePosition,isArbitraryPosition],ue=()=>["","none",g,isArbitraryVariable,isArbitraryValue],be=()=>["none",isNumber,isArbitraryVariable,isArbitraryValue],re=()=>["none",isNumber,isArbitraryVariable,isArbitraryValue],Fe=()=>[isNumber,isArbitraryVariable,isArbitraryValue],oe=()=>[isFraction,"full",...w()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[isTshirtSize],breakpoint:[isTshirtSize],color:[isAny],container:[isTshirtSize],"drop-shadow":[isTshirtSize],ease:["in","out","in-out"],font:[isAnyNonArbitrary],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[isTshirtSize],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[isTshirtSize],shadow:[isTshirtSize],spacing:["px",isNumber],text:[isTshirtSize],"text-shadow":[isTshirtSize],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",isFraction,isArbitraryValue,isArbitraryVariable,x]}],container:["container"],columns:[{columns:[isNumber,isArbitraryValue,isArbitraryVariable,l]}],"break-after":[{"break-after":b()}],"break-before":[{"break-before":b()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:M()}],overflow:[{overflow:T()}],"overflow-x":[{"overflow-x":T()}],"overflow-y":[{"overflow-y":T()}],overscroll:[{overscroll:I()}],"overscroll-x":[{"overscroll-x":I()}],"overscroll-y":[{"overscroll-y":I()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:R()}],"inset-x":[{"inset-x":R()}],"inset-y":[{"inset-y":R()}],start:[{start:R()}],end:[{end:R()}],top:[{top:R()}],right:[{right:R()}],bottom:[{bottom:R()}],left:[{left:R()}],visibility:["visible","invisible","collapse"],z:[{z:[isInteger,"auto",isArbitraryVariable,isArbitraryValue]}],basis:[{basis:[isFraction,"full","auto",l,...w()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[isNumber,isFraction,"auto","initial","none",isArbitraryValue]}],grow:[{grow:["",isNumber,isArbitraryVariable,isArbitraryValue]}],shrink:[{shrink:["",isNumber,isArbitraryVariable,isArbitraryValue]}],order:[{order:[isInteger,"first","last","none",isArbitraryVariable,isArbitraryValue]}],"grid-cols":[{"grid-cols":A()}],"col-start-end":[{col:P()}],"col-start":[{"col-start":B()}],"col-end":[{"col-end":B()}],"grid-rows":[{"grid-rows":A()}],"row-start-end":[{row:P()}],"row-start":[{"row-start":B()}],"row-end":[{"row-end":B()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...W(),"normal"]}],"justify-items":[{"justify-items":[...Y(),"normal"]}],"justify-self":[{"justify-self":["auto",...Y()]}],"align-content":[{content:["normal",...W()]}],"align-items":[{items:[...Y(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...Y(),{baseline:["","last"]}]}],"place-content":[{"place-content":W()}],"place-items":[{"place-items":[...Y(),"baseline"]}],"place-self":[{"place-self":["auto",...Y()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:$()}],mx:[{mx:$()}],my:[{my:$()}],ms:[{ms:$()}],me:[{me:$()}],mt:[{mt:$()}],mr:[{mr:$()}],mb:[{mb:$()}],ml:[{ml:$()}],"space-x":[{"space-x":w()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":w()}],"space-y-reverse":["space-y-reverse"],size:[{size:ee()}],w:[{w:[l,"screen",...ee()]}],"min-w":[{"min-w":[l,"screen","none",...ee()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[a]},...ee()]}],h:[{h:["screen","lh",...ee()]}],"min-h":[{"min-h":["screen","lh","none",...ee()]}],"max-h":[{"max-h":["screen","lh",...ee()]}],"font-size":[{text:["base",t,isArbitraryVariableLength,isArbitraryLength]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,isArbitraryVariable,isArbitraryNumber]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",isPercent,isArbitraryValue]}],"font-family":[{font:[isArbitraryVariableFamilyName,isArbitraryValue,e]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,isArbitraryVariable,isArbitraryValue]}],"line-clamp":[{"line-clamp":[isNumber,"none",isArbitraryVariable,isArbitraryNumber]}],leading:[{leading:[o,...w()]}],"list-image":[{"list-image":["none",isArbitraryVariable,isArbitraryValue]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",isArbitraryVariable,isArbitraryValue]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:G()}],"text-color":[{text:G()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...j(),"wavy"]}],"text-decoration-thickness":[{decoration:[isNumber,"from-font","auto",isArbitraryVariable,isArbitraryLength]}],"text-decoration-color":[{decoration:G()}],"underline-offset":[{"underline-offset":[isNumber,"auto",isArbitraryVariable,isArbitraryValue]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:w()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",isArbitraryVariable,isArbitraryValue]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",isArbitraryVariable,isArbitraryValue]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:K()}],"bg-repeat":[{bg:F()}],"bg-size":[{bg:X()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},isInteger,isArbitraryVariable,isArbitraryValue],radial:["",isArbitraryVariable,isArbitraryValue],conic:[isInteger,isArbitraryVariable,isArbitraryValue]},isArbitraryVariableImage,isArbitraryImage]}],"bg-color":[{bg:G()}],"gradient-from-pos":[{from:se()}],"gradient-via-pos":[{via:se()}],"gradient-to-pos":[{to:se()}],"gradient-from":[{from:G()}],"gradient-via":[{via:G()}],"gradient-to":[{to:G()}],rounded:[{rounded:me()}],"rounded-s":[{"rounded-s":me()}],"rounded-e":[{"rounded-e":me()}],"rounded-t":[{"rounded-t":me()}],"rounded-r":[{"rounded-r":me()}],"rounded-b":[{"rounded-b":me()}],"rounded-l":[{"rounded-l":me()}],"rounded-ss":[{"rounded-ss":me()}],"rounded-se":[{"rounded-se":me()}],"rounded-ee":[{"rounded-ee":me()}],"rounded-es":[{"rounded-es":me()}],"rounded-tl":[{"rounded-tl":me()}],"rounded-tr":[{"rounded-tr":me()}],"rounded-br":[{"rounded-br":me()}],"rounded-bl":[{"rounded-bl":me()}],"border-w":[{border:Me()}],"border-w-x":[{"border-x":Me()}],"border-w-y":[{"border-y":Me()}],"border-w-s":[{"border-s":Me()}],"border-w-e":[{"border-e":Me()}],"border-w-t":[{"border-t":Me()}],"border-w-r":[{"border-r":Me()}],"border-w-b":[{"border-b":Me()}],"border-w-l":[{"border-l":Me()}],"divide-x":[{"divide-x":Me()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":Me()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...j(),"hidden","none"]}],"divide-style":[{divide:[...j(),"hidden","none"]}],"border-color":[{border:G()}],"border-color-x":[{"border-x":G()}],"border-color-y":[{"border-y":G()}],"border-color-s":[{"border-s":G()}],"border-color-e":[{"border-e":G()}],"border-color-t":[{"border-t":G()}],"border-color-r":[{"border-r":G()}],"border-color-b":[{"border-b":G()}],"border-color-l":[{"border-l":G()}],"divide-color":[{divide:G()}],"outline-style":[{outline:[...j(),"none","hidden"]}],"outline-offset":[{"outline-offset":[isNumber,isArbitraryVariable,isArbitraryValue]}],"outline-w":[{outline:["",isNumber,isArbitraryVariableLength,isArbitraryLength]}],"outline-color":[{outline:G()}],shadow:[{shadow:["","none",h,isArbitraryVariableShadow,isArbitraryShadow]}],"shadow-color":[{shadow:G()}],"inset-shadow":[{"inset-shadow":["none",d,isArbitraryVariableShadow,isArbitraryShadow]}],"inset-shadow-color":[{"inset-shadow":G()}],"ring-w":[{ring:Me()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:G()}],"ring-offset-w":[{"ring-offset":[isNumber,isArbitraryLength]}],"ring-offset-color":[{"ring-offset":G()}],"inset-ring-w":[{"inset-ring":Me()}],"inset-ring-color":[{"inset-ring":G()}],"text-shadow":[{"text-shadow":["none",p,isArbitraryVariableShadow,isArbitraryShadow]}],"text-shadow-color":[{"text-shadow":G()}],opacity:[{opacity:[isNumber,isArbitraryVariable,isArbitraryValue]}],"mix-blend":[{"mix-blend":[...ie(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":ie()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[isNumber]}],"mask-image-linear-from-pos":[{"mask-linear-from":Z()}],"mask-image-linear-to-pos":[{"mask-linear-to":Z()}],"mask-image-linear-from-color":[{"mask-linear-from":G()}],"mask-image-linear-to-color":[{"mask-linear-to":G()}],"mask-image-t-from-pos":[{"mask-t-from":Z()}],"mask-image-t-to-pos":[{"mask-t-to":Z()}],"mask-image-t-from-color":[{"mask-t-from":G()}],"mask-image-t-to-color":[{"mask-t-to":G()}],"mask-image-r-from-pos":[{"mask-r-from":Z()}],"mask-image-r-to-pos":[{"mask-r-to":Z()}],"mask-image-r-from-color":[{"mask-r-from":G()}],"mask-image-r-to-color":[{"mask-r-to":G()}],"mask-image-b-from-pos":[{"mask-b-from":Z()}],"mask-image-b-to-pos":[{"mask-b-to":Z()}],"mask-image-b-from-color":[{"mask-b-from":G()}],"mask-image-b-to-color":[{"mask-b-to":G()}],"mask-image-l-from-pos":[{"mask-l-from":Z()}],"mask-image-l-to-pos":[{"mask-l-to":Z()}],"mask-image-l-from-color":[{"mask-l-from":G()}],"mask-image-l-to-color":[{"mask-l-to":G()}],"mask-image-x-from-pos":[{"mask-x-from":Z()}],"mask-image-x-to-pos":[{"mask-x-to":Z()}],"mask-image-x-from-color":[{"mask-x-from":G()}],"mask-image-x-to-color":[{"mask-x-to":G()}],"mask-image-y-from-pos":[{"mask-y-from":Z()}],"mask-image-y-to-pos":[{"mask-y-to":Z()}],"mask-image-y-from-color":[{"mask-y-from":G()}],"mask-image-y-to-color":[{"mask-y-to":G()}],"mask-image-radial":[{"mask-radial":[isArbitraryVariable,isArbitraryValue]}],"mask-image-radial-from-pos":[{"mask-radial-from":Z()}],"mask-image-radial-to-pos":[{"mask-radial-to":Z()}],"mask-image-radial-from-color":[{"mask-radial-from":G()}],"mask-image-radial-to-color":[{"mask-radial-to":G()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":v()}],"mask-image-conic-pos":[{"mask-conic":[isNumber]}],"mask-image-conic-from-pos":[{"mask-conic-from":Z()}],"mask-image-conic-to-pos":[{"mask-conic-to":Z()}],"mask-image-conic-from-color":[{"mask-conic-from":G()}],"mask-image-conic-to-color":[{"mask-conic-to":G()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:K()}],"mask-repeat":[{mask:F()}],"mask-size":[{mask:X()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",isArbitraryVariable,isArbitraryValue]}],filter:[{filter:["","none",isArbitraryVariable,isArbitraryValue]}],blur:[{blur:ue()}],brightness:[{brightness:[isNumber,isArbitraryVariable,isArbitraryValue]}],contrast:[{contrast:[isNumber,isArbitraryVariable,isArbitraryValue]}],"drop-shadow":[{"drop-shadow":["","none",f,isArbitraryVariableShadow,isArbitraryShadow]}],"drop-shadow-color":[{"drop-shadow":G()}],grayscale:[{grayscale:["",isNumber,isArbitraryVariable,isArbitraryValue]}],"hue-rotate":[{"hue-rotate":[isNumber,isArbitraryVariable,isArbitraryValue]}],invert:[{invert:["",isNumber,isArbitraryVariable,isArbitraryValue]}],saturate:[{saturate:[isNumber,isArbitraryVariable,isArbitraryValue]}],sepia:[{sepia:["",isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-filter":[{"backdrop-filter":["","none",isArbitraryVariable,isArbitraryValue]}],"backdrop-blur":[{"backdrop-blur":ue()}],"backdrop-brightness":[{"backdrop-brightness":[isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-contrast":[{"backdrop-contrast":[isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-grayscale":[{"backdrop-grayscale":["",isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-invert":[{"backdrop-invert":["",isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-opacity":[{"backdrop-opacity":[isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-saturate":[{"backdrop-saturate":[isNumber,isArbitraryVariable,isArbitraryValue]}],"backdrop-sepia":[{"backdrop-sepia":["",isNumber,isArbitraryVariable,isArbitraryValue]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",isArbitraryVariable,isArbitraryValue]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[isNumber,"initial",isArbitraryVariable,isArbitraryValue]}],ease:[{ease:["linear","initial",y,isArbitraryVariable,isArbitraryValue]}],delay:[{delay:[isNumber,isArbitraryVariable,isArbitraryValue]}],animate:[{animate:["none",E,isArbitraryVariable,isArbitraryValue]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[_,isArbitraryVariable,isArbitraryValue]}],"perspective-origin":[{"perspective-origin":M()}],rotate:[{rotate:be()}],"rotate-x":[{"rotate-x":be()}],"rotate-y":[{"rotate-y":be()}],"rotate-z":[{"rotate-z":be()}],scale:[{scale:re()}],"scale-x":[{"scale-x":re()}],"scale-y":[{"scale-y":re()}],"scale-z":[{"scale-z":re()}],"scale-3d":["scale-3d"],skew:[{skew:Fe()}],"skew-x":[{"skew-x":Fe()}],"skew-y":[{"skew-y":Fe()}],transform:[{transform:[isArbitraryVariable,isArbitraryValue,"","none","gpu","cpu"]}],"transform-origin":[{origin:M()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:oe()}],"translate-x":[{"translate-x":oe()}],"translate-y":[{"translate-y":oe()}],"translate-z":[{"translate-z":oe()}],"translate-none":["translate-none"],accent:[{accent:G()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:G()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",isArbitraryVariable,isArbitraryValue]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",isArbitraryVariable,isArbitraryValue]}],fill:[{fill:["none",...G()]}],"stroke-w":[{stroke:[isNumber,isArbitraryVariableLength,isArbitraryLength,isArbitraryNumber]}],stroke:[{stroke:["none",...G()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},twMerge=createTailwindMerge(getDefaultConfig);function cn(...i){return twMerge(clsx(i))}const Tooltip=({anchorEl:i,title:e,position:t="right",visible:n,collisionPadding:s=8})=>{const o=React.useRef(null);return React.useLayoutEffect(()=>{if(!i||!o.current)return;const a=o.current;if(!n){a.style.opacity="0",a.style.transform="scale(0.95)",a.style.pointerEvents="none";return}a.style.visibility="hidden",a.style.top="-9999px",a.style.left="-9999px",a.style.opacity="0",a.style.transform="scale(0.95)";const l=a.getBoundingClientRect(),c=i.getBoundingClientRect(),u=8,h=window.innerWidth,d=window.innerHeight,p={right:h-c.right>=l.width+u+s,left:c.left>=l.width+u+s,top:c.top>=l.height+u+s,bottom:d-c.bottom>=l.height+u+s};let f=t;p[t]||(f=["right","left","top","bottom"].find(y=>p[y])??t);let g=0,_=0;switch(f){case"right":g=c.top+c.height/2-l.height/2,_=c.right+u;break;case"left":g=c.top+c.height/2-l.height/2,_=c.left-l.width-u;break;case"top":g=c.top-l.height-u,_=c.left+c.width/2-l.width/2;break;case"bottom":g=c.bottom+u,_=c.left+c.width/2-l.width/2;break}const x=(y,E,b)=>Math.min(Math.max(y,E),b);a.style.position="fixed",a.style.top=`${x(g,s,d-l.height-s)}px`,a.style.left=`${x(_,s,h-l.width-s)}px`,a.style.visibility="visible",a.style.opacity="1",a.style.transform="scale(1)",a.style.pointerEvents="none"},[n,i,t,s]),reactDom.createPortal(jsxRuntimeExports.jsx("div",{ref:o,className:`
71
71
  z-[9999]
72
72
  fixed
73
73
  bg-black text-white text-xs
@@ -3928,12 +3928,12 @@ This License becomes null and void to the extent applicable to Fonts or Font Sof
3928
3928
  \r
3929
3929
  The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself. \r
3930
3930
  \r
3931
- THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL MAGENTA OR PERSONS OR BODIES IN CHARGE OF ADMINISTRATION AND MAINTENANCE OF THE FONT SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.`,manufacturer_name:"Μagenta ltd",font_sub_family_name:"Regular"},descender:-334,familyName:"Helvetiker",lineHeight:1522,underlineThickness:50};function gridHorizontalStreak(i,e,t,n){const s=t.properties.get("step"),o=t.properties.has("color")?List([t.properties.get("color")]):t.properties.get("colors"),a=new Object3D;a.name="streak";let l=0;for(let c=0;c<=e;c+=s){const u=[new Vector3(0,0,-c),new Vector3(i,0,-c)],h=new BufferGeometry().setFromPoints(u),d=o.get(l%o.size),p=new LineBasicMaterial({color:d}),f=new LineSegments(h,p);a.add(f),a.add(new LineSegments(h,p)),l++}return a}function gridVerticalStreak(i,e,t,n){const s=t.properties.get("step"),o=t.properties.has("color")?List([t.properties.get("color")]):t.properties.get("colors"),a=new Object3D;a.name="streak";let l=0;for(let c=0;c<=i;c+=s){const u=[new Vector3(c,0,0),new Vector3(c,0,-e)],h=new BufferGeometry().setFromPoints(u),d=o.get(l%o.size),p=new LineBasicMaterial({color:d});a.add(new LineSegments(h,p)),l++}return a}const MIN_GRID=2e3,PADDING=1e3,MAX_GRID=4e4;function contentGridExtent(i){const e=i,t=e.get?e.get("layers"):e.layers;let n=1/0,s=1/0,o=-1/0,a=-1/0,l=!1;const c=(_,x)=>{typeof _!="number"||typeof x!="number"||!isFinite(_)||!isFinite(x)||(n=Math.min(n,_),s=Math.min(s,x),o=Math.max(o,_),a=Math.max(a,x),l=!0)};t.forEach(_=>{const x=_.get("vertices");_.get("lines").forEach(y=>{y.get("vertices").forEach(E=>{const b=x.get(E);b&&c(b.get("x"),b.get("y"))})}),_.get("items").forEach(y=>{c(y.get("x"),y.get("y"))})});const u=(()=>{var y,E,b,v,M;const _=e.get?e.get("grids"):e.grids,x=((y=_==null?void 0:_.first)==null?void 0:y.call(_))??((v=(E=_==null?void 0:_.valueSeq)==null?void 0:(b=E.call(_)).first)==null?void 0:v.call(b));return((M=x==null?void 0:x.properties)==null?void 0:M.get("step"))??20})(),h=_=>Math.ceil(_/u)*u;if(!l)return{offsetX:0,offsetZ:0,gridW:MIN_GRID,gridH:MIN_GRID};const d=Math.min(MAX_GRID,Math.max(MIN_GRID,h(o-n+PADDING*2))),p=Math.min(MAX_GRID,Math.max(MIN_GRID,h(a-s+PADDING*2))),f=(n+o)/2,g=(s+a)/2;return{offsetX:f-d/2,offsetZ:g-p/2,gridW:d,gridH:p}}function createGrid(i){const e=new Object3D;e.name="grid",new FontLoader().parse(HELVETIKER);const{grids:n}=i,{offsetX:s,offsetZ:o,gridW:a,gridH:l}=contentGridExtent(i);return n.forEach(c=>{switch(c.type){case"horizontal-streak":e.add(gridHorizontalStreak(a,l,c));break;case"vertical-streak":e.add(gridVerticalStreak(a,l,c));break}}),e.position.x=s,e.position.z=-o,e.position.y=-1,e}function disposeGeometry(i){i&&i.dispose&&i.dispose()}function disposeTexture(i){i&&i.dispose&&i.dispose()}function disposeMaterial(i){if(i){if(Array.isArray(i)){i.forEach(e=>disposeMaterial(e));return}for(const e in i){const t=i[e];t instanceof Texture&&disposeTexture(t)}i.dispose()}}function disposeMesh(i){(i instanceof Mesh||i instanceof BoxHelper||i instanceof LineSegments)&&(disposeGeometry(i.geometry),disposeMaterial(i.material),i.geometry=null,i.material=null)}function disposeScene(i){i.traverse(e=>{disposeMesh(e)})}function disposeObject(i){i.traverse(e=>{disposeMesh(e)})}function asColorMap(i){return i.colorSpace=SRGBColorSpace,i}function asDataMap(i){return i.colorSpace=NoColorSpace,i}const converted=new WeakMap,isConvertible=i=>i.isMeshPhongMaterial===!0||i.isMeshLambertMaterial===!0;function toStandard(i){const e=converted.get(i);if(e)return e;const t=i.shininess??0,n=new MeshStandardMaterial({name:i.name,color:i.color,map:i.map,roughness:MathUtils.clamp(1-Math.sqrt(Math.min(t,200)/200),.65,1),metalness:0,emissive:i.emissive,emissiveMap:i.emissiveMap,normalMap:i.normalMap,normalScale:i.normalScale,bumpMap:i.bumpMap,bumpScale:i.bumpScale,alphaMap:i.alphaMap,aoMap:i.aoMap,side:i.side,transparent:i.transparent,opacity:i.opacity,alphaTest:i.alphaTest,vertexColors:i.vertexColors});return converted.set(i,n),n}const fixColorSpaces=i=>{i.map&&asColorMap(i.map),i.emissiveMap&&asColorMap(i.emissiveMap),i.specularMap&&asColorMap(i.specularMap),i.normalMap&&asDataMap(i.normalMap),i.roughnessMap&&asDataMap(i.roughnessMap),i.metalnessMap&&asDataMap(i.metalnessMap),i.aoMap&&asDataMap(i.aoMap)};function normalizeImportedMaterials(i){return i.traverse(e=>{const t=e;if(!t.isMesh||!t.material)return;const s=(Array.isArray(t.material)?t.material:[t.material]).map(o=>{const a=isConvertible(o)?toStandard(o):o;return fixColorSpaces(a),a.needsUpdate=!0,a});t.material=Array.isArray(t.material)?s:s[0]}),i}function enableShadows(i,{cast:e=!0,receive:t=!0}={}){return i.traverse(n=>{n.isMesh&&(n.castShadow=e,n.receiveShadow=t)}),i}function parseData(i,e,t){const n={sceneGraph:{unit:i.unit,layers:{},busyResources:{layers:{}},width:i.width,height:i.height,LODs:{}},plan:new Object3D,grid:createGrid(i),boundingBox:new Box3};n.plan.name="plan",n.grid.name="grid",n.boundingBox.setFromObject(n.grid);let s=[];return i.layers.forEach(o=>{(o.id===i.selectedLayer||o.visible)&&(s=s.concat(createLayerObjects(o,n,i,e,t)))}),updateBoundingBoxWhenSettled(s,n),n}function createLayerObjects(i,e,t,n,s){const o=[];return e.sceneGraph.layers[i.id]={id:i.id,lines:{},holes:{},areas:{},items:{},visible:i.visible,altitude:i.altitude},e.sceneGraph.busyResources.layers[i.id]={id:i.id,lines:{},holes:{},areas:{},items:{}},i.lines.forEach(a=>{o.push(addLine(t,e,i,a.id,s,n.linesActions)),a.holes.forEach(l=>{o.push(addHole(t,e,i,l,s,n.holesActions))})}),i.areas.forEach(a=>{o.push(addArea(t,e,i,a.id,s,n.areaActions))}),i.items.forEach(a=>{o.push(addItem(t,e,i,a.id,s,n.itemsActions))}),o}function updateScene(i,e,t,n,s,o){const a=n.map(c=>({op:c.op,path:c.path.split("/"),value:c.value}));let l=filterDiffs(a,e,t);return l=l.filter(({path:c})=>c[3]!=="selected"),l=l.filter(({path:c})=>c[1]!=="groups"),l.forEach(({op:c,path:u,value:h})=>{if(u[1]==="layers"){const d=e.getIn(["layers",u[2]]);if(u.length===3&&c==="remove")removeLayer(u[2],i);else if(u.length>3)switch(c){case"replace":replaceObject(u,d,i,s,e,t,o);break;case"add":addObject(u,d,i,s,e,t,o);break;case"remove":removeObject(u,d,i,s,e,t,o);break}}else if(u[1]==="selectedLayer"){const d=h,p=e.getIn(["layers",d]);if(!p.visible){const g=createLayerObjects(p,i,e,s,o);updateBoundingBoxWhenSettled(g,i)}const f=i.sceneGraph.layers[(t==null?void 0:t.selectedLayer)??""];if(f&&!f.visible){for(let g in f.lines)removeLine(i,f.id,g);for(let g in f.areas)removeArea(i,f.id,g);for(let g in f.items)removeItem(i,f.id,g);for(let g in f.holes)removeHole(i,f.id,g)}}}),i}function replaceObject(i,e,t,n,s,o,a){let l=[];switch(i[3]){case"vertices":if(i[5]!=="selected"){const f=e.getIn(["vertices",i[4]]);if((i[5]==="x"||i[5]==="y")&&(f.lines.forEach(g=>{const _=o.getIn(["layers",e.id,"lines",g,"holes"]);return _&&_.forEach(x=>{replaceObject([0,0,0,"holes",x,"selected"],e,t,n,s,o,a)}),replaceObject([0,0,0,"lines",g],e,t,n,s,o,a)}),f.areas.forEach(g=>replaceObject([0,0,0,"areas",g],e,t,n,s,o,a))),i[5]==="areas"){let g=f.getIn(["areas",~~i[6]]);replaceObject([0,0,0,"areas",g],e,t,n,s,o,a)}}break;case"holes":const c=e.getIn(["holes",i[4]]);if(a.getElement(c.type).updateRender3D)l.push(updateHole(s,o,t,e,i[4],i.slice(5),a,n.holesActions,()=>removeHole(t,e.id,c.id),()=>addHole(s,t,e,c.id,a,n.holesActions)));else{let f=c.line;i[5]==="selected"?(removeHole(t,e.id,c.id),l.push(addHole(s,t,e,c.id,a,n.holesActions))):(e.getIn(["lines",f,"holes"]).forEach(g=>{removeHole(t,e.id,g)}),removeLine(t,e.id,f),l.push(addLine(s,t,e,f,a,n.linesActions)),e.getIn(["lines",f,"holes"]).forEach(g=>{l.push(addHole(s,t,e,g,a,n.holesActions))}))}break;case"lines":const u=e.getIn(["lines",i[4]]);a.getElement(u.type).updateRender3D?l.push(updateLine(s,o,t,e,i[4],i.slice(5),a,n.linesActions,()=>removeLine(t,e.id,i[4]),()=>addLine(s,t,e,i[4],a,n.linesActions))):(removeLine(t,e.id,i[4]),l.push(addLine(s,t,e,i[4],a,n.linesActions)));break;case"areas":const h=e.getIn(["areas",i[4]]);a.getElement(h.type).updateRender3D?l.push(updateArea(s,o,t,e,i[4],i.slice(5),a,n.areaActions,()=>removeArea(t,e.id,i[4]),()=>addArea(s,t,e,i[4],a,n.areaActions))):(t.sceneGraph.layers[e.id].areas[i[4]]&&removeArea(t,e.id,i[4]),l.push(addArea(s,t,e,i[4],a,n.areaActions)));break;case"items":const d=e.getIn(["items",i[4]]);a.getElement(d.type).updateRender3D?l.push(updateItem(s,o,t,e,i[4],i.slice(5),a,n.itemsActions,()=>removeItem(t,e.id,i[4]),()=>addItem(s,t,e,i[4],a,n.itemsActions))):(removeItem(t,e.id,i[4]),l.push(addItem(s,t,e,i[4],a,n.itemsActions)));break;case"visible":if(e.visible)l=l.concat(createLayerObjects(e,t,s,n,a));else{let f=t.sceneGraph.layers[e.id];for(let g in f.lines)removeLine(t,e.id,g);for(let g in f.areas)removeArea(t,e.id,g);for(let g in f.items)removeItem(t,e.id,g);for(let g in f.holes)removeHole(t,e.id,g)}break;case"opacity":case"altitude":let p=t.sceneGraph.layers[e.id];for(let f in p.lines)removeLine(t,e.id,f);for(let f in p.areas)removeArea(t,e.id,f);for(let f in p.items)removeItem(t,e.id,f);for(let f in p.holes)removeHole(t,e.id,f);l=l.concat(createLayerObjects(e,t,s,n,a))}updateBoundingBoxWhenSettled(l,t)}function removeObject(i,e,t,n,s,o,a){let l=[];switch(i[3]){case"lines":const c=i[4];o.getIn(["layers",e.id,"lines",c,"holes"]).forEach(u=>{removeHole(t,e.id,u)}),removeLine(t,e.id,c),i.length>5&&(l.push(addLine(s,t,e,c,a,n.linesActions)),e.getIn(["lines",c,"holes"]).forEach(u=>{l.push(addHole(s,t,e,u,a,n.holesActions))}));break;case"areas":i.length===5&&removeArea(t,e.id,i[4]);break;case"items":i.length===5&&removeItem(t,e.id,i[4]);break}updateBoundingBoxWhenSettled(l,t)}function removeLayer(i,e){let t=e.sceneGraph.layers[i];for(let n in t.lines)removeLine(e,i,n);for(let n in t.areas)removeArea(e,i,n);for(let n in t.items)removeItem(e,i,n);for(let n in t.holes)removeHole(e,i,n);delete e.sceneGraph.layers[i]}function removeHole(i,e,t){if(i.sceneGraph.busyResources.layers[e].holes[t]){setTimeout(()=>removeHole(i,e,t),100);return}i.sceneGraph.busyResources.layers[e].holes[t]=!0;let n=i.sceneGraph.layers[e].holes[t];n&&(i.plan.remove(n),disposeObject(n),delete i.sceneGraph.layers[e].holes[t],delete i.sceneGraph.LODs[t],n=null,updateBoundingBox(i)),i.sceneGraph.busyResources.layers[e].holes[t]=!1}function removeLine(i,e,t){if(i.sceneGraph.busyResources.layers[e].lines[t]){setTimeout(()=>removeLine(i,e,t),100);return}i.sceneGraph.busyResources.layers[e].lines[t]=!0;let n=i.sceneGraph.layers[e].lines[t];n&&(i.plan.remove(n),disposeObject(n),delete i.sceneGraph.layers[e].lines[t],delete i.sceneGraph.LODs[t],n=null,updateBoundingBox(i)),i.sceneGraph.busyResources.layers[e].lines[t]=!1}function removeArea(i,e,t){if(i.sceneGraph.busyResources.layers[e].areas[t]){setTimeout(()=>removeArea(i,e,t),100);return}i.sceneGraph.busyResources.layers[e].areas[t]=!0;let n=i.sceneGraph.layers[e].areas[t];n&&(i.plan.remove(n),disposeObject(n),delete i.sceneGraph.layers[e].areas[t],delete i.sceneGraph.LODs[t],n=null,updateBoundingBox(i)),i.sceneGraph.busyResources.layers[e].areas[t]=!1}function removeItem(i,e,t){if(i.sceneGraph.busyResources.layers[e].items[t]){setTimeout(()=>removeItem(i,e,t),100);return}i.sceneGraph.busyResources.layers[e].items[t]=!0;let n=i.sceneGraph.layers[e].items[t];n&&(i.plan.remove(n),disposeObject(n),delete i.sceneGraph.layers[e].items[t],delete i.sceneGraph.LODs[t],n=null,updateBoundingBox(i)),i.sceneGraph.busyResources.layers[e].items[t]=!1}function addObject(i,e,t,n,s,o,a){if(i.length===5){let l=null,c=null;switch(i[3]){case"lines":l=addLine,c=n.linesActions;break;case"areas":l=addArea,c=n.areaActions;break;case"items":l=addItem,c=n.itemsActions;break;case"holes":l=addHole,c=n.holesActions;break}l&&updateBoundingBoxWhenSettled([l(s,t,e,i[4],a,c)],t)}}function addHole(i,e,t,n,s,o){const a=t.getIn(["holes",n]);return s.getElement(a.type).render3D(a,t,i).then(l=>{l instanceof LOD&&(e.sceneGraph.LODs[n]=l);const c=new Object3D;c.name="pivot",c.add(enableShadows(l));const u=t.getIn(["lines",a.line]);let h=t.vertices.get(u.vertices.get(0)),d=t.vertices.get(u.vertices.get(1)),p=a.offset;if(h.x>d.x){const T=h;h=d,d=T,p=1-p}let f=Math.sqrt(Math.pow(h.x-d.x,2)+Math.pow(h.y-d.y,2)),g=Math.asin((d.y-h.y)/f),_=new Box3().setFromObject(c),x=[(_.max.x-_.min.x)/2+_.min.x,(_.max.y-_.min.y)/2+_.min.y,(_.max.z-_.min.z)/2+_.min.z],y=a.properties.getIn(["altitude","length"]),E=a.properties.getIn(["height","length"]);const b=a.flipAlongWall?-1:1;c.scale.x=b;const v=b===-1?2*x[0]:0;c.rotation.y=g,c.position.x=h.x+(f*p+v)*Math.cos(g)-x[2]*Math.sin(g),c.position.y=y+E/2-x[1]+t.altitude,c.position.z=-h.y-(f*p+v)*Math.sin(g)-x[2]*Math.cos(g),e.plan.add(c),e.sceneGraph.layers[t.id].holes[a.id]=c,applyInteract(c,()=>o.selectHole(t.id,a.id));let M=t.opacity;a.selected&&(M=1),applyOpacity(c,M)})}function updateHole(i,e,t,n,s,o,a,l,c,u){const h=n.getIn(["holes",s]),d=e.getIn(["layers",n.id,"holes",s]),p=t.sceneGraph.layers[n.id].holes[s];return p?a.getElement(h.type).updateRender3D(h,n,i,p,d,o,c,u):null}function addLine(i,e,t,n,s,o){if(e.sceneGraph.busyResources.layers[t.id].lines[n]){setTimeout(()=>addLine(i,e,t,n,s,o),100);return}e.sceneGraph.busyResources.layers[t.id].lines[n]=!0;const a=t.getIn(["lines",n]);let l=t.vertices.get(a.vertices.get(0)),c=t.vertices.get(a.vertices.get(1));if(l.x>c.x){let u=l;l=c,c=u}return s.getElement(a.type).render3D(a,t,i).then(u=>{u instanceof LOD&&(e.sceneGraph.LODs[a.id]=u);let h=new Object3D;h.name="pivot",h.add(enableShadows(u)),h.position.x=l.x,h.position.y=t.altitude,h.position.z=-l.y,e.plan.add(h),e.sceneGraph.layers[t.id].lines[n]=h,applyInteract(h,()=>o.selectLine(t.id,a.id));let d=t.opacity;a.selected&&(d=1),applyOpacity(h,d),e.sceneGraph.busyResources.layers[t.id].lines[n]=!1})}function updateLine(i,e,t,n,s,o,a,l,c,u){const h=n.getIn(["lines",s]),d=e.getIn(["layers",n.id,"lines",s]),p=t.sceneGraph.layers[n.id].lines[s];return p?a.getElement(h.type).updateRender3D(h,n,i,p,d,o,c,u):null}function addArea(i,e,t,n,s,o){if(e.sceneGraph.busyResources.layers[t.id].areas[n]){setTimeout(()=>addArea(i,e,t,n,s,o),100);return}e.sceneGraph.busyResources.layers[t.id].areas[n]=!0;const a=t.getIn(["areas",n]),l=()=>o.selectArea(t.id,n);return s.getElement(a.type).render3D(a,t,i).then(c=>{c instanceof LOD&&(e.sceneGraph.LODs[n]=c);let u=new Object3D;u.name="pivot",u.add(enableShadows(c,{cast:!1})),u.position.y=t.altitude,e.plan.add(u),e.sceneGraph.layers[t.id].areas[n]=u,applyInteract(u,l);let h=t.opacity;a.selected&&(h=1),applyOpacity(u,h),e.sceneGraph.busyResources.layers[t.id].areas[n]=!1})}function updateArea(i,e,t,n,s,o,a,l,c,u){const h=n.getIn(["areas",s]),d=e.getIn(["layers",n.id,"areas",s]),p=t.sceneGraph.layers[n.id].areas[s];return p?a.getElement(h.type).updateRender3D(h,n,i,p,d,o,c,u):null}function addItem(i,e,t,n,s,o){const a=t.getIn(["items",n]);return s.getElement(a.type).render3D(a,t,i).then(l=>{l instanceof LOD&&(e.sceneGraph.LODs[n]=l);const c=new Object3D;c.name="pivot",c.add(enableShadows(l));const{scale:u,flipHorizontal:h,flipVertical:d}=getItemTransform(a);c.scale.set(u*(h?-1:1),u,u*(d?-1:1)),c.rotation.y=a.rotation*Math.PI/180,c.position.x=a.x,c.position.y=t.altitude,c.position.z=-a.y,applyInteract(l,()=>{o.selectItem(t.id,a.id)});let p=t.opacity;a.selected&&(p=1),applyOpacity(c,p),e.plan.add(c),e.sceneGraph.layers[t.id].items[a.id]=c})}function updateItem(i,e,t,n,s,o,a,l,c,u){const h=n.getIn(["items",s]),d=e.getIn(["layers",n.id,"items",s]),p=t.sceneGraph.layers[n.id].items[s];return p?a.getElement(h.type).updateRender3D(h,n,i,p,d,o,c,u):null}function applyInteract(i,e){i.traverse(t=>{(t instanceof Mesh||t.isMesh)&&(t.interact=e)})}function applyOpacity(i,e){i.traverse(t=>{t instanceof Mesh&&(t.material instanceof Array?t.material.forEach(n=>{n.transparent=!0,n.maxOpacity?n.opacity=Math.min(n.maxOpacity,e):n.opacity&&n.opacity>e&&(n.maxOpacity=n.opacity,n.opacity=e)}):(t.material.transparent=!0,t.material.maxOpacity?t.material.opacity=Math.min(t.material.maxOpacity,e):t.material.opacity&&t.material.opacity>e&&(t.material.maxOpacity=t.material.opacity,t.material.opacity=e)))})}function updateBoundingBox(i){const e=new Box3().setFromObject(i.plan);isFinite(e.max.x)&&isFinite(e.min.x)&&isFinite(e.max.y)&&isFinite(e.min.y)&&isFinite(e.max.z)&&isFinite(e.min.z)&&(i.boundingBox=e)}function updateBoundingBoxWhenSettled(i,e){return Promise.allSettled(i).then(()=>updateBoundingBox(e))}function filterDiffs(i,e,t){return minimizeRemoveDiffsWhenSwitchingLayers(minimizeChangePropertiesAfterSelectionsDiffs(minimizeChangePropertiesDiffs(i)),e,t)}function minimizeRemoveDiffsWhenSwitchingLayers(i,e,t){let n,s;for(s=0;s<i.length&&!n;s++)i[s].path[1]==="selectedLayer"&&(n=i[s]);return n&&!e.getIn(["layers",t.selectedLayer,"visible"])?i.filter(({op:o,path:a})=>!(a[a.length-1]==="selected"&&a[1]==="layers"&&a[2]===t.selectedLayer)&&!(o==="remove"&&a.indexOf(t.selectedLayer)!==-1)):i}function minimizeChangePropertiesAfterSelectionsDiffs(i,e,t){const n={};return i.forEach(({path:s})=>{s[5]==="selected"&&(n[s[4]]=s[4])}),i.filter(({path:s})=>s[5]==="properties"?!n[s[4]]:!0)}function minimizeChangePropertiesDiffs(i,e,t){const n={};return i.filter(({path:s})=>s[5]==="properties"?n[s[4]]?!1:n[s[4]]=!0:s[5]!=="misc")}const _changeEvent={type:"change"},_startEvent={type:"start"},_endEvent={type:"end"},_ray=new Ray,_plane=new Plane,_TILT_LIMIT=Math.cos(70*MathUtils.DEG2RAD),_v=new Vector3,_twoPI=2*Math.PI,_STATE={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},_EPS=1e-6;class OrbitControls extends Controls{constructor(e,t=null){super(e,t),this.state=_STATE.NONE,this.target=new Vector3,this.cursor=new Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:MOUSE.ROTATE,MIDDLE:MOUSE.DOLLY,RIGHT:MOUSE.PAN},this.touches={ONE:TOUCH.ROTATE,TWO:TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new Vector3,this._lastQuaternion=new Quaternion,this._lastTargetPosition=new Vector3,this._quat=new Quaternion().setFromUnitVectors(e.up,new Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Spherical,this._sphericalDelta=new Spherical,this._scale=1,this._panOffset=new Vector3,this._rotateStart=new Vector2,this._rotateEnd=new Vector2,this._rotateDelta=new Vector2,this._panStart=new Vector2,this._panEnd=new Vector2,this._panDelta=new Vector2,this._dollyStart=new Vector2,this._dollyEnd=new Vector2,this._dollyDelta=new Vector2,this._dollyDirection=new Vector3,this._mouse=new Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=onPointerMove.bind(this),this._onPointerDown=onPointerDown.bind(this),this._onPointerUp=onPointerUp.bind(this),this._onContextMenu=onContextMenu.bind(this),this._onMouseWheel=onMouseWheel.bind(this),this._onKeyDown=onKeyDown.bind(this),this._onTouchStart=onTouchStart.bind(this),this._onTouchMove=onTouchMove.bind(this),this._onMouseDown=onMouseDown.bind(this),this._onMouseMove=onMouseMove.bind(this),this._interceptControlDown=interceptControlDown.bind(this),this._interceptControlUp=interceptControlUp.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(_changeEvent),this.update(),this.state=_STATE.NONE}update(e=null){const t=this.object.position;_v.copy(t).sub(this.target),_v.applyQuaternion(this._quat),this._spherical.setFromVector3(_v),this.autoRotate&&this.state===_STATE.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=_twoPI:n>Math.PI&&(n-=_twoPI),s<-Math.PI?s+=_twoPI:s>Math.PI&&(s-=_twoPI),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let o=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),o=a!=this._spherical.radius}if(_v.setFromSpherical(this._spherical),_v.applyQuaternion(this._quatInverse),t.copy(this.target).add(_v),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const l=_v.length();a=this._clampDistance(l*this._scale);const c=l-a;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),o=!!c}else if(this.object.isOrthographicCamera){const l=new Vector3(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),o=c!==this.object.zoom;const u=new Vector3(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),a=_v.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(_ray.origin.copy(this.object.position),_ray.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(_ray.direction))<_TILT_LIMIT?this.object.lookAt(this.target):(_plane.setFromNormalAndCoplanarPoint(this.object.up,this.target),_ray.intersectPlane(_plane,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),o=!0)}return this._scale=1,this._performCursorZoom=!1,o||this._lastPosition.distanceToSquared(this.object.position)>_EPS||8*(1-this._lastQuaternion.dot(this.object.quaternion))>_EPS||this._lastTargetPosition.distanceToSquared(this.target)>_EPS?(this.dispatchEvent(_changeEvent),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?_twoPI/60*this.autoRotateSpeed*e:_twoPI/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){_v.setFromMatrixColumn(t,0),_v.multiplyScalar(-e),this._panOffset.add(_v)}_panUp(e,t){this.screenSpacePanning===!0?_v.setFromMatrixColumn(t,1):(_v.setFromMatrixColumn(t,0),_v.crossVectors(this.object.up,_v)),_v.multiplyScalar(e),this._panOffset.add(_v)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;_v.copy(s).sub(this.target);let o=_v.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*o/n.clientHeight,this.object.matrix),this._panUp(2*t*o/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),s=e-n.left,o=t-n.top,a=n.width,l=n.height;this._mouse.x=s/a*2-1,this._mouse.y=-(o/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(_twoPI*this._rotateDelta.x/t.clientHeight),this._rotateUp(_twoPI*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(_twoPI*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-_twoPI*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(_twoPI*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-_twoPI*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,o=Math.sqrt(n*n+s*s);this._dollyStart.set(0,o)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),o=.5*(e.pageY+n.y);this._rotateEnd.set(s,o)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(_twoPI*this._rotateDelta.x/t.clientHeight),this._rotateUp(_twoPI*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,o=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,o),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,l=(e.pageY+t.y)*.5;this._updateZoomParameters(a,l)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function onPointerDown(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function onPointerMove(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function onPointerUp(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(_endEvent),this.state=_STATE.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function onMouseDown(i){let e;switch(i.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=_STATE.DOLLY;break;case MOUSE.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=_STATE.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=_STATE.ROTATE}break;case MOUSE.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=_STATE.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=_STATE.PAN}break;default:this.state=_STATE.NONE}this.state!==_STATE.NONE&&this.dispatchEvent(_startEvent)}function onMouseMove(i){switch(this.state){case _STATE.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case _STATE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case _STATE.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function onMouseWheel(i){this.enabled===!1||this.enableZoom===!1||this.state!==_STATE.NONE||(i.preventDefault(),this.dispatchEvent(_startEvent),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(_endEvent))}function onKeyDown(i){this.enabled!==!1&&this._handleKeyDown(i)}function onTouchStart(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=_STATE.TOUCH_ROTATE;break;case TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=_STATE.TOUCH_PAN;break;default:this.state=_STATE.NONE}break;case 2:switch(this.touches.TWO){case TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=_STATE.TOUCH_DOLLY_PAN;break;case TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=_STATE.TOUCH_DOLLY_ROTATE;break;default:this.state=_STATE.NONE}break;default:this.state=_STATE.NONE}this.state!==_STATE.NONE&&this.dispatchEvent(_startEvent)}function onTouchMove(i){switch(this._trackPointer(i),this.state){case _STATE.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case _STATE.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case _STATE.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case _STATE.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=_STATE.NONE}}function onContextMenu(i){this.enabled!==!1&&i.preventDefault()}function interceptControlDown(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function interceptControlUp(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const ACCENT=1877756,SHADE=1710618,RING_OUTER=1.35,RING_INNER=1.18,RING_GRAB_PADDING=.14,LIFT_RADIUS_PX=21,LIFT_GRAB_PX=30,PLUMB_WIDTH_PX=3,PLUMB_DASH_PX=17,LIFTED_EPSILON=1,MIN_RING_RADIUS=20;function dashTexture(){const i=document.createElement("canvas");i.width=1,i.height=16;const e=i.getContext("2d");e&&(e.fillStyle="#111111",e.fillRect(0,0,1,10));const t=new CanvasTexture(i);return t.wrapT=RepeatWrapping,t.magFilter=NearestFilter,t.minFilter=NearestFilter,t.colorSpace=SRGBColorSpace,t}function arrowShape(i,e,t){const n=i/2,s=t,o=e/2,a=t/2,l=n-s,c=new Shape;return c.moveTo(-n,0),c.lineTo(-l,a),c.lineTo(-l,o),c.lineTo(l,o),c.lineTo(l,a),c.lineTo(n,0),c.lineTo(l,-a),c.lineTo(l,-o),c.lineTo(-l,-o),c.lineTo(-l,-a),c.closePath(),c}const overlayMaterial=(i,e)=>new MeshBasicMaterial({color:i,opacity:e,transparent:!0,depthTest:!1,depthWrite:!1,side:DoubleSide,toneMapped:!1});class SelectionGizmo{constructor(){ze(this,"group",new Group);ze(this,"base",new Group);ze(this,"ring");ze(this,"rotateGrab");ze(this,"rotateArrow");ze(this,"lift",new Group);ze(this,"liftGrab");ze(this,"plumb");ze(this,"plumbTexture");ze(this,"materials",[]);ze(this,"geometries",[]);ze(this,"textures",[]);this.group.name="selection-gizmo",this.group.visible=!1,this.group.userData.gizmo=!0;const e=this.keep(new RingGeometry(RING_INNER,RING_OUTER,64)),t=this.keep(new CircleGeometry(RING_INNER,64)),n=this.keep(new RingGeometry(RING_INNER-RING_GRAB_PADDING,RING_OUTER+RING_GRAB_PADDING,32));this.ring=new Mesh(e,this.keep(overlayMaterial(SHADE,.3)));const s=new Mesh(t,this.keep(overlayMaterial(SHADE,.12)));this.rotateGrab=new Mesh(n,this.keep(new MeshBasicMaterial({visible:!1,side:DoubleSide})));const o=this.keep(new ShapeGeometry(arrowShape(.62,.055,.17)));this.rotateArrow=new Mesh(o,this.keep(overlayMaterial(ACCENT,1))),[s,this.ring,this.rotateGrab,this.rotateArrow].forEach(c=>{c.rotation.x=-Math.PI/2,this.base.add(c)}),this.rotateArrow.position.set(0,.02,(RING_INNER+RING_OUTER)/2),this.group.add(this.base);const a=new Mesh(this.keep(new CircleGeometry(1,40)),this.keep(overlayMaterial(16777215,1))),l=new Mesh(this.keep(new ShapeGeometry(arrowShape(1.5,.16,.62))),this.keep(overlayMaterial(SHADE,1)));l.rotation.z=Math.PI/2,l.position.z=.01,this.liftGrab=new Mesh(this.keep(new CircleGeometry(LIFT_GRAB_PX/LIFT_RADIUS_PX,16)),this.keep(new MeshBasicMaterial({visible:!1,side:DoubleSide}))),this.lift.add(a,l,this.liftGrab),this.group.add(this.lift),this.plumbTexture=this.keepTexture(dashTexture()),this.plumb=new Mesh(this.keep(new PlaneGeometry(1,1)),this.keep(new MeshBasicMaterial({map:this.plumbTexture,transparent:!0,depthTest:!1,depthWrite:!1,side:DoubleSide,toneMapped:!1}))),this.plumb.visible=!1,this.group.add(this.plumb)}keep(e){return e instanceof Material?this.materials.push(e):this.geometries.push(e),e}keepTexture(e){return this.textures.push(e),e}update(e,t,n){if(!e){this.group.visible=!1;return}this.group.visible=!0;const s=Math.max(MIN_RING_RADIUS,e.radius);this.base.position.set(e.centre.x,e.floorY,e.centre.z),this.base.rotation.y=e.rotationY,this.base.scale.setScalar(s),this.lift.position.set(e.centre.x,e.handleY,e.centre.z),this.lift.quaternion.copy(t.quaternion);const o=t.position.distanceTo(this.lift.position),a=n(o);this.lift.scale.setScalar(a*LIFT_RADIUS_PX),this.updatePlumb(e,t,a)}updatePlumb(e,t,n){const s=e.handleY-e.floorY;if(this.plumb.visible=e.lifting&&e.bottomY-e.floorY>LIFTED_EPSILON&&s>0,!this.plumb.visible)return;this.plumb.position.set(e.centre.x,e.floorY+s/2,e.centre.z),this.plumb.scale.set(n*PLUMB_WIDTH_PX,s,1),Math.hypot(t.position.x-this.plumb.position.x,t.position.z-this.plumb.position.z)>.001&&this.plumb.lookAt(t.position.x,this.plumb.position.y,t.position.z),this.plumbTexture.repeat.set(1,Math.max(1,s/(n*PLUMB_DASH_PX)))}pick(e){return this.group.visible?e.intersectObject(this.liftGrab,!1).length>0?"lift":e.intersectObject(this.rotateGrab,!1).length>0?"rotate":null:null}dispose(){this.group.removeFromParent(),this.geometries.forEach(e=>e.dispose()),this.materials.forEach(e=>e.dispose()),this.textures.forEach(e=>e.dispose())}}const isMap=i=>isKeyed(i),isIndexedCollection=i=>isIndexed(i),isRecord$1=i=>Record.isRecord(i),op=(i,e,t)=>i==="remove"?{op:i,path:e}:{op:i,path:e,value:t},makeMatrix=(i,e,t)=>{const n=[];for(let s=0;s<i;s++){n[s]=new Array(e);for(let o=0;o<e;o++)n[s][o]=t}return n},DiffResult=Record({op:"=",val:null}),ReplaceResult=Record({op:"!=",val:null,newVal:null}),diff$1=(i,e)=>{const t=computeLcsMatrix(i,e);return printDiff(t,i,e,i.size??0,e.size??0)},computeLcsMatrix=(i,e)=>{const t=i.size??0,n=e.size??0,s=makeMatrix(t+1,n+1,0);for(let o=0;o<t;o++)for(let a=0;a<n;a++)is(i.get(o),e.get(a))?s[o+1][a+1]=s[o][a]+1:s[o+1][a+1]=Math.max(s[o+1][a],s[o][a+1]);return s},printDiff=(i,e,t,n,s)=>{const o=[];let a=n-1,l=s-1;for(;a>=0||l>=0;)a>=0&&l>=0&&is(e.get(a),t.get(l))?(o.push(new DiffResult({op:"=",val:e.get(a)})),a--,l--):a>=0&&l>=0&&a===l&&!is(e.get(a),t.get(l))?(o.push(new ReplaceResult({val:e.get(a),newVal:t.get(a)})),a--,l--):l>=0&&(a===-1||i[a+1][l]>=i[a][l+1])?(o.push(new DiffResult({op:"+",val:t.get(l)})),l--):a>=0&&(l===-1||i[a+1][l]<i[a][l+1])&&(o.push(new DiffResult({op:"-",val:e.get(a)})),a--);return o.reverse()},slashRe=/\//g,tildeRe=/~/g,escape=i=>{if(typeof i=="number")return i.toString();if(typeof i!="string")throw new Error(`param str (${String(i)}) is not a string`);return i.replace(tildeRe,"~0").replace(slashRe,"~1")},concat=(i,e)=>`${i}/${e}`,mapDiff=(i,e,t="")=>{let n=[];if(is(i,e)||i==e&&i==null)return n;const s=isIndexedCollection(i)&&isIndexedCollection(e);let o=null,a=null;return i.forEach&&i.forEach((l,c)=>{if(e.has(c))if(isRecord$1(l)&&isRecord$1(e.get(c)))n=n.concat(recordDiff(l,e.get(c),concat(t,escape(c))));else if(isMap(l)&&isMap(e.get(c)))n=n.concat(mapDiff(l,e.get(c),concat(t,escape(c))));else if(isIndexedCollection(l)&&isIndexedCollection(e.get(c)))n=n.concat(sequenceDiff(l,e.get(c),concat(t,escape(c))));else{const u=e.get?e.get(c):e;l!==u&&n.push(op("replace",concat(t,escape(c)),u))}else s?(a=o!=null&&Number(o)+1===c?a:c,n.push(op("remove",concat(t,escape(a)))),o=c):n.push(op("remove",concat(t,escape(c))))}),e.forEach((l,c)=>{i.has&&!i.has(c)&&n.push(op("add",concat(t,escape(c)),l))}),n},recordDiff=(i,e,t="")=>{let n=[];if(is(i,e)||i==e&&i==null)return n;const s=i.toSeq().toMap(),o=e.toSeq().toMap();return n=n.concat(mapDiff(s,o,t)),n},sequenceDiff=(i,e,t="")=>{let n=[];if(is(i,e)||i==e&&i==null)return n;if((i.count()+1)*(e.count()+1)>=1e4)return mapDiff(i,e,t);const s=diff$1(i,e);let o=0;return s.forEach(a=>{if(a.op==="=")o++;else if(a.op==="!="){if(isRecord$1(a.val)&&isRecord$1(a.newVal)){const l=recordDiff(a.val,a.newVal,concat(t,String(o)));n=n.concat(l)}else if(isMap(a.val)&&isMap(a.newVal)){const l=mapDiff(a.val,a.newVal,concat(t,String(o)));n=n.concat(l)}else n.push(op("replace",concat(t,String(o)),a.newVal));o++}else a.op==="+"?(n.push(op("add",concat(t,String(o)),a.val)),o++):a.op==="-"&&n.push(op("remove",concat(t,String(o))))}),n},primitiveTypeDiff=(i,e,t="")=>i===e?[]:[op("replace",concat(t,""),e)],diff=(i,e,t="")=>is(i,e)?List():i!=e&&(i==null||e==null)?fromJS([op("replace","/",e)]):isIndexedCollection(i)&&isIndexedCollection(e)?fromJS(sequenceDiff(i,e)):isRecord$1(i)&&isRecord$1(e)?fromJS(recordDiff(i,e)):isMap(i)&&isMap(e)?fromJS(mapDiff(i,e)):fromJS(primitiveTypeDiff(i,e,t)),FIT_MARGIN=1.25,ENTRY_MARGIN=1.25,TOP_DOWN=new Vector3(0,1,0),SHADOW_SETTLE_MS=2e3,pointerAngleAround=(i,e)=>Math.atan2(-(e.z-i.z),e.x-i.x);class Scene3DViewer extends React.Component{constructor(t){super(t);ze(this,"canvasWrapperRef",React.createRef());ze(this,"renderer");ze(this,"scene3D",null);ze(this,"camera",null);ze(this,"orbitControls",null);ze(this,"planData");ze(this,"renderingID",0);ze(this,"width");ze(this,"height");ze(this,"lastMousePosition",{});ze(this,"mouseDownEvent");ze(this,"mouseUpEvent");ze(this,"lastBoundingBox",null);ze(this,"userMovedCamera",!1);ze(this,"sun",null);ze(this,"shadowsDirtyUntil",0);ze(this,"gizmo",null);ze(this,"gizmoDrag",null);ze(this,"gizmoMoveEvent");ze(this,"gizmoUpEvent");ze(this,"scratchBox",new Box3);ze(this,"scratchVector",new Vector3);ze(this,"scratchSize",new Vector3);ze(this,"gizmoRadiusFor",null);ze(this,"gizmoRadius",0);ze(this,"worldPerPixel",t=>{const n=this.camera;return!n||this.height===0?1:2*t*Math.tan(MathUtils.degToRad(n.fov)/2)/this.height});this.width=t.width,this.height=t.height,this.renderer=new WebGLRenderer({preserveDrawingBuffer:!0,antialias:!0})}componentDidMount(){var v,M;const{state:t,actions:n}=this.props,s={areaActions:n.areaActions,holesActions:n.holesActions,itemsActions:n.itemsActions,linesActions:n.linesActions,projectActions:n.projectActions},o=t.scene,a=this.canvasWrapperRef.current,l=new Scene;this.renderer.setSize(this.width,this.height),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,1.5)),this.renderer.outputColorSpace=SRGBColorSpace,this.renderer.useLegacyLights=!1,this.renderer.toneMapping=NeutralToneMapping,this.renderer.toneMappingExposure=1,this.renderer.setClearColor(new Color(COLORS.threeBG)),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=PCFSoftShadowMap,this.renderer.shadowMap.autoUpdate=!1,this.renderer.sortObjects=!1;const c=parseData(o,s,this.props.catalog);l.add(c.plan),l.add(c.grid),c.grid.visible=this.props.showGrid;const u=this.width/this.height,h=new PerspectiveCamera(45,u,1,3e5);l.add(h),h.up.set(0,1,0);const d=c.boundingBox.getCenter(new Vector3),p=c.boundingBox.getSize(new Vector3);h.position.copy(d).add(TOP_DOWN.clone().setLength(Math.max(1,p.length()))),l.add(new HemisphereLight(16777215,15921906,3));const f=new DirectionalLight(16774892,1);f.castShadow=!0,f.shadow.mapSize.set(2048,2048),f.shadow.bias=-5e-4,f.shadow.normalBias=2,l.add(f),l.add(f.target),this.sun=f;const g=[c.plan],_=new Vector2,x=new Raycaster;this.mouseDownEvent=T=>{var w;this.lastMousePosition.x=T.offsetX/this.width*2-1,this.lastMousePosition.y=-T.offsetY/this.height*2+1,_.set(this.lastMousePosition.x,this.lastMousePosition.y),x.setFromCamera(_,h);const I=((w=this.gizmo)==null?void 0:w.pick(x))??null;I&&(T.preventDefault(),T.stopPropagation(),this.beginGizmoDrag(I,x))},this.mouseUpEvent=T=>{var I,w;if(T.preventDefault(),!this.gizmoDrag&&(_.x=T.offsetX/this.width*2-1,_.y=-(T.offsetY/this.height)*2+1,Math.abs(_.x-(this.lastMousePosition.x??0))<=.02&&Math.abs(_.y-(this.lastMousePosition.y??0))<=.02)){x.setFromCamera(_,h);const R=x.intersectObjects(g,!0);R.length>0&&!isNaN(R[0].distance)?(w=(I=R[0].object).interact)==null||w.call(I):this.props.actions.projectActions.unselectAll()}},this.gizmoMoveEvent=T=>{if(!this.camera)return;const I=this.renderer.domElement.getBoundingClientRect();if(_.x=(T.clientX-I.left)/I.width*2-1,_.y=-((T.clientY-I.top)/I.height)*2+1,this.gizmoDrag){x.setFromCamera(_,this.camera),this.updateGizmoDrag(x);return}Math.abs(_.x)<=1&&Math.abs(_.y)<=1&&this.gizmo&&(x.setFromCamera(_,this.camera),this.renderer.domElement.style.cursor=this.gizmo.pick(x)?"grab":"")},this.gizmoUpEvent=()=>this.endGizmoDrag(),this.renderer.domElement.addEventListener("mousedown",this.mouseDownEvent),this.renderer.domElement.addEventListener("mouseup",this.mouseUpEvent),window.addEventListener("mousemove",this.gizmoMoveEvent),window.addEventListener("mouseup",this.gizmoUpEvent),a&&a.appendChild(this.renderer.domElement);const y=new OrbitControls(h,this.renderer.domElement);y.enableDamping=!0,y.dampingFactor=.05,y.addEventListener("start",()=>{this.userMovedCamera=!0});const E=new SelectionGizmo;l.add(E.group),this.gizmo=E,this.orbitControls=y,this.camera=h,this.scene3D=l,this.planData=c,this.applyZoomLimits(c.boundingBox);const b=()=>{var I;const T=(I=this.planData)==null?void 0:I.boundingBox;T&&T!==this.lastBoundingBox&&!T.isEmpty()&&(this.lastBoundingBox=T,this.positionSun(T),this.userMovedCamera||(this.applyZoomLimits(T),this.frameScene(TOP_DOWN,ENTRY_MARGIN))),performance.now()<this.shadowsDirtyUntil&&(this.renderer.shadowMap.needsUpdate=!0),E.update(this.selectedItemTarget(),h,this.worldPerPixel),y.update();for(const w in c.sceneGraph.LODs)c.sceneGraph.LODs[w].update(h);this.renderer.render(l,h),this.renderingID=requestAnimationFrame(b)};b(),(M=(v=this.props.actions).registerViewer)==null||M.call(v,this)}selectedItemTarget(){var u,h,d,p,f,g,_,x;const t=this.props.state.scene,n=t.selectedLayer,s=t.layers.get(n),o=(h=(u=s==null?void 0:s.selected)==null?void 0:u.items)==null?void 0:h.first();if(!o)return null;const a=(_=(g=(f=(p=(d=this.planData)==null?void 0:d.sceneGraph)==null?void 0:p.layers)==null?void 0:f[n])==null?void 0:g.items)==null?void 0:_[o];if(!a)return null;const l=this.scratchBox.setFromObject(a);if(l.isEmpty())return null;if(this.gizmoRadiusFor!==a){const y=l.getSize(this.scratchSize);this.gizmoRadius=Math.hypot(y.x,y.z)/2,this.gizmoRadiusFor=a}const c=a.getWorldPosition(this.scratchVector);return{centre:c,floorY:c.y,handleY:(l.min.y+l.max.y)/2,radius:this.gizmoRadius,rotationY:a.rotation.y,bottomY:l.min.y,lifting:((x=this.gizmoDrag)==null?void 0:x.handle)==="lift"}}beginGizmoDrag(t,n){var f,g,_,x,y,E,b,v;const s=this.props.state.scene,o=s.selectedLayer,a=s.layers.get(o),l=(g=(f=a==null?void 0:a.selected)==null?void 0:f.items)==null?void 0:g.first();if(!l)return;const c=a.items.get(l),u=(b=(E=(y=(x=(_=this.planData)==null?void 0:_.sceneGraph)==null?void 0:x.layers)==null?void 0:y[o])==null?void 0:E.items)==null?void 0:b[l];if(!c||!u)return;const h=u.getWorldPosition(new Vector3),d=t==="rotate"?new Plane(new Vector3(0,1,0),-h.y):new Plane().setFromNormalAndCoplanarPoint(this.camera.position.clone().sub(h).setY(0).normalize(),h),p=n.ray.intersectPlane(d,new Vector3);p&&(this.gizmoDrag={handle:t,layerID:o,itemID:l,pivot:u,plane:d,startRotation:c.rotation??0,startPointerAngle:pointerAngleAround(h,p),startAltitude:c.altitude??0,model:u.children[0]??null,startModelY:((v=u.children[0])==null?void 0:v.position.y)??0,startPointerY:p.y,rotation:c.rotation??0,altitude:c.altitude??0},this.orbitControls&&(this.orbitControls.enabled=!1),this.renderer.domElement.style.cursor="grabbing")}updateGizmoDrag(t){const n=this.gizmoDrag;if(!n)return;const s=t.ray.intersectPlane(n.plane,new Vector3);if(s){if(n.handle==="rotate"){const o=n.pivot.getWorldPosition(new Vector3),a=pointerAngleAround(o,s)-n.startPointerAngle;n.rotation=snapToRightAngle(normalizeAngle(n.startRotation+MathUtils.radToDeg(a))),n.pivot.rotation.y=MathUtils.degToRad(n.rotation)}else if(n.model){n.altitude=Math.max(0,n.startAltitude+(s.y-n.startPointerY));const o=n.pivot.scale.y||1;n.model.position.y=n.startModelY+(n.altitude-n.startAltitude)/o}this.invalidateShadows()}}endGizmoDrag(){var s,o;const t=this.gizmoDrag;!t||(this.gizmoDrag=null,this.orbitControls&&(this.orbitControls.enabled=!0),this.renderer.domElement.style.cursor="",!(t.handle==="rotate"?t.rotation!==t.startRotation:t.altitude!==t.startAltitude))||(o=(s=this.props.actions.itemsActions)==null?void 0:s.setItemAttributes)==null||o.call(s,t.itemID,t.handle==="rotate"?{rotation:t.rotation}:{altitude:t.altitude})}positionSun(t){const n=this.sun;if(!n)return;const s=t.getCenter(new Vector3),o=Math.max(100,t.getSize(new Vector3).length()/2);n.position.copy(s).add(new Vector3(.45,1,.35).setLength(o*2.5)),n.target.position.copy(s),n.target.updateMatrixWorld();const a=n.shadow.camera;a.left=-o,a.right=o,a.top=o,a.bottom=-o,a.near=o*.5,a.far=o*5,a.updateProjectionMatrix(),this.invalidateShadows()}invalidateShadows(){this.renderer.shadowMap.needsUpdate=!0,this.shadowsDirtyUntil=performance.now()+SHADOW_SETTLE_MS}applyZoomLimits(t){const n=this.orbitControls;if(!n||t.isEmpty())return;const s=Math.max(1,t.getSize(this.scratchSize).length());n.minDistance=Math.max(50,s*.05),n.maxDistance=Math.max(600,s*2.5)}zoomBy(t){const n=this.orbitControls,s=this.camera;if(!n||!s||t<=0)return;this.userMovedCamera=!0;const o=s.position.clone().sub(n.target),a=o.length();if(a===0)return;const l=MathUtils.clamp(a/t,n.minDistance,n.maxDistance);s.position.copy(n.target).add(o.setLength(l)),n.update()}fitToScene(){this.userMovedCamera=!0,this.frameScene()}frameScene(t,n=FIT_MARGIN){var y;const s=this.orbitControls,o=this.camera,a=(y=this.planData)==null?void 0:y.boundingBox;if(!s||!o||!a||a.isEmpty())return;const l=a.getCenter(new Vector3),c=t?t.clone():o.position.clone().sub(s.target);c.lengthSq()===0&&c.copy(TOP_DOWN);const u=c.clone().normalize(),h=Math.abs(u.dot(o.up))>.999?new Vector3(0,0,-1):o.up.clone(),d=new Vector3().crossVectors(h,u).normalize(),p=new Vector3().crossVectors(u,d).normalize(),f=Math.tan(MathUtils.degToRad(o.fov)/2),g=f*o.aspect;let _=0;const x=new Vector3;for(const E of[a.min.x,a.max.x])for(const b of[a.min.y,a.max.y])for(const v of[a.min.z,a.max.z]){x.set(E,b,v).sub(l);const M=x.dot(u);_=Math.max(_,M+Math.abs(x.dot(d))/g,M+Math.abs(x.dot(p))/f)}_*=n,c.setLength(MathUtils.clamp(_,s.minDistance,s.maxDistance)),s.target.copy(l),o.position.copy(l).add(c),s.update()}componentWillUnmount(){var t,n,s,o;(n=(t=this.props.actions).registerViewer)==null||n.call(t,null),cancelAnimationFrame(this.renderingID),(s=this.orbitControls)==null||s.dispose(),this.renderer.domElement.removeEventListener("mousedown",this.mouseDownEvent),this.renderer.domElement.removeEventListener("mouseup",this.mouseUpEvent),window.removeEventListener("mousemove",this.gizmoMoveEvent),window.removeEventListener("mouseup",this.gizmoUpEvent),this.gizmoDrag=null,(o=this.gizmo)==null||o.dispose(),this.gizmo=null,this.scene3D&&(disposeScene(this.scene3D),this.scene3D.remove(this.planData.plan),this.scene3D.remove(this.planData.grid)),this.scene3D=null,this.planData=null,this.camera=null,this.orbitControls=null,this.renderer.renderLists.dispose()}componentDidUpdate(t){const{width:n,height:s}=this.props;if(this.width=n,this.height=s,this.camera&&(this.camera.aspect=n/s,this.camera.updateProjectionMatrix()),this.planData&&t.showGrid!==this.props.showGrid&&(this.planData.grid.visible=this.props.showGrid),t.state.scene!==this.props.state.scene){const o=diff(t.state.scene,this.props.state.scene),a={areaActions:this.props.actions.areaActions,holesActions:this.props.actions.holesActions,itemsActions:this.props.actions.itemsActions,linesActions:this.props.actions.linesActions,projectActions:this.props.actions.projectActions};updateScene(this.planData,this.props.state.scene,t.state.scene,o.toJS(),a,this.props.catalog),this.invalidateShadows()}this.renderer.setSize(n,s)}render(){return React.createElement("div",{ref:this.canvasWrapperRef})}}const STYLE$1={color:SharedStyle.PRIMARY_COLOR.alt,fontWeight:300};function ContentTitle({children:i,style:e={},...t}){return jsxRuntimeExports.jsx("h1",{style:{...STYLE$1,...e},...t,children:i})}const STYLE={padding:"0 20px",overflowY:"auto"};function ContentContainer({children:i,width:e,height:t,style:n={}}){return jsxRuntimeExports.jsx("div",{style:{width:e,height:t,...STYLE,...n},onWheel:s=>s.stopPropagation(),children:i})}function FaCog(i){return GenIcon({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M487.4 315.7l-42.6-24.6c4.3-23.2 4.3-47 0-70.2l42.6-24.6c4.9-2.8 7.1-8.6 5.5-14-11.1-35.6-30-67.8-54.7-94.6-3.8-4.1-10-5.1-14.8-2.3L380.8 110c-17.9-15.4-38.5-27.3-60.8-35.1V25.8c0-5.6-3.9-10.5-9.4-11.7-36.7-8.2-74.3-7.8-109.2 0-5.5 1.2-9.4 6.1-9.4 11.7V75c-22.2 7.9-42.8 19.8-60.8 35.1L88.7 85.5c-4.9-2.8-11-1.9-14.8 2.3-24.7 26.7-43.6 58.9-54.7 94.6-1.7 5.4.6 11.2 5.5 14L67.3 221c-4.3 23.2-4.3 47 0 70.2l-42.6 24.6c-4.9 2.8-7.1 8.6-5.5 14 11.1 35.6 30 67.8 54.7 94.6 3.8 4.1 10 5.1 14.8 2.3l42.6-24.6c17.9 15.4 38.5 27.3 60.8 35.1v49.2c0 5.6 3.9 10.5 9.4 11.7 36.7 8.2 74.3 7.8 109.2 0 5.5-1.2 9.4-6.1 9.4-11.7v-49.2c22.2-7.9 42.8-19.8 60.8-35.1l42.6 24.6c4.9 2.8 11 1.9 14.8-2.3 24.7-26.7 43.6-58.9 54.7-94.6 1.5-5.5-.7-11.3-5.6-14.1zM256 336c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z"},child:[]}]})(i)}function FaMinus(i){return GenIcon({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"},child:[]}]})(i)}function FaPlusCircle(i){return GenIcon({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm144 276c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92h-92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z"},child:[]}]})(i)}function FaPlus(i){return GenIcon({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"},child:[]}]})(i)}function FaSortDown(i){return GenIcon({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M41 288h238c21.4 0 32.1 25.9 17 41L177 448c-9.4 9.4-24.6 9.4-33.9 0L24 329c-15.1-15.1-4.4-41 17-41z"},child:[]}]})(i)}function FaUnlink(i){return GenIcon({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M304.083 405.907c4.686 4.686 4.686 12.284 0 16.971l-44.674 44.674c-59.263 59.262-155.693 59.266-214.961 0-59.264-59.265-59.264-155.696 0-214.96l44.675-44.675c4.686-4.686 12.284-4.686 16.971 0l39.598 39.598c4.686 4.686 4.686 12.284 0 16.971l-44.675 44.674c-28.072 28.073-28.072 73.75 0 101.823 28.072 28.072 73.75 28.073 101.824 0l44.674-44.674c4.686-4.686 12.284-4.686 16.971 0l39.597 39.598zm-56.568-260.216c4.686 4.686 12.284 4.686 16.971 0l44.674-44.674c28.072-28.075 73.75-28.073 101.824 0 28.072 28.073 28.072 73.75 0 101.823l-44.675 44.674c-4.686 4.686-4.686 12.284 0 16.971l39.598 39.598c4.686 4.686 12.284 4.686 16.971 0l44.675-44.675c59.265-59.265 59.265-155.695 0-214.96-59.266-59.264-155.695-59.264-214.961 0l-44.674 44.674c-4.686 4.686-4.686 12.284 0 16.971l39.597 39.598zm234.828 359.28l22.627-22.627c9.373-9.373 9.373-24.569 0-33.941L63.598 7.029c-9.373-9.373-24.569-9.373-33.941 0L7.029 29.657c-9.373 9.373-9.373 24.569 0 33.941l441.373 441.373c9.373 9.372 24.569 9.372 33.941 0z"},child:[]}]})(i)}const STYLE_BOX$1={width:"14em",height:"14em",padding:"0.625em",background:"#f7f7f9",border:"1px solid #e1e1e8",cursor:"pointer",position:"relative",boxShadow:"0 1px 6px 0 rgba(0, 0, 0, 0.11), 0 1px 4px 0 rgba(0, 0, 0, 0.11)",borderRadius:"2px",transition:"all .15s ease-in-out",WebkitTransition:"all .15s ease-in-out",alignSelf:"center",justifySelf:"center"},STYLE_BOX_HOVER$1={...STYLE_BOX$1,background:SharedStyle.SECONDARY_COLOR.main},STYLE_TITLE={width:"100%",textAlign:"center",display:"block",marginBottom:".5em",textTransform:"capitalize"},STYLE_TITLE_HOVER={...STYLE_TITLE,color:SharedStyle.COLORS.white},STYLE_IMAGE_CONTAINER={width:"100%",height:"8em",position:"relative",overflow:"hidden",border:"solid 1px #e6e6e6",padding:0,margin:0,marginBottom:"5px"},STYLE_IMAGE={position:"absolute",background:"#222",width:"100%",height:"100%",backgroundSize:"contain",backgroundPosition:"50% 50%",backgroundColor:SharedStyle.COLORS.white,backgroundRepeat:"no-repeat",transition:"all .2s ease-in-out"},STYLE_IMAGE_HOVER={...STYLE_IMAGE,transform:"scale(1.2)"},STYLE_PLUS_HOVER={marginTop:"1.5em",color:SharedStyle.SECONDARY_COLOR.main,fontSize:"2em",opacity:"0.7",width:"100%"},STYLE_DESCRIPTION={display:"block",height:"2em",margin:"0 auto",fontSize:"0.75em",fontStyle:"italic",lineHeight:"1em",WebkitLineClamp:"2",WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"},STYLE_TAGS={listStyle:"none",margin:"0px",padding:"0px",fontSize:"11px",marginBottom:"3px"},STYLE_TAG={display:"inline-block",background:"#337ab7",color:SharedStyle.COLORS.white,padding:"1px 4px",marginRight:"3px",borderRadius:"3px"},CatalogItem=({element:i})=>{const[e,t]=React.useState(!1),{selectToolDrawingLine:n,selectToolDrawingItem:s,selectToolDrawingHole:o,pushLastSelectedCatalogElementToHistory:a}=useReactPlannerStore(),l=()=>{switch(i.prototype){case"lines":n(i.name);break;case"items":s(i.name);break;case"holes":o(i.name);break}a(i)};return jsxRuntimeExports.jsxs("div",{style:e?STYLE_BOX_HOVER$1:STYLE_BOX$1,onClick:l,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[jsxRuntimeExports.jsx("b",{style:e?STYLE_TITLE_HOVER:STYLE_TITLE,children:i.info.title}),jsxRuntimeExports.jsx("div",{style:STYLE_IMAGE_CONTAINER,children:jsxRuntimeExports.jsx("div",{style:{...e?STYLE_IMAGE_HOVER:STYLE_IMAGE,backgroundImage:"url("+i.info.image+")"},children:e?jsxRuntimeExports.jsx(FaPlusCircle,{style:STYLE_PLUS_HOVER}):null})}),jsxRuntimeExports.jsx("ul",{style:STYLE_TAGS,children:i.info.tag.map((c,u)=>jsxRuntimeExports.jsx("li",{style:STYLE_TAG,children:c},u))}),jsxRuntimeExports.jsx("div",{style:STYLE_DESCRIPTION,children:i.info.description})]})},breadcrumbStyle={margin:"1.5em",display:"flex"},breadcrumbTextStyle={fontSize:"20px",cursor:"pointer"},breadcrumbLastTextStyle={...breadcrumbTextStyle,fontWeight:"bolder",color:SharedStyle.SECONDARY_COLOR.main},breadcrumbTabStyle={fill:SharedStyle.COLORS.black,fontSize:"24px",marginLeft:"10px",marginRight:"10px"},CatalogBreadcrumb=({names:i})=>{let e=i.map((t,n)=>{let s=n===i.length-1;return jsxRuntimeExports.jsxs("div",{style:{display:"flex"},children:[jsxRuntimeExports.jsx("div",{style:s?breadcrumbLastTextStyle:breadcrumbTextStyle,onClick:t.action||null,children:t.name}),s?null:jsxRuntimeExports.jsx(MdArrowBack,{style:breadcrumbTabStyle})]},n)});return jsxRuntimeExports.jsx("div",{style:breadcrumbStyle,children:e})},STYLE_BOX={width:"14em",height:"14em",padding:"0.625em",background:"#f7f7f9",border:"1px solid #e1e1e8",margin:"0.3em",cursor:"pointer",position:"relative",boxShadow:"0 1px 6px 0 rgba(0, 0, 0, 0.11), 0 1px 4px 0 rgba(0, 0, 0, 0.11)",borderRadius:"2px",transition:"all .2s ease-in-out",WebkitTransition:"all .2s ease-in-out"},STYLE_BOX_HOVER={...STYLE_BOX,background:SharedStyle.SECONDARY_COLOR.main},STYLE_BACK={position:"absolute",color:SharedStyle.COLORS.black,fontSize:"5em",width:"100%"},STYLE_BACK_HOVER={...STYLE_BACK,color:SharedStyle.SECONDARY_COLOR.main},CONTAINER_DIV={background:SharedStyle.COLORS.white,marginBottom:"5px",border:"solid 1px #e6e6e6",width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},CatalogTurnBackPageItem=({page:i})=>{const[e,t]=React.useState(!1),{goBackToCatalogPage:n}=useReactPlannerStore(),s=o=>{n(o)};return jsxRuntimeExports.jsx("div",{style:e?STYLE_BOX_HOVER:STYLE_BOX,onClick:()=>s(i.name),onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:jsxRuntimeExports.jsx("div",{style:CONTAINER_DIV,children:jsxRuntimeExports.jsx(MdNavigateBefore,{style:e?STYLE_BACK_HOVER:STYLE_BACK})})})},containerStyle={position:"fixed",width:"calc( 100% - 51px)",height:"calc( 100% - 20px)",backgroundColor:"#FFF",padding:"1em",left:50,overflowY:"auto",overflowX:"hidden",zIndex:10},itemsStyle={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(14em, 1fr))",gridGap:"10px",marginTop:"1em"},searchContainer={width:"100%",height:"3em",padding:"0.625em",background:"#f7f7f9",border:"1px solid #e1e1e8",cursor:"pointer",position:"relative",boxShadow:"0 1px 6px 0 rgba(0, 0, 0, 0.11), 0 1px 4px 0 rgba(0, 0, 0, 0.11)",borderRadius:"2px",transition:"all .2s ease-in-out",WebkitTransition:"all .2s ease-in-out",marginBottom:"1em"},searchText={width:"8em",display:"inline-block"},searchInput={width:"calc( 100% - 10em )",height:"2em",margin:"0",padding:"0 1em",border:"1px solid #EEE"},historyContainer={...searchContainer,padding:"0.2em 0.625em"},historyElementStyle={width:"auto",height:"2em",lineHeight:"2em",textAlign:"center",borderRadius:"1em",display:"inline-block",cursor:"pointer",backgroundColor:SharedStyle.PRIMARY_COLOR.alt,color:SharedStyle.PRIMARY_COLOR.text_main,textTransform:"capitalize",margin:"0.25em",padding:"0 1em"},CatalogList=({width:i,height:e,style:t,catalog:n})=>{const{planner:s,goBackToCatalogPage:o,selectToolDrawingHole:a,selectToolDrawingItem:l,selectToolDrawingLine:c,pushLastSelectedCatalogElementToHistory:u}=useReactPlannerStore();let h=s.catalog.page;const d=n.getCategory(h);let p=d.elements.filter(R=>R.info.visibility?R.info.visibility.catalog:!0);const[f,g]=React.useState(""),[_,x]=React.useState([]);let y=null;if(h!=="root"){let R=[];s.catalog.path.forEach(A=>{R.push({name:n.getCategory(A).label,action:()=>o(A)})}),R.push({name:d.label,action:""}),y=jsxRuntimeExports.jsx(CatalogBreadcrumb,{names:R})}let E=s.catalog.path.size,b=E>0?jsxRuntimeExports.jsx(CatalogTurnBackPageItem,{page:n.categories[s.catalog.path.get(E-1)]},E):null,v=s.get("selectedElementsHistory"),M=v.map((R,A)=>jsxRuntimeExports.jsx("div",{style:historyElementStyle,title:R.name,onClick:()=>w(R),children:R.name},A));const T=R=>{let A=[];for(let P=0;P<R.length;P++){let B=R[P];A=A.concat(B.elements),B.categories.length&&(A=A.concat(T(B.categories)))}return A},I=R=>{let A=p.concat(T(d.categories)),P=[];if(R!=""){let B=new RegExp(R,"i");for(let k=0;k<A.length;k++)B.test(A[k].info.title)&&P.push(A[k])}g(R),x(P)},w=R=>{switch(R.prototype){case"lines":c(R.name);break;case"items":l(R.name);break;case"holes":a(R.name);break}u(R)};return jsxRuntimeExports.jsxs(ContentContainer,{width:i,height:e,style:{...containerStyle,...t},children:[jsxRuntimeExports.jsx(ContentTitle,{children:"Catalog"}),y,jsxRuntimeExports.jsxs("div",{style:searchContainer,children:[jsxRuntimeExports.jsx("span",{style:searchText,children:"Search Element"}),jsxRuntimeExports.jsx("input",{type:"text",style:searchInput,onChange:R=>{I(R.target.value)}})]}),v.size?jsxRuntimeExports.jsxs("div",{style:historyContainer,children:[jsxRuntimeExports.jsx("span",{children:"Last Selected"}),M]}):null,jsxRuntimeExports.jsx("div",{style:itemsStyle,children:f===""?[b,p.map(R=>jsxRuntimeExports.jsx(CatalogItem,{element:R},R.name))]:_.map(R=>jsxRuntimeExports.jsx(CatalogItem,{element:R},R.name))})]})},V_2D_MODES={MODE_IDLE:MODE_IDLE$1,MODE_2D_ZOOM_IN,MODE_2D_ZOOM_OUT,MODE_2D_PAN,MODE_WAITING_DRAWING_ROOM,MODE_WAITING_DRAWING_LINE,MODE_WAITING_DRAWING_SURFACE,MODE_DRAGGING_LINE,MODE_DRAGGING_VERTEX,MODE_DRAGGING_ITEM,MODE_DRAWING_SURFACE,MODE_DRAWING_LINE,MODE_DRAWING_ROOM,MODE_DRAWING_HOLE,MODE_DRAWING_ITEM,MODE_DRAGGING_HOLE,MODE_ROTATING_ITEM,MODE_RESIZING_ITEM};function Content({width:i,height:e,catalog:t}){const n=useReactPlannerStore(),{planner:s}=n,{mode:o}=s;return o===MODE_3D_VIEW?jsxRuntimeExports.jsx(Scene3DViewer,{width:i,height:e,state:s,catalog:t,showGrid:n.showGrid,actions:{registerViewer:n.setViewer3D,areaActions:{selectArea:n.selectArea},holesActions:{selectHole:n.selectHole,selectToolDrawingHole:n.selectToolDrawingHole,updateDrawingHole:n.updateDrawingHole,endDrawingHole:n.endDrawingHole,beginDraggingHole:n.beginDraggingHole,updateDraggingHole:n.updateDraggingHole,endDraggingHole:n.endDraggingHole},itemsActions:{selectItem:n.selectItem,selectToolDrawingItem:n.selectToolDrawingItem,updateDrawingItem:n.updateDrawingItem,endDrawingItem:n.endDrawingItem,beginDraggingItem:n.beginDraggingItem,updateDraggingItem:n.updateDraggingItem,endDraggingItem:n.endDraggingItem,beginRotatingItem:n.beginRotatingItem,updateRotatingItem:n.updateRotatingItem,endRotatingItem:n.endRotatingItem,setItemAttributes:n.setItemAttributes},linesActions:{selectLine:n.selectLine,selectToolDrawingLine:n.selectToolDrawingLine,beginDrawingLine:n.beginDrawingLine,updateDrawingLine:n.updateDrawingLine,endDrawingLine:n.endDrawingLine,beginDraggingLine:n.beginDraggingLine,updateDraggingLine:n.updateDraggingLine,endDraggingLine:n.endDraggingLine},projectActions:{loadProject:n.loadProject,newProject:n.newProject,openCatalog:n.openCatalog,changeCatalogPage:n.changeCatalogPage,goBackToCatalogPage:n.goBackToCatalogPage,selectToolEdit:n.selectToolEdit,unselectAll:n.unselectAll,setProperties:n.setProperties,setItemsAttributes:n.setItemsAttributes,setLinesAttributes:n.setLinesAttributes,setHolesAttributes:n.setHolesAttributes,remove:n.remove,undo:n.undo,rollback:n.rollback,openProjectConfigurator:n.openProjectConfigurator,initCatalog:n.initCatalog,updateMouseCoord:n.updateMouseCoord,updateZoomScale:n.updateZoomScale,toggleSnap:n.toggleSnap,copyProperties:n.copyProperties,pasteProperties:n.pasteProperties,pushLastSelectedCatalogElementToHistory:n.pushLastSelectedCatalogElementToHistory,setAlterateState:n.setAlterateState,setMode:n.setMode,addHorizontalGuide:n.addHorizontalGuide,addVerticalGuide:n.addVerticalGuide,removeHorizontalGuide:n.removeHorizontalGuide,removeVerticalGuide:n.removeVerticalGuide}}}):o===MODE_3D_FIRST_PERSON?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{}):o===MODE_VIEWING_CATALOG?jsxRuntimeExports.jsx(CatalogList,{width:i,height:e,catalog:t}):V_2D_MODES[o]?jsxRuntimeExports.jsx(Viewer2D,{width:i,height:e,catalog:t}):o===MODE_CONFIGURING_PROJECT?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{}):null}const Footerbar=()=>null,Panel=({children:i,name:e,subtitle:t,...n})=>{const[s,o]=React.useState(n.opened||!0);return jsxRuntimeExports.jsxs("div",{className:"select-none",children:[jsxRuntimeExports.jsx("div",{className:"panel-property_header flex px-4 pt-2.5 pb-2.5 items-center gap-1 cursor-pointer",children:jsxRuntimeExports.jsxs("div",{className:"min-w-0 flex-1 leading-tight",children:[jsxRuntimeExports.jsx("div",{className:"text-[11px] text-gray-500",children:e}),t&&jsxRuntimeExports.jsx("div",{className:"text-sm font-semibold truncate",children:t})]})}),jsxRuntimeExports.jsx("div",{className:cn("floor_planner-sidebar_panel max-h-[540px] overflow-auto",s?"block":"hidden"),children:i})]})};function FaChevronLeft(i){return GenIcon({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256 246.6 86.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z"},child:[]}]})(i)}function FaChevronRight(i){return GenIcon({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"},child:[]}]})(i)}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 FaMagnifyingGlass(i){return GenIcon({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z"},child:[]}]})(i)}function FormLabel({children:i,style:e,className:t,...n}){return jsxRuntimeExports.jsx("label",{className:cn("mb-1 panel-property_label block",t),style:e,...n,children:i})}const BASE_STYLE={fontSize:"13px",WebkitAppearance:"none"};function FormSelect({children:i,style:e,...t}){return jsxRuntimeExports.jsx("select",{className:"w-full cursor-pointer block px-2 outline-none rounded h-[35px] panel-property_select",style:{...BASE_STYLE,...e},...t,children:i})}const FormTextInput=({style:i,...e})=>jsxRuntimeExports.jsx("input",{className:"block w-full px-2 text-sm leading-5 panel-property_input rounded outline-none h-[35px]",style:{...i},type:"text",...e}),SearchInput=({term:i="",placeholder:e="Search",noSpacing:t=!1,onClick:n=()=>!1,isStatic:s=!1,hasDropDown:o=!1,onSearch:a,className:l,value:c,inputClassName:u})=>{const[h,d]=React.useState("");return React.useEffect(()=>{c!==void 0&&c!==h&&d(c??"")},[c]),jsxRuntimeExports.jsxs("div",{className:cn(`relative w-full ${t?"":"mt-2"}`,l),onClick:n??(()=>!1),children:[s?jsxRuntimeExports.jsx("div",{className:"panel-property_input w-full rounded px-3 py-2 text-sm font-normal cursor-pointer",children:i}):jsxRuntimeExports.jsx("input",{className:cn("panel-property_input w-full rounded py-2 pl-3 pr-10 text-[14px] outline-none focus:border-[color:var(--dark-blue,#1ca6fc)]",u),type:"text",placeholder:e,onChange:p=>{a(p.target.value,p),d(p.target.value)},value:h,onClick:n??(()=>!1)}),!s&&!o&&jsxRuntimeExports.jsx(FaMagnifyingGlass,{className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-[color:var(--properties-color,#2F3033)] opacity-70",size:18}),n!==null&&o&&jsxRuntimeExports.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2",style:{zIndex:1},children:jsxRuntimeExports.jsx(FaSortDown,{className:"-mb-1"})})]})},PAINT_FAMILIES={Spectrum:{hues:[6,26,44,62,96,150,188,212,244,316],saturation:52},"Earth tones":{hues:[10,18,25,32,38,45,58,74,92,128],saturation:34},"Cool tones":{hues:[162,178,192,202,212,222,234,250,272,300],saturation:38},Neutrals:{hues:[28,34,42,58,96,168,204,224,262,320],saturation:7}},PAINT_LIGHTNESS=[24,34,44,54,64,73,81,89,95],chromaFor=(i,e)=>{const t=Math.min(1,Math.abs(e-55)/45);return Math.max(3,i*(1-.5*t*t))},perceptualLightness=(i,e)=>{const t=-6*Math.cos((i-60)*Math.PI/180),n=Math.sin(Math.PI*e/100);return Math.max(0,Math.min(100,e+t*n))},hslToHex=(i,e,t)=>{const n=t/100,s=(1-Math.abs(2*n-1))*(e/100),o=s*(1-Math.abs(i/60%2-1)),a=n-s/2,[l,c,u]=i<60?[s,o,0]:i<120?[o,s,0]:i<180?[0,s,o]:i<240?[0,o,s]:i<300?[o,0,s]:[s,0,o];return`#${[l,c,u].map(h=>Math.round((h+a)*255).toString(16).padStart(2,"0")).join("")}`.toUpperCase()},buildSwatch=(i,e,t)=>hslToHex((i%360+360)%360,chromaFor(e,t),perceptualLightness(i,t)),PaintPalette=({value:i,onChange:e})=>{const[t,n]=React.useState("Spectrum"),[s,o]=React.useState(i.toUpperCase()),[a,l]=React.useState(0);React.useEffect(()=>{o(i.toUpperCase())},[i]);const c=/^#[0-9A-F]{6}$/i.test(s),u=i.toUpperCase(),h=_=>{const x=_.startsWith("#")?_:`#${_}`;o(x.toUpperCase()),/^#[0-9A-F]{6}$/i.test(x)&&e(x.toUpperCase())},d=PAINT_FAMILIES[t],p=d.saturation>=12,f=p?a:0,g=d.hues.map(_=>PAINT_LIGHTNESS.map(x=>buildSwatch(_+f,d.saturation,x)));return jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntimeExports.jsxs("div",{className:"relative",children:[jsxRuntimeExports.jsx("input",{type:"text",value:s,onChange:_=>h(_.target.value),placeholder:"#82695F",spellCheck:!1,maxLength:7,"aria-label":"Color hex value","aria-invalid":!c,className:"panel-property_input w-full rounded py-2 pl-3 pr-12 text-[14px] uppercase outline-none focus:border-[color:var(--dark-blue,#1ca6fc)]",style:c?void 0:{borderColor:"#EF4444"}}),jsxRuntimeExports.jsx("label",{className:"absolute right-2 top-1/2 h-7 w-7 -translate-y-1/2 cursor-pointer overflow-hidden rounded border border-[color:var(--properties-input-border,#E5E7EB)] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.6)]",style:{background:c?s:"transparent"},title:"Pick a color",children:jsxRuntimeExports.jsx("input",{type:"color",value:c?s:"#FFFFFF",onChange:_=>h(_.target.value),"aria-label":"Pick a color",className:"h-full w-full cursor-pointer opacity-0"})})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Palette"}),jsxRuntimeExports.jsx(FormSelect,{value:t,onChange:_=>n(_.target.value),children:Object.keys(PAINT_FAMILIES).map(_=>jsxRuntimeExports.jsx("option",{value:_,children:_},_))})]}),p&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Hue"}),jsxRuntimeExports.jsxs("div",{className:"relative h-8 overflow-hidden rounded border border-[color:var(--properties-input-border,#E5E7EB)]",children:[jsxRuntimeExports.jsx("div",{className:"absolute inset-0",style:{background:"linear-gradient(90deg, #ef4444, #f59e0b, #eab308, #22c55e, #06b6d4, #3b82f6, #8b5cf6, #ec4899, #ef4444)"}}),jsxRuntimeExports.jsx("input",{type:"range",min:"0",max:"359",value:a,onChange:_=>l(Number(_.target.value)),"aria-label":"Adjust palette hue",className:"absolute inset-0 z-10 h-full w-full cursor-pointer opacity-0"}),jsxRuntimeExports.jsx("div",{className:"pointer-events-none absolute top-1/2 z-20 h-7 w-7 -translate-y-1/2 rounded border-[3px] border-white shadow-[0_0_0_1px_rgba(0,0,0,0.25)]",style:{left:`calc(${a/359*100}% - 14px)`}})]})]}),jsxRuntimeExports.jsx("div",{className:"grid overflow-hidden rounded border border-[color:var(--properties-input-border,#E5E7EB)]",style:{gridTemplateColumns:`repeat(${PAINT_LIGHTNESS.length}, minmax(0, 1fr))`},children:g.flat().map((_,x)=>{const y=_===u;return jsxRuntimeExports.jsx("button",{type:"button","aria-label":`Select ${_}`,"aria-pressed":y,title:_,onClick:()=>e(_),className:cn("relative aspect-square focus:z-10 focus:outline-none",y?"z-10":"hover:z-10 hover:shadow-[inset_0_0_0_2px_rgba(255,255,255,0.75),inset_0_0_0_3px_rgba(0,0,0,0.2)]"),style:{background:_,boxShadow:y?"inset 0 0 0 2px #fff, inset 0 0 0 4px var(--dark-blue, #1ca6fc)":void 0}},`${_}-${x}`)})})]})},BackHeader$1=({title:i,subtitle:e,onBack:t})=>jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[jsxRuntimeExports.jsx("button",{type:"button",onClick:t,className:"w-7 h-7 flex items-center justify-center rounded hover:bg-[color:var(--panel-property-background-hover,#E5E7EB)] cursor-pointer","aria-label":"Back",children:jsxRuntimeExports.jsx(FaChevronLeft,{size:12})}),jsxRuntimeExports.jsxs("div",{className:"min-w-0",children:[jsxRuntimeExports.jsx("div",{className:"text-[11px] text-gray-500 leading-tight",children:i}),e&&jsxRuntimeExports.jsx("div",{className:"text-[14px] font-semibold truncate leading-tight",children:e})]})]}),RowButton$1=({swatchColor:i,textureUri:e,icon:t,label:n,value:s,onClick:o})=>jsxRuntimeExports.jsxs("button",{type:"button",onClick:o,className:"w-full flex items-center gap-3 px-3 py-2 rounded bg-[color:var(--panel-property-background,#F3F4F6)] hover:bg-[color:var(--panel-property-background-hover,#E5E7EB)] text-left",children:[i!==void 0&&jsxRuntimeExports.jsx("span",{className:"w-7 h-7 rounded flex-shrink-0 border border-gray-200",style:{background:i,backgroundImage:e?`url(${e})`:void 0,backgroundSize:"cover",backgroundPosition:"center"}}),t&&jsxRuntimeExports.jsx("span",{className:"w-8 h-8 flex items-center justify-center flex-shrink-0",children:t}),jsxRuntimeExports.jsxs("span",{className:"flex-1 min-w-0",children:[n&&jsxRuntimeExports.jsx("span",{className:"block text-[11px] text-gray-500 leading-tight",children:n}),s&&jsxRuntimeExports.jsx("span",{className:"block text-[14px] font-medium truncate leading-tight",children:s})]}),jsxRuntimeExports.jsx(FaChevronRight,{size:12,className:"text-gray-500 flex-shrink-0"})]}),MeasureStepper=({value:i,onChange:e,step:t=1,min:n=0,max:s=1e4,unit:o="cm"})=>{const a=l=>Math.max(n,Math.min(s,l));return jsxRuntimeExports.jsxs("div",{className:"panel-property_input flex items-stretch h-[35px] rounded overflow-hidden text-sm",children:[jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>e(a(i-t)),className:"w-8 flex items-center justify-center text-[color:var(--dark-blue,#1ca6fc)] hover:bg-[color:var(--panel-property-background-hover,#E5E7EB)] transition-colors","aria-label":"Decrease",children:jsxRuntimeExports.jsx(FaMinus,{size:11})}),jsxRuntimeExports.jsxs("div",{className:"flex-1 flex items-center justify-center gap-1 min-w-0",children:[jsxRuntimeExports.jsx("input",{type:"number",value:Number.isFinite(i)?i:0,onChange:l=>{const c=Number(l.target.value);Number.isFinite(c)&&e(a(c))},className:"w-full text-center outline-none bg-transparent leading-none [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"}),o&&jsxRuntimeExports.jsx("span",{className:"text-[11px] opacity-60 pr-1",children:o})]}),jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>e(a(i+t)),className:"w-8 flex items-center justify-center text-[color:var(--dark-blue,#1ca6fc)] hover:bg-[color:var(--panel-property-background-hover,#E5E7EB)] transition-colors","aria-label":"Increase",children:jsxRuntimeExports.jsx(FaPlus,{size:11})})]})},ActionRow=({actions:i})=>jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:i.map(e=>jsxRuntimeExports.jsx("button",{type:"button",title:e.label,"aria-label":e.label,onClick:e.onClick,className:cn("w-10 h-10 rounded-full flex items-center justify-center text-[17px] border border-[color:var(--panel-property-background-hover,#E5E7EB)]","hover:bg-[color:var(--panel-property-background-hover,#E5E7EB)] transition-colors cursor-pointer",e.danger&&"text-red-500 hover:text-red-500"),children:e.icon},e.key))}),MaterialPicker=({textures:i,value:e,onChange:t,label:n})=>{const[s,o]=React.useState(""),[a,l]=React.useState("all"),c=Object.entries(i),u=i[e],h=[];for(const[,f]of c)for(const g of f.tag??[])h.includes(g)||h.push(g);const d=s.trim().toLowerCase(),p=c.filter(([f,g])=>{var y;const _=a==="all"||((y=g.tag)==null?void 0:y.includes(a)),x=!d||g.name.toLowerCase().includes(d)||f.toLowerCase().includes(d);return _&&x});return c.length===0?null:jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4",children:[n&&jsxRuntimeExports.jsx(FormLabel,{children:n}),jsxRuntimeExports.jsx(SearchInput,{noSpacing:!0,value:s,placeholder:"Search",onSearch:f=>o(f)}),h.length>0&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Category"}),jsxRuntimeExports.jsxs(FormSelect,{value:a,onChange:f=>l(f.target.value),children:[jsxRuntimeExports.jsx("option",{value:"all",children:"All materials"}),h.map(f=>jsxRuntimeExports.jsx("option",{value:f,children:f},f))]})]}),jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>t("none"),className:"rounded overflow-hidden text-left aspect-square border transition-colors flex flex-col",style:{borderColor:e==="none"?"var(--dark-blue, #1ca6fc)":"var(--properties-input-border, #E5E7EB)",borderWidth:2},children:jsxRuntimeExports.jsx("div",{className:"flex-1 flex items-center justify-center text-[11px] text-[color:var(--properties-color,#2F3033)] opacity-70 bg-[color:var(--panel-property-background,#F3F4F6)]",children:"None"})}),p.map(([f,g])=>jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>t(f),className:"rounded overflow-hidden text-left aspect-square border transition-colors flex flex-col",style:{borderColor:f===e?"var(--dark-blue, #1ca6fc)":"var(--properties-input-border, #E5E7EB)",borderWidth:2},title:g.name,children:jsxRuntimeExports.jsx("div",{className:"flex-1",style:{backgroundImage:`url(${g.uri})`,backgroundSize:"cover",backgroundPosition:"center"}})},f))]}),p.length===0&&jsxRuntimeExports.jsx("div",{className:"text-center text-[13px] text-[color:var(--properties-color,#2F3033)] opacity-70 py-6",children:"No materials match this search."}),u&&jsxRuntimeExports.jsx("div",{className:"text-[12px] text-[color:var(--properties-color,#2F3033)] opacity-70",children:u.name})]})},FinishPicker=({color:i,onColorChange:e,textures:t,texture:n,onTextureChange:s,patterns:o})=>{const[a,l]=React.useState("colors");return jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntimeExports.jsx("div",{className:"grid grid-cols-2 overflow-hidden rounded-lg border border-[color:var(--properties-input-border,#E5E7EB)] bg-[color:var(--panel-property-background,#F3F4F6)]",children:[["colors","Colors"],["materials","Materials"]].map(([c,u])=>jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>l(c),className:"p-2 text-[14px] font-semibold transition-colors",style:{background:a===c?"var(--dark-blue, #1ca6fc)":"var(--panel-property-background, #F3F4F6)",color:a===c?"white":"var(--properties-color)"},children:u},c))}),a==="colors"&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(PaintPalette,{value:i,onChange:e}),o]}),a==="materials"&&jsxRuntimeExports.jsx(MaterialPicker,{textures:t,value:n,onChange:s})]})},ElementPreview=({imageUri:i,alt:e})=>jsxRuntimeExports.jsx("div",{className:"w-full aspect-[4/3] bg-[color:var(--panel-property-background,#F3F4F6)] rounded flex items-center justify-center overflow-hidden",children:i?jsxRuntimeExports.jsx("img",{src:i,alt:e,loading:"lazy",decoding:"async",className:"max-w-full max-h-full object-contain"}):jsxRuntimeExports.jsx("span",{className:"text-[11px] text-gray-500",children:"No preview"})});function darkenHex(i,e=.55){const t=/^#([0-9a-f]{6})$/i.exec(i);if(!t)return i;const n=parseInt(t[1],16),s=Math.max(0,Math.min(255,Math.round((n>>16&255)*e))),o=Math.max(0,Math.min(255,Math.round((n>>8&255)*e))),a=Math.max(0,Math.min(255,Math.round((n&255)*e)));return`#${(s<<16|o<<8|a).toString(16).padStart(6,"0")}`}const AREA_PATTERNS=[{key:"diagonal-stripes",name:"Diagonal stripes",size:10,rotation:45,marks:i=>`<line x1="0" y1="0" x2="0" y2="10" stroke="${i}" stroke-width="2"/>`},{key:"vertical-lines",name:"Vertical lines",size:12,marks:i=>`<line x1="6" y1="0" x2="6" y2="12" stroke="${i}" stroke-width="2"/>`},{key:"horizontal-lines",name:"Horizontal lines",size:12,marks:i=>`<line x1="0" y1="6" x2="12" y2="6" stroke="${i}" stroke-width="2"/>`},{key:"dashed",name:"Dashed",size:12,marks:i=>`<line x1="0" y1="6" x2="12" y2="6" stroke="${i}" stroke-width="2" stroke-dasharray="5 3"/>`},{key:"grid",name:"Grid",size:16,marks:i=>`<path d="M 16 0 L 0 0 L 0 16" stroke="${i}" stroke-width="1.5" fill="none"/>`},{key:"diagonal-grid",name:"Diagonal grid",size:12,rotation:45,marks:i=>`<path d="M 12 0 L 0 0 L 0 12" stroke="${i}" stroke-width="1.5" fill="none"/>`},{key:"thick-stripes",name:"Thick stripes",size:14,marks:i=>`<rect x="0" y="0" width="4" height="14" fill="${i}"/><rect x="8" y="0" width="2" height="14" fill="${i}"/>`},{key:"dots-small",name:"Small dots",size:8,marks:i=>`<circle cx="4" cy="4" r="1.1" fill="${i}"/>`},{key:"dots-large",name:"Large dots",size:14,marks:i=>`<circle cx="7" cy="7" r="2.2" fill="${i}"/>`},{key:"chevrons",name:"Chevrons",size:12,marks:i=>`<path d="M 1 3 L 6 8 L 11 3" stroke="${i}" stroke-width="1.5" fill="none"/>`},{key:"bricks",name:"Bricks",size:24,marks:i=>`<g stroke="${i}" stroke-width="1" fill="none"><rect x="0" y="0" width="24" height="12"/><line x1="12" y1="12" x2="12" y2="24"/><line x1="0" y1="12" x2="24" y2="12"/><line x1="0" y1="24" x2="24" y2="24"/></g>`},{key:"cross-hatch",name:"Cross-hatch",size:8,marks:i=>`<g stroke="${i}" stroke-width="0.8"><line x1="-1" y1="-1" x2="9" y2="9"/><line x1="9" y1="-1" x2="-1" y2="9"/></g>`}],PATTERN_BY_KEY=new Map(AREA_PATTERNS.map(i=>[i.key,i]));function getAreaPattern(i){if(!(!i||i==="none"))return PATTERN_BY_KEY.get(i)}function patternTransform(i){return i.rotation?`rotate(${i.rotation})`:void 0}function PatternMarks({pattern:i,color:e}){return jsxRuntimeExports.jsx("g",{dangerouslySetInnerHTML:{__html:i.marks(e)}})}function tileSide(i){return i.rotation?i.size*Math.SQRT2:i.size}function patternTileDataURI(i,e,t){const n=Math.round(tileSide(i)*1e4)/1e4,s=Math.round(n*Math.max(2,Math.ceil(160/n))),o=patternTransform(i),a=`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${s}" viewBox="0 0 ${n} ${n}"><defs><pattern id="p" patternUnits="userSpaceOnUse" width="${i.size}" height="${i.size}"`+(o?` patternTransform="${o}"`:"")+`>${i.marks(t)}</pattern></defs><rect width="${n}" height="${n}" fill="${e}"/><rect width="${n}" height="${n}" fill="url(#p)"/></svg>`;return{uri:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(a)}`,tileSize:n}}const NEUTRAL_PREVIEW_FILL="#FFDFBF",UNSELECTED_SWATCH="#E5E7EB",readVertices=(i,e)=>i.vertices.toArray().map(t=>{const{x:n,y:s}=e.vertices.get(t);return{x:n,y:s}}),computeAreaSize=(i,e)=>{const t=readVertices(i,e).map(s=>[s.x,s.y]);let n=areapolygon(t);return i.holes.forEach(s=>{const a=e.areas.get(s).vertices.toArray().map(l=>{const{x:c,y:u}=e.vertices.get(l);return[c,u]});n-=areapolygon(a)}),n},AreaPreview=({element:i,layer:e,color:t,label:n,pattern:s})=>{const o=readVertices(i,e);if(o.length===0)return null;const a=o.map(v=>v.x),l=o.map(v=>v.y),c=Math.min(...a),u=Math.max(...a),h=Math.min(...l),d=Math.max(...l),p=Math.max(u-c,1),f=Math.max(d-h,1),g=Math.max(p,f)*.1,_=o.map((v,M)=>`${M===0?"M":"L"}${v.x} ${v.y}`).join(" ")+" Z",x=[];i.holes.forEach(v=>{const T=e.areas.get(v).vertices.toArray().map(I=>{const{x:w,y:R}=e.vertices.get(I);return{x:w,y:R}});x.push(T.map((I,w)=>`${w===0?"M":"L"}${I.x} ${I.y}`).join(" ")+" Z")});const y=`${c-g} ${-(d+g)} ${p+g*2} ${f+g*2}`,E=t||NEUTRAL_PREVIEW_FILL,b=`preview-pattern-${i.id}`;return jsxRuntimeExports.jsx("div",{className:"w-full aspect-[16/9] bg-[color:var(--panel-property-background,#F3F4F6)] rounded flex items-center justify-center overflow-hidden relative",children:jsxRuntimeExports.jsxs("svg",{viewBox:y,className:"w-full h-full",preserveAspectRatio:"xMidYMid meet",children:[s&&jsxRuntimeExports.jsx("defs",{children:jsxRuntimeExports.jsx("pattern",{id:b,patternUnits:"userSpaceOnUse",width:s.size,height:s.size,patternTransform:patternTransform(s),children:jsxRuntimeExports.jsx(PatternMarks,{pattern:s,color:darkenHex(E)})})}),jsxRuntimeExports.jsxs("g",{transform:"scale(1, -1)",children:[jsxRuntimeExports.jsx("path",{d:[_,...x].join(" "),fill:E,fillRule:"evenodd"}),s&&jsxRuntimeExports.jsx("path",{d:[_,...x].join(" "),fill:`url(#${b})`,fillRule:"evenodd"})]})]})})},PatternSwatch=({pattern:i,color:e,size:t=48,className:n,rounded:s=!0})=>{const o=`swatch-pattern-${i.key}-${e.replace("#","")}`,a=darkenHex(e);return jsxRuntimeExports.jsxs("svg",{width:t,height:t,viewBox:`0 0 ${t} ${t}`,className:n,style:{display:"block",borderRadius:s?4:0},children:[jsxRuntimeExports.jsx("defs",{children:jsxRuntimeExports.jsx("pattern",{id:o,patternUnits:"userSpaceOnUse",width:i.size,height:i.size,patternTransform:patternTransform(i),children:jsxRuntimeExports.jsx(PatternMarks,{pattern:i,color:a})})}),jsxRuntimeExports.jsx("rect",{width:t,height:t,fill:e}),jsxRuntimeExports.jsx("rect",{width:t,height:t,fill:`url(#${o})`})]})},RowButton=({swatchColor:i,textureUri:e,patternPreview:t,icon:n,label:s,value:o,onClick:a})=>jsxRuntimeExports.jsxs("button",{type:"button",onClick:a,className:"w-full flex items-center gap-3 px-3 py-2 rounded bg-[color:var(--panel-property-background,#F3F4F6)] hover:bg-[color:var(--panel-property-background-hover,#E5E7EB)] text-left",children:[t&&i&&jsxRuntimeExports.jsx("span",{className:"w-7 h-7 rounded flex-shrink-0 border border-gray-200 overflow-hidden",children:jsxRuntimeExports.jsx(PatternSwatch,{pattern:t,color:i,size:28,rounded:!1})}),!t&&i!==void 0&&jsxRuntimeExports.jsx("span",{className:"w-7 h-7 rounded flex-shrink-0 border border-gray-200 bg-center bg-cover",style:{background:i||UNSELECTED_SWATCH,backgroundImage:e?`url(${e})`:void 0,backgroundSize:"cover"}}),n&&jsxRuntimeExports.jsx("span",{className:"w-8 h-8 flex items-center justify-center flex-shrink-0",children:n}),jsxRuntimeExports.jsxs("span",{className:"flex-1 min-w-0",children:[s&&jsxRuntimeExports.jsx("span",{className:"block text-[11px] text-gray-500 leading-tight",children:s}),o&&jsxRuntimeExports.jsx("span",{className:"block text-[14px] font-medium truncate leading-tight",children:o})]}),jsxRuntimeExports.jsx(FaChevronRight,{size:12,className:"text-gray-500 flex-shrink-0"})]}),BackHeader=({title:i,subtitle:e,onBack:t})=>jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[jsxRuntimeExports.jsx("button",{type:"button",onClick:t,className:"w-7 h-7 flex items-center justify-center rounded hover:bg-[color:var(--panel-property-background-hover,#E5E7EB)] cursor-pointer","aria-label":"Back",children:jsxRuntimeExports.jsx(FaChevronLeft,{size:12})}),jsxRuntimeExports.jsxs("div",{className:"min-w-0",children:[jsxRuntimeExports.jsx("div",{className:"text-[11px] text-gray-500 leading-tight",children:i}),e&&jsxRuntimeExports.jsx("div",{className:"text-[14px] font-semibold truncate leading-tight",children:e})]})]}),AreaAttributesEditor=({element:i,layer:e,catalog:t})=>{const{setProperties:n}=useReactPlannerStore(),[s,o]=React.useState("main"),a=i.properties.get("roomCategory")||"",l=i.properties.get("roomType")||"",c=i.properties.get("customName")||"",u=i.properties.get("showName")??!0,h=i.properties.get("showSurfaceArea")??!1,d=i.properties.get("patternColor")||"#FFFFFF",p=i.properties.get("texture")||"none",f=i.properties.get("pattern")||"none",g=getCategory(a),_=getRoomType(a,l),x=t.getElement(i.type).textures||{},y=x[p],E=getAreaPattern(f),[b,v]=React.useState((g==null?void 0:g.value)||""),M=getCategory(b),T=c||(_==null?void 0:_.label)||"",I=A=>{n(Map$1(A))},w=A=>{if(!M)return;const P=M.types.find(B=>B.value===A);P&&I({roomCategory:M.value,roomType:P.value,patternColor:P.color})};if(s==="roomtype")return jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-3",children:[jsxRuntimeExports.jsx(BackHeader,{title:"Choose Roomtype",subtitle:(_==null?void 0:_.label)||"Unknown",onBack:()=>o("main")}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Category"}),jsxRuntimeExports.jsxs(FormSelect,{value:(M==null?void 0:M.value)??"",onChange:A=>v(A.target.value),children:[jsxRuntimeExports.jsx("option",{value:"",disabled:!0,children:"Select a category"}),ROOM_CATEGORIES.map(A=>jsxRuntimeExports.jsx("option",{value:A.value,children:A.label},A.value))]})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Type"}),jsxRuntimeExports.jsxs(FormSelect,{value:(M==null?void 0:M.value)===(g==null?void 0:g.value)?l:"",disabled:!M,onChange:A=>w(A.target.value),children:[jsxRuntimeExports.jsx("option",{value:"",disabled:!0,children:"Select a type"}),M==null?void 0:M.types.map(A=>jsxRuntimeExports.jsx("option",{value:A.value,children:A.label},A.value))]})]}),jsxRuntimeExports.jsx("div",{className:"text-[12px] text-gray-500 mt-1",children:"Pick a roomtype for this area"}),jsxRuntimeExports.jsx("div",{className:"grid grid-cols-2 gap-2",children:((M==null?void 0:M.types)??[]).map(A=>{const P=(M==null?void 0:M.value)===(g==null?void 0:g.value)&&A.value===l;return jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>w(A.value),className:"rounded px-3 py-2 text-left text-[13px] font-medium transition-colors",style:{background:A.color,outline:P?"2px solid var(--dark-blue, #1ca6fc)":"none",outlineOffset:-2},children:A.label},A.value)})})]});if(s==="material"){const A=(E==null?void 0:E.name)||(y==null?void 0:y.name)||d.toUpperCase();return jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntimeExports.jsx(BackHeader,{title:"Material",subtitle:A,onBack:()=>o("main")}),jsxRuntimeExports.jsx(FinishPicker,{color:d,onColorChange:P=>I({patternColor:P}),textures:x,texture:p,onTextureChange:P=>I(P==="none"?{texture:"none"}:{texture:P,pattern:"none"}),patterns:jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Patterns"}),jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>I({pattern:"none"}),className:"rounded overflow-hidden text-left aspect-square border transition-colors flex items-center justify-center",style:{borderColor:f==="none"?"var(--dark-blue, #1ca6fc)":"var(--properties-input-border, #E5E7EB)",borderWidth:2,background:d},title:"None",children:jsxRuntimeExports.jsx("span",{className:"text-[11px] text-gray-700 bg-white/70 px-1.5 rounded",children:"None"})}),AREA_PATTERNS.map(P=>{const B=P.key===f;return jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>I({pattern:P.key,texture:"none"}),className:"rounded overflow-hidden text-left aspect-square border transition-colors",style:{borderColor:B?"var(--dark-blue, #1ca6fc)":"var(--properties-input-border, #E5E7EB)",borderWidth:2},title:P.name,children:jsxRuntimeExports.jsx(PatternSwatch,{pattern:P,color:d,size:80,rounded:!1})},P.key)})]}),E&&jsxRuntimeExports.jsx("div",{className:"text-[12px] text-gray-500 mt-2",children:E.name})]})})]})}if(s==="settings"){const A=computeAreaSize(i,e);return jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntimeExports.jsx(BackHeader,{title:"Room Settings",subtitle:T||"Unnamed",onBack:()=>o("main")}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Custom Name"}),jsxRuntimeExports.jsx(FormTextInput,{value:c,onChange:P=>I({customName:P.target.value}),placeholder:"e.g. Master bedroom",style:{textAlign:"left"}})]}),jsxRuntimeExports.jsxs("div",{className:"flex items-start justify-between gap-4",children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"text-[11px] text-gray-500 leading-tight",children:"Total Area"}),jsxRuntimeExports.jsxs("div",{className:"text-[16px] font-semibold",children:[(A/1e4).toFixed(2)," m²"]})]}),jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntimeExports.jsxs("label",{className:"flex items-center gap-2 text-[13px] cursor-pointer",children:[jsxRuntimeExports.jsx("input",{type:"checkbox",className:"m-0",checked:!!u,onChange:()=>I({showName:!u})}),"Show name in 2D"]}),jsxRuntimeExports.jsxs("label",{className:"flex items-center gap-2 text-[13px] cursor-pointer",children:[jsxRuntimeExports.jsx("input",{type:"checkbox",className:"m-0",checked:!!h,onChange:()=>I({showSurfaceArea:!h})}),"Show surface area"]})]})]})]})}const R=computeAreaSize(i,e);return jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-3 mb-2",children:[jsxRuntimeExports.jsx(AreaPreview,{element:i,layer:e,color:d,label:T,pattern:E}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"text-[11px] text-gray-500 leading-tight",children:"Room"}),jsxRuntimeExports.jsxs("div",{className:"text-[16px] font-semibold",children:[(R/1e4).toFixed(2)," m²"]})]}),jsxRuntimeExports.jsx(RowButton,{swatchColor:_==null?void 0:_.color,label:"Roomtype",value:(_==null?void 0:_.label)||"Unknown",onClick:()=>{v((g==null?void 0:g.value)||""),o("roomtype")}}),jsxRuntimeExports.jsx(RowButton,{swatchColor:d,textureUri:y==null?void 0:y.uri,patternPreview:E,label:"Material",value:(E==null?void 0:E.name)||(y==null?void 0:y.name)||d.toUpperCase(),onClick:()=>o("material")}),jsxRuntimeExports.jsx(RowButton,{icon:jsxRuntimeExports.jsx(FaCog,{size:20}),label:"",value:"Settings",onClick:()=>o("settings")})]})},tagsOf=i=>{var e;return(((e=i.info)==null?void 0:e.tag)??[]).map(t=>String(t).toLowerCase())},isBrowsable=i=>{var e;return(e=i.info)!=null&&e.visibility?i.info.visibility.catalog:!0};function findSimilarElements(i,e){let t;try{t=i.getElement(e.type)}catch{return[]}const n=new Set(tagsOf(t));return n.size===0?[]:i.getElementsOfPrototype(e.prototype).filter(s=>s.name!==t.name).filter(isBrowsable).map(s=>({candidate:s,shared:tagsOf(s).filter(o=>n.has(o)).length})).filter(({shared:s})=>s>0).sort((s,o)=>o.shared-s.shared||(s.candidate.info.title??"").localeCompare(o.candidate.info.title??"")).map(({candidate:s})=>s)}const SimilarElementsGrid=({elements:i,containerSelector:e=".floor_planner-sidebar"})=>{const{selectToolDrawingItem:t,selectToolDrawingHole:n,pushLastSelectedCatalogElementToHistory:s}=useReactPlannerStore(),o=l=>{switch(l.prototype){case"items":t(l.name);break;case"holes":n(l.name);break;default:return}s(l)},a=(l,c)=>{l.preventDefault();const u=l.currentTarget.closest(e);if(!u)return;const h=()=>{u.removeEventListener("mouseleave",d),document.removeEventListener("mouseup",p)},d=()=>{o(c),h()},p=()=>h();u.addEventListener("mouseleave",d),document.addEventListener("mouseup",p)};return i.length===0?jsxRuntimeExports.jsx("p",{className:"text-sm font-medium text-gray-400 text-center py-6",children:"No similar items"}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("p",{className:"text-[11px] text-gray-500",children:"Drag one onto the plan to place it."}),jsxRuntimeExports.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-5",children:i.map(l=>jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1.5",title:l.info.title,children:[jsxRuntimeExports.jsx("div",{className:"fp-aspect-ratio-container",children:jsxRuntimeExports.jsx("div",{className:"fp-aspect-ratio-content",onMouseDown:c=>a(c,l),children:jsxRuntimeExports.jsx("img",{draggable:!1,loading:"lazy",decoding:"async",className:"fp-item-image",alt:l.info.title,src:l.info.image})})}),jsxRuntimeExports.jsx("p",{className:"text-xs font-semibold capitalize truncate",children:l.info.title})]},l.name.replace(/\s+/g,"_")))})]})},HoleAttributesEditor=({element:i,catalog:e})=>{const{planner:t,setHoleProperties:n,duplicateSelected:s,flipSelected:o,remove:a}=useReactPlannerStore(),[l,c]=React.useState("main"),u=React.useMemo(()=>findSimilarElements(e,i),[e,i.type,i.prototype]),h=t.mode!==MODE_3D_VIEW&&u.length>0,d=i.properties.get("customName")||"",p=i.properties.get("showName")??!1,f=I=>i.properties.getIn([I,"length"])??0,g=f("width"),_=f("height"),x=f("altitude"),y=f("thickness"),E=(()=>{try{return e.getElement(i.type).info??{}}catch{return{}}})(),b=t.scene.unit,v=(I,w)=>{const R=i.properties.get(I)||Map$1();n(i.id,{[I]:R.set("length",w).set("_length",w)})},M=I=>n(i.id,I),T=[{key:"duplicate",label:"Duplicate",icon:jsxRuntimeExports.jsx(LuCopy,{}),onClick:s},{key:"flip-hinge",label:"Flip hinge side",icon:jsxRuntimeExports.jsx(PiFlipHorizontalBold,{}),onClick:()=>o("x")},{key:"flip-opening",label:"Flip opening side",icon:jsxRuntimeExports.jsx(PiFlipVerticalBold,{}),onClick:()=>o("y")},{key:"delete",label:"Delete",icon:jsxRuntimeExports.jsx(LuTrash2,{}),danger:!0,onClick:()=>a()}];return l==="similar"&&h?jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-3",children:[jsxRuntimeExports.jsx(BackHeader$1,{title:"Similar Items",subtitle:E.title||i.name,onBack:()=>c("main")}),jsxRuntimeExports.jsx(SimilarElementsGrid,{elements:u})]}):l==="settings"?jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntimeExports.jsx(BackHeader$1,{title:"Settings",subtitle:d||i.name,onBack:()=>c("main")}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Custom Name"}),jsxRuntimeExports.jsx(FormTextInput,{value:d,onChange:I=>M({customName:I.target.value}),placeholder:i.name,style:{textAlign:"left"}})]}),jsxRuntimeExports.jsxs("label",{className:"flex items-center gap-2 text-[13px] cursor-pointer",children:[jsxRuntimeExports.jsx("input",{type:"checkbox",className:"m-0",checked:p,onChange:()=>M({showName:!p})}),"Show name in 2D"]}),jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Width"}),jsxRuntimeExports.jsx(MeasureStepper,{value:Math.round(g),onChange:I=>v("width",I),min:1,max:1e3})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Height"}),jsxRuntimeExports.jsx(MeasureStepper,{value:Math.round(_),onChange:I=>v("height",I),min:1,max:1e3})]})]}),jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Raise From Floor"}),jsxRuntimeExports.jsx(MeasureStepper,{value:Math.round(x),onChange:I=>v("altitude",I),min:0,max:1e3})]}),i.properties.has("thickness")&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Thickness"}),jsxRuntimeExports.jsx(MeasureStepper,{value:Math.round(y),onChange:I=>v("thickness",I),min:1,max:200})]})]})]}):jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-3 mb-2",children:[jsxRuntimeExports.jsx(ElementPreview,{imageUri:E.image,alt:i.name}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"text-[11px] text-gray-500 leading-tight",children:"Dimensions"}),jsxRuntimeExports.jsxs("div",{className:"text-[16px] font-semibold",children:[formatDistance(g,b)," × ",formatDistance(_,b)]})]}),jsxRuntimeExports.jsx(ActionRow,{actions:T}),jsxRuntimeExports.jsx(RowButton$1,{icon:jsxRuntimeExports.jsx(FaCog,{size:20}),label:"",value:"Settings",onClick:()=>c("settings")}),h&&jsxRuntimeExports.jsx(RowButton$1,{icon:jsxRuntimeExports.jsx(MdOutlineDoorFront,{size:20}),label:"",value:"Similar Items",onClick:()=>c("similar")})]})},useNaturalSize=i=>{const[e,t]=React.useState(null);return React.useLayoutEffect(()=>{const n=document.querySelector(`#svg-drawing-paper [data-element-root][data-id="${i.id}"]`);if(!n){t(null);return}let s;try{s=n.getBBox()}catch{return}!s.width||!s.height||t(o=>o&&o.width===s.width&&o.height===s.height?o:{width:s.width,height:s.height})},[i.id,i.type]),e},ItemAttributesEditor=({element:i,catalog:e})=>{const{planner:t,setProperties:n,setItemAttributes:s,duplicateSelected:o,rotateSelected:a,flipSelected:l,remove:c}=useReactPlannerStore(),[u,h]=React.useState("main"),d=useNaturalSize(i),{scale:p}=getItemTransform(i),f=i.properties.get("customName")||"",g=i.properties.get("showName")??!1,_=i.rotation??0,x=i.altitude??0,y=(()=>{try{return e.getElement(i.type).info??{}}catch{return{}}})(),E=t.scene.unit,b=d?d.width*p:null,v=d?d.height*p:null,M=React.useMemo(()=>findSimilarElements(e,i),[e,i.type,i.prototype]),T=t.mode!==MODE_3D_VIEW&&M.length>0,I=(R,A)=>{if(!d)return;const P=R==="width"?d.width:d.height;P&&s(i.id,{scale:clampItemScale(A/P)})},w=[{key:"duplicate",label:"Duplicate",icon:jsxRuntimeExports.jsx(LuCopy,{}),onClick:o},{key:"rotate-ccw",label:"Rotate left 90°",icon:jsxRuntimeExports.jsx(LuRotateCcw,{}),onClick:()=>a(90)},{key:"rotate-cw",label:"Rotate right 90°",icon:jsxRuntimeExports.jsx(LuRotateCw,{}),onClick:()=>a(-90)},{key:"flip-horizontal",label:"Flip horizontally",icon:jsxRuntimeExports.jsx(PiFlipHorizontalBold,{}),onClick:()=>l("x")},{key:"flip-vertical",label:"Flip vertically",icon:jsxRuntimeExports.jsx(PiFlipVerticalBold,{}),onClick:()=>l("y")},{key:"delete",label:"Delete",icon:jsxRuntimeExports.jsx(LuTrash2,{}),danger:!0,onClick:()=>c()}];return u==="similar"&&T?jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-3",children:[jsxRuntimeExports.jsx(BackHeader$1,{title:"Similar Items",subtitle:y.title||i.name,onBack:()=>h("main")}),jsxRuntimeExports.jsx(SimilarElementsGrid,{elements:M})]}):u==="settings"?jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntimeExports.jsx(BackHeader$1,{title:"Object Settings",subtitle:f||i.name,onBack:()=>h("main")}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Custom Name"}),jsxRuntimeExports.jsx(FormTextInput,{value:f,onChange:R=>n(Map$1({customName:R.target.value})),placeholder:i.name,style:{textAlign:"left"}})]}),jsxRuntimeExports.jsxs("label",{className:"flex items-center gap-2 text-[13px] cursor-pointer",children:[jsxRuntimeExports.jsx("input",{type:"checkbox",className:"m-0",checked:g,onChange:()=>n(Map$1({showName:!g}))}),"Show name in 2D"]}),b!==null&&v!==null&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Width"}),jsxRuntimeExports.jsx(MeasureStepper,{value:Math.round(b),onChange:R=>I("width",R),min:1,max:5e3})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Depth"}),jsxRuntimeExports.jsx(MeasureStepper,{value:Math.round(v),onChange:R=>I("depth",R),min:1,max:5e3})]})]}),jsxRuntimeExports.jsx("div",{className:"-mt-2 text-[11px] text-gray-500",children:"Objects scale proportionally, so width and depth move together."})]}),jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Raise From Floor"}),jsxRuntimeExports.jsx(MeasureStepper,{value:Math.round(x),onChange:R=>s(i.id,{altitude:R}),min:0,max:1e3})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Rotation"}),jsxRuntimeExports.jsx(MeasureStepper,{value:Math.round(_),onChange:R=>s(i.id,{rotation:R}),step:15,min:-360,max:360,unit:"°"})]})]})]}):jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-3 mb-2",children:[jsxRuntimeExports.jsx(ElementPreview,{imageUri:y.image,alt:i.name}),b!==null&&v!==null&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"text-[11px] text-gray-500 leading-tight",children:"Dimensions"}),jsxRuntimeExports.jsxs("div",{className:"text-[16px] font-semibold",children:[formatDistance(b,E)," × ",formatDistance(v,E)]})]}),jsxRuntimeExports.jsx(ActionRow,{actions:w}),jsxRuntimeExports.jsx(RowButton$1,{icon:jsxRuntimeExports.jsx(FaCog,{size:20}),label:"",value:"Settings",onClick:()=>h("settings")}),T&&jsxRuntimeExports.jsx(RowButton$1,{icon:jsxRuntimeExports.jsx(MdOutlineChair,{size:20}),label:"",value:"Similar Items",onClick:()=>h("similar")})]})},FormNumberInput=({value:i,min:e,max:t,precision:n,onChange:s,onValid:o,onInvalid:a,style:l,placeholder:c})=>{const[u,h]=React.useState(!0),[d,p]=React.useState(i);let f=new RegExp(`^-?([0-9]+)?\\.?([0-9]{0,${n}})?$`);React.useEffect(()=>{e!==void 0&&!isNaN(e)&&isFinite(e)&&Number(d)<e&&p(e),t&&!isNaN(t)&&isFinite(t)&&Number(d)>t&&p(t)},[e,t,d]);const g=React.useMemo(()=>parseFloat(String(i)).toFixed(n)!==parseFloat(String(d)).toFixed(n),[i,d,n]),_=x=>{if(x.stopPropagation(),u){let y=d!==""&&d!=="-"?parseFloat(String(d)):0;p(y),s({target:{value:y}})}};return jsxRuntimeExports.jsxs("div",{className:"relative w-full",children:[jsxRuntimeExports.jsx("input",{type:"text",value:f.test(String(d))?d:parseFloat(String(d)).toFixed(n),className:"block text-[13px] h-[35px] w-full px-2 leading-5 rounded panel-property_input outline-none focus:outline-none",style:{...l},onChange:x=>{let y=f.test(x.target.value);y?(p(x.target.value),o&&o(x.nativeEvent)):a&&a(x.nativeEvent),h(y)},onKeyDown:x=>{var y=x.keyCode||x.which;(y==KEYBOARD_BUTTON_CODE.ENTER||y==KEYBOARD_BUTTON_CODE.TAB)&&g&&_(x)},placeholder:c}),jsxRuntimeExports.jsx("div",{onClick:x=>{g&&_(x)},title:"Confirm",className:"absolute cursor-pointer w-6 h-6 text-white top-1.5 right-1 bg-dark-blue",style:{transition:"all 0.1s linear",visibility:g?"visible":"hidden",opacity:g?"1":"0"},children:jsxRuntimeExports.jsx(MdUpdate,{style:{width:"100%",height:"100%",padding:"0.2em",color:"#FFF"}})})]})},PropertyLengthMeasure$1=({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;i.get("_unit");const{hook:h,label:d,...p}=n,f=(g,_)=>{let x=toFixedFloat(g),y=i.merge({length:x,_length:g,_unit:_});return h?h(y,s,o,a).then(E=>e(E)):e(y)};if(l!==MODE_3D_VIEW)return jsxRuntimeExports.jsxs("div",{className:"PropertyLengthMeasure w-full mb-2",children:[jsxRuntimeExports.jsx(FormLabel,{children:d}),jsxRuntimeExports.jsxs("div",{className:"w-full flex",children:[jsxRuntimeExports.jsx(FormNumberInput,{value:u,style:{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:0},onChange:g=>f(g.target.value,UNIT_CENTIMETER),onValid:t,...p}),jsxRuntimeExports.jsx("div",{className:"w-1/4 [&>*:first-child]:text-center",children:jsxRuntimeExports.jsx(FormSelect,{style:{borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"},disabled:!0,value:UNIT_CENTIMETER,onChange:g=>{},children:UNITS_LENGTH.map(g=>jsxRuntimeExports.jsx("option",{value:g,children:g},g))})})]})]})},LineAttributesEditor=({element:i,onUpdate:e,attributeFormData:t})=>{let n=t.has("name")?t.get("name"):i.name,s=t.has("lineLength")?t.get("lineLength"):null;return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsxs("div",{className:"w-full mb-2",children:[jsxRuntimeExports.jsx(FormLabel,{children:"Name"}),jsxRuntimeExports.jsx(FormTextInput,{value:n,onChange:o=>e("name",o.target.value),style:{textAlign:"left"}})]}),jsxRuntimeExports.jsx(PropertyLengthMeasure$1,{value:s,onUpdate:o=>e("lineLength",o),configs:{label:"Length",min:0,max:1/0,precision:2}})]})},DEFAULT_WALL_COLOR="#EFEFEF",SideTogglePills=({activeSide:i,onChange:e,colorA:t,colorB:n,textureUriA:s,textureUriB:o})=>jsxRuntimeExports.jsx("div",{className:"w-full grid grid-cols-2 gap-2",children:[["A","side 1",t,s],["B","side 2",n,o]].map(([a,l,c,u])=>{const h=a===i;return jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>e(a),className:"w-full flex items-center justify-between px-3 py-2 rounded transition-colors",style:{background:h?"var(--dark-blue, #1ca6fc)":"var(--panel-property-background, #F3F4F6)",color:h?"white":void 0},children:[jsxRuntimeExports.jsx("span",{className:"text-[13px] font-medium",children:l}),jsxRuntimeExports.jsx("span",{className:"w-4 h-4 rounded-full border bg-center bg-cover",style:{background:c,backgroundImage:u?`url(${u})`:void 0,backgroundSize:"cover",backgroundPosition:"center",borderColor:h?"white":"#D1D5DB"}})]},a)})}),WallPreview=({color:i,textureUri:e})=>jsxRuntimeExports.jsx("div",{className:"w-full aspect-[16/9] bg-[color:var(--panel-property-background,#F3F4F6)] rounded flex items-center justify-center overflow-hidden",children:jsxRuntimeExports.jsx("div",{className:"rounded-sm",style:{width:"40%",height:"70%",background:i,backgroundImage:e?`url(${e})`:void 0,backgroundSize:"cover",backgroundPosition:"center",boxShadow:"0 1px 6px rgba(0,0,0,0.12)"}})}),WallAttributesEditor=({element:i,layer:e,catalog:t})=>{var $,ee;const{setProperties:n}=useReactPlannerStore(),[s,o]=React.useState("main"),[a,l]=React.useState("A"),c=i.properties.get("colorA")||DEFAULT_WALL_COLOR,u=i.properties.get("colorB")||DEFAULT_WALL_COLOR,h=i.properties.get("textureA")||"none",d=i.properties.get("textureB")||"none",p=i.properties.get("customName")||"",f=i.properties.get("showName")??!1,g=i.properties.get("finishNameA")||"",_=i.properties.get("finishNameB")||"",x=t.getElement(i.type).textures||{},y=a==="A"?"colorA":"colorB",E=a==="A"?"textureA":"textureB",b=a==="A"?"finishNameA":"finishNameB",v=a==="A"?c:u,M=a==="A"?h:d,T=x[M],I=a==="A"?g:_,w=G=>{n(Map$1(G))},R=e.vertices.get(i.vertices.get(0)),A=e.vertices.get(i.vertices.get(1)),P=pointsDistance(R.x,R.y,A.x,A.y),B=i.properties.getIn(["height","length"])||0,k=i.properties.getIn(["thickness","length"])||0,W=P*B/1e4,Y=(G,K)=>{const X=(i.properties.get(G)||Map$1()).set("length",K).set("_length",K);w({[G]:X})};return s==="finish"?jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntimeExports.jsx(BackHeader$1,{title:`Wall Finish · ${a==="A"?"side 1":"side 2"}`,subtitle:I||(T==null?void 0:T.name)||v.toUpperCase(),onBack:()=>o("main")}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Finish Name"}),jsxRuntimeExports.jsx(FormTextInput,{value:I,onChange:G=>w({[b]:G.target.value}),placeholder:(T==null?void 0:T.name)||`Finish ${a==="A"?1:2}`,style:{textAlign:"left"}})]}),jsxRuntimeExports.jsx(FinishPicker,{color:v,onColorChange:G=>w({[y]:G}),textures:x,texture:M,onTextureChange:G=>w({[E]:G})})]}):s==="settings"?jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntimeExports.jsx(BackHeader$1,{title:"Wall Settings",subtitle:p||"Unnamed",onBack:()=>o("main")}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Custom Name"}),jsxRuntimeExports.jsx(FormTextInput,{value:p,onChange:G=>w({customName:G.target.value}),placeholder:"e.g. Party wall",style:{textAlign:"left"}})]}),jsxRuntimeExports.jsxs("label",{className:"flex items-center gap-2 text-[13px] cursor-pointer",children:[jsxRuntimeExports.jsx("input",{type:"checkbox",className:"m-0",checked:f,onChange:()=>w({showName:!f})}),"Show name in 2D"]}),jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Thickness"}),jsxRuntimeExports.jsx(MeasureStepper,{value:Math.round(k),onChange:G=>Y("thickness",G),min:1,max:200})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Wall Height"}),jsxRuntimeExports.jsx(MeasureStepper,{value:Math.round(B),onChange:G=>Y("height",G),min:1,max:1e3})]})]}),jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-2 gap-4 pt-1",children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"text-[11px] text-gray-500 leading-tight",children:"Length"}),jsxRuntimeExports.jsxs("div",{className:"text-[14px] font-semibold",children:[(P/100).toFixed(2)," m"]})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"text-[11px] text-gray-500 leading-tight",children:"Surface Area"}),jsxRuntimeExports.jsxs("div",{className:"text-[14px] font-semibold",children:[W.toFixed(2)," m²"]})]})]})]}):jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-3 mb-2",children:[jsxRuntimeExports.jsx(SideTogglePills,{activeSide:a,onChange:l,colorA:c,colorB:u,textureUriA:($=x[h])==null?void 0:$.uri,textureUriB:(ee=x[d])==null?void 0:ee.uri}),jsxRuntimeExports.jsx(WallPreview,{color:v,textureUri:T==null?void 0:T.uri}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"text-[11px] text-gray-500 leading-tight",children:"Dimensions"}),jsxRuntimeExports.jsxs("div",{className:"text-[16px] font-semibold",children:[W.toFixed(2)," m²"]})]}),jsxRuntimeExports.jsx(RowButton$1,{swatchColor:v,textureUri:T==null?void 0:T.uri,label:"Wall Finish",value:I||(T==null?void 0:T.name)||v.toUpperCase(),onClick:()=>o("finish")}),jsxRuntimeExports.jsx(RowButton$1,{icon:jsxRuntimeExports.jsx(FaCog,{size:20}),label:"",value:"Settings",onClick:()=>o("settings")})]})},AttributesEditor=({element:i,layer:e,catalog:t,onUpdate:n,onValid:s,attributeFormData:o,...a})=>i.prototype==="items"?jsxRuntimeExports.jsx(ItemAttributesEditor,{element:i,catalog:t}):i.prototype==="lines"?i.type==="wall"?jsxRuntimeExports.jsx(WallAttributesEditor,{element:i,layer:e,catalog:t}):jsxRuntimeExports.jsx(LineAttributesEditor,{element:i,onUpdate:n,onValid:s,attributeFormData:o,...a}):i.prototype==="holes"?jsxRuntimeExports.jsx(HoleAttributesEditor,{element:i,catalog:t}):i.prototype==="areas"?jsxRuntimeExports.jsx(AreaAttributesEditor,{element:i,layer:e,catalog:t}):null,PRECISION=2,initAttrData=(i,e,t)=>{switch(i=typeof i.misc=="object"?i.set("misc",Map$1(i.misc)):i,i.prototype){case"items":return Map$1(i);case"lines":{let n=e.vertices.get(i.vertices.get(0)),s=e.vertices.get(i.vertices.get(1)),o=pointsDistance(n.x,n.y,s.x,s.y),a=i.misc.get("_unitLength")||t.unit,l=convert(o).from(t.unit).to(a);return Map$1({vertexOne:n,vertexTwo:s,lineLength:Map$1({length:o,_length:l,_unit:a})})}case"holes":{let n=e.lines.get(i.line),{x:s,y:o}=e.vertices.get(n.vertices.get(0)),{x:a,y:l}=e.vertices.get(n.vertices.get(1)),c=pointsDistance(s,o,a,l),u=c*i.offset-i.properties.get("width").get("length")/2,h=i.misc.get("_unitA")||t.unit,d=convert(u).from(t.unit).to(h),p=c-c*i.offset-i.properties.get("width").get("length")/2,f=i.misc.get("_unitB")||t.unit,g=convert(p).from(t.unit).to(f);return Map$1({offset:i.offset,offsetA:Map$1({length:toFixedFloat(u,PRECISION),_length:toFixedFloat(d,PRECISION),_unit:h}),offsetB:Map$1({length:toFixedFloat(p,PRECISION),_length:toFixedFloat(g,PRECISION),_unit:f})})}case"areas":return Map$1({});default:return null}},initPropData=(i,e)=>{const t=e.getElement(i.type),n={};for(const s in t.properties)n[s]=Map$1({currentValue:i.properties.has(s)?i.properties.get(s):fromJS(t.properties[s].defaultValue),configs:t.properties[s]});return Map$1(n)},ElementEditor=({element:i,layer:e,catalog:t})=>{const{planner:n,setItemsAttributes:s,setProperties:o,setLinesAttributes:a,setHolesAttributes:l}=useReactPlannerStore(),[c,u]=React.useState(initAttrData(i,e,t)),[h,d]=React.useState(initPropData(i,t)),p=({propertiesFormData:x,attributesFormData:y})=>{if(x){let E=x.map(b=>b.get("currentValue"));o(E)}if(y)switch(i.prototype){case"items":{s(y);break}case"lines":{a(y);break}case"holes":{l(y);break}}},f=(x,y)=>{if(!c)return;let E;switch(i.prototype){case"items":{E=c.set(x,y);break}case"lines":{switch(x){case"lineLength":{let b=c.get("vertexOne"),v=c.get("vertexTwo"),[M,T]=orderVertices([b,v]),I=extendLine(M.x,M.y,T.x,T.y,y.get("length"),PRECISION);E=c.withMutations(w=>{w.set(b===M?"vertexTwo":"vertexOne",T.merge(I)),w.set("lineLength",y)});break}case"vertexOne":case"vertexTwo":{E=c.withMutations(b=>{b.set(x,b.get(x).merge(y));let v=verticesDistance(b.get("vertexOne"),b.get("vertexTwo"));b.mergeIn(["lineLength"],b.get("lineLength").merge({length:v,_length:convert(v).from(t.unit).to(b.get("lineLength").get("_unit"))}))});break}default:{E=c.set(x,y);break}}break}case"holes":{switch(x){case"offsetA":{let b=e.lines.get(i.line),v=orderVertices([e.vertices.get(b.vertices.get(0)),e.vertices.get(b.vertices.get(1))]),[{x:M,y:T},{x:I,y:w}]=v,R=angleBetweenTwoPoints(M,T,I,w),A=pointsDistance(M,T,I,w),P=i.properties.get("width").get("length"),B=P/2,k=y.get("length");k=Math.max(k,0),k=Math.min(k,A-P);let W=(k+B)*Math.cos(R)+M,Y=(k+B)*Math.sin(R)+T,$=pointPositionOnLineSegment(M,T,I,w,W,Y),ee=toFixedFloat(A-A*$-B,PRECISION),G=c.getIn(["offsetB","_unit"]),K=Map$1({length:ee,_length:convert(ee).from(t.unit).to(G),_unit:G});E=c.set("offsetB",K).set("offset",$);let F=Map$1({length:toFixedFloat(k,PRECISION),_unit:y.get("_unit"),_length:toFixedFloat(convert(k).from(t.unit).to(y.get("_unit")),PRECISION)});E=c.set(x,F);break}case"offsetB":{let b=e.lines.get(i.line),v=orderVertices([e.vertices.get(b.vertices.get(0)),e.vertices.get(b.vertices.get(1))]),[{x:M,y:T},{x:I,y:w}]=v,R=angleBetweenTwoPoints(M,T,I,w),A=pointsDistance(M,T,I,w),P=i.properties.get("width").get("length"),B=P/2,k=y.get("length");k=Math.max(k,0),k=Math.min(k,A-P);let W=I-(k+B)*Math.cos(R),Y=w-(k+B)*Math.sin(R),$=pointPositionOnLineSegment(M,T,I,w,W,Y),ee=toFixedFloat(A*$-B,PRECISION),G=c.getIn(["offsetA","_unit"]),K=Map$1({length:ee,_length:convert(ee).from(t.unit).to(G),_unit:G});E=c.set("offsetA",K).set("offset",$);let F=Map$1({length:toFixedFloat(k,PRECISION),_unit:y.get("_unit"),_length:toFixedFloat(convert(k).from(t.unit).to(y.get("_unit")),PRECISION)});E=c.set(x,F);break}default:{E=c.set(x,y);break}}break}}E&&(u(E),p({attributesFormData:E,propertiesFormData:h}))},g=i.prototype==="areas"||i.prototype==="items"||i.prototype==="holes"||i.prototype==="lines"&&i.type==="wall",_=(x,y)=>{const E=h.setIn([x,"currentValue"],y);d(E),p({propertiesFormData:E,attributesFormData:c})};return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(AttributesEditor,{element:i,layer:e,catalog:t,onValid:()=>{},onUpdate:f,attributeFormData:c}),!g&&h.entrySeq().map(([x,y])=>{let E=y.get("currentValue"),b=y.get("configs"),{Editor:v}=t.getPropertyType(b.type);return jsxRuntimeExports.jsx(v,{propertyName:x,value:E,configs:b,onUpdate:M=>_(x,M),state:n,sourceElement:i,internalState:{attributesFormData:c,propertiesFormData:h}},x)})]})},PanelElementEditorEmpty=()=>jsxRuntimeExports.jsx("div",{className:"h-full flex flex-col gap-4 justify-center items-center",children:jsxRuntimeExports.jsx("p",{className:"mx-4 text-white text-sm text-center",children:"Select an element on the canvas to edit its properties."})}),VISIBILITY_MODE$1=[MODE_IDLE$1,MODE_2D_ZOOM_IN,MODE_2D_ZOOM_OUT,MODE_2D_PAN,MODE_3D_VIEW,MODE_3D_FIRST_PERSON,MODE_WAITING_DRAWING_LINE,MODE_DRAWING_LINE,MODE_DRAWING_HOLE,MODE_DRAWING_ITEM,MODE_DRAGGING_LINE,MODE_DRAGGING_VERTEX,MODE_DRAGGING_ITEM,MODE_DRAGGING_HOLE,MODE_ROTATING_ITEM,MODE_UPLOADING_IMAGE,MODE_FITTING_IMAGE],titleCase=i=>i.split(/[-_\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),getElementTypeLabel=(i,e,t)=>{if(i.prototype==="areas")return getAreaKind(i,t);if(i.prototype==="lines"&&(i.type==="wall"||i.type==="surface"))return"";try{const n=e.getElement(i.type).info;if(n!=null&&n.title)return titleCase(n.title)}catch{}return titleCase(i.type||i.prototype||"Element")},getElementDisplayName=(i,e)=>{var t;if(i.prototype==="areas"){const n=i.properties.get("customName"),s=i.properties.get("roomCategory"),o=i.properties.get("roomType");return n||getRoomTypeLabel(s,o)||"Unknown"}if(i.prototype==="lines"){if(i.type==="wall")return"Wall";if(i.type==="surface")return"Surface"}return((t=i.properties)==null?void 0:t.get("customName"))||i.name||"Unknown"},PanelElementEditor=({catalog:i})=>{const{planner:e}=useReactPlannerStore(),{scene:t,mode:n}=e;return VISIBILITY_MODE$1.includes(n)?t.layers.valueSeq().flatMap(o=>Seq().concat(o.lines,o.holes,o.areas,o.items).filter(a=>a.selected).map(a=>({element:a,layer:o}))).toArray().length===0?jsxRuntimeExports.jsx(PanelElementEditorEmpty,{}):jsxRuntimeExports.jsx("div",{children:t.layers.valueSeq().map(o=>Seq().concat(o.lines,o.holes,o.areas,o.items).filter(a=>a.selected&&a.type!=="surface").map(a=>jsxRuntimeExports.jsx(Panel,{name:getElementTypeLabel(a,i,o),subtitle:getElementDisplayName(a),opened:!0,children:jsxRuntimeExports.jsx("div",{className:"py-[5px] px-[15px]",children:jsxRuntimeExports.jsx(ElementEditor,{element:a,layer:o,catalog:i})})},a.id)).valueSeq())}):null},VISIBILITY_MODE={MODE_IDLE:MODE_IDLE$1,MODE_2D_ZOOM_IN,MODE_2D_ZOOM_OUT,MODE_2D_PAN,MODE_3D_VIEW,MODE_3D_FIRST_PERSON,MODE_WAITING_DRAWING_LINE,MODE_DRAWING_LINE,MODE_DRAWING_HOLE,MODE_DRAWING_ITEM,MODE_DRAGGING_LINE,MODE_DRAGGING_VERTEX,MODE_DRAGGING_ITEM,MODE_DRAGGING_HOLE,MODE_FITTING_IMAGE,MODE_UPLOADING_IMAGE,MODE_ROTATING_ITEM},tableStyle$1={width:"100%"},firstTdStyle$1={width:"6em"},inputStyle={textAlign:"left"},styleEditButton={marginLeft:"5px",border:"0px",background:"none",color:"#FFFFFF",fontSize:"14px",outline:"0px"},tablegroupStyle={width:"100%",cursor:"pointer",maxHeight:"20em",marginLeft:"1px",marginTop:"1em"},iconColStyle={width:"2em"},PanelGroupEditor=({groupID:i})=>{const{planner:e,setGroupAttributes:t,groupTranslate:n,groupRotate:s,removeFromGroup:o}=useReactPlannerStore(),{mode:a}=e;if(!i||!VISIBILITY_MODE[a])return null;const l=e.getIn(["scene","groups",i]),c=l.get("elements");return jsxRuntimeExports.jsx(Panel,{name:`Group [${l.get("name")}]`,opened:!0,children:jsxRuntimeExports.jsxs("div",{style:{padding:"5px 15px"},children:[jsxRuntimeExports.jsx("table",{style:tableStyle$1,children:jsxRuntimeExports.jsxs("tbody",{children:[jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{style:firstTdStyle$1,children:"Name"}),jsxRuntimeExports.jsx("td",{children:jsxRuntimeExports.jsx(FormTextInput,{value:l.get("name"),onChange:u=>t(i,Map$1({name:u.target.value})),style:inputStyle})})]}),jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{style:firstTdStyle$1,children:"X"}),jsxRuntimeExports.jsx("td",{children:jsxRuntimeExports.jsx(FormNumberInput,{value:l.get("x"),onChange:u=>n(i,u.target.value,l.get("y")),style:inputStyle,precision:2})})]}),jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{style:firstTdStyle$1,children:"Y"}),jsxRuntimeExports.jsx("td",{children:jsxRuntimeExports.jsx(FormNumberInput,{value:l.get("y"),onChange:u=>n(i,l.get("x"),u.target.value),style:inputStyle,precision:2})})]}),jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{style:firstTdStyle$1,children:"Rotation"}),jsxRuntimeExports.jsx("td",{children:jsxRuntimeExports.jsx(FormNumberInput,{value:l.get("rotation"),onChange:u=>s(i,u.target.value),style:inputStyle,precision:2})})]})]})}),c.size?jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("p",{style:{textAlign:"center",borderBottom:"1px solid #555",paddingBottom:"1em"},children:"Group's Elements"}),jsxRuntimeExports.jsxs("table",{style:tablegroupStyle,children:[jsxRuntimeExports.jsx("thead",{children:jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("th",{style:iconColStyle}),jsxRuntimeExports.jsx("th",{children:"Layer"}),jsxRuntimeExports.jsx("th",{children:"Prototype"}),jsxRuntimeExports.jsx("th",{children:"Name"})]})}),jsxRuntimeExports.jsx("tbody",{children:c.entrySeq().map(([u,h])=>h.entrySeq().map(([d,p])=>p.valueSeq().map(f=>{let g=e.getIn(["scene","layers",u,d,f]);return jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{style:iconColStyle,title:"Un-chain Element from Group",children:jsxRuntimeExports.jsx(FaUnlink,{onClick:()=>o(i,u,d,f),style:styleEditButton})}),jsxRuntimeExports.jsx("td",{style:{textAlign:"center"},children:u}),jsxRuntimeExports.jsx("td",{style:{textAlign:"center",textTransform:"capitalize"},children:d}),jsxRuntimeExports.jsx("td",{style:{textAlign:"center"},children:g.name})]},f)})))})]})]}):null]})})},Sidebar=({catalog:i,width:e=280})=>{const{planner:t}=useReactPlannerStore(),n=t.getIn(["scene","selectedLayer"]),s=t.getIn(["scene","layers",n,"selected"]),o=t.getIn(["scene","layers",n,"lines"]),a=t.getIn(["scene","groups"]).findEntry(h=>h.get("selected")),l=s.lines.filter(h=>{var d;return((d=o.get(h))==null?void 0:d.get("type"))!=="surface"}),c=l.size>1||s.items.size>1||s.holes.size>1||s.areas.size>1||l.size+s.items.size+s.holes.size+s.areas.size>1;return l.size>0||s.items.size>0||s.holes.size>0||s.areas.size>0?jsxRuntimeExports.jsxs("aside",{onKeyDown:h=>h.stopPropagation(),onKeyUp:h=>h.stopPropagation(),className:"floor_planner-sidebar h-full block overflow-y-auto overflow-x-hidden pb-5",style:{width:e},children:[!c&&jsxRuntimeExports.jsx(PanelElementEditor,{catalog:i}),!!a&&jsxRuntimeExports.jsx(PanelGroupEditor,{groupID:a?a[0]:null})]}):null},inlinedAssets=new Map,fetchAsDataURL=async i=>{const e=inlinedAssets.get(i);if(e)return e;const t=await fetch(i);if(!t.ok)throw new Error(`${t.status} ${t.statusText}`);const n=await t.blob(),s=await new Promise((o,a)=>{const l=new FileReader;l.onerror=()=>a(l.error??new Error("FileReader failed")),l.onload=()=>o(l.result),l.readAsDataURL(n)});return inlinedAssets.set(i,s),s},loadImage=i=>new Promise((e,t)=>{const n=new Image;n.onload=()=>e(n),n.onerror=()=>t(new Error("Browser could not decode the serialized SVG")),n.src=i}),capture=async i=>{const{maxWidth:e,type:t="image/png",quality:n,minWidth:s=200}=i,o=document.getElementsByTagName("svg");if(!o.length)throw new Error("No <svg> on the page to capture");let a=o[0];for(let p=1;p<o.length;p++)o[p].width.baseVal.value>a.width.baseVal.value&&(a=o[p]);const l=a.width.baseVal.value,c=a.height.baseVal.value;if(l<s||!c)throw new Error(`Largest SVG is ${l}x${c}, too small to be the plan viewer`);const u=a.cloneNode(!0);await Promise.all(Array.from(u.querySelectorAll("image")).map(async p=>{const f=p.getAttribute("href")||p.getAttribute("xlink:href");if(!(!f||f.startsWith("data:")))try{const g=await fetchAsDataURL(f);p.setAttribute("href",g),p.removeAttribute("xlink:href")}catch(g){console.warn("Could not inline image:",f,g),p.remove()}}));const h=new XMLSerializer().serializeToString(u),d=URL.createObjectURL(new Blob([h],{type:"image/svg+xml;charset=utf-8"}));try{const p=await loadImage(d),f=e&&l>e?e/l:1,g=document.createElement("canvas");g.width=Math.round(l*f),g.height=Math.round(c*f);const _=g.getContext("2d");if(!_)throw new Error("Could not get a 2d canvas context");return _.fillStyle="white",_.fillRect(0,0,g.width,g.height),_.drawImage(p,0,0,g.width,g.height),g.toDataURL(t,n)}finally{URL.revokeObjectURL(d)}},getSVGScreenshot=(i={})=>{const{timeout:e=15e3}=i;let t;return Promise.race([capture(i),new Promise((n,s)=>{t=setTimeout(()=>s(new Error(`Screenshot timed out after ${e}ms`)),e)})]).finally(()=>clearTimeout(t))},ToolbarRail=({items:i,active:e,onChange:t})=>jsxRuntimeExports.jsx("aside",{className:"fp-toolbar-rail",children:i.map(n=>{const s=n.key===e;return jsxRuntimeExports.jsxs("div",{className:cn("fp-toolbar-rail__item",s&&"fp-toolbar-rail__item--active",n.disabled&&"fp-toolbar-rail__item--disabled"),onClick:()=>{n.disabled||t(n.key)},children:[jsxRuntimeExports.jsx("span",{className:"fp-toolbar-rail__icon",children:n.icon}),jsxRuntimeExports.jsx("span",{className:"fp-toolbar-rail__label",children:n.label})]},n.key)})});function BiChevronLeft(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M13.293 6.293 7.586 12l5.707 5.707 1.414-1.414L10.414 12l4.293-4.293z"},child:[]}]})(i)}function BiChevronRight(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M10.707 17.707 16.414 12l-5.707-5.707-1.414 1.414L13.586 12l-4.293 4.293z"},child:[]}]})(i)}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 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 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,...f}=n,g=(_,x)=>{let y=toFixedFloat(_),E=i.merge({length:x!==UNIT_CENTIMETER?convert(y).from(x).to(UNIT_CENTIMETER):y,_length:_,_unit:x});return d?d(E,s,o,a).then(b=>e(b)):e(E)};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:_=>g(_.target.value,h),onValid:t,...f}),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:_=>{},children:UNITS_LENGTH.map(_=>jsxRuntimeExports.jsx("option",{value:_,children:_},_))})})]})]})}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})})]})})})}const PLACEHOLDER_SIZE=100,PLACEHOLDER_THICKNESS=15,STROKE="#9CA3AF",FILL="rgba(156, 163, 175, 0.18)",SELECTED_STROKE="#1ca6fc",outline=i=>({fill:FILL,stroke:i?SELECTED_STROKE:STROKE,strokeWidth:2,strokeDasharray:"8 6",vectorEffect:"non-scaling-stroke"}),Placeholder=({x:i,y:e,width:t,height:n,selected:s})=>jsxRuntimeExports.jsxs("g",{children:[jsxRuntimeExports.jsx("rect",{x:i,y:e,width:t,height:n,style:outline(s)}),jsxRuntimeExports.jsx("path",{d:`M${i} ${e} L${i+t} ${e+n} M${i} ${e+n} L${i+t} ${e}`,style:{...outline(s),fill:"none",strokeDasharray:"none"}})]}),lineLength=(i,e)=>{var s,o,a,l,c,u,h,d;const t=(l=(s=e==null?void 0:e.vertices)==null?void 0:s.get)==null?void 0:l.call(s,(a=(o=i.vertices)==null?void 0:o.get)==null?void 0:a.call(o,0)),n=(d=(c=e==null?void 0:e.vertices)==null?void 0:c.get)==null?void 0:d.call(c,(h=(u=i.vertices)==null?void 0:u.get)==null?void 0:h.call(u,1));return!t||!n?PLACEHOLDER_SIZE:Math.hypot(n.x-t.x,n.y-t.y)},propertyLength=(i,e,t)=>{var n,s;return((s=(n=i.properties)==null?void 0:n.getIn)==null?void 0:s.call(n,[e,"length"]))??t},renderPlaceholder=(i,e)=>{var n;const t=!!i.selected;switch(i.prototype){case"lines":{const s=lineLength(i,e),o=propertyLength(i,"thickness",PLACEHOLDER_THICKNESS);return jsxRuntimeExports.jsx(Placeholder,{x:0,y:-o/2,width:s,height:o,selected:t})}case"areas":{let s="";return(n=i.vertices)==null||n.forEach((o,a)=>{var c,u;const l=(u=(c=e==null?void 0:e.vertices)==null?void 0:c.get)==null?void 0:u.call(c,o);l&&(s+=`${a?"L":"M"}${l.x} ${l.y} `)}),s?jsxRuntimeExports.jsx("path",{d:`${s}Z`,style:outline(t)}):null}case"holes":{const s=propertyLength(i,"width",PLACEHOLDER_SIZE),o=propertyLength(i,"height",PLACEHOLDER_SIZE);return jsxRuntimeExports.jsx(Placeholder,{x:-s/2,y:-o/2,width:s,height:o,selected:t})}default:return jsxRuntimeExports.jsx(Placeholder,{x:-PLACEHOLDER_SIZE/2,y:-PLACEHOLDER_SIZE/2,width:PLACEHOLDER_SIZE,height:PLACEHOLDER_SIZE,selected:t})}};function unknownElement(i){return{name:i,prototype:"",info:{title:i,tag:[],category:"",description:"Not in the current catalog",image:"",visibility:{catalog:!1,layerElementsVisible:!0}},properties:{},render2D:((e,t)=>renderPlaceholder(e,t)),render3D:()=>Promise.resolve(new Object3D),updateRender3D:(e,t,n,s)=>Promise.resolve(s)}}class Catalog{constructor(e=UNIT_CENTIMETER){ze(this,"elements");ze(this,"categories");ze(this,"propertyTypes");ze(this,"missingElements");ze(this,"unit");this.elements={},this.categories={root:{name:"root",label:"/",elements:[],categories:[]}},this.propertyTypes={},this.missingElements=new Map,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){return this.hasElement(e)?this.elements[e]:(this.missingElements.has(e)||(this.missingElements.set(e,unknownElement(e)),console.warn(`[floor-planner] Element "${e}" is in the plan but not in the catalog — drawing a placeholder. Register it to restore it.`)),this.missingElements.get(e))}getElementsOfPrototype(e){return Object.values(this.elements).filter(t=>t.prototype===e)}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)}}const 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})=>jsxRuntimeExports.jsx("div",{role:"tablist",className:"grid w-full overflow-hidden rounded-lg border border-[color:var(--properties-input-border,#E5E7EB)] bg-[color:var(--panel-property-background,#F3F4F6)]",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map(n=>{const s=n.value===i;return jsxRuntimeExports.jsx("button",{role:"tab","aria-selected":s,className:cn("p-2 text-sm font-semibold capitalize transition-colors",s?"bg-[color:var(--dark-blue,#1ca6fc)] text-white":"bg-[color:var(--panel-property-background,#F3F4F6)] text-[color:var(--properties-color,#2F3033)]"),onClick:()=>t(n),children:n.label},n.value)})}),NestedSelect=({options:i,selections:e,level:t,onChange:n})=>{var s,o;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(FormSelect,{value:e[t]||"all",onChange:a=>n(t,a.target.value),children:i.map(a=>jsxRuntimeExports.jsx("option",{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})]})},CatalogPicker=({catalog:i,page:e,containerSelector:t=".fp-toolbar-subpanel"})=>{const{setToast:n,selectToolDrawingLine:s,selectToolDrawingItem:o,selectToolDrawingHole:a,pushLastSelectedCatalogElementToHistory:l}=useReactPlannerStore(),[c,u]=React.useState([]),[h,d]=React.useState(""),[p,f]=React.useState([]),[g,_]=React.useState(["all"]),[x,y]=React.useState([]),[E,b]=React.useState("");React.useEffect(()=>{b(""),_(["all"]);const R=i.getCategory(e).elements.filter(A=>A.info.visibility?A.info.visibility.catalog:!0);if(y(R),e==="objects"){const A=Array.from(new Set(R.map(k=>k.info.category).filter(Boolean))),P=A[0]??"",B=R.filter(k=>k.info.category===P);d(P),u(A),f(getCatalogOptions(B))}else d(""),u([]),f([])},[e,i]);const v=w=>{e!=="objects"&&n({text:`Cancel placing ${e}`}),setTimeout(()=>{switch(w.prototype){case"lines":s(w.name);break;case"items":o(w.name);break;case"holes":a(w.name);break}l(w)},0)},M=(w,R)=>{const A=[...g.slice(0,w),R];_(A)},T=(w,R)=>{w.preventDefault();const A=w.currentTarget.closest(t);if(!A)return;const P=()=>{v(R),k()},B=()=>k(),k=()=>{A.removeEventListener("mouseleave",P),document.removeEventListener("mouseup",B)};A.addEventListener("mouseleave",P),document.addEventListener("mouseup",B)},I=React.useMemo(()=>x.filter(w=>{const R=w.info.title.toLowerCase().includes(E.toLowerCase()),A=h?w.info.category===h:w,P=g.every(B=>B==="all"||w.info.tag.includes(B));return R&&A&&P}),[x,E,h,g]);return jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-0 flex-1 min-h-0",children:[jsxRuntimeExports.jsxs("div",{className:"fp-highlight",children:[c.length>1&&jsxRuntimeExports.jsx(SegmentedTabs,{selected:h,onChange:w=>{_(["all"]),d(w.value),f(getCatalogOptions(x.filter(R=>R.info.category===w.value)))},options:c.map(w=>({label:w,value:w}))}),p.length>0&&jsxRuntimeExports.jsx(NestedSelect,{options:p,level:0,selections:g,onChange:M}),jsxRuntimeExports.jsx(SearchInput,{noSpacing:!0,placeholder:"Search",value:E,onSearch:(w,R)=>{R.preventDefault(),R.stopPropagation(),b(w)}})]}),I.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:w=>w.stopPropagation(),children:I.map(w=>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:R=>T(R,w),children:jsxRuntimeExports.jsx("img",{draggable:!1,loading:"lazy",decoding:"async",className:"fp-item-image",alt:w.info.title,src:w.info.image})})}),jsxRuntimeExports.jsx("p",{className:"text-xs font-semibold capitalize",children:w.info.title})]},w.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"})})]})},SubPanelRow=({option:i})=>jsxRuntimeExports.jsxs("div",{className:cn("fp-subpanel-option",i.active&&"fp-subpanel-option--active",i.disabled&&"fp-subpanel-option--disabled"),onClick:()=>{var e;i.disabled||(e=i.onClick)==null||e.call(i)},children:[jsxRuntimeExports.jsx("span",{className:"fp-subpanel-option__icon",children:i.icon}),jsxRuntimeExports.jsx("span",{className:"fp-subpanel-option__label",children:i.label}),i.hasChildren&&jsxRuntimeExports.jsx("span",{className:"fp-subpanel-option__chevron",children:jsxRuntimeExports.jsx(BiChevronRight,{size:22})})]}),ToolbarSubPanel=({title:i,options:e,cta:t,emptyState:n,catalog:s,catalogPage:o,onBack:a,headerExtras:l})=>{const c=!!(s&&o);return jsxRuntimeExports.jsxs("div",{className:"fp-toolbar-subpanel",children:[jsxRuntimeExports.jsxs("header",{className:"fp-toolbar-subpanel__header",children:[a&&jsxRuntimeExports.jsx("div",{className:"fp-toolbar-subpanel__back",onClick:a,children:jsxRuntimeExports.jsx(BiChevronLeft,{size:22})}),jsxRuntimeExports.jsx("span",{className:"fp-toolbar-subpanel__title",children:i})]}),c&&s&&o?jsxRuntimeExports.jsx(CatalogPicker,{catalog:s,page:o}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[l&&jsxRuntimeExports.jsx("div",{className:"fp-toolbar-subpanel__extras",children:l}),t&&jsxRuntimeExports.jsx("div",{className:"fp-toolbar-subpanel__cta",children:t}),e&&e.length>0?jsxRuntimeExports.jsx("div",{className:"fp-toolbar-subpanel__body",children:e.map(u=>jsxRuntimeExports.jsx(SubPanelRow,{option:u},u.key))}):n&&jsxRuntimeExports.jsx("div",{className:"fp-toolbar-subpanel__body",children:n})]})]})};function HiOutlineFolder(i){return GenIcon({attr:{fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 12.75V12A2.25 2.25 0 0 1 4.5 9.75h15A2.25 2.25 0 0 1 21.75 12v.75m-8.69-6.44-2.12-2.12a1.5 1.5 0 0 0-1.061-.44H4.5A2.25 2.25 0 0 0 2.25 6v12a2.25 2.25 0 0 0 2.25 2.25h15A2.25 2.25 0 0 0 21.75 18V9a2.25 2.25 0 0 0-2.25-2.25h-5.379a1.5 1.5 0 0 1-1.06-.44Z"},child:[]}]})(i)}function HiOutlineMinus(i){return GenIcon({attr:{fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 12h14"},child:[]}]})(i)}function HiOutlinePlus(i){return GenIcon({attr:{fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"},child:[]}]})(i)}function HiOutlineWrenchScrewdriver(i){return GenIcon({attr:{fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.42 15.17 17.25 21A2.652 2.652 0 0 0 21 17.25l-5.877-5.877M11.42 15.17l2.496-3.03c.317-.384.74-.626 1.208-.766M11.42 15.17l-4.655 5.653a2.548 2.548 0 1 1-3.586-3.586l6.837-5.63m5.108-.233c.55-.164 1.163-.188 1.743-.14a4.5 4.5 0 0 0 4.486-6.336l-3.276 3.277a3.004 3.004 0 0 1-2.25-2.25l3.276-3.276a4.5 4.5 0 0 0-6.336 4.486c.091 1.076-.071 2.264-.904 2.95l-.102.085m-1.745 1.437L5.909 7.5H4.5L2.25 3.75l1.5-1.5L7.5 4.5v1.409l4.26 4.26m-1.745 1.437 1.745-1.437m6.615 8.206L15.75 15.75M4.867 19.125h.008v.008h-.008v-.008Z"},child:[]}]})(i)}const ZOOM_STEP=1.2,ZoomControls=({subPanelOpen:i=!1})=>{const{planner:e,viewer:t,viewer3D:n,fitViewerToScene:s}=useReactPlannerStore(),{mode:o,zoom:a}=e,l=o===MODE_3D_VIEW,c=d=>{const p=d==="in"?ZOOM_STEP:1/ZOOM_STEP;if(l){n==null||n.zoomBy(p);return}if(!t)return;const f=a<=MIN_ZOOM+.01,g=a>=MAX_ZOOM-.01;f&&d==="out"||g&&d==="in"||typeof t.zoomOnViewerCenter=="function"&&t.zoomOnViewerCenter(p)},u=()=>{l?n==null||n.fitToScene():s()},h=l?12:i?414:102;return jsxRuntimeExports.jsxs("div",{className:"fp-zoom-controls",style:{left:h},children:[jsxRuntimeExports.jsx(ToolbarButton,{active:!1,tooltipPosition:"left",tooltip:"Zoom in",onClick:()=>c("in"),children:jsxRuntimeExports.jsx(HiOutlinePlus,{size:20})}),jsxRuntimeExports.jsx(ToolbarButton,{active:!1,tooltipPosition:"left",tooltip:"Zoom out",onClick:()=>c("out"),children:jsxRuntimeExports.jsx(HiOutlineMinus,{size:20})}),jsxRuntimeExports.jsx(ToolbarButton,{active:!1,tooltipPosition:"left",tooltip:"Fit to view",onClick:u,children:jsxRuntimeExports.jsx(MdMyLocation,{size:20})})]})},NumberStepper=({label:i,value:e,unit:t="cm",step:n=1,min:s=0,max:o=1e4,onChange:a})=>{const l=c=>Math.min(o,Math.max(s,c));return jsxRuntimeExports.jsxs("label",{className:"fp-number-stepper",children:[jsxRuntimeExports.jsx("span",{className:"fp-number-stepper__label",children:i}),jsxRuntimeExports.jsxs("div",{className:"fp-number-stepper__control",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"fp-number-stepper__btn",onClick:()=>a(l(e-n)),"aria-label":`Decrease ${i}`,children:jsxRuntimeExports.jsx(HiOutlineMinus,{size:14})}),jsxRuntimeExports.jsxs("div",{className:"fp-number-stepper__value",children:[e,t?` ${t}`:""]}),jsxRuntimeExports.jsx("button",{type:"button",className:"fp-number-stepper__btn",onClick:()=>a(l(e+n)),"aria-label":`Increase ${i}`,children:jsxRuntimeExports.jsx(HiOutlinePlus,{size:14})})]})]})},PREVIEW_WIDTH=260,PREVIEW_HEIGHT=160,ProjectMiniMap=({onHoverChange:i})=>{const{planner:e,focusOnArea:t}=useReactPlannerStore(),[n,s]=React.useState(null),[o,a]=React.useState(null),l=React.useRef(null),{areas:c,walls:u,bounds:h}=React.useMemo(()=>{const I=e.get("scene").get("layers"),w=[],R=[];let A=1/0,P=1/0,B=-1/0,k=-1/0,W=!1;const Y=($,ee)=>{typeof $!="number"||typeof ee!="number"||(A=Math.min(A,$),P=Math.min(P,ee),B=Math.max(B,$),k=Math.max(k,ee),W=!0)};return I.forEach($=>{const ee=$.get("id");$.get("areas").forEach(G=>{const K=[];if(G.get("vertices").forEach(j=>{const ie=$.getIn(["vertices",j]);if(!ie)return;const Z=ie.get("x"),ue=ie.get("y");Y(Z,ue),K.push({x:Z,y:ue})}),K.length<3)return;const F=G.getIn(["properties","patternColor"])||SharedStyle.AREA_MESH_COLOR.unselected,X=deriveAreaLabel(G,$),se=areapolygon(K),me=K.reduce((j,ie)=>j+ie.x,0)/K.length,Me=K.reduce((j,ie)=>j+ie.y,0)/K.length;w.push({layerID:ee,areaID:G.get("id"),color:F,points:K.map(j=>`${j.x},${j.y}`).join(" "),label:X,area:se/1e4,center:{x:me,y:Me}})}),$.get("lines").forEach(G=>{const[K,F]=G.get("vertices").toArray(),X=$.getIn(["vertices",K]),se=$.getIn(["vertices",F]);!X||!se||(Y(X.get("x"),X.get("y")),Y(se.get("x"),se.get("y")),R.push({x1:X.get("x"),y1:X.get("y"),x2:se.get("x"),y2:se.get("y"),thickness:G.getIn(["properties","thickness","length"])??10}))})}),{areas:w,walls:R,bounds:W?{minX:A,minY:P,maxX:B,maxY:k}:null}},[e]);if(!h||c.length+u.length===0)return jsxRuntimeExports.jsx("div",{className:"fp-project-minimap fp-project-minimap--empty",children:jsxRuntimeExports.jsx("p",{children:"No areas yet, draw a room to see it here."})});const d=Math.max(1,h.maxX-h.minX),p=Math.max(1,h.maxY-h.minY),f=Math.max(d,p)*.06,g=h.minX-f,_=h.minY-f,x=d+f*2,y=p+f*2,b=1/Math.min(PREVIEW_WIDTH/x,PREVIEW_HEIGHT/y),v=(T,I)=>{if(s(T),T){const w=c.find(R=>R.areaID===T);w&&(i==null||i({layerID:w.layerID,areaID:w.areaID,label:w.label,area:w.area}))}else i==null||i(null);if(I&&l.current){const w=l.current.getBoundingClientRect();a({x:I.clientX-w.left,y:I.clientY-w.top})}else a(null)},M=n?c.find(T=>T.areaID===n):null;return jsxRuntimeExports.jsx("div",{className:"fp-project-minimap",children:jsxRuntimeExports.jsxs("div",{className:"fp-project-minimap__stage",children:[jsxRuntimeExports.jsx("svg",{ref:l,viewBox:`${g} ${_} ${x} ${y}`,width:PREVIEW_WIDTH,height:PREVIEW_HEIGHT,preserveAspectRatio:"xMidYMid meet",children:jsxRuntimeExports.jsxs("g",{transform:`translate(0, ${h.maxY+h.minY}) scale(1, -1)`,children:[c.map(T=>{const I=T.areaID===n;return jsxRuntimeExports.jsx("polygon",{points:T.points,fill:I?SharedStyle.MESH_SELECTED:T.color,stroke:"rgba(0,0,0,0.15)",strokeWidth:b,style:{cursor:"pointer",transition:"fill 0.15s ease"},onMouseEnter:w=>v(T.areaID,w),onMouseMove:w=>v(T.areaID,w),onMouseLeave:()=>v(null),onClick:()=>t(T.layerID,T.areaID)},T.areaID)}),u.map((T,I)=>jsxRuntimeExports.jsx("line",{x1:T.x1,y1:T.y1,x2:T.x2,y2:T.y2,stroke:"rgba(0,0,0,0.55)",strokeWidth:Math.max(T.thickness,b*2),strokeLinecap:"butt"},I))]})}),M&&o&&jsxRuntimeExports.jsx("div",{className:"fp-project-minimap__tooltip",style:{left:o.x,top:o.y},children:M.label})]})})},ProjectPanel=()=>{const{planner:i,plan:e}=useReactPlannerStore(),[t,n]=React.useState(null),{totalArea:s,areaCount:o}=React.useMemo(()=>{const l=i.get("scene").get("layers");let c=0,u=0;return l.forEach(h=>{h.get("areas").forEach(d=>{const p=d.get("vertices").toArray().map(f=>{const g=h.getIn(["vertices",f]);return[g?g.get("x"):0,g?g.get("y"):0]});p.length<3||(c+=Math.abs(areapolygon(p)),u+=1)})}),{totalArea:c/1e4,areaCount:u}},[i]);return jsxRuntimeExports.jsxs("div",{className:"fp-project-panel",children:[(e==null?void 0:e.planTitle)&&jsxRuntimeExports.jsxs("div",{className:"fp-project-info",children:[jsxRuntimeExports.jsx("span",{className:"fp-project-info__label",children:"Design Name"}),jsxRuntimeExports.jsx("span",{className:"fp-project-info__value",children:e.planTitle})]}),jsxRuntimeExports.jsx(ProjectMiniMap,{onHoverChange:n}),jsxRuntimeExports.jsx("div",{className:"fp-project-summary",children:t?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("span",{className:"fp-project-summary__label",children:t.label}),jsxRuntimeExports.jsxs("span",{className:"fp-project-summary__value",children:[t.area.toFixed(2)," m²"]})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("span",{className:"fp-project-summary__label",children:o===1?"1 area":`${o} areas`}),jsxRuntimeExports.jsxs("span",{className:"fp-project-summary__value",children:[s.toFixed(2)," m²"]})]})})]})};function GiCube(i){return GenIcon({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 24.585L51.47 118.989 256 213.394l204.53-94.405zM38.998 133.054v258.353L247 487.415V229.063zm434.004 0L265 229.062v258.353l208.002-96.008z"},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"}),RAIL_ITEMS=[{key:"project",label:"Project",icon:jsxRuntimeExports.jsx(HiOutlineFolder,{})},{key:"build",label:"Build",icon:jsxRuntimeExports.jsx(HiOutlineWrenchScrewdriver,{})},{key:"objects",label:"Objects",icon:jsxRuntimeExports.jsx(MdOutlineChair,{})}];function Toolbar({catalog:i,has3dView:e}){const{planner:t,setMode:n,setToast:s,selectTool3DView:o,unselectAll:a,selectToolDrawingLine:l,selectToolDrawingSurface:c,selectToolDrawingRoom:u,updateRoomDrawingProperties:h,showDimensions:d,setShowDimensions:p}=useReactPlannerStore(),{mode:f,alterate:g,drawingSupport:_}=t,[x,y]=React.useState("build"),[E,b]=React.useState(null),[v,M]=React.useState(15),[T,I]=React.useState(280),w=_.get("type"),R=[MODE_WAITING_DRAWING_LINE,MODE_DRAWING_LINE].includes(f)&&w==="wall",A=[MODE_WAITING_DRAWING_SURFACE,MODE_DRAWING_SURFACE].includes(f),P=f===MODE_DRAWING_HOLE,B=[MODE_WAITING_DRAWING_ROOM,MODE_DRAWING_ROOM].includes(f),k=B||R;React.useEffect(()=>{k&&h({thickness:v,height:T})},[v,T,k,h]);const W=F=>{if(x===F){y(null),b(null);return}y(F),b(null)},Y=()=>{s({text:"Cancel drawing"}),u({thickness:v,height:T})},$=()=>{s({text:"Cancel drawing"}),l("wall",{thickness:v,height:T})},ee=React.useMemo(()=>[{key:"draw-room",label:"Draw Room",icon:jsxRuntimeExports.jsx(GiCube,{}),active:B,onClick:Y},{key:"draw-wall",label:"Draw Wall",icon:jsxRuntimeExports.jsx(LuBrickWall,{}),active:R,onClick:$},{key:"draw-surface",label:"Draw Surface",icon:jsxRuntimeExports.jsx(PiWall,{}),active:A,onClick:()=>{s({text:"Cancel drawing"}),c("surface")}},{key:"place-doors",label:"Place Doors",icon:jsxRuntimeExports.jsx(FaDoorOpen,{}),active:P&&w!=="window",hasChildren:!0,onClick:()=>b("doors")},{key:"place-windows",label:"Place Windows",icon:jsxRuntimeExports.jsx(MdOutlineWindow,{}),active:P&&w==="window",hasChildren:!0,onClick:()=>b("windows")}],[R,A,P,B,w,c,s,Y,$]),G=jsxRuntimeExports.jsx("p",{className:"text-sm text-gray-500 px-3 py-6 text-center",children:"Coming soon."}),K=()=>{if(!x)return null;switch(x){case"build":if(E){const F=E==="doors"?"Place Doors":"Place Windows";return jsxRuntimeExports.jsx(ToolbarSubPanel,{title:F,catalog:i,catalogPage:E,onBack:()=>b(null)})}return jsxRuntimeExports.jsx(ToolbarSubPanel,{title:"Build",options:ee,headerExtras:k?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(NumberStepper,{label:"Thickness",value:v,onChange:M,min:1,max:100}),jsxRuntimeExports.jsx(NumberStepper,{label:"Wall Height",value:T,onChange:I,step:10,min:50,max:1e3})]}):void 0});case"objects":return jsxRuntimeExports.jsx(ToolbarSubPanel,{title:"Objects",catalog:i,catalogPage:"objects"});case"project":return jsxRuntimeExports.jsx(ToolbarSubPanel,{title:"Project",emptyState:jsxRuntimeExports.jsx(ProjectPanel,{})});case"info":return jsxRuntimeExports.jsx(ToolbarSubPanel,{title:"Info",emptyState:G});case"styleboards":return jsxRuntimeExports.jsx(ToolbarSubPanel,{title:"Styleboards",emptyState:G});case"finishes":return jsxRuntimeExports.jsx(ToolbarSubPanel,{title:"Finishes",emptyState:G});case"help":return jsxRuntimeExports.jsx(ToolbarSubPanel,{title:"Help",emptyState:G});default:return null}};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[![MODE_3D_VIEW].includes(f)&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ToolbarRail,{items:RAIL_ITEMS,active:x,onChange:W}),K()]}),jsxRuntimeExports.jsx("div",{className:"fp-toolbar-utility",children:e&&([MODE_3D_VIEW].includes(f)?jsxRuntimeExports.jsx(ToolbarButton,{active:!1,tooltipPosition:"top",tooltip:"2D View",onClick:()=>{a(),setTimeout(()=>n(MODE_IDLE$1),0)},children:jsxRuntimeExports.jsx(Icon2D,{style:{color:g?"#FF9800":""}})}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ToolbarButton,{active:!1,tooltipPosition:"top",tooltip:"3D View",onClick:o,children:jsxRuntimeExports.jsx(Icon3D,{})}),jsxRuntimeExports.jsx(ToolbarButton,{active:d,tooltipPosition:"top",tooltip:"Show dimensions",onClick:()=>{[MODE_3D_VIEW].includes(f)||p(!d)},children:jsxRuntimeExports.jsx(RxDimensions,{size:22})})]}))}),jsxRuntimeExports.jsx(ZoomControls,{subPanelOpen:x!==null})]})}const localStorage$1=window.hasOwnProperty("localStorage")?window.localStorage:!1,TIMEOUT_DELAY=500;function autosave(i,e){return(t,n,s)=>{let o,a=null;if(e=e||TIMEOUT_DELAY,!i||!localStorage$1)return;if(n){t.setPlan(n);const c=n.floors[0].floorDesign;o=JSON.parse(c)}else if(localStorage$1.getItem(i)!==null){const c=localStorage$1.getItem(i);o=JSON.parse(c)}o&&t.loadProject(o);const l=useReactPlannerStore.subscribe(c=>{a&&clearTimeout(a),a=setTimeout(()=>{const u=localStorage$1.getItem(i),h=Project.unselectAll(c.planner).updatedState,d=JSON.stringify(h.scene.toJS());if(u!==d&&(localStorage$1.setItem(i,d),c.plan))try{const p=c.plan.floors[c.activeFloor];s&&s({floor:{floorID:p.floorID,title:p.floorTitle,description:p.floorDescription,design:d}})}catch{}},e)});return()=>{a&&clearTimeout(a),l()}}}function keyboard(){return i=>{const e=n=>{const s=i.planner,o=s.get("mode");switch(n.keyCode){case KEYBOARD_BUTTON_CODE.BACKSPACE:case KEYBOARD_BUTTON_CODE.DELETE:{[MODE_IDLE$1,MODE_3D_FIRST_PERSON,MODE_3D_VIEW].includes(o)&&i.remove();break}case KEYBOARD_BUTTON_CODE.ESC:{i.rollback();break}case KEYBOARD_BUTTON_CODE.Z:{(n.getModifierState("Control")||n.getModifierState("Meta"))&&(n.getModifierState("Shift")?i.redo():i.undo());break}case KEYBOARD_BUTTON_CODE.ALT:{MODE_SNAPPING.includes(o)&&i.toggleSnap(s.snapMask.merge({SNAP_POINT:!1,SNAP_LINE:!1,SNAP_SEGMENT:!1,SNAP_GRID:!1,SNAP_GUIDE:!1,tempSnapConfiguartion:s.snapMask.toJS()}));break}case KEYBOARD_BUTTON_CODE.C:{let a=s.getIn(["scene","selectedLayer"]),l=s.getIn(["scene","layers",a,"selected"]);if((o===MODE_IDLE$1||o===MODE_3D_VIEW)&&(l.holes.size||l.areas.size||l.items.size||l.lines.size)){if(l.holes.size){let c=s.getIn(["scene","layers",a,"holes",l.holes.get(0)]);i.copyProperties(c.get("properties"))}else if(l.areas.size){const c=s.getIn(["scene","layers",a,"areas",l.areas.get(0)]);i.copyProperties(c.properties)}else if(l.items.size){const c=s.getIn(["scene","layers",a,"items",l.items.get(0)]);i.copyProperties(c.properties)}else if(l.lines.size){const c=s.getIn(["scene","layers",a,"lines",l.lines.get(0)]);i.copyProperties(c.properties)}}break}case KEYBOARD_BUTTON_CODE.V:{i.pasteProperties();break}case KEYBOARD_BUTTON_CODE.CTRL:{i.setAlterateState();break}}},t=n=>{const s=i.planner,o=s.get("mode");switch(n.keyCode){case KEYBOARD_BUTTON_CODE.ALT:{MODE_SNAPPING.includes(o)&&i.toggleSnap(s.snapMask.merge(s.snapMask.get("tempSnapConfiguartion")));break}case KEYBOARD_BUTTON_CODE.CTRL:{i.setAlterateState();break}}};return window.addEventListener("keydown",e),window.addEventListener("keyup",t),()=>{window.removeEventListener("keydown",e),window.removeEventListener("keyup",t)}}}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,theme:s,setTheme:o,showGrid:a,setShowGrid:l}=useReactPlannerStore(),{snapMask:c}=t,u=React.useRef(null);React.useEffect(()=>{if(i){const{x:p,y:f}=i.rect;u.current={top:f+TOP_OFFSET,left:p+LEFT_OFFSET}}},[i]);const h=()=>{e()},d=p=>n(c.merge(p));return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[i&&jsxRuntimeExports.jsx("div",{className:"fixed inset-0 bg-black/30 z-10",onClick:h}),jsxRuntimeExports.jsxs("div",{style:i&&i.rect?{top:i.rect.y+TOP_OFFSET,left:i.rect.x+LEFT_OFFSET}:u.current?u.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-[340px] 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:c.get(SNAP_POINT),toggleOn:()=>{d({SNAP_POINT:!0})},toggleOff:()=>{d({SNAP_POINT:!1})}}),jsxRuntimeExports.jsx(ToggleSetting,{toggleOn:()=>{d({SNAP_LINE:!0})},toggleOff:()=>{d({SNAP_LINE:!1})},toggleState:c.get(SNAP_LINE),title:"Snap to Line"}),jsxRuntimeExports.jsx(ToggleSetting,{toggleOn:()=>{d({SNAP_SEGMENT:!0})},toggleOff:()=>{d({SNAP_SEGMENT:!1})},toggleState:c.get(SNAP_SEGMENT),title:"Snap to Segment"}),jsxRuntimeExports.jsx(ToggleSetting,{toggleOn:()=>{d({SNAP_GRID:!0})},toggleOff:()=>{d({SNAP_GRID:!1})},toggleState:c.get(SNAP_GRID),title:"Snap to Grid"}),jsxRuntimeExports.jsx(ToggleSetting,{toggleOn:()=>{d({SNAP_GUIDE:!0})},toggleOff:()=>{d({SNAP_GUIDE:!1})},toggleState:c.get(SNAP_GUIDE),title:"Snap to Guide"}),jsxRuntimeExports.jsx(ToggleSetting,{title:"Show Grid",toggleState:a,toggleOn:()=>l(!0),toggleOff:()=>l(!1)}),jsxRuntimeExports.jsx(ToggleSetting,{title:"Dark Mode",toggleState:s==="dark",toggleOn:()=>o("dark"),toggleOff:()=>o("light")})]})]})]})},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 f=p.target.value.trim();if(f&&f!==(s==null?void 0:s.planTitle)){o({...s,planTitle:f});try{e&&e({title:f,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] pr-3 pl-2.5 w-full select-none cursor-default top-0 m-0",children:[jsxRuntimeExports.jsx("div",{className:"min-w-[122px]",children:jsxRuntimeExports.jsx(ToolbarButton,{className:"border border-white rounded",active:!1,tooltip:"Go Back",onClick:()=>{i&&i()},children:jsxRuntimeExports.jsx(BiChevronLeft,{})})}),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-4",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,y){!u&&a&&o&&l.size()===0&&f(),l.add(x,y)}function d(){for(u=!0;l.size();){var x=l;l=e(),x.process()}u=!1}function p(x){u||(x===void 0&&(x=o),c&&(g(c),c=null),x?f():d())}function f(){c=_(d)}function g(x){var y=clearTimeout;return y(x)}function _(x){var y=function(E){return setTimeout(E,0)};return y(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 f=c(h);if(!f)throw new Error("Element is not detectable by this strategy.");f.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 f(g,_){var x=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"]),y=!1,E=window.getComputedStyle(g),b=g.offsetWidth,v=g.offsetHeight;s(g).startSize={width:b,height:v};function M(){function T(){if(E.position==="static"){g.style.setProperty("position","relative",h.important?"important":"");var R=function(A,P,B,k){function W($){return $.replace(/[^-\d\.]/g,"")}var Y=B[k];Y!=="auto"&&W(Y)!=="0"&&(A.warn("An element that is positioned static has style."+k+"="+Y+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+k+" will be set to 0. Element: ",P),P.style.setProperty(k,"0",h.important?"important":""))};R(t,g,E,"top"),R(t,g,E,"right"),R(t,g,E,"bottom"),R(t,g,E,"left")}}function I(){y||T();function R(P,B){if(!P.contentDocument){var k=s(P);k.checkForObjectDocumentTimeoutId&&window.clearTimeout(k.checkForObjectDocumentTimeoutId),k.checkForObjectDocumentTimeoutId=setTimeout(function(){k.checkForObjectDocumentTimeoutId=0,R(P,B)},100);return}B(P.contentDocument)}var A=this;R(A,function(B){_(g)})}E.position!==""&&(T(),y=!0);var w=document.createElement("object");w.style.cssText=x,w.tabIndex=-1,w.type="text/html",w.setAttribute("aria-hidden","true"),w.onload=I,i.isIE()||(w.data="about:blank"),s(g)&&(g.appendChild(w),s(g).object=w,i.isIE()&&(w.data="about:blank"))}n?n.add(M):M()}i.isIE(8)?p(d):f(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 T=e.important?" !important; ":"; ";return(M.join(T)+T).trim()}function d(){var M=500,T=500,I=document.createElement("div");I.style.cssText=h(["position: absolute","width: "+M*2+"px","height: "+T*2+"px","visibility: hidden","margin: 0","padding: 0"]);var w=document.createElement("div");w.style.cssText=h(["position: absolute","width: "+M+"px","height: "+T+"px","overflow: scroll","visibility: none","top: "+-M*3+"px","left: "+-T*3+"px","visibility: hidden","margin: 0","padding: 0"]),w.appendChild(I),document.body.insertBefore(w,document.body.firstChild);var R=M-w.clientWidth,A=T-w.clientHeight;return document.body.removeChild(w),{width:R,height:A}}function p(M,T,I){function w(B,k){k=k||function(Y){M.head.appendChild(Y)};var W=M.createElement("style");return W.innerHTML=B,W.id=T,k(W),W}if(!M.getElementById(T)){var R=I+"_animation",A=I+"_animation_active",P=`/* Created by the element-resize-detector library. */
3931
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL MAGENTA OR PERSONS OR BODIES IN CHARGE OF ADMINISTRATION AND MAINTENANCE OF THE FONT SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.`,manufacturer_name:"Μagenta ltd",font_sub_family_name:"Regular"},descender:-334,familyName:"Helvetiker",lineHeight:1522,underlineThickness:50};function gridHorizontalStreak(i,e,t,n){const s=t.properties.get("step"),o=t.properties.has("color")?List([t.properties.get("color")]):t.properties.get("colors"),a=new Object3D;a.name="streak";let l=0;for(let c=0;c<=e;c+=s){const u=[new Vector3(0,0,-c),new Vector3(i,0,-c)],h=new BufferGeometry().setFromPoints(u),d=o.get(l%o.size),p=new LineBasicMaterial({color:d}),f=new LineSegments(h,p);a.add(f),a.add(new LineSegments(h,p)),l++}return a}function gridVerticalStreak(i,e,t,n){const s=t.properties.get("step"),o=t.properties.has("color")?List([t.properties.get("color")]):t.properties.get("colors"),a=new Object3D;a.name="streak";let l=0;for(let c=0;c<=i;c+=s){const u=[new Vector3(c,0,0),new Vector3(c,0,-e)],h=new BufferGeometry().setFromPoints(u),d=o.get(l%o.size),p=new LineBasicMaterial({color:d});a.add(new LineSegments(h,p)),l++}return a}const MIN_GRID=2e3,PADDING=1e3,MAX_GRID=4e4;function contentGridExtent(i){const e=i,t=e.get?e.get("layers"):e.layers;let n=1/0,s=1/0,o=-1/0,a=-1/0,l=!1;const c=(_,x)=>{typeof _!="number"||typeof x!="number"||!isFinite(_)||!isFinite(x)||(n=Math.min(n,_),s=Math.min(s,x),o=Math.max(o,_),a=Math.max(a,x),l=!0)};t.forEach(_=>{const x=_.get("vertices");_.get("lines").forEach(y=>{y.get("vertices").forEach(E=>{const b=x.get(E);b&&c(b.get("x"),b.get("y"))})}),_.get("items").forEach(y=>{c(y.get("x"),y.get("y"))})});const u=(()=>{var y,E,b,v,M;const _=e.get?e.get("grids"):e.grids,x=((y=_==null?void 0:_.first)==null?void 0:y.call(_))??((v=(E=_==null?void 0:_.valueSeq)==null?void 0:(b=E.call(_)).first)==null?void 0:v.call(b));return((M=x==null?void 0:x.properties)==null?void 0:M.get("step"))??20})(),h=_=>Math.ceil(_/u)*u;if(!l)return{offsetX:0,offsetZ:0,gridW:MIN_GRID,gridH:MIN_GRID};const d=Math.min(MAX_GRID,Math.max(MIN_GRID,h(o-n+PADDING*2))),p=Math.min(MAX_GRID,Math.max(MIN_GRID,h(a-s+PADDING*2))),f=(n+o)/2,g=(s+a)/2;return{offsetX:f-d/2,offsetZ:g-p/2,gridW:d,gridH:p}}function createGrid(i){const e=new Object3D;e.name="grid",new FontLoader().parse(HELVETIKER);const{grids:n}=i,{offsetX:s,offsetZ:o,gridW:a,gridH:l}=contentGridExtent(i);return n.forEach(c=>{switch(c.type){case"horizontal-streak":e.add(gridHorizontalStreak(a,l,c));break;case"vertical-streak":e.add(gridVerticalStreak(a,l,c));break}}),e.position.x=s,e.position.z=-o,e.position.y=-1,e}function disposeGeometry(i){i&&i.dispose&&i.dispose()}function disposeTexture(i){i&&i.dispose&&i.dispose()}function disposeMaterial(i){if(i){if(Array.isArray(i)){i.forEach(e=>disposeMaterial(e));return}for(const e in i){const t=i[e];t instanceof Texture&&disposeTexture(t)}i.dispose()}}function disposeMesh(i){(i instanceof Mesh||i instanceof BoxHelper||i instanceof LineSegments)&&(disposeGeometry(i.geometry),disposeMaterial(i.material),i.geometry=null,i.material=null)}function disposeScene(i){i.traverse(e=>{disposeMesh(e)})}function disposeObject(i){i.traverse(e=>{disposeMesh(e)})}function asColorMap(i){return i.colorSpace=SRGBColorSpace,i}function asDataMap(i){return i.colorSpace=NoColorSpace,i}const converted=new WeakMap,isConvertible=i=>i.isMeshPhongMaterial===!0||i.isMeshLambertMaterial===!0;function toStandard(i){const e=converted.get(i);if(e)return e;const t=i.shininess??0,n=new MeshStandardMaterial({name:i.name,color:i.color,map:i.map,roughness:MathUtils.clamp(1-Math.sqrt(Math.min(t,200)/200),.65,1),metalness:0,emissive:i.emissive,emissiveMap:i.emissiveMap,normalMap:i.normalMap,normalScale:i.normalScale,bumpMap:i.bumpMap,bumpScale:i.bumpScale,alphaMap:i.alphaMap,aoMap:i.aoMap,side:i.side,transparent:i.transparent,opacity:i.opacity,alphaTest:i.alphaTest,vertexColors:i.vertexColors});return converted.set(i,n),n}const fixColorSpaces=i=>{i.map&&asColorMap(i.map),i.emissiveMap&&asColorMap(i.emissiveMap),i.specularMap&&asColorMap(i.specularMap),i.normalMap&&asDataMap(i.normalMap),i.roughnessMap&&asDataMap(i.roughnessMap),i.metalnessMap&&asDataMap(i.metalnessMap),i.aoMap&&asDataMap(i.aoMap)};function normalizeImportedMaterials(i){return i.traverse(e=>{const t=e;if(!t.isMesh||!t.material)return;const s=(Array.isArray(t.material)?t.material:[t.material]).map(o=>{const a=isConvertible(o)?toStandard(o):o;return fixColorSpaces(a),a.needsUpdate=!0,a});t.material=Array.isArray(t.material)?s:s[0]}),i}function enableShadows(i,{cast:e=!0,receive:t=!0}={}){return i.traverse(n=>{n.isMesh&&(n.castShadow=e,n.receiveShadow=t)}),i}function parseData(i,e,t){const n={sceneGraph:{unit:i.unit,layers:{},busyResources:{layers:{}},width:i.width,height:i.height,LODs:{}},plan:new Object3D,grid:createGrid(i),boundingBox:new Box3};n.plan.name="plan",n.grid.name="grid",n.boundingBox.setFromObject(n.grid);let s=[];return i.layers.forEach(o=>{(o.id===i.selectedLayer||o.visible)&&(s=s.concat(createLayerObjects(o,n,i,e,t)))}),updateBoundingBoxWhenSettled(s,n),n}function createLayerObjects(i,e,t,n,s){const o=[];return e.sceneGraph.layers[i.id]={id:i.id,lines:{},holes:{},areas:{},items:{},visible:i.visible,altitude:i.altitude},e.sceneGraph.busyResources.layers[i.id]={id:i.id,lines:{},holes:{},areas:{},items:{}},i.lines.forEach(a=>{o.push(addLine(t,e,i,a.id,s,n.linesActions)),a.holes.forEach(l=>{o.push(addHole(t,e,i,l,s,n.holesActions))})}),i.areas.forEach(a=>{o.push(addArea(t,e,i,a.id,s,n.areaActions))}),i.items.forEach(a=>{o.push(addItem(t,e,i,a.id,s,n.itemsActions))}),o}function updateScene(i,e,t,n,s,o){const a=n.map(c=>({op:c.op,path:c.path.split("/"),value:c.value}));let l=filterDiffs(a,e,t);return l=l.filter(({path:c})=>c[3]!=="selected"),l=l.filter(({path:c})=>c[1]!=="groups"),l.forEach(({op:c,path:u,value:h})=>{if(u[1]==="layers"){const d=e.getIn(["layers",u[2]]);if(u.length===3&&c==="remove")removeLayer(u[2],i);else if(u.length>3)switch(c){case"replace":replaceObject(u,d,i,s,e,t,o);break;case"add":addObject(u,d,i,s,e,t,o);break;case"remove":removeObject(u,d,i,s,e,t,o);break}}else if(u[1]==="selectedLayer"){const d=h,p=e.getIn(["layers",d]);if(!p.visible){const g=createLayerObjects(p,i,e,s,o);updateBoundingBoxWhenSettled(g,i)}const f=i.sceneGraph.layers[(t==null?void 0:t.selectedLayer)??""];if(f&&!f.visible){for(let g in f.lines)removeLine(i,f.id,g);for(let g in f.areas)removeArea(i,f.id,g);for(let g in f.items)removeItem(i,f.id,g);for(let g in f.holes)removeHole(i,f.id,g)}}}),i}function replaceObject(i,e,t,n,s,o,a){let l=[];switch(i[3]){case"vertices":if(i[5]!=="selected"){const f=e.getIn(["vertices",i[4]]);if((i[5]==="x"||i[5]==="y")&&(f.lines.forEach(g=>{const _=o.getIn(["layers",e.id,"lines",g,"holes"]);return _&&_.forEach(x=>{replaceObject([0,0,0,"holes",x,"selected"],e,t,n,s,o,a)}),replaceObject([0,0,0,"lines",g],e,t,n,s,o,a)}),f.areas.forEach(g=>replaceObject([0,0,0,"areas",g],e,t,n,s,o,a))),i[5]==="areas"){let g=f.getIn(["areas",~~i[6]]);replaceObject([0,0,0,"areas",g],e,t,n,s,o,a)}}break;case"holes":const c=e.getIn(["holes",i[4]]);if(a.getElement(c.type).updateRender3D)l.push(updateHole(s,o,t,e,i[4],i.slice(5),a,n.holesActions,()=>removeHole(t,e.id,c.id),()=>addHole(s,t,e,c.id,a,n.holesActions)));else{let f=c.line;i[5]==="selected"?(removeHole(t,e.id,c.id),l.push(addHole(s,t,e,c.id,a,n.holesActions))):(e.getIn(["lines",f,"holes"]).forEach(g=>{removeHole(t,e.id,g)}),removeLine(t,e.id,f),l.push(addLine(s,t,e,f,a,n.linesActions)),e.getIn(["lines",f,"holes"]).forEach(g=>{l.push(addHole(s,t,e,g,a,n.holesActions))}))}break;case"lines":const u=e.getIn(["lines",i[4]]);a.getElement(u.type).updateRender3D?l.push(updateLine(s,o,t,e,i[4],i.slice(5),a,n.linesActions,()=>removeLine(t,e.id,i[4]),()=>addLine(s,t,e,i[4],a,n.linesActions))):(removeLine(t,e.id,i[4]),l.push(addLine(s,t,e,i[4],a,n.linesActions)));break;case"areas":const h=e.getIn(["areas",i[4]]);a.getElement(h.type).updateRender3D?l.push(updateArea(s,o,t,e,i[4],i.slice(5),a,n.areaActions,()=>removeArea(t,e.id,i[4]),()=>addArea(s,t,e,i[4],a,n.areaActions))):(t.sceneGraph.layers[e.id].areas[i[4]]&&removeArea(t,e.id,i[4]),l.push(addArea(s,t,e,i[4],a,n.areaActions)));break;case"items":const d=e.getIn(["items",i[4]]);a.getElement(d.type).updateRender3D?l.push(updateItem(s,o,t,e,i[4],i.slice(5),a,n.itemsActions,()=>removeItem(t,e.id,i[4]),()=>addItem(s,t,e,i[4],a,n.itemsActions))):(removeItem(t,e.id,i[4]),l.push(addItem(s,t,e,i[4],a,n.itemsActions)));break;case"visible":if(e.visible)l=l.concat(createLayerObjects(e,t,s,n,a));else{let f=t.sceneGraph.layers[e.id];for(let g in f.lines)removeLine(t,e.id,g);for(let g in f.areas)removeArea(t,e.id,g);for(let g in f.items)removeItem(t,e.id,g);for(let g in f.holes)removeHole(t,e.id,g)}break;case"opacity":case"altitude":let p=t.sceneGraph.layers[e.id];for(let f in p.lines)removeLine(t,e.id,f);for(let f in p.areas)removeArea(t,e.id,f);for(let f in p.items)removeItem(t,e.id,f);for(let f in p.holes)removeHole(t,e.id,f);l=l.concat(createLayerObjects(e,t,s,n,a))}updateBoundingBoxWhenSettled(l,t)}function removeObject(i,e,t,n,s,o,a){let l=[];switch(i[3]){case"lines":const c=i[4];o.getIn(["layers",e.id,"lines",c,"holes"]).forEach(u=>{removeHole(t,e.id,u)}),removeLine(t,e.id,c),i.length>5&&(l.push(addLine(s,t,e,c,a,n.linesActions)),e.getIn(["lines",c,"holes"]).forEach(u=>{l.push(addHole(s,t,e,u,a,n.holesActions))}));break;case"areas":i.length===5&&removeArea(t,e.id,i[4]);break;case"items":i.length===5&&removeItem(t,e.id,i[4]);break}updateBoundingBoxWhenSettled(l,t)}function removeLayer(i,e){let t=e.sceneGraph.layers[i];for(let n in t.lines)removeLine(e,i,n);for(let n in t.areas)removeArea(e,i,n);for(let n in t.items)removeItem(e,i,n);for(let n in t.holes)removeHole(e,i,n);delete e.sceneGraph.layers[i]}function removeHole(i,e,t){if(i.sceneGraph.busyResources.layers[e].holes[t]){setTimeout(()=>removeHole(i,e,t),100);return}i.sceneGraph.busyResources.layers[e].holes[t]=!0;let n=i.sceneGraph.layers[e].holes[t];n&&(i.plan.remove(n),disposeObject(n),delete i.sceneGraph.layers[e].holes[t],delete i.sceneGraph.LODs[t],n=null,updateBoundingBox(i)),i.sceneGraph.busyResources.layers[e].holes[t]=!1}function removeLine(i,e,t){if(i.sceneGraph.busyResources.layers[e].lines[t]){setTimeout(()=>removeLine(i,e,t),100);return}i.sceneGraph.busyResources.layers[e].lines[t]=!0;let n=i.sceneGraph.layers[e].lines[t];n&&(i.plan.remove(n),disposeObject(n),delete i.sceneGraph.layers[e].lines[t],delete i.sceneGraph.LODs[t],n=null,updateBoundingBox(i)),i.sceneGraph.busyResources.layers[e].lines[t]=!1}function removeArea(i,e,t){if(i.sceneGraph.busyResources.layers[e].areas[t]){setTimeout(()=>removeArea(i,e,t),100);return}i.sceneGraph.busyResources.layers[e].areas[t]=!0;let n=i.sceneGraph.layers[e].areas[t];n&&(i.plan.remove(n),disposeObject(n),delete i.sceneGraph.layers[e].areas[t],delete i.sceneGraph.LODs[t],n=null,updateBoundingBox(i)),i.sceneGraph.busyResources.layers[e].areas[t]=!1}function removeItem(i,e,t){if(i.sceneGraph.busyResources.layers[e].items[t]){setTimeout(()=>removeItem(i,e,t),100);return}i.sceneGraph.busyResources.layers[e].items[t]=!0;let n=i.sceneGraph.layers[e].items[t];n&&(i.plan.remove(n),disposeObject(n),delete i.sceneGraph.layers[e].items[t],delete i.sceneGraph.LODs[t],n=null,updateBoundingBox(i)),i.sceneGraph.busyResources.layers[e].items[t]=!1}function addObject(i,e,t,n,s,o,a){if(i.length===5){let l=null,c=null;switch(i[3]){case"lines":l=addLine,c=n.linesActions;break;case"areas":l=addArea,c=n.areaActions;break;case"items":l=addItem,c=n.itemsActions;break;case"holes":l=addHole,c=n.holesActions;break}l&&updateBoundingBoxWhenSettled([l(s,t,e,i[4],a,c)],t)}}function addHole(i,e,t,n,s,o){const a=t.getIn(["holes",n]);return s.getElement(a.type).render3D(a,t,i).then(l=>{l instanceof LOD&&(e.sceneGraph.LODs[n]=l);const c=new Object3D;c.name="pivot",c.add(enableShadows(l));const u=t.getIn(["lines",a.line]);let h=t.vertices.get(u.vertices.get(0)),d=t.vertices.get(u.vertices.get(1)),p=a.offset;if(h.x>d.x){const T=h;h=d,d=T,p=1-p}let f=Math.sqrt(Math.pow(h.x-d.x,2)+Math.pow(h.y-d.y,2)),g=Math.asin((d.y-h.y)/f),_=new Box3().setFromObject(c),x=[(_.max.x-_.min.x)/2+_.min.x,(_.max.y-_.min.y)/2+_.min.y,(_.max.z-_.min.z)/2+_.min.z],y=a.properties.getIn(["altitude","length"]),E=a.properties.getIn(["height","length"]);const b=a.flipAlongWall?-1:1;c.scale.x=b;const v=b===-1?2*x[0]:0;c.rotation.y=g,c.position.x=h.x+(f*p+v)*Math.cos(g)-x[2]*Math.sin(g),c.position.y=y+E/2-x[1]+t.altitude,c.position.z=-h.y-(f*p+v)*Math.sin(g)-x[2]*Math.cos(g),e.plan.add(c),e.sceneGraph.layers[t.id].holes[a.id]=c,applyInteract(c,()=>o.selectHole(t.id,a.id));let M=t.opacity;a.selected&&(M=1),applyOpacity(c,M)})}function updateHole(i,e,t,n,s,o,a,l,c,u){const h=n.getIn(["holes",s]),d=e.getIn(["layers",n.id,"holes",s]),p=t.sceneGraph.layers[n.id].holes[s];return p?a.getElement(h.type).updateRender3D(h,n,i,p,d,o,c,u):null}function addLine(i,e,t,n,s,o){if(e.sceneGraph.busyResources.layers[t.id].lines[n]){setTimeout(()=>addLine(i,e,t,n,s,o),100);return}e.sceneGraph.busyResources.layers[t.id].lines[n]=!0;const a=t.getIn(["lines",n]);let l=t.vertices.get(a.vertices.get(0)),c=t.vertices.get(a.vertices.get(1));if(l.x>c.x){let u=l;l=c,c=u}return s.getElement(a.type).render3D(a,t,i).then(u=>{u instanceof LOD&&(e.sceneGraph.LODs[a.id]=u);let h=new Object3D;h.name="pivot",h.add(enableShadows(u)),h.position.x=l.x,h.position.y=t.altitude,h.position.z=-l.y,e.plan.add(h),e.sceneGraph.layers[t.id].lines[n]=h,applyInteract(h,()=>o.selectLine(t.id,a.id));let d=t.opacity;a.selected&&(d=1),applyOpacity(h,d),e.sceneGraph.busyResources.layers[t.id].lines[n]=!1})}function updateLine(i,e,t,n,s,o,a,l,c,u){const h=n.getIn(["lines",s]),d=e.getIn(["layers",n.id,"lines",s]),p=t.sceneGraph.layers[n.id].lines[s];return p?a.getElement(h.type).updateRender3D(h,n,i,p,d,o,c,u):null}function addArea(i,e,t,n,s,o){if(e.sceneGraph.busyResources.layers[t.id].areas[n]){setTimeout(()=>addArea(i,e,t,n,s,o),100);return}e.sceneGraph.busyResources.layers[t.id].areas[n]=!0;const a=t.getIn(["areas",n]),l=()=>o.selectArea(t.id,n);return s.getElement(a.type).render3D(a,t,i).then(c=>{c instanceof LOD&&(e.sceneGraph.LODs[n]=c);let u=new Object3D;u.name="pivot",u.add(enableShadows(c,{cast:!1})),u.position.y=t.altitude,e.plan.add(u),e.sceneGraph.layers[t.id].areas[n]=u,applyInteract(u,l);let h=t.opacity;a.selected&&(h=1),applyOpacity(u,h),e.sceneGraph.busyResources.layers[t.id].areas[n]=!1})}function updateArea(i,e,t,n,s,o,a,l,c,u){const h=n.getIn(["areas",s]),d=e.getIn(["layers",n.id,"areas",s]),p=t.sceneGraph.layers[n.id].areas[s];return p?a.getElement(h.type).updateRender3D(h,n,i,p,d,o,c,u):null}function addItem(i,e,t,n,s,o){const a=t.getIn(["items",n]);return s.getElement(a.type).render3D(a,t,i).then(l=>{l instanceof LOD&&(e.sceneGraph.LODs[n]=l);const c=new Object3D;c.name="pivot",c.add(enableShadows(l));const{scale:u,flipHorizontal:h,flipVertical:d}=getItemTransform(a);c.scale.set(u*(h?-1:1),u,u*(d?-1:1)),c.rotation.y=a.rotation*Math.PI/180,c.position.x=a.x,c.position.y=t.altitude,c.position.z=-a.y,applyInteract(l,()=>{o.selectItem(t.id,a.id)});let p=t.opacity;a.selected&&(p=1),applyOpacity(c,p),e.plan.add(c),e.sceneGraph.layers[t.id].items[a.id]=c})}function updateItem(i,e,t,n,s,o,a,l,c,u){const h=n.getIn(["items",s]),d=e.getIn(["layers",n.id,"items",s]),p=t.sceneGraph.layers[n.id].items[s];return p?a.getElement(h.type).updateRender3D(h,n,i,p,d,o,c,u):null}function applyInteract(i,e){i.traverse(t=>{(t instanceof Mesh||t.isMesh)&&(t.interact=e)})}function applyOpacity(i,e){i.traverse(t=>{t instanceof Mesh&&(t.material instanceof Array?t.material.forEach(n=>{n.transparent=!0,n.maxOpacity?n.opacity=Math.min(n.maxOpacity,e):n.opacity&&n.opacity>e&&(n.maxOpacity=n.opacity,n.opacity=e)}):(t.material.transparent=!0,t.material.maxOpacity?t.material.opacity=Math.min(t.material.maxOpacity,e):t.material.opacity&&t.material.opacity>e&&(t.material.maxOpacity=t.material.opacity,t.material.opacity=e)))})}function updateBoundingBox(i){const e=new Box3().setFromObject(i.plan);isFinite(e.max.x)&&isFinite(e.min.x)&&isFinite(e.max.y)&&isFinite(e.min.y)&&isFinite(e.max.z)&&isFinite(e.min.z)&&(i.boundingBox=e)}function updateBoundingBoxWhenSettled(i,e){return Promise.allSettled(i).then(()=>updateBoundingBox(e))}function filterDiffs(i,e,t){return minimizeRemoveDiffsWhenSwitchingLayers(minimizeChangePropertiesAfterSelectionsDiffs(minimizeChangePropertiesDiffs(i)),e,t)}function minimizeRemoveDiffsWhenSwitchingLayers(i,e,t){let n,s;for(s=0;s<i.length&&!n;s++)i[s].path[1]==="selectedLayer"&&(n=i[s]);return n&&!e.getIn(["layers",t.selectedLayer,"visible"])?i.filter(({op:o,path:a})=>!(a[a.length-1]==="selected"&&a[1]==="layers"&&a[2]===t.selectedLayer)&&!(o==="remove"&&a.indexOf(t.selectedLayer)!==-1)):i}function minimizeChangePropertiesAfterSelectionsDiffs(i,e,t){const n={};return i.forEach(({path:s})=>{s[5]==="selected"&&(n[s[4]]=s[4])}),i.filter(({path:s})=>s[5]==="properties"?!n[s[4]]:!0)}function minimizeChangePropertiesDiffs(i,e,t){const n={};return i.filter(({path:s})=>s[5]==="properties"?n[s[4]]?!1:n[s[4]]=!0:s[5]!=="misc")}const _changeEvent={type:"change"},_startEvent={type:"start"},_endEvent={type:"end"},_ray=new Ray,_plane=new Plane,_TILT_LIMIT=Math.cos(70*MathUtils.DEG2RAD),_v=new Vector3,_twoPI=2*Math.PI,_STATE={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},_EPS=1e-6;class OrbitControls extends Controls{constructor(e,t=null){super(e,t),this.state=_STATE.NONE,this.target=new Vector3,this.cursor=new Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:MOUSE.ROTATE,MIDDLE:MOUSE.DOLLY,RIGHT:MOUSE.PAN},this.touches={ONE:TOUCH.ROTATE,TWO:TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new Vector3,this._lastQuaternion=new Quaternion,this._lastTargetPosition=new Vector3,this._quat=new Quaternion().setFromUnitVectors(e.up,new Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new Spherical,this._sphericalDelta=new Spherical,this._scale=1,this._panOffset=new Vector3,this._rotateStart=new Vector2,this._rotateEnd=new Vector2,this._rotateDelta=new Vector2,this._panStart=new Vector2,this._panEnd=new Vector2,this._panDelta=new Vector2,this._dollyStart=new Vector2,this._dollyEnd=new Vector2,this._dollyDelta=new Vector2,this._dollyDirection=new Vector3,this._mouse=new Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=onPointerMove.bind(this),this._onPointerDown=onPointerDown.bind(this),this._onPointerUp=onPointerUp.bind(this),this._onContextMenu=onContextMenu.bind(this),this._onMouseWheel=onMouseWheel.bind(this),this._onKeyDown=onKeyDown.bind(this),this._onTouchStart=onTouchStart.bind(this),this._onTouchMove=onTouchMove.bind(this),this._onMouseDown=onMouseDown.bind(this),this._onMouseMove=onMouseMove.bind(this),this._interceptControlDown=interceptControlDown.bind(this),this._interceptControlUp=interceptControlUp.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(_changeEvent),this.update(),this.state=_STATE.NONE}update(e=null){const t=this.object.position;_v.copy(t).sub(this.target),_v.applyQuaternion(this._quat),this._spherical.setFromVector3(_v),this.autoRotate&&this.state===_STATE.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=_twoPI:n>Math.PI&&(n-=_twoPI),s<-Math.PI?s+=_twoPI:s>Math.PI&&(s-=_twoPI),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let o=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),o=a!=this._spherical.radius}if(_v.setFromSpherical(this._spherical),_v.applyQuaternion(this._quatInverse),t.copy(this.target).add(_v),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const l=_v.length();a=this._clampDistance(l*this._scale);const c=l-a;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),o=!!c}else if(this.object.isOrthographicCamera){const l=new Vector3(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),o=c!==this.object.zoom;const u=new Vector3(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),a=_v.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(_ray.origin.copy(this.object.position),_ray.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(_ray.direction))<_TILT_LIMIT?this.object.lookAt(this.target):(_plane.setFromNormalAndCoplanarPoint(this.object.up,this.target),_ray.intersectPlane(_plane,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),o=!0)}return this._scale=1,this._performCursorZoom=!1,o||this._lastPosition.distanceToSquared(this.object.position)>_EPS||8*(1-this._lastQuaternion.dot(this.object.quaternion))>_EPS||this._lastTargetPosition.distanceToSquared(this.target)>_EPS?(this.dispatchEvent(_changeEvent),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?_twoPI/60*this.autoRotateSpeed*e:_twoPI/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){_v.setFromMatrixColumn(t,0),_v.multiplyScalar(-e),this._panOffset.add(_v)}_panUp(e,t){this.screenSpacePanning===!0?_v.setFromMatrixColumn(t,1):(_v.setFromMatrixColumn(t,0),_v.crossVectors(this.object.up,_v)),_v.multiplyScalar(e),this._panOffset.add(_v)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;_v.copy(s).sub(this.target);let o=_v.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*o/n.clientHeight,this.object.matrix),this._panUp(2*t*o/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),s=e-n.left,o=t-n.top,a=n.width,l=n.height;this._mouse.x=s/a*2-1,this._mouse.y=-(o/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(_twoPI*this._rotateDelta.x/t.clientHeight),this._rotateUp(_twoPI*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(_twoPI*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-_twoPI*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(_twoPI*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-_twoPI*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,o=Math.sqrt(n*n+s*s);this._dollyStart.set(0,o)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),o=.5*(e.pageY+n.y);this._rotateEnd.set(s,o)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(_twoPI*this._rotateDelta.x/t.clientHeight),this._rotateUp(_twoPI*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,o=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,o),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,l=(e.pageY+t.y)*.5;this._updateZoomParameters(a,l)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function onPointerDown(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function onPointerMove(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function onPointerUp(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(_endEvent),this.state=_STATE.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function onMouseDown(i){let e;switch(i.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=_STATE.DOLLY;break;case MOUSE.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=_STATE.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=_STATE.ROTATE}break;case MOUSE.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=_STATE.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=_STATE.PAN}break;default:this.state=_STATE.NONE}this.state!==_STATE.NONE&&this.dispatchEvent(_startEvent)}function onMouseMove(i){switch(this.state){case _STATE.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case _STATE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case _STATE.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function onMouseWheel(i){this.enabled===!1||this.enableZoom===!1||this.state!==_STATE.NONE||(i.preventDefault(),this.dispatchEvent(_startEvent),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(_endEvent))}function onKeyDown(i){this.enabled!==!1&&this._handleKeyDown(i)}function onTouchStart(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=_STATE.TOUCH_ROTATE;break;case TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=_STATE.TOUCH_PAN;break;default:this.state=_STATE.NONE}break;case 2:switch(this.touches.TWO){case TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=_STATE.TOUCH_DOLLY_PAN;break;case TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=_STATE.TOUCH_DOLLY_ROTATE;break;default:this.state=_STATE.NONE}break;default:this.state=_STATE.NONE}this.state!==_STATE.NONE&&this.dispatchEvent(_startEvent)}function onTouchMove(i){switch(this._trackPointer(i),this.state){case _STATE.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case _STATE.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case _STATE.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case _STATE.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=_STATE.NONE}}function onContextMenu(i){this.enabled!==!1&&i.preventDefault()}function interceptControlDown(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function interceptControlUp(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const ACCENT=1877756,SHADE=1710618,RING_OUTER=1.35,RING_INNER=1.18,RING_GRAB_PADDING=.14,LIFT_RADIUS_PX=21,LIFT_GRAB_PX=30,PLUMB_WIDTH_PX=3,PLUMB_DASH_PX=17,LIFTED_EPSILON=1,MIN_RING_RADIUS=20;function dashTexture(){const i=document.createElement("canvas");i.width=1,i.height=16;const e=i.getContext("2d");e&&(e.fillStyle="#111111",e.fillRect(0,0,1,10));const t=new CanvasTexture(i);return t.wrapT=RepeatWrapping,t.magFilter=NearestFilter,t.minFilter=NearestFilter,t.colorSpace=SRGBColorSpace,t}function arrowShape(i,e,t){const n=i/2,s=t,o=e/2,a=t/2,l=n-s,c=new Shape;return c.moveTo(-n,0),c.lineTo(-l,a),c.lineTo(-l,o),c.lineTo(l,o),c.lineTo(l,a),c.lineTo(n,0),c.lineTo(l,-a),c.lineTo(l,-o),c.lineTo(-l,-o),c.lineTo(-l,-a),c.closePath(),c}const overlayMaterial=(i,e)=>new MeshBasicMaterial({color:i,opacity:e,transparent:!0,depthTest:!1,depthWrite:!1,side:DoubleSide,toneMapped:!1});class SelectionGizmo{constructor(){ze(this,"group",new Group);ze(this,"base",new Group);ze(this,"ring");ze(this,"rotateGrab");ze(this,"rotateArrow");ze(this,"lift",new Group);ze(this,"liftGrab");ze(this,"plumb");ze(this,"plumbTexture");ze(this,"materials",[]);ze(this,"geometries",[]);ze(this,"textures",[]);this.group.name="selection-gizmo",this.group.visible=!1,this.group.userData.gizmo=!0;const e=this.keep(new RingGeometry(RING_INNER,RING_OUTER,64)),t=this.keep(new CircleGeometry(RING_INNER,64)),n=this.keep(new RingGeometry(RING_INNER-RING_GRAB_PADDING,RING_OUTER+RING_GRAB_PADDING,32));this.ring=new Mesh(e,this.keep(overlayMaterial(SHADE,.3)));const s=new Mesh(t,this.keep(overlayMaterial(SHADE,.12)));this.rotateGrab=new Mesh(n,this.keep(new MeshBasicMaterial({visible:!1,side:DoubleSide})));const o=this.keep(new ShapeGeometry(arrowShape(.62,.055,.17)));this.rotateArrow=new Mesh(o,this.keep(overlayMaterial(ACCENT,1))),[s,this.ring,this.rotateGrab,this.rotateArrow].forEach(c=>{c.rotation.x=-Math.PI/2,this.base.add(c)}),this.rotateArrow.position.set(0,.02,(RING_INNER+RING_OUTER)/2),this.group.add(this.base);const a=new Mesh(this.keep(new CircleGeometry(1,40)),this.keep(overlayMaterial(16777215,1))),l=new Mesh(this.keep(new ShapeGeometry(arrowShape(1.5,.16,.62))),this.keep(overlayMaterial(SHADE,1)));l.rotation.z=Math.PI/2,l.position.z=.01,this.liftGrab=new Mesh(this.keep(new CircleGeometry(LIFT_GRAB_PX/LIFT_RADIUS_PX,16)),this.keep(new MeshBasicMaterial({visible:!1,side:DoubleSide}))),this.lift.add(a,l,this.liftGrab),this.group.add(this.lift),this.plumbTexture=this.keepTexture(dashTexture()),this.plumb=new Mesh(this.keep(new PlaneGeometry(1,1)),this.keep(new MeshBasicMaterial({map:this.plumbTexture,transparent:!0,depthTest:!1,depthWrite:!1,side:DoubleSide,toneMapped:!1}))),this.plumb.visible=!1,this.group.add(this.plumb)}keep(e){return e instanceof Material?this.materials.push(e):this.geometries.push(e),e}keepTexture(e){return this.textures.push(e),e}update(e,t,n){if(!e){this.group.visible=!1;return}this.group.visible=!0;const s=Math.max(MIN_RING_RADIUS,e.radius);this.base.position.set(e.centre.x,e.floorY,e.centre.z),this.base.rotation.y=e.rotationY,this.base.scale.setScalar(s),this.lift.position.set(e.centre.x,e.handleY,e.centre.z),this.lift.quaternion.copy(t.quaternion);const o=t.position.distanceTo(this.lift.position),a=n(o);this.lift.scale.setScalar(a*LIFT_RADIUS_PX),this.updatePlumb(e,t,a)}updatePlumb(e,t,n){const s=e.handleY-e.floorY;if(this.plumb.visible=e.lifting&&e.bottomY-e.floorY>LIFTED_EPSILON&&s>0,!this.plumb.visible)return;this.plumb.position.set(e.centre.x,e.floorY+s/2,e.centre.z),this.plumb.scale.set(n*PLUMB_WIDTH_PX,s,1),Math.hypot(t.position.x-this.plumb.position.x,t.position.z-this.plumb.position.z)>.001&&this.plumb.lookAt(t.position.x,this.plumb.position.y,t.position.z),this.plumbTexture.repeat.set(1,Math.max(1,s/(n*PLUMB_DASH_PX)))}pick(e){return this.group.visible?e.intersectObject(this.liftGrab,!1).length>0?"lift":e.intersectObject(this.rotateGrab,!1).length>0?"rotate":null:null}dispose(){this.group.removeFromParent(),this.geometries.forEach(e=>e.dispose()),this.materials.forEach(e=>e.dispose()),this.textures.forEach(e=>e.dispose())}}const isMap=i=>isKeyed(i),isIndexedCollection=i=>isIndexed(i),isRecord$1=i=>Record.isRecord(i),op=(i,e,t)=>i==="remove"?{op:i,path:e}:{op:i,path:e,value:t},makeMatrix=(i,e,t)=>{const n=[];for(let s=0;s<i;s++){n[s]=new Array(e);for(let o=0;o<e;o++)n[s][o]=t}return n},DiffResult=Record({op:"=",val:null}),ReplaceResult=Record({op:"!=",val:null,newVal:null}),diff$1=(i,e)=>{const t=computeLcsMatrix(i,e);return printDiff(t,i,e,i.size??0,e.size??0)},computeLcsMatrix=(i,e)=>{const t=i.size??0,n=e.size??0,s=makeMatrix(t+1,n+1,0);for(let o=0;o<t;o++)for(let a=0;a<n;a++)is(i.get(o),e.get(a))?s[o+1][a+1]=s[o][a]+1:s[o+1][a+1]=Math.max(s[o+1][a],s[o][a+1]);return s},printDiff=(i,e,t,n,s)=>{const o=[];let a=n-1,l=s-1;for(;a>=0||l>=0;)a>=0&&l>=0&&is(e.get(a),t.get(l))?(o.push(new DiffResult({op:"=",val:e.get(a)})),a--,l--):a>=0&&l>=0&&a===l&&!is(e.get(a),t.get(l))?(o.push(new ReplaceResult({val:e.get(a),newVal:t.get(a)})),a--,l--):l>=0&&(a===-1||i[a+1][l]>=i[a][l+1])?(o.push(new DiffResult({op:"+",val:t.get(l)})),l--):a>=0&&(l===-1||i[a+1][l]<i[a][l+1])&&(o.push(new DiffResult({op:"-",val:e.get(a)})),a--);return o.reverse()},slashRe=/\//g,tildeRe=/~/g,escape=i=>{if(typeof i=="number")return i.toString();if(typeof i!="string")throw new Error(`param str (${String(i)}) is not a string`);return i.replace(tildeRe,"~0").replace(slashRe,"~1")},concat=(i,e)=>`${i}/${e}`,mapDiff=(i,e,t="")=>{let n=[];if(is(i,e)||i==e&&i==null)return n;const s=isIndexedCollection(i)&&isIndexedCollection(e);let o=null,a=null;return i.forEach&&i.forEach((l,c)=>{if(e.has(c))if(isRecord$1(l)&&isRecord$1(e.get(c)))n=n.concat(recordDiff(l,e.get(c),concat(t,escape(c))));else if(isMap(l)&&isMap(e.get(c)))n=n.concat(mapDiff(l,e.get(c),concat(t,escape(c))));else if(isIndexedCollection(l)&&isIndexedCollection(e.get(c)))n=n.concat(sequenceDiff(l,e.get(c),concat(t,escape(c))));else{const u=e.get?e.get(c):e;l!==u&&n.push(op("replace",concat(t,escape(c)),u))}else s?(a=o!=null&&Number(o)+1===c?a:c,n.push(op("remove",concat(t,escape(a)))),o=c):n.push(op("remove",concat(t,escape(c))))}),e.forEach((l,c)=>{i.has&&!i.has(c)&&n.push(op("add",concat(t,escape(c)),l))}),n},recordDiff=(i,e,t="")=>{let n=[];if(is(i,e)||i==e&&i==null)return n;const s=i.toSeq().toMap(),o=e.toSeq().toMap();return n=n.concat(mapDiff(s,o,t)),n},sequenceDiff=(i,e,t="")=>{let n=[];if(is(i,e)||i==e&&i==null)return n;if((i.count()+1)*(e.count()+1)>=1e4)return mapDiff(i,e,t);const s=diff$1(i,e);let o=0;return s.forEach(a=>{if(a.op==="=")o++;else if(a.op==="!="){if(isRecord$1(a.val)&&isRecord$1(a.newVal)){const l=recordDiff(a.val,a.newVal,concat(t,String(o)));n=n.concat(l)}else if(isMap(a.val)&&isMap(a.newVal)){const l=mapDiff(a.val,a.newVal,concat(t,String(o)));n=n.concat(l)}else n.push(op("replace",concat(t,String(o)),a.newVal));o++}else a.op==="+"?(n.push(op("add",concat(t,String(o)),a.val)),o++):a.op==="-"&&n.push(op("remove",concat(t,String(o))))}),n},primitiveTypeDiff=(i,e,t="")=>i===e?[]:[op("replace",concat(t,""),e)],diff=(i,e,t="")=>is(i,e)?List():i!=e&&(i==null||e==null)?fromJS([op("replace","/",e)]):isIndexedCollection(i)&&isIndexedCollection(e)?fromJS(sequenceDiff(i,e)):isRecord$1(i)&&isRecord$1(e)?fromJS(recordDiff(i,e)):isMap(i)&&isMap(e)?fromJS(mapDiff(i,e)):fromJS(primitiveTypeDiff(i,e,t)),FIT_MARGIN=1.25,ENTRY_MARGIN=1.25,TOP_DOWN=new Vector3(0,1,0),SHADOW_SETTLE_MS=2e3,pointerAngleAround=(i,e)=>Math.atan2(-(e.z-i.z),e.x-i.x);class Scene3DViewer extends React.Component{constructor(t){super(t);ze(this,"canvasWrapperRef",React.createRef());ze(this,"renderer");ze(this,"scene3D",null);ze(this,"camera",null);ze(this,"orbitControls",null);ze(this,"planData");ze(this,"renderingID",0);ze(this,"width");ze(this,"height");ze(this,"lastMousePosition",{});ze(this,"mouseDownEvent");ze(this,"mouseUpEvent");ze(this,"lastBoundingBox",null);ze(this,"userMovedCamera",!1);ze(this,"sun",null);ze(this,"shadowsDirtyUntil",0);ze(this,"gizmo",null);ze(this,"gizmoDrag",null);ze(this,"gizmoMoveEvent");ze(this,"gizmoUpEvent");ze(this,"scratchBox",new Box3);ze(this,"scratchVector",new Vector3);ze(this,"scratchSize",new Vector3);ze(this,"gizmoRadiusFor",null);ze(this,"gizmoRadius",0);ze(this,"worldPerPixel",t=>{const n=this.camera;return!n||this.height===0?1:2*t*Math.tan(MathUtils.degToRad(n.fov)/2)/this.height});this.width=t.width,this.height=t.height,this.renderer=new WebGLRenderer({preserveDrawingBuffer:!0,antialias:!0})}componentDidMount(){var v,M;const{state:t,actions:n}=this.props,s={areaActions:n.areaActions,holesActions:n.holesActions,itemsActions:n.itemsActions,linesActions:n.linesActions,projectActions:n.projectActions},o=t.scene,a=this.canvasWrapperRef.current,l=new Scene;this.renderer.setSize(this.width,this.height),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,1.5)),this.renderer.outputColorSpace=SRGBColorSpace,this.renderer.useLegacyLights=!1,this.renderer.toneMapping=NeutralToneMapping,this.renderer.toneMappingExposure=1,this.renderer.setClearColor(new Color(COLORS.threeBG)),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=PCFSoftShadowMap,this.renderer.shadowMap.autoUpdate=!1,this.renderer.sortObjects=!1;const c=parseData(o,s,this.props.catalog);l.add(c.plan),l.add(c.grid),c.grid.visible=this.props.showGrid;const u=this.width/this.height,h=new PerspectiveCamera(45,u,1,3e5);l.add(h),h.up.set(0,1,0);const d=c.boundingBox.getCenter(new Vector3),p=c.boundingBox.getSize(new Vector3);h.position.copy(d).add(TOP_DOWN.clone().setLength(Math.max(1,p.length()))),l.add(new HemisphereLight(16777215,15921906,3));const f=new DirectionalLight(16774892,1);f.castShadow=!0,f.shadow.mapSize.set(2048,2048),f.shadow.bias=-5e-4,f.shadow.normalBias=2,l.add(f),l.add(f.target),this.sun=f;const g=[c.plan],_=new Vector2,x=new Raycaster;this.mouseDownEvent=T=>{var w;this.lastMousePosition.x=T.offsetX/this.width*2-1,this.lastMousePosition.y=-T.offsetY/this.height*2+1,_.set(this.lastMousePosition.x,this.lastMousePosition.y),x.setFromCamera(_,h);const I=((w=this.gizmo)==null?void 0:w.pick(x))??null;I&&(T.preventDefault(),T.stopPropagation(),this.beginGizmoDrag(I,x))},this.mouseUpEvent=T=>{var I,w;if(T.preventDefault(),!this.gizmoDrag&&(_.x=T.offsetX/this.width*2-1,_.y=-(T.offsetY/this.height)*2+1,Math.abs(_.x-(this.lastMousePosition.x??0))<=.02&&Math.abs(_.y-(this.lastMousePosition.y??0))<=.02)){x.setFromCamera(_,h);const R=x.intersectObjects(g,!0);R.length>0&&!isNaN(R[0].distance)?(w=(I=R[0].object).interact)==null||w.call(I):this.props.actions.projectActions.unselectAll()}},this.gizmoMoveEvent=T=>{if(!this.camera)return;const I=this.renderer.domElement.getBoundingClientRect();if(_.x=(T.clientX-I.left)/I.width*2-1,_.y=-((T.clientY-I.top)/I.height)*2+1,this.gizmoDrag){x.setFromCamera(_,this.camera),this.updateGizmoDrag(x);return}Math.abs(_.x)<=1&&Math.abs(_.y)<=1&&this.gizmo&&(x.setFromCamera(_,this.camera),this.renderer.domElement.style.cursor=this.gizmo.pick(x)?"grab":"")},this.gizmoUpEvent=()=>this.endGizmoDrag(),this.renderer.domElement.addEventListener("mousedown",this.mouseDownEvent),this.renderer.domElement.addEventListener("mouseup",this.mouseUpEvent),window.addEventListener("mousemove",this.gizmoMoveEvent),window.addEventListener("mouseup",this.gizmoUpEvent),a&&a.appendChild(this.renderer.domElement);const y=new OrbitControls(h,this.renderer.domElement);y.enableDamping=!0,y.dampingFactor=.05,y.addEventListener("start",()=>{this.userMovedCamera=!0});const E=new SelectionGizmo;l.add(E.group),this.gizmo=E,this.orbitControls=y,this.camera=h,this.scene3D=l,this.planData=c,this.applyZoomLimits(c.boundingBox);const b=()=>{var I;const T=(I=this.planData)==null?void 0:I.boundingBox;T&&T!==this.lastBoundingBox&&!T.isEmpty()&&(this.lastBoundingBox=T,this.positionSun(T),this.userMovedCamera||(this.applyZoomLimits(T),this.frameScene(TOP_DOWN,ENTRY_MARGIN))),performance.now()<this.shadowsDirtyUntil&&(this.renderer.shadowMap.needsUpdate=!0),E.update(this.selectedItemTarget(),h,this.worldPerPixel),y.update();for(const w in c.sceneGraph.LODs)c.sceneGraph.LODs[w].update(h);this.renderer.render(l,h),this.renderingID=requestAnimationFrame(b)};b(),(M=(v=this.props.actions).registerViewer)==null||M.call(v,this)}selectedItemTarget(){var u,h,d,p,f,g,_,x;const t=this.props.state.scene,n=t.selectedLayer,s=t.layers.get(n),o=(h=(u=s==null?void 0:s.selected)==null?void 0:u.items)==null?void 0:h.first();if(!o)return null;const a=(_=(g=(f=(p=(d=this.planData)==null?void 0:d.sceneGraph)==null?void 0:p.layers)==null?void 0:f[n])==null?void 0:g.items)==null?void 0:_[o];if(!a)return null;const l=this.scratchBox.setFromObject(a);if(l.isEmpty())return null;if(this.gizmoRadiusFor!==a){const y=l.getSize(this.scratchSize);this.gizmoRadius=Math.hypot(y.x,y.z)/2,this.gizmoRadiusFor=a}const c=a.getWorldPosition(this.scratchVector);return{centre:c,floorY:c.y,handleY:(l.min.y+l.max.y)/2,radius:this.gizmoRadius,rotationY:a.rotation.y,bottomY:l.min.y,lifting:((x=this.gizmoDrag)==null?void 0:x.handle)==="lift"}}beginGizmoDrag(t,n){var f,g,_,x,y,E,b,v;const s=this.props.state.scene,o=s.selectedLayer,a=s.layers.get(o),l=(g=(f=a==null?void 0:a.selected)==null?void 0:f.items)==null?void 0:g.first();if(!l)return;const c=a.items.get(l),u=(b=(E=(y=(x=(_=this.planData)==null?void 0:_.sceneGraph)==null?void 0:x.layers)==null?void 0:y[o])==null?void 0:E.items)==null?void 0:b[l];if(!c||!u)return;const h=u.getWorldPosition(new Vector3),d=t==="rotate"?new Plane(new Vector3(0,1,0),-h.y):new Plane().setFromNormalAndCoplanarPoint(this.camera.position.clone().sub(h).setY(0).normalize(),h),p=n.ray.intersectPlane(d,new Vector3);p&&(this.gizmoDrag={handle:t,layerID:o,itemID:l,pivot:u,plane:d,startRotation:c.rotation??0,startPointerAngle:pointerAngleAround(h,p),startAltitude:c.altitude??0,model:u.children[0]??null,startModelY:((v=u.children[0])==null?void 0:v.position.y)??0,startPointerY:p.y,rotation:c.rotation??0,altitude:c.altitude??0},this.orbitControls&&(this.orbitControls.enabled=!1),this.renderer.domElement.style.cursor="grabbing")}updateGizmoDrag(t){const n=this.gizmoDrag;if(!n)return;const s=t.ray.intersectPlane(n.plane,new Vector3);if(s){if(n.handle==="rotate"){const o=n.pivot.getWorldPosition(new Vector3),a=pointerAngleAround(o,s)-n.startPointerAngle;n.rotation=snapToRightAngle(normalizeAngle(n.startRotation+MathUtils.radToDeg(a))),n.pivot.rotation.y=MathUtils.degToRad(n.rotation)}else if(n.model){n.altitude=Math.max(0,n.startAltitude+(s.y-n.startPointerY));const o=n.pivot.scale.y||1;n.model.position.y=n.startModelY+(n.altitude-n.startAltitude)/o}this.invalidateShadows()}}endGizmoDrag(){var s,o;const t=this.gizmoDrag;!t||(this.gizmoDrag=null,this.orbitControls&&(this.orbitControls.enabled=!0),this.renderer.domElement.style.cursor="",!(t.handle==="rotate"?t.rotation!==t.startRotation:t.altitude!==t.startAltitude))||(o=(s=this.props.actions.itemsActions)==null?void 0:s.setItemAttributes)==null||o.call(s,t.itemID,t.handle==="rotate"?{rotation:t.rotation}:{altitude:t.altitude})}positionSun(t){const n=this.sun;if(!n)return;const s=t.getCenter(new Vector3),o=Math.max(100,t.getSize(new Vector3).length()/2);n.position.copy(s).add(new Vector3(.45,1,.35).setLength(o*2.5)),n.target.position.copy(s),n.target.updateMatrixWorld();const a=n.shadow.camera;a.left=-o,a.right=o,a.top=o,a.bottom=-o,a.near=o*.5,a.far=o*5,a.updateProjectionMatrix(),this.invalidateShadows()}invalidateShadows(){this.renderer.shadowMap.needsUpdate=!0,this.shadowsDirtyUntil=performance.now()+SHADOW_SETTLE_MS}applyZoomLimits(t){const n=this.orbitControls;if(!n||t.isEmpty())return;const s=Math.max(1,t.getSize(this.scratchSize).length());n.minDistance=Math.max(50,s*.05),n.maxDistance=Math.max(600,s*2.5)}zoomBy(t){const n=this.orbitControls,s=this.camera;if(!n||!s||t<=0)return;this.userMovedCamera=!0;const o=s.position.clone().sub(n.target),a=o.length();if(a===0)return;const l=MathUtils.clamp(a/t,n.minDistance,n.maxDistance);s.position.copy(n.target).add(o.setLength(l)),n.update()}fitToScene(){this.userMovedCamera=!0,this.frameScene()}frameScene(t,n=FIT_MARGIN){var y;const s=this.orbitControls,o=this.camera,a=(y=this.planData)==null?void 0:y.boundingBox;if(!s||!o||!a||a.isEmpty())return;const l=a.getCenter(new Vector3),c=t?t.clone():o.position.clone().sub(s.target);c.lengthSq()===0&&c.copy(TOP_DOWN);const u=c.clone().normalize(),h=Math.abs(u.dot(o.up))>.999?new Vector3(0,0,-1):o.up.clone(),d=new Vector3().crossVectors(h,u).normalize(),p=new Vector3().crossVectors(u,d).normalize(),f=Math.tan(MathUtils.degToRad(o.fov)/2),g=f*o.aspect;let _=0;const x=new Vector3;for(const E of[a.min.x,a.max.x])for(const b of[a.min.y,a.max.y])for(const v of[a.min.z,a.max.z]){x.set(E,b,v).sub(l);const M=x.dot(u);_=Math.max(_,M+Math.abs(x.dot(d))/g,M+Math.abs(x.dot(p))/f)}_*=n,c.setLength(MathUtils.clamp(_,s.minDistance,s.maxDistance)),s.target.copy(l),o.position.copy(l).add(c),s.update()}componentWillUnmount(){var t,n,s,o;(n=(t=this.props.actions).registerViewer)==null||n.call(t,null),cancelAnimationFrame(this.renderingID),(s=this.orbitControls)==null||s.dispose(),this.renderer.domElement.removeEventListener("mousedown",this.mouseDownEvent),this.renderer.domElement.removeEventListener("mouseup",this.mouseUpEvent),window.removeEventListener("mousemove",this.gizmoMoveEvent),window.removeEventListener("mouseup",this.gizmoUpEvent),this.gizmoDrag=null,(o=this.gizmo)==null||o.dispose(),this.gizmo=null,this.scene3D&&(disposeScene(this.scene3D),this.scene3D.remove(this.planData.plan),this.scene3D.remove(this.planData.grid)),this.scene3D=null,this.planData=null,this.camera=null,this.orbitControls=null,this.renderer.renderLists.dispose()}componentDidUpdate(t){const{width:n,height:s}=this.props;if(this.width=n,this.height=s,this.camera&&(this.camera.aspect=n/s,this.camera.updateProjectionMatrix()),this.planData&&t.showGrid!==this.props.showGrid&&(this.planData.grid.visible=this.props.showGrid),t.state.scene!==this.props.state.scene){const o=diff(t.state.scene,this.props.state.scene),a={areaActions:this.props.actions.areaActions,holesActions:this.props.actions.holesActions,itemsActions:this.props.actions.itemsActions,linesActions:this.props.actions.linesActions,projectActions:this.props.actions.projectActions};updateScene(this.planData,this.props.state.scene,t.state.scene,o.toJS(),a,this.props.catalog),this.invalidateShadows()}this.renderer.setSize(n,s)}render(){return React.createElement("div",{ref:this.canvasWrapperRef})}}const STYLE$1={color:SharedStyle.PRIMARY_COLOR.alt,fontWeight:300};function ContentTitle({children:i,style:e={},...t}){return jsxRuntimeExports.jsx("h1",{style:{...STYLE$1,...e},...t,children:i})}const STYLE={padding:"0 20px",overflowY:"auto"};function ContentContainer({children:i,width:e,height:t,style:n={}}){return jsxRuntimeExports.jsx("div",{style:{width:e,height:t,...STYLE,...n},onWheel:s=>s.stopPropagation(),children:i})}function FaCog(i){return GenIcon({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M487.4 315.7l-42.6-24.6c4.3-23.2 4.3-47 0-70.2l42.6-24.6c4.9-2.8 7.1-8.6 5.5-14-11.1-35.6-30-67.8-54.7-94.6-3.8-4.1-10-5.1-14.8-2.3L380.8 110c-17.9-15.4-38.5-27.3-60.8-35.1V25.8c0-5.6-3.9-10.5-9.4-11.7-36.7-8.2-74.3-7.8-109.2 0-5.5 1.2-9.4 6.1-9.4 11.7V75c-22.2 7.9-42.8 19.8-60.8 35.1L88.7 85.5c-4.9-2.8-11-1.9-14.8 2.3-24.7 26.7-43.6 58.9-54.7 94.6-1.7 5.4.6 11.2 5.5 14L67.3 221c-4.3 23.2-4.3 47 0 70.2l-42.6 24.6c-4.9 2.8-7.1 8.6-5.5 14 11.1 35.6 30 67.8 54.7 94.6 3.8 4.1 10 5.1 14.8 2.3l42.6-24.6c17.9 15.4 38.5 27.3 60.8 35.1v49.2c0 5.6 3.9 10.5 9.4 11.7 36.7 8.2 74.3 7.8 109.2 0 5.5-1.2 9.4-6.1 9.4-11.7v-49.2c22.2-7.9 42.8-19.8 60.8-35.1l42.6 24.6c4.9 2.8 11 1.9 14.8-2.3 24.7-26.7 43.6-58.9 54.7-94.6 1.5-5.5-.7-11.3-5.6-14.1zM256 336c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z"},child:[]}]})(i)}function FaMinus(i){return GenIcon({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"},child:[]}]})(i)}function FaPlusCircle(i){return GenIcon({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm144 276c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92h-92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z"},child:[]}]})(i)}function FaPlus(i){return GenIcon({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M416 208H272V64c0-17.67-14.33-32-32-32h-32c-17.67 0-32 14.33-32 32v144H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h144v144c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32V304h144c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"},child:[]}]})(i)}function FaSortDown(i){return GenIcon({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M41 288h238c21.4 0 32.1 25.9 17 41L177 448c-9.4 9.4-24.6 9.4-33.9 0L24 329c-15.1-15.1-4.4-41 17-41z"},child:[]}]})(i)}function FaUnlink(i){return GenIcon({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M304.083 405.907c4.686 4.686 4.686 12.284 0 16.971l-44.674 44.674c-59.263 59.262-155.693 59.266-214.961 0-59.264-59.265-59.264-155.696 0-214.96l44.675-44.675c4.686-4.686 12.284-4.686 16.971 0l39.598 39.598c4.686 4.686 4.686 12.284 0 16.971l-44.675 44.674c-28.072 28.073-28.072 73.75 0 101.823 28.072 28.072 73.75 28.073 101.824 0l44.674-44.674c4.686-4.686 12.284-4.686 16.971 0l39.597 39.598zm-56.568-260.216c4.686 4.686 12.284 4.686 16.971 0l44.674-44.674c28.072-28.075 73.75-28.073 101.824 0 28.072 28.073 28.072 73.75 0 101.823l-44.675 44.674c-4.686 4.686-4.686 12.284 0 16.971l39.598 39.598c4.686 4.686 12.284 4.686 16.971 0l44.675-44.675c59.265-59.265 59.265-155.695 0-214.96-59.266-59.264-155.695-59.264-214.961 0l-44.674 44.674c-4.686 4.686-4.686 12.284 0 16.971l39.597 39.598zm234.828 359.28l22.627-22.627c9.373-9.373 9.373-24.569 0-33.941L63.598 7.029c-9.373-9.373-24.569-9.373-33.941 0L7.029 29.657c-9.373 9.373-9.373 24.569 0 33.941l441.373 441.373c9.373 9.372 24.569 9.372 33.941 0z"},child:[]}]})(i)}const STYLE_BOX$1={width:"14em",height:"14em",padding:"0.625em",background:"#f7f7f9",border:"1px solid #e1e1e8",cursor:"pointer",position:"relative",boxShadow:"0 1px 6px 0 rgba(0, 0, 0, 0.11), 0 1px 4px 0 rgba(0, 0, 0, 0.11)",borderRadius:"2px",transition:"all .15s ease-in-out",WebkitTransition:"all .15s ease-in-out",alignSelf:"center",justifySelf:"center"},STYLE_BOX_HOVER$1={...STYLE_BOX$1,background:SharedStyle.SECONDARY_COLOR.main},STYLE_TITLE={width:"100%",textAlign:"center",display:"block",marginBottom:".5em",textTransform:"capitalize"},STYLE_TITLE_HOVER={...STYLE_TITLE,color:SharedStyle.COLORS.white},STYLE_IMAGE_CONTAINER={width:"100%",height:"8em",position:"relative",overflow:"hidden",border:"solid 1px #e6e6e6",padding:0,margin:0,marginBottom:"5px"},STYLE_IMAGE={position:"absolute",background:"#222",width:"100%",height:"100%",backgroundSize:"contain",backgroundPosition:"50% 50%",backgroundColor:SharedStyle.COLORS.white,backgroundRepeat:"no-repeat",transition:"all .2s ease-in-out"},STYLE_IMAGE_HOVER={...STYLE_IMAGE,transform:"scale(1.2)"},STYLE_PLUS_HOVER={marginTop:"1.5em",color:SharedStyle.SECONDARY_COLOR.main,fontSize:"2em",opacity:"0.7",width:"100%"},STYLE_DESCRIPTION={display:"block",height:"2em",margin:"0 auto",fontSize:"0.75em",fontStyle:"italic",lineHeight:"1em",WebkitLineClamp:"2",WebkitBoxOrient:"vertical",overflow:"hidden",textOverflow:"ellipsis"},STYLE_TAGS={listStyle:"none",margin:"0px",padding:"0px",fontSize:"11px",marginBottom:"3px"},STYLE_TAG={display:"inline-block",background:"#337ab7",color:SharedStyle.COLORS.white,padding:"1px 4px",marginRight:"3px",borderRadius:"3px"},CatalogItem=({element:i})=>{const[e,t]=React.useState(!1),{selectToolDrawingLine:n,selectToolDrawingItem:s,selectToolDrawingHole:o,pushLastSelectedCatalogElementToHistory:a}=useReactPlannerStore(),l=()=>{switch(i.prototype){case"lines":n(i.name);break;case"items":s(i.name);break;case"holes":o(i.name);break}a(i)};return jsxRuntimeExports.jsxs("div",{style:e?STYLE_BOX_HOVER$1:STYLE_BOX$1,onClick:l,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[jsxRuntimeExports.jsx("b",{style:e?STYLE_TITLE_HOVER:STYLE_TITLE,children:i.info.title}),jsxRuntimeExports.jsx("div",{style:STYLE_IMAGE_CONTAINER,children:jsxRuntimeExports.jsx("div",{style:{...e?STYLE_IMAGE_HOVER:STYLE_IMAGE,backgroundImage:"url("+i.info.image+")"},children:e?jsxRuntimeExports.jsx(FaPlusCircle,{style:STYLE_PLUS_HOVER}):null})}),jsxRuntimeExports.jsx("ul",{style:STYLE_TAGS,children:i.info.tag.map((c,u)=>jsxRuntimeExports.jsx("li",{style:STYLE_TAG,children:c},u))}),jsxRuntimeExports.jsx("div",{style:STYLE_DESCRIPTION,children:i.info.description})]})},breadcrumbStyle={margin:"1.5em",display:"flex"},breadcrumbTextStyle={fontSize:"20px",cursor:"pointer"},breadcrumbLastTextStyle={...breadcrumbTextStyle,fontWeight:"bolder",color:SharedStyle.SECONDARY_COLOR.main},breadcrumbTabStyle={fill:SharedStyle.COLORS.black,fontSize:"24px",marginLeft:"10px",marginRight:"10px"},CatalogBreadcrumb=({names:i})=>{let e=i.map((t,n)=>{let s=n===i.length-1;return jsxRuntimeExports.jsxs("div",{style:{display:"flex"},children:[jsxRuntimeExports.jsx("div",{style:s?breadcrumbLastTextStyle:breadcrumbTextStyle,onClick:t.action||null,children:t.name}),s?null:jsxRuntimeExports.jsx(MdArrowBack,{style:breadcrumbTabStyle})]},n)});return jsxRuntimeExports.jsx("div",{style:breadcrumbStyle,children:e})},STYLE_BOX={width:"14em",height:"14em",padding:"0.625em",background:"#f7f7f9",border:"1px solid #e1e1e8",margin:"0.3em",cursor:"pointer",position:"relative",boxShadow:"0 1px 6px 0 rgba(0, 0, 0, 0.11), 0 1px 4px 0 rgba(0, 0, 0, 0.11)",borderRadius:"2px",transition:"all .2s ease-in-out",WebkitTransition:"all .2s ease-in-out"},STYLE_BOX_HOVER={...STYLE_BOX,background:SharedStyle.SECONDARY_COLOR.main},STYLE_BACK={position:"absolute",color:SharedStyle.COLORS.black,fontSize:"5em",width:"100%"},STYLE_BACK_HOVER={...STYLE_BACK,color:SharedStyle.SECONDARY_COLOR.main},CONTAINER_DIV={background:SharedStyle.COLORS.white,marginBottom:"5px",border:"solid 1px #e6e6e6",width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},CatalogTurnBackPageItem=({page:i})=>{const[e,t]=React.useState(!1),{goBackToCatalogPage:n}=useReactPlannerStore(),s=o=>{n(o)};return jsxRuntimeExports.jsx("div",{style:e?STYLE_BOX_HOVER:STYLE_BOX,onClick:()=>s(i.name),onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:jsxRuntimeExports.jsx("div",{style:CONTAINER_DIV,children:jsxRuntimeExports.jsx(MdNavigateBefore,{style:e?STYLE_BACK_HOVER:STYLE_BACK})})})},containerStyle={position:"fixed",width:"calc( 100% - 51px)",height:"calc( 100% - 20px)",backgroundColor:"#FFF",padding:"1em",left:50,overflowY:"auto",overflowX:"hidden",zIndex:10},itemsStyle={display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(14em, 1fr))",gridGap:"10px",marginTop:"1em"},searchContainer={width:"100%",height:"3em",padding:"0.625em",background:"#f7f7f9",border:"1px solid #e1e1e8",cursor:"pointer",position:"relative",boxShadow:"0 1px 6px 0 rgba(0, 0, 0, 0.11), 0 1px 4px 0 rgba(0, 0, 0, 0.11)",borderRadius:"2px",transition:"all .2s ease-in-out",WebkitTransition:"all .2s ease-in-out",marginBottom:"1em"},searchText={width:"8em",display:"inline-block"},searchInput={width:"calc( 100% - 10em )",height:"2em",margin:"0",padding:"0 1em",border:"1px solid #EEE"},historyContainer={...searchContainer,padding:"0.2em 0.625em"},historyElementStyle={width:"auto",height:"2em",lineHeight:"2em",textAlign:"center",borderRadius:"1em",display:"inline-block",cursor:"pointer",backgroundColor:SharedStyle.PRIMARY_COLOR.alt,color:SharedStyle.PRIMARY_COLOR.text_main,textTransform:"capitalize",margin:"0.25em",padding:"0 1em"},CatalogList=({width:i,height:e,style:t,catalog:n})=>{const{planner:s,goBackToCatalogPage:o,selectToolDrawingHole:a,selectToolDrawingItem:l,selectToolDrawingLine:c,pushLastSelectedCatalogElementToHistory:u}=useReactPlannerStore();let h=s.catalog.page;const d=n.getCategory(h);let p=d.elements.filter(R=>R.info.visibility?R.info.visibility.catalog:!0);const[f,g]=React.useState(""),[_,x]=React.useState([]);let y=null;if(h!=="root"){let R=[];s.catalog.path.forEach(A=>{R.push({name:n.getCategory(A).label,action:()=>o(A)})}),R.push({name:d.label,action:""}),y=jsxRuntimeExports.jsx(CatalogBreadcrumb,{names:R})}let E=s.catalog.path.size,b=E>0?jsxRuntimeExports.jsx(CatalogTurnBackPageItem,{page:n.categories[s.catalog.path.get(E-1)]},E):null,v=s.get("selectedElementsHistory"),M=v.map((R,A)=>jsxRuntimeExports.jsx("div",{style:historyElementStyle,title:R.name,onClick:()=>w(R),children:R.name},A));const T=R=>{let A=[];for(let P=0;P<R.length;P++){let B=R[P];A=A.concat(B.elements),B.categories.length&&(A=A.concat(T(B.categories)))}return A},I=R=>{let A=p.concat(T(d.categories)),P=[];if(R!=""){let B=new RegExp(R,"i");for(let k=0;k<A.length;k++)B.test(A[k].info.title)&&P.push(A[k])}g(R),x(P)},w=R=>{switch(R.prototype){case"lines":c(R.name);break;case"items":l(R.name);break;case"holes":a(R.name);break}u(R)};return jsxRuntimeExports.jsxs(ContentContainer,{width:i,height:e,style:{...containerStyle,...t},children:[jsxRuntimeExports.jsx(ContentTitle,{children:"Catalog"}),y,jsxRuntimeExports.jsxs("div",{style:searchContainer,children:[jsxRuntimeExports.jsx("span",{style:searchText,children:"Search Element"}),jsxRuntimeExports.jsx("input",{type:"text",style:searchInput,onChange:R=>{I(R.target.value)}})]}),v.size?jsxRuntimeExports.jsxs("div",{style:historyContainer,children:[jsxRuntimeExports.jsx("span",{children:"Last Selected"}),M]}):null,jsxRuntimeExports.jsx("div",{style:itemsStyle,children:f===""?[b,p.map(R=>jsxRuntimeExports.jsx(CatalogItem,{element:R},R.name))]:_.map(R=>jsxRuntimeExports.jsx(CatalogItem,{element:R},R.name))})]})};function Content({width:i,height:e,catalog:t}){const n=useReactPlannerStore(),{planner:s}=n,{mode:o}=s;return o===MODE_3D_VIEW?jsxRuntimeExports.jsx(Scene3DViewer,{width:i,height:e,state:s,catalog:t,showGrid:n.showGrid,actions:{registerViewer:n.setViewer3D,areaActions:{selectArea:n.selectArea},holesActions:{selectHole:n.selectHole,selectToolDrawingHole:n.selectToolDrawingHole,updateDrawingHole:n.updateDrawingHole,endDrawingHole:n.endDrawingHole,beginDraggingHole:n.beginDraggingHole,updateDraggingHole:n.updateDraggingHole,endDraggingHole:n.endDraggingHole},itemsActions:{selectItem:n.selectItem,selectToolDrawingItem:n.selectToolDrawingItem,updateDrawingItem:n.updateDrawingItem,endDrawingItem:n.endDrawingItem,beginDraggingItem:n.beginDraggingItem,updateDraggingItem:n.updateDraggingItem,endDraggingItem:n.endDraggingItem,beginRotatingItem:n.beginRotatingItem,updateRotatingItem:n.updateRotatingItem,endRotatingItem:n.endRotatingItem,setItemAttributes:n.setItemAttributes},linesActions:{selectLine:n.selectLine,selectToolDrawingLine:n.selectToolDrawingLine,beginDrawingLine:n.beginDrawingLine,updateDrawingLine:n.updateDrawingLine,endDrawingLine:n.endDrawingLine,beginDraggingLine:n.beginDraggingLine,updateDraggingLine:n.updateDraggingLine,endDraggingLine:n.endDraggingLine},projectActions:{loadProject:n.loadProject,newProject:n.newProject,openCatalog:n.openCatalog,changeCatalogPage:n.changeCatalogPage,goBackToCatalogPage:n.goBackToCatalogPage,selectToolEdit:n.selectToolEdit,unselectAll:n.unselectAll,setProperties:n.setProperties,setItemsAttributes:n.setItemsAttributes,setLinesAttributes:n.setLinesAttributes,setHolesAttributes:n.setHolesAttributes,remove:n.remove,undo:n.undo,rollback:n.rollback,openProjectConfigurator:n.openProjectConfigurator,initCatalog:n.initCatalog,updateMouseCoord:n.updateMouseCoord,updateZoomScale:n.updateZoomScale,toggleSnap:n.toggleSnap,copyProperties:n.copyProperties,pasteProperties:n.pasteProperties,pushLastSelectedCatalogElementToHistory:n.pushLastSelectedCatalogElementToHistory,setAlterateState:n.setAlterateState,setMode:n.setMode,addHorizontalGuide:n.addHorizontalGuide,addVerticalGuide:n.addVerticalGuide,removeHorizontalGuide:n.removeHorizontalGuide,removeVerticalGuide:n.removeVerticalGuide}}}):o===MODE_3D_FIRST_PERSON?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{}):o===MODE_VIEWING_CATALOG?jsxRuntimeExports.jsx(CatalogList,{width:i,height:e,catalog:t}):MODE_2D_VIEWER.includes(o)?jsxRuntimeExports.jsx(Viewer2D,{width:i,height:e,catalog:t}):o===MODE_CONFIGURING_PROJECT?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{}):null}const Footerbar=()=>null,Panel=({children:i,name:e,subtitle:t,...n})=>{const[s,o]=React.useState(n.opened||!0);return jsxRuntimeExports.jsxs("div",{className:"select-none",children:[jsxRuntimeExports.jsx("div",{className:"panel-property_header flex px-4 pt-2.5 pb-2.5 items-center gap-1 cursor-pointer",children:jsxRuntimeExports.jsxs("div",{className:"min-w-0 flex-1 leading-tight",children:[jsxRuntimeExports.jsx("div",{className:"text-[11px] text-gray-500",children:e}),t&&jsxRuntimeExports.jsx("div",{className:"text-sm font-semibold truncate",children:t})]})}),jsxRuntimeExports.jsx("div",{className:cn("floor_planner-sidebar_panel max-h-[540px] overflow-auto",s?"block":"hidden"),children:i})]})};function FaChevronLeft(i){return GenIcon({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256 246.6 86.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z"},child:[]}]})(i)}function FaChevronRight(i){return GenIcon({attr:{viewBox:"0 0 320 512"},child:[{tag:"path",attr:{d:"M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"},child:[]}]})(i)}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 FaMagnifyingGlass(i){return GenIcon({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z"},child:[]}]})(i)}function FormLabel({children:i,style:e,className:t,...n}){return jsxRuntimeExports.jsx("label",{className:cn("mb-1 panel-property_label block",t),style:e,...n,children:i})}const BASE_STYLE={fontSize:"13px",WebkitAppearance:"none"};function FormSelect({children:i,style:e,...t}){return jsxRuntimeExports.jsx("select",{className:"w-full cursor-pointer block px-2 outline-none rounded h-[35px] panel-property_select",style:{...BASE_STYLE,...e},...t,children:i})}const FormTextInput=({style:i,...e})=>jsxRuntimeExports.jsx("input",{className:"block w-full px-2 text-sm leading-5 panel-property_input rounded outline-none h-[35px]",style:{...i},type:"text",...e}),SearchInput=({term:i="",placeholder:e="Search",noSpacing:t=!1,onClick:n=()=>!1,isStatic:s=!1,hasDropDown:o=!1,onSearch:a,className:l,value:c,inputClassName:u})=>{const[h,d]=React.useState("");return React.useEffect(()=>{c!==void 0&&c!==h&&d(c??"")},[c]),jsxRuntimeExports.jsxs("div",{className:cn(`relative w-full ${t?"":"mt-2"}`,l),onClick:n??(()=>!1),children:[s?jsxRuntimeExports.jsx("div",{className:"panel-property_input w-full rounded px-3 py-2 text-sm font-normal cursor-pointer",children:i}):jsxRuntimeExports.jsx("input",{className:cn("panel-property_input w-full rounded py-2 pl-3 pr-10 text-[14px] outline-none focus:border-[color:var(--dark-blue,#1ca6fc)]",u),type:"text",placeholder:e,onChange:p=>{a(p.target.value,p),d(p.target.value)},value:h,onClick:n??(()=>!1)}),!s&&!o&&jsxRuntimeExports.jsx(FaMagnifyingGlass,{className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-[color:var(--properties-color,#2F3033)] opacity-70",size:18}),n!==null&&o&&jsxRuntimeExports.jsx("span",{className:"absolute right-2 top-1/2 -translate-y-1/2",style:{zIndex:1},children:jsxRuntimeExports.jsx(FaSortDown,{className:"-mb-1"})})]})},PAINT_FAMILIES={Spectrum:{hues:[6,26,44,62,96,150,188,212,244,316],saturation:52},"Earth tones":{hues:[10,18,25,32,38,45,58,74,92,128],saturation:34},"Cool tones":{hues:[162,178,192,202,212,222,234,250,272,300],saturation:38},Neutrals:{hues:[28,34,42,58,96,168,204,224,262,320],saturation:7}},PAINT_LIGHTNESS=[24,34,44,54,64,73,81,89,95],chromaFor=(i,e)=>{const t=Math.min(1,Math.abs(e-55)/45);return Math.max(3,i*(1-.5*t*t))},perceptualLightness=(i,e)=>{const t=-6*Math.cos((i-60)*Math.PI/180),n=Math.sin(Math.PI*e/100);return Math.max(0,Math.min(100,e+t*n))},hslToHex=(i,e,t)=>{const n=t/100,s=(1-Math.abs(2*n-1))*(e/100),o=s*(1-Math.abs(i/60%2-1)),a=n-s/2,[l,c,u]=i<60?[s,o,0]:i<120?[o,s,0]:i<180?[0,s,o]:i<240?[0,o,s]:i<300?[o,0,s]:[s,0,o];return`#${[l,c,u].map(h=>Math.round((h+a)*255).toString(16).padStart(2,"0")).join("")}`.toUpperCase()},buildSwatch=(i,e,t)=>hslToHex((i%360+360)%360,chromaFor(e,t),perceptualLightness(i,t)),PaintPalette=({value:i,onChange:e})=>{const[t,n]=React.useState("Spectrum"),[s,o]=React.useState(i.toUpperCase()),[a,l]=React.useState(0);React.useEffect(()=>{o(i.toUpperCase())},[i]);const c=/^#[0-9A-F]{6}$/i.test(s),u=i.toUpperCase(),h=_=>{const x=_.startsWith("#")?_:`#${_}`;o(x.toUpperCase()),/^#[0-9A-F]{6}$/i.test(x)&&e(x.toUpperCase())},d=PAINT_FAMILIES[t],p=d.saturation>=12,f=p?a:0,g=d.hues.map(_=>PAINT_LIGHTNESS.map(x=>buildSwatch(_+f,d.saturation,x)));return jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntimeExports.jsxs("div",{className:"relative",children:[jsxRuntimeExports.jsx("input",{type:"text",value:s,onChange:_=>h(_.target.value),placeholder:"#82695F",spellCheck:!1,maxLength:7,"aria-label":"Color hex value","aria-invalid":!c,className:"panel-property_input w-full rounded py-2 pl-3 pr-12 text-[14px] uppercase outline-none focus:border-[color:var(--dark-blue,#1ca6fc)]",style:c?void 0:{borderColor:"#EF4444"}}),jsxRuntimeExports.jsx("label",{className:"absolute right-2 top-1/2 h-7 w-7 -translate-y-1/2 cursor-pointer overflow-hidden rounded border border-[color:var(--properties-input-border,#E5E7EB)] shadow-[inset_0_0_0_1px_rgba(255,255,255,0.6)]",style:{background:c?s:"transparent"},title:"Pick a color",children:jsxRuntimeExports.jsx("input",{type:"color",value:c?s:"#FFFFFF",onChange:_=>h(_.target.value),"aria-label":"Pick a color",className:"h-full w-full cursor-pointer opacity-0"})})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Palette"}),jsxRuntimeExports.jsx(FormSelect,{value:t,onChange:_=>n(_.target.value),children:Object.keys(PAINT_FAMILIES).map(_=>jsxRuntimeExports.jsx("option",{value:_,children:_},_))})]}),p&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Hue"}),jsxRuntimeExports.jsxs("div",{className:"relative h-8 overflow-hidden rounded border border-[color:var(--properties-input-border,#E5E7EB)]",children:[jsxRuntimeExports.jsx("div",{className:"absolute inset-0",style:{background:"linear-gradient(90deg, #ef4444, #f59e0b, #eab308, #22c55e, #06b6d4, #3b82f6, #8b5cf6, #ec4899, #ef4444)"}}),jsxRuntimeExports.jsx("input",{type:"range",min:"0",max:"359",value:a,onChange:_=>l(Number(_.target.value)),"aria-label":"Adjust palette hue",className:"absolute inset-0 z-10 h-full w-full cursor-pointer opacity-0"}),jsxRuntimeExports.jsx("div",{className:"pointer-events-none absolute top-1/2 z-20 h-7 w-7 -translate-y-1/2 rounded border-[3px] border-white shadow-[0_0_0_1px_rgba(0,0,0,0.25)]",style:{left:`calc(${a/359*100}% - 14px)`}})]})]}),jsxRuntimeExports.jsx("div",{className:"grid overflow-hidden rounded border border-[color:var(--properties-input-border,#E5E7EB)]",style:{gridTemplateColumns:`repeat(${PAINT_LIGHTNESS.length}, minmax(0, 1fr))`},children:g.flat().map((_,x)=>{const y=_===u;return jsxRuntimeExports.jsx("button",{type:"button","aria-label":`Select ${_}`,"aria-pressed":y,title:_,onClick:()=>e(_),className:cn("relative aspect-square focus:z-10 focus:outline-none",y?"z-10":"hover:z-10 hover:shadow-[inset_0_0_0_2px_rgba(255,255,255,0.75),inset_0_0_0_3px_rgba(0,0,0,0.2)]"),style:{background:_,boxShadow:y?"inset 0 0 0 2px #fff, inset 0 0 0 4px var(--dark-blue, #1ca6fc)":void 0}},`${_}-${x}`)})})]})},BackHeader$1=({title:i,subtitle:e,onBack:t})=>jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[jsxRuntimeExports.jsx("button",{type:"button",onClick:t,className:"w-7 h-7 flex items-center justify-center rounded hover:bg-[color:var(--panel-property-background-hover,#E5E7EB)] cursor-pointer","aria-label":"Back",children:jsxRuntimeExports.jsx(FaChevronLeft,{size:12})}),jsxRuntimeExports.jsxs("div",{className:"min-w-0",children:[jsxRuntimeExports.jsx("div",{className:"text-[11px] text-gray-500 leading-tight",children:i}),e&&jsxRuntimeExports.jsx("div",{className:"text-[14px] font-semibold truncate leading-tight",children:e})]})]}),RowButton$1=({swatchColor:i,textureUri:e,icon:t,label:n,value:s,onClick:o})=>jsxRuntimeExports.jsxs("button",{type:"button",onClick:o,className:"w-full flex items-center gap-3 px-3 py-2 rounded bg-[color:var(--panel-property-background,#F3F4F6)] hover:bg-[color:var(--panel-property-background-hover,#E5E7EB)] text-left",children:[i!==void 0&&jsxRuntimeExports.jsx("span",{className:"w-7 h-7 rounded flex-shrink-0 border border-gray-200",style:{background:i,backgroundImage:e?`url(${e})`:void 0,backgroundSize:"cover",backgroundPosition:"center"}}),t&&jsxRuntimeExports.jsx("span",{className:"w-8 h-8 flex items-center justify-center flex-shrink-0",children:t}),jsxRuntimeExports.jsxs("span",{className:"flex-1 min-w-0",children:[n&&jsxRuntimeExports.jsx("span",{className:"block text-[11px] text-gray-500 leading-tight",children:n}),s&&jsxRuntimeExports.jsx("span",{className:"block text-[14px] font-medium truncate leading-tight",children:s})]}),jsxRuntimeExports.jsx(FaChevronRight,{size:12,className:"text-gray-500 flex-shrink-0"})]}),MeasureStepper=({value:i,onChange:e,step:t=1,min:n=0,max:s=1e4,unit:o="cm"})=>{const a=l=>Math.max(n,Math.min(s,l));return jsxRuntimeExports.jsxs("div",{className:"panel-property_input flex items-stretch h-[35px] rounded overflow-hidden text-sm",children:[jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>e(a(i-t)),className:"w-8 flex items-center justify-center text-[color:var(--dark-blue,#1ca6fc)] hover:bg-[color:var(--panel-property-background-hover,#E5E7EB)] transition-colors","aria-label":"Decrease",children:jsxRuntimeExports.jsx(FaMinus,{size:11})}),jsxRuntimeExports.jsxs("div",{className:"flex-1 flex items-center justify-center gap-1 min-w-0",children:[jsxRuntimeExports.jsx("input",{type:"number",value:Number.isFinite(i)?i:0,onChange:l=>{const c=Number(l.target.value);Number.isFinite(c)&&e(a(c))},className:"w-full text-center outline-none bg-transparent leading-none [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"}),o&&jsxRuntimeExports.jsx("span",{className:"text-[11px] opacity-60 pr-1",children:o})]}),jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>e(a(i+t)),className:"w-8 flex items-center justify-center text-[color:var(--dark-blue,#1ca6fc)] hover:bg-[color:var(--panel-property-background-hover,#E5E7EB)] transition-colors","aria-label":"Increase",children:jsxRuntimeExports.jsx(FaPlus,{size:11})})]})},ActionRow=({actions:i})=>jsxRuntimeExports.jsx("div",{className:"flex items-center gap-2 flex-wrap",children:i.map(e=>jsxRuntimeExports.jsx("button",{type:"button",title:e.label,"aria-label":e.label,onClick:e.onClick,className:cn("w-10 h-10 rounded-full flex items-center justify-center text-[17px] border border-[color:var(--panel-property-background-hover,#E5E7EB)]","hover:bg-[color:var(--panel-property-background-hover,#E5E7EB)] transition-colors cursor-pointer",e.danger&&"text-red-500 hover:text-red-500"),children:e.icon},e.key))}),MaterialPicker=({textures:i,value:e,onChange:t,label:n})=>{const[s,o]=React.useState(""),[a,l]=React.useState("all"),c=Object.entries(i),u=i[e],h=[];for(const[,f]of c)for(const g of f.tag??[])h.includes(g)||h.push(g);const d=s.trim().toLowerCase(),p=c.filter(([f,g])=>{var y;const _=a==="all"||((y=g.tag)==null?void 0:y.includes(a)),x=!d||g.name.toLowerCase().includes(d)||f.toLowerCase().includes(d);return _&&x});return c.length===0?null:jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4",children:[n&&jsxRuntimeExports.jsx(FormLabel,{children:n}),jsxRuntimeExports.jsx(SearchInput,{noSpacing:!0,value:s,placeholder:"Search",onSearch:f=>o(f)}),h.length>0&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Category"}),jsxRuntimeExports.jsxs(FormSelect,{value:a,onChange:f=>l(f.target.value),children:[jsxRuntimeExports.jsx("option",{value:"all",children:"All materials"}),h.map(f=>jsxRuntimeExports.jsx("option",{value:f,children:f},f))]})]}),jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>t("none"),className:"rounded overflow-hidden text-left aspect-square border transition-colors flex flex-col",style:{borderColor:e==="none"?"var(--dark-blue, #1ca6fc)":"var(--properties-input-border, #E5E7EB)",borderWidth:2},children:jsxRuntimeExports.jsx("div",{className:"flex-1 flex items-center justify-center text-[11px] text-[color:var(--properties-color,#2F3033)] opacity-70 bg-[color:var(--panel-property-background,#F3F4F6)]",children:"None"})}),p.map(([f,g])=>jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>t(f),className:"rounded overflow-hidden text-left aspect-square border transition-colors flex flex-col",style:{borderColor:f===e?"var(--dark-blue, #1ca6fc)":"var(--properties-input-border, #E5E7EB)",borderWidth:2},title:g.name,children:jsxRuntimeExports.jsx("div",{className:"flex-1",style:{backgroundImage:`url(${g.uri})`,backgroundSize:"cover",backgroundPosition:"center"}})},f))]}),p.length===0&&jsxRuntimeExports.jsx("div",{className:"text-center text-[13px] text-[color:var(--properties-color,#2F3033)] opacity-70 py-6",children:"No materials match this search."}),u&&jsxRuntimeExports.jsx("div",{className:"text-[12px] text-[color:var(--properties-color,#2F3033)] opacity-70",children:u.name})]})},FinishPicker=({color:i,onColorChange:e,textures:t,texture:n,onTextureChange:s,patterns:o})=>{const[a,l]=React.useState("colors");return jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntimeExports.jsx("div",{className:"grid grid-cols-2 overflow-hidden rounded-lg border border-[color:var(--properties-input-border,#E5E7EB)] bg-[color:var(--panel-property-background,#F3F4F6)]",children:[["colors","Colors"],["materials","Materials"]].map(([c,u])=>jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>l(c),className:"p-2 text-[14px] font-semibold transition-colors",style:{background:a===c?"var(--dark-blue, #1ca6fc)":"var(--panel-property-background, #F3F4F6)",color:a===c?"white":"var(--properties-color)"},children:u},c))}),a==="colors"&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(PaintPalette,{value:i,onChange:e}),o]}),a==="materials"&&jsxRuntimeExports.jsx(MaterialPicker,{textures:t,value:n,onChange:s})]})},ElementPreview=({imageUri:i,alt:e})=>jsxRuntimeExports.jsx("div",{className:"w-full aspect-[4/3] bg-[color:var(--panel-property-background,#F3F4F6)] rounded flex items-center justify-center overflow-hidden",children:i?jsxRuntimeExports.jsx("img",{src:i,alt:e,loading:"lazy",decoding:"async",className:"max-w-full max-h-full object-contain"}):jsxRuntimeExports.jsx("span",{className:"text-[11px] text-gray-500",children:"No preview"})});function darkenHex(i,e=.55){const t=/^#([0-9a-f]{6})$/i.exec(i);if(!t)return i;const n=parseInt(t[1],16),s=Math.max(0,Math.min(255,Math.round((n>>16&255)*e))),o=Math.max(0,Math.min(255,Math.round((n>>8&255)*e))),a=Math.max(0,Math.min(255,Math.round((n&255)*e)));return`#${(s<<16|o<<8|a).toString(16).padStart(6,"0")}`}const AREA_PATTERNS=[{key:"diagonal-stripes",name:"Diagonal stripes",size:10,rotation:45,marks:i=>`<line x1="0" y1="0" x2="0" y2="10" stroke="${i}" stroke-width="2"/>`},{key:"vertical-lines",name:"Vertical lines",size:12,marks:i=>`<line x1="6" y1="0" x2="6" y2="12" stroke="${i}" stroke-width="2"/>`},{key:"horizontal-lines",name:"Horizontal lines",size:12,marks:i=>`<line x1="0" y1="6" x2="12" y2="6" stroke="${i}" stroke-width="2"/>`},{key:"dashed",name:"Dashed",size:12,marks:i=>`<line x1="0" y1="6" x2="12" y2="6" stroke="${i}" stroke-width="2" stroke-dasharray="5 3"/>`},{key:"grid",name:"Grid",size:16,marks:i=>`<path d="M 16 0 L 0 0 L 0 16" stroke="${i}" stroke-width="1.5" fill="none"/>`},{key:"diagonal-grid",name:"Diagonal grid",size:12,rotation:45,marks:i=>`<path d="M 12 0 L 0 0 L 0 12" stroke="${i}" stroke-width="1.5" fill="none"/>`},{key:"thick-stripes",name:"Thick stripes",size:14,marks:i=>`<rect x="0" y="0" width="4" height="14" fill="${i}"/><rect x="8" y="0" width="2" height="14" fill="${i}"/>`},{key:"dots-small",name:"Small dots",size:8,marks:i=>`<circle cx="4" cy="4" r="1.1" fill="${i}"/>`},{key:"dots-large",name:"Large dots",size:14,marks:i=>`<circle cx="7" cy="7" r="2.2" fill="${i}"/>`},{key:"chevrons",name:"Chevrons",size:12,marks:i=>`<path d="M 1 3 L 6 8 L 11 3" stroke="${i}" stroke-width="1.5" fill="none"/>`},{key:"bricks",name:"Bricks",size:24,marks:i=>`<g stroke="${i}" stroke-width="1" fill="none"><rect x="0" y="0" width="24" height="12"/><line x1="12" y1="12" x2="12" y2="24"/><line x1="0" y1="12" x2="24" y2="12"/><line x1="0" y1="24" x2="24" y2="24"/></g>`},{key:"cross-hatch",name:"Cross-hatch",size:8,marks:i=>`<g stroke="${i}" stroke-width="0.8"><line x1="-1" y1="-1" x2="9" y2="9"/><line x1="9" y1="-1" x2="-1" y2="9"/></g>`}],PATTERN_BY_KEY=new Map(AREA_PATTERNS.map(i=>[i.key,i]));function getAreaPattern(i){if(!(!i||i==="none"))return PATTERN_BY_KEY.get(i)}function patternTransform(i){return i.rotation?`rotate(${i.rotation})`:void 0}function PatternMarks({pattern:i,color:e}){return jsxRuntimeExports.jsx("g",{dangerouslySetInnerHTML:{__html:i.marks(e)}})}function tileSide(i){return i.rotation?i.size*Math.SQRT2:i.size}function patternTileDataURI(i,e,t){const n=Math.round(tileSide(i)*1e4)/1e4,s=Math.round(n*Math.max(2,Math.ceil(160/n))),o=patternTransform(i),a=`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${s}" viewBox="0 0 ${n} ${n}"><defs><pattern id="p" patternUnits="userSpaceOnUse" width="${i.size}" height="${i.size}"`+(o?` patternTransform="${o}"`:"")+`>${i.marks(t)}</pattern></defs><rect width="${n}" height="${n}" fill="${e}"/><rect width="${n}" height="${n}" fill="url(#p)"/></svg>`;return{uri:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(a)}`,tileSize:n}}const NEUTRAL_PREVIEW_FILL="#FFDFBF",UNSELECTED_SWATCH="#E5E7EB",readVertices=(i,e)=>i.vertices.toArray().map(t=>{const{x:n,y:s}=e.vertices.get(t);return{x:n,y:s}}),computeAreaSize=(i,e)=>{const t=readVertices(i,e).map(s=>[s.x,s.y]);let n=areapolygon(t);return i.holes.forEach(s=>{const a=e.areas.get(s).vertices.toArray().map(l=>{const{x:c,y:u}=e.vertices.get(l);return[c,u]});n-=areapolygon(a)}),n},AreaPreview=({element:i,layer:e,color:t,label:n,pattern:s})=>{const o=readVertices(i,e);if(o.length===0)return null;const a=o.map(v=>v.x),l=o.map(v=>v.y),c=Math.min(...a),u=Math.max(...a),h=Math.min(...l),d=Math.max(...l),p=Math.max(u-c,1),f=Math.max(d-h,1),g=Math.max(p,f)*.1,_=o.map((v,M)=>`${M===0?"M":"L"}${v.x} ${v.y}`).join(" ")+" Z",x=[];i.holes.forEach(v=>{const T=e.areas.get(v).vertices.toArray().map(I=>{const{x:w,y:R}=e.vertices.get(I);return{x:w,y:R}});x.push(T.map((I,w)=>`${w===0?"M":"L"}${I.x} ${I.y}`).join(" ")+" Z")});const y=`${c-g} ${-(d+g)} ${p+g*2} ${f+g*2}`,E=t||NEUTRAL_PREVIEW_FILL,b=`preview-pattern-${i.id}`;return jsxRuntimeExports.jsx("div",{className:"w-full aspect-[16/9] bg-[color:var(--panel-property-background,#F3F4F6)] rounded flex items-center justify-center overflow-hidden relative",children:jsxRuntimeExports.jsxs("svg",{viewBox:y,className:"w-full h-full",preserveAspectRatio:"xMidYMid meet",children:[s&&jsxRuntimeExports.jsx("defs",{children:jsxRuntimeExports.jsx("pattern",{id:b,patternUnits:"userSpaceOnUse",width:s.size,height:s.size,patternTransform:patternTransform(s),children:jsxRuntimeExports.jsx(PatternMarks,{pattern:s,color:darkenHex(E)})})}),jsxRuntimeExports.jsxs("g",{transform:"scale(1, -1)",children:[jsxRuntimeExports.jsx("path",{d:[_,...x].join(" "),fill:E,fillRule:"evenodd"}),s&&jsxRuntimeExports.jsx("path",{d:[_,...x].join(" "),fill:`url(#${b})`,fillRule:"evenodd"})]})]})})},PatternSwatch=({pattern:i,color:e,size:t=48,className:n,rounded:s=!0})=>{const o=`swatch-pattern-${i.key}-${e.replace("#","")}`,a=darkenHex(e);return jsxRuntimeExports.jsxs("svg",{width:t,height:t,viewBox:`0 0 ${t} ${t}`,className:n,style:{display:"block",borderRadius:s?4:0},children:[jsxRuntimeExports.jsx("defs",{children:jsxRuntimeExports.jsx("pattern",{id:o,patternUnits:"userSpaceOnUse",width:i.size,height:i.size,patternTransform:patternTransform(i),children:jsxRuntimeExports.jsx(PatternMarks,{pattern:i,color:a})})}),jsxRuntimeExports.jsx("rect",{width:t,height:t,fill:e}),jsxRuntimeExports.jsx("rect",{width:t,height:t,fill:`url(#${o})`})]})},RowButton=({swatchColor:i,textureUri:e,patternPreview:t,icon:n,label:s,value:o,onClick:a})=>jsxRuntimeExports.jsxs("button",{type:"button",onClick:a,className:"w-full flex items-center gap-3 px-3 py-2 rounded bg-[color:var(--panel-property-background,#F3F4F6)] hover:bg-[color:var(--panel-property-background-hover,#E5E7EB)] text-left",children:[t&&i&&jsxRuntimeExports.jsx("span",{className:"w-7 h-7 rounded flex-shrink-0 border border-gray-200 overflow-hidden",children:jsxRuntimeExports.jsx(PatternSwatch,{pattern:t,color:i,size:28,rounded:!1})}),!t&&i!==void 0&&jsxRuntimeExports.jsx("span",{className:"w-7 h-7 rounded flex-shrink-0 border border-gray-200 bg-center bg-cover",style:{background:i||UNSELECTED_SWATCH,backgroundImage:e?`url(${e})`:void 0,backgroundSize:"cover"}}),n&&jsxRuntimeExports.jsx("span",{className:"w-8 h-8 flex items-center justify-center flex-shrink-0",children:n}),jsxRuntimeExports.jsxs("span",{className:"flex-1 min-w-0",children:[s&&jsxRuntimeExports.jsx("span",{className:"block text-[11px] text-gray-500 leading-tight",children:s}),o&&jsxRuntimeExports.jsx("span",{className:"block text-[14px] font-medium truncate leading-tight",children:o})]}),jsxRuntimeExports.jsx(FaChevronRight,{size:12,className:"text-gray-500 flex-shrink-0"})]}),BackHeader=({title:i,subtitle:e,onBack:t})=>jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[jsxRuntimeExports.jsx("button",{type:"button",onClick:t,className:"w-7 h-7 flex items-center justify-center rounded hover:bg-[color:var(--panel-property-background-hover,#E5E7EB)] cursor-pointer","aria-label":"Back",children:jsxRuntimeExports.jsx(FaChevronLeft,{size:12})}),jsxRuntimeExports.jsxs("div",{className:"min-w-0",children:[jsxRuntimeExports.jsx("div",{className:"text-[11px] text-gray-500 leading-tight",children:i}),e&&jsxRuntimeExports.jsx("div",{className:"text-[14px] font-semibold truncate leading-tight",children:e})]})]}),AreaAttributesEditor=({element:i,layer:e,catalog:t})=>{const{setProperties:n}=useReactPlannerStore(),[s,o]=React.useState("main"),a=i.properties.get("roomCategory")||"",l=i.properties.get("roomType")||"",c=i.properties.get("customName")||"",u=i.properties.get("showName")??!0,h=i.properties.get("showSurfaceArea")??!1,d=i.properties.get("patternColor")||"#FFFFFF",p=i.properties.get("texture")||"none",f=i.properties.get("pattern")||"none",g=getCategory(a),_=getRoomType(a,l),x=t.getElement(i.type).textures||{},y=x[p],E=getAreaPattern(f),[b,v]=React.useState((g==null?void 0:g.value)||""),M=getCategory(b),T=c||(_==null?void 0:_.label)||"",I=A=>{n(Map$1(A))},w=A=>{if(!M)return;const P=M.types.find(B=>B.value===A);P&&I({roomCategory:M.value,roomType:P.value,patternColor:P.color})};if(s==="roomtype")return jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-3",children:[jsxRuntimeExports.jsx(BackHeader,{title:"Choose Roomtype",subtitle:(_==null?void 0:_.label)||"Unknown",onBack:()=>o("main")}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Category"}),jsxRuntimeExports.jsxs(FormSelect,{value:(M==null?void 0:M.value)??"",onChange:A=>v(A.target.value),children:[jsxRuntimeExports.jsx("option",{value:"",disabled:!0,children:"Select a category"}),ROOM_CATEGORIES.map(A=>jsxRuntimeExports.jsx("option",{value:A.value,children:A.label},A.value))]})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Type"}),jsxRuntimeExports.jsxs(FormSelect,{value:(M==null?void 0:M.value)===(g==null?void 0:g.value)?l:"",disabled:!M,onChange:A=>w(A.target.value),children:[jsxRuntimeExports.jsx("option",{value:"",disabled:!0,children:"Select a type"}),M==null?void 0:M.types.map(A=>jsxRuntimeExports.jsx("option",{value:A.value,children:A.label},A.value))]})]}),jsxRuntimeExports.jsx("div",{className:"text-[12px] text-gray-500 mt-1",children:"Pick a roomtype for this area"}),jsxRuntimeExports.jsx("div",{className:"grid grid-cols-2 gap-2",children:((M==null?void 0:M.types)??[]).map(A=>{const P=(M==null?void 0:M.value)===(g==null?void 0:g.value)&&A.value===l;return jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>w(A.value),className:"rounded px-3 py-2 text-left text-[13px] font-medium transition-colors",style:{background:A.color,outline:P?"2px solid var(--dark-blue, #1ca6fc)":"none",outlineOffset:-2},children:A.label},A.value)})})]});if(s==="material"){const A=(E==null?void 0:E.name)||(y==null?void 0:y.name)||d.toUpperCase();return jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntimeExports.jsx(BackHeader,{title:"Material",subtitle:A,onBack:()=>o("main")}),jsxRuntimeExports.jsx(FinishPicker,{color:d,onColorChange:P=>I({patternColor:P}),textures:x,texture:p,onTextureChange:P=>I(P==="none"?{texture:"none"}:{texture:P,pattern:"none"}),patterns:jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Patterns"}),jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>I({pattern:"none"}),className:"rounded overflow-hidden text-left aspect-square border transition-colors flex items-center justify-center",style:{borderColor:f==="none"?"var(--dark-blue, #1ca6fc)":"var(--properties-input-border, #E5E7EB)",borderWidth:2,background:d},title:"None",children:jsxRuntimeExports.jsx("span",{className:"text-[11px] text-gray-700 bg-white/70 px-1.5 rounded",children:"None"})}),AREA_PATTERNS.map(P=>{const B=P.key===f;return jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>I({pattern:P.key,texture:"none"}),className:"rounded overflow-hidden text-left aspect-square border transition-colors",style:{borderColor:B?"var(--dark-blue, #1ca6fc)":"var(--properties-input-border, #E5E7EB)",borderWidth:2},title:P.name,children:jsxRuntimeExports.jsx(PatternSwatch,{pattern:P,color:d,size:80,rounded:!1})},P.key)})]}),E&&jsxRuntimeExports.jsx("div",{className:"text-[12px] text-gray-500 mt-2",children:E.name})]})})]})}if(s==="settings"){const A=computeAreaSize(i,e);return jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntimeExports.jsx(BackHeader,{title:"Room Settings",subtitle:T||"Unnamed",onBack:()=>o("main")}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Custom Name"}),jsxRuntimeExports.jsx(FormTextInput,{value:c,onChange:P=>I({customName:P.target.value}),placeholder:"e.g. Master bedroom",style:{textAlign:"left"}})]}),jsxRuntimeExports.jsxs("div",{className:"flex items-start justify-between gap-4",children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"text-[11px] text-gray-500 leading-tight",children:"Total Area"}),jsxRuntimeExports.jsxs("div",{className:"text-[16px] font-semibold",children:[(A/1e4).toFixed(2)," m²"]})]}),jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-2",children:[jsxRuntimeExports.jsxs("label",{className:"flex items-center gap-2 text-[13px] cursor-pointer",children:[jsxRuntimeExports.jsx("input",{type:"checkbox",className:"m-0",checked:!!u,onChange:()=>I({showName:!u})}),"Show name in 2D"]}),jsxRuntimeExports.jsxs("label",{className:"flex items-center gap-2 text-[13px] cursor-pointer",children:[jsxRuntimeExports.jsx("input",{type:"checkbox",className:"m-0",checked:!!h,onChange:()=>I({showSurfaceArea:!h})}),"Show surface area"]})]})]})]})}const R=computeAreaSize(i,e);return jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-3 mb-2",children:[jsxRuntimeExports.jsx(AreaPreview,{element:i,layer:e,color:d,label:T,pattern:E}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"text-[11px] text-gray-500 leading-tight",children:"Room"}),jsxRuntimeExports.jsxs("div",{className:"text-[16px] font-semibold",children:[(R/1e4).toFixed(2)," m²"]})]}),jsxRuntimeExports.jsx(RowButton,{swatchColor:_==null?void 0:_.color,label:"Roomtype",value:(_==null?void 0:_.label)||"Unknown",onClick:()=>{v((g==null?void 0:g.value)||""),o("roomtype")}}),jsxRuntimeExports.jsx(RowButton,{swatchColor:d,textureUri:y==null?void 0:y.uri,patternPreview:E,label:"Material",value:(E==null?void 0:E.name)||(y==null?void 0:y.name)||d.toUpperCase(),onClick:()=>o("material")}),jsxRuntimeExports.jsx(RowButton,{icon:jsxRuntimeExports.jsx(FaCog,{size:20}),label:"",value:"Settings",onClick:()=>o("settings")})]})},tagsOf=i=>{var e;return(((e=i.info)==null?void 0:e.tag)??[]).map(t=>String(t).toLowerCase())},isBrowsable=i=>{var e;return(e=i.info)!=null&&e.visibility?i.info.visibility.catalog:!0};function findSimilarElements(i,e){let t;try{t=i.getElement(e.type)}catch{return[]}const n=new Set(tagsOf(t));return n.size===0?[]:i.getElementsOfPrototype(e.prototype).filter(s=>s.name!==t.name).filter(isBrowsable).map(s=>({candidate:s,shared:tagsOf(s).filter(o=>n.has(o)).length})).filter(({shared:s})=>s>0).sort((s,o)=>o.shared-s.shared||(s.candidate.info.title??"").localeCompare(o.candidate.info.title??"")).map(({candidate:s})=>s)}const SimilarElementsGrid=({elements:i,containerSelector:e=".floor_planner-sidebar"})=>{const{selectToolDrawingItem:t,selectToolDrawingHole:n,pushLastSelectedCatalogElementToHistory:s}=useReactPlannerStore(),o=l=>{switch(l.prototype){case"items":t(l.name);break;case"holes":n(l.name);break;default:return}s(l)},a=(l,c)=>{l.preventDefault();const u=l.currentTarget.closest(e);if(!u)return;const h=()=>{u.removeEventListener("mouseleave",d),document.removeEventListener("mouseup",p)},d=()=>{o(c),h()},p=()=>h();u.addEventListener("mouseleave",d),document.addEventListener("mouseup",p)};return i.length===0?jsxRuntimeExports.jsx("p",{className:"text-sm font-medium text-gray-400 text-center py-6",children:"No similar items"}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("p",{className:"text-[11px] text-gray-500",children:"Drag one onto the plan to place it."}),jsxRuntimeExports.jsx("div",{className:"grid grid-cols-2 gap-x-4 gap-y-5",children:i.map(l=>jsxRuntimeExports.jsxs("div",{className:"w-full space-y-1.5",title:l.info.title,children:[jsxRuntimeExports.jsx("div",{className:"fp-aspect-ratio-container",children:jsxRuntimeExports.jsx("div",{className:"fp-aspect-ratio-content",onMouseDown:c=>a(c,l),children:jsxRuntimeExports.jsx("img",{draggable:!1,loading:"lazy",decoding:"async",className:"fp-item-image",alt:l.info.title,src:l.info.image})})}),jsxRuntimeExports.jsx("p",{className:"text-xs font-semibold capitalize truncate",children:l.info.title})]},l.name.replace(/\s+/g,"_")))})]})},HoleAttributesEditor=({element:i,catalog:e})=>{const{planner:t,setHoleProperties:n,duplicateSelected:s,flipSelected:o,remove:a}=useReactPlannerStore(),[l,c]=React.useState("main"),u=React.useMemo(()=>findSimilarElements(e,i),[e,i.type,i.prototype]),h=t.mode!==MODE_3D_VIEW&&u.length>0,d=i.properties.get("customName")||"",p=i.properties.get("showName")??!1,f=I=>i.properties.getIn([I,"length"])??0,g=f("width"),_=f("height"),x=f("altitude"),y=f("thickness"),E=(()=>{try{return e.getElement(i.type).info??{}}catch{return{}}})(),b=t.scene.unit,v=(I,w)=>{const R=i.properties.get(I)||Map$1();n(i.id,{[I]:R.set("length",w).set("_length",w)})},M=I=>n(i.id,I),T=[{key:"duplicate",label:"Duplicate",icon:jsxRuntimeExports.jsx(LuCopy,{}),onClick:s},{key:"flip-hinge",label:"Flip hinge side",icon:jsxRuntimeExports.jsx(PiFlipHorizontalBold,{}),onClick:()=>o("x")},{key:"flip-opening",label:"Flip opening side",icon:jsxRuntimeExports.jsx(PiFlipVerticalBold,{}),onClick:()=>o("y")},{key:"delete",label:"Delete",icon:jsxRuntimeExports.jsx(LuTrash2,{}),danger:!0,onClick:()=>a()}];return l==="similar"&&h?jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-3",children:[jsxRuntimeExports.jsx(BackHeader$1,{title:"Similar Items",subtitle:E.title||i.name,onBack:()=>c("main")}),jsxRuntimeExports.jsx(SimilarElementsGrid,{elements:u})]}):l==="settings"?jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntimeExports.jsx(BackHeader$1,{title:"Settings",subtitle:d||i.name,onBack:()=>c("main")}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Custom Name"}),jsxRuntimeExports.jsx(FormTextInput,{value:d,onChange:I=>M({customName:I.target.value}),placeholder:i.name,style:{textAlign:"left"}})]}),jsxRuntimeExports.jsxs("label",{className:"flex items-center gap-2 text-[13px] cursor-pointer",children:[jsxRuntimeExports.jsx("input",{type:"checkbox",className:"m-0",checked:p,onChange:()=>M({showName:!p})}),"Show name in 2D"]}),jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Width"}),jsxRuntimeExports.jsx(MeasureStepper,{value:Math.round(g),onChange:I=>v("width",I),min:1,max:1e3})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Height"}),jsxRuntimeExports.jsx(MeasureStepper,{value:Math.round(_),onChange:I=>v("height",I),min:1,max:1e3})]})]}),jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Raise From Floor"}),jsxRuntimeExports.jsx(MeasureStepper,{value:Math.round(x),onChange:I=>v("altitude",I),min:0,max:1e3})]}),i.properties.has("thickness")&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Thickness"}),jsxRuntimeExports.jsx(MeasureStepper,{value:Math.round(y),onChange:I=>v("thickness",I),min:1,max:200})]})]})]}):jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-3 mb-2",children:[jsxRuntimeExports.jsx(ElementPreview,{imageUri:E.image,alt:i.name}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"text-[11px] text-gray-500 leading-tight",children:"Dimensions"}),jsxRuntimeExports.jsxs("div",{className:"text-[16px] font-semibold",children:[formatDistance(g,b)," × ",formatDistance(_,b)]})]}),jsxRuntimeExports.jsx(ActionRow,{actions:T}),jsxRuntimeExports.jsx(RowButton$1,{icon:jsxRuntimeExports.jsx(FaCog,{size:20}),label:"",value:"Settings",onClick:()=>c("settings")}),h&&jsxRuntimeExports.jsx(RowButton$1,{icon:jsxRuntimeExports.jsx(MdOutlineDoorFront,{size:20}),label:"",value:"Similar Items",onClick:()=>c("similar")})]})},useNaturalSize=i=>{const[e,t]=React.useState(null);return React.useLayoutEffect(()=>{const n=document.querySelector(`#svg-drawing-paper [data-element-root][data-id="${i.id}"]`);if(!n){t(null);return}let s;try{s=n.getBBox()}catch{return}!s.width||!s.height||t(o=>o&&o.width===s.width&&o.height===s.height?o:{width:s.width,height:s.height})},[i.id,i.type]),e},ItemAttributesEditor=({element:i,catalog:e})=>{const{planner:t,setProperties:n,setItemAttributes:s,duplicateSelected:o,rotateSelected:a,flipSelected:l,remove:c}=useReactPlannerStore(),[u,h]=React.useState("main"),d=useNaturalSize(i),{scale:p}=getItemTransform(i),f=i.properties.get("customName")||"",g=i.properties.get("showName")??!1,_=i.rotation??0,x=i.altitude??0,y=(()=>{try{return e.getElement(i.type).info??{}}catch{return{}}})(),E=t.scene.unit,b=d?d.width*p:null,v=d?d.height*p:null,M=React.useMemo(()=>findSimilarElements(e,i),[e,i.type,i.prototype]),T=t.mode!==MODE_3D_VIEW&&M.length>0,I=(R,A)=>{if(!d)return;const P=R==="width"?d.width:d.height;P&&s(i.id,{scale:clampItemScale(A/P)})},w=[{key:"duplicate",label:"Duplicate",icon:jsxRuntimeExports.jsx(LuCopy,{}),onClick:o},{key:"rotate-ccw",label:"Rotate left 90°",icon:jsxRuntimeExports.jsx(LuRotateCcw,{}),onClick:()=>a(90)},{key:"rotate-cw",label:"Rotate right 90°",icon:jsxRuntimeExports.jsx(LuRotateCw,{}),onClick:()=>a(-90)},{key:"flip-horizontal",label:"Flip horizontally",icon:jsxRuntimeExports.jsx(PiFlipHorizontalBold,{}),onClick:()=>l("x")},{key:"flip-vertical",label:"Flip vertically",icon:jsxRuntimeExports.jsx(PiFlipVerticalBold,{}),onClick:()=>l("y")},{key:"delete",label:"Delete",icon:jsxRuntimeExports.jsx(LuTrash2,{}),danger:!0,onClick:()=>c()}];return u==="similar"&&T?jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-3",children:[jsxRuntimeExports.jsx(BackHeader$1,{title:"Similar Items",subtitle:y.title||i.name,onBack:()=>h("main")}),jsxRuntimeExports.jsx(SimilarElementsGrid,{elements:M})]}):u==="settings"?jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntimeExports.jsx(BackHeader$1,{title:"Object Settings",subtitle:f||i.name,onBack:()=>h("main")}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Custom Name"}),jsxRuntimeExports.jsx(FormTextInput,{value:f,onChange:R=>n(Map$1({customName:R.target.value})),placeholder:i.name,style:{textAlign:"left"}})]}),jsxRuntimeExports.jsxs("label",{className:"flex items-center gap-2 text-[13px] cursor-pointer",children:[jsxRuntimeExports.jsx("input",{type:"checkbox",className:"m-0",checked:g,onChange:()=>n(Map$1({showName:!g}))}),"Show name in 2D"]}),b!==null&&v!==null&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Width"}),jsxRuntimeExports.jsx(MeasureStepper,{value:Math.round(b),onChange:R=>I("width",R),min:1,max:5e3})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Depth"}),jsxRuntimeExports.jsx(MeasureStepper,{value:Math.round(v),onChange:R=>I("depth",R),min:1,max:5e3})]})]}),jsxRuntimeExports.jsx("div",{className:"-mt-2 text-[11px] text-gray-500",children:"Objects scale proportionally, so width and depth move together."})]}),jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Raise From Floor"}),jsxRuntimeExports.jsx(MeasureStepper,{value:Math.round(x),onChange:R=>s(i.id,{altitude:R}),min:0,max:1e3})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Rotation"}),jsxRuntimeExports.jsx(MeasureStepper,{value:Math.round(_),onChange:R=>s(i.id,{rotation:R}),step:15,min:-360,max:360,unit:"°"})]})]})]}):jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-3 mb-2",children:[jsxRuntimeExports.jsx(ElementPreview,{imageUri:y.image,alt:i.name}),b!==null&&v!==null&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"text-[11px] text-gray-500 leading-tight",children:"Dimensions"}),jsxRuntimeExports.jsxs("div",{className:"text-[16px] font-semibold",children:[formatDistance(b,E)," × ",formatDistance(v,E)]})]}),jsxRuntimeExports.jsx(ActionRow,{actions:w}),jsxRuntimeExports.jsx(RowButton$1,{icon:jsxRuntimeExports.jsx(FaCog,{size:20}),label:"",value:"Settings",onClick:()=>h("settings")}),T&&jsxRuntimeExports.jsx(RowButton$1,{icon:jsxRuntimeExports.jsx(MdOutlineChair,{size:20}),label:"",value:"Similar Items",onClick:()=>h("similar")})]})},FormNumberInput=({value:i,min:e,max:t,precision:n,onChange:s,onValid:o,onInvalid:a,style:l,placeholder:c})=>{const[u,h]=React.useState(!0),[d,p]=React.useState(i);let f=new RegExp(`^-?([0-9]+)?\\.?([0-9]{0,${n}})?$`);React.useEffect(()=>{e!==void 0&&!isNaN(e)&&isFinite(e)&&Number(d)<e&&p(e),t&&!isNaN(t)&&isFinite(t)&&Number(d)>t&&p(t)},[e,t,d]);const g=React.useMemo(()=>parseFloat(String(i)).toFixed(n)!==parseFloat(String(d)).toFixed(n),[i,d,n]),_=x=>{if(x.stopPropagation(),u){let y=d!==""&&d!=="-"?parseFloat(String(d)):0;p(y),s({target:{value:y}})}};return jsxRuntimeExports.jsxs("div",{className:"relative w-full",children:[jsxRuntimeExports.jsx("input",{type:"text",value:f.test(String(d))?d:parseFloat(String(d)).toFixed(n),className:"block text-[13px] h-[35px] w-full px-2 leading-5 rounded panel-property_input outline-none focus:outline-none",style:{...l},onChange:x=>{let y=f.test(x.target.value);y?(p(x.target.value),o&&o(x.nativeEvent)):a&&a(x.nativeEvent),h(y)},onKeyDown:x=>{var y=x.keyCode||x.which;(y==KEYBOARD_BUTTON_CODE.ENTER||y==KEYBOARD_BUTTON_CODE.TAB)&&g&&_(x)},placeholder:c}),jsxRuntimeExports.jsx("div",{onClick:x=>{g&&_(x)},title:"Confirm",className:"absolute cursor-pointer w-6 h-6 text-white top-1.5 right-1 bg-dark-blue",style:{transition:"all 0.1s linear",visibility:g?"visible":"hidden",opacity:g?"1":"0"},children:jsxRuntimeExports.jsx(MdUpdate,{style:{width:"100%",height:"100%",padding:"0.2em",color:"#FFF"}})})]})},PropertyLengthMeasure$1=({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;i.get("_unit");const{hook:h,label:d,...p}=n,f=(g,_)=>{let x=toFixedFloat(g),y=i.merge({length:x,_length:g,_unit:_});return h?h(y,s,o,a).then(E=>e(E)):e(y)};if(l!==MODE_3D_VIEW)return jsxRuntimeExports.jsxs("div",{className:"PropertyLengthMeasure w-full mb-2",children:[jsxRuntimeExports.jsx(FormLabel,{children:d}),jsxRuntimeExports.jsxs("div",{className:"w-full flex",children:[jsxRuntimeExports.jsx(FormNumberInput,{value:u,style:{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:0},onChange:g=>f(g.target.value,UNIT_CENTIMETER),onValid:t,...p}),jsxRuntimeExports.jsx("div",{className:"w-1/4 [&>*:first-child]:text-center",children:jsxRuntimeExports.jsx(FormSelect,{style:{borderTopLeftRadius:"0px",borderBottomLeftRadius:"0px"},disabled:!0,value:UNIT_CENTIMETER,onChange:g=>{},children:UNITS_LENGTH.map(g=>jsxRuntimeExports.jsx("option",{value:g,children:g},g))})})]})]})},LineAttributesEditor=({element:i,onUpdate:e,attributeFormData:t})=>{let n=t.has("name")?t.get("name"):i.name,s=t.has("lineLength")?t.get("lineLength"):null;return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsxs("div",{className:"w-full mb-2",children:[jsxRuntimeExports.jsx(FormLabel,{children:"Name"}),jsxRuntimeExports.jsx(FormTextInput,{value:n,onChange:o=>e("name",o.target.value),style:{textAlign:"left"}})]}),jsxRuntimeExports.jsx(PropertyLengthMeasure$1,{value:s,onUpdate:o=>e("lineLength",o),configs:{label:"Length",min:0,max:1/0,precision:2}})]})},DEFAULT_WALL_COLOR="#EFEFEF",SideTogglePills=({activeSide:i,onChange:e,colorA:t,colorB:n,textureUriA:s,textureUriB:o})=>jsxRuntimeExports.jsx("div",{className:"w-full grid grid-cols-2 gap-2",children:[["A","side 1",t,s],["B","side 2",n,o]].map(([a,l,c,u])=>{const h=a===i;return jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>e(a),className:"w-full flex items-center justify-between px-3 py-2 rounded transition-colors",style:{background:h?"var(--dark-blue, #1ca6fc)":"var(--panel-property-background, #F3F4F6)",color:h?"white":void 0},children:[jsxRuntimeExports.jsx("span",{className:"text-[13px] font-medium",children:l}),jsxRuntimeExports.jsx("span",{className:"w-4 h-4 rounded-full border bg-center bg-cover",style:{background:c,backgroundImage:u?`url(${u})`:void 0,backgroundSize:"cover",backgroundPosition:"center",borderColor:h?"white":"#D1D5DB"}})]},a)})}),WallPreview=({color:i,textureUri:e})=>jsxRuntimeExports.jsx("div",{className:"w-full aspect-[16/9] bg-[color:var(--panel-property-background,#F3F4F6)] rounded flex items-center justify-center overflow-hidden",children:jsxRuntimeExports.jsx("div",{className:"rounded-sm",style:{width:"40%",height:"70%",background:i,backgroundImage:e?`url(${e})`:void 0,backgroundSize:"cover",backgroundPosition:"center",boxShadow:"0 1px 6px rgba(0,0,0,0.12)"}})}),WallAttributesEditor=({element:i,layer:e,catalog:t})=>{var $,ee;const{setProperties:n}=useReactPlannerStore(),[s,o]=React.useState("main"),[a,l]=React.useState("A"),c=i.properties.get("colorA")||DEFAULT_WALL_COLOR,u=i.properties.get("colorB")||DEFAULT_WALL_COLOR,h=i.properties.get("textureA")||"none",d=i.properties.get("textureB")||"none",p=i.properties.get("customName")||"",f=i.properties.get("showName")??!1,g=i.properties.get("finishNameA")||"",_=i.properties.get("finishNameB")||"",x=t.getElement(i.type).textures||{},y=a==="A"?"colorA":"colorB",E=a==="A"?"textureA":"textureB",b=a==="A"?"finishNameA":"finishNameB",v=a==="A"?c:u,M=a==="A"?h:d,T=x[M],I=a==="A"?g:_,w=G=>{n(Map$1(G))},R=e.vertices.get(i.vertices.get(0)),A=e.vertices.get(i.vertices.get(1)),P=pointsDistance(R.x,R.y,A.x,A.y),B=i.properties.getIn(["height","length"])||0,k=i.properties.getIn(["thickness","length"])||0,W=P*B/1e4,Y=(G,K)=>{const X=(i.properties.get(G)||Map$1()).set("length",K).set("_length",K);w({[G]:X})};return s==="finish"?jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntimeExports.jsx(BackHeader$1,{title:`Wall Finish · ${a==="A"?"side 1":"side 2"}`,subtitle:I||(T==null?void 0:T.name)||v.toUpperCase(),onBack:()=>o("main")}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Finish Name"}),jsxRuntimeExports.jsx(FormTextInput,{value:I,onChange:G=>w({[b]:G.target.value}),placeholder:(T==null?void 0:T.name)||`Finish ${a==="A"?1:2}`,style:{textAlign:"left"}})]}),jsxRuntimeExports.jsx(FinishPicker,{color:v,onColorChange:G=>w({[y]:G}),textures:x,texture:M,onTextureChange:G=>w({[E]:G})})]}):s==="settings"?jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-4",children:[jsxRuntimeExports.jsx(BackHeader$1,{title:"Wall Settings",subtitle:p||"Unnamed",onBack:()=>o("main")}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Custom Name"}),jsxRuntimeExports.jsx(FormTextInput,{value:p,onChange:G=>w({customName:G.target.value}),placeholder:"e.g. Party wall",style:{textAlign:"left"}})]}),jsxRuntimeExports.jsxs("label",{className:"flex items-center gap-2 text-[13px] cursor-pointer",children:[jsxRuntimeExports.jsx("input",{type:"checkbox",className:"m-0",checked:f,onChange:()=>w({showName:!f})}),"Show name in 2D"]}),jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Thickness"}),jsxRuntimeExports.jsx(MeasureStepper,{value:Math.round(k),onChange:G=>Y("thickness",G),min:1,max:200})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(FormLabel,{children:"Wall Height"}),jsxRuntimeExports.jsx(MeasureStepper,{value:Math.round(B),onChange:G=>Y("height",G),min:1,max:1e3})]})]}),jsxRuntimeExports.jsxs("div",{className:"grid grid-cols-2 gap-4 pt-1",children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"text-[11px] text-gray-500 leading-tight",children:"Length"}),jsxRuntimeExports.jsxs("div",{className:"text-[14px] font-semibold",children:[(P/100).toFixed(2)," m"]})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"text-[11px] text-gray-500 leading-tight",children:"Surface Area"}),jsxRuntimeExports.jsxs("div",{className:"text-[14px] font-semibold",children:[W.toFixed(2)," m²"]})]})]})]}):jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-3 mb-2",children:[jsxRuntimeExports.jsx(SideTogglePills,{activeSide:a,onChange:l,colorA:c,colorB:u,textureUriA:($=x[h])==null?void 0:$.uri,textureUriB:(ee=x[d])==null?void 0:ee.uri}),jsxRuntimeExports.jsx(WallPreview,{color:v,textureUri:T==null?void 0:T.uri}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"text-[11px] text-gray-500 leading-tight",children:"Dimensions"}),jsxRuntimeExports.jsxs("div",{className:"text-[16px] font-semibold",children:[W.toFixed(2)," m²"]})]}),jsxRuntimeExports.jsx(RowButton$1,{swatchColor:v,textureUri:T==null?void 0:T.uri,label:"Wall Finish",value:I||(T==null?void 0:T.name)||v.toUpperCase(),onClick:()=>o("finish")}),jsxRuntimeExports.jsx(RowButton$1,{icon:jsxRuntimeExports.jsx(FaCog,{size:20}),label:"",value:"Settings",onClick:()=>o("settings")})]})},AttributesEditor=({element:i,layer:e,catalog:t,onUpdate:n,onValid:s,attributeFormData:o,...a})=>i.prototype==="items"?jsxRuntimeExports.jsx(ItemAttributesEditor,{element:i,catalog:t}):i.prototype==="lines"?i.type==="wall"?jsxRuntimeExports.jsx(WallAttributesEditor,{element:i,layer:e,catalog:t}):jsxRuntimeExports.jsx(LineAttributesEditor,{element:i,onUpdate:n,onValid:s,attributeFormData:o,...a}):i.prototype==="holes"?jsxRuntimeExports.jsx(HoleAttributesEditor,{element:i,catalog:t}):i.prototype==="areas"?jsxRuntimeExports.jsx(AreaAttributesEditor,{element:i,layer:e,catalog:t}):null,PRECISION=2,initAttrData=(i,e,t)=>{switch(i=typeof i.misc=="object"?i.set("misc",Map$1(i.misc)):i,i.prototype){case"items":return Map$1(i);case"lines":{let n=e.vertices.get(i.vertices.get(0)),s=e.vertices.get(i.vertices.get(1)),o=pointsDistance(n.x,n.y,s.x,s.y),a=i.misc.get("_unitLength")||t.unit,l=convert(o).from(t.unit).to(a);return Map$1({vertexOne:n,vertexTwo:s,lineLength:Map$1({length:o,_length:l,_unit:a})})}case"holes":{let n=e.lines.get(i.line),{x:s,y:o}=e.vertices.get(n.vertices.get(0)),{x:a,y:l}=e.vertices.get(n.vertices.get(1)),c=pointsDistance(s,o,a,l),u=c*i.offset-i.properties.get("width").get("length")/2,h=i.misc.get("_unitA")||t.unit,d=convert(u).from(t.unit).to(h),p=c-c*i.offset-i.properties.get("width").get("length")/2,f=i.misc.get("_unitB")||t.unit,g=convert(p).from(t.unit).to(f);return Map$1({offset:i.offset,offsetA:Map$1({length:toFixedFloat(u,PRECISION),_length:toFixedFloat(d,PRECISION),_unit:h}),offsetB:Map$1({length:toFixedFloat(p,PRECISION),_length:toFixedFloat(g,PRECISION),_unit:f})})}case"areas":return Map$1({});default:return null}},initPropData=(i,e)=>{const t=e.getElement(i.type),n={};for(const s in t.properties)n[s]=Map$1({currentValue:i.properties.has(s)?i.properties.get(s):fromJS(t.properties[s].defaultValue),configs:t.properties[s]});return Map$1(n)},ElementEditor=({element:i,layer:e,catalog:t})=>{const{planner:n,setItemsAttributes:s,setProperties:o,setLinesAttributes:a,setHolesAttributes:l}=useReactPlannerStore(),[c,u]=React.useState(initAttrData(i,e,t)),[h,d]=React.useState(initPropData(i,t)),p=({propertiesFormData:x,attributesFormData:y})=>{if(x){let E=x.map(b=>b.get("currentValue"));o(E)}if(y)switch(i.prototype){case"items":{s(y);break}case"lines":{a(y);break}case"holes":{l(y);break}}},f=(x,y)=>{if(!c)return;let E;switch(i.prototype){case"items":{E=c.set(x,y);break}case"lines":{switch(x){case"lineLength":{let b=c.get("vertexOne"),v=c.get("vertexTwo"),[M,T]=orderVertices([b,v]),I=extendLine(M.x,M.y,T.x,T.y,y.get("length"),PRECISION);E=c.withMutations(w=>{w.set(b===M?"vertexTwo":"vertexOne",T.merge(I)),w.set("lineLength",y)});break}case"vertexOne":case"vertexTwo":{E=c.withMutations(b=>{b.set(x,b.get(x).merge(y));let v=verticesDistance(b.get("vertexOne"),b.get("vertexTwo"));b.mergeIn(["lineLength"],b.get("lineLength").merge({length:v,_length:convert(v).from(t.unit).to(b.get("lineLength").get("_unit"))}))});break}default:{E=c.set(x,y);break}}break}case"holes":{switch(x){case"offsetA":{let b=e.lines.get(i.line),v=orderVertices([e.vertices.get(b.vertices.get(0)),e.vertices.get(b.vertices.get(1))]),[{x:M,y:T},{x:I,y:w}]=v,R=angleBetweenTwoPoints(M,T,I,w),A=pointsDistance(M,T,I,w),P=i.properties.get("width").get("length"),B=P/2,k=y.get("length");k=Math.max(k,0),k=Math.min(k,A-P);let W=(k+B)*Math.cos(R)+M,Y=(k+B)*Math.sin(R)+T,$=pointPositionOnLineSegment(M,T,I,w,W,Y),ee=toFixedFloat(A-A*$-B,PRECISION),G=c.getIn(["offsetB","_unit"]),K=Map$1({length:ee,_length:convert(ee).from(t.unit).to(G),_unit:G});E=c.set("offsetB",K).set("offset",$);let F=Map$1({length:toFixedFloat(k,PRECISION),_unit:y.get("_unit"),_length:toFixedFloat(convert(k).from(t.unit).to(y.get("_unit")),PRECISION)});E=c.set(x,F);break}case"offsetB":{let b=e.lines.get(i.line),v=orderVertices([e.vertices.get(b.vertices.get(0)),e.vertices.get(b.vertices.get(1))]),[{x:M,y:T},{x:I,y:w}]=v,R=angleBetweenTwoPoints(M,T,I,w),A=pointsDistance(M,T,I,w),P=i.properties.get("width").get("length"),B=P/2,k=y.get("length");k=Math.max(k,0),k=Math.min(k,A-P);let W=I-(k+B)*Math.cos(R),Y=w-(k+B)*Math.sin(R),$=pointPositionOnLineSegment(M,T,I,w,W,Y),ee=toFixedFloat(A*$-B,PRECISION),G=c.getIn(["offsetA","_unit"]),K=Map$1({length:ee,_length:convert(ee).from(t.unit).to(G),_unit:G});E=c.set("offsetA",K).set("offset",$);let F=Map$1({length:toFixedFloat(k,PRECISION),_unit:y.get("_unit"),_length:toFixedFloat(convert(k).from(t.unit).to(y.get("_unit")),PRECISION)});E=c.set(x,F);break}default:{E=c.set(x,y);break}}break}}E&&(u(E),p({attributesFormData:E,propertiesFormData:h}))},g=i.prototype==="areas"||i.prototype==="items"||i.prototype==="holes"||i.prototype==="lines"&&i.type==="wall",_=(x,y)=>{const E=h.setIn([x,"currentValue"],y);d(E),p({propertiesFormData:E,attributesFormData:c})};return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(AttributesEditor,{element:i,layer:e,catalog:t,onValid:()=>{},onUpdate:f,attributeFormData:c}),!g&&h.entrySeq().map(([x,y])=>{let E=y.get("currentValue"),b=y.get("configs"),{Editor:v}=t.getPropertyType(b.type);return jsxRuntimeExports.jsx(v,{propertyName:x,value:E,configs:b,onUpdate:M=>_(x,M),state:n,sourceElement:i,internalState:{attributesFormData:c,propertiesFormData:h}},x)})]})},PanelElementEditorEmpty=()=>jsxRuntimeExports.jsx("div",{className:"h-full flex flex-col gap-4 justify-center items-center",children:jsxRuntimeExports.jsx("p",{className:"mx-4 text-white text-sm text-center",children:"Select an element on the canvas to edit its properties."})}),VISIBILITY_MODE$1=[MODE_IDLE$1,MODE_2D_ZOOM_IN,MODE_2D_ZOOM_OUT,MODE_2D_PAN,MODE_3D_VIEW,MODE_3D_FIRST_PERSON,MODE_WAITING_DRAWING_LINE,MODE_DRAWING_LINE,MODE_DRAWING_HOLE,MODE_DRAWING_ITEM,MODE_DRAGGING_LINE,MODE_DRAGGING_VERTEX,MODE_DRAGGING_ITEM,MODE_DRAGGING_HOLE,MODE_ROTATING_ITEM,MODE_UPLOADING_IMAGE,MODE_FITTING_IMAGE],titleCase=i=>i.split(/[-_\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),getElementTypeLabel=(i,e,t)=>{if(i.prototype==="areas")return getAreaKind(i,t);if(i.prototype==="lines"&&(i.type==="wall"||i.type==="surface"))return"";try{const n=e.getElement(i.type).info;if(n!=null&&n.title)return titleCase(n.title)}catch{}return titleCase(i.type||i.prototype||"Element")},getElementDisplayName=(i,e)=>{var t;if(i.prototype==="areas"){const n=i.properties.get("customName"),s=i.properties.get("roomCategory"),o=i.properties.get("roomType");return n||getRoomTypeLabel(s,o)||"Unknown"}if(i.prototype==="lines"){if(i.type==="wall")return"Wall";if(i.type==="surface")return"Surface"}return((t=i.properties)==null?void 0:t.get("customName"))||i.name||"Unknown"},PanelElementEditor=({catalog:i})=>{const{planner:e}=useReactPlannerStore(),{scene:t,mode:n}=e;return VISIBILITY_MODE$1.includes(n)?t.layers.valueSeq().flatMap(o=>Seq().concat(o.lines,o.holes,o.areas,o.items).filter(a=>a.selected).map(a=>({element:a,layer:o}))).toArray().length===0?jsxRuntimeExports.jsx(PanelElementEditorEmpty,{}):jsxRuntimeExports.jsx("div",{children:t.layers.valueSeq().map(o=>Seq().concat(o.lines,o.holes,o.areas,o.items).filter(a=>a.selected&&a.type!=="surface").map(a=>jsxRuntimeExports.jsx(Panel,{name:getElementTypeLabel(a,i,o),subtitle:getElementDisplayName(a),opened:!0,children:jsxRuntimeExports.jsx("div",{className:"py-[5px] px-[15px]",children:jsxRuntimeExports.jsx(ElementEditor,{element:a,layer:o,catalog:i})})},a.id)).valueSeq())}):null},VISIBILITY_MODE={MODE_IDLE:MODE_IDLE$1,MODE_2D_ZOOM_IN,MODE_2D_ZOOM_OUT,MODE_2D_PAN,MODE_3D_VIEW,MODE_3D_FIRST_PERSON,MODE_WAITING_DRAWING_LINE,MODE_DRAWING_LINE,MODE_DRAWING_HOLE,MODE_DRAWING_ITEM,MODE_DRAGGING_LINE,MODE_DRAGGING_VERTEX,MODE_DRAGGING_ITEM,MODE_DRAGGING_HOLE,MODE_FITTING_IMAGE,MODE_UPLOADING_IMAGE,MODE_ROTATING_ITEM},tableStyle$1={width:"100%"},firstTdStyle$1={width:"6em"},inputStyle={textAlign:"left"},styleEditButton={marginLeft:"5px",border:"0px",background:"none",color:"#FFFFFF",fontSize:"14px",outline:"0px"},tablegroupStyle={width:"100%",cursor:"pointer",maxHeight:"20em",marginLeft:"1px",marginTop:"1em"},iconColStyle={width:"2em"},PanelGroupEditor=({groupID:i})=>{const{planner:e,setGroupAttributes:t,groupTranslate:n,groupRotate:s,removeFromGroup:o}=useReactPlannerStore(),{mode:a}=e;if(!i||!VISIBILITY_MODE[a])return null;const l=e.getIn(["scene","groups",i]),c=l.get("elements");return jsxRuntimeExports.jsx(Panel,{name:`Group [${l.get("name")}]`,opened:!0,children:jsxRuntimeExports.jsxs("div",{style:{padding:"5px 15px"},children:[jsxRuntimeExports.jsx("table",{style:tableStyle$1,children:jsxRuntimeExports.jsxs("tbody",{children:[jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{style:firstTdStyle$1,children:"Name"}),jsxRuntimeExports.jsx("td",{children:jsxRuntimeExports.jsx(FormTextInput,{value:l.get("name"),onChange:u=>t(i,Map$1({name:u.target.value})),style:inputStyle})})]}),jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{style:firstTdStyle$1,children:"X"}),jsxRuntimeExports.jsx("td",{children:jsxRuntimeExports.jsx(FormNumberInput,{value:l.get("x"),onChange:u=>n(i,u.target.value,l.get("y")),style:inputStyle,precision:2})})]}),jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{style:firstTdStyle$1,children:"Y"}),jsxRuntimeExports.jsx("td",{children:jsxRuntimeExports.jsx(FormNumberInput,{value:l.get("y"),onChange:u=>n(i,l.get("x"),u.target.value),style:inputStyle,precision:2})})]}),jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{style:firstTdStyle$1,children:"Rotation"}),jsxRuntimeExports.jsx("td",{children:jsxRuntimeExports.jsx(FormNumberInput,{value:l.get("rotation"),onChange:u=>s(i,u.target.value),style:inputStyle,precision:2})})]})]})}),c.size?jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("p",{style:{textAlign:"center",borderBottom:"1px solid #555",paddingBottom:"1em"},children:"Group's Elements"}),jsxRuntimeExports.jsxs("table",{style:tablegroupStyle,children:[jsxRuntimeExports.jsx("thead",{children:jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("th",{style:iconColStyle}),jsxRuntimeExports.jsx("th",{children:"Layer"}),jsxRuntimeExports.jsx("th",{children:"Prototype"}),jsxRuntimeExports.jsx("th",{children:"Name"})]})}),jsxRuntimeExports.jsx("tbody",{children:c.entrySeq().map(([u,h])=>h.entrySeq().map(([d,p])=>p.valueSeq().map(f=>{let g=e.getIn(["scene","layers",u,d,f]);return jsxRuntimeExports.jsxs("tr",{children:[jsxRuntimeExports.jsx("td",{style:iconColStyle,title:"Un-chain Element from Group",children:jsxRuntimeExports.jsx(FaUnlink,{onClick:()=>o(i,u,d,f),style:styleEditButton})}),jsxRuntimeExports.jsx("td",{style:{textAlign:"center"},children:u}),jsxRuntimeExports.jsx("td",{style:{textAlign:"center",textTransform:"capitalize"},children:d}),jsxRuntimeExports.jsx("td",{style:{textAlign:"center"},children:g.name})]},f)})))})]})]}):null]})})},Sidebar=({catalog:i,width:e=280})=>{const{planner:t}=useReactPlannerStore(),n=t.getIn(["scene","selectedLayer"]),s=t.getIn(["scene","layers",n,"selected"]),o=t.getIn(["scene","layers",n,"lines"]),a=t.getIn(["scene","groups"]).findEntry(h=>h.get("selected")),l=s.lines.filter(h=>{var d;return((d=o.get(h))==null?void 0:d.get("type"))!=="surface"}),c=l.size>1||s.items.size>1||s.holes.size>1||s.areas.size>1||l.size+s.items.size+s.holes.size+s.areas.size>1;return l.size>0||s.items.size>0||s.holes.size>0||s.areas.size>0?jsxRuntimeExports.jsxs("aside",{onKeyDown:h=>h.stopPropagation(),onKeyUp:h=>h.stopPropagation(),className:"floor_planner-sidebar h-full block overflow-y-auto overflow-x-hidden pb-5",style:{width:e},children:[!c&&jsxRuntimeExports.jsx(PanelElementEditor,{catalog:i}),!!a&&jsxRuntimeExports.jsx(PanelGroupEditor,{groupID:a?a[0]:null})]}):null},inlinedAssets=new Map,fetchAsDataURL=async i=>{const e=inlinedAssets.get(i);if(e)return e;const t=await fetch(i);if(!t.ok)throw new Error(`${t.status} ${t.statusText}`);const n=await t.blob(),s=await new Promise((o,a)=>{const l=new FileReader;l.onerror=()=>a(l.error??new Error("FileReader failed")),l.onload=()=>o(l.result),l.readAsDataURL(n)});return inlinedAssets.set(i,s),s},loadImage=i=>new Promise((e,t)=>{const n=new Image;n.onload=()=>e(n),n.onerror=()=>t(new Error("Browser could not decode the serialized SVG")),n.src=i}),capture=async i=>{const{maxWidth:e,type:t="image/png",quality:n,minWidth:s=200}=i,o=document.getElementsByTagName("svg");if(!o.length)throw new Error("No <svg> on the page to capture");let a=o[0];for(let p=1;p<o.length;p++)o[p].width.baseVal.value>a.width.baseVal.value&&(a=o[p]);const l=a.width.baseVal.value,c=a.height.baseVal.value;if(l<s||!c)throw new Error(`Largest SVG is ${l}x${c}, too small to be the plan viewer`);const u=a.cloneNode(!0);u.querySelectorAll('[data-fp-screenshot="omit"]').forEach(p=>p.remove()),await Promise.all(Array.from(u.querySelectorAll("image")).map(async p=>{const f=p.getAttribute("href")||p.getAttribute("xlink:href");if(!(!f||f.startsWith("data:")))try{const g=await fetchAsDataURL(f);p.setAttribute("href",g),p.removeAttribute("xlink:href")}catch(g){console.warn("Could not inline image:",f,g),p.remove()}}));const h=new XMLSerializer().serializeToString(u),d=URL.createObjectURL(new Blob([h],{type:"image/svg+xml;charset=utf-8"}));try{const p=await loadImage(d),f=e&&l>e?e/l:1,g=document.createElement("canvas");g.width=Math.round(l*f),g.height=Math.round(c*f);const _=g.getContext("2d");if(!_)throw new Error("Could not get a 2d canvas context");return _.fillStyle="white",_.fillRect(0,0,g.width,g.height),_.drawImage(p,0,0,g.width,g.height),g.toDataURL(t,n)}finally{URL.revokeObjectURL(d)}},getSVGScreenshot=(i={})=>{const{timeout:e=15e3}=i;let t;return Promise.race([capture(i),new Promise((n,s)=>{t=setTimeout(()=>s(new Error(`Screenshot timed out after ${e}ms`)),e)})]).finally(()=>clearTimeout(t))},ToolbarRail=({items:i,active:e,onChange:t})=>jsxRuntimeExports.jsx("aside",{className:"fp-toolbar-rail",children:i.map(n=>{const s=n.key===e;return jsxRuntimeExports.jsxs("div",{className:cn("fp-toolbar-rail__item",s&&"fp-toolbar-rail__item--active",n.disabled&&"fp-toolbar-rail__item--disabled"),onClick:()=>{n.disabled||t(n.key)},children:[jsxRuntimeExports.jsx("span",{className:"fp-toolbar-rail__icon",children:n.icon}),jsxRuntimeExports.jsx("span",{className:"fp-toolbar-rail__label",children:n.label})]},n.key)})});function BiChevronLeft(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M13.293 6.293 7.586 12l5.707 5.707 1.414-1.414L10.414 12l4.293-4.293z"},child:[]}]})(i)}function BiChevronRight(i){return GenIcon({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M10.707 17.707 16.414 12l-5.707-5.707-1.414 1.414L13.586 12l-4.293 4.293z"},child:[]}]})(i)}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 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 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,...f}=n,g=(_,x)=>{let y=toFixedFloat(_),E=i.merge({length:x!==UNIT_CENTIMETER?convert(y).from(x).to(UNIT_CENTIMETER):y,_length:_,_unit:x});return d?d(E,s,o,a).then(b=>e(b)):e(E)};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:_=>g(_.target.value,h),onValid:t,...f}),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:_=>{},children:UNITS_LENGTH.map(_=>jsxRuntimeExports.jsx("option",{value:_,children:_},_))})})]})]})}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})})]})})})}const PLACEHOLDER_SIZE=100,PLACEHOLDER_THICKNESS=15,STROKE="#9CA3AF",FILL="rgba(156, 163, 175, 0.18)",SELECTED_STROKE="#1ca6fc",outline=i=>({fill:FILL,stroke:i?SELECTED_STROKE:STROKE,strokeWidth:2,strokeDasharray:"8 6",vectorEffect:"non-scaling-stroke"}),Placeholder=({x:i,y:e,width:t,height:n,selected:s})=>jsxRuntimeExports.jsxs("g",{children:[jsxRuntimeExports.jsx("rect",{x:i,y:e,width:t,height:n,style:outline(s)}),jsxRuntimeExports.jsx("path",{d:`M${i} ${e} L${i+t} ${e+n} M${i} ${e+n} L${i+t} ${e}`,style:{...outline(s),fill:"none",strokeDasharray:"none"}})]}),lineLength=(i,e)=>{var s,o,a,l,c,u,h,d;const t=(l=(s=e==null?void 0:e.vertices)==null?void 0:s.get)==null?void 0:l.call(s,(a=(o=i.vertices)==null?void 0:o.get)==null?void 0:a.call(o,0)),n=(d=(c=e==null?void 0:e.vertices)==null?void 0:c.get)==null?void 0:d.call(c,(h=(u=i.vertices)==null?void 0:u.get)==null?void 0:h.call(u,1));return!t||!n?PLACEHOLDER_SIZE:Math.hypot(n.x-t.x,n.y-t.y)},propertyLength=(i,e,t)=>{var n,s;return((s=(n=i.properties)==null?void 0:n.getIn)==null?void 0:s.call(n,[e,"length"]))??t},renderPlaceholder=(i,e)=>{var n;const t=!!i.selected;switch(i.prototype){case"lines":{const s=lineLength(i,e),o=propertyLength(i,"thickness",PLACEHOLDER_THICKNESS);return jsxRuntimeExports.jsx(Placeholder,{x:0,y:-o/2,width:s,height:o,selected:t})}case"areas":{let s="";return(n=i.vertices)==null||n.forEach((o,a)=>{var c,u;const l=(u=(c=e==null?void 0:e.vertices)==null?void 0:c.get)==null?void 0:u.call(c,o);l&&(s+=`${a?"L":"M"}${l.x} ${l.y} `)}),s?jsxRuntimeExports.jsx("path",{d:`${s}Z`,style:outline(t)}):null}case"holes":{const s=propertyLength(i,"width",PLACEHOLDER_SIZE),o=propertyLength(i,"height",PLACEHOLDER_SIZE);return jsxRuntimeExports.jsx(Placeholder,{x:-s/2,y:-o/2,width:s,height:o,selected:t})}default:return jsxRuntimeExports.jsx(Placeholder,{x:-PLACEHOLDER_SIZE/2,y:-PLACEHOLDER_SIZE/2,width:PLACEHOLDER_SIZE,height:PLACEHOLDER_SIZE,selected:t})}};function unknownElement(i){return{name:i,prototype:"",info:{title:i,tag:[],category:"",description:"Not in the current catalog",image:"",visibility:{catalog:!1,layerElementsVisible:!0}},properties:{},render2D:((e,t)=>renderPlaceholder(e,t)),render3D:()=>Promise.resolve(new Object3D),updateRender3D:(e,t,n,s)=>Promise.resolve(s)}}class Catalog{constructor(e=UNIT_CENTIMETER){ze(this,"elements");ze(this,"categories");ze(this,"propertyTypes");ze(this,"missingElements");ze(this,"unit");this.elements={},this.categories={root:{name:"root",label:"/",elements:[],categories:[]}},this.propertyTypes={},this.missingElements=new Map,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){return this.hasElement(e)?this.elements[e]:(this.missingElements.has(e)||(this.missingElements.set(e,unknownElement(e)),console.warn(`[floor-planner] Element "${e}" is in the plan but not in the catalog — drawing a placeholder. Register it to restore it.`)),this.missingElements.get(e))}getElementsOfPrototype(e){return Object.values(this.elements).filter(t=>t.prototype===e)}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)}}const 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})=>jsxRuntimeExports.jsx("div",{role:"tablist",className:"grid w-full overflow-hidden rounded-lg border border-[color:var(--properties-input-border,#E5E7EB)] bg-[color:var(--panel-property-background,#F3F4F6)]",style:{gridTemplateColumns:`repeat(${e.length}, minmax(0, 1fr))`},children:e.map(n=>{const s=n.value===i;return jsxRuntimeExports.jsx("button",{role:"tab","aria-selected":s,className:cn("p-2 text-sm font-semibold capitalize transition-colors",s?"bg-[color:var(--dark-blue,#1ca6fc)] text-white":"bg-[color:var(--panel-property-background,#F3F4F6)] text-[color:var(--properties-color,#2F3033)]"),onClick:()=>t(n),children:n.label},n.value)})}),NestedSelect=({options:i,selections:e,level:t,onChange:n})=>{var s,o;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(FormSelect,{value:e[t]||"all",onChange:a=>n(t,a.target.value),children:i.map(a=>jsxRuntimeExports.jsx("option",{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})]})},CatalogPicker=({catalog:i,page:e,containerSelector:t=".fp-toolbar-subpanel"})=>{const{setToast:n,selectToolDrawingLine:s,selectToolDrawingItem:o,selectToolDrawingHole:a,pushLastSelectedCatalogElementToHistory:l}=useReactPlannerStore(),[c,u]=React.useState([]),[h,d]=React.useState(""),[p,f]=React.useState([]),[g,_]=React.useState(["all"]),[x,y]=React.useState([]),[E,b]=React.useState("");React.useEffect(()=>{b(""),_(["all"]);const R=i.getCategory(e).elements.filter(A=>A.info.visibility?A.info.visibility.catalog:!0);if(y(R),e==="objects"){const A=Array.from(new Set(R.map(k=>k.info.category).filter(Boolean))),P=A[0]??"",B=R.filter(k=>k.info.category===P);d(P),u(A),f(getCatalogOptions(B))}else d(""),u([]),f([])},[e,i]);const v=w=>{e!=="objects"&&n({text:`Cancel placing ${e}`}),setTimeout(()=>{switch(w.prototype){case"lines":s(w.name);break;case"items":o(w.name);break;case"holes":a(w.name);break}l(w)},0)},M=(w,R)=>{const A=[...g.slice(0,w),R];_(A)},T=(w,R)=>{w.preventDefault();const A=w.currentTarget.closest(t);if(!A)return;const P=()=>{v(R),k()},B=()=>k(),k=()=>{A.removeEventListener("mouseleave",P),document.removeEventListener("mouseup",B)};A.addEventListener("mouseleave",P),document.addEventListener("mouseup",B)},I=React.useMemo(()=>x.filter(w=>{const R=w.info.title.toLowerCase().includes(E.toLowerCase()),A=h?w.info.category===h:w,P=g.every(B=>B==="all"||w.info.tag.includes(B));return R&&A&&P}),[x,E,h,g]);return jsxRuntimeExports.jsxs("div",{className:"flex flex-col gap-0 flex-1 min-h-0",children:[jsxRuntimeExports.jsxs("div",{className:"fp-highlight",children:[c.length>1&&jsxRuntimeExports.jsx(SegmentedTabs,{selected:h,onChange:w=>{_(["all"]),d(w.value),f(getCatalogOptions(x.filter(R=>R.info.category===w.value)))},options:c.map(w=>({label:w,value:w}))}),p.length>0&&jsxRuntimeExports.jsx(NestedSelect,{options:p,level:0,selections:g,onChange:M}),jsxRuntimeExports.jsx(SearchInput,{noSpacing:!0,placeholder:"Search",value:E,onSearch:(w,R)=>{R.preventDefault(),R.stopPropagation(),b(w)}})]}),I.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:w=>w.stopPropagation(),children:I.map(w=>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:R=>T(R,w),children:jsxRuntimeExports.jsx("img",{draggable:!1,loading:"lazy",decoding:"async",className:"fp-item-image",alt:w.info.title,src:w.info.image})})}),jsxRuntimeExports.jsx("p",{className:"text-xs font-semibold capitalize",children:w.info.title})]},w.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"})})]})},SubPanelRow=({option:i})=>jsxRuntimeExports.jsxs("div",{className:cn("fp-subpanel-option",i.active&&"fp-subpanel-option--active",i.disabled&&"fp-subpanel-option--disabled"),onClick:()=>{var e;i.disabled||(e=i.onClick)==null||e.call(i)},children:[jsxRuntimeExports.jsx("span",{className:"fp-subpanel-option__icon",children:i.icon}),jsxRuntimeExports.jsx("span",{className:"fp-subpanel-option__label",children:i.label}),i.hasChildren&&jsxRuntimeExports.jsx("span",{className:"fp-subpanel-option__chevron",children:jsxRuntimeExports.jsx(BiChevronRight,{size:22})})]}),ToolbarSubPanel=({title:i,options:e,cta:t,emptyState:n,catalog:s,catalogPage:o,onBack:a,headerExtras:l})=>{const c=!!(s&&o);return jsxRuntimeExports.jsxs("div",{className:"fp-toolbar-subpanel",children:[jsxRuntimeExports.jsxs("header",{className:"fp-toolbar-subpanel__header",children:[a&&jsxRuntimeExports.jsx("div",{className:"fp-toolbar-subpanel__back",onClick:a,children:jsxRuntimeExports.jsx(BiChevronLeft,{size:22})}),jsxRuntimeExports.jsx("span",{className:"fp-toolbar-subpanel__title",children:i})]}),c&&s&&o?jsxRuntimeExports.jsx(CatalogPicker,{catalog:s,page:o}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[l&&jsxRuntimeExports.jsx("div",{className:"fp-toolbar-subpanel__extras",children:l}),t&&jsxRuntimeExports.jsx("div",{className:"fp-toolbar-subpanel__cta",children:t}),e&&e.length>0?jsxRuntimeExports.jsx("div",{className:"fp-toolbar-subpanel__body",children:e.map(u=>jsxRuntimeExports.jsx(SubPanelRow,{option:u},u.key))}):n&&jsxRuntimeExports.jsx("div",{className:"fp-toolbar-subpanel__body",children:n})]})]})};function HiOutlineFolder(i){return GenIcon({attr:{fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 12.75V12A2.25 2.25 0 0 1 4.5 9.75h15A2.25 2.25 0 0 1 21.75 12v.75m-8.69-6.44-2.12-2.12a1.5 1.5 0 0 0-1.061-.44H4.5A2.25 2.25 0 0 0 2.25 6v12a2.25 2.25 0 0 0 2.25 2.25h15A2.25 2.25 0 0 0 21.75 18V9a2.25 2.25 0 0 0-2.25-2.25h-5.379a1.5 1.5 0 0 1-1.06-.44Z"},child:[]}]})(i)}function HiOutlineMinus(i){return GenIcon({attr:{fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 12h14"},child:[]}]})(i)}function HiOutlinePlus(i){return GenIcon({attr:{fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 4.5v15m7.5-7.5h-15"},child:[]}]})(i)}function HiOutlineWrenchScrewdriver(i){return GenIcon({attr:{fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor","aria-hidden":"true"},child:[{tag:"path",attr:{strokeLinecap:"round",strokeLinejoin:"round",d:"M11.42 15.17 17.25 21A2.652 2.652 0 0 0 21 17.25l-5.877-5.877M11.42 15.17l2.496-3.03c.317-.384.74-.626 1.208-.766M11.42 15.17l-4.655 5.653a2.548 2.548 0 1 1-3.586-3.586l6.837-5.63m5.108-.233c.55-.164 1.163-.188 1.743-.14a4.5 4.5 0 0 0 4.486-6.336l-3.276 3.277a3.004 3.004 0 0 1-2.25-2.25l3.276-3.276a4.5 4.5 0 0 0-6.336 4.486c.091 1.076-.071 2.264-.904 2.95l-.102.085m-1.745 1.437L5.909 7.5H4.5L2.25 3.75l1.5-1.5L7.5 4.5v1.409l4.26 4.26m-1.745 1.437 1.745-1.437m6.615 8.206L15.75 15.75M4.867 19.125h.008v.008h-.008v-.008Z"},child:[]}]})(i)}const ZOOM_STEP=1.2,ZoomControls=({subPanelOpen:i=!1})=>{const{planner:e,viewer:t,viewer3D:n,fitViewerToScene:s}=useReactPlannerStore(),{mode:o,zoom:a}=e,l=o===MODE_3D_VIEW,c=d=>{const p=d==="in"?ZOOM_STEP:1/ZOOM_STEP;if(l){n==null||n.zoomBy(p);return}if(!t)return;const f=a<=MIN_ZOOM+.01,g=a>=MAX_ZOOM-.01;f&&d==="out"||g&&d==="in"||typeof t.zoomOnViewerCenter=="function"&&t.zoomOnViewerCenter(p)},u=()=>{l?n==null||n.fitToScene():s()},h=l?12:i?414:102;return jsxRuntimeExports.jsxs("div",{className:"fp-zoom-controls",style:{left:h},children:[jsxRuntimeExports.jsx(ToolbarButton,{active:!1,tooltipPosition:"left",tooltip:"Zoom in",onClick:()=>c("in"),children:jsxRuntimeExports.jsx(HiOutlinePlus,{size:20})}),jsxRuntimeExports.jsx(ToolbarButton,{active:!1,tooltipPosition:"left",tooltip:"Zoom out",onClick:()=>c("out"),children:jsxRuntimeExports.jsx(HiOutlineMinus,{size:20})}),jsxRuntimeExports.jsx(ToolbarButton,{active:!1,tooltipPosition:"left",tooltip:"Fit to view",onClick:u,children:jsxRuntimeExports.jsx(MdMyLocation,{size:20})})]})},NumberStepper=({label:i,value:e,unit:t="cm",step:n=1,min:s=0,max:o=1e4,onChange:a})=>{const l=c=>Math.min(o,Math.max(s,c));return jsxRuntimeExports.jsxs("label",{className:"fp-number-stepper",children:[jsxRuntimeExports.jsx("span",{className:"fp-number-stepper__label",children:i}),jsxRuntimeExports.jsxs("div",{className:"fp-number-stepper__control",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"fp-number-stepper__btn",onClick:()=>a(l(e-n)),"aria-label":`Decrease ${i}`,children:jsxRuntimeExports.jsx(HiOutlineMinus,{size:14})}),jsxRuntimeExports.jsxs("div",{className:"fp-number-stepper__value",children:[e,t?` ${t}`:""]}),jsxRuntimeExports.jsx("button",{type:"button",className:"fp-number-stepper__btn",onClick:()=>a(l(e+n)),"aria-label":`Increase ${i}`,children:jsxRuntimeExports.jsx(HiOutlinePlus,{size:14})})]})]})},PREVIEW_WIDTH=260,PREVIEW_HEIGHT=160,ProjectMiniMap=({onHoverChange:i})=>{const{planner:e,focusOnArea:t}=useReactPlannerStore(),[n,s]=React.useState(null),[o,a]=React.useState(null),l=React.useRef(null),{areas:c,walls:u,bounds:h}=React.useMemo(()=>{const I=e.get("scene").get("layers"),w=[],R=[];let A=1/0,P=1/0,B=-1/0,k=-1/0,W=!1;const Y=($,ee)=>{typeof $!="number"||typeof ee!="number"||(A=Math.min(A,$),P=Math.min(P,ee),B=Math.max(B,$),k=Math.max(k,ee),W=!0)};return I.forEach($=>{const ee=$.get("id");$.get("areas").forEach(G=>{const K=[];if(G.get("vertices").forEach(j=>{const ie=$.getIn(["vertices",j]);if(!ie)return;const Z=ie.get("x"),ue=ie.get("y");Y(Z,ue),K.push({x:Z,y:ue})}),K.length<3)return;const F=G.getIn(["properties","patternColor"])||SharedStyle.AREA_MESH_COLOR.unselected,X=deriveAreaLabel(G,$),se=areapolygon(K),me=K.reduce((j,ie)=>j+ie.x,0)/K.length,Me=K.reduce((j,ie)=>j+ie.y,0)/K.length;w.push({layerID:ee,areaID:G.get("id"),color:F,points:K.map(j=>`${j.x},${j.y}`).join(" "),label:X,area:se/1e4,center:{x:me,y:Me}})}),$.get("lines").forEach(G=>{const[K,F]=G.get("vertices").toArray(),X=$.getIn(["vertices",K]),se=$.getIn(["vertices",F]);!X||!se||(Y(X.get("x"),X.get("y")),Y(se.get("x"),se.get("y")),R.push({x1:X.get("x"),y1:X.get("y"),x2:se.get("x"),y2:se.get("y"),thickness:G.getIn(["properties","thickness","length"])??10}))})}),{areas:w,walls:R,bounds:W?{minX:A,minY:P,maxX:B,maxY:k}:null}},[e]);if(!h||c.length+u.length===0)return jsxRuntimeExports.jsx("div",{className:"fp-project-minimap fp-project-minimap--empty",children:jsxRuntimeExports.jsx("p",{children:"No areas yet, draw a room to see it here."})});const d=Math.max(1,h.maxX-h.minX),p=Math.max(1,h.maxY-h.minY),f=Math.max(d,p)*.06,g=h.minX-f,_=h.minY-f,x=d+f*2,y=p+f*2,b=1/Math.min(PREVIEW_WIDTH/x,PREVIEW_HEIGHT/y),v=(T,I)=>{if(s(T),T){const w=c.find(R=>R.areaID===T);w&&(i==null||i({layerID:w.layerID,areaID:w.areaID,label:w.label,area:w.area}))}else i==null||i(null);if(I&&l.current){const w=l.current.getBoundingClientRect();a({x:I.clientX-w.left,y:I.clientY-w.top})}else a(null)},M=n?c.find(T=>T.areaID===n):null;return jsxRuntimeExports.jsx("div",{className:"fp-project-minimap",children:jsxRuntimeExports.jsxs("div",{className:"fp-project-minimap__stage",children:[jsxRuntimeExports.jsx("svg",{ref:l,viewBox:`${g} ${_} ${x} ${y}`,width:PREVIEW_WIDTH,height:PREVIEW_HEIGHT,preserveAspectRatio:"xMidYMid meet",children:jsxRuntimeExports.jsxs("g",{transform:`translate(0, ${h.maxY+h.minY}) scale(1, -1)`,children:[c.map(T=>{const I=T.areaID===n;return jsxRuntimeExports.jsx("polygon",{points:T.points,fill:I?SharedStyle.MESH_SELECTED:T.color,stroke:"rgba(0,0,0,0.15)",strokeWidth:b,style:{cursor:"pointer",transition:"fill 0.15s ease"},onMouseEnter:w=>v(T.areaID,w),onMouseMove:w=>v(T.areaID,w),onMouseLeave:()=>v(null),onClick:()=>t(T.layerID,T.areaID)},T.areaID)}),u.map((T,I)=>jsxRuntimeExports.jsx("line",{x1:T.x1,y1:T.y1,x2:T.x2,y2:T.y2,stroke:"rgba(0,0,0,0.55)",strokeWidth:Math.max(T.thickness,b*2),strokeLinecap:"butt"},I))]})}),M&&o&&jsxRuntimeExports.jsx("div",{className:"fp-project-minimap__tooltip",style:{left:o.x,top:o.y},children:M.label})]})})},ProjectPanel=()=>{const{planner:i,plan:e}=useReactPlannerStore(),[t,n]=React.useState(null),{totalArea:s,areaCount:o}=React.useMemo(()=>{const l=i.get("scene").get("layers");let c=0,u=0;return l.forEach(h=>{h.get("areas").forEach(d=>{const p=d.get("vertices").toArray().map(f=>{const g=h.getIn(["vertices",f]);return[g?g.get("x"):0,g?g.get("y"):0]});p.length<3||(c+=Math.abs(areapolygon(p)),u+=1)})}),{totalArea:c/1e4,areaCount:u}},[i]);return jsxRuntimeExports.jsxs("div",{className:"fp-project-panel",children:[(e==null?void 0:e.planTitle)&&jsxRuntimeExports.jsxs("div",{className:"fp-project-info",children:[jsxRuntimeExports.jsx("span",{className:"fp-project-info__label",children:"Design Name"}),jsxRuntimeExports.jsx("span",{className:"fp-project-info__value",children:e.planTitle})]}),jsxRuntimeExports.jsx(ProjectMiniMap,{onHoverChange:n}),jsxRuntimeExports.jsx("div",{className:"fp-project-summary",children:t?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("span",{className:"fp-project-summary__label",children:t.label}),jsxRuntimeExports.jsxs("span",{className:"fp-project-summary__value",children:[t.area.toFixed(2)," m²"]})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("span",{className:"fp-project-summary__label",children:o===1?"1 area":`${o} areas`}),jsxRuntimeExports.jsxs("span",{className:"fp-project-summary__value",children:[s.toFixed(2)," m²"]})]})})]})};function GiCube(i){return GenIcon({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 24.585L51.47 118.989 256 213.394l204.53-94.405zM38.998 133.054v258.353L247 487.415V229.063zm434.004 0L265 229.062v258.353l208.002-96.008z"},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"}),RAIL_ITEMS=[{key:"project",label:"Project",icon:jsxRuntimeExports.jsx(HiOutlineFolder,{})},{key:"build",label:"Build",icon:jsxRuntimeExports.jsx(HiOutlineWrenchScrewdriver,{})},{key:"objects",label:"Objects",icon:jsxRuntimeExports.jsx(MdOutlineChair,{})}];function Toolbar({catalog:i,has3dView:e}){const{planner:t,setMode:n,setToast:s,selectTool3DView:o,unselectAll:a,selectToolDrawingLine:l,selectToolDrawingSurface:c,selectToolDrawingRoom:u,updateRoomDrawingProperties:h,showDimensions:d,setShowDimensions:p}=useReactPlannerStore(),{mode:f,alterate:g,drawingSupport:_}=t,[x,y]=React.useState("build"),[E,b]=React.useState(null),[v,M]=React.useState(15),[T,I]=React.useState(280),w=_.get("type"),R=[MODE_WAITING_DRAWING_LINE,MODE_DRAWING_LINE].includes(f)&&w==="wall",A=[MODE_WAITING_DRAWING_SURFACE,MODE_DRAWING_SURFACE].includes(f),P=f===MODE_DRAWING_HOLE,B=[MODE_WAITING_DRAWING_ROOM,MODE_DRAWING_ROOM].includes(f),k=B||R;React.useEffect(()=>{k&&h({thickness:v,height:T})},[v,T,k,h]);const W=F=>{if(x===F){y(null),b(null);return}y(F),b(null)},Y=()=>{s({text:"Cancel drawing"}),u({thickness:v,height:T})},$=()=>{s({text:"Cancel drawing"}),l("wall",{thickness:v,height:T})},ee=React.useMemo(()=>[{key:"draw-room",label:"Draw Room",icon:jsxRuntimeExports.jsx(GiCube,{}),active:B,onClick:Y},{key:"draw-wall",label:"Draw Wall",icon:jsxRuntimeExports.jsx(LuBrickWall,{}),active:R,onClick:$},{key:"draw-surface",label:"Draw Surface",icon:jsxRuntimeExports.jsx(PiWall,{}),active:A,onClick:()=>{s({text:"Cancel drawing"}),c("surface")}},{key:"place-doors",label:"Place Doors",icon:jsxRuntimeExports.jsx(FaDoorOpen,{}),active:P&&w!=="window",hasChildren:!0,onClick:()=>b("doors")},{key:"place-windows",label:"Place Windows",icon:jsxRuntimeExports.jsx(MdOutlineWindow,{}),active:P&&w==="window",hasChildren:!0,onClick:()=>b("windows")}],[R,A,P,B,w,c,s,Y,$]),G=jsxRuntimeExports.jsx("p",{className:"text-sm text-gray-500 px-3 py-6 text-center",children:"Coming soon."}),K=()=>{if(!x)return null;switch(x){case"build":if(E){const F=E==="doors"?"Place Doors":"Place Windows";return jsxRuntimeExports.jsx(ToolbarSubPanel,{title:F,catalog:i,catalogPage:E,onBack:()=>b(null)})}return jsxRuntimeExports.jsx(ToolbarSubPanel,{title:"Build",options:ee,headerExtras:k?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(NumberStepper,{label:"Thickness",value:v,onChange:M,min:1,max:100}),jsxRuntimeExports.jsx(NumberStepper,{label:"Wall Height",value:T,onChange:I,step:10,min:50,max:1e3})]}):void 0});case"objects":return jsxRuntimeExports.jsx(ToolbarSubPanel,{title:"Objects",catalog:i,catalogPage:"objects"});case"project":return jsxRuntimeExports.jsx(ToolbarSubPanel,{title:"Project",emptyState:jsxRuntimeExports.jsx(ProjectPanel,{})});case"info":return jsxRuntimeExports.jsx(ToolbarSubPanel,{title:"Info",emptyState:G});case"styleboards":return jsxRuntimeExports.jsx(ToolbarSubPanel,{title:"Styleboards",emptyState:G});case"finishes":return jsxRuntimeExports.jsx(ToolbarSubPanel,{title:"Finishes",emptyState:G});case"help":return jsxRuntimeExports.jsx(ToolbarSubPanel,{title:"Help",emptyState:G});default:return null}};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[![MODE_3D_VIEW].includes(f)&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ToolbarRail,{items:RAIL_ITEMS,active:x,onChange:W}),K()]}),jsxRuntimeExports.jsx("div",{className:"fp-toolbar-utility",children:e&&([MODE_3D_VIEW].includes(f)?jsxRuntimeExports.jsx(ToolbarButton,{active:!1,tooltipPosition:"top",tooltip:"2D View",onClick:()=>{a(),setTimeout(()=>n(MODE_IDLE$1),0)},children:jsxRuntimeExports.jsx(Icon2D,{style:{color:g?"#FF9800":""}})}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ToolbarButton,{active:!1,tooltipPosition:"top",tooltip:"3D View",onClick:o,children:jsxRuntimeExports.jsx(Icon3D,{})}),jsxRuntimeExports.jsx(ToolbarButton,{active:d,tooltipPosition:"top",tooltip:"Show dimensions",onClick:()=>{[MODE_3D_VIEW].includes(f)||p(!d)},children:jsxRuntimeExports.jsx(RxDimensions,{size:22})})]}))}),jsxRuntimeExports.jsx(ZoomControls,{subPanelOpen:x!==null})]})}const localStorage$1=window.hasOwnProperty("localStorage")?window.localStorage:!1,TIMEOUT_DELAY=500;function autosave(i,e){return(t,n,s)=>{let o,a=null;if(e=e||TIMEOUT_DELAY,!i||!localStorage$1)return;if(n){t.setPlan(n);const c=n.floors[0].floorDesign;o=JSON.parse(c)}else if(localStorage$1.getItem(i)!==null){const c=localStorage$1.getItem(i);o=JSON.parse(c)}o&&t.loadProject(o);const l=useReactPlannerStore.subscribe(c=>{a&&clearTimeout(a),a=setTimeout(()=>{const u=localStorage$1.getItem(i),h=Project.unselectAll(c.planner).updatedState,d=JSON.stringify(h.scene.toJS());if(u!==d&&(localStorage$1.setItem(i,d),c.plan))try{const p=c.plan.floors[c.activeFloor];s&&s({floor:{floorID:p.floorID,title:p.floorTitle,description:p.floorDescription,design:d}})}catch{}},e)});return()=>{a&&clearTimeout(a),l()}}}const SNAPPING_OFF={[SNAP_POINT]:!1,[SNAP_LINE]:!1,[SNAP_SEGMENT]:!1,[SNAP_GRID]:!1,[SNAP_GUIDE]:!1};function keyboard(){return i=>{const e=()=>useReactPlannerStore.getState().planner;let t=null;const n=()=>{if(t)return;const d=e();MODE_SNAPPING.includes(d.get("mode"))&&(t=d.snapMask,i.toggleSnap(d.snapMask.merge(SNAPPING_OFF)))},s=()=>{if(!t)return;const d=t;t=null,i.toggleSnap(e().snapMask.merge(d))},o=()=>{e().alterate||i.setAlterateState()},a=()=>{e().alterate&&i.setAlterateState()},l=d=>{d.getModifierState("Alt")?n():s(),d.getModifierState("Control")?o():a()},c=()=>{s(),a()},u=d=>{const p=d;return p!=null&&p.tagName?["INPUT","TEXTAREA","SELECT"].includes(p.tagName)||p.isContentEditable:!1},h=d=>{if(l(d),u(d.target))return;const p=e(),f=p.get("mode");switch(d.keyCode){case KEYBOARD_BUTTON_CODE.BACKSPACE:case KEYBOARD_BUTTON_CODE.DELETE:{[MODE_IDLE$1,MODE_3D_FIRST_PERSON,MODE_3D_VIEW].includes(f)&&i.remove();break}case KEYBOARD_BUTTON_CODE.ESC:{i.rollback();break}case KEYBOARD_BUTTON_CODE.Z:{(d.getModifierState("Control")||d.getModifierState("Meta"))&&(d.getModifierState("Shift")?i.redo():i.undo());break}case KEYBOARD_BUTTON_CODE.C:{let g=p.getIn(["scene","selectedLayer"]),_=p.getIn(["scene","layers",g,"selected"]);if((f===MODE_IDLE$1||f===MODE_3D_VIEW)&&(_.holes.size||_.areas.size||_.items.size||_.lines.size)){if(_.holes.size){let x=p.getIn(["scene","layers",g,"holes",_.holes.get(0)]);i.copyProperties(x.get("properties"))}else if(_.areas.size){const x=p.getIn(["scene","layers",g,"areas",_.areas.get(0)]);i.copyProperties(x.properties)}else if(_.items.size){const x=p.getIn(["scene","layers",g,"items",_.items.get(0)]);i.copyProperties(x.properties)}else if(_.lines.size){const x=p.getIn(["scene","layers",g,"lines",_.lines.get(0)]);i.copyProperties(x.properties)}}break}case KEYBOARD_BUTTON_CODE.V:{i.pasteProperties();break}}};return window.addEventListener("keydown",h),window.addEventListener("keyup",l),window.addEventListener("mousemove",l,{passive:!0}),window.addEventListener("mousedown",l,{passive:!0}),window.addEventListener("blur",c),document.addEventListener("visibilitychange",c),()=>{s(),window.removeEventListener("keydown",h),window.removeEventListener("keyup",l),window.removeEventListener("mousemove",l),window.removeEventListener("mousedown",l),window.removeEventListener("blur",c),document.removeEventListener("visibilitychange",c)}}}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,theme:s,setTheme:o,showGrid:a,setShowGrid:l}=useReactPlannerStore(),{snapMask:c}=t,u=React.useRef(null);React.useEffect(()=>{if(i){const{x:p,y:f}=i.rect;u.current={top:f+TOP_OFFSET,left:p+LEFT_OFFSET}}},[i]);const h=()=>{e()},d=p=>n(c.merge(p));return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[i&&jsxRuntimeExports.jsx("div",{className:"fixed inset-0 bg-black/30 z-10",onClick:h}),jsxRuntimeExports.jsxs("div",{style:i&&i.rect?{top:i.rect.y+TOP_OFFSET,left:i.rect.x+LEFT_OFFSET}:u.current?u.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-[340px] 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:c.get(SNAP_POINT),toggleOn:()=>{d({SNAP_POINT:!0})},toggleOff:()=>{d({SNAP_POINT:!1})}}),jsxRuntimeExports.jsx(ToggleSetting,{toggleOn:()=>{d({SNAP_LINE:!0})},toggleOff:()=>{d({SNAP_LINE:!1})},toggleState:c.get(SNAP_LINE),title:"Snap to Line"}),jsxRuntimeExports.jsx(ToggleSetting,{toggleOn:()=>{d({SNAP_SEGMENT:!0})},toggleOff:()=>{d({SNAP_SEGMENT:!1})},toggleState:c.get(SNAP_SEGMENT),title:"Snap to Segment"}),jsxRuntimeExports.jsx(ToggleSetting,{toggleOn:()=>{d({SNAP_GRID:!0})},toggleOff:()=>{d({SNAP_GRID:!1})},toggleState:c.get(SNAP_GRID),title:"Snap to Grid"}),jsxRuntimeExports.jsx(ToggleSetting,{toggleOn:()=>{d({SNAP_GUIDE:!0})},toggleOff:()=>{d({SNAP_GUIDE:!1})},toggleState:c.get(SNAP_GUIDE),title:"Snap to Guide"}),jsxRuntimeExports.jsx(ToggleSetting,{title:"Show Grid",toggleState:a,toggleOn:()=>l(!0),toggleOff:()=>l(!1)}),jsxRuntimeExports.jsx(ToggleSetting,{title:"Dark Mode",toggleState:s==="dark",toggleOn:()=>o("dark"),toggleOff:()=>o("light")})]})]})]})},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 f=p.target.value.trim();if(f&&f!==(s==null?void 0:s.planTitle)){o({...s,planTitle:f});try{e&&e({title:f,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] pr-3 pl-2.5 w-full select-none cursor-default top-0 m-0",children:[jsxRuntimeExports.jsx("div",{className:"min-w-[122px]",children:jsxRuntimeExports.jsx(ToolbarButton,{className:"border border-white rounded",active:!1,tooltip:"Go Back",onClick:()=>{i&&i()},children:jsxRuntimeExports.jsx(BiChevronLeft,{})})}),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-4",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,y){!u&&a&&o&&l.size()===0&&f(),l.add(x,y)}function d(){for(u=!0;l.size();){var x=l;l=e(),x.process()}u=!1}function p(x){u||(x===void 0&&(x=o),c&&(g(c),c=null),x?f():d())}function f(){c=_(d)}function g(x){var y=clearTimeout;return y(x)}function _(x){var y=function(E){return setTimeout(E,0)};return y(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 f=c(h);if(!f)throw new Error("Element is not detectable by this strategy.");f.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 f(g,_){var x=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"]),y=!1,E=window.getComputedStyle(g),b=g.offsetWidth,v=g.offsetHeight;s(g).startSize={width:b,height:v};function M(){function T(){if(E.position==="static"){g.style.setProperty("position","relative",h.important?"important":"");var R=function(A,P,B,k){function W($){return $.replace(/[^-\d\.]/g,"")}var Y=B[k];Y!=="auto"&&W(Y)!=="0"&&(A.warn("An element that is positioned static has style."+k+"="+Y+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+k+" will be set to 0. Element: ",P),P.style.setProperty(k,"0",h.important?"important":""))};R(t,g,E,"top"),R(t,g,E,"right"),R(t,g,E,"bottom"),R(t,g,E,"left")}}function I(){y||T();function R(P,B){if(!P.contentDocument){var k=s(P);k.checkForObjectDocumentTimeoutId&&window.clearTimeout(k.checkForObjectDocumentTimeoutId),k.checkForObjectDocumentTimeoutId=setTimeout(function(){k.checkForObjectDocumentTimeoutId=0,R(P,B)},100);return}B(P.contentDocument)}var A=this;R(A,function(B){_(g)})}E.position!==""&&(T(),y=!0);var w=document.createElement("object");w.style.cssText=x,w.tabIndex=-1,w.type="text/html",w.setAttribute("aria-hidden","true"),w.onload=I,i.isIE()||(w.data="about:blank"),s(g)&&(g.appendChild(w),s(g).object=w,i.isIE()&&(w.data="about:blank"))}n?n.add(M):M()}i.isIE(8)?p(d):f(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 T=e.important?" !important; ":"; ";return(M.join(T)+T).trim()}function d(){var M=500,T=500,I=document.createElement("div");I.style.cssText=h(["position: absolute","width: "+M*2+"px","height: "+T*2+"px","visibility: hidden","margin: 0","padding: 0"]);var w=document.createElement("div");w.style.cssText=h(["position: absolute","width: "+M+"px","height: "+T+"px","overflow: scroll","visibility: none","top: "+-M*3+"px","left: "+-T*3+"px","visibility: hidden","margin: 0","padding: 0"]),w.appendChild(I),document.body.insertBefore(w,document.body.firstChild);var R=M-w.clientWidth,A=T-w.clientHeight;return document.body.removeChild(w),{width:R,height:A}}function p(M,T,I){function w(B,k){k=k||function(Y){M.head.appendChild(Y)};var W=M.createElement("style");return W.innerHTML=B,W.id=T,k(W),W}if(!M.getElementById(T)){var R=I+"_animation",A=I+"_animation_active",P=`/* Created by the element-resize-detector library. */
3932
3932
  `;P+="."+I+" > div::-webkit-scrollbar { "+h(["display: none"])+` }
3933
3933
 
3934
3934
  `,P+="."+A+" { "+h(["-webkit-animation-duration: 0.1s","animation-duration: 0.1s","-webkit-animation-name: "+R,"animation-name: "+R])+` }
3935
3935
  `,P+="@-webkit-keyframes "+R+` { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }
3936
- `,P+="@keyframes "+R+" { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }",w(P)}}function f(M){M.className+=" "+c+"_animation_active"}function g(M,T,I){if(M.addEventListener)M.addEventListener(T,I);else if(M.attachEvent)M.attachEvent("on"+T,I);else return t.error("[scroll] Don't know how to add event listeners.")}function _(M,T,I){if(M.removeEventListener)M.removeEventListener(T,I);else if(M.detachEvent)M.detachEvent("on"+T,I);else return t.error("[scroll] Don't know how to remove event listeners.")}function x(M){return s(M).container.childNodes[0].childNodes[0].childNodes[0]}function y(M){return s(M).container.childNodes[0].childNodes[0].childNodes[1]}function E(M,T){var I=s(M).listeners;if(!I.push)throw new Error("Cannot add listener to an element that is not detectable.");s(M).listeners.push(T)}function b(M,T,I){I||(I=T,T=M,M=null),M=M||{};function w(){if(M.debug){var re=Array.prototype.slice.call(arguments);if(re.unshift(o.get(T),"Scroll: "),t.log.apply)t.log.apply(null,re);else for(var Fe=0;Fe<re.length;Fe++)t.log(re[Fe])}}function R(re){function Fe(oe){var V=oe.getRootNode&&oe.getRootNode().contains(oe);return oe===oe.ownerDocument.body||oe.ownerDocument.body.contains(oe)||V}return!Fe(re)||window.getComputedStyle(re)===null}function A(re){var Fe=s(re).container.childNodes[0],oe=window.getComputedStyle(Fe);return!oe.width||oe.width.indexOf("px")===-1}function P(){var re=window.getComputedStyle(T),Fe={};return Fe.position=re.position,Fe.width=T.offsetWidth,Fe.height=T.offsetHeight,Fe.top=re.top,Fe.right=re.right,Fe.bottom=re.bottom,Fe.left=re.left,Fe.widthCSS=re.width,Fe.heightCSS=re.height,Fe}function B(){var re=P();s(T).startSize={width:re.width,height:re.height},w("Element start size",s(T).startSize)}function k(){s(T).listeners=[]}function W(){if(w("storeStyle invoked."),!s(T)){w("Aborting because element has been uninstalled");return}var re=P();s(T).style=re}function Y(re,Fe,oe){s(re).lastWidth=Fe,s(re).lastHeight=oe}function $(re){return x(re).childNodes[0]}function ee(){return 2*a.width+1}function G(){return 2*a.height+1}function K(re){return re+10+ee()}function F(re){return re+10+G()}function X(re){return re*2+ee()}function se(re){return re*2+G()}function me(re,Fe,oe){var V=x(re),pe=y(re),ae=K(Fe),Te=F(oe),_e=X(Fe),ye=se(oe);V.scrollLeft=ae,V.scrollTop=Te,pe.scrollLeft=_e,pe.scrollTop=ye}function Me(){var re=s(T).container;if(!re){re=document.createElement("div"),re.className=c,re.style.cssText=h(["visibility: hidden","display: inline","width: 0px","height: 0px","z-index: -1","overflow: hidden","margin: 0","padding: 0"]),s(T).container=re,f(re),T.appendChild(re);var Fe=function(){s(T).onRendered&&s(T).onRendered()};g(re,"animationstart",Fe),s(T).onAnimationStart=Fe}return re}function j(){function re(){var Be=s(T).style;if(Be.position==="static"){T.style.setProperty("position","relative",M.important?"important":"");var Le=function(je,Ve,Oe,ve){function Ne(xe){return xe.replace(/[^-\d\.]/g,"")}var Ce=Oe[ve];Ce!=="auto"&&Ne(Ce)!=="0"&&(je.warn("An element that is positioned static has style."+ve+"="+Ce+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+ve+" will be set to 0. Element: ",Ve),Ve.style[ve]=0)};Le(t,T,Be,"top"),Le(t,T,Be,"right"),Le(t,T,Be,"bottom"),Le(t,T,Be,"left")}}function Fe(Be,Le,je,Ve){return Be=Be?Be+"px":"0",Le=Le?Le+"px":"0",je=je?je+"px":"0",Ve=Ve?Ve+"px":"0",["left: "+Be,"top: "+Le,"right: "+Ve,"bottom: "+je]}if(w("Injecting elements"),!s(T)){w("Aborting because element has been uninstalled");return}re();var oe=s(T).container;oe||(oe=Me());var V=a.width,pe=a.height,ae=h(["position: absolute","flex: none","overflow: hidden","z-index: -1","visibility: hidden","width: 100%","height: 100%","left: 0px","top: 0px"]),Te=h(["position: absolute","flex: none","overflow: hidden","z-index: -1","visibility: hidden"].concat(Fe(-(1+V),-(1+pe),-pe,-V))),_e=h(["position: absolute","flex: none","overflow: scroll","z-index: -1","visibility: hidden","width: 100%","height: 100%"]),ye=h(["position: absolute","flex: none","overflow: scroll","z-index: -1","visibility: hidden","width: 100%","height: 100%"]),Se=h(["position: absolute","left: 0","top: 0"]),Ae=h(["position: absolute","width: 200%","height: 200%"]),qe=document.createElement("div"),$e=document.createElement("div"),U=document.createElement("div"),N=document.createElement("div"),ne=document.createElement("div"),he=document.createElement("div");qe.dir="ltr",qe.style.cssText=ae,qe.className=c,$e.className=c,$e.style.cssText=Te,U.style.cssText=_e,N.style.cssText=Se,ne.style.cssText=ye,he.style.cssText=Ae,U.appendChild(N),ne.appendChild(he),$e.appendChild(U),$e.appendChild(ne),qe.appendChild($e),oe.appendChild(qe);function Ie(){var Be=s(T);Be&&Be.onExpand?Be.onExpand():w("Aborting expand scroll handler: element has been uninstalled")}function fe(){var Be=s(T);Be&&Be.onShrink?Be.onShrink():w("Aborting shrink scroll handler: element has been uninstalled")}g(U,"scroll",Ie),g(ne,"scroll",fe),s(T).onExpandScroll=Ie,s(T).onShrinkScroll=fe}function ie(){function re(_e,ye,Se){var Ae=$(_e),qe=K(ye),$e=F(Se);Ae.style.setProperty("width",qe+"px",M.important?"important":""),Ae.style.setProperty("height",$e+"px",M.important?"important":"")}function Fe(_e){var ye=T.offsetWidth,Se=T.offsetHeight,Ae=ye!==s(T).lastWidth||Se!==s(T).lastHeight;w("Storing current size",ye,Se),Y(T,ye,Se),n.add(0,function(){if(Ae){if(!s(T)){w("Aborting because element has been uninstalled");return}if(!oe()){w("Aborting because element container has not been initialized");return}if(M.debug){var $e=T.offsetWidth,U=T.offsetHeight;($e!==ye||U!==Se)&&t.warn(o.get(T),"Scroll: Size changed before updating detector elements.")}re(T,ye,Se)}}),n.add(1,function(){if(!s(T)){w("Aborting because element has been uninstalled");return}if(!oe()){w("Aborting because element container has not been initialized");return}me(T,ye,Se)}),Ae&&_e&&n.add(2,function(){if(!s(T)){w("Aborting because element has been uninstalled");return}if(!oe()){w("Aborting because element container has not been initialized");return}_e()})}function oe(){return!!s(T).container}function V(){function _e(){return s(T).lastNotifiedWidth===void 0}w("notifyListenersIfNeeded invoked");var ye=s(T);if(_e()&&ye.lastWidth===ye.startSize.width&&ye.lastHeight===ye.startSize.height)return w("Not notifying: Size is the same as the start size, and there has been no notification yet.");if(ye.lastWidth===ye.lastNotifiedWidth&&ye.lastHeight===ye.lastNotifiedHeight)return w("Not notifying: Size already notified");w("Current size not notified, notifying..."),ye.lastNotifiedWidth=ye.lastWidth,ye.lastNotifiedHeight=ye.lastHeight,i(s(T).listeners,function(Se){Se(T)})}function pe(){if(w("startanimation triggered."),A(T)){w("Ignoring since element is still unrendered...");return}w("Element rendered.");var _e=x(T),ye=y(T);(_e.scrollLeft===0||_e.scrollTop===0||ye.scrollLeft===0||ye.scrollTop===0)&&(w("Scrollbars out of sync. Updating detector elements..."),Fe(V))}function ae(){if(w("Scroll detected."),A(T)){w("Scroll event fired while unrendered. Ignoring...");return}Fe(V)}if(w("registerListenersAndPositionElements invoked."),!s(T)){w("Aborting because element has been uninstalled");return}s(T).onRendered=pe,s(T).onExpand=ae,s(T).onShrink=ae;var Te=s(T).style;re(T,Te.width,Te.height)}function Z(){if(w("finalizeDomMutation invoked."),!s(T)){w("Aborting because element has been uninstalled");return}var re=s(T).style;Y(T,re.width,re.height),me(T,re.width,re.height)}function ue(){I(T)}function be(){w("Installing..."),k(),B(),n.add(0,W),n.add(1,j),n.add(2,ie),n.add(3,Z),n.add(4,ue)}w("Making detectable..."),R(T)?(w("Element is detached"),Me(),w("Waiting until element is attached..."),s(T).onRendered=function(){w("Element is now attached"),be()}):be()}function v(M){var T=s(M);T&&(T.onExpandScroll&&_(x(M),"scroll",T.onExpandScroll),T.onShrinkScroll&&_(y(M),"scroll",T.onShrinkScroll),T.onAnimationStart&&_(T.container,"animationstart",T.onAnimationStart),T.container&&M.removeChild(T.container))}return{makeDetectable:b,addListener:E,uninstall:v,initDocument:u}},scroll}var elementResizeDetector,hasRequiredElementResizeDetector;function requireElementResizeDetector(){if(hasRequiredElementResizeDetector)return elementResizeDetector;hasRequiredElementResizeDetector=1;var i=requireCollectionUtils().forEach,e=requireElementUtils(),t=requireListenerHandler(),n=requireIdGenerator(),s=requireIdHandler(),o=requireReporter(),a=requireBrowserDetector(),l=requireBatchProcessor(),c=requireStateHandler(),u=requireObject(),h=requireScroll();function d(_){return Array.isArray(_)||_.length!==void 0}function p(_){if(Array.isArray(_))return _;var x=[];return i(_,function(y){x.push(y)}),x}function f(_){return _&&_.nodeType===1}elementResizeDetector=function(_){_=_||{};var x;if(_.idHandler)x={get:function(ee){return _.idHandler.get(ee,!0)},set:_.idHandler.set};else{var y=n(),E=s({idGenerator:y,stateHandler:c});x=E}var b=_.reporter;if(!b){var v=b===!1;b=o(v)}var M=g(_,"batchProcessor",l({reporter:b})),T={};T.callOnAdd=!!g(_,"callOnAdd",!0),T.debug=!!g(_,"debug",!1);var I=t(x),w=e({stateHandler:c}),R,A=g(_,"strategy","object"),P=g(_,"important",!1),B={reporter:b,batchProcessor:M,stateHandler:c,idHandler:x,important:P};if(A==="scroll"&&(a.isLegacyOpera()?(b.warn("Scroll strategy is not supported on legacy Opera. Changing to object strategy."),A="object"):a.isIE(9)&&(b.warn("Scroll strategy is not supported on IE9. Changing to object strategy."),A="object")),A==="scroll")R=h(B);else if(A==="object")R=u(B);else throw new Error("Invalid strategy name: "+A);var k={};function W(ee,G,K){function F(ie){var Z=I.get(ie);i(Z,function(be){be(ie)})}function X(ie,Z,ue){I.add(Z,ue),ie&&ue(Z)}if(K||(K=G,G=ee,ee={}),!G)throw new Error("At least one element required.");if(!K)throw new Error("Listener required.");if(f(G))G=[G];else if(d(G))G=p(G);else return b.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");var se=0,me=g(ee,"callOnAdd",T.callOnAdd),Me=g(ee,"onReady",function(){}),j=g(ee,"debug",T.debug);i(G,function(Z){c.getState(Z)||(c.initState(Z),x.set(Z));var ue=x.get(Z);if(j&&b.log("Attaching listener to element",ue,Z),!w.isDetectable(Z)){if(j&&b.log(ue,"Not detectable."),w.isBusy(Z)){j&&b.log(ue,"System busy making it detectable"),X(me,Z,K),k[ue]=k[ue]||[],k[ue].push(function(){se++,se===G.length&&Me()});return}return j&&b.log(ue,"Making detectable..."),w.markBusy(Z,!0),R.makeDetectable({debug:j,important:P},Z,function(re){if(j&&b.log(ue,"onElementDetectable"),c.getState(re)){w.markAsDetectable(re),w.markBusy(re,!1),R.addListener(re,F),X(me,re,K);var Fe=c.getState(re);if(Fe&&Fe.startSize){var oe=re.offsetWidth,V=re.offsetHeight;(Fe.startSize.width!==oe||Fe.startSize.height!==V)&&F(re)}k[ue]&&i(k[ue],function(pe){pe()})}else j&&b.log(ue,"Element uninstalled before being detectable.");delete k[ue],se++,se===G.length&&Me()})}j&&b.log(ue,"Already detecable, adding listener."),X(me,Z,K),se++}),se===G.length&&Me()}function Y(ee){if(!ee)return b.error("At least one element is required.");if(f(ee))ee=[ee];else if(d(ee))ee=p(ee);else return b.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");i(ee,function(G){I.removeAllListeners(G),R.uninstall(G),c.cleanState(G)})}function $(ee){R.initDocument&&R.initDocument(ee)}return{listenTo:W,removeListener:I.removeListener,removeAllListeners:I.removeAllListeners,uninstall:Y,initDocument:$}};function g(_,x,y){var E=_[x];return E==null&&y!==void 0?y:E}return elementResizeDetector}var elementResizeDetectorExports=requireElementResizeDetector();const elementResizeDetectorMaker=getDefaultExportFromCjs(elementResizeDetectorExports);function getDomNodeDimensions(i){const{top:e,right:t,bottom:n,left:s,width:o,height:a}=i.getBoundingClientRect();return{top:e,right:t,bottom:n,left:s,width:o,height:a}}const ContainerDimensions=({children:i})=>{const[e,t]=React.useState(null),n=React.useRef(null),s=React.useRef(null);return React.useEffect(()=>{if(!n.current)return;const o=n.current.parentElement;if(!o)return;s.current=elementResizeDetectorMaker({strategy:"scroll",callOnAdd:!1});const a=()=>{const l=getDomNodeDimensions(o);t(l)};return s.current.listenTo(o,a),a(),()=>{s.current&&o&&s.current.uninstall(o)}},[]),e?typeof i=="function"?i(e):React.cloneElement(i,e):jsxRuntimeExports.jsx("div",{ref:n})},IDLE_DELAY=15e3,MAX_WIDTH=1200;function usePlanThumbnail(i){const e=React.useRef(i);e.current=i;const t=React.useRef(!1),n=React.useRef(null),s=React.useRef(null),o=React.useCallback((a=!1)=>{if(!a&&!t.current)return n.current??Promise.resolve();if(n.current)return n.current;const l=useReactPlannerStore.getState().planner.get("mode");return l===MODE_3D_VIEW||l===MODE_3D_FIRST_PERSON?Promise.resolve():(t.current=!1,n.current=(async()=>{var c;try{const u=await getSVGScreenshot({maxWidth:MAX_WIDTH});if(u===s.current)return;s.current=u,(c=e.current)==null||c.call(e,u)}catch(u){console.warn("Plan screenshot failed:",u),t.current=!0}finally{n.current=null}})(),n.current)},[]);return React.useEffect(()=>{let a=null,l=useReactPlannerStore.getState().planner.scene;const c=useReactPlannerStore.subscribe(d=>{d.planner.scene!==l&&(l=d.planner.scene,t.current=!0,a&&clearTimeout(a),a=setTimeout(()=>o(),IDLE_DELAY))}),u=()=>{a&&clearTimeout(a),o()},h=()=>{document.visibilityState==="hidden"&&u()};return document.addEventListener("visibilitychange",h),window.addEventListener("pagehide",u),()=>{a&&clearTimeout(a),c(),document.removeEventListener("visibilitychange",h),window.removeEventListener("pagehide",u)}},[o]),{ensureScreenshot:o}}const Toast=()=>{const{toast:i,setToast:e}=useReactPlannerStore(),[t,n]=React.useState(!1);return React.useEffect(()=>{let s;return i&&(n(!0),s=setTimeout(()=>{n(!1),setTimeout(()=>e(null),300)},2500)),()=>clearTimeout(s)},[i,e]),i?jsxRuntimeExports.jsx("div",{className:`absolute top-6 left-1/2 -translate-x-1/2 z-[9999] transition-all duration-300 ease-in-out
3936
+ `,P+="@keyframes "+R+" { 0% { opacity: 1; } 50% { opacity: 0; } 100% { opacity: 1; } }",w(P)}}function f(M){M.className+=" "+c+"_animation_active"}function g(M,T,I){if(M.addEventListener)M.addEventListener(T,I);else if(M.attachEvent)M.attachEvent("on"+T,I);else return t.error("[scroll] Don't know how to add event listeners.")}function _(M,T,I){if(M.removeEventListener)M.removeEventListener(T,I);else if(M.detachEvent)M.detachEvent("on"+T,I);else return t.error("[scroll] Don't know how to remove event listeners.")}function x(M){return s(M).container.childNodes[0].childNodes[0].childNodes[0]}function y(M){return s(M).container.childNodes[0].childNodes[0].childNodes[1]}function E(M,T){var I=s(M).listeners;if(!I.push)throw new Error("Cannot add listener to an element that is not detectable.");s(M).listeners.push(T)}function b(M,T,I){I||(I=T,T=M,M=null),M=M||{};function w(){if(M.debug){var re=Array.prototype.slice.call(arguments);if(re.unshift(o.get(T),"Scroll: "),t.log.apply)t.log.apply(null,re);else for(var Fe=0;Fe<re.length;Fe++)t.log(re[Fe])}}function R(re){function Fe(oe){var V=oe.getRootNode&&oe.getRootNode().contains(oe);return oe===oe.ownerDocument.body||oe.ownerDocument.body.contains(oe)||V}return!Fe(re)||window.getComputedStyle(re)===null}function A(re){var Fe=s(re).container.childNodes[0],oe=window.getComputedStyle(Fe);return!oe.width||oe.width.indexOf("px")===-1}function P(){var re=window.getComputedStyle(T),Fe={};return Fe.position=re.position,Fe.width=T.offsetWidth,Fe.height=T.offsetHeight,Fe.top=re.top,Fe.right=re.right,Fe.bottom=re.bottom,Fe.left=re.left,Fe.widthCSS=re.width,Fe.heightCSS=re.height,Fe}function B(){var re=P();s(T).startSize={width:re.width,height:re.height},w("Element start size",s(T).startSize)}function k(){s(T).listeners=[]}function W(){if(w("storeStyle invoked."),!s(T)){w("Aborting because element has been uninstalled");return}var re=P();s(T).style=re}function Y(re,Fe,oe){s(re).lastWidth=Fe,s(re).lastHeight=oe}function $(re){return x(re).childNodes[0]}function ee(){return 2*a.width+1}function G(){return 2*a.height+1}function K(re){return re+10+ee()}function F(re){return re+10+G()}function X(re){return re*2+ee()}function se(re){return re*2+G()}function me(re,Fe,oe){var V=x(re),pe=y(re),ae=K(Fe),Te=F(oe),_e=X(Fe),ye=se(oe);V.scrollLeft=ae,V.scrollTop=Te,pe.scrollLeft=_e,pe.scrollTop=ye}function Me(){var re=s(T).container;if(!re){re=document.createElement("div"),re.className=c,re.style.cssText=h(["visibility: hidden","display: inline","width: 0px","height: 0px","z-index: -1","overflow: hidden","margin: 0","padding: 0"]),s(T).container=re,f(re),T.appendChild(re);var Fe=function(){s(T).onRendered&&s(T).onRendered()};g(re,"animationstart",Fe),s(T).onAnimationStart=Fe}return re}function j(){function re(){var Be=s(T).style;if(Be.position==="static"){T.style.setProperty("position","relative",M.important?"important":"");var Le=function(je,Ve,Oe,ve){function Ne(xe){return xe.replace(/[^-\d\.]/g,"")}var Ce=Oe[ve];Ce!=="auto"&&Ne(Ce)!=="0"&&(je.warn("An element that is positioned static has style."+ve+"="+Ce+" which is ignored due to the static positioning. The element will need to be positioned relative, so the style."+ve+" will be set to 0. Element: ",Ve),Ve.style[ve]=0)};Le(t,T,Be,"top"),Le(t,T,Be,"right"),Le(t,T,Be,"bottom"),Le(t,T,Be,"left")}}function Fe(Be,Le,je,Ve){return Be=Be?Be+"px":"0",Le=Le?Le+"px":"0",je=je?je+"px":"0",Ve=Ve?Ve+"px":"0",["left: "+Be,"top: "+Le,"right: "+Ve,"bottom: "+je]}if(w("Injecting elements"),!s(T)){w("Aborting because element has been uninstalled");return}re();var oe=s(T).container;oe||(oe=Me());var V=a.width,pe=a.height,ae=h(["position: absolute","flex: none","overflow: hidden","z-index: -1","visibility: hidden","width: 100%","height: 100%","left: 0px","top: 0px"]),Te=h(["position: absolute","flex: none","overflow: hidden","z-index: -1","visibility: hidden"].concat(Fe(-(1+V),-(1+pe),-pe,-V))),_e=h(["position: absolute","flex: none","overflow: scroll","z-index: -1","visibility: hidden","width: 100%","height: 100%"]),ye=h(["position: absolute","flex: none","overflow: scroll","z-index: -1","visibility: hidden","width: 100%","height: 100%"]),Se=h(["position: absolute","left: 0","top: 0"]),Ae=h(["position: absolute","width: 200%","height: 200%"]),qe=document.createElement("div"),$e=document.createElement("div"),U=document.createElement("div"),N=document.createElement("div"),ne=document.createElement("div"),he=document.createElement("div");qe.dir="ltr",qe.style.cssText=ae,qe.className=c,$e.className=c,$e.style.cssText=Te,U.style.cssText=_e,N.style.cssText=Se,ne.style.cssText=ye,he.style.cssText=Ae,U.appendChild(N),ne.appendChild(he),$e.appendChild(U),$e.appendChild(ne),qe.appendChild($e),oe.appendChild(qe);function Ie(){var Be=s(T);Be&&Be.onExpand?Be.onExpand():w("Aborting expand scroll handler: element has been uninstalled")}function fe(){var Be=s(T);Be&&Be.onShrink?Be.onShrink():w("Aborting shrink scroll handler: element has been uninstalled")}g(U,"scroll",Ie),g(ne,"scroll",fe),s(T).onExpandScroll=Ie,s(T).onShrinkScroll=fe}function ie(){function re(_e,ye,Se){var Ae=$(_e),qe=K(ye),$e=F(Se);Ae.style.setProperty("width",qe+"px",M.important?"important":""),Ae.style.setProperty("height",$e+"px",M.important?"important":"")}function Fe(_e){var ye=T.offsetWidth,Se=T.offsetHeight,Ae=ye!==s(T).lastWidth||Se!==s(T).lastHeight;w("Storing current size",ye,Se),Y(T,ye,Se),n.add(0,function(){if(Ae){if(!s(T)){w("Aborting because element has been uninstalled");return}if(!oe()){w("Aborting because element container has not been initialized");return}if(M.debug){var $e=T.offsetWidth,U=T.offsetHeight;($e!==ye||U!==Se)&&t.warn(o.get(T),"Scroll: Size changed before updating detector elements.")}re(T,ye,Se)}}),n.add(1,function(){if(!s(T)){w("Aborting because element has been uninstalled");return}if(!oe()){w("Aborting because element container has not been initialized");return}me(T,ye,Se)}),Ae&&_e&&n.add(2,function(){if(!s(T)){w("Aborting because element has been uninstalled");return}if(!oe()){w("Aborting because element container has not been initialized");return}_e()})}function oe(){return!!s(T).container}function V(){function _e(){return s(T).lastNotifiedWidth===void 0}w("notifyListenersIfNeeded invoked");var ye=s(T);if(_e()&&ye.lastWidth===ye.startSize.width&&ye.lastHeight===ye.startSize.height)return w("Not notifying: Size is the same as the start size, and there has been no notification yet.");if(ye.lastWidth===ye.lastNotifiedWidth&&ye.lastHeight===ye.lastNotifiedHeight)return w("Not notifying: Size already notified");w("Current size not notified, notifying..."),ye.lastNotifiedWidth=ye.lastWidth,ye.lastNotifiedHeight=ye.lastHeight,i(s(T).listeners,function(Se){Se(T)})}function pe(){if(w("startanimation triggered."),A(T)){w("Ignoring since element is still unrendered...");return}w("Element rendered.");var _e=x(T),ye=y(T);(_e.scrollLeft===0||_e.scrollTop===0||ye.scrollLeft===0||ye.scrollTop===0)&&(w("Scrollbars out of sync. Updating detector elements..."),Fe(V))}function ae(){if(w("Scroll detected."),A(T)){w("Scroll event fired while unrendered. Ignoring...");return}Fe(V)}if(w("registerListenersAndPositionElements invoked."),!s(T)){w("Aborting because element has been uninstalled");return}s(T).onRendered=pe,s(T).onExpand=ae,s(T).onShrink=ae;var Te=s(T).style;re(T,Te.width,Te.height)}function Z(){if(w("finalizeDomMutation invoked."),!s(T)){w("Aborting because element has been uninstalled");return}var re=s(T).style;Y(T,re.width,re.height),me(T,re.width,re.height)}function ue(){I(T)}function be(){w("Installing..."),k(),B(),n.add(0,W),n.add(1,j),n.add(2,ie),n.add(3,Z),n.add(4,ue)}w("Making detectable..."),R(T)?(w("Element is detached"),Me(),w("Waiting until element is attached..."),s(T).onRendered=function(){w("Element is now attached"),be()}):be()}function v(M){var T=s(M);T&&(T.onExpandScroll&&_(x(M),"scroll",T.onExpandScroll),T.onShrinkScroll&&_(y(M),"scroll",T.onShrinkScroll),T.onAnimationStart&&_(T.container,"animationstart",T.onAnimationStart),T.container&&M.removeChild(T.container))}return{makeDetectable:b,addListener:E,uninstall:v,initDocument:u}},scroll}var elementResizeDetector,hasRequiredElementResizeDetector;function requireElementResizeDetector(){if(hasRequiredElementResizeDetector)return elementResizeDetector;hasRequiredElementResizeDetector=1;var i=requireCollectionUtils().forEach,e=requireElementUtils(),t=requireListenerHandler(),n=requireIdGenerator(),s=requireIdHandler(),o=requireReporter(),a=requireBrowserDetector(),l=requireBatchProcessor(),c=requireStateHandler(),u=requireObject(),h=requireScroll();function d(_){return Array.isArray(_)||_.length!==void 0}function p(_){if(Array.isArray(_))return _;var x=[];return i(_,function(y){x.push(y)}),x}function f(_){return _&&_.nodeType===1}elementResizeDetector=function(_){_=_||{};var x;if(_.idHandler)x={get:function(ee){return _.idHandler.get(ee,!0)},set:_.idHandler.set};else{var y=n(),E=s({idGenerator:y,stateHandler:c});x=E}var b=_.reporter;if(!b){var v=b===!1;b=o(v)}var M=g(_,"batchProcessor",l({reporter:b})),T={};T.callOnAdd=!!g(_,"callOnAdd",!0),T.debug=!!g(_,"debug",!1);var I=t(x),w=e({stateHandler:c}),R,A=g(_,"strategy","object"),P=g(_,"important",!1),B={reporter:b,batchProcessor:M,stateHandler:c,idHandler:x,important:P};if(A==="scroll"&&(a.isLegacyOpera()?(b.warn("Scroll strategy is not supported on legacy Opera. Changing to object strategy."),A="object"):a.isIE(9)&&(b.warn("Scroll strategy is not supported on IE9. Changing to object strategy."),A="object")),A==="scroll")R=h(B);else if(A==="object")R=u(B);else throw new Error("Invalid strategy name: "+A);var k={};function W(ee,G,K){function F(ie){var Z=I.get(ie);i(Z,function(be){be(ie)})}function X(ie,Z,ue){I.add(Z,ue),ie&&ue(Z)}if(K||(K=G,G=ee,ee={}),!G)throw new Error("At least one element required.");if(!K)throw new Error("Listener required.");if(f(G))G=[G];else if(d(G))G=p(G);else return b.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");var se=0,me=g(ee,"callOnAdd",T.callOnAdd),Me=g(ee,"onReady",function(){}),j=g(ee,"debug",T.debug);i(G,function(Z){c.getState(Z)||(c.initState(Z),x.set(Z));var ue=x.get(Z);if(j&&b.log("Attaching listener to element",ue,Z),!w.isDetectable(Z)){if(j&&b.log(ue,"Not detectable."),w.isBusy(Z)){j&&b.log(ue,"System busy making it detectable"),X(me,Z,K),k[ue]=k[ue]||[],k[ue].push(function(){se++,se===G.length&&Me()});return}return j&&b.log(ue,"Making detectable..."),w.markBusy(Z,!0),R.makeDetectable({debug:j,important:P},Z,function(re){if(j&&b.log(ue,"onElementDetectable"),c.getState(re)){w.markAsDetectable(re),w.markBusy(re,!1),R.addListener(re,F),X(me,re,K);var Fe=c.getState(re);if(Fe&&Fe.startSize){var oe=re.offsetWidth,V=re.offsetHeight;(Fe.startSize.width!==oe||Fe.startSize.height!==V)&&F(re)}k[ue]&&i(k[ue],function(pe){pe()})}else j&&b.log(ue,"Element uninstalled before being detectable.");delete k[ue],se++,se===G.length&&Me()})}j&&b.log(ue,"Already detecable, adding listener."),X(me,Z,K),se++}),se===G.length&&Me()}function Y(ee){if(!ee)return b.error("At least one element is required.");if(f(ee))ee=[ee];else if(d(ee))ee=p(ee);else return b.error("Invalid arguments. Must be a DOM element or a collection of DOM elements.");i(ee,function(G){I.removeAllListeners(G),R.uninstall(G),c.cleanState(G)})}function $(ee){R.initDocument&&R.initDocument(ee)}return{listenTo:W,removeListener:I.removeListener,removeAllListeners:I.removeAllListeners,uninstall:Y,initDocument:$}};function g(_,x,y){var E=_[x];return E==null&&y!==void 0?y:E}return elementResizeDetector}var elementResizeDetectorExports=requireElementResizeDetector();const elementResizeDetectorMaker=getDefaultExportFromCjs(elementResizeDetectorExports);function getDomNodeDimensions(i){const{top:e,right:t,bottom:n,left:s,width:o,height:a}=i.getBoundingClientRect();return{top:e,right:t,bottom:n,left:s,width:o,height:a}}const ContainerDimensions=({children:i})=>{const[e,t]=React.useState(null),n=React.useRef(null),s=React.useRef(null);return React.useEffect(()=>{if(!n.current)return;const o=n.current.parentElement;if(!o)return;s.current=elementResizeDetectorMaker({strategy:"scroll",callOnAdd:!1});const a=()=>{const l=getDomNodeDimensions(o);t(l)};return s.current.listenTo(o,a),a(),()=>{s.current&&o&&s.current.uninstall(o)}},[]),e?typeof i=="function"?i(e):React.cloneElement(i,e):jsxRuntimeExports.jsx("div",{ref:n})},DRAWABLE=["vertices","lines","holes","areas","items"],sameIgnoringSelection=(i,e)=>i.size!==e.size?!1:i.every((t,n)=>{const s=e.get(n);return s===void 0?!1:t===s?!0:t.set("selected",!1).equals(s.set("selected",!1))}),layerChanged=(i,e)=>{if(!e)return!0;if(i===e)return!1;if(i.visible!==e.visible||i.opacity!==e.opacity||i.altitude!==e.altitude||i.order!==e.order)return!0;const t=i.selected!==e.selected;return DRAWABLE.some(n=>{const s=i[n],o=e[n];return s===o?!1:t?!sameIgnoringSelection(s,o):!0})};function hasVisualChange(i,e){if(i.showDimensions!==e.showDimensions||i.showGrid!==e.showGrid||i.theme!==e.theme)return!0;const t=i.planner.scene,n=e.planner.scene;if(t===n)return!1;if(t.width!==n.width||t.height!==n.height||t.unit!==n.unit||t.grids!==n.grids||t.guides!==n.guides)return!0;if(t.layers===n.layers)return!1;if(t.layers.size!==n.layers.size)return!0;const s=n.layers;return t.layers.some((o,a)=>layerChanged(o,s.get(a)))}const SETTLE_DELAY=800,MAX_WAIT=6e3,RETRY_DELAY=2e3,MAX_RETRIES=3,MAX_WIDTH=1200,isCapturable=i=>MODE_2D_VIEWER.includes(i)&&!MODE_IN_PROGRESS.includes(i);function usePlanThumbnail(i){const e=React.useRef(i);e.current=i;const t=React.useRef(!1),n=React.useRef(null),s=React.useRef(null),o=React.useCallback((a=!1)=>!a&&!t.current?n.current??Promise.resolve():n.current?n.current:isCapturable(useReactPlannerStore.getState().planner.get("mode"))?(t.current=!1,n.current=(async()=>{var l;try{const c=await getSVGScreenshot({maxWidth:MAX_WIDTH});if(c===s.current)return;s.current=c,(l=e.current)==null||l.call(e,c)}catch(c){console.warn("Plan screenshot failed:",c),t.current=!0}finally{n.current=null}})(),n.current):Promise.resolve(),[]);return React.useEffect(()=>{let a=null,l=null,c=0;const u=()=>{a=null,l=null,isCapturable(useReactPlannerStore.getState().planner.get("mode"))&&o().then(()=>{a||!t.current||c>=MAX_RETRIES||(c+=1,a=setTimeout(u,RETRY_DELAY*c))})},h=()=>{const g=Date.now();l===null&&(l=g),a&&clearTimeout(a),a=setTimeout(u,Math.max(0,Math.min(SETTLE_DELAY,l+MAX_WAIT-g)))},d=useReactPlannerStore.subscribe((g,_)=>{if(hasVisualChange(g,_)){t.current=!0,c=0,h();return}const x=g.planner.get("mode");t.current&&isCapturable(x)&&!isCapturable(_.planner.get("mode"))&&h()}),p=()=>{a&&clearTimeout(a),a=null,l=null,o()},f=()=>{document.visibilityState==="hidden"&&p()};return document.addEventListener("visibilitychange",f),window.addEventListener("pagehide",p),()=>{a&&clearTimeout(a),d(),document.removeEventListener("visibilitychange",f),window.removeEventListener("pagehide",p),o()}},[o]),{ensureScreenshot:o}}const Toast=()=>{const{toast:i,setToast:e}=useReactPlannerStore(),[t,n]=React.useState(!1);return React.useEffect(()=>{let s;return i&&(n(!0),s=setTimeout(()=>{n(!1),setTimeout(()=>e(null),300)},2500)),()=>clearTimeout(s)},[i,e]),i?jsxRuntimeExports.jsx("div",{className:`absolute top-6 left-1/2 -translate-x-1/2 z-[9999] transition-all duration-300 ease-in-out
3937
3937
  ${t?"opacity-100 translate-y-0":"opacity-0 -translate-y-2"}
3938
3938
  `,children:jsxRuntimeExports.jsx("div",{className:"p-1 px-3 shadow-md rounded-md bg-white text-slate-600",children:jsxRuntimeExports.jsxs("div",{className:"flex gap-1 justify-center items-center h-8 rounded",children:[jsxRuntimeExports.jsx("span",{className:"text-xs",children:i.text}),jsxRuntimeExports.jsx("div",{className:"text-xs bg-gray-50 border rounded-md px-1 py-0.5 font-medium",children:"ESC"})]})})}):null};class ErrorBoundary extends React.Component{constructor(){super(...arguments);ze(this,"state",{error:null})}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){console.error("[floor-planner] render crashed",t,n.componentStack)}render(){return this.state.error?jsxRuntimeExports.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-4 bg-white p-8 text-center dark:bg-neutral-900",children:[jsxRuntimeExports.jsx("h2",{className:"text-lg font-semibold text-neutral-900 dark:text-neutral-100",children:"Something went wrong with this floor plan."}),jsxRuntimeExports.jsx("p",{className:"max-w-md text-sm text-neutral-500 dark:text-neutral-400",children:this.state.error.message}),jsxRuntimeExports.jsx("button",{type:"button",className:"rounded px-4 py-2 text-sm font-medium text-white",style:{background:"var(--dark-blue, #1ca6fc)"},onClick:()=>{var t,n;(n=(t=this.props).onReset)==null||n.call(t),window.location.reload()},children:"Reset floor plan"})]}):this.props.children}}function IoClose(i){return GenIcon({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"m289.94 256 95-95A24 24 0 0 0 351 127l-95 95-95-95a24 24 0 0 0-34 34l95 95-95 95a24 24 0 1 0 34 34l95-95 95 95a24 24 0 0 0 34-34z"},child:[]}]})(i)}async function getAIResponse(i,e){var s;await new Promise(o=>setTimeout(o,400));const n=(((s=i[i.length-1])==null?void 0:s.content)??"").toLowerCase().trim();return/\b(help|what can you do|commands)\b/.test(n)?{reply:"Connect a real backend via the onAIMessage prop for full functionality — the built-in stub only understands very basic phrases.",actions:[]}:{reply:"I don't have a real AI backend configured. Pass an `onAIMessage` prop to `<ReactPlanner>` to wire this up to your server.",actions:[]}}function orientationOf(i,e,t,n){const s=Math.abs(t-i),o=Math.abs(n-e);return s<1?"vertical":o<1?"horizontal":"diagonal"}function summarizePlan(i){var E,b,v,M,T,I;const e=i.get("scene"),t=e.get("selectedLayer"),n=t?e.getIn(["layers",t]):null,s=[],o=[],a=[],l=[];if(n){const w=n.get("vertices");n.get("lines").forEach(R=>{const[A,P]=R.get("vertices").toArray(),B=w.get(A),k=w.get(P);if(!B||!k)return;const W=B.get("x"),Y=B.get("y"),$=k.get("x"),ee=k.get("y"),G=Math.hypot($-W,ee-Y);s.push({id:R.get("id"),v0:A,v1:P,x0:W,y0:Y,x1:$,y1:ee,length:Math.round(G),orientation:orientationOf(W,Y,$,ee),holeCount:R.get("holes").size,thickness:R.getIn(["properties","thickness","length"])??null,height:R.getIn(["properties","height","length"])??null,textureA:R.getIn(["properties","textureA"])??null,textureB:R.getIn(["properties","textureB"])??null})}),n.get("holes").forEach(R=>{o.push({id:R.get("id"),type:R.get("type")??R.get("name")??"hole",lineID:R.get("line"),offset:R.get("offset"),flipAlongWall:R.get("flipAlongWall")===!0,flipAcrossWall:R.getIn(["properties","flip_horizontal"])===!0})}),n.get("areas").forEach(R=>{const A=[];R.get("vertices").forEach(B=>{const k=w.get(B);k&&A.push({id:B,x:k.get("x"),y:k.get("y")})});const P=getAreaKind(R,n);a.push({id:R.get("id"),kind:P==="Surface"?"surface":P==="Room"?"room":"area",vertices:A,color:R.getIn(["properties","patternColor"])??null,pattern:R.getIn(["properties","pattern"])??null,texture:R.getIn(["properties","texture"])??null,customName:R.getIn(["properties","customName"])||null,roomCategory:R.getIn(["properties","roomCategory"])??null,roomType:R.getIn(["properties","roomType"])??null,showName:R.getIn(["properties","showName"])??!0,showSurfaceArea:R.getIn(["properties","showSurfaceArea"])??!1})}),n.get("items").forEach(R=>{const A=getItemTransform(R);l.push({id:R.get("id"),name:R.get("type")??R.get("name")??"item",x:R.get("x")??0,y:R.get("y")??0,rotation:R.get("rotation")??0,scale:A.scale,flipHorizontal:A.flipHorizontal,flipVertical:A.flipVertical})})}const c=i.getIn(["catalog","elements"]),u=[],h=[],d=[];let p=[],f=[];if(c){c.forEach((R,A)=>{const P=R.get("prototype");P==="items"?u.push(A):P==="holes"?h.push(A):P==="lines"&&A!=="wall"&&d.push(A)});const w=R=>{var B;const A=c.get(R),P=(B=A==null?void 0:A.get)==null?void 0:B.call(A,"textures");return!P||typeof P.keySeq!="function"?[]:P.keySeq().toArray()};p=w("wall"),f=w("area")}const g=AREA_PATTERNS.map(w=>w.key),_=i.get("mode"),x=useReactPlannerStore.getState().showDimensions,y={walls:[],holes:[],items:[],areas:[],vertices:[]};if(n){const w=n.get("selected");if(w){const R=new Set;(E=w.get("areas"))==null||E.forEach(A=>{var B;const P=n.getIn(["areas",A]);P&&((B=P.get("vertices"))==null||B.forEach(k=>{var Y;const W=n.getIn(["vertices",k]);(Y=W==null?void 0:W.get("lines"))==null||Y.forEach($=>{const ee=n.getIn(["lines",$]);(ee==null?void 0:ee.get("type"))==="surface"&&R.add($)})}))}),(b=w.get("lines"))==null||b.forEach(A=>{R.has(A)||y.walls.push(A)}),(v=w.get("holes"))==null||v.forEach(A=>y.holes.push(A)),(M=w.get("items"))==null||M.forEach(A=>y.items.push(A)),(T=w.get("areas"))==null||T.forEach(A=>y.areas.push(A)),(I=w.get("vertices"))==null||I.forEach(A=>y.vertices.push(A))}}return{layerName:n?n.get("name")??"Layer":"(no layer)",wallCount:s.length,itemCount:l.length,holeCount:o.length,areaCount:a.length,walls:s,holes:o,areas:a,items:l,mode:_,is3D:_===MODE_3D_VIEW,showDimensions:x,sceneWidth:e.get("width")??0,sceneHeight:e.get("height")??0,unit:e.get("unit")??"ft",catalogItemTypes:u,catalogHoleTypes:h,catalogSurfaceTypes:d,catalogAreaPatterns:g,catalogAreaTextures:f,catalogWallTextures:p,roomTypes:ROOM_CATEGORIES.map(w=>({...w,types:w.types.map(({color:R,...A})=>A)})),selection:y}}function placeAgainst(i,e,t,n){switch(e){case"left":return{x0:i.x0-t,x1:i.x0,y0:i.y1-n,y1:i.y1};case"above":return{x0:i.x0,x1:i.x0+t,y0:i.y1,y1:i.y1+n};case"below":return{x0:i.x0,x1:i.x0+t,y0:i.y0-n,y1:i.y0};default:return{x0:i.x1,x1:i.x1+t,y0:i.y1-n,y1:i.y1}}}function rectOfArea(i,e){const t=[],n=[];return i.get("vertices").forEach(s=>{const o=e.get(s);o&&(t.push(o.get("x")),n.push(o.get("y")))}),t.length<3?null:{x0:Math.min(...t),x1:Math.max(...t),y0:Math.min(...n),y1:Math.max(...n)}}function findRoomByName(i,e,t,{surfaces:n=!1}={}){const s=i.getIn(["scene","layers",e]);if(!s)return null;const o=s.get("vertices"),a=h=>n||getAreaKind(h,s)!=="Surface",l=s.getIn(["areas",t]);if(l)return a(l)?{id:t,rect:rectOfArea(l,o)}:null;const c=t.trim().toLowerCase();let u=null;return s.get("areas").forEach(h=>{if(u||!a(h))return;const d=h.getIn(["properties","customName"]);typeof d=="string"&&d.trim().toLowerCase()===c&&(u={id:h.get("id"),rect:rectOfArea(h,o)})}),u}function areaProps(i){const e={};if(i.name&&(e.customName=i.name),i.roomCategory&&(e.roomCategory=i.roomCategory),i.roomType){e.roomType=i.roomType;const t=getRoomTypeColor(i.roomCategory,i.roomType);t&&(e.patternColor=t)}return i.color&&(e.patternColor=i.color),i.pattern&&(e.pattern=i.pattern,e.texture="none"),i.texture&&(e.texture=i.texture,e.pattern="none"),e}function findAreaContainingPoint(i,e,t,n){const s=i.getIn(["scene","layers",e]);if(!s)return;const o=s.get("vertices");let a;return s.get("areas").forEach(l=>{if(a)return;const c=[];l.get("vertices").forEach(u=>{const h=o.get(u);h&&c.push(h.get("x"),h.get("y"))}),c.length>=6&&ContainsPoint(c,t,n)&&(a=l.get("id"))}),a}function findWalls(i,e,t,n){const s=i.getIn(["scene","layers",e]),o=s==null?void 0:s.getIn(["areas",t]);if(!o)return[];const a=s.get("vertices"),l=new Set(o.get("vertices").toArray()),c=rectOfArea(o,a);if(!c)return[];const u=(c.x0+c.x1)/2,h=(c.y0+c.y1)/2,d=[];return s.get("lines").forEach(p=>{const[f,g]=p.get("vertices").toArray();if(!l.has(f)||!l.has(g))return;const _=a.get(f),x=a.get(g);if(!_||!x)return;const y=Math.abs(_.get("y")-x.get("y"))<Math.abs(_.get("x")-x.get("x")),E=(_.get("x")+x.get("x"))/2,b=(_.get("y")+x.get("y"))/2;(y?b>=h?"above":"below":E>=u?"right":"left")===n&&d.push(p.get("id"))}),d}function sharedWall(i,e,t,n){const s=i.getIn(["scene","layers",e]),o=h=>{var d;return new Set(((d=s.getIn(["areas",h,"vertices"]))==null?void 0:d.toArray())??[])},a=o(t),l=o(n),c=s.get("vertices");let u;return s.get("lines").forEach(h=>{const[d,p]=h.get("vertices").toArray();if(!(a.has(d)&&a.has(p)&&l.has(d)&&l.has(p)))return;const f=Math.hypot(c.getIn([d,"x"])-c.getIn([p,"x"]),c.getIn([d,"y"])-c.getIn([p,"y"]));(!u||f>u.span)&&(u={id:h.get("id"),span:f})}),u==null?void 0:u.id}function surfacePoints(i,e,t){return e==="left"?[{x:i.x0-t,y:i.y0},{x:i.x0,y:i.y0},{x:i.x0,y:i.y1},{x:i.x0-t,y:i.y1}]:e==="right"?[{x:i.x1,y:i.y0},{x:i.x1+t,y:i.y0},{x:i.x1+t,y:i.y1},{x:i.x1,y:i.y1}]:e==="above"?[{x:i.x0,y:i.y1},{x:i.x1,y:i.y1},{x:i.x1,y:i.y1+t},{x:i.x0,y:i.y1+t}]:[{x:i.x0,y:i.y0-t},{x:i.x1,y:i.y0-t},{x:i.x1,y:i.y0},{x:i.x0,y:i.y0}]}function neighbourRoom(i,e,t,n){const s=i.getIn(["scene","layers",e]),o=new Set(s.getIn(["areas",t,"vertices"]).toArray());for(const a of findWalls(i,e,t,n)){const[l,c]=s.getIn(["lines",a,"vertices"]).toArray();let u;if(s.get("areas").forEach(h=>{if(u||h.get("id")===t)return;const d=new Set(h.get("vertices").toArray());d.has(l)&&d.has(c)&&o.has(l)&&o.has(c)&&(u=h.getIn(["properties","customName"])||"another room")}),u)return u}}function widestWall(i,e,t,n){const s=i.getIn(["scene","layers",e,"vertices"]),o=a=>{const[l,c]=i.getIn(["scene","layers",e,"lines",a,"vertices"]).toArray();return Math.hypot(s.getIn([l,"x"])-s.getIn([c,"x"]),s.getIn([l,"y"])-s.getIn([c,"y"]))};return findWalls(i,e,t,n).sort((a,l)=>o(l)-o(a))[0]}function respaceHoles(i,e,t,n){const s=e.getIn(["scene","layers",t,"lines",n,"holes"]),o=s?s.toArray():[];o.length<2||o.forEach((a,l)=>i.moveHole(a,(l+1)/(o.length+1)))}const GRID=8;function roomWalls(i,e,t){const n={};for(const s of["left","right","above","below"])n[s]=findWalls(i,e,t,s);return n}function faceFacing(i,e,t,n){const s=i.getIn(["scene","layers",e]),o=s.get("vertices"),[a,l]=s.getIn(["lines",t,"vertices"]).toArray(),c=M=>({id:M,x:Number(o.getIn([M,"x"])),y:Number(o.getIn([M,"y"]))});let u=c(a),h=c(l);const d={x:-(h.y-u.y),y:h.x-u.x};let p=!0;e:for(const M of s.get("areas").valueSeq()){const T=M.get("vertices");for(let I=0;I<T.size;I+=1){const w=T.get(I),R=T.get((I+1)%T.size);if(w===u.id&&R===h.id||w===h.id&&R===u.id){const A=c(w),P=c(R),B={x:-(P.y-A.y),y:P.x-A.x};p=d.x*B.x+d.y*B.y<0;break e}}}u.x>h.x&&([u,h]=[h,u]);const f=Math.hypot(h.x-u.x,h.y-u.y)||1,g=(h.y-u.y)/f,_=Math.cos(Math.asin(g)),x=(u.x+h.x)/2,y=(u.y+h.y)/2;return(n.x-x)*g+(n.y-y)*-_>0?p?"A":"B":p?"B":"A"}function itemSize(i,e,t=1){const n=i.getIn(["catalog","elements",e,"info"]),s=Number(n==null?void 0:n.get("width"))||200,o=Number(n==null?void 0:n.get("depth"))||100;return{w:s*t,d:o*t}}function itemRects(i,e){const t=i.getIn(["scene","layers",e,"items"]),n=[];return t==null||t.forEach(s=>{const{w:o,d:a}=itemSize(i,s.get("type"),Number(s.get("scale"))||1),l=Math.round((Number(s.get("rotation"))||0)/90)%2!==0,[c,u]=l?[a,o]:[o,a],h=Number(s.get("x")),d=Number(s.get("y"));n.push({itemID:s.get("id"),x0:h-c/2,x1:h+c/2,y0:d-u/2,y1:d+u/2})}),n}const overlaps=(i,e)=>Math.min(i.x1,e.x1)-Math.max(i.x0,e.x0)>0&&Math.min(i.y1,e.y1)-Math.max(i.y0,e.y0)>0;function placeInRoom(i,e,t,n,s,o){if(n>i.x1-i.x0||s>i.y1-i.y0)return null;const a=(i.x1-i.x0)/GRID,l=(i.y1-i.y0)/GRID,c=[];for(let u=1;u<=GRID;u+=1)for(let h=1;h<=GRID;h+=1)c.push({c:u,r:h,dist:Math.abs(u-e)+Math.abs(h-t)});c.sort((u,h)=>u.dist-h.dist);for(const{c:u,r:h}of c){const d=clamp(i.x0+(u-.5)*a,i.x0+n/2,i.x1-n/2),p=clamp(i.y1-(h-.5)*l,i.y0+s/2,i.y1-s/2),f={x0:d-n/2,x1:d+n/2,y0:p-s/2,y1:p+s/2};if(!o.some(g=>overlaps(g,f)))return{x:d,y:p}}return null}const clamp=(i,e,t)=>Math.min(Math.max(i,e),t);function applyPlannerActions(i){var s,o,a,l,c,u;const e=[],t=useReactPlannerStore.getState();let n=!1;for(const h of i){if(h.type==="set-wall-properties"){const E=useReactPlannerStore.getState().planner,b=E.getIn(["scene","selectedLayer"]),v=b?(s=findRoomByName(E,b,h.room))==null?void 0:s.id:void 0,M=v?E.getIn(["scene","layers",b,"areas",v]):void 0,T=M?rectOfArea(M,E.getIn(["scene","layers",b,"vertices"])):null;if(!T){e.push(`wall changes (no room called "${h.room}")`);continue}const I=roomWalls(E,b,v),w=h.side?I[h.side]:Object.values(I).flat();if(w.length===0){e.push(`wall changes ("${h.room}" has no ${h.side} wall)`);continue}for(const R of w){const A=faceFacing(E,b,R,{x:(T.x0+T.x1)/2,y:(T.y0+T.y1)/2}),P={};h.color&&(P[`color${A}`]=h.color),h.texture&&(P[`texture${A}`]=h.texture);for(const B of["thickness","height"]){const k=h[B];typeof k=="number"&&(P[B]={length:k,_length:k,_unit:"cm"})}t.setLineProperties(R,P)}continue}if(h.type==="set-item-properties"){const E=useReactPlannerStore.getState().planner,b=E.getIn(["scene","selectedLayer"]),v=b?findRoomByName(E,b,h.room):void 0;if(!(v!=null&&v.rect)){e.push(`${h.item} (no room called "${h.room}")`);continue}const M=v.rect,T=[];if(E.getIn(["scene","layers",b,"items"]).forEach(A=>{const P=Number(A.get("x")),B=Number(A.get("y"));P>=M.x0&&P<=M.x1&&B>=M.y0&&B<=M.y1&&A.get("type")===h.item&&T.push(A)}),T.length===0){e.push(`${h.item} (none in "${h.room}")`);continue}if(T.length>1){e.push(`${h.item} ("${h.room}" has ${T.length} — ask which one)`);continue}const w=T[0],R={};if(typeof h.rotation=="number"&&(R.rotation=h.rotation),typeof h.scale=="number"&&(R.scale=clampItemScale(h.scale)),typeof h.flipHorizontal=="boolean"&&(R.flipHorizontal=h.flipHorizontal),typeof h.flipVertical=="boolean"&&(R.flipVertical=h.flipVertical),typeof h.col=="number"&&typeof h.row=="number"){const A=Number(R.scale??w.get("scale"))||1,P=Number(R.rotation??w.get("rotation"))||0,{w:B,d:k}=itemSize(E,h.item,A),W=Math.round(P/90)%2!==0,Y=itemRects(E,b).filter(ee=>overlaps(ee,M)&&ee.itemID!==w.get("id")),$=placeInRoom(M,h.col,h.row,W?k:B,W?B:k,Y);if(!$){e.push(`moving ${h.item} (nowhere free in "${h.room}")`);continue}R.x=$.x,R.y=$.y}t.setItemAttributes(w.get("id"),R);continue}if(h.type==="add-item"){const E=useReactPlannerStore.getState().planner,b=E.getIn(["scene","selectedLayer"]),v=b?(o=findRoomByName(E,b,h.room))==null?void 0:o.id:void 0,M=v?E.getIn(["scene","layers",b,"areas",v]):void 0,T=M?rectOfArea(M,E.getIn(["scene","layers",b,"vertices"])):null;if(!T){e.push(`${h.itemType} (no room called "${h.room}")`);continue}const{w:I,d:w}=itemSize(E,h.itemType),R=Math.round((h.rotation??0)/90)%2!==0,A=placeInRoom(T,h.col,h.row,R?w:I,R?I:w,itemRects(E,b).filter(P=>overlaps(P,T)));if(!A){e.push(`${h.itemType} (no room for it in "${h.room}")`);continue}t.addItemByCoords(h.itemType,A.x,A.y,I,w,h.rotation??0);continue}if(h.type==="set-surface-properties"){const E=useReactPlannerStore.getState().planner,b=E.getIn(["scene","selectedLayer"]),v=b?findRoomByName(E,b,h.surface,{surfaces:!0}):void 0,M=b?E.getIn(["scene","layers",b]):void 0;if(!(v!=null&&v.rect)||getAreaKind(M.getIn(["areas",v.id]),M)!=="Surface"){e.push(`changing "${h.surface}" (no outdoor surface by that name)`);continue}const T=areaProps({name:h.name,texture:h.texture,pattern:h.pattern,color:h.color});if(typeof h.depth=="number"){const I=v.rect;let w,R;if(M.get("areas").forEach(W=>{if(w||W.get("id")===v.id||getAreaKind(W,M)==="Surface")return;const Y=rectOfArea(W,M.get("vertices"));if(!Y)return;const $=(ee,G)=>Math.abs(ee-G)<=1;$(I.x1,Y.x0)?(w=Y,R="left"):$(I.x0,Y.x1)?(w=Y,R="right"):$(I.y0,Y.y1)?(w=Y,R="above"):$(I.y1,Y.y0)&&(w=Y,R="below")}),!w||!R){e.push(`resizing "${h.surface}" (can't tell which wall it lies against)`);continue}const A=R==="left"?w.x0:R==="right"?w.x1:R==="above"?w.y1:w.y0,P=R==="left"?A-h.depth:R==="right"||R==="above"?A+h.depth:A-h.depth,B=R==="left"||R==="right",k=M.get("vertices");for(const W of M.getIn(["areas",v.id,"vertices"]).toArray()){const Y=Number(k.getIn([W,"x"])),$=Number(k.getIn([W,"y"]));(B?Math.abs(Y-A)<=1:Math.abs($-A)<=1)||t.moveVertex(W,B?P:Y,B?$:P)}n=!0}t.setAreaProperties(v.id,T);continue}if(h.type==="delete"){const E=useReactPlannerStore.getState().planner,b=E.getIn(["scene","selectedLayer"]),v=b?findRoomByName(E,b,h.room,{surfaces:!0}):void 0;if(!(v!=null&&v.rect)){e.push(`deleting "${h.room}" (nothing by that name)`);continue}const M=E.getIn(["scene","layers",b]),T=P=>Number(P.get("x"))>=v.rect.x0&&Number(P.get("x"))<=v.rect.x1&&Number(P.get("y"))>=v.rect.y0&&Number(P.get("y"))<=v.rect.y1;if(h.item){const P=[];if(M.get("items").forEach(B=>{T(B)&&B.get("type")===h.item&&P.push(B)}),P.length===0){e.push(`${h.item} (none in "${h.room}")`);continue}if(P.length>1){e.push(`${h.item} ("${h.room}" has ${P.length} — ask which one)`);continue}t.removeItem(P[0].get("id"));continue}const I=new Set(M.getIn(["areas",v.id,"vertices"]).toArray()),w=new Set;M.get("areas").forEach(P=>{if(P.get("id")===v.id)return;const B=new Set(P.get("vertices").toArray());M.get("lines").forEach(k=>{const[W,Y]=k.get("vertices").toArray();I.has(W)&&I.has(Y)&&B.has(W)&&B.has(Y)&&w.add(k.get("id"))})});const R=[];M.get("lines").forEach(P=>{const[B,k]=P.get("vertices").toArray();I.has(B)&&I.has(k)&&!w.has(P.get("id"))&&R.push(P.get("id"))});const A=[];M.get("items").forEach(P=>{T(P)&&A.push(P.get("id"))});for(const P of A)t.removeItem(P);for(const P of R)t.removeLine(P);n=!0;continue}if(h.type==="add-surface"){const E=useReactPlannerStore.getState().planner,b=E.getIn(["scene","selectedLayer"]),v=b?findRoomByName(E,b,h.of):void 0;if(!(v!=null&&v.rect)){e.push(`surface (no room called "${h.of}")`);continue}const M=v.rect,T=neighbourRoom(E,b,v.id,h.side);if(T){e.push(`surface ("${h.of}"'s ${h.side} side faces ${T}, not outside)`);continue}const I=surfacePoints(M,h.side,Number(h.depth)||300);t.addSurfaceByPoints(I,"surface");const w=findAreaContainingPoint(useReactPlannerStore.getState().planner,b,(I[0].x+I[2].x)/2,(I[0].y+I[2].y)/2);if(!w){e.push("naming the surface (it did not close into an area)");continue}t.setAreaProperties(w,areaProps({name:h.name,texture:h.texture,color:h.color})),n=!0;continue}if(h.type==="add-hole"){const E=useReactPlannerStore.getState().planner,b=E.getIn(["scene","selectedLayer"]);let v;if(h.between){const[M,T]=h.between,I=b?(a=findRoomByName(E,b,M))==null?void 0:a.id:void 0,w=b?(l=findRoomByName(E,b,T))==null?void 0:l.id:void 0;if(!I||!w){e.push(`${h.holeType} (no room called "${I?T:M}")`);continue}if(v=sharedWall(E,b,I,w),!v){e.push(`${h.holeType} ("${M}" and "${T}" do not share a wall)`);continue}}else{const M=b?(c=findRoomByName(E,b,h.room))==null?void 0:c.id:void 0;if(!M){e.push(`${h.holeType} (no room called "${h.room}")`);continue}if(v=widestWall(E,b,M,h.side),!v){e.push(`${h.holeType} ("${h.room}" has no ${h.side} wall)`);continue}}if(!t.addHoleOnLine(v,h.holeType,.5)){e.push(`${h.holeType} (the wall would not take it)`);continue}respaceHoles(t,useReactPlannerStore.getState().planner,b,v);continue}if(h.type==="set-room-properties"){const E=useReactPlannerStore.getState().planner,b=E.getIn(["scene","selectedLayer"]),v=b?(u=findRoomByName(E,b,h.room))==null?void 0:u.id:void 0;if(!v){e.push(`changing "${h.room}" (no room by that name)`);continue}t.setAreaProperties(v,areaProps(h));continue}if(h.type!=="add-room"){e.push(`${h.type} (not supported yet)`);continue}const d=typeof h.name=="string"?h.name.trim():"";if(!d){e.push("a room with no name");continue}const p=Number(h.width),f=Number(h.height);if(!(p>0)||!(f>0)){e.push(`"${d}" (bad size)`);continue}const g=useReactPlannerStore.getState().planner,_=g.getIn(["scene","selectedLayer"]);if(!_){e.push(`"${d}" (no active layer)`);continue}let x;if(typeof h.of=="string"&&typeof h.side=="string"){const E=findRoomByName(g,_,h.of);if(!(E!=null&&E.rect)){e.push(`"${d}" (no room called "${h.of}" to place it against)`);continue}x=placeAgainst(E.rect,h.side,p,f)}else{const E=g.get("scene"),b=(E.get("width")??0)/2,v=(E.get("height")??0)/2;x={x0:Math.round(b-p/2),x1:Math.round(b-p/2)+p,y0:Math.round(v-f/2),y1:Math.round(v-f/2)+f}}t.addRoom(x.x0,x.y0,x.x1,x.y1),n=!0;const y=findAreaContainingPoint(useReactPlannerStore.getState().planner,_,(x.x0+x.x1)/2,(x.y0+x.y1)/2);if(!y){e.push(`naming "${d}" (the walls did not close into a room)`);continue}t.setAreaProperties(y,areaProps({...h,name:d}))}return n&&setTimeout(()=>{var d;const h=useReactPlannerStore.getState();h.planner.mode===MODE_3D_VIEW?(d=h.viewer3D)==null||d.fitToScene():h.fitViewerToScene()},50),e.length>0&&console.warn(`[plannerActions] skipped: ${e.join(", ")}`),{skipped:e}}const MAX_DIMENSION=1568,JPEG_QUALITY=.85;async function fileToChatImage(i){const e=await createImageBitmap(i);try{const t=Math.min(1,MAX_DIMENSION/Math.max(e.width,e.height)),n=Math.max(1,Math.round(e.width*t)),s=Math.max(1,Math.round(e.height*t)),o=document.createElement("canvas");o.width=n,o.height=s;const a=o.getContext("2d");if(!a)throw new Error("Canvas 2D context unavailable");a.drawImage(e,0,0,n,s);const l="image/jpeg",c=o.toDataURL(l,JPEG_QUALITY),u=c.split(",")[1]??"";return{mediaType:l,data:u,previewUrl:c}}finally{e.close()}}const FRAMES=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],ThinkingIndicator=({label:i="Thinking"})=>{const[e,t]=React.useState(0);return React.useEffect(()=>{const n=window.setInterval(()=>{t(s=>(s+1)%FRAMES.length)},90);return()=>window.clearInterval(n)},[]),jsxRuntimeExports.jsxs("span",{className:"fp-thinking",role:"status","aria-live":"polite",children:[jsxRuntimeExports.jsx("span",{className:"fp-thinking__glyph",children:FRAMES[e]}),jsxRuntimeExports.jsxs("span",{className:"fp-thinking__label",children:[i,"…"]})]})},titleize=i=>i?i.charAt(0).toUpperCase()+i.slice(1):"",SelectionChips=()=>{const{planner:i}=useReactPlannerStore(),e=React.useMemo(()=>{var u,h,d,p,f;const t=i.get("scene"),n=t.get("selectedLayer");if(!n)return[];const s=t.getIn(["layers",n]);if(!s)return[];const o=s.get("selected");if(!o)return[];const a=t.get("unit")??"",l=[],c=new Set;return(u=o.get("areas"))==null||u.forEach(g=>{var x;const _=s.getIn(["areas",g]);_&&((x=_.get("vertices"))==null||x.forEach(y=>{var b;const E=s.getIn(["vertices",y]);(b=E==null?void 0:E.get("lines"))==null||b.forEach(v=>{const M=s.getIn(["lines",v]);(M==null?void 0:M.get("type"))==="surface"&&c.add(v)})}))}),(h=o.get("lines"))==null||h.forEach(g=>{if(c.has(g))return;const _=s.getIn(["lines",g]);if(!_)return;const[x,y]=_.get("vertices").toArray(),E=s.getIn(["vertices",x]),b=s.getIn(["vertices",y]);let v=0;E&&b&&(v=Math.hypot(b.get("x")-E.get("x"),b.get("y")-E.get("y")));const M=_.get("type")??"wall";l.push({key:`wall:${g}`,kind:"wall",label:`${titleize(M)} (${Math.round(v)} ${a})`})}),(d=o.get("holes"))==null||d.forEach(g=>{const _=s.getIn(["holes",g]);if(!_)return;const x=_.get("type")??"hole";l.push({key:`hole:${g}`,kind:"hole",label:titleize(x)})}),(p=o.get("items"))==null||p.forEach(g=>{const _=s.getIn(["items",g]);if(!_)return;const x=_.get("type")??_.get("name")??"item";l.push({key:`item:${g}`,kind:"item",label:titleize(x)})}),(f=o.get("areas"))==null||f.forEach(g=>{const _=s.getIn(["areas",g]);_&&l.push({key:`area:${g}`,kind:"area",label:deriveAreaLabel(_,s)})}),l},[i]);return e.length===0?null:jsxRuntimeExports.jsxs("div",{className:"fp-ai-selection",children:[jsxRuntimeExports.jsx("span",{className:"fp-ai-selection__label",children:"Referring to"}),jsxRuntimeExports.jsx("div",{className:"fp-ai-selection__chips",children:e.map(t=>jsxRuntimeExports.jsx("span",{className:`fp-ai-selection__chip fp-ai-selection__chip--${t.kind}`,children:t.label},t.key))})]})},useTypewriter=()=>{const[i,e]=React.useState(""),t=React.useRef(""),n=React.useRef(null),s=React.useRef(""),o=React.useCallback(()=>{n.current!==null&&cancelAnimationFrame(n.current),n.current=null},[]),a=React.useCallback(()=>{n.current=null;const h=t.current;if(!h)return;const d=Math.max(2,Math.ceil(h.length/8));t.current=h.slice(d),e(p=>p+h.slice(0,d)),t.current&&(n.current=requestAnimationFrame(a))},[]),l=React.useCallback(h=>{t.current+=h,s.current+=h,n.current===null&&(n.current=requestAnimationFrame(a))},[a]),c=React.useCallback(()=>{o(),t.current="",s.current="",e("")},[o]),u=React.useCallback(()=>s.current,[]);return React.useEffect(()=>o,[o]),{text:i,push:l,reset:c,getFullText:u}},SUGGESTIONS=[{label:"Create a room",prompt:"Create a new room in the middle"},{label:"Add a door",prompt:"Add a door to the room"},{label:"Try a sample layout",prompt:"Generate a sample layout"}],renderInline=i=>{const e=[],t=/\*\*([^*]+)\*\*/g;let n=0,s,o=0;for(;(s=t.exec(i))!==null;)s.index>n&&e.push(i.slice(n,s.index)),e.push(jsxRuntimeExports.jsx("strong",{children:s[1]},o++)),n=t.lastIndex;return n<i.length&&e.push(i.slice(n)),e},AssistantMarkdown=({content:i})=>{const e=[],t=i.split(`
3939
3939
  `);let n=[],s=[],o=0;const a=()=>{s.length&&(e.push(jsxRuntimeExports.jsx("p",{className:"leading-relaxed",children:renderInline(s.join(" "))},o++)),s=[])},l=()=>{n.length&&(e.push(jsxRuntimeExports.jsx("ul",{className:"list-disc pl-5 space-y-1",children:n.map((c,u)=>jsxRuntimeExports.jsx("li",{children:renderInline(c)},u))},o++)),n=[])};for(const c of t){const u=c.trimEnd(),h=/^\s*(?:[-*•])\s+(.*)$/.exec(u);h?(a(),n.push(h[1])):u.trim()===""?(a(),l()):(l(),s.push(u))}return a(),l(),jsxRuntimeExports.jsx("div",{className:"space-y-3 text-sm text-white/90",children:e})},getSpeechRecognitionCtor=()=>{if(typeof window>"u")return null;const i=window;return i.SpeechRecognition||i.webkitSpeechRecognition||null},MAX_AGENT_STEPS=8,appendToLastReply=(i,e)=>{const t=i[i.length-1];return(t==null?void 0:t.role)!=="assistant"?[...i,{role:"assistant",content:e}]:[...i.slice(0,-1),{...t,content:`${t.content}