@vertexvis/viewer-toolkit-react 0.0.5-canary.7 → 0.0.5-canary.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.cjs.js +1 -1
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.esm.js +1 -1
- package/dist/bundle.esm.js.map +1 -1
- package/package.json +8 -8
package/dist/bundle.cjs.js
CHANGED
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
Copyright (c) 2018 Jed Watson.
|
|
16
16
|
Licensed under the MIT License (MIT), see
|
|
17
17
|
http://jedwatson.github.io/classnames
|
|
18
|
-
*/Ve=we,function(){var e={}.hasOwnProperty;function classNames(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=appendClass(e,parseValue(n)))}return e}function parseValue(t){if("string"==typeof t||"number"==typeof t)return t;if("object"!=typeof t)return"";if(Array.isArray(t))return classNames.apply(null,t);if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes("[native code]"))return t.toString();var n="";for(var a in t)e.call(t,a)&&t[a]&&(n=appendClass(n,a));return n}function appendClass(e,t){return t?e?e+" "+t:e+t:e}Ve.exports?(classNames.default=classNames,Ve.exports=classNames):window.classNames=classNames}();var Ce=we.exports;const VertexSlider=t=>{var{value:n,defaultValue:s,leftLabel:i,rightLabel:l,onChange:r,onValueChange:c,onValueInput:u}=t,d=__rest(t,["value","defaultValue","leftLabel","rightLabel","onChange","onValueChange","onValueInput"]);const[m,p]=a.useState(s);return e.jsxs("div",{className:"flex w-full items-center gap-2",children:[i&&e.jsx("div",{className:"pl-0.5 text-xs text-center",children:i}),e.jsx(o.VertexSlider,Object.assign({className:Ce("w-full",{"mt-0.5":null!=i||null!=l}),value:null!=n?n:m,onValueChange:e=>{p(e.detail.value),null==r||r(e.detail.value),null==c||c(e)},onValueInput:e=>{p(e.detail.value),null==r||r(e.detail.value),null==u||u(e)}},d)),l&&e.jsx("div",{className:"text-xs pr-2 flex-shrink-0 text-right",children:l})]})},VertexCrossSectionAppearanceLineThicknessSlider=({onUpdate:t})=>{const a=useCrossSectioningActions(),[s,o]=n.useRecoilState(ee);return e.jsx(VertexSlider,{id:"cross-section-line-thickness","data-testid":"cross-section-line-thickness-slider",leftLabel:"Off",rightLabel:"Thick",min:0,max:3,step:.5,value:s,valueLabelDisplay:"auto",onValueInput:async e=>{o(e.detail.value),await a.reapply()},onValueChange:e=>{null==t||t(e.detail.value)}})};function VertexCrossSectionAppearanceControls({onUpdateCrossSectionColor:t,onUpdateCrossSectionLineThickness:n}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsx(VertexCrossSectionAppearanceColorPicker,{onUpdate:t}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Line Thickness"}),e.jsx(VertexCrossSectionAppearanceLineThicknessSlider,{onUpdate:n})]})}function PanelSection({header:t,children:n}){return e.jsxs("div",{className:"py-3 px-4 border-neutral-300 border-b",children:[e.jsx("div",{className:"my-2 text-base text-neutral-700",children:t}),n]})}const VertexCrossSectionAppearanceReset=({onReset:t})=>{const a=useCrossSectioningActions(),[s,i]=n.useRecoilState(Q),[l,r]=n.useRecoilState(ee),c=s!==Y||1!==l;return e.jsx("div",{className:"ml-auto",children:e.jsx(o.VertexTooltip,{content:"Reset Cross Sectioning Appearance",children:e.jsx(o.VertexIconButton,{"data-testid":"cross-section-appearance-reset",iconName:"reset",iconSize:"sm",onClick:async()=>{i(Y),r(1),null==t||t(),await a.reapply()},disabled:!c})})})};function VertexCrossSectionAppearancePanelSection({onResetCrossSectionAppearance:t,onUpdateCrossSectionColor:n,onUpdateCrossSectionLineThickness:a}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Cross Sectioning",e.jsx(VertexCrossSectionAppearanceReset,{onReset:t})]}),children:e.jsx(VertexCrossSectionAppearanceControls,{onUpdateCrossSectionColor:n,onUpdateCrossSectionLineThickness:a})})}const je=.5,Te="#444444",ke=n.atom({key:"featureEdgesSelectedColor",default:Te}),Ae=n.atom({key:"featureEdgesLineThickness",default:je}),VertexFeatureEdgesColorPicker=({onUpdate:t})=>{const[a,s]=n.useRecoilState(ke);return e.jsx(VertexColorPicker,{"data-testid":"feature-edges-color-picker",value:a,onValueChanged:e=>{null==t||t(e.detail)},onInput:e=>s(e)})},VertexFeatureEdgesThicknessSlider=({onUpdate:t})=>{const[a,s]=n.useRecoilState(Ae);return e.jsx(VertexSlider,{id:"feature-edges-thickness","data-testid":"feature-edges-thickness-slider",leftLabel:"Off",rightLabel:"Thick",min:0,max:3,step:.5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{s(e.detail.value)},onValueChange:e=>{null==t||t(e.detail.value)}})};function VertexFeatureEdgesControls({onUpdateFeatureEdgesColor:t,onUpdateFeatureEdgesThickness:n}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsx(VertexFeatureEdgesColorPicker,{onUpdate:t}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Line Thickness"}),e.jsx(VertexFeatureEdgesThicknessSlider,{onUpdate:n})]})}const VertexFeatureEdgesReset=({onReset:t})=>{const[a,s]=n.useRecoilState(ke),[i,l]=n.useRecoilState(Ae),r=i!==je||a!==Te;return e.jsx("div",{className:"ml-auto",children:e.jsx(o.VertexTooltip,{content:"Reset Feature Edges",children:e.jsx(o.VertexIconButton,{"data-testid":"feature-edges-reset",iconName:"reset",iconSize:"sm",onClick:()=>{s(Te),l(je),null==t||t()},disabled:!r})})})};function VertexFeatureEdgesPanelSection({onResetFeatureEdges:t,onUpdateFeatureEdgesColor:n,onUpdateFeatureEdgesThickness:a}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Feature Edges",e.jsx(VertexFeatureEdgesReset,{onReset:t})]}),children:e.jsx(VertexFeatureEdgesControls,{onUpdateFeatureEdgesColor:n,onUpdateFeatureEdgesThickness:a})})}function contextMenuItemIsRow(e){var t;return null!=e&&null!=(null===(t=null==e?void 0:e.node)||void 0===t?void 0:t.id)}const Pe=n.atom({key:"contextMenuActive",default:void 0}),Ee=n.atom({key:"contextMenuPosition",default:void 0}),Ie=n.atom({key:"contextMenuTarget",default:void 0}),Re=n.atom({key:"contextMenuItem",default:void 0}),Ne=n.atom({key:"contextMenuActions",default:[]}),Oe=n.selector({key:"contextMenuActivePosition",get:({get:e})=>null!=e(Pe)?e(Ee):void 0});function useContextMenuActions(){return{pointerDown:useActionCallback((({set:e})=>async t=>{if(2===t.button){const n=t.clientX,a=null==t?void 0:t.clientY;e(Ee,s.Point.create(n,a)),e(Ie,t.target)}})),pointerUp:useActionCallback((({snapshot:e,set:t})=>async(n,a,o,i)=>{const l=await e.getPromise(Ee),r=await e.getPromise(Pe);if(null!=l&&null==r){const e=n.clientX,r=null==n?void 0:n.clientY,c=s.Point.create(e,r),u=null!=l?s.Point.distance(l,c):0,d=null==o||o(n);u<2&&d&&(null==i||i(n,null!=l?l:c),t(Pe,a))}})),contextMenu:useActionCallback((()=>(e,t)=>{(null==t||t(e))&&e.preventDefault()})),longPress:useActionCallback((({set:e})=>(t,n,a,o)=>{if(null==a||a(t)){const a=s.Point.create(t.touches[0].clientX,t.touches[0].clientY);e(Ee,a),e(Ie,t.target),e(Pe,n),null==o||o(t,a)}})),clearActiveContextMenu:useActionCallback((({reset:e,set:t})=>n=>{t(ye,!!n),e(Pe),e(Ne),e(Ee)})),clearDismissedState:useActionCallback((({reset:e})=>()=>e(ye)))}}function targetWithinMenu(e){return e.target instanceof Element&&isChildOf("vertex-menu",e.target)}function targetShouldSkipNextHit(e){return e.target instanceof Element&&isChildOf("vertex-viewer",e.target)}function isChildOf(e,t){return null!=t.closest(e)}const Me=n.atom({key:"boxSelectionEnabled",default:!1}),Le=n.atom({key:"boxSelectionOperationType",default:"clearAndSelect"}),useBoxSelectionActions=()=>({enable:useActionCallback((({set:e})=>()=>{e(Me,!0)})),disable:useActionCallback((({reset:e})=>async()=>{e(Me),e(Le)})),setOperationType:useActionCallback((({set:e})=>t=>{e(Le,t)}))});async function whenComponentReady(e,t,n=customElements,a=requestAnimationFrame,s=setTimeout){return null!=e&&null!=e.nodeName&&await n.whenDefined(e.nodeName.toLowerCase()),"function"==typeof(null==e?void 0:e.componentOnReady)?(await(null==e?void 0:e.componentOnReady()),t()):(await new Promise((e=>"function"==typeof a?a(e):s(e))),t())}const Be=n.atom({key:"isEditingPointToPointMeasurement",default:!1}),_e=n.atom({key:"pointToPointMeasurementOutcome",default:void 0}),De=n.atom({key:"editedPointToPointMeasurement",default:void 0});function usePointToPointMeasurement(e){const t=n.useSetRecoilState(_e);a.useEffect((()=>{let n;return whenComponentReady(e,(()=>{n=null==e?void 0:e.measurementModel.onOutcomeChanged(t)})),()=>null==n?void 0:n.dispose()}),[e,t])}const ze=2,Fe=n.atom({key:"isEditingPreciseMeasurement",default:!1}),He=n.atom({key:"preciseMeasurementOutcome",default:void 0}),Ue=n.atom({key:"preciseMeasurementController",dangerouslyAllowMutability:!0,default:void 0}),We=n.atom({key:"preciseMeasurementOverlays",dangerouslyAllowMutability:!0,default:void 0}),Ge=n.atom({key:"preciseMeasurementEntities",dangerouslyAllowMutability:!0,default:[]}),Ke=n.selector({key:"preciseMeasurementMessage",get:({get:e})=>{const t=undefined;return 0===e(Ge).length?"Select a surface":void 0}});function usePreciseMeasurementModel(e,t,s){const o=n.useSetRecoilState(Ge),i=n.useSetRecoilState(He),l=n.useSetRecoilState(Ue),r=n.useSetRecoilState(We),c=n.useRecoilValue(Ue);a.useEffect((()=>{let n;return whenComponentReady(e,(()=>{n=null==e?void 0:e.measurementModel.onEntitiesChanged((e=>{o(e),null==t||t(e)}))})),()=>null==n?void 0:n.dispose()}),[e,o]),a.useEffect((()=>{let t;return whenComponentReady(e,(()=>{t=null==e?void 0:e.measurementModel.onOutcomeChanged((e=>{i(e),null==s||s(e)}))})),()=>null==t?void 0:t.dispose()}),[e,i]),a.useEffect((()=>{let t;return whenComponentReady(e,(()=>{t=null==e?void 0:e.measurementModel.onEntitiesChanged((e=>{if(e.length>2){const t=e[2];null==c||c.setEntities(new Set([t]))}}))})),()=>null==t?void 0:t.dispose()}),[e,c]),a.useEffect((()=>{whenComponentReady(e,(()=>{l(null==e?void 0:e.measurementController)}))}),[e,l]),a.useEffect((()=>{whenComponentReady(e,(()=>{r(null==e?void 0:e.measurementOverlays)}))}),[e,r])}function useMeasurementActions(){const e=useBoxSelectionActions(),t=useEnablePointToPointMeasurement(),n=useDisablePointToPointMeasurement(),a=useDisablePreciseMeasurement(),s=useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(Ue);null==t||t.clearEntities()})),o=useActionCallback((()=>async(e={})=>{await s(),n(e),a()})),i=useActionCallback((({set:e,reset:n})=>async a=>{await o(),"point-to-point"===a?t():(n(He),n(Ge),e(Fe,!0))}));return{disableEditMeasurement:useActionCallback((()=>async e=>{await o(e)})),enableEditMeasurement:useActionCallback((()=>async e=>{await i(e)})),resetMeasurement:useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=await e.getPromise(Fe),a=await e.getPromise(Be);n?await s():a&&(t(_e),t(De))})),clearEditedPointToPointMeasurement:useActionCallback((({reset:e})=>()=>{e(De)})),setEditedPointToPointMeasurement:useActionCallback((({set:e})=>t=>{e(De,t)})),toggleEditPointToPointMeasurement:useActionCallback((({snapshot:t})=>async()=>{const n=undefined;await t.getPromise(Be)?await o():await i("point-to-point"),e.disable()})),toggleEditPreciseMeasurement:useActionCallback((({snapshot:t})=>async()=>{const n=undefined;await t.getPromise(Fe)?await o():await i("precise"),e.disable()}))}}function useEnablePointToPointMeasurement(){return useActionCallback((({reset:e,set:t})=>(n={})=>{t(Be,!0),n.keepExistingMeasurement||e(_e)}))}function useDisablePointToPointMeasurement(){return useActionCallback((({reset:e})=>(t={})=>{e(Be),t.keepExistingMeasurement||(e(De),e(_e))}))}function useDisablePreciseMeasurement(){return useActionCallback((({reset:e})=>async()=>{e(Fe),e(He),e(Ge)}))}const $e=n.selector({key:"isEditingMeasurement",get:({get:e})=>e(Be)||e(Fe)}),qe=n.selector({key:"measurementPanelModel",get:({get:e})=>e(_e)||e(He)}),Ye=n.selector({key:"measurementPanelOverlays",dangerouslyAllowMutability:!0,get:({get:e})=>e(We)}),Xe=n.selector({key:"measurementPanelMessage",get:({get:e})=>{const t=undefined;return e(Fe)?e(Ke):void 0}}),Ze=n.selector({key:"measurementPanelIsResettable",get:({get:e})=>e($e)&&null!=e(qe)}),Je=3e3,Qe=n.atom({key:"applicationMessageToast",default:void 0}),et=n.atom({key:"applicationMessageBanner",default:void 0}),useApplicationMessageActions=()=>({setBannerMessage:useActionCallback((({set:e})=>t=>{e(et,null!=t?Object.assign(Object.assign({},t),{id:O.create()}):void 0)})),setToastMessage:useActionCallback((({set:e})=>t=>{e(Qe,null!=t?Object.assign(Object.assign({},t),{id:O.create()}):void 0)}))});var tt;!function(e){e.HIDE_ITEM="Hide Item",e.SHOW_ONLY_SELECTED="Show Only Selected",e.HIDE_SELECTED="Hide Selected",e.SHOW_ONLY_ITEM="Show Only Item",e.SHOW_ALL="Show All",e.HIDE_ALL="Hide All",e.SELECT_FILTERED_ITEMS="Select Filtered Items",e.INVERT_SELECTION="Invert Selection",e.CLEAR_ALL_TRANSFORMS="Clear All Transforms",e.CLEAR_SELECTED_TRANSFORMS="Clear Selected Transforms",e.CLEAR_SELECTION="Clear Selection",e.DESELECTING_ITEMS="Deselecting Items",e.SELECTING_ITEMS="Selecting Items",e.SELECTING_ONLY_ITEM="Selecting Only Item",e.SELECTING_ANCESTOR="Selecting Ancestor",e.APPLY_MATERIAL_OVERRIDE_TO_ALL="Apply Material Override To All",e.APPLY_MATERIAL_OVERRIDE_TO_SELECTION="Apply Material Override To Selection",e.CLEAR_ALL_MATERIAL_OVERRIDES="Clear All Material Overrides",e.CLEAR_SELECTED_MATERIAL_OVERRIDES="Clear Selected Material Overrides",e.SET_PHANTOM_ALL="Set Phantom All",e.SET_PHANTOM_SELECTED_ITEMS="Set Phantom Selected Items",e.CLEAR_PHANTOM_ALL="Clear Phantom All",e.CLEAR_PHANTOM_SELECTED_ITEMS="Clear Phantom Selected Items",e.SET_PHANTOM_NON_SELECTED_ITEMS="Set Phantom Non Selected Items",e.RESTORE_PHANTOM_OVERRIDES="Restore Phantom Overrides",e.SET_ITEM_AS_END_ITEM="Set Item as End Item",e.UNSET_ITEM_AS_END_ITEM="Unset Item as End Item",e.SHOW_ANNOTATION="Show Annotation",e.HIDE_ANNOTATION="Hide Annotation"}(tt||(tt={}));const nt=n.atom({key:"fetchedItemInvalidator",default:0}),at=n.selectorFamily({key:"fetchedItems",get:e=>async({get:t})=>{var n;const a=t(M),s=t(F);if(t(nt),t(Lt),null!=s)try{return await(null===(n=null==a?void 0:a.sceneItems)||void 0===n?void 0:n.getSceneViewItem(e,s,{includeOverride:!0,includeWorldTransform:!0}))}catch(t){return void logger_debug(`Error encountered get scene view item. [itemId={${e}}]`,t)}}}),st=n.atomFamily({key:"selectionSelectedItems",default:void 0}),ot=n.atom({key:"selectionSelectedItemIds",default:[]}),it=n.atom({key:"selectionLastSelected",default:void 0}),lt=n.atom({key:"selectionLastSelectionFromViewer",default:!1}),rt=n.atom({key:"selectionLastSelectWasMultiSelect",default:!1}),ct=n.selector({key:"selectionHasMultipleSelected",get:({get:e})=>{const t=e(it),n=undefined;return e(ot).filter((e=>{var n;return e!==(null==t?void 0:t.id)&&!(null===(n=null==t?void 0:t.ancestors)||void 0===n?void 0:n.includes(e))})).length>0}}),ut=n.atom({key:"selectionFirstSelectedItemInTreeId",default:void 0}),dt=n.selector({key:"selectionHighestSelectedAncestor",get:({get:e})=>{var t,n;const a=e(it),s=e(ot);return null!==(n=null===(t=null==a?void 0:a.ancestors)||void 0===t?void 0:t.find((e=>s.includes(e))))&&void 0!==n?n:null==a?void 0:a.id}}),mt=n.atom({key:"selectionPreviousVisibleSummary",default:void 0}),pt=n.atom({key:"selectionVisibleSummary",default:void 0}),xt=n.selector({key:"selectionVisibleCount",get:({get:e})=>{var t,n;return null!==(n=null===(t=e(pt))||void 0===t?void 0:t.count)&&void 0!==n?n:0}}),ht=n.selector({key:"selectionBoundingBoxCenter",get:({get:e})=>{const t=e(pt);return null!=(null==t?void 0:t.boundingBox)?s.BoundingBox.center(t.boundingBox):s.Vector3.origin()}}),ft=n.selector({key:"selectionIsActive",get:({get:e})=>{const t=e(ot),n=undefined;return e(xt)>0||t.length>0}}),gt=n.selector({key:"fetchedAndSelectedItems",get:async({get:e})=>{const t=e(ot),n=undefined;return null!=e(F)?t.map((t=>e(at(t)))):[]}});function useSceneViewItemActions(){return{invalidateCachedItems:useActionCallback((({set:e})=>()=>{e(nt,(e=>e+1))}))}}const vt=n.atom({key:"lengthUnit",default:"cm"}),yt=n.atom({key:"decimalPlace",default:"2"});var bt,St;!function(e){e.mm="millimeters",e.cm="centimeters",e.m="meters",e.in="inches",e.ft="feet"}(bt||(bt={})),function(e){e[e.mm=1]="mm",e[e.cm=.1]="cm",e[e.m=.001]="m",e[e.in=.03937007874015748]="in",e[e.ft=.0032808398950131233]="ft"}(St||(St={}));const convertFrom=(e,t)=>{const n=undefined;return e/St[t]},convertTo=(e,t)=>{const n=undefined;return e*St[t]},formatWithUnit=(e,t,n)=>`${e.toFixed(n)} ${t}`,formatDistance=(e,t,n)=>formatWithUnit(convertTo(e,t),t,n),createDistanceFormatter=(e,t)=>n=>formatDistance(n,e,t);function toUnitType(e){switch(e){case"cm":return"centimeters";case"m":return"meters";case"in":return"inches";case"ft":return"feet";default:return"millimeters"}}function pickLocalOrWorldTransform(e,t){return"local"===t?e.local:e.world}function mapItemTransforms(e,t){return{local:t(e.local),world:t(e.world)}}function makeItemTransforms(e,t,n){return"local"===n?{local:e,world:i.toWorldTransform(e,t)}:{world:e,local:i.toLocalTransform(e,t)}}function convertTransformToUnits(e,t){const{position:n,rotation:a,scale:o}=e;return{position:s.Vector3.create(convertTo(n.x,t),convertTo(n.y,t),convertTo(n.z,t)),rotation:a,scale:o}}function convertTransformFromUnits(e,t){const{position:n,rotation:a,scale:o}=e;return{position:s.Vector3.create(convertFrom(n.x,t),convertFrom(n.y,t),convertFrom(n.z,t)),rotation:a,scale:o}}function toValidTransform(e){const{position:t,rotation:n,scale:a}=e;return{position:{x:t.x||0,y:t.y||0,z:t.z||0},rotation:{x:n.x||0,y:n.y||0,z:n.z||0},scale:a||1}}function scale(e){const t=parseFloat(Math.sqrt(e[0]**2+e[4]**2+e[8]**2).toFixed(2)),n=parseFloat(Math.sqrt(e[1]**2+e[5]**2+e[9]**2).toFixed(2)),a=parseFloat(Math.sqrt(e[2]**2+e[6]**2+e[10]**2).toFixed(2));return t===n&&n===a?t:NaN}function translation(e){return{x:e[12],y:e[13],z:e[14]}}function rotation(e){const t=e.map((t=>t*(1/scale(e))));return t[8]<1?t[8]>-1?{x:Math.atan2(-t[9],t[10])*(180/Math.PI),y:Math.asin(t[8])*(180/Math.PI),z:Math.atan2(-t[4],t[0])*(180/Math.PI)}:{x:-Math.atan2(-t[1],t[5])*(180/Math.PI),y:-90,z:0}:{x:Math.atan2(t[1],t[5])*(180/Math.PI),y:90,z:0}}function toTransformFromApiMatrix(e){return null!=e?{position:translation(e),rotation:rotation(e),scale:scale(e)}:void 0}const wt={position:s.Vector3.create(0,0,0),rotation:s.Vector3.create(0,0,0),scale:1},Vt=n.atom({key:"transformWidgetEnabled",default:!1}),Ct=n.atom({key:"transformWidgetPosition",default:void 0}),jt=n.atom({key:"transformWidgetOrientationOverride",default:void 0}),Tt=n.selector({key:"transformWidgetOrientation",get:({get:e})=>{const t=e(jt),n=e(it);if(null!=t)return t;if(null!=n){const t=e(Mt(n.id));return s.Euler.fromDegrees({x:null==t?void 0:t.world.rotation.x,y:null==t?void 0:t.world.rotation.y,z:null==t?void 0:t.world.rotation.z})}}}),kt=n.atom({key:"transformWidgetCachedOrientation",default:void 0}),At=n.atom({key:"transformWidgetSyncToSelection",default:!1}),Pt=n.atom({key:"transformWidgetIsInteracting",default:!1}),Et=n.atomFamily({key:"appliedItemTransform",default:void 0}),It=n.atom({key:"appliedItemTransformIds",default:[]}),Rt=n.atom({key:"selectedCoordinateSpace",default:"world"}),Nt=n.atomFamily({key:"editedItemTransform",default:void 0}),Ot=n.selectorFamily({key:"displayedItemTransform",get:e=>({get:t})=>{if(null!=e){const n=t(Rt),a=t(vt),s=t(Mt(e)),o=t(Nt(e));if(null!=o)return o.transform;if(null!=s)return pickLocalOrWorldTransform(mapItemTransforms(s,(e=>convertTransformToUnits(e,a))),n)}},set:e=>({get:t,set:a},s)=>{if(null!=e){const o=t(Rt),i=t(Bt(e)),l=t(Mt(e)),r=t(vt);if(null!=l&&!(s instanceof n.DefaultValue)&&null!=s&&null!=i){a(Nt(e),{coordinateSpace:o,units:r,transform:s});const n=makeItemTransforms(convertTransformFromUnits(toValidTransform(s),r),i,o),l=t(It);a(Et(e),n),a(It,[...l,e])}}}}),Mt=n.selectorFamily({key:"fetchedItemTransforms",get:e=>({get:t})=>{var n,a;const s=t(at(e));if(null!=s){const e=(null===(n=s.override)||void 0===n?void 0:n.transform)?toTransformFromApiMatrix(null===(a=s.override)||void 0===a?void 0:a.transform):void 0,t=s.worldTransform?toTransformFromApiMatrix(s.worldTransform):void 0;return{local:null!=e?e:wt,world:null!=t?t:wt}}}}),Lt=n.atom({key:"transformInvalidator",default:0}),Bt=n.selectorFamily({key:"parentItemWorldMatrix",get:e=>({get:t})=>{const n=t(F);if(null!=e&&null!=n){const n=t(at(e));if(null!=(null==n?void 0:n.parentId)){const e=t(Mt(n.parentId)),a=t(Et(n.parentId));if(null==e)throw new Error("Invalid state. Parent item state should be populated, but is undefined.");return null!=a?i.toMatrix(i.toRadiansTransform(a.world)):i.toMatrix(i.toRadiansTransform(e.world))}}return logger_debug(`Unable to find the world matrix for the parent of ${e}. Returning the identity matrix.`),s.Matrix4.makeIdentity()}});function useUpdateEditedTransformWhenSettingsChange(e){const t=n.useRecoilValue(vt),s=n.useRecoilValue(Rt),o=n.useRecoilValue(Et(null!=e?e:"")),[i,l]=n.useRecoilState(Nt(null!=e?e:""));a.useEffect((()=>{if(null!=o&&((null==i?void 0:i.coordinateSpace)!==s||(null==i?void 0:i.units)!==t)){const e=undefined,n=convertTransformToUnits(pickLocalOrWorldTransform(o,s),t);l({units:t,coordinateSpace:s,transform:n})}}),[t,s])}function useEditItemTransform(e){const t=useTransformActions();useUpdateEditedTransformWhenSettingsChange(e);const a=n.useRecoilValueLoadable(Bt(e)),[s,o]=n.useRecoilStateLoadable(Ot(e));return{transform:"hasValue"===s.state?s.contents:void 0,loading:"loading"===s.state||"loading"===a.state,error:"hasError"===s.state?s.contents:void 0,async update(n){o(n),null!=e&&await t.applyTransformToItem(e)}}}const useTransformActions=()=>{const e=useApplicationMessageActions(),t=useViewerSceneActions(),n=useActionCallback((({set:e,snapshot:t})=>async()=>{const n=await t.getPromise(ht);e(Ct,n)})),a=useActionCallback((({set:e,snapshot:t})=>async()=>{const a=await t.getPromise(Ct),s=await t.getPromise(rt),o=await t.getPromise(ot),i=await t.getPromise(xt);null==a&&(o.length>0||s||i>0)&&await n(),e(At,!0)})),o=useActionCallback((({set:e})=>async t=>{e(Ct,null!=t?t:void 0)})),l=useActionCallback(retainSnapshot((({snapshot:e,set:t,reset:n})=>async()=>{const a=await e.getPromise(Tt),s=undefined;(await e.getPromise(It)).forEach((e=>{n(Et(e)),n(Nt(e))})),n(It),null!=a&&t(kt,a),t(Lt,(e=>e+1))}))),r=useActionCallback((({set:e,reset:t})=>n=>{t(kt),e(jt,n)})),c=useActionCallback((({set:e})=>()=>{e(Ct,void 0),e(Vt,!1)}));return{enableTransformWidget:useActionCallback((({set:t})=>async(s,i)=>{e.setToastMessage({message:"Transform manipulator enabled! Select parts to interact.",duration:Je}),t(Vt,!0),i?await n():null==s?await a():await o(s)})),disableTransformWidget:useActionCallback((({reset:e})=>()=>{e(Vt),e(jt)})),setTransformWidgetOrientation:r,clearTransformWidgetOrientation:useActionCallback((({reset:e})=>()=>{e(kt),e(jt)})),setTransformWidgetPosition:o,clearTransformWidgetPosition:useActionCallback((({reset:e})=>()=>e(Ct))),invalidateTransforms:l,setIsInteractivelyTransforming:useActionCallback((({set:e})=>t=>{e(Pt,t)})),setDefaultWidgetPosition:a,setDefaultWidgetPositionToSelection:n,enableSelectionSync:useActionCallback((({set:e})=>()=>e(At,!0))),disableSelectionSync:useActionCallback((({reset:e})=>()=>e(At))),syncToSelection:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(mt),n=await e.getPromise(pt),a=undefined;if(await e.getPromise(At)){const e=null==n?void 0:n.boundingBox,a=null!=e&&null!=(null==t?void 0:t.boundingBox)&&equals(e,t.boundingBox);null==e||a||await o(s.BoundingBox.center(e))}})),orientToHitResult:useActionCallback((({reset:e})=>async t=>{e(At),null!=t?await o(null==t?void 0:t.position):(e(Ct),r(void 0))})),clearSelectedTransforms:useActionCallback((()=>async()=>{await t.execute(tt.CLEAR_SELECTED_TRANSFORMS,(e=>e.where((e=>e.withSelected())).clearTransforms())),await l(),c()})),clearAllTransforms:useActionCallback((()=>async()=>{await t.execute(tt.CLEAR_SELECTED_TRANSFORMS,(e=>e.where((e=>e.all())).clearTransforms())),await l(),c()})),applyTransformToItem:useActionCallback((({snapshot:e})=>async t=>{const n=await e.getPromise(M),a=await(null==n?void 0:n.scene()),o=await e.getPromise(Et(t));if(null==o)return void logger_warn(`There is no transform to apply to item ${t}.`);const l=s.Matrix4.transpose(i.toMatrix(i.toRadiansTransform(null==o?void 0:o.local)));return null==a?void 0:a.items((e=>e.where((e=>e.withItemId(t))).transform(l))).execute()}))}},useHitActions=()=>{const e=useCrossSectioningActions(),t=useMeasurementActions(),n=useTransformActions(),a=useActionCallback(retainSnapshot((({snapshot:e})=>async()=>{const n=await e.tryGetPromise(ve).then((e=>e.value)),a=await e.getPromise(De);null==n&&null!=(null==a?void 0:a.start)&&null!=a.end&&await t.resetMeasurement()}))),s=useActionCallback(retainSnapshot((({snapshot:e})=>async()=>{const t=await e.tryGetPromise(ve).then((e=>e.value));await n.orientToHitResult(t)}))),o=useActionCallback(retainSnapshot((({set:e,snapshot:t})=>async()=>{const n=await t.tryGetPromise(ve).then((e=>e.value));e(Re,n)}))),i=useActionCallback(retainSnapshot((({snapshot:e,set:t})=>async()=>{t(ge,await e.tryGetPromise(ve).then((e=>e.value)))})));return{tap:useActionCallback(retainSnapshot((({snapshot:t,set:n})=>async({detail:l},...r)=>{const c=await t.getPromise($e),u=await t.getPromise(ne),d=2!==(null==l?void 0:l.buttons)&&!(null==l?void 0:l.altKey);l.altKey||l.ctrlKey||l.metaKey||l.shiftKey;const m=d&&!u.hitPending&&!c,p=await t.tryGetPromise(ve).then((e=>e.value));n(fe,p),n(xe,l),await a(),m&&(r.forEach((e=>e())),await s()),await o(),await e.sectionCurrentHit(),await i()}))),longPress:useActionCallback(retainSnapshot((({snapshot:e,set:t,reset:n})=>async a=>{n(xe),t(he,a.detail),await e.tryGetPromise(ve),await o(),await i()})))}},_t=n.selector({key:"viewerToolkitHitState",get:({get:e})=>{const t=undefined,n=undefined,a=undefined,s=undefined,o=undefined;return{tapDetails:e(xe),longPressDetails:e(he),previousHitResult:e(fe),currentHitResult:e(ge)}}});var Dt=Object.freeze({__proto__:null,currentHitResult:ge,hitResult:ve,hitResultsLongPressDetails:he,hitResultsSkipNextTap:ye,hitResultsTapDetails:xe,hitState:_t,previousHitResult:fe,useHitActions:useHitActions});function useSelectionActions(){const e=useSceneViewItemActions(),t=useTransformActions(),n=useViewerSceneActions(),a=useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=undefined;(await e.getPromise(ot)).forEach((e=>t(st(e))))})),s=useActionCallback((({snapshot:e,reset:t,set:a})=>async(s,o)=>{var i,l;const r=await e.getPromise(st(s.id)),c=await e.getPromise(ot),u=null===(l=[...null!==(i=s.ancestors)&&void 0!==i?i:[]])||void 0===l?void 0:l.reverse().find((e=>!c.includes(e)));null!=r&&null!=u?(a(st(u),{id:u}),a(ot,(e=>[...e,u])),n.execute(tt.SELECTING_ANCESTOR,n.selectItemsTransform(u))):(null==o?void 0:o.clear)?(a(st(s.id),s),a(ot,[s.id]),n.execute(tt.SELECTING_ONLY_ITEM,n.clearSelectionTransform,n.selectItemsTransform(s.id))):(a(st(s.id),s),a(ot,(e=>[...e,s.id])),n.execute(tt.SELECTING_ITEMS,n.selectItemsTransform(s.id))),d(s),a(it,s),a(lt,!0),t(rt)})),o=useActionCallback((({reset:e,set:t})=>async a=>{e(st(a)),e(rt),t(ot,(e=>e.filter((e=>e!==a)))),n.execute(tt.DESELECTING_ITEMS,n.deselectItemsTransform(a))})),i=useActionCallback((({snapshot:e})=>async t=>{const n=await e.getPromise(st(t.id));null!=n?await o(n.id):await s(t)})),l=useActionCallback((({snapshot:n,reset:a,set:o})=>async(i,l={})=>{const r=await n.getPromise(st(i.id)),c=await n.getPromise(ot);if(c.filter((e=>{var t;return e!==i.id&&!(null===(t=i.ancestors)||void 0===t?void 0:t.includes(e))})).forEach((e=>a(st(e)))),a(rt),r)if(l.ignoreAncestorSelection)a(ot),a(st(r.id));else{const e=c.filter((e=>{var t;return e===i.id||(null===(t=i.ancestors)||void 0===t?void 0:t.includes(e))}));o(ot,e)}else a(ot);e.invalidateCachedItems(),t.clearTransformWidgetOrientation(),await s(i,{clear:!0})})),r=useActionCallback((({reset:e})=>async()=>{await a(),e(ot),e(it),e(lt),e(rt),t.clearTransformWidgetPosition(),t.clearTransformWidgetOrientation()})),c=useActionCallback((()=>async()=>{await r(),n.execute(tt.CLEAR_SELECTION,n.clearSelectionTransform)})),u=useActionCallback((({set:e})=>async t=>{e(rt,t)})),d=useActionCallback((({reset:e,set:t})=>e=>{}));return{select:s,toggleSelection:i,clearAndSelect:l,selectCurrentHit:useActionCallback(retainSnapshot((({snapshot:e})=>async()=>{const t=await e.tryGetPromise(ve).then((e=>e.value)),n=await e.getPromise(xe),a=(null==n?void 0:n.metaKey)||(null==n?void 0:n.ctrlKey)||(null==n?void 0:n.shiftKey);null==t||a?null!=t&&a?await i(t):await c():await l(t)}))),syncSelection:useActionCallback((({set:e,reset:t})=>async(n,s)=>{s.selected?(await a(),e(st(n.id),n),s.multiSelect?e(ot,(e=>[...e.filter((e=>e!==n.id)),n.id])):e(ot,[n.id]),d(n),e(it,n),e(lt,!1),e(rt,!!s.multiSelect)):(t(st(n.id)),t(rt),e(ot,(e=>e.filter((e=>e!==n.id)))))})),deselect:o,clearSelection:c,resetSelectionState:r,toggleLastSelectWasMultiSelect:u,selectForModelViewsPanel:d}}const zt=n.selector({key:"viewerToolkitSelectionState",get:({get:e})=>{const t=undefined,n=undefined,a=undefined,s=undefined;return{selectedItemIds:e(ot),lastSelected:e(it),highestSelectedAncestorId:e(dt)}}});var Ft=Object.freeze({__proto__:null,fetchedAndSelectedItems:gt,selectionBoundingBoxCenter:ht,selectionFirstSelectedItemInTreeId:ut,selectionHasMultipleSelected:ct,selectionHighestSelectedAncestor:dt,selectionIsActive:ft,selectionLastSelectWasMultiSelect:rt,selectionLastSelected:it,selectionLastSelectionFromViewer:lt,selectionPreviousVisibleSummary:mt,selectionSelectedItemIds:ot,selectionSelectedItems:st,selectionState:zt,selectionVisibleCount:xt,selectionVisibleSummary:pt,useSelectionActions:useSelectionActions});const Ht=255,Ut=n.atom({key:"sceneItemAdjustmentsSelectedColor",default:void 0}),Wt=n.atom({key:"sceneItemAdjustmentsSelectedOpacity",default:void 0}),Gt=n.atomFamily({key:"appliedItemMaterialOverride",default:void 0}),Kt=n.atom({key:"appliedItemMaterialOverrideIds",default:[]}),$t=n.selector({key:"sceneItemAdjustmentsLastSelectedOverride",get:({get:e})=>{const t=e(it);if(null!=t)return e(Gt(t.id))}}),qt=n.atom({key:"applyMaterialToAllUserAction",default:void 0}),Yt=n.atom({key:"showConfirmDialogWhenApplyingMaterialToAll",default:!0}),Xt=n.atom({key:"confirmApplyMaterialToAllDialogOpen",default:!1}),useSceneItemMaterialActions=()=>{const e=useViewerSceneActions(),t=useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=await e.getPromise(Kt);t(Ut),n.forEach((e=>t(Gt(e)))),t(Kt)}));return{updateColor:useActionCallback((({set:e})=>t=>{e(Ut,t)})),clearCurrentColor:useActionCallback((({reset:e})=>()=>{e(Ut)})),clearCurrentOpacity:useActionCallback((({reset:e})=>()=>{e(Wt)})),clear:useActionCallback((({snapshot:t,set:n,reset:a})=>async()=>{const s=await t.getPromise(ot);a(Ut),s.forEach((e=>a(Gt(e)))),n(Kt,(e=>e.filter((e=>!s.includes(e))))),await e.execute(tt.CLEAR_SELECTED_MATERIAL_OVERRIDES,(e=>e.where((e=>e.withSelected())).clearMaterialOverrides().select()))})),clearAll:useActionCallback((()=>async()=>{await t(),await e.execute(tt.CLEAR_ALL_MATERIAL_OVERRIDES,(e=>e.where((e=>e.all())).clearMaterialOverrides()),(e=>e.where((e=>e.withSelected())).select()))})),clearState:t,updateOpacity:useActionCallback((({set:e})=>t=>{e(Wt,t)})),apply:useActionCallback((({snapshot:t,set:n})=>async()=>{const a=await t.getPromise(Ut),s=await t.getPromise(Wt),o=await t.getPromise(ot),i=await t.getPromise($t),l=null!=a?a:i,r=null!=s?s:null==i?void 0:i.opacity;if(null!=l){const t=Object.assign(Object.assign({},l),{opacity:null!=r?r:l.opacity});await e.execute(tt.APPLY_MATERIAL_OVERRIDE_TO_SELECTION,(e=>e.where((e=>e.withSelected())).materialOverride(t))),o.forEach((e=>n(Gt(e),t))),n(Kt,(e=>[...e,...o]))}})),confirmApplyAll:useActionCallback((({set:e})=>t=>{e(Xt,!0),e(qt,(()=>t))})),cancelApplyAll:useActionCallback((({reset:e})=>()=>{e(Xt),e(qt)})),applyAll:useActionCallback((({snapshot:t,reset:n})=>async()=>{const a=await t.getPromise(Ut),s=await t.getPromise(Wt);if(null!=a){const o=await t.getPromise(Kt),i=Object.assign(Object.assign({},a),{opacity:null!=s?s:a.opacity});await e.execute(tt.APPLY_MATERIAL_OVERRIDE_TO_ALL,(e=>e.where((e=>e.all())).materialOverride(i))),o.forEach((e=>n(Gt(e))));const l=await t.getPromise(qt);null==l||l(i),n(Xt),n(qt)}})),hideConfirmApplyAllDialog:useActionCallback((({set:e})=>()=>{e(Yt,!1)}))}},Zt="#FFFFFF",Jt=n.atom({key:"viewerBackgroundSelectedColor",default:Zt}),VertexSceneItemMaterialApplyAll=({onApplyAll:t})=>{const a=useSceneItemMaterialActions(),s=n.useRecoilValueLoadable($t),i=n.useRecoilValue(Ut),l=n.useRecoilValue(Yt),r=u.useMemo((()=>"hasValue"===s.state?null!=i?i:s.contents:i),[s,i]);return e.jsx(o.VertexTooltip,{content:"Apply to All",children:e.jsx(o.VertexIconButton,{iconName:"square-dot-outline",iconSize:"sm",color:"secondary",disabled:null==r,onClick:async()=>{l?a.confirmApplyAll(t):(await a.applyAll(),null==t||t(r))}})})};function SceneItemMaterialApplyAllConfirmationDialog(){const t=useSceneItemMaterialActions(),s=n.useRecoilValue(Xt),[i,l]=a.useState(!1),onCloseDialog=()=>{t.cancelApplyAll(),l(!1)};return s?e.jsxs(o.VertexDialog,{open:!0,className:"text-sm",onClosed:onCloseDialog,onBackdropClick:onCloseDialog,children:[e.jsx("div",{slot:"heading",children:"Apply to All Parts"}),e.jsx("div",{className:"max-w-lg break-words pr-2",children:"This will apply the same material to all parts in the model. Any previous material changes will be lost."}),e.jsxs("div",{className:"flex mt-8 gap-2 items-center",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(o.VertexToggle,{"data-testid":"hide-confirmation-dialog-in-future-checkbox",variant:"check",className:"pt-0.5",checked:i,onValueChanged:e=>{l(e.detail)}}),"Don't show again this session"]}),e.jsxs("div",{className:"flex ml-auto gap-2",children:[e.jsx(o.VertexButton,{"data-testid":"cancel-apply-material-to-all",onClick:onCloseDialog,children:"Cancel"}),e.jsx(o.VertexButton,{color:"primary","data-testid":"confirm-apply-material-to-all",onClick:async()=>{await t.applyAll(),i&&t.hideConfirmApplyAllDialog()},children:"Apply"})]})]})]}):e.jsx(e.Fragment,{})}function createColorMaterialWithId(e,t=O.create()){return Object.assign({id:t},i.ColorMaterial.fromHex(e))}const VertexSceneItemMaterialColorPicker=({onApply:t})=>{const a=useSceneItemMaterialActions(),s=n.useRecoilValueLoadable($t),o=n.useRecoilValue(Ut),i=u.useMemo((()=>"hasValue"===s.state?null!=o?o:s.contents:o),[s,o]);return e.jsx(VertexColorPicker,{"data-testid":"selected-item-color-picker",value:null!=i?T.toHexString(i.diffuse):void 0,onValueChanged:()=>{a.apply(),null==t||t(i)},onInput:async e=>{a.updateColor(createColorMaterialWithId(e)),await a.apply()}})},VertexSceneItemMaterialOpacitySlider=({onApply:t})=>{const a=useSceneItemMaterialActions(),s=n.useRecoilValue(Wt),i=n.useRecoilValueLoadable($t),l=u.useMemo((()=>{var e,t;return"hasValue"===i.state?null!==(t=null!=s?s:null===(e=i.contents)||void 0===e?void 0:e.opacity)&&void 0!==t?t:Ht:null!=s?s:Ht}),[s,i]),r=useDebouncedCallback((()=>{a.apply()}),500),c=u.useCallback((e=>{a.updateOpacity(e.detail.value),r(e.detail.value)}),[r,a]),d=u.useMemo((()=>"hasValue"!==i.state||null==i.contents),[i]);return e.jsx(o.VertexTooltip,{className:"flex w-full",content:d?"Select a part and apply a color to enable opacity":`${Math.floor(l/Ht*100)}%`,placement:"top",children:e.jsx(VertexSlider,{"data-testid":"scene-item-adjustments-opacity-slider",leftLabel:"0%",rightLabel:"100%",disabled:d,value:null!=l?l:Ht,step:5,min:0,max:Ht,onValueChange:e=>{a.updateOpacity(e.detail.value),a.apply(),null==t||t(e.detail.value)},onValueInput:c})})};function VertexMaterialControls({onApplyMaterial:t,onApplyMaterialToAll:s,onApplyOpacity:o}){const i=useSceneItemMaterialActions(),l=n.useRecoilValue(it);return a.useEffect((()=>{i.clearCurrentColor(),i.clearCurrentOpacity()}),[null==l?void 0:l.id]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(VertexSceneItemMaterialColorPicker,{onApply:t}),e.jsx(VertexSceneItemMaterialApplyAll,{onApplyAll:s})]})]}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Opacity"}),e.jsx(VertexSceneItemMaterialOpacitySlider,{onApply:o}),e.jsx(SceneItemMaterialApplyAllConfirmationDialog,{})]})}const ResetButton=({id:t,tooltip:n,children:s})=>{const[i,l]=a.useState(!1);return e.jsx("div",{className:"ml-auto",children:e.jsxs(o.VertexDropdownMenu,{className:"flex items-stretch h-full","data-testid":`reset-button-dropdown-menu-${t}`,placement:"bottom-end",onMenuOpened:()=>l(!0),onMenuClosed:()=>l(!1),children:[e.jsx("div",{slot:"anchor",className:"flex items-center h-full",children:e.jsx(o.VertexTooltip,{content:n,disabled:i,placement:"bottom",children:e.jsxs(o.VertexButton,{className:Ce("p-1.5 rounded-md select-none hover:bg-neutral-300 active:bg-neutral-400 cursor-pointer",{"bg-neutral-300":i}),"data-testid":`reset-button-${t}`,variant:"plaintext",children:[e.jsx(o.VertexIcon,{className:"px-0.5",name:"reset",size:"sm"}),e.jsx(o.VertexIcon,{name:"chevron-down",size:"sm"})]})})}),e.jsx("div",{className:"whitespace-nowrap",children:s})]})})},VertexSceneItemMaterialClear=({onClear:t,onClearAll:a})=>{const s=useSceneItemMaterialActions(),i=n.useRecoilValue(ft);return e.jsx("div",{className:"ml-auto",children:e.jsxs(ResetButton,{id:"materials",tooltip:"Clear Materials",children:[e.jsx("div",{className:"pt-1"}),e.jsx(o.VertexMenuItem,{"data-testid":"clear-selected-materials",onClick:()=>{s.clear(),null==t||t()},disabled:!i,children:"Clear selected materials"}),e.jsx(o.VertexMenuItem,{"data-testid":"clear-all-materials",onClick:()=>{s.clearAll(),null==a||a()},children:"Clear all materials"})]})})};function VertexMaterialPanelSection({onClearMaterial:t,onClearAllMaterials:n,onApplyMaterial:a,onApplyMaterialToAll:s,onApplyOpacity:o}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Material",e.jsx(VertexSceneItemMaterialClear,{onClear:t,onClearAll:n})]}),children:e.jsx(VertexMaterialControls,{onApplyMaterial:a,onApplyMaterialToAll:s,onApplyOpacity:o})})}const Qt="#ffff00",en=35,tn=1,nn=n.atom({key:"selectionHighlightingSelectedColor",default:Qt}),an=n.atom({key:"selectionHighlightingSelectedOpacity",default:en}),sn=n.atom({key:"selectionHighlightingSelectedLineThickness",default:1}),VertexSelectionHighlightingColorPicker=({onUpdate:t})=>{const[a,s]=n.useRecoilState(nn);return e.jsx(VertexColorPicker,{"data-testid":"selection-highlighting-color-picker",value:a,onValueChanged:e=>{null==t||t(e.detail)},onInput:e=>s(e)})},VertexSelectionHighlightingLineThicknessSlider=({onUpdate:t})=>{const[a,s]=n.useRecoilState(sn);return e.jsx(VertexSlider,{id:"selection-highlighting-line-thickness","data-testid":"selection-highlighting-line-thickness-slider",leftLabel:"Off",rightLabel:"Thick",min:0,max:3,step:.5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{s(e.detail.value)},onValueChange:e=>{null==t||t(e.detail.value)}})},VertexSelectionHighlightingOpacitySlider=({onUpdate:t})=>{const[a,s]=n.useRecoilState(an);return e.jsx(VertexSlider,{id:"selection-highlighting-opacity","data-testid":"selection-highlighting-opacity-slider",leftLabel:"0%",rightLabel:"100%",min:0,max:100,step:5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{s(e.detail.value)},onValueChange:e=>{null==t||t(e.detail.value)}})};function VertexSelectionHighlightingControls({onUpdateSelectionHighlightColor:t,onUpdateSelectionHighlightOpacity:n,onUpdateSelectionHighlightLineThickness:a}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsx(VertexSelectionHighlightingColorPicker,{onUpdate:t}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Opacity"}),e.jsx(VertexSelectionHighlightingOpacitySlider,{onUpdate:n}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Line Thickness"}),e.jsx(VertexSelectionHighlightingLineThicknessSlider,{onUpdate:a})]})}const VertexSelectionHighlightingReset=({onReset:t})=>{const[a,s]=n.useRecoilState(nn),[i,l]=n.useRecoilState(an),[r,c]=n.useRecoilState(sn),u=a!==Qt||i!==en||1!==r;return e.jsx("div",{className:"ml-auto",children:e.jsx(o.VertexTooltip,{content:"Reset Selection Highlighting",children:e.jsx(o.VertexIconButton,{"data-testid":"selection-highlighting-reset",iconName:"reset",iconSize:"sm",onClick:()=>{s(Qt),l(en),c(1),null==t||t()},disabled:!u})})})};function VertexSelectionHighlightingPanelSection({onResetSelectionHighlighting:t,onUpdateSelectionHighlightColor:n,onUpdateSelectionHighlightOpacity:a,onUpdateSelectionHighlightLineThickness:s}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Selection Highlighting",e.jsx(VertexSelectionHighlightingReset,{onReset:t})]}),children:e.jsx(VertexSelectionHighlightingControls,{onUpdateSelectionHighlightColor:n,onUpdateSelectionHighlightOpacity:a,onUpdateSelectionHighlightLineThickness:s})})}const VertexViewerBackgroundColorPicker=({onUpdate:t})=>{const[a,s]=n.useRecoilState(Jt);return e.jsx(VertexColorPicker,{"data-testid":"viewer-background-color-picker",value:a,onValueChanged:e=>{null==t||t(e.detail)},onInput:e=>s(e)})};function VertexViewerBackgroundControls({onUpdateViewerBackgroundColor:t}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsx(VertexViewerBackgroundColorPicker,{onUpdate:t})]})}const VertexViewerBackgroundReset=({onReset:t})=>{const[a,s]=n.useRecoilState(Jt),i=a!==Zt;return e.jsx("div",{className:"ml-auto",children:e.jsx(o.VertexTooltip,{content:"Reset Background Color",children:e.jsx(o.VertexIconButton,{"data-testid":"viewer-background-reset",iconName:"reset",iconSize:"sm",onClick:()=>{s(Zt),null==t||t()},disabled:!i})})})};function VertexViewerBackgroundPanelSection({onResetViewerBackgroundColor:t,onUpdateViewerBackgroundColor:n}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Viewer Background",e.jsx(VertexViewerBackgroundReset,{onReset:t})]}),children:e.jsx(VertexViewerBackgroundControls,{onUpdateViewerBackgroundColor:n})})}const isInputElement=e=>{const t=e instanceof HTMLElement&&"VERTEX-AUTO-RESIZE-TEXTAREA"===e.tagName,n=e instanceof HTMLElement&&"VERTEX-TEXTFIELD"===e.tagName,a=e instanceof HTMLElement&&"true"===e.contentEditable,s=e instanceof HTMLElement&&"VERTEX-SCENE-TREE-SEARCH"===e.tagName,o=e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement,i=e instanceof HTMLElement&&"VERTEX-VIEWER-PIN-TOOL"===e.tagName,l=e instanceof HTMLElement&&"VERTEX-VIEWER-TRANSFORM-WIDGET"===e.tagName;return t||n||a||s||o||i||l},useRecoilReducer=({reducer:e,atom:t})=>{const a=undefined,s=undefined;return[n.useRecoilValue(t),useRecoilReducerDispatch({reducer:e,atom:t})]},useRecoilReducerDispatch=({reducer:e,atom:t})=>{const a=n.useRecoilCallback((({set:n})=>async a=>{n(t,(t=>e(t,a)))}),[]);return a},on=n.atom({key:"keyBindings",default:{applyBindings:[],bindings:{},pressed:{}}});function reducer(e,t){var n,a,s,o;switch(t.type){case"push-key-binding":const i=undefined;return null!=(null===(n=e.bindings[t.binding.keyBind])||void 0===n?void 0:n.find((e=>e.id===t.binding.id)))?e:Object.assign(Object.assign({},e),{bindings:Object.assign(Object.assign({},e.bindings),{[t.binding.keyBind]:[...null!==(a=e.bindings[t.binding.keyBind])&&void 0!==a?a:[],t.binding]})});case"remove-key-binding":const l=undefined;return null==(null===(s=e.bindings[t.binding.keyBind])||void 0===s?void 0:s.find((e=>e.id===t.binding.id)))?e:Object.assign(Object.assign({},e),{bindings:Object.assign(Object.assign({},e.bindings),{[t.binding.keyBind]:(null!==(o=e.bindings[t.binding.keyBind])&&void 0!==o?o:[]).filter((e=>e.id!==t.binding.id))})});case"add-apply-key-binding":return Object.assign(Object.assign({},e),{applyBindings:[...e.applyBindings,t.binding]});case"remove-apply-key-binding":return Object.assign(Object.assign({},e),{applyBindings:e.applyBindings.filter((e=>e.id!==t.id))});case"set-key-pressed":return Object.assign(Object.assign({},e),{applyBindings:e.applyBindings.map((t=>Object.assign(Object.assign({},t),{active:null!=t.keyBind&&allPressed(t.keyBind,e.pressed)}))),pressed:Object.assign(Object.assign({},e.pressed),{[t.key]:t.pressed}),lastPressed:t.pressed?t.key:void 0})}}const useKeyBindingState=()=>useRecoilReducer({reducer:reducer,atom:on});function pressedValue(e,t){return e.includes("!")?!t[e.replace("!","")]&&!t[e.replace("!","").toLowerCase()]:t[e]||t[e.toLowerCase()]}function isPressed(e,t){const n=e.split("||");return n.length>1?n.some((e=>pressedValue(e,t))):pressedValue(n[0],t)}function allPressed(e,t){const n=undefined;return e.split("+").every((e=>isPressed(e,t)))}function matchingSingleFnBindings(e,t,n){return e.filter((e=>!e.repeat)).filter((e=>{var a;return null!=e.keyBind&&null!=n&&(null===(a=e.keyBind)||void 0===a?void 0:a.includes(n))&&allPressed(e.keyBind,t)})).map((e=>e.fn))}function matchingOffBindings(e,t,n){return e.filter((e=>e.off&&e.active&&null!=e.keyBind&&null==n&&!allPressed(e.keyBind,t))).map((e=>e.off))}const useApplyKeyBinding=e=>{const[t,n]=useKeyBindingState();a.useEffect((()=>{const a=O.create();return n({type:"add-apply-key-binding",binding:Object.assign(Object.assign({},e),{id:a,active:null!=e.keyBind&&allPressed(e.keyBind,t.pressed)})}),()=>{n({type:"remove-apply-key-binding",id:a})}}),[e.fn,e.off,e.keyBind,e.repeat])},useStackKeyBinding=(e,t=[])=>{const[,n]=useKeyBindingState();a.useEffect((()=>{const t=null==e.addPredicate||e.addPredicate(),a=null!=e.cancelPredicate&&e.cancelPredicate();t&&n({type:"push-key-binding",binding:e}),a&&n({type:"remove-key-binding",binding:e})}),t)},useKeyBindings=({keydownRepeatInterval:e=25,keydownIgnorePredicate:t=isInputElement}={})=>{const[n,s]=useKeyBindingState(),o=a.useCallback((e=>{Object.keys(n.bindings).filter((t=>t.includes(e)&&allPressed(t,Object.assign(Object.assign({},n.pressed),{[e]:!0})))).forEach((e=>{const t=n.bindings[e],a=t.length>0?t[t.length-1]:void 0;null!=a&&(a.fn(),s({type:"remove-key-binding",binding:a}))}))}),[n]);a.useEffect((()=>{const handleKeyDown=e=>{if(!e.repeat&&!t(e.target)){s({type:"set-key-pressed",key:e.key,pressed:!0}),o(e.key);const t=Object.assign(Object.assign({},n.pressed),{[e.key]:!0}),a=matchingSingleFnBindings(n.applyBindings,t,e.key),i=matchingOffBindings(n.applyBindings,t,e.key);(a.length>0||i.length>0)&&e.preventDefault()}},handleKeyUp=e=>{s({type:"set-key-pressed",key:e.key,pressed:!1})};return window.addEventListener("keydown",handleKeyDown),window.addEventListener("keyup",handleKeyUp),()=>{window.removeEventListener("keydown",handleKeyDown),window.removeEventListener("keyup",handleKeyUp)}}),[o,n.applyBindings,n.pressed]),a.useEffect((()=>{const e=matchingSingleFnBindings(n.applyBindings,n.pressed,n.lastPressed),t=matchingOffBindings(n.applyBindings,n.pressed,n.lastPressed);e.forEach((e=>e())),t.forEach((e=>e()))}),[n.pressed,n.lastPressed]),a.useEffect((()=>{const t=n.applyBindings.filter((e=>e.repeat&&null!=e.keyBind&&allPressed(e.keyBind,n.pressed))).map((e=>e.fn));if(t.length>0){const n=setInterval((()=>{t.forEach((e=>e()))}),e);return()=>{clearInterval(n)}}return()=>{}}),[n.applyBindings,n.lastPressed])},VertexBoxSelectionButton=()=>{const t=useBoxSelectionActions(),a=n.useRecoilValue(Me);return useStackKeyBinding({id:"ExitBoxSelection",keyBind:"Escape",fn:t.disable,addPredicate:()=>a,cancelPredicate:()=>!a},[a]),e.jsx(o.VertexTooltip,{content:"Box Selection",children:e.jsx(o.VertexIconButton,{iconName:"box-cursor",iconColor:a?"primary":"secondary","data-testid":"viewer-toolbar-enable-box-selection-button",onClick:a?t.disable:t.enable})})},ln=1,VertexResizableContent=t=>{var{className:n,style:a,displayShadow:s,heading:i,id:l,initialScale:r,placement:c="left",children:u,onResize:d}=t,m=__rest(t,["className","style","displayShadow","heading","id","initialScale","placement","children","onResize"]);const p="left"===c||"right"===c,h="top"===c;function getHorizontalResizeDirection(){switch(c){case"left":return"right";case"right":return"left";default:return"none"}}function getVerticalResizeDirection(){return"top"===c?"top":"none"}const f=null!=r?r:1;return e.jsx(o.VertexResizable,Object.assign({id:l,"data-testid":`resizable-content-position-${c}`,className:Ce(n,"pointer-events-auto z-popover md:z-overlay bg-white bg-opacity-95 flex-grow-0 flex-shrink-0 border-neutral-300",{"border-r min-w-75 max-w-half":"left"===c,"sidebar-shadow-right":"left"===c&&s,"border-l min-w-75 max-w-half":"right"===c,"sidebar-shadow-left":"right"===c&&s,"border-t bottom-0 fixed":"top"===c,"min-h-12 sheet":h}),style:Object.assign({maxHeight:"top"===c?window.innerHeight:void 0},a),initialHorizontalScale:p?r:void 0,initialVerticalScale:h?f:void 0,horizontalDirection:getHorizontalResizeDirection(),verticalDirection:getVerticalResizeDirection(),position:"right"===c||"top"===c?"absolute":"relative",onResizeEnd:()=>null==d?void 0:d()},m,{children:e.jsxs("div",{className:"flex flex-col h-full w-full",children:["top"===c&&e.jsx("div",{className:"flex justify-center w-full",children:e.jsx("div",{className:"block md:hidden w-20 h-0.5 mt-0.5 bg-neutral-600 rounded"})}),i,e.jsx("div",{className:Ce("w-full flex flex-col h-0 flex-grow",{"right-0":"right"===c}),children:u})]})}))};function useDefaultKeybindings(){useApplyKeyBinding({fn:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromiseRequired(H),n={milliseconds:500},a=await t();await(null==a?void 0:a.camera().viewAll().render({animation:n}))})),keyBind:"f"})}function useLongPress({target:e,callback:t,delay:n=500,onMovement:a}){const[o,i]=u.useState(),[l,r]=u.useState();u.useEffect((()=>{const handleTouchStart=e=>{const a=e;null!=a.touches&&1===a.touches.length&&(null!=o&&clearTimeout(o),r(s.Point.create(a.touches[0].clientX,a.touches[0].clientY)),i(setTimeout((()=>null==t?void 0:t(a)),n)))},handleTouchMove=e=>{const t=e;null!=t.touches&&t.touches.length>0&&null!=o&&null!=l&&s.Point.distance(l,s.Point.create(t.touches[0].clientX,t.touches[0].clientY))>=2&&(clearTimeout(o),null==a||a())},handleTouchEnd=()=>{null!=o&&clearTimeout(o)};return null==e||e.addEventListener("touchstart",handleTouchStart),null==e||e.addEventListener("touchmove",handleTouchMove),null==e||e.addEventListener("touchend",handleTouchEnd),()=>{null==e||e.removeEventListener("touchstart",handleTouchStart),null==e||e.removeEventListener("touchmove",handleTouchMove),null==e||e.removeEventListener("touchend",handleTouchEnd)}}),[e,o,l])}function asBooleanAttribute(e){return!!e||void 0}const VertexContextMenu=({targetElement:t,menuType:s,disableBackdrop:i,openPredicate:l,onOpen:r,onClose:c,children:u})=>{const d=useContextMenuActions(),m=n.useRecoilValue(Pe),p=n.useRecoilValue(Oe),h=a.useMemo((()=>["bottom-end","top-start","top-end","right","left"]),[]),f=m===s;useStackKeyBinding({id:"ContextMenu",keyBind:"Escape",fn:d.clearActiveContextMenu,addPredicate:()=>null!=m&&m===s,cancelPredicate:()=>null==m},[m]);const g=a.useMemo((()=>null!=t?t:null!=l?window:void 0),[t,l]);return useLongPress({target:g,callback:e=>d.longPress(e,s,l,r),onMovement:()=>d.clearActiveContextMenu()}),a.useEffect((()=>{const handleWindowPointerDown=e=>{const t=undefined;if(!targetWithinMenu(e)&&2!==e.buttons&&m===s){const t=targetShouldSkipNextHit(e);d.clearActiveContextMenu(t)}};if(i)return window.addEventListener("pointerdown",handleWindowPointerDown),()=>{window.removeEventListener("pointerdown",handleWindowPointerDown)}}),[i,s,m]),a.useEffect((()=>{const handlePointerDown=e=>{d.pointerDown(e)},handlePointerUp=e=>{d.pointerUp(e,s,l,r)},handleContextMenu=e=>d.contextMenu(e,l);return null==g||g.addEventListener("pointerdown",handlePointerDown),null==g||g.addEventListener("pointerup",handlePointerUp),null==g||g.addEventListener("contextmenu",handleContextMenu),()=>{null==g||g.removeEventListener("pointerdown",handlePointerDown),null==g||g.removeEventListener("pointerup",handlePointerUp),null==g||g.removeEventListener("contextmenu",handleContextMenu)}}),[t,s,l]),e.jsx("div",{className:Ce({hidden:!f}),children:e.jsx(o.VertexMenu,{"data-testid":`${s}-context-menu`,open:asBooleanAttribute(f),position:p,fallbackPlacements:h,backdrop:!i,onMenuClosed:()=>{d.clearActiveContextMenu(),null==c||c()},children:e.jsx("div",{className:"pt-1",children:u})})})},VertexFitSelectedMenuItem=()=>{const t=n.useRecoilValue(ot),a=n.useRecoilValue(pt),s=useViewerCameraActions();return e.jsxs(o.VertexMenuItem,{"data-testid":"fit-selected-menu-option",onClick:()=>{null!=(null==a?void 0:a.boundingBox)&&s.flyToByBoundingBox(a.boundingBox)},disabled:asBooleanAttribute(0===t.length),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"fit-selected",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Fit Selected"})]})},VertexFlyToMenuItem=()=>{const t=useViewerCameraActions(),a=n.useRecoilValue(Re);return e.jsxs(o.VertexMenuItem,{"data-testid":"fly-to-part-menu-option",onClick:()=>{var e;const n=undefined,s=contextMenuItemIsRow(a)?null===(e=null==a?void 0:a.node.id)||void 0===e?void 0:e.hex:null==a?void 0:a.id;null!=s&&t.flyToById(s)},disabled:asBooleanAttribute(null==a),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"paper-airplane",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Fly To"})]})};function useSceneItemsOperations(){const e=n.useRecoilValue(M),t=undefined,s=undefined,o=undefined,i=undefined,l=undefined,r=undefined;return{sceneItemsOperation:a.useCallback((async(t,n)=>{const a=await(null==e?void 0:e.scene());null==n?await(null==a?void 0:a.items((e=>t(e.where((e=>e.all()))))).execute()):n.length>0&&await(null==a?void 0:a.items((e=>t(e.where((e=>e.withItemIds(n)))))).execute())}),[e]),showOnlySelected:a.useCallback((async()=>{const t=await(null==e?void 0:e.scene());null==t||t.items((e=>[e.where((e=>e.all())).hide(),e.where((e=>e.withSelected())).show()])).execute()}),[e]),hideSelected:a.useCallback((async()=>{const t=await(null==e?void 0:e.scene());null==t||t.items((e=>[e.where((e=>e.withSelected())).hide()])).execute()}),[e]),showOnlyItem:a.useCallback((async t=>{const n=await(null==e?void 0:e.scene());null==n||n.items((e=>[e.where((e=>e.all())).hide(),e.where((e=>e.withItemIds([t]))).show()])).execute()}),[e]),ghostSelected:a.useCallback((async()=>{const t=await(null==e?void 0:e.scene());null==t||t.items((e=>[e.where((e=>e.withSelected())).setPhantom(!0)])).execute()}),[e]),unGhostSelected:a.useCallback((async()=>{const t=await(null==e?void 0:e.scene());null==t||t.items((e=>[e.where((e=>e.withSelected())).setPhantom(!1)])).execute()}),[e])}}const VertexHideAllMenuItem=()=>{const t=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"hide-all-menu-option",onClick:()=>{t.sceneItemsOperation((e=>e.hide()))},children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Hide All Parts"})]})},VertexHidePartMenuItem=()=>{const t=n.useRecoilValue(Re),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"hide-menu-option",onClick:()=>{var e;const n=undefined,s=contextMenuItemIsRow(t)?null===(e=null==t?void 0:t.node.id)||void 0===e?void 0:e.hex:t.id;null!=s&&a.sceneItemsOperation((e=>e.hide()),[s])},disabled:asBooleanAttribute(null==t),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Hide Part"})]})},VertexHideSelectedMenuItem=()=>{const t=n.useRecoilValue(ot),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"hide-selected-menu-option",onClick:()=>a.hideSelected(),disabled:asBooleanAttribute(0===t.length),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Hide Selected"})]})},VertexShowAllMenuItem=()=>{const t=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"show-all-menu-option",onClick:()=>{t.sceneItemsOperation((e=>e.show()))},children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Show All Parts"})]})},VertexShowOnlyMenuItem=()=>{const t=n.useRecoilValue(Re),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"show-only-menu-option",onClick:()=>{var e;const n=undefined,s=contextMenuItemIsRow(t)?null===(e=null==t?void 0:t.node.id)||void 0===e?void 0:e.hex:null==t?void 0:t.id;null!=s&&a.showOnlyItem(s)},disabled:asBooleanAttribute(null==t),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Show Only Part"})]})},VertexShowOnlySelectedMenuItem=()=>{const t=n.useRecoilValue(ot),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"show-only-selected-menu-option",onClick:()=>a.showOnlySelected(),disabled:asBooleanAttribute(0===t.length),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Show Only Selected"})]})};n.atom({key:"sceneTreeLoaderVisible",default:!1});const rn=n.atom({key:"sceneTreeElement",default:void 0}),cn=n.atom({key:"sceneTreeController",default:void 0,dangerouslyAllowMutability:!0});function useSceneTreeActions(){const e=useSelectionActions(),t=useViewerCameraActions();return{toggleSelection:useActionCallback((({snapshot:t})=>async(n,a,s)=>{var o,i;if(!n.defaultPrevented&&0===n.button&&(n.altKey||((n.ctrlKey||n.metaKey)&&a.selected?await s.deselectItem(a):a.selected?await s.selectItem(a,{recurseParent:!0}):a.selected||await s.selectItem(a,{append:n.ctrlKey||n.metaKey,range:n.shiftKey})),null!=a.id)){const s=await t.getPromise(it);e.syncSelection({id:null===(o=a.id)||void 0===o?void 0:o.hex,ancestors:null!==(i=null==s?void 0:s.ancestors)&&void 0!==i?i:[]},{selected:!n.metaKey&&!n.ctrlKey||!a.selected,multiSelect:n.shiftKey||n.metaKey||n.ctrlKey})}})),toggleExpansion:useActionCallback((()=>(e,t,n)=>{n.toggleExpandItem(t)})),toggleVisibility:useActionCallback((()=>(e,t,n)=>{n.toggleItemVisibility(t)})),flyToRow:useActionCallback((({snapshot:e})=>async n=>{var a;const s=await e.getPromise(rn),o=await(null==s?void 0:s.getRowAtClientY(n));null!=(null===(a=null==o?void 0:o.node.id)||void 0===a?void 0:a.hex)&&await t.flyToById(o.node.id.hex)})),flyToFirstSelectedItem:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(rn),n=await e.getPromise(ut);null!=n&&(null==t||t.scrollToItem(n))})),setContextMenuItem:useActionCallback((({set:e,snapshot:t})=>async n=>{const a=await t.getPromise(rn),s=await(null==a?void 0:a.getRowAtClientY(n));e(Re,s)}))}}const VertexGhostSelectedMenuItem=()=>{const t=n.useRecoilValue(ot),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"ghost-selected-menu-option",onClick:()=>a.ghostSelected(),disabled:asBooleanAttribute(0===t.length),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-partial",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Ghost Selected"})]})},VertexUnghostSelectedMenuItem=()=>{const t=n.useRecoilValue(ot),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"unghost-selected-menu-option",onClick:()=>a.unGhostSelected(),disabled:asBooleanAttribute(0===t.length),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Unghost Selected"})]})},DefaultSceneTreeContextMenu=()=>e.jsxs("div",{className:"w-56",children:[e.jsx(VertexHideSelectedMenuItem,{}),e.jsx(VertexHideAllMenuItem,{}),e.jsx(VertexShowOnlyMenuItem,{}),e.jsx(VertexShowOnlySelectedMenuItem,{}),e.jsx(VertexShowAllMenuItem,{}),e.jsx(VertexGhostSelectedMenuItem,{}),e.jsx(VertexUnghostSelectedMenuItem,{}),e.jsx(o.VertexMenuDivider,{}),e.jsx(VertexFitSelectedMenuItem,{}),e.jsx(VertexFlyToMenuItem,{})]}),VertexSceneTreeContextMenu=({children:t})=>{const a=useSceneTreeActions(),s=n.useRecoilValue(rn),o=null!=t&&!1!==t;return e.jsx(VertexContextMenu,{menuType:"scene-tree",targetElement:s,onOpen:async(e,t)=>{const n=e;await a.setContextMenuItem(n.clientY)},disableBackdrop:!0,children:o?t:e.jsx(DefaultSceneTreeContextMenu,{})})},DefaultViewerContextMenu=()=>e.jsxs("div",{className:"w-56",children:[e.jsx(VertexHidePartMenuItem,{}),e.jsx(VertexHideSelectedMenuItem,{}),e.jsx(VertexHideAllMenuItem,{}),e.jsx(VertexShowOnlyMenuItem,{}),e.jsx(VertexShowOnlySelectedMenuItem,{}),e.jsx(VertexShowAllMenuItem,{}),e.jsx(VertexGhostSelectedMenuItem,{}),e.jsx(VertexUnghostSelectedMenuItem,{}),e.jsx(o.VertexMenuDivider,{}),e.jsx(VertexFitSelectedMenuItem,{}),e.jsx(VertexFlyToMenuItem,{})]}),VertexViewerContextMenu=({children:t})=>{const n=null!=t&&!1!==t,s=a.useCallback((e=>e.target instanceof HTMLElement&&"vertex-viewer"===e.target.id),[]);return e.jsx(VertexContextMenu,{menuType:"viewer",disableBackdrop:!0,openPredicate:s,children:n?t:e.jsx(DefaultViewerContextMenu,{})})},un=35,dn=n.atom({key:"sceneItemGhostingSelectedOpacity",default:un}),mn=n.atomFamily({key:"appliedItemPhantomState",default:void 0}),pn=n.atom({key:"appliedItemPhantomStateIds",default:[]}),xn=n.selector({key:"sceneItemGhostingLastSelectedPhantom",get:({get:e})=>{var t;const n=e(it);return null!=n&&(null!==(t=e(mn(n.id)))&&void 0!==t&&t)}}),VertexSceneItemGhostingOpacitySlider=({onApply:t})=>{const[a,s]=n.useRecoilState(dn);return e.jsx(VertexSlider,{id:"phantom-opacity","data-testid":"phantom-opacity-slider",leftLabel:"0%",rightLabel:"100%",min:0,max:100,step:5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{s(e.detail.value)},onValueChange:e=>{null==t||t(e.detail.value)}})},useSceneItemPhantomActions=()=>{const e=useViewerSceneActions(),t=useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=undefined;(await e.getPromise(pn)).forEach((e=>t(mn(e)))),t(pn)}));return{setPhantomState:useActionCallback((({snapshot:t,set:n})=>async a=>{const s=await t.getPromise(ot);s.forEach((e=>n(mn(e),a))),n(pn,(e=>[...e,...s])),await e.execute(tt.SET_PHANTOM_SELECTED_ITEMS,(e=>e.where((e=>e.withSelected())).setPhantom(a)))})),clearPhantomState:useActionCallback((({snapshot:t,set:n,reset:a})=>async()=>{const s=await t.getPromise(ot);s.forEach((e=>a(mn(e)))),n(pn,(e=>e.filter((e=>!s.includes(e))))),await e.execute(tt.CLEAR_PHANTOM_SELECTED_ITEMS,(e=>e.where((e=>e.withSelected())).clearPhantom()),(e=>e.where((e=>e.withSelected())).select()))})),clearAllPhantomState:useActionCallback((()=>async()=>{await t(),await e.execute(tt.CLEAR_PHANTOM_ALL,(e=>e.where((e=>e.all())).clearPhantom()),(e=>e.where((e=>e.withSelected())).select()))})),resetAllPhantomState:t}},VertexSceneItemGhostingToggle=({onApply:t})=>{const a=useSceneItemPhantomActions(),s=n.useRecoilValue(ft),i=n.useRecoilValueLoadable(xn);return e.jsx(o.VertexTooltip,{content:"Select a part to display as ghost",disabled:s,children:e.jsx(o.VertexToggle,{className:"flex items-center","data-testid":"phantom-state-toggle",variant:"switch",disabled:!s,checked:"hasValue"===i.state&&i.contents,onValueChanged:async e=>{await a.setPhantomState(e.detail),null==t||t(e.detail)}})})};function VertexGhostingControls({onApplyGhostingChange:t,onApplyOpacity:n}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center py-3",children:[e.jsx(VertexSceneItemGhostingToggle,{onApply:t}),e.jsx("span",{className:"pl-4 text-sm text-neutral-700",children:"Display as Ghost"})]}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Global Ghost Opacity"}),e.jsx(VertexSceneItemGhostingOpacitySlider,{onApply:n})]})}const VertexSceneItemGhostingClear=({onClear:t,onClearAll:a})=>{const s=useSceneItemPhantomActions(),i=n.useRecoilValue(xn);return e.jsx("div",{className:"ml-auto",children:e.jsxs(ResetButton,{id:"phantom",tooltip:"Clear Ghosting",children:[e.jsx("div",{className:"pt-1"}),e.jsx(o.VertexMenuItem,{"data-testid":"reset-selected-phantom",onClick:async()=>{await s.clearPhantomState(),null==t||t()},disabled:!i,children:"Clear ghosting for selected"}),e.jsx(o.VertexMenuItem,{"data-testid":"reset-all-phantom",onClick:async()=>{await s.clearAllPhantomState(),null==a||a()},children:"Clear ghosting for all"})]})})};function VertexGhostingPanelSection({onClearGhostState:t,onClearAllGhostState:n,onApplyGhostingChange:a,onApplyOpacity:s}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Ghosting",e.jsx(VertexSceneItemGhostingClear,{onClear:t,onClearAll:n})]}),children:e.jsx(VertexGhostingControls,{onApplyGhostingChange:a,onApplyOpacity:s})})}function VertexMeasurementContextMenu({onDelete:t}){const a=n.useRecoilValue(Ie);return e.jsx(VertexContextMenu,{menuType:"measurement",openPredicate:e=>e.target instanceof HTMLElement&&"VERTEX-VIEWER-MEASUREMENT-DISTANCE"===e.target.tagName,children:e.jsxs(o.VertexMenuItem,{"data-testid":"measurement-delete",onClick:()=>null!=a&&t(a.id),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"delete",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Delete"})]})})}function useDockedPlacement(e,t){const[n,a]=u.useState(s.Point.create(0,0));return u.useLayoutEffect((()=>{if(null!=e){const n=e.getBoundingClientRect(),o=s.Point.create(n.left,n.bottom),i=s.Point.create(n.right,n.bottom);a("left"===t?o:i)}}),[e,t]),n}function VertexMeasurementDetails({placement:t}){const a=useMeasurementActions(),s=n.useRecoilValue(M),i=n.useRecoilValue(L),r=useDockedPlacement(null!=s?s:null,t),c=n.useRecoilValue(qe),u=n.useRecoilValue(Ye),d=n.useRecoilValue(Xe),m=n.useRecoilValue(Ze),p=n.useRecoilValue(vt),h=n.useRecoilValue(yt);return e.jsx(o.VertexDraggablePopover,{className:"z-popover",boundaryPadding:16,boundarySelector:`#${i}`,position:r,children:e.jsxs("div",{className:"flex flex-col leading-4 min-w-40",children:[e.jsxs("div",{className:"pb-2 flex justify-between",children:[e.jsx("div",{className:"w-full",children:"Measurement"}),e.jsx("div",{className:Ce("-mt-1 relative",{hidden:!m}),children:e.jsx(o.VertexTooltip,{content:"Reset",placement:"left-start",children:e.jsx(o.VertexIconButton,{"data-testid":"measurement-details-reset",iconName:"reset",iconSize:"sm",onClick:a.resetMeasurement})})})]}),e.jsx(l.VertexViewerMeasurementDetails,{"data-testid":"measurement-details-viewer-measurement-details",className:Ce("gap-y-1.5 text-xs",{hidden:null==c}),measurementOutcome:c,measurementOverlays:u,distanceUnits:toUnitType(p),fractionalDigits:parseInt(h,10)}),e.jsx("div",{"data-testid":"measurement-details-message",className:Ce("text-xs",{hidden:null==d}),children:d})]})})}function useCallbackRef(e){var t;const[n,s]=a.useState((t=void 0,null)),o=undefined;return{element:n,callback:a.useCallback((e=>s(e)),[])}}function VertexPointToPointMeasurement({detailsPlacement:t,onPointToPointMeasurementChange:s}){const o=useMeasurementActions(),i=n.useRecoilValue(M),r=n.useRecoilValue(Be),c=n.useRecoilValue(De),u=n.useRecoilValue(vt),d=n.useRecoilValue(yt),{callback:m,element:p}=useCallbackRef();usePointToPointMeasurement(p);const h=a.useCallback((e=>{const t={start:e.detail.start,end:e.detail.end,invalid:!e.detail.valid};o.setEditedPointToPointMeasurement(t),null==s||s(t)}),[o]);return r?e.jsxs(e.Fragment,{children:[e.jsx(l.VertexViewerMeasurementDistance,{"data-testid":"point-to-point-measurement",ref:m,viewer:null!=i?i:void 0,mode:"replace",start:null==c?void 0:c.start,end:null==c?void 0:c.end,invalid:null==c?void 0:c.invalid,units:toUnitType(u),fractionalDigits:parseInt(d,10),showAxisReferenceLines:!0,onEditEnd:h}),e.jsx(VertexMeasurementDetails,{placement:t}),e.jsx(VertexMeasurementContextMenu,{onDelete:o.resetMeasurement})]}):e.jsx(e.Fragment,{})}function VertexPointToPointMeasurementTool(){const t=useMeasurementActions(),a=n.useRecoilValue(Be);return useStackKeyBinding({id:"ExitMeasurement",keyBind:"Escape",fn:t.disableEditMeasurement,addPredicate:()=>a,cancelPredicate:()=>!a},[a,t]),e.jsx(o.VertexTooltip,{content:"Point to Point Measurement",children:e.jsx(o.VertexIconButton,{iconName:"tape-measure","data-testid":"viewer-toolbar-point-to-point-measurement-button",iconColor:a?"primary":"secondary",onClick:t.toggleEditPointToPointMeasurement})})}const hn=n.atom({key:"viewerToolkitSdkConfig",default:void 0}),VertexPreciseMeasurement=({detailsPlacement:t,onEntitiesChanged:a,onOutcomeChanged:s})=>{var o,i,r,c;const u=n.useRecoilValue(M),d=n.useRecoilValue(hn),m=n.useRecoilValue(Fe),{callback:p,element:h}=useCallbackRef();return usePreciseMeasurementModel(h,a,s),m?e.jsxs(e.Fragment,{children:[e.jsx(l.VertexViewerMeasurementPrecise,{"data-testid":"precise-measurement-viewer-tool",ref:p,viewer:null!=u?u:void 0,config:JSON.stringify({network:{apiHost:null===(o=null==d?void 0:d.network)||void 0===o?void 0:o.apiHost,renderingHost:null===(i=null==d?void 0:d.network)||void 0===i?void 0:i.renderingHost,sceneTreeHost:null===(r=null==d?void 0:d.network)||void 0===r?void 0:r.sceneTreeHost,sceneViewHost:null===(c=null==d?void 0:d.network)||void 0===c?void 0:c.sceneViewHost}})}),e.jsx(VertexMeasurementDetails,{placement:t})]}):e.jsx(e.Fragment,{})};function VertexPreciseMeasurementTool(){const t=useMeasurementActions(),a=n.useRecoilValue(Fe);return e.jsx(o.VertexTooltip,{content:"Precise Measurement",children:e.jsx(o.VertexIconButton,{iconName:"ruler","data-testid":"viewer-toolbar-precise-measurement-button",iconColor:a?"primary":"secondary",onClick:t.toggleEditPreciseMeasurement})})}function VertexApplicationMessages(){const t=n.useRecoilValue(et),a=n.useRecoilValue(Qe);return e.jsxs(e.Fragment,{children:[null!=t&&e.jsx(o.VertexBanner,{className:"z-[16000]",duration:t.duration,open:!0,content:t.message,type:t.type},t.id),null!=a&&e.jsx(o.VertexToast,{placement:"bottom-left",className:"z-[16000]",duration:a.duration,open:!0,content:a.message,type:a.type},a.id)]})}const fn={binding:"{{row.node.name}}",label:"Name",metadataKeyName:"VERTEX_SCENE_ITEM_NAME"};function mapToColumn(e,t){return{label:"name"===e.toLowerCase()?"Name (Property)":e,binding:`{{row.metadata.${e}}}`,initialWidth:t,minWidth:t/2}}const gn=n.atom({key:"sceneTreeColumnsRefreshTrigger",default:0}),vn=n.selector({key:"sceneTreeColumnsAvailableColumns",get:async({get:e})=>{const t=e(cn);return e(gn),null!=t?await t.fetchMetadataKeys():[]}}),yn=n.selector({key:"sceneTreeColumnsAvailableSortedColumns",get:({get:e})=>e(vn).filter((e=>e!==fn.metadataKeyName)).sort(((e,t)=>e.localeCompare(t)))}),bn=n.atom({key:"sceneTreeColumnsVisibleMetadataColumnNames",default:[]}),Sn=n.selector({key:"sceneTreeColumnsActiveColumns",get:({get:e})=>{const t=e(bn),n=e(rn),a=null==n?void 0:n.clientWidth;if(null!=a&&a>0){const e=1/(t.length+1)*a,n=(a-e)/t.length;return t.reduce(((e,t)=>{const a=mapToColumn(t,n);return Object.assign(Object.assign({},e),{[a.label]:a})}),{Name:Object.assign(Object.assign({},fn),{initialWidth:e,minWidth:n})})}return{Name:fn}}}),wn=n.selector({key:"sceneTreeColumnsActiveColumnNames",get:({get:e})=>Object.keys(e(Sn))});function useSceneTreeColumnActions(){return{setActive:useActionCallback((({set:e,snapshot:t})=>async n=>{e(bn,n);const a=await t.getPromise(cn);null==a||a.setMetadataKeys(n)})),refreshKeyList:useActionCallback((({set:e})=>()=>{e(gn,(e=>e+1))}))}}const Vn=16,Cn=-8;var jn;function useOpenColumnPopover({buttonElement:e,horizontalOffset:t,verticalOffset:n}){const[a,s]=u.useState(!1),[o,i]=u.useState(),[l,r]=u.useState(),c=u.useCallback((()=>{if(a)s(!1);else{const a=null==e?void 0:e.getBoundingClientRect();if(null!=a){const e=null!=t?t:Vn,o=null!=n?n:Cn,l=a.x>window.innerWidth/2?jn.LEFT:jn.RIGHT;i({x:l===jn.LEFT?a.left-e:a.right+e,y:a.top+o}),r(l),s(!0)}}}),[a,e]),d=u.useCallback((()=>{s(!1)}),[]);return{open:a,position:o,direction:l,handleOpen:c,handleClose:d}}!function(e){e.LEFT="left",e.RIGHT="right"}(jn||(jn={}));const Tn=n.atom({key:"sceneTreeSearchActive",default:!1}),kn=n.atom({key:"sceneTreeColumnsPartial",default:!1}),An=n.atom({key:"sceneTreeSearchValue",default:void 0}),Pn=n.atom({key:"sceneTreeSearchExactMatch",default:!1}),En=n.atom({key:"sceneTreeSearchResultCount",default:0}),In=n.atom({key:"sceneTreeSearchActiveColumns",default:[]}),Rn=n.selector({key:"sceneTreeSearchNameColumnActive",get:({get:e})=>{const t=e(In);return 0===t.length||t.includes(fn.metadataKeyName)}});function useSceneTreeSearch({sceneTreeElement:e}){const t=useSceneTreeActions(),s=n.useRecoilValue(Tn),o=n.useSetRecoilState(En),i=n.useSetRecoilState(ut);a.useEffect((()=>{let t;return whenComponentReady(e,(()=>{var n;t=null===(n=null==e?void 0:e.controller)||void 0===n?void 0:n.stateChanged((e=>{void 0!==(null==e?void 0:e.totalFilteredRows)&&o(null==e?void 0:e.totalFilteredRows)}))})),()=>{null==t||t.dispose()}}),[e]),a.useEffect((()=>{if(null!=e){let n;return whenComponentReady(e,(()=>{var a;n=null===(a=null==e?void 0:e.controller)||void 0===a?void 0:a.stateChanged((e=>{var n;if(null!=(null==e?void 0:e.filterTerm)){const t=null==e?void 0:e.rows.find((e=>{var t;return null===(t=null==e?void 0:e.node)||void 0===t?void 0:t.selected}));i(null===(n=null==t?void 0:t.node.id)||void 0===n?void 0:n.hex)}else s&&t.flyToFirstSelectedItem()}))})),()=>{null==n||n.dispose()}}}),[e,null==e?void 0:e.controller,open])}function useSceneTreePartialResults({sceneTreeElement:e}){const t=n.useSetRecoilState(kn);a.useEffect((()=>{let n;return whenComponentReady(e,(()=>{var a;n=null===(a=null==e?void 0:e.controller)||void 0===a?void 0:a.stateChanged((e=>{t(!!(null==e?void 0:e.isPartialKeysResponse))}))})),()=>{null==n||n.dispose()}}),[e])}const useSceneTreeSearchActions=()=>{const e=useActionCallback((({set:e})=>t=>{e(In,t)})),t=useActionCallback((({snapshot:t})=>async(n,a,s,o)=>{const i=await t.getPromise(rn),l=await t.getPromise(Pn),r=await t.getPromise(In),c=r.length>0?a?[...r,n]:r.filter((e=>e!==n)):[...s,fn.metadataKeyName].filter((e=>e!==n));e(c),o&&(null==i||i.filterItems(o,{columns:c,exactMatch:l}))})),n=useActionCallback((({snapshot:e,set:t})=>async(n,a,s)=>{const o=await e.getPromise(rn),i=await e.getPromise(Pn),l=await e.getPromise(In),r=n.filter((e=>!a.includes(e))),c=a.filter((e=>!n.includes(e))),u=l.length>0?[...l.filter((e=>!r.includes(e))),...c]:[...a,fn.metadataKeyName],d=u.length>0?u:[...a,fn.metadataKeyName];t(In,d),s&&(null==o||o.filterItems(s,{columns:d,exactMatch:i}))})),a=useActionCallback((({set:e})=>t=>{e(Pn,t)}));return{setMetadataSearchKeys:e,updateMetadataSearchAfterSearchKeysChange:t,updateMetadataSearchAfterColumnVisibilityChange:n,setMetadataSearchExactMatch:a}};function useCacheableLoadable(e,t){const s=a.useRef(),[o,i]=a.useState(0),l=n.useRecoilValueLoadable(e);a.useEffect((()=>{"hasValue"===l.state&&(s.current=l.contents)}),[t,l]);const[r,c]=a.useMemo((()=>"hasValue"!==l.state&&null!=s.current?[s.current,!0]:"hasValue"===l.state?[l.contents,!1]:[void 0,!1]),[l.state,l.contents,o]),u=a.useCallback((()=>{s.current=void 0,i(o+1)}),[o]),d=undefined;return a.useMemo((()=>({data:r,state:l.state,cached:c,invalidate:u})),[u,r,c,l.state])}const VertexSceneTreeMetadataCheck=({checked:t,disabled:n,onChange:a,children:s})=>{const i="string"==typeof s?s.replace(" ","-"):"";return e.jsxs("div",{className:"flex items-center",children:[e.jsx(o.VertexToggle,{"data-testid":`scene-tree-metadata-check-${i}`,variant:"check",checked:t,disabled:n,onValueChanged:e=>null==a?void 0:a(e.detail)}),e.jsx("div",{className:"pl-2 py-1 text-[0.875rem] w-full","data-testid":`scene-tree-metadata-name-${i}`,onClick:()=>{n||null==a||a(!t)},children:s})]})},VertexSceneTreeColumnPopover=({onVisibleSceneTreeColumnsChange:t})=>{const a=useSceneTreeColumnActions(),s=useSceneTreeSearchActions(),i=n.useRecoilValue(rn);useSceneTreePartialResults({sceneTreeElement:null!=i?i:null});const r=n.useRecoilValue(An),c=useCacheableLoadable(yn),d=n.useRecoilValue(bn),m=n.useRecoilValue(kn),[p,h]=u.useState(d),[f,g]=u.useState(""),{element:v,callback:b}=useCallbackRef(),{open:S,position:w,direction:V,handleOpen:C,handleClose:j}=useOpenColumnPopover({buttonElement:v}),T=V===jn.LEFT?"left-end":"right-start",k=u.useMemo((()=>{if(null!=c.data){const e=c.data.filter((e=>p.indexOf(e)<0)),t=undefined;return[...[...p].sort(((e,t)=>e.localeCompare(t))),...e]}return[]}),[p,c.data]),A=u.useMemo((()=>k),[S,c.data]);return e.jsxs(e.Fragment,{children:[e.jsx(o.VertexTooltip,{content:"Configure Columns",placement:"top",children:e.jsx(o.VertexIconButton,{"data-testid":"scene-tree-column-popover-button",ref:b,iconName:"columns-add",iconSize:"sm",onClick:()=>{C()}})}),S&&e.jsx(o.VertexPopover,{"data-testid":"scene-tree-column-popover",open:S,backdrop:!1,position:w,resizeBehavior:"fixed",placement:T,className:"z-popover",children:e.jsxs("div",{className:Ce("flex flex-col bg-white border border-neutral-300 rounded",{hidden:!S}),children:[e.jsxs("div",{className:"flex items-center text-[0.875rem] p-3",children:[e.jsxs("div",{className:"pr-2",children:[e.jsx("div",{className:"text-[0.875rem]",children:"Assembly Properties"}),e.jsx("div",{className:"text-[0.75rem] text-neutral-700 mt-1.5",children:"Select up to six properties to appear in the Assembly panel."})]}),e.jsx(o.VertexIconButton,{"data-testid":"scene-tree-columns-popover-close-button",className:"ml-auto",iconName:"close",iconSize:"sm",onClick:()=>{g(""),j()}})]}),e.jsx(o.VertexTextfield,{className:"flex w-full px-2 overflow-hidden border-b border-neutral-300 pb-2",id:"scene-tree-available-columns-search-bar","data-testid":"scene-tree-available-columns-search-bar",multiline:!1,placeholder:"Filter properties",type:"text",onInputInput:e=>{const t=e.detail.value;null!=t&&g(t.toLowerCase())}}),m&&e.jsx(l.VertexSceneTreeNotificationBanner,{"data-testid":"partial-key-list-notification-banner",message:"loading"===c.state?"Refreshing results...":"Data loading, refresh for more.",actionLabel:"Refresh",onAction:()=>a.refreshKeyList()}),e.jsxs("div",{className:"max-h-64 p-3 overflow-y-auto",children:[e.jsx(VertexSceneTreeMetadataCheck,{checked:!0,disabled:!0,children:fn.label}),A.filter((e=>""===f||e.toLowerCase().includes(f))).map((t=>e.jsx(VertexSceneTreeMetadataCheck,{checked:p.includes(t),disabled:p.length>=6&&!p.includes(t),onChange:e=>{h(e?[...p,t]:p.filter((e=>e!==t)))},children:t},t)))]}),e.jsxs("div",{className:"flex items-center p-3 border-t border-neutral-300 space-x-4",children:[e.jsx("div",{className:"text-[0.75rem] text-[var(--vertex-ui-blue-700)] cursor-pointer","data-testid":"scene-tree-column-clear-selection",onClick:()=>h([]),children:"Clear selection"}),e.jsx("div",{className:"flex-grow"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(o.VertexButton,{"data-testid":"scene-tree-column-popover-cancel",color:"secondary",onClick:()=>{g(""),j()},children:"Cancel"}),e.jsx(o.VertexButton,{"data-testid":"scene-tree-column-popover-apply",color:"primary",onClick:async()=>{await s.updateMetadataSearchAfterColumnVisibilityChange(d,p,r),await a.setActive(p),null==t||t(p),g(""),j()},children:"Apply"})]})]})]})})]})},VertexSceneTreeSearchOptionsPopover=({onSearchedSceneTreeColumnsChange:t,onSearchForExactMatchChange:a})=>{const s=useSceneTreeSearchActions(),i=n.useRecoilValue(rn),l=n.useRecoilValue(Rn),r=n.useRecoilValue(In),c=n.useRecoilValue(An),u=n.useRecoilValue(Pn),d=n.useRecoilValue(bn),{element:m,callback:p}=useCallbackRef(),{open:h,position:f,direction:g,handleOpen:v,handleClose:b}=useOpenColumnPopover({buttonElement:m,horizontalOffset:40}),S=g===jn.LEFT?"left-end":"right-start",updateSearch=e=>{if(c){const t=r.length>0?r:[...d,fn.metadataKeyName];null==i||i.filterItems(c,{columns:t,exactMatch:e})}};return e.jsxs(e.Fragment,{children:[e.jsx(o.VertexTooltip,{content:"Search Options",placement:"top",children:e.jsx(o.VertexIconButton,{"data-testid":"scene-tree-search-options-popover-button",ref:p,iconName:"gear",iconSize:"sm",onClick:()=>{v()}})}),e.jsx(o.VertexPopover,{"data-testid":"scene-tree-search-options-popover",open:h,backdrop:!1,position:f,resizeBehavior:"fixed",placement:S,className:"z-popover",children:e.jsxs("div",{className:Ce("flex flex-col bg-white border border-neutral-300 rounded",{hidden:!h}),children:[e.jsxs("div",{className:"flex items-center text-[0.875rem] p-3 border-b border-neutral-300 pb-2",children:[e.jsx("div",{className:"pr-2 text-[0.875rem] whitespace-nowrap",children:"Column Properties Search"}),e.jsx(o.VertexIconButton,{className:"ml-auto",iconName:"close",iconSize:"sm",onClick:()=>{b()}})]}),e.jsxs("div",{className:"max-h-64 p-3 overflow-y-auto",children:[e.jsx("div",{className:"text-[0.875rem] pb-2 pr-2",children:"Select properties to perform the search on:"}),e.jsx(VertexSceneTreeMetadataCheck,{checked:l,disabled:0===r.length||r.every((e=>e===fn.metadataKeyName)),onChange:async e=>{await s.updateMetadataSearchAfterSearchKeysChange(fn.metadataKeyName,e,d,c),null==t||t()},children:fn.label},fn.metadataKeyName),d.map((n=>e.jsx(VertexSceneTreeMetadataCheck,{checked:r.includes(n),disabled:r.length>0&&r.every((e=>e===n)),onChange:async e=>{await s.updateMetadataSearchAfterSearchKeysChange(n,e,d,c),null==t||t()},children:n},n)))]}),e.jsxs("div",{className:"flex p-3 border-t border-neutral-300",children:[e.jsx(o.VertexToggle,{className:"flex items-center","data-testid":"filter-exact-match-toggle",variant:"switch",checked:u,onValueChanged:async e=>{s.setMetadataSearchExactMatch(e.detail),null==a||a(),updateSearch(e.detail)}}),e.jsx("span",{className:"pl-4 text-[0.875rem] text-neutral-800",children:"Return only exact matches"})]})]})})]})},VertexSceneTreeSearchBar=({onSearch:t,onClearSearch:a,onExitSearchMode:s,onSearchedSceneTreeColumnsChange:i,onSearchForExactMatchChange:r,children:c})=>{const d=useSceneTreeActions(),m=n.useRecoilValue(rn),[p,h]=n.useRecoilState(Tn),[f,g]=n.useRecoilState(An);useSceneTreeSearch({sceneTreeElement:null!=m?m:null});const{element:v,callback:b}=useCallbackRef(),S=null==f||""===f,w=S?"Exit Search":"Clear Search";return u.useEffect((()=>{p&&(null==v||v.setFocus())}),[v,p]),e.jsxs("div",{className:"flex w-full py-3 px-2",children:[e.jsx(l.VertexSceneTreeSearch,{"data-testid":"scene-tree-search-bar",ref:b,controller:null==m?void 0:m.controller,onBlur:()=>{S&&(h(!1),null==s||s())},onSearch:()=>{g(null==v?void 0:v.value),null==t||t(null==v?void 0:v.value)},children:c}),e.jsx("div",{className:"self-center px-1",onPointerDown:e=>{e.preventDefault()},children:e.jsx(VertexSceneTreeSearchOptionsPopover,{onSearchedSceneTreeColumnsChange:i,onSearchForExactMatchChange:r})}),e.jsx(o.VertexTooltip,{className:"self-center pr-1",content:w,children:e.jsx(o.VertexIconButton,{"data-testid":"scene-tree-search-close-button",iconName:"close-circle-fill",iconSize:"sm",variant:"plain",onPointerDown:e=>{e.preventDefault()},onClick:async()=>{S?(h(!1),await d.flyToFirstSelectedItem(),null==s||s()):(await(null==v?void 0:v.clear()),await(null==v?void 0:v.setFocus()),g(void 0),null==a||a())}})})]})};function VertexToolbarDivider(){return e.jsx("div",{"data-testid":"toolbar-divider",className:"h-6 w-px bg-neutral-300 mx-1"})}const VertexSceneTreeSearchInformationForToolbar=()=>{const t=useSelectionActions(),a=n.useRecoilValue(rn),s=n.useRecoilValue(An),i=n.useRecoilValue(En),l=undefined,r=undefined,c=`${i>=1e3?`${i}+`:`${i}`} ${1===i?"result":"results"}`;return e.jsxs(e.Fragment,{children:[e.jsx(VertexToolbarDivider,{}),e.jsxs("div",{className:"flex flex-row items-center overflow-hidden",children:[e.jsx("div",{className:"px-2 text-[0.8125rem] leading-4 text-neutral-900 truncate","data-testid":"search-result-info",children:`${c}`}),e.jsx(o.VertexTooltip,{className:"w-auto",content:"Select Results",placement:"top",children:e.jsx(o.VertexButton,{className:"h-6 rounded cursor-pointer","data-testid":"select-search-results-button",color:"secondary",variant:"text",size:"sm",onClick:async()=>{null!=a&&null!=s&&(await a.selectFilteredItems(s),t.toggleLastSelectWasMultiSelect(!0))},children:e.jsxs("div",{className:"flex h-6 items-center gap-1",children:[e.jsx(o.VertexIcon,{size:"sm",name:"check-circle"}),e.jsx("span",{className:"whitespace-nowrap",children:"Select Results"})]})})})]})]})},targetIsElement=(e,t)=>e instanceof Element&&e.tagName===t;function useRecoilRef({state:e}){const t=n.useRecoilCallback((({set:t})=>n=>{t(e,n)}),[]);return t}var Nn;function styleFromOptionalFont(e){return null!=e?{"--scene-tree-default-font-family":styleFromFontFace(e.fontFace),"--scene-tree-default-font-color":e.color}:{}}function styleFromOptionalBackgroundColors(e){const t=null==e?void 0:e.depthColors,n=null!=t?Object.keys(t).reduce(((e,n)=>Object.assign(Object.assign({},e),{[`--scene-tree-row-background-color-depth-${n}`]:t[parseInt(n)]})),{}):{};return null!=e?Object.assign(Object.assign({},n),{"--scene-tree-hovered-row-background-color":e.hovered,"--scene-tree-selected-row-background-color":e.selected,"--scene-tree-row-background-color":e.defaultColor}):{}}function styleFromFontFace(e){return e===Nn.ROBOTO_MONO?"var(--vertex-ui-font-family-monospace)":"var(--vertex-ui-font-family)"}!function(e){e.ROBOTO="ROBOTO",e.ROBOTO_MONO="ROBOTO_MONO"}(Nn||(Nn={}));const VertexEnterSceneTreeSearchModeButton=({onEnterSearchMode:t})=>{const a=n.useSetRecoilState(Tn);return e.jsx(o.VertexTooltip,{className:"flex ml-auto",content:"Scene Tree Search",children:e.jsx(o.VertexIconButton,{"data-testid":"enter-scene-tree-search-mode-button",iconName:"search",iconSize:"sm",onPointerDown:e=>{e.preventDefault()},onClick:()=>{a(!0),null==t||t()}})})},VertexSceneTreeSearch=({onEnterSearchMode:t,onExitSearchMode:a,onSearch:s,onClearSearch:o,onSearchedSceneTreeColumnsChange:i,onSearchForExactMatchChange:r,children:c})=>{const u=n.useRecoilValue(Tn);return e.jsxs(l.VertexSceneTreeToolbar,{className:"h-11 p-0 border-b border-neutral-300 box-content",slot:"header",children:[u&&e.jsx(VertexSceneTreeSearchBar,{onSearch:s,onClearSearch:o,onExitSearchMode:a,onSearchedSceneTreeColumnsChange:i,onSearchForExactMatchChange:r,children:c}),!u&&e.jsx("div",{className:"ml-auto mr-2",children:e.jsx(VertexEnterSceneTreeSearchModeButton,{onEnterSearchMode:t})})]})},VertexSceneTreeCollapseAll=()=>{const t=n.useRecoilValue(rn);return e.jsx(o.VertexTooltip,{className:"w-auto",content:"Collapse All",placement:"top",children:e.jsx(o.VertexIcon,{size:"sm",className:"h-6 w-6 hover:bg-neutral-300 rounded cursor-pointer","data-testid":"collapse-all-icon",name:"collapse-all",onClick:()=>{null==t||t.collapseAll()}})})},VertexSceneTreeExpandAll=()=>{const t=n.useRecoilValue(rn);return e.jsx(o.VertexTooltip,{className:"w-auto",content:"Expand All",placement:"top",children:e.jsx(o.VertexIcon,{size:"sm","data-testid":"expand-all-icon",className:"h-6 w-6 hover:bg-neutral-300 rounded cursor-pointer",name:"expand-all",onClick:()=>{null==t||t.expandAll()}})})},VertexSceneTreeToolbar=({onVisibleSceneTreeColumnsChange:t})=>{const a=n.useRecoilValue(An),s=null==a||""===a;return e.jsx(l.VertexSceneTreeToolbar,{className:"h-10 border-b border-neutral-300 box-border",children:e.jsxs("div",{className:"flex w-full text-neutral-700 items-center gap mx-2",children:[e.jsx(VertexSceneTreeExpandAll,{}),e.jsx(VertexSceneTreeCollapseAll,{}),!s&&e.jsx(VertexSceneTreeSearchInformationForToolbar,{}),e.jsx("div",{className:"ml-auto",children:e.jsx(VertexSceneTreeColumnPopover,{onVisibleSceneTreeColumnsChange:t})})]})})},VertexSceneTreeHeader=({onEnterSearchMode:t,onExitSearchMode:n,onSearch:a,onClearSearch:s,onVisibleSceneTreeColumnsChange:o,children:i})=>{const l=null!=i&&!1!==i;return e.jsx("div",{slot:"header",className:"flex flex-col",children:l?i:e.jsxs(e.Fragment,{children:[e.jsx(VertexSceneTreeSearch,{onEnterSearchMode:t,onExitSearchMode:n,onSearch:a,onClearSearch:s,children:e.jsx("div",{slot:"clear-icon"})}),e.jsx(VertexSceneTreeToolbar,{onVisibleSceneTreeColumnsChange:o})]})})},VertexSceneTreeTableLayout=t=>{const a=n.useRecoilValue(Sn),s=n.useRecoilValue(wn),o=[];return e.jsx(l.VertexSceneTreeTableLayout,Object.assign({"data-testid":"scene-tree-table-layout"},t,{children:s.map(((t,n)=>{var i;const r=a[t],c=null!==(i=o[n])&&void 0!==i?i:r.initialWidth;return e.jsxs(l.VertexSceneTreeTableColumn,{"data-testid":`scene-tree-table-column-${n}`,initialWidth:c,minWidth:r.minWidth,children:[e.jsx("template",{slot:"header",dangerouslySetInnerHTML:{__html:`\n <div class="text-sm text-neutral-800 my-2">\n <div class="${Ce("truncate",{"pl-2":0===n,"pr-2":n===s.length-1})}">\n ${r.label}\n </div>\n </div>\n `}}),e.jsx("template",{dangerouslySetInnerHTML:{__html:`\n <vertex-scene-tree-table-cell\n prop:value="${r.binding}"\n prop:selection-handler="{{row.data.handleSelection}}"\n prop:expansion-handler="{{row.data.handleExpansion}}"\n prop:visibility-handler="{{row.data.handleVisibility}}"\n ${0===n?"expand-toggle":""}\n ${n===s.length-1?"isolate-button visibility-toggle":""}>\n <div class="flex items-center gap-2">\n <vertex-tooltip \n class="truncate" \n prop:content="${null!=r.binding?r.binding:"--"}" \n placement="${n!==s.length-1?"right":"top"}">\n <div class="flex items-center w-full">\n <div class="truncate">${r.binding}</div>\n </div>\n </vertex-tooltip>\n </div>\n \n\n <div slot="placeholder" class="flex items-center w-full truncate">\n <div> -- </div>\n </div>\n </vertex-scene-tree-table-cell>\n `}})]},r.label)}))}))},VertexSceneTree=t=>{var{id:s,font:o,backgroundColors:i,children:r,style:c,onPointerDown:u,onClick:d,onToggleSelection:m,onToggleExpansion:p,onToggleVisibility:h,className:f,rowData:g}=t,v=__rest(t,["id","font","backgroundColors","children","style","onPointerDown","onClick","onToggleSelection","onToggleExpansion","onToggleVisibility","className","rowData"]);const b=useSceneTreeActions(),S=useSelectionActions(),w=n.useRecoilValue(hn),V=n.useRecoilValue(M),C=n.useRecoilValue(In),j=n.useRecoilValue(Pn),T=n.useRecoilValue(An),k=null==T||""===T,A=useRecoilRef({state:rn}),P=null!=r&&!1!==r,wrappedExpansionHandler=(e,t,n)=>{b.toggleExpansion(e,t,n),null==p||p(e,t,n)},wrappedSelectionHandler=(e,t,n)=>{b.toggleSelection(e,t,n),null==m||m(e,t,n)},wrappedVisibilityHandler=(e,t,n)=>{b.toggleVisibility(e,t,n),null==h||h(e,t,n)},handleClick=e=>{e.altKey&&b.flyToRow(e.clientY),null==d||d(e)},handlePointerDown=e=>{targetIsElement(e.target,"VERTEX-SCENE-TREE-TABLE-COLUMN")&&S.clearSelection(),null==u||u(e)},E=n.useSetRecoilState(cn),handleFirstRowRendered=e=>{var t;E(e.target.controller),null===(t=null==v?void 0:v.onFirstRowRendered)||void 0===t||t.call(v,e)},I=a.useMemo((()=>({metadataSearchKeys:C,exactMatch:j})),[C,j]);return e.jsx("div",{className:Ce("flex flex-col w-full h-full",f),children:e.jsx("div",{className:"flex group h-full",children:e.jsx(l.VertexSceneTree,Object.assign({id:null!=s?s:"vertex-scene-tree","data-testid":"vertex-scene-tree",config:w,ref:A,className:Ce("flex-1",{filtered:!k}),style:Object.assign(Object.assign(Object.assign({},styleFromOptionalFont(o)),styleFromOptionalBackgroundColors(i)),c),onConnectionError:e=>{logger_error("Scene Tree Connection Error: ",e.detail)},viewer:V,onPointerDown:handlePointerDown,onClick:handleClick,rowData:e=>{var t;const n=null!==(t=null==g?void 0:g(e))&&void 0!==t?t:{};return Object.assign({handleExpansion:wrappedExpansionHandler,handleSelection:wrappedSelectionHandler,handleVisibility:wrappedVisibilityHandler},n)},searchOptions:I},v,{onFirstRowRendered:handleFirstRowRendered,children:P?r:e.jsxs(e.Fragment,{children:[e.jsx(VertexSceneTreeHeader,{}),e.jsx(VertexSceneTreeTableLayout,{}),e.jsx(VertexSceneTreeContextMenu,{})]})}))})})},VertexDecimalPlaceSelector=({onApply:t})=>{const[a,s]=n.useRecoilState(yt);return e.jsxs(o.VertexSelect,{"data-testid":"decimal-place-select",className:"w-24",value:a,onOptionChanged:e=>{s(e.detail),null==t||t(e.detail)},children:[e.jsx("div",{className:"py-1.5 px-3",children:"0"}),e.jsx("div",{className:"py-1.5 px-3",children:"1"}),e.jsx("div",{className:"py-1.5 px-3",children:"2"}),e.jsx("div",{className:"py-1.5 px-3",children:"3"})]})},VertexLengthUnitSelector=({onApply:t})=>{const[a,s]=n.useRecoilState(vt);return e.jsxs(o.VertexSelect,{"data-testid":"length-unit-select",className:"w-40",value:a,onOptionChanged:e=>{s(e.detail),null==t||t(e.detail)},children:[e.jsx("div",{"data-value":"cm",className:"py-1.5 px-3",children:"centimeters"}),e.jsx("div",{"data-value":"mm",className:"py-1.5 px-3",children:"millimeters"}),e.jsx("div",{"data-value":"m",className:"py-1.5 px-3",children:"meters"}),e.jsx("div",{"data-value":"in",className:"py-1.5 px-3",children:"inches"}),e.jsx("div",{"data-value":"ft",className:"py-1.5 px-3",children:"feet"})]})};function VertexUnitsControls({onUnitChange:t,onDecimalPlaceChange:n}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Length Unit"}),e.jsx(VertexLengthUnitSelector,{onApply:t})]}),e.jsxs("div",{children:[e.jsx("div",{className:"pt-2 pb-2 text-sm text-neutral-700",children:"Decimals"}),e.jsx(VertexDecimalPlaceSelector,{onApply:n})]})]})}function VertexUnitsPanelSection({onUnitChange:t,onDecimalPlaceChange:n}){return e.jsx(PanelSection,{header:e.jsx("div",{className:"flex items-center text-base",children:"Units"}),children:e.jsx(VertexUnitsControls,{onUnitChange:t,onDecimalPlaceChange:n})})}const On=n.atom({key:"openedPanelActivePrimaryLeft",default:void 0}),Mn=n.atom({key:"openedPanelActivePrimaryRight",default:void 0});function usePanelActions(){return{openPrimary:useActionCallback((({set:e})=>(t,n)=>{e("left"===n?On:Mn,t)})),closePrimary:useActionCallback((({set:e})=>t=>{e("left"===t?On:Mn,void 0)}))}}function childrenAsArray(e){return Array.isArray(e)?e:[e]}function filterChildElements(e,t){return childrenAsArray(e).filter((e=>a.isValidElement(e)&&e.type===t))}function DefaultAppearancePanel(){return e.jsxs("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:[e.jsx(VertexMaterialPanelSection,{}),e.jsx(VertexGhostingPanelSection,{}),e.jsx(VertexFeatureEdgesPanelSection,{}),e.jsx(VertexViewerBackgroundPanelSection,{}),e.jsx(VertexSelectionHighlightingPanelSection,{}),e.jsx(VertexCrossSectionAppearancePanelSection,{})]})}function DefaultSettingsPanel(){return e.jsx("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:e.jsx(VertexUnitsPanelSection,{})})}const VertexTransformClear=({onClear:t,onClearAll:s})=>{const i=useTransformActions(),l=useCacheableLoadable(gt),r=n.useRecoilValue(dt),c=useCacheableLoadable(Et(null!=r?r:"")),u=a.useMemo((()=>{var e;const t=null===(e=l.data)||void 0===e?void 0:e.some((e=>{var t;return null!=(null===(t=null==e?void 0:e.override)||void 0===t?void 0:t.transform)})),n=null!=c.data;return t||n}),[l,c]);return e.jsx("div",{className:"ml-auto",children:e.jsxs(ResetButton,{id:"transforms",tooltip:"Clear Transforms",children:[e.jsx("div",{className:"pt-1"}),e.jsx(o.VertexMenuItem,{"data-testid":"clear-selected-transforms",onClick:async()=>{await i.clearSelectedTransforms(),null==t||t()},disabled:!u,children:"Clear selected transforms"}),e.jsx(o.VertexMenuItem,{"data-testid":"clear-all-transforms",onClick:async()=>{await i.clearAllTransforms(),null==s||s()},children:"Clear all transforms"})]})})},VertexTransformNumericField=({bottomLabel:t,value:s,step:o,min:i,max:l,disabled:r,testId:c,onBlur:u,onInput:d,onChange:m})=>{const p=a.useRef(null),h=n.useRecoilValue(yt),[f,g]=a.useState(!0);a.useEffect((()=>{var e;const t=null!=p.current&&Number.isNaN(p.current.valueAsNumber),n=f||t;null!=p.current&&n?p.current.value=null!==(e=null==s?void 0:s.toFixed(Number(h)))&&void 0!==e?e:"":g(!0)}),[s]);const v=a.useCallback((e=>{g(!1),null==m||m(e)}),[g,m]),b=a.useCallback((e=>{g(!0),null==u||u(e),null!=p.current&&null!=s&&(p.current.value=s.toFixed(Number(h)))}),[u,s,g]);return e.jsxs("div",{children:[e.jsx("div",{className:"truncate rounded-md w-full",children:e.jsx("input",{ref:p,className:"w-full truncate border border-neutral-400 rounded-md px-2 py-1.5 hover:border-neutral-500 focus:border-neutral-500 focus:outline-none",type:"number",step:o,min:i,max:l,"data-testid":c,disabled:r,defaultValue:Number.isNaN(s)?"":null==s?void 0:s.toFixed(Number(h)),onBlur:b,onInput:d,onChange:v})}),null!=t&&e.jsx("div",{className:"flex justify-center items-center pointer-events-none text-neutral-500",children:e.jsx("span",{children:t})})]})},VertexTransformInputs=({onUpdateTransform:t})=>{const a=n.useRecoilValue(vt),s=n.useRecoilValue(ct),o=n.useRecoilValue(rt),i=s||o,l=n.useRecoilValue(dt),{transform:r,error:c,update:u}=useEditItemTransform(l),d=i?void 0:r,m=useDebouncedCallback((async e=>{await u(e),null==t||t(e)}),50);function updateTransform(e){return t=>{if(null!=d){const n=parseFloat(t.currentTarget.value);Number.isNaN(n)||null==m||m(Object.assign(Object.assign({},d),e(n,d)))}}}function updatePosition(e){return updateTransform(((t,n)=>({position:Object.assign(Object.assign({},n.position),e(t))})))}function updateRotation(e){return updateTransform(((t,n)=>({rotation:Object.assign(Object.assign({},n.rotation),e(t))})))}function updateScale(){return updateTransform((e=>e>0?{scale:e}:{}))}function updateToDefaultValueIfInvalid(e,t){return n=>{const a=parseFloat(n.currentTarget.value),s=undefined;(isNaN(a)||!!(null==t?void 0:t(a)))&&null!=d&&m(A.defaults(e,d))}}return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 text-[0.8125rem]",children:[e.jsx("span",{className:"flex w-full items-center mt-3 mb-1",children:"Position"}),e.jsxs("div",{className:"flex flex-wrap w-full gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"X"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"position-x",value:null!=d?d.position.x:void 0,bottomLabel:a,disabled:null==d,onChange:updatePosition((e=>({x:e}))),onBlur:updateToDefaultValueIfInvalid({position:{x:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Y"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"position-y",value:null==d?void 0:d.position.y,bottomLabel:a,disabled:null==d,onChange:updatePosition((e=>({y:e}))),onBlur:updateToDefaultValueIfInvalid({position:{y:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Z"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"position-z",value:null==d?void 0:d.position.z,bottomLabel:a,disabled:null==d,onChange:updatePosition((e=>({z:e}))),onBlur:updateToDefaultValueIfInvalid({position:{z:0}})})})]})]})]}),e.jsxs("div",{className:"mb-2 text-[0.8125rem]",children:[e.jsx("span",{className:"flex w-full items-center mt-3 mb-1",children:"Rotation"}),e.jsxs("div",{className:"flex flex-wrap w-full gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"X"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"rotation-x",value:null==d?void 0:d.rotation.x,bottomLabel:"deg",disabled:null==d,onChange:updateRotation((e=>({x:e}))),onBlur:updateToDefaultValueIfInvalid({rotation:{x:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Y"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"rotation-y",value:null==d?void 0:d.rotation.y,bottomLabel:"deg",disabled:null==d,onChange:updateRotation((e=>({y:e}))),onBlur:updateToDefaultValueIfInvalid({rotation:{y:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Z"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"rotation-z",value:null==d?void 0:d.rotation.z,bottomLabel:"deg",disabled:null==d,onChange:updateRotation((e=>({z:e}))),onBlur:updateToDefaultValueIfInvalid({rotation:{z:0}})})})]})]})]}),e.jsxs("div",{className:"mb-2 text-[0.8125rem]",children:[e.jsx("span",{className:"flex w-full items-center mt-3 mb-1",children:"Scale"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"scale",value:null==d?void 0:d.scale,step:.1,min:.1,disabled:null==d,onChange:updateScale(),onBlur:updateToDefaultValueIfInvalid({scale:1},(e=>e<=0))})}),i&&e.jsx("div",{className:"bg-orange-100 rounded px-3 py-2 mt-6 mb-2",children:"Input based part transformation is not yet supported for multiple parts."}),null!=c&&e.jsx("div",{className:"bg-red-100 rounded px-3 py-2 mt-6 mb-2",children:"There was a problem retrieving data. Try selecting a different part."})]})]})},VertexTransformManipulatorToggle=({onToggleTransformsManipulator:t})=>{const a=useTransformActions(),s=n.useRecoilValue(Vt),i=n.useSetRecoilState(Rt);return e.jsx(o.VertexToggle,{className:"flex items-center","data-testid":"transform-widget-toggle",variant:"switch",checked:s,onValueChanged:async()=>{s?(a.disableTransformWidget(),null==t||t(!1)):(i("world"),await a.enableTransformWidget(),null==t||t(!0))}})};function VertexTransformControls({onToggleTransformsManipulator:t,onUpdateTransform:n}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center py-3",children:[e.jsx(VertexTransformManipulatorToggle,{onToggleTransformsManipulator:t}),e.jsx("span",{className:"pl-4 text-[0.8125rem] text-neutral-700",children:"Enable manipulator"})]}),e.jsx(VertexTransformInputs,{onUpdateTransform:n})]})}function VertexTransformPanelSection({onClearTransforms:t,onClearAllTransforms:n,onToggleTransformsManipulator:a,onUpdateTransform:s}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Manual Part Transforms",e.jsx(VertexTransformClear,{onClear:t,onClearAll:n})]}),children:e.jsx(VertexTransformControls,{onToggleTransformsManipulator:a,onUpdateTransform:s})})}function DefaultTransformsPanel(){return e.jsx("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:e.jsx(VertexTransformPanelSection,{})})}const Ln="Appearance",Bn="Settings",_n="Transforms",ViewerRightPanelHeader=({additionalHeaderMap:t})=>{const a=undefined,s=getHeading(n.useRecoilValue(Mn),t);return e.jsx("div",{className:"flex flex-col w-full items-center z-overlay pointer-events-none md:pointer-events-auto py-3 px-4 border-b border-neutral-300",children:e.jsx("div",{className:"items-center w-full leading-6 text-md align-center font-medium text-neutral-800",children:s})})};function getHeading(e,t={}){switch(e){case"appearance":return Ln;case"settings":return Bn;case"transforms":return _n;default:const n=null!=e?t[e]:void 0;return null!=n?n:"None"}}function VertexViewerRightOpenedPanel({children:t}){const s=n.useRecoilValue(Mn),o=a.useMemo((()=>filterChildElements(t,CustomPanelContent)),[t]),i=a.useMemo((()=>o.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.props.panelName]:t.props.panelTitle})),{})),[o]),l=a.useMemo((()=>["appearance","settings","transforms",...o.map((e=>e.props.panelName))]),[o]);return e.jsx(e.Fragment,{children:null!=s&&l.includes(s)&&e.jsxs(VertexResizableContent,{displayShadow:!0,heading:e.jsx(ViewerRightPanelHeader,{additionalHeaderMap:i}),placement:"right",children:["appearance"===s&&e.jsx(DefaultAppearancePanel,{}),"transforms"===s&&e.jsx(DefaultTransformsPanel,{}),"settings"===s&&e.jsx(DefaultSettingsPanel,{}),t]})})}function CustomPanelContent({panelName:t,children:a}){const s=n.useRecoilValue(Mn);return e.jsx(e.Fragment,{children:s===t&&a})}function Sidebar({children:t}){return e.jsx("div",{className:"pointer-events-auto flex flex-col items-center w-full border-neutral-300 py-2",children:t})}function SidebarIcon({name:t,iconName:n,active:s,responsive:i,disabled:l,content:r,tooltipPlacement:c,children:u,onSelect:d,onDeselect:m}){return e.jsx("div",{className:Ce({"text-[var(--vertex-ui-blue-700)]":s===t&&!l,"text-neutral-700 hover:text-neutral-800":s!==t&&!l,"cursor-pointer hover:bg-neutral-200":!l,"text-neutral-400":l,"rounded-full md:p-3":i,"p-3":!i&&null==u,"px-3 py-1":null!=u}),"data-testid":`${t}-sidebar-panel`,onClick:()=>{l||(s===t?m():d())},children:e.jsxs(o.VertexTooltip,{placement:null!=c?c:void 0,content:a.isValidElement(r)?void 0:r,children:[e.jsx("div",{slot:"content",children:r}),e.jsx("div",{className:"flex flex-col",children:null!=u?u:e.jsx(o.VertexIcon,{name:n})})]})})}function VertexViewerRightSidebar({children:t}){const a=usePanelActions(),s=n.useRecoilValue(Mn);return e.jsx("div",{className:"flex flex-col flex-shrink-0 items-center relative border-neutral-300 border-l bg-white h-full top-0 min-w-12 w-12",children:e.jsxs(Sidebar,{children:[t,e.jsx(SidebarIcon,{name:"appearance",active:s,iconName:"adjustments",tooltipPlacement:"right",content:"Appearance",onSelect:()=>{a.openPrimary("appearance","right")},onDeselect:()=>a.closePrimary("right")}),e.jsx(SidebarIcon,{name:"transforms",active:s,iconName:"show-only-nearby",tooltipPlacement:"right",content:"Transforms",onSelect:()=>{a.openPrimary("transforms","right")},onDeselect:()=>a.closePrimary("right")}),e.jsx(SidebarIcon,{name:"settings",active:s,iconName:"gear",tooltipPlacement:"right",content:"Settings",onSelect:()=>{a.openPrimary("settings","right")},onDeselect:()=>a.closePrimary("right")})]})})}function CustomPanelIcon(t){const a=usePanelActions(),s=n.useRecoilValue(Mn),{panelName:o,tooltipContent:i,iconName:l}=t,r=__rest(t,["panelName","tooltipContent","iconName"]);if(null==l&&null==r.children)throw new Error('CustomPanelIcon must contain either a Vertex "iconName" or custom "children"');return e.jsx(SidebarIcon,Object.assign({},r,{name:o,iconName:null!=l?l:"help",active:s,content:i,onSelect:()=>{a.openPrimary(t.panelName,"right")},onDeselect:()=>{a.closePrimary("right")}}))}VertexViewerRightOpenedPanel.CustomPanelContent=CustomPanelContent,VertexViewerRightSidebar.CustomPanelIcon=CustomPanelIcon;const VertexPopupButton=t=>{var{open:n,children:a}=t,s=__rest(t,["open","children"]);const i=a.find((e=>e.type===Anchor)),l=a.filter((e=>e.type!==Anchor));return null==i?e.jsx(e.Fragment,{}):e.jsxs(o.VertexPopover,Object.assign({className:"flex",placement:"top",backdrop:!1,open:asBooleanAttribute(n)},s,{children:[i,e.jsx("div",{className:Ce("flex mb-1.5",{hidden:!n}),"data-testid":"align-plane-popover-menu",children:l})]}))},Anchor=({tooltipContent:t,children:n})=>e.jsx("div",{slot:"anchor",children:e.jsx(o.VertexTooltip,{className:"cursor-pointer",content:t,children:n})});function VertexViewerCrossSectionAlignmentPopoverMenu(){const t=useCrossSectioningActions(),a=n.useRecoilValue(de),s=n.useRecoilValue(ne),getBaseIcon=()=>`align-to-${null==s?void 0:s.mode}`;return useStackKeyBinding({id:"CrossSectionAlignment",keyBind:"Escape",fn:t.cancelCurrentHit,addPredicate:()=>{var e;return null!==(e=null==s?void 0:s.hitPending)&&void 0!==e&&e},cancelPredicate:()=>!(null==s?void 0:s.hitPending)},[null==s?void 0:s.hitPending]),e.jsxs(VertexPopupButton,{"data-testid":"section-alignment-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(a),onDismissed:t.closeAlignmentTools,children:[e.jsx(VertexPopupButton.Anchor,{tooltipContent:"Section Alignment",children:e.jsx(o.VertexIconButton,{"data-testid":"section-alignment-icon-button",iconName:getBaseIcon(),iconColor:"secondary",onClick:a?t.closeAlignmentTools:t.openAlignmentTools,children:e.jsx(o.VertexIcon,{"data-testid":"section-alignment-icon-chevron",name:"chevron-up",size:"sm"})})}),e.jsxs(l.VertexViewerToolbarGroup,{direction:"vertical",className:"flex justify-evenly items-center py-1 my-1 ring-1 ring-neutral-200 rounded bg-neutral-100 opacity-95",children:[e.jsx(o.VertexIconButton,{iconColor:"secondary",onClick:()=>t.updateAlignment("global"),className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2","data-testid":"section-alignment-align-global",iconName:"align-to-global",variant:"plain",children:e.jsx("div",{className:"text-base ml-2",children:"Align to Global"})}),e.jsx(o.VertexIconButton,{iconColor:"secondary",onClick:()=>t.updateAlignment("surface"),className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2","data-testid":"section-alignment-align-surface",iconName:"align-to-surface",variant:"plain",children:e.jsx("div",{className:"text-base ml-2",children:"Align to Surface"})})]})]})}function VertexViewerCrossSectionAxisPopoverMenu(){const t=useCrossSectioningActions(),s=n.useRecoilValue(me),i=n.useRecoilValue(te),r=n.useRecoilValueLoadable(ie),c=a.useMemo((()=>{const e=i.length>0&&"hasValue"===r.state?axis(i[0],xAxis(r.contents),yAxis(r.contents),zAxis(r.contents)):"x";return null!=e?`axis-${e}`:"axis-x"}),[r.state,r.contents,i]);return e.jsxs(VertexPopupButton,{"data-testid":"align-plane-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(s),onDismissed:t.closeAxisTools,children:[e.jsx(VertexPopupButton.Anchor,{tooltipContent:"Align Plane",children:e.jsx(o.VertexIconButton,{onClick:s?t.closeAxisTools:t.openAxisTools,iconName:c,"data-testid":"align-plane-icon",iconColor:"secondary",children:e.jsx(o.VertexIcon,{"data-testid":"align-plane-icon-chevron",name:"chevron-up",size:"sm"})})}),e.jsxs(l.VertexViewerToolbarGroup,{direction:"vertical",className:"flex justify-evenly items-center py-1 my-1 ring-1 ring-neutral-200 rounded bg-neutral-100 opacity-95",children:[e.jsx(o.VertexIconButton,{"data-testid":"align-plane-x-axis-button",className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2",onClick:()=>t.updateAxis("x"),variant:"plain",iconColor:"secondary",iconName:"axis-x",children:e.jsx("div",{className:"text-base ml-2",children:"X-axis Plane"})}),e.jsx(o.VertexIconButton,{className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2",variant:"plain",iconColor:"secondary",iconName:"axis-y","data-testid":"align-plane-y-axis-button",onClick:()=>t.updateAxis("y"),children:e.jsx("div",{className:"text-base ml-2",children:"Y-axis Plane"})}),e.jsx(o.VertexIconButton,{"data-testid":"align-plane-z-axis-button",className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2",onClick:()=>t.updateAxis("z"),variant:"plain",iconColor:"secondary",iconName:"axis-z",children:e.jsx("div",{className:"text-base ml-2",children:"Z-axis Plane"})})]})]})}function VertexViewerCrossSectionOffsetStepper({offset:t,onOffsetChange:s}){const i=n.useRecoilValue(vt),l=n.useRecoilValue(yt),[r,c]=a.useState(convertTo(t,i));a.useEffect((()=>{c(convertTo(t,i))}),[i,t]);const u=createDistanceFormatter(i,parseInt(l,10)),handleIncrementalUpdate=e=>{const t=convertFrom(r+e,i);s(t)},handleSubmit=e=>{e.preventDefault(),s(convertFrom(r,i))},handleBlur=()=>{s(convertFrom(r,i))};return e.jsx(o.VertexTooltip,{content:"Plane Offset",children:e.jsx("form",{"data-testid":"cross-section-stepper-form",onSubmit:handleSubmit,children:e.jsxs(o.VertexTextfield,{"data-testid":"cross-section-stepper-input",className:"viewer-toolbar-input w-32 border-none ring-0 bg-white",type:"text",value:u(parseFloat(t.toFixed(3))),onInputInput:e=>{c(null!=e.detail.value?parseFloat(e.detail.value):t)},onBlur:handleBlur,children:[e.jsx("div",{"data-testid":"cross-section-stepper-decrement",className:"py-1 cursor-pointer",slot:"left",onClick:()=>handleIncrementalUpdate(-1),children:e.jsx(o.VertexIcon,{name:"chevron-left",size:"sm"})}),e.jsx("div",{"data-testid":"cross-section-stepper-increment",className:"py-1 cursor-pointer",slot:"right",onClick:()=>handleIncrementalUpdate(1),children:e.jsx(o.VertexIcon,{name:"chevron-right",size:"sm"})})]})})})}VertexPopupButton.Anchor=Anchor;const Dn=400;function VertexViewerCrossSectionPopupMenu(){const t=useCrossSectioningActions(),s=n.useRecoilValue(ue),i=n.useRecoilValueLoadable(re),r=n.useRecoilValueLoadable(ce),c=a.useRef(),u=a.useMemo((()=>"hasValue"===i.state?i.contents:Z),[i.state,i.contents]),d=a.useMemo((()=>"hasValue"===r.state?r.contents:0),[r.state,r.contents]),handleCrossSectionValueChange=e=>{clearTimeout(c.current),c.current=window.setTimeout((()=>{t.endInteraction()}),Dn),t.beginInteraction(),t.updatePlanes(e)};return e.jsxs(VertexPopupButton,{"data-testid":"cross-section-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(s),onDismissed:t.closeAdditionalTools,children:[e.jsx(VertexPopupButton.Anchor,{tooltipContent:"Section Tools",children:e.jsx("div",{className:"-ml-px py-1.5",children:e.jsx(o.VertexIcon,{"data-testid":"cross-section-popover-icon",name:"chevron-up",size:"sm",onClick:s?t.closeAdditionalTools:t.openAdditionalTools})})}),e.jsxs(l.VertexViewerToolbarGroup,{className:"relative bottom-3 flex justify-evenly items-center p-1 ring-1 ring-neutral-200 rounded bg-neutral-100 opacity-95",children:[e.jsx(VertexViewerCrossSectionAlignmentPopoverMenu,{}),e.jsx(o.VertexTooltip,{className:"w-auto",content:"Reverse",children:e.jsx(o.VertexIconButton,{iconName:"flip","data-testid":"viewer-toolbar-flip-button",onClick:t.flipPlanes,iconColor:"secondary"})}),e.jsx(o.VertexTooltip,{className:"w-auto",content:"Align View to Plane",children:e.jsx(o.VertexIconButton,{"data-testid":"viewer-toolbar-align-view-to-plane-button",iconName:"align-view-to-plane",onClick:t.alignViewToPlane,iconColor:"secondary"})}),e.jsx(VertexToolbarDivider,{}),e.jsx(VertexViewerCrossSectionAxisPopoverMenu,{}),e.jsx("div",{className:"w-52 mx-2",children:e.jsx(VertexSlider,{value:d,defaultValue:u.default,disabled:asBooleanAttribute("hasValue"!==i.state),min:u.min,max:u.max,step:.01,onChange:handleCrossSectionValueChange})}),e.jsx("div",{className:"px-4",children:e.jsx(VertexViewerCrossSectionOffsetStepper,{offset:"hasValue"===r.state?r.contents:0,onOffsetChange:handleCrossSectionValueChange})})]})]})}const VertexViewerCrossSectionButton=()=>{const t=useCrossSectioningActions(),a=n.useRecoilValue(J);return e.jsxs(e.Fragment,{children:[e.jsx(o.VertexTooltip,{content:a?"Hide Section":"Show Section",children:e.jsx(o.VertexIconButton,{"data-testid":"viewer-toolbar-cross-section-button",iconName:"cross-section",iconColor:a?"primary":"secondary",onClick:()=>a?t.disable():t.enable()})}),e.jsx(VertexViewerCrossSectionPopupMenu,{})]})},VertexFitAllButton=()=>{const t=n.useRecoilValue(M);return e.jsx(o.VertexTooltip,{content:"Fit All",children:e.jsx(o.VertexIconButton,{iconName:"fit-all",iconColor:"secondary","data-testid":"viewer-toolbar-fit-all-button",onClick:async()=>{const e=await(null==t?void 0:t.scene());await(null==e?void 0:e.camera().viewAll().render({animation:{milliseconds:500}}))}})})},VertexPanButton=()=>{const t=n.useRecoilValue(M),s=n.useRecoilValue(B),[i,l]=n.useRecoilState(D),[r,c]=n.useRecoilState(_);return a.useEffect((()=>{null!=t&&s&&c(t.getBaseInteractionHandler())}),[t,s,c]),e.jsx(o.VertexTooltip,{content:"Pan",children:e.jsx(o.VertexIconButton,{iconName:"pan",iconColor:"pan"===i?"primary":"secondary","data-testid":"viewer-toolbar-pan-button",onClick:async()=>{if(l("pan"),null!=r){const e=await r;null==e||e.setPrimaryInteractionType("pan")}}})})},VertexRotateButton=()=>{const t=n.useRecoilValue(M),s=n.useRecoilValue(B),[i,l]=n.useRecoilState(D),[r,c]=n.useRecoilState(_);return a.useEffect((()=>{null!=t&&s&&c(t.getBaseInteractionHandler())}),[t,s,c]),e.jsx(o.VertexTooltip,{content:"Rotate",children:e.jsx(o.VertexIconButton,{iconName:"rotate",iconColor:"rotate"===i?"primary":"secondary","data-testid":"viewer-toolbar-rotate-button",onClick:async()=>{if(l("rotate"),null!=r){const e=await r;null==e||e.setPrimaryInteractionType("rotate")}}})})},VertexZoomButton=()=>{const t=n.useRecoilValue(M),s=n.useRecoilValue(B),[i,l]=n.useRecoilState(D),[r,c]=n.useRecoilState(_);return a.useEffect((()=>{null!=t&&s&&c(t.getBaseInteractionHandler())}),[t,s,c]),e.jsx(o.VertexTooltip,{content:"Zoom",children:e.jsx(o.VertexIconButton,{iconName:"zoom",iconColor:"zoom"===i?"primary":"secondary","data-testid":"viewer-toolbar-zoom-button",onClick:async()=>{if(l("zoom"),null!=r){const e=await r;null==e||e.setPrimaryInteractionType("zoom")}}})})},DefaultToolbar=()=>e.jsx(l.VertexViewerToolbar,{placement:"bottom-center",children:e.jsxs(l.VertexViewerToolbarGroup,{className:"p-1 border border-neutral-200 rounded bg-neutral-100 opacity-95",children:[e.jsx(VertexRotateButton,{}),e.jsx(VertexPanButton,{}),e.jsx(VertexZoomButton,{}),e.jsx(VertexFitAllButton,{}),e.jsx(VertexToolbarDivider,{}),e.jsx(VertexBoxSelectionButton,{}),e.jsx(VertexToolbarDivider,{}),e.jsx(VertexViewerCrossSectionButton,{}),e.jsx(VertexToolbarDivider,{}),e.jsx(VertexPointToPointMeasurementTool,{}),e.jsx(VertexPreciseMeasurementTool,{})]})}),VertexToolbar=({children:t})=>{const n=null!=t&&!1!==t;return e.jsx(l.VertexViewerToolbar,{placement:"bottom-center",children:n?e.jsx(l.VertexViewerToolbarGroup,{className:"p-1 border border-neutral-200 rounded bg-neutral-100 opacity-95",children:t}):e.jsx(DefaultToolbar,{})})};function VertexTransformWidget({transformWidgetElement:t,supportUndo:s,onPositionChange:o,onRotationChange:i}){const r=useTransformActions(),c=n.useRecoilValue(At),u=n.useRecoilValue(Vt),d=n.useRecoilValue(Ct),m=n.useRecoilValue(kt),p=n.useRecoilValueLoadable(Tt),h=n.useRecoilValue(vt),f=n.useRecoilValue(yt),g=a.useMemo((()=>"hasValue"===p.state?p.contents:m),[p,m]),v=a.useMemo((()=>{const e=undefined;return u&&(null!=g||c)}),[u,g,c]);return e.jsx(e.Fragment,{children:v&&e.jsx(l.VertexViewerTransformWidget,{id:"transform-widget","data-testid":"viewer-transform-widget",ref:t,position:d,rotation:null!=d?g:void 0,decimalPlaces:parseInt(f,10),distanceUnit:toUnitType(h),EXPERIMENTAL_undoKeybindings:null==s||s,onInteractionStarted:()=>{r.disableSelectionSync(),r.setIsInteractivelyTransforming(!0)},onInteractionEnded:()=>{r.invalidateTransforms(),r.setIsInteractivelyTransforming(!1)},onPositionChanged:async e=>{await r.setTransformWidgetPosition(e.detail),null==o||o(e.detail)},onRotationChanged:e=>{r.setTransformWidgetOrientation(e.detail),null==i||i(e.detail)}})})}const VertexViewerSceneReset=({onReset:t})=>{const n=useCrossSectioningActions(),a=useSelectionActions(),s=useTransformActions(),i=useViewerSceneActions(),handleReset=async()=>{await n.disable(),await a.resetSelectionState(),s.clearTransformWidgetPosition(),await s.invalidateTransforms(),null==t||t(),await i.reset()};return e.jsx(o.VertexTooltip,{content:"Reset View",children:e.jsx(o.VertexIconButton,{iconName:"reset",className:"flex bg-white opacity-70 hover:opacity-100 text-neutral-900 hover:text-neutral-700 hover:bg-neutral-200 rounded p-1 cursor-pointer","data-testid":"viewer-reset-tool-button",onClick:handleReset,variant:"plain"})})};function useViewerFrameActions(){const e=useTransformActions();return{frameDrawn:useActionCallback((({set:t,snapshot:n})=>async a=>{const s=await n.getPromise(pt);t(U,a.detail.scene),t(pt,a.detail.scene.sceneViewSummary.selectedVisibleSummary),t(mt,s);const o=undefined;await n.getPromise(Vt)&&await e.syncToSelection()}))}}const VertexBoxSelectionTool=()=>{const{element:t,callback:a}=useCallbackRef(),s=useBoxSelectionActions(),o=useTransformActions(),i=n.useRecoilValue(Le);return u.useEffect((()=>{const e=whenComponentReady(t,(()=>{var e;return[null===(e=null==t?void 0:t.model)||void 0===e?void 0:e.onDragComplete((()=>{"clearAndSelect"===i&&(o.clearTransformWidgetOrientation(),o.clearTransformWidgetPosition(),o.enableSelectionSync())}))]}));return()=>{null==e||e.then((e=>{null==e||e.forEach((e=>null==e?void 0:e.dispose()))}))}}),[t,i]),useApplyKeyBinding({keyBind:"Shift",fn:u.useCallback((()=>s.setOperationType("select")),[]),off:u.useCallback((()=>s.setOperationType("clearAndSelect")),[])}),e.jsx(l.VertexViewerBoxQueryTool,{ref:a,"data-testid":"viewer-box-query-tool",operationType:i})};function VertexViewerCameraTypeMenu({open:t,onOpen:a,onDismiss:s,onCameraTypeChange:i}){const l=useViewerCameraActions(),r=n.useRecoilValue(K);return e.jsxs(o.VertexMenu,{"data-testid":"camera-types-popover",className:"flex",placement:"bottom-end",open:asBooleanAttribute(t),onMenuClosed:s,children:[e.jsx("div",{slot:"anchor",children:e.jsx("div",{className:Ce("flex bg-white hover:opacity-100 hover:text-neutral-700 hover:bg-neutral-200 rounded",{"opacity-70 text-neutral-900":!t,"opacity-100 text-neutral-700 bg-neutral-200":t}),children:e.jsx(o.VertexTooltip,{content:"Change View",children:e.jsx(o.VertexIconButton,{"data-testid":"set-camera-mode-option",className:"p-1 cursor-pointer",variant:"plain",onClick:a,iconName:"orthographic"===r?"cube-orthographic":"cube-perspective",children:e.jsx(o.VertexIcon,{"data-testid":"change-camera-type-icon-button",name:"chevron-down",size:"sm"})})})})}),e.jsxs("div",{className:"w-36",children:[e.jsx("div",{className:"pt-1"}),e.jsxs(o.VertexMenuItem,{"data-testid":"set-perspective-view",onClick:()=>{l.updateCameraType("perspective"),null==i||i("perspective")},children:[e.jsx(o.VertexIcon,{slot:"icon","data-testid":"set-perspective-view-icon",name:"cube-perspective",size:"sm",className:Ce({"text-[var(--vertex-ui-blue-700)]":"perspective"===r})}),e.jsx("div",{className:Ce("ml-2 items-center",{"text-[var(--vertex-ui-blue-700)]":"perspective"===r}),children:"Perspective"})]}),e.jsxs(o.VertexMenuItem,{"data-testid":"set-orthographic-view",onClick:()=>{l.updateCameraType("orthographic"),null==i||i("orthographic")},children:[e.jsx(o.VertexIcon,{slot:"icon","data-testid":"set-orthographic-view-icon",name:"cube-orthographic",size:"sm",className:Ce({"text-[var(--vertex-ui-blue-700)]":"orthographic"===r})}),e.jsx("div",{className:Ce("ml-2 items-center",{"text-[var(--vertex-ui-blue-700)]":"orthographic"===r}),children:"Orthographic"})]})]})]})}const VertexViewerViewCube=t=>{var{placement:n,children:s}=t,o=__rest(t,["placement","children"]);const i=Array.isArray(s)?s:[s],r=i.filter((e=>!a.isValidElement(e)||e.type!==l.VertexViewerViewCube)).filter((e=>null!=e&&!1!==e)),c=i.find((e=>a.isValidElement(e)&&e.type===l.VertexViewerViewCube)),[u,d]=a.useState(!1);return e.jsxs(l.VertexViewerToolbar,{direction:"vertical","data-testid":"view-cube-toolbar",placement:null!=n?n:"top-right",children:[null!=c?c:e.jsx(l.VertexViewerViewCube,Object.assign({className:"m-7"},o)),0===r.length?e.jsxs("div",{className:"flex items-center justify-center mt-3 gap-1",children:[e.jsx(VertexViewerSceneReset,{}),e.jsx(VertexViewerCameraTypeMenu,{open:u,onDismiss:()=>d(!1),onOpen:()=>d(!0)})]}):e.jsx("div",{className:"mt-3",children:r})]})},VertexViewer=t=>{var{id:s,className:o,disableSelection:i,onTap:r,onLongpress:c,onFrameDrawn:u,onSceneReady:d,viewerRefCallback:m,children:p}=t,h=__rest(t,["id","className","disableSelection","onTap","onLongpress","onFrameDrawn","onSceneReady","viewerRefCallback","children"]);const f=n.useRecoilValue(hn),g=useRecoilRef({state:M}),v=useViewerCameraActions(),b=useHitActions(),S=useSelectionActions(),w=useViewerFrameActions(),[V,C]=n.useRecoilState(B),j=n.useRecoilValue(K),T=n.useRecoilValue(ne),k=n.useRecoilValue(Me),A=n.useSetRecoilState(F),[P,E]=n.useRecoilState(L);a.useEffect((()=>{null!=s&&E(s)}),[s]);const I=n.useRecoilValue(dn),R=a.useMemo((()=>({opacity:I/100})),[I]),N=n.useRecoilValue(ke),O=n.useRecoilValue(Ae),_=a.useMemo((()=>({color:N,width:O})),[N,O]),D=n.useRecoilValue(Jt),H=n.useRecoilValue(nn),U=n.useRecoilValue(an),W=n.useRecoilValue(sn),G=a.useMemo((()=>({color:H,opacity:U/100,lineWidth:W})),[H,U,W]),$=n.useRecoilValue(Fe),q=null!=p&&!1!==p;return useKeyBindings(),useDefaultKeybindings(),e.jsxs(l.VertexViewer,Object.assign({id:P,"data-testid":"vertex-viewer",ref:null!=m?m:g,className:Ce("flex w-full h-full",o,{"cursor-crosshair":T.hitPending}),style:{"--viewer-background":D},config:f,cameraType:V?j:void 0,onCameraTypeChanged:e=>{V&&v.updateCameraType(e.detail)},phantom:R,featureLines:_,selectionHighlighting:G,featureMaps:$?"final":void 0,onTap:e=>{const t=[...i?[]:[S.selectCurrentHit]];b.tap(e,...t),null==r||r(e)},onLongpress:e=>{b.longPress(e),null==c||c(e)},onFrameDrawn:e=>{w.frameDrawn(e),null==u||u(e)},onSceneReady:async e=>{var t;if(!V){C(!0);const n=await(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.scene());A(null==n?void 0:n.sceneViewId)}null==d||d(e)}},h,{children:[k&&e.jsx(VertexBoxSelectionTool,{}),q?p:e.jsxs(e.Fragment,{children:[e.jsx(VertexViewerViewCube,{}),e.jsx(VertexToolbar,{}),e.jsx(VertexViewerContextMenu,{})]})]}))};function toSdkConfig(e){return isOnlyNetworkConfig(e)?{network:e}:e}function isOnlyNetworkConfig(e){const t=undefined;return null!=e.renderingHost}const VertexViewerToolkitEventListener=({onHitStateChange:t,onSelectionStateChange:s})=>{const o=n.useRecoilValue(_t),i=n.useRecoilValue(zt);return a.useEffect((()=>{null==t||t(o)}),[o,t]),a.useEffect((()=>{null==s||s(i)}),[i,s]),e.jsx(e.Fragment,{})},VertexViewerToolkitRoot=t=>{var{override:s,autoDefineCustomElements:o,children:i,config:l}=t,u=__rest(t,["override","autoDefineCustomElements","children","config"]);return a.useEffect((()=>{(null==o||o)&&(c.defineCustomElements(),r.defineCustomElements())}),[o]),e.jsx(n.RecoilRoot,{override:s,children:e.jsxs(e.Fragment,{children:[e.jsx(VertexViewerToolkitEventListener,Object.assign({},u)),e.jsx(VertexViewerToolkitRootConfig,{config:l,children:i})]})})},VertexViewerToolkitRootConfig=({config:t,children:s})=>{const o=n.useSetRecoilState(hn);return a.useEffect((()=>{const e=null!=t?toSdkConfig(t):void 0;o(e)}),[t,o]),e.jsx(e.Fragment,{children:s})};var zn=Object.freeze({__proto__:null,get AssemblyFontFace(){return Nn}});exports.CrossSection=Se,exports.Hits=Dt,exports.SceneTree=zn,exports.Selection=Ft,exports.VertexApplicationMessages=VertexApplicationMessages,exports.VertexBoxSelectionButton=VertexBoxSelectionButton,exports.VertexContextMenu=VertexContextMenu,exports.VertexCrossSectionAppearanceColorPicker=VertexCrossSectionAppearanceColorPicker,exports.VertexCrossSectionAppearanceControls=VertexCrossSectionAppearanceControls,exports.VertexCrossSectionAppearanceLineThicknessSlider=VertexCrossSectionAppearanceLineThicknessSlider,exports.VertexCrossSectionAppearancePanelSection=VertexCrossSectionAppearancePanelSection,exports.VertexCrossSectionAppearanceReset=VertexCrossSectionAppearanceReset,exports.VertexDecimalPlaceSelector=VertexDecimalPlaceSelector,exports.VertexFeatureEdgesColorPicker=VertexFeatureEdgesColorPicker,exports.VertexFeatureEdgesControls=VertexFeatureEdgesControls,exports.VertexFeatureEdgesPanelSection=VertexFeatureEdgesPanelSection,exports.VertexFeatureEdgesReset=VertexFeatureEdgesReset,exports.VertexFeatureEdgesThicknessSlider=VertexFeatureEdgesThicknessSlider,exports.VertexFitAllButton=VertexFitAllButton,exports.VertexFitSelectedMenuItem=VertexFitSelectedMenuItem,exports.VertexFlyToMenuItem=VertexFlyToMenuItem,exports.VertexGhostingControls=VertexGhostingControls,exports.VertexGhostingPanelSection=VertexGhostingPanelSection,exports.VertexHideAllMenuItem=VertexHideAllMenuItem,exports.VertexHidePartMenuItem=VertexHidePartMenuItem,exports.VertexHideSelectedMenuItem=VertexHideSelectedMenuItem,exports.VertexLengthUnitSelector=VertexLengthUnitSelector,exports.VertexMaterialControls=VertexMaterialControls,exports.VertexMaterialPanelSection=VertexMaterialPanelSection,exports.VertexMeasurementContextMenu=VertexMeasurementContextMenu,exports.VertexMeasurementDetails=VertexMeasurementDetails,exports.VertexPanButton=VertexPanButton,exports.VertexPointToPointMeasurement=VertexPointToPointMeasurement,exports.VertexPointToPointMeasurementTool=VertexPointToPointMeasurementTool,exports.VertexPreciseMeasurement=VertexPreciseMeasurement,exports.VertexPreciseMeasurementTool=VertexPreciseMeasurementTool,exports.VertexResizableContent=VertexResizableContent,exports.VertexRotateButton=VertexRotateButton,exports.VertexSceneItemGhostingClear=VertexSceneItemGhostingClear,exports.VertexSceneItemGhostingOpacitySlider=VertexSceneItemGhostingOpacitySlider,exports.VertexSceneItemGhostingToggle=VertexSceneItemGhostingToggle,exports.VertexSceneItemMaterialClear=VertexSceneItemMaterialClear,exports.VertexSceneItemMaterialColorPicker=VertexSceneItemMaterialColorPicker,exports.VertexSceneItemMaterialOpacitySlider=VertexSceneItemMaterialOpacitySlider,exports.VertexSceneTree=VertexSceneTree,exports.VertexSceneTreeColumnPopover=VertexSceneTreeColumnPopover,exports.VertexSceneTreeContextMenu=VertexSceneTreeContextMenu,exports.VertexSceneTreeHeader=VertexSceneTreeHeader,exports.VertexSceneTreeSearchBar=VertexSceneTreeSearchBar,exports.VertexSceneTreeSearchInformationForToolbar=VertexSceneTreeSearchInformationForToolbar,exports.VertexSceneTreeSearchOptionsPopover=VertexSceneTreeSearchOptionsPopover,exports.VertexSceneTreeTableLayout=VertexSceneTreeTableLayout,exports.VertexSelectionHighlightingColorPicker=VertexSelectionHighlightingColorPicker,exports.VertexSelectionHighlightingControls=VertexSelectionHighlightingControls,exports.VertexSelectionHighlightingLineThicknessSlider=VertexSelectionHighlightingLineThicknessSlider,exports.VertexSelectionHighlightingOpacitySlider=VertexSelectionHighlightingOpacitySlider,exports.VertexSelectionHighlightingPanelSection=VertexSelectionHighlightingPanelSection,exports.VertexSelectionHighlightingReset=VertexSelectionHighlightingReset,exports.VertexShowAllMenuItem=VertexShowAllMenuItem,exports.VertexShowOnlyMenuItem=VertexShowOnlyMenuItem,exports.VertexShowOnlySelectedMenuItem=VertexShowOnlySelectedMenuItem,exports.VertexToolbar=VertexToolbar,exports.VertexToolbarDivider=VertexToolbarDivider,exports.VertexTransformClear=VertexTransformClear,exports.VertexTransformControls=VertexTransformControls,exports.VertexTransformInputs=VertexTransformInputs,exports.VertexTransformManipulatorToggle=VertexTransformManipulatorToggle,exports.VertexTransformPanelSection=VertexTransformPanelSection,exports.VertexTransformWidget=VertexTransformWidget,exports.VertexUnitsControls=VertexUnitsControls,exports.VertexUnitsPanelSection=VertexUnitsPanelSection,exports.VertexViewer=VertexViewer,exports.VertexViewerBackgroundColorPicker=VertexViewerBackgroundColorPicker,exports.VertexViewerBackgroundControls=VertexViewerBackgroundControls,exports.VertexViewerBackgroundPanelSection=VertexViewerBackgroundPanelSection,exports.VertexViewerBackgroundReset=VertexViewerBackgroundReset,exports.VertexViewerContextMenu=VertexViewerContextMenu,exports.VertexViewerCrossSectionButton=VertexViewerCrossSectionButton,exports.VertexViewerRightOpenedPanel=VertexViewerRightOpenedPanel,exports.VertexViewerRightSidebar=VertexViewerRightSidebar,exports.VertexViewerSceneReset=VertexViewerSceneReset,exports.VertexViewerToolkitRoot=VertexViewerToolkitRoot,exports.VertexViewerViewCube=VertexViewerViewCube,exports.VertexZoomButton=VertexZoomButton;
|
|
18
|
+
*/Ve=we,function(){var e={}.hasOwnProperty;function classNames(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=appendClass(e,parseValue(n)))}return e}function parseValue(t){if("string"==typeof t||"number"==typeof t)return t;if("object"!=typeof t)return"";if(Array.isArray(t))return classNames.apply(null,t);if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes("[native code]"))return t.toString();var n="";for(var a in t)e.call(t,a)&&t[a]&&(n=appendClass(n,a));return n}function appendClass(e,t){return t?e?e+" "+t:e+t:e}Ve.exports?(classNames.default=classNames,Ve.exports=classNames):window.classNames=classNames}();var Ce=we.exports;const VertexSlider=t=>{var{value:n,defaultValue:s,leftLabel:i,rightLabel:l,onChange:r,onValueChange:c,onValueInput:u}=t,d=__rest(t,["value","defaultValue","leftLabel","rightLabel","onChange","onValueChange","onValueInput"]);const[m,p]=a.useState(s);return e.jsxs("div",{className:"flex w-full items-center gap-2",children:[i&&e.jsx("div",{className:"pl-0.5 text-xs text-center",children:i}),e.jsx(o.VertexSlider,Object.assign({className:Ce("w-full",{"mt-0.5":null!=i||null!=l}),value:null!=n?n:m,onValueChange:e=>{p(e.detail.value),null==r||r(e.detail.value),null==c||c(e)},onValueInput:e=>{p(e.detail.value),null==r||r(e.detail.value),null==u||u(e)}},d)),l&&e.jsx("div",{className:"text-xs pr-2 flex-shrink-0 text-right",children:l})]})},VertexCrossSectionAppearanceLineThicknessSlider=({onUpdate:t})=>{const a=useCrossSectioningActions(),[s,o]=n.useRecoilState(ee);return e.jsx(VertexSlider,{id:"cross-section-line-thickness","data-testid":"cross-section-line-thickness-slider",leftLabel:"Off",rightLabel:"Thick",min:0,max:3,step:.5,value:s,valueLabelDisplay:"auto",onValueInput:async e=>{o(e.detail.value),await a.reapply()},onValueChange:e=>{null==t||t(e.detail.value)}})};function VertexCrossSectionAppearanceControls({onUpdateCrossSectionColor:t,onUpdateCrossSectionLineThickness:n}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsx(VertexCrossSectionAppearanceColorPicker,{onUpdate:t}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Line Thickness"}),e.jsx(VertexCrossSectionAppearanceLineThicknessSlider,{onUpdate:n})]})}function PanelSection({header:t,children:n}){return e.jsxs("div",{className:"py-3 px-4 border-neutral-300 border-b",children:[e.jsx("div",{className:"my-2 text-base text-neutral-700",children:t}),n]})}const VertexCrossSectionAppearanceReset=({onReset:t})=>{const a=useCrossSectioningActions(),[s,i]=n.useRecoilState(Q),[l,r]=n.useRecoilState(ee),c=s!==Y||1!==l;return e.jsx("div",{className:"ml-auto",children:e.jsx(o.VertexTooltip,{content:"Reset Cross Sectioning Appearance",children:e.jsx(o.VertexIconButton,{"data-testid":"cross-section-appearance-reset",iconName:"reset",iconSize:"sm",onClick:async()=>{i(Y),r(1),null==t||t(),await a.reapply()},disabled:!c})})})};function VertexCrossSectionAppearancePanelSection({onResetCrossSectionAppearance:t,onUpdateCrossSectionColor:n,onUpdateCrossSectionLineThickness:a}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Cross Sectioning",e.jsx(VertexCrossSectionAppearanceReset,{onReset:t})]}),children:e.jsx(VertexCrossSectionAppearanceControls,{onUpdateCrossSectionColor:n,onUpdateCrossSectionLineThickness:a})})}const je=.5,Te="#444444",ke=n.atom({key:"featureEdgesSelectedColor",default:Te}),Ae=n.atom({key:"featureEdgesLineThickness",default:je}),VertexFeatureEdgesColorPicker=({onUpdate:t})=>{const[a,s]=n.useRecoilState(ke);return e.jsx(VertexColorPicker,{"data-testid":"feature-edges-color-picker",value:a,onValueChanged:e=>{null==t||t(e.detail)},onInput:e=>s(e)})},VertexFeatureEdgesThicknessSlider=({onUpdate:t})=>{const[a,s]=n.useRecoilState(Ae);return e.jsx(VertexSlider,{id:"feature-edges-thickness","data-testid":"feature-edges-thickness-slider",leftLabel:"Off",rightLabel:"Thick",min:0,max:3,step:.5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{s(e.detail.value)},onValueChange:e=>{null==t||t(e.detail.value)}})};function VertexFeatureEdgesControls({onUpdateFeatureEdgesColor:t,onUpdateFeatureEdgesThickness:n}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsx(VertexFeatureEdgesColorPicker,{onUpdate:t}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Line Thickness"}),e.jsx(VertexFeatureEdgesThicknessSlider,{onUpdate:n})]})}const VertexFeatureEdgesReset=({onReset:t})=>{const[a,s]=n.useRecoilState(ke),[i,l]=n.useRecoilState(Ae),r=i!==je||a!==Te;return e.jsx("div",{className:"ml-auto",children:e.jsx(o.VertexTooltip,{content:"Reset Feature Edges",children:e.jsx(o.VertexIconButton,{"data-testid":"feature-edges-reset",iconName:"reset",iconSize:"sm",onClick:()=>{s(Te),l(je),null==t||t()},disabled:!r})})})};function VertexFeatureEdgesPanelSection({onResetFeatureEdges:t,onUpdateFeatureEdgesColor:n,onUpdateFeatureEdgesThickness:a}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Feature Edges",e.jsx(VertexFeatureEdgesReset,{onReset:t})]}),children:e.jsx(VertexFeatureEdgesControls,{onUpdateFeatureEdgesColor:n,onUpdateFeatureEdgesThickness:a})})}function contextMenuItemIsRow(e){var t;return null!=e&&null!=(null===(t=null==e?void 0:e.node)||void 0===t?void 0:t.id)}const Pe=n.atom({key:"contextMenuActive",default:void 0}),Ee=n.atom({key:"contextMenuPosition",default:void 0}),Ie=n.atom({key:"contextMenuTarget",default:void 0}),Re=n.atom({key:"contextMenuItem",default:void 0}),Ne=n.atom({key:"contextMenuActions",default:[]}),Oe=n.selector({key:"contextMenuActivePosition",get:({get:e})=>null!=e(Pe)?e(Ee):void 0});function useContextMenuActions(){return{pointerDown:useActionCallback((({set:e})=>async t=>{if(2===t.button){const n=t.clientX,a=null==t?void 0:t.clientY;e(Ee,s.Point.create(n,a)),e(Ie,t.target)}})),pointerUp:useActionCallback((({snapshot:e,set:t})=>async(n,a,o,i)=>{const l=await e.getPromise(Ee),r=await e.getPromise(Pe);if(null!=l&&null==r){const e=n.clientX,r=null==n?void 0:n.clientY,c=s.Point.create(e,r),u=null!=l?s.Point.distance(l,c):0,d=null==o||o(n);u<2&&d&&(null==i||i(n,null!=l?l:c),t(Pe,a))}})),contextMenu:useActionCallback((()=>(e,t)=>{(null==t||t(e))&&e.preventDefault()})),longPress:useActionCallback((({set:e})=>(t,n,a,o)=>{if(null==a||a(t)){const a=s.Point.create(t.touches[0].clientX,t.touches[0].clientY);e(Ee,a),e(Ie,t.target),e(Pe,n),null==o||o(t,a)}})),clearActiveContextMenu:useActionCallback((({reset:e,set:t})=>n=>{t(ye,!!n),e(Pe),e(Ne),e(Ee)})),clearDismissedState:useActionCallback((({reset:e})=>()=>e(ye)))}}function targetWithinMenu(e){return e.target instanceof Element&&isChildOf("vertex-menu",e.target)}function targetShouldSkipNextHit(e){return e.target instanceof Element&&isChildOf("vertex-viewer",e.target)}function isChildOf(e,t){return null!=t.closest(e)}const Me=n.atom({key:"boxSelectionEnabled",default:!1}),Le=n.atom({key:"boxSelectionOperationType",default:"clearAndSelect"}),useBoxSelectionActions=()=>({enable:useActionCallback((({set:e})=>()=>{e(Me,!0)})),disable:useActionCallback((({reset:e})=>async()=>{e(Me),e(Le)})),setOperationType:useActionCallback((({set:e})=>t=>{e(Le,t)}))});async function whenComponentReady(e,t,n=customElements,a=requestAnimationFrame,s=setTimeout){return null!=e&&null!=e.nodeName&&await n.whenDefined(e.nodeName.toLowerCase()),"function"==typeof(null==e?void 0:e.componentOnReady)?(await(null==e?void 0:e.componentOnReady()),t()):(await new Promise((e=>"function"==typeof a?a(e):s(e))),t())}const Be=n.atom({key:"isEditingPointToPointMeasurement",default:!1}),_e=n.atom({key:"pointToPointMeasurementOutcome",default:void 0}),De=n.atom({key:"editedPointToPointMeasurement",default:void 0});function usePointToPointMeasurement(e){const t=n.useSetRecoilState(_e);a.useEffect((()=>{let n;return whenComponentReady(e,(()=>{n=null==e?void 0:e.measurementModel.onOutcomeChanged(t)})),()=>null==n?void 0:n.dispose()}),[e,t])}const ze=2,Fe=n.atom({key:"isEditingPreciseMeasurement",default:!1}),He=n.atom({key:"preciseMeasurementOutcome",default:void 0}),Ue=n.atom({key:"preciseMeasurementController",dangerouslyAllowMutability:!0,default:void 0}),We=n.atom({key:"preciseMeasurementOverlays",dangerouslyAllowMutability:!0,default:void 0}),Ge=n.atom({key:"preciseMeasurementEntities",dangerouslyAllowMutability:!0,default:[]}),Ke=n.selector({key:"preciseMeasurementMessage",get:({get:e})=>{const t=undefined;return 0===e(Ge).length?"Select a surface":void 0}});function usePreciseMeasurementModel(e,t,s){const o=n.useSetRecoilState(Ge),i=n.useSetRecoilState(He),l=n.useSetRecoilState(Ue),r=n.useSetRecoilState(We),c=n.useRecoilValue(Ue);a.useEffect((()=>{let n;return whenComponentReady(e,(()=>{n=null==e?void 0:e.measurementModel.onEntitiesChanged((e=>{o(e),null==t||t(e)}))})),()=>null==n?void 0:n.dispose()}),[e,o]),a.useEffect((()=>{let t;return whenComponentReady(e,(()=>{t=null==e?void 0:e.measurementModel.onOutcomeChanged((e=>{i(e),null==s||s(e)}))})),()=>null==t?void 0:t.dispose()}),[e,i]),a.useEffect((()=>{let t;return whenComponentReady(e,(()=>{t=null==e?void 0:e.measurementModel.onEntitiesChanged((e=>{if(e.length>2){const t=e[2];null==c||c.setEntities(new Set([t]))}}))})),()=>null==t?void 0:t.dispose()}),[e,c]),a.useEffect((()=>{whenComponentReady(e,(()=>{l(null==e?void 0:e.measurementController)}))}),[e,l]),a.useEffect((()=>{whenComponentReady(e,(()=>{r(null==e?void 0:e.measurementOverlays)}))}),[e,r])}function useMeasurementActions(){const e=useBoxSelectionActions(),t=useEnablePointToPointMeasurement(),n=useDisablePointToPointMeasurement(),a=useDisablePreciseMeasurement(),s=useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(Ue);null==t||t.clearEntities()})),o=useActionCallback((()=>async(e={})=>{await s(),n(e),a()})),i=useActionCallback((({set:e,reset:n})=>async a=>{await o(),"point-to-point"===a?t():(n(He),n(Ge),e(Fe,!0))}));return{disableEditMeasurement:useActionCallback((()=>async e=>{await o(e)})),enableEditMeasurement:useActionCallback((()=>async e=>{await i(e)})),resetMeasurement:useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=await e.getPromise(Fe),a=await e.getPromise(Be);n?await s():a&&(t(_e),t(De))})),clearEditedPointToPointMeasurement:useActionCallback((({reset:e})=>()=>{e(De)})),setEditedPointToPointMeasurement:useActionCallback((({set:e})=>t=>{e(De,t)})),toggleEditPointToPointMeasurement:useActionCallback((({snapshot:t})=>async()=>{const n=undefined;await t.getPromise(Be)?await o():await i("point-to-point"),e.disable()})),toggleEditPreciseMeasurement:useActionCallback((({snapshot:t})=>async()=>{const n=undefined;await t.getPromise(Fe)?await o():await i("precise"),e.disable()}))}}function useEnablePointToPointMeasurement(){return useActionCallback((({reset:e,set:t})=>(n={})=>{t(Be,!0),n.keepExistingMeasurement||e(_e)}))}function useDisablePointToPointMeasurement(){return useActionCallback((({reset:e})=>(t={})=>{e(Be),t.keepExistingMeasurement||(e(De),e(_e))}))}function useDisablePreciseMeasurement(){return useActionCallback((({reset:e})=>async()=>{e(Fe),e(He),e(Ge)}))}const $e=n.selector({key:"isEditingMeasurement",get:({get:e})=>e(Be)||e(Fe)}),qe=n.selector({key:"measurementPanelModel",get:({get:e})=>e(_e)||e(He)}),Ye=n.selector({key:"measurementPanelOverlays",dangerouslyAllowMutability:!0,get:({get:e})=>e(We)}),Xe=n.selector({key:"measurementPanelMessage",get:({get:e})=>{const t=undefined;return e(Fe)?e(Ke):void 0}}),Ze=n.selector({key:"measurementPanelIsResettable",get:({get:e})=>e($e)&&null!=e(qe)}),Je=3e3,Qe=n.atom({key:"applicationMessageToast",default:void 0}),et=n.atom({key:"applicationMessageBanner",default:void 0}),useApplicationMessageActions=()=>({setBannerMessage:useActionCallback((({set:e})=>t=>{e(et,null!=t?Object.assign(Object.assign({},t),{id:O.create()}):void 0)})),setToastMessage:useActionCallback((({set:e})=>t=>{e(Qe,null!=t?Object.assign(Object.assign({},t),{id:O.create()}):void 0)}))});var tt;!function(e){e.HIDE_ITEM="Hide Item",e.SHOW_ONLY_SELECTED="Show Only Selected",e.HIDE_SELECTED="Hide Selected",e.SHOW_ONLY_ITEM="Show Only Item",e.SHOW_ALL="Show All",e.HIDE_ALL="Hide All",e.SELECT_FILTERED_ITEMS="Select Filtered Items",e.INVERT_SELECTION="Invert Selection",e.CLEAR_ALL_TRANSFORMS="Clear All Transforms",e.CLEAR_SELECTED_TRANSFORMS="Clear Selected Transforms",e.CLEAR_SELECTION="Clear Selection",e.DESELECTING_ITEMS="Deselecting Items",e.SELECTING_ITEMS="Selecting Items",e.SELECTING_ONLY_ITEM="Selecting Only Item",e.SELECTING_ANCESTOR="Selecting Ancestor",e.APPLY_MATERIAL_OVERRIDE_TO_ALL="Apply Material Override To All",e.APPLY_MATERIAL_OVERRIDE_TO_SELECTION="Apply Material Override To Selection",e.CLEAR_ALL_MATERIAL_OVERRIDES="Clear All Material Overrides",e.CLEAR_SELECTED_MATERIAL_OVERRIDES="Clear Selected Material Overrides",e.SET_PHANTOM_ALL="Set Phantom All",e.SET_PHANTOM_SELECTED_ITEMS="Set Phantom Selected Items",e.CLEAR_PHANTOM_ALL="Clear Phantom All",e.CLEAR_PHANTOM_SELECTED_ITEMS="Clear Phantom Selected Items",e.SET_PHANTOM_NON_SELECTED_ITEMS="Set Phantom Non Selected Items",e.RESTORE_PHANTOM_OVERRIDES="Restore Phantom Overrides",e.SET_ITEM_AS_END_ITEM="Set Item as End Item",e.UNSET_ITEM_AS_END_ITEM="Unset Item as End Item",e.SHOW_ANNOTATION="Show Annotation",e.HIDE_ANNOTATION="Hide Annotation"}(tt||(tt={}));const nt=n.atom({key:"fetchedItemInvalidator",default:0}),at=n.selectorFamily({key:"fetchedItems",get:e=>async({get:t})=>{var n;const a=t(M),s=t(F);if(t(nt),t(Lt),null!=s)try{return await(null===(n=null==a?void 0:a.sceneItems)||void 0===n?void 0:n.getSceneViewItem(e,s,{includeOverride:!0,includeWorldTransform:!0}))}catch(t){return void logger_debug(`Error encountered get scene view item. [itemId={${e}}]`,t)}}}),st=n.atomFamily({key:"selectionSelectedItems",default:void 0}),ot=n.atom({key:"selectionSelectedItemIds",default:[]}),it=n.atom({key:"selectionLastSelected",default:void 0}),lt=n.atom({key:"selectionLastSelectionFromViewer",default:!1}),rt=n.atom({key:"selectionLastSelectWasMultiSelect",default:!1}),ct=n.selector({key:"selectionHasMultipleSelected",get:({get:e})=>{const t=e(it),n=undefined;return e(ot).filter((e=>{var n;return e!==(null==t?void 0:t.id)&&!(null===(n=null==t?void 0:t.ancestors)||void 0===n?void 0:n.includes(e))})).length>0}}),ut=n.atom({key:"selectionFirstSelectedItemInTreeId",default:void 0}),dt=n.selector({key:"selectionHighestSelectedAncestor",get:({get:e})=>{var t,n;const a=e(it),s=e(ot);return null!==(n=null===(t=null==a?void 0:a.ancestors)||void 0===t?void 0:t.find((e=>s.includes(e))))&&void 0!==n?n:null==a?void 0:a.id}}),mt=n.atom({key:"selectionPreviousVisibleSummary",default:void 0}),pt=n.atom({key:"selectionVisibleSummary",default:void 0}),xt=n.selector({key:"selectionVisibleCount",get:({get:e})=>{var t,n;return null!==(n=null===(t=e(pt))||void 0===t?void 0:t.count)&&void 0!==n?n:0}}),ht=n.selector({key:"selectionBoundingBoxCenter",get:({get:e})=>{const t=e(pt);return null!=(null==t?void 0:t.boundingBox)?s.BoundingBox.center(t.boundingBox):s.Vector3.origin()}}),ft=n.selector({key:"selectionIsActive",get:({get:e})=>{const t=e(ot),n=undefined;return e(xt)>0||t.length>0}}),gt=n.selector({key:"fetchedAndSelectedItems",get:async({get:e})=>{const t=e(ot),n=undefined;return null!=e(F)?t.map((t=>e(at(t)))):[]}});function useSceneViewItemActions(){return{invalidateCachedItems:useActionCallback((({set:e})=>()=>{e(nt,(e=>e+1))}))}}const vt=n.atom({key:"lengthUnit",default:"cm"}),yt=n.atom({key:"decimalPlace",default:"2"});var bt,St;!function(e){e.mm="millimeters",e.cm="centimeters",e.m="meters",e.in="inches",e.ft="feet"}(bt||(bt={})),function(e){e[e.mm=1]="mm",e[e.cm=.1]="cm",e[e.m=.001]="m",e[e.in=.03937007874015748]="in",e[e.ft=.0032808398950131233]="ft"}(St||(St={}));const convertFrom=(e,t)=>{const n=undefined;return e/St[t]},convertTo=(e,t)=>{const n=undefined;return e*St[t]},formatWithUnit=(e,t,n)=>`${e.toFixed(n)} ${t}`,formatDistance=(e,t,n)=>formatWithUnit(convertTo(e,t),t,n),createDistanceFormatter=(e,t)=>n=>formatDistance(n,e,t);function toUnitType(e){switch(e){case"cm":return"centimeters";case"m":return"meters";case"in":return"inches";case"ft":return"feet";default:return"millimeters"}}function pickLocalOrWorldTransform(e,t){return"local"===t?e.local:e.world}function mapItemTransforms(e,t){return{local:t(e.local),world:t(e.world)}}function makeItemTransforms(e,t,n){return"local"===n?{local:e,world:i.toWorldTransform(e,t)}:{world:e,local:i.toLocalTransform(e,t)}}function convertTransformToUnits(e,t){const{position:n,rotation:a,scale:o}=e;return{position:s.Vector3.create(convertTo(n.x,t),convertTo(n.y,t),convertTo(n.z,t)),rotation:a,scale:o}}function convertTransformFromUnits(e,t){const{position:n,rotation:a,scale:o}=e;return{position:s.Vector3.create(convertFrom(n.x,t),convertFrom(n.y,t),convertFrom(n.z,t)),rotation:a,scale:o}}function toValidTransform(e){const{position:t,rotation:n,scale:a}=e;return{position:{x:t.x||0,y:t.y||0,z:t.z||0},rotation:{x:n.x||0,y:n.y||0,z:n.z||0},scale:a||1}}function scale(e){const t=parseFloat(Math.sqrt(e[0]**2+e[4]**2+e[8]**2).toFixed(2)),n=parseFloat(Math.sqrt(e[1]**2+e[5]**2+e[9]**2).toFixed(2)),a=parseFloat(Math.sqrt(e[2]**2+e[6]**2+e[10]**2).toFixed(2));return t===n&&n===a?t:NaN}function translation(e){return{x:e[12],y:e[13],z:e[14]}}function rotation(e){const t=e.map((t=>t*(1/scale(e))));return t[8]<1?t[8]>-1?{x:Math.atan2(-t[9],t[10])*(180/Math.PI),y:Math.asin(t[8])*(180/Math.PI),z:Math.atan2(-t[4],t[0])*(180/Math.PI)}:{x:-Math.atan2(-t[1],t[5])*(180/Math.PI),y:-90,z:0}:{x:Math.atan2(t[1],t[5])*(180/Math.PI),y:90,z:0}}function toTransformFromApiMatrix(e){return null!=e?{position:translation(e),rotation:rotation(e),scale:scale(e)}:void 0}const wt={position:s.Vector3.create(0,0,0),rotation:s.Vector3.create(0,0,0),scale:1},Vt=n.atom({key:"transformWidgetEnabled",default:!1}),Ct=n.atom({key:"transformWidgetPosition",default:void 0}),jt=n.atom({key:"transformWidgetOrientationOverride",default:void 0}),Tt=n.selector({key:"transformWidgetOrientation",get:({get:e})=>{const t=e(jt),n=e(it);if(null!=t)return t;if(null!=n){const t=e(Mt(n.id));return s.Euler.fromDegrees({x:null==t?void 0:t.world.rotation.x,y:null==t?void 0:t.world.rotation.y,z:null==t?void 0:t.world.rotation.z})}}}),kt=n.atom({key:"transformWidgetCachedOrientation",default:void 0}),At=n.atom({key:"transformWidgetSyncToSelection",default:!1}),Pt=n.atom({key:"transformWidgetIsInteracting",default:!1}),Et=n.atomFamily({key:"appliedItemTransform",default:void 0}),It=n.atom({key:"appliedItemTransformIds",default:[]}),Rt=n.atom({key:"selectedCoordinateSpace",default:"world"}),Nt=n.atomFamily({key:"editedItemTransform",default:void 0}),Ot=n.selectorFamily({key:"displayedItemTransform",get:e=>({get:t})=>{if(null!=e){const n=t(Rt),a=t(vt),s=t(Mt(e)),o=t(Nt(e));if(null!=o)return o.transform;if(null!=s)return pickLocalOrWorldTransform(mapItemTransforms(s,(e=>convertTransformToUnits(e,a))),n)}},set:e=>({get:t,set:a},s)=>{if(null!=e){const o=t(Rt),i=t(Bt(e)),l=t(Mt(e)),r=t(vt);if(null!=l&&!(s instanceof n.DefaultValue)&&null!=s&&null!=i){a(Nt(e),{coordinateSpace:o,units:r,transform:s});const n=makeItemTransforms(convertTransformFromUnits(toValidTransform(s),r),i,o),l=t(It);a(Et(e),n),a(It,[...l,e])}}}}),Mt=n.selectorFamily({key:"fetchedItemTransforms",get:e=>({get:t})=>{var n,a;const s=t(at(e));if(null!=s){const e=(null===(n=s.override)||void 0===n?void 0:n.transform)?toTransformFromApiMatrix(null===(a=s.override)||void 0===a?void 0:a.transform):void 0,t=s.worldTransform?toTransformFromApiMatrix(s.worldTransform):void 0;return{local:null!=e?e:wt,world:null!=t?t:wt}}}}),Lt=n.atom({key:"transformInvalidator",default:0}),Bt=n.selectorFamily({key:"parentItemWorldMatrix",get:e=>({get:t})=>{const n=t(F);if(null!=e&&null!=n){const n=t(at(e));if(null!=(null==n?void 0:n.parentId)){const e=t(Mt(n.parentId)),a=t(Et(n.parentId));if(null==e)throw new Error("Invalid state. Parent item state should be populated, but is undefined.");return null!=a?i.toMatrix(i.toRadiansTransform(a.world)):i.toMatrix(i.toRadiansTransform(e.world))}}return logger_debug(`Unable to find the world matrix for the parent of ${e}. Returning the identity matrix.`),s.Matrix4.makeIdentity()}});function useUpdateEditedTransformWhenSettingsChange(e){const t=n.useRecoilValue(vt),s=n.useRecoilValue(Rt),o=n.useRecoilValue(Et(null!=e?e:"")),[i,l]=n.useRecoilState(Nt(null!=e?e:""));a.useEffect((()=>{if(null!=o&&((null==i?void 0:i.coordinateSpace)!==s||(null==i?void 0:i.units)!==t)){const e=undefined,n=convertTransformToUnits(pickLocalOrWorldTransform(o,s),t);l({units:t,coordinateSpace:s,transform:n})}}),[t,s])}function useEditItemTransform(e){const t=useTransformActions();useUpdateEditedTransformWhenSettingsChange(e);const a=n.useRecoilValueLoadable(Bt(e)),[s,o]=n.useRecoilStateLoadable(Ot(e));return{transform:"hasValue"===s.state?s.contents:void 0,loading:"loading"===s.state||"loading"===a.state,error:"hasError"===s.state?s.contents:void 0,async update(n){t.enableSelectionSync(),o(n),null!=e&&await t.applyTransformToItem(e)}}}const useTransformActions=()=>{const e=useApplicationMessageActions(),t=useViewerSceneActions(),n=useActionCallback((({set:e,snapshot:t})=>async()=>{const n=await t.getPromise(ht);e(Ct,n)})),a=useActionCallback((({set:e,snapshot:t})=>async()=>{const a=await t.getPromise(Ct),s=await t.getPromise(rt),o=await t.getPromise(ot),i=await t.getPromise(xt);null==a&&(o.length>0||s||i>0)&&await n(),e(At,!0)})),o=useActionCallback((({set:e})=>async t=>{e(Ct,null!=t?t:void 0)})),l=useActionCallback(retainSnapshot((({snapshot:e,set:t,reset:n})=>async()=>{const a=await e.getPromise(Tt),s=undefined;(await e.getPromise(It)).forEach((e=>{n(Et(e)),n(Nt(e))})),n(It),null!=a&&t(kt,a),t(Lt,(e=>e+1))}))),r=useActionCallback((({set:e,reset:t})=>n=>{t(kt),e(jt,n)})),c=useActionCallback((({set:e})=>()=>{e(Ct,void 0),e(Vt,!1)}));return{enableTransformWidget:useActionCallback((({set:t})=>async(s,i)=>{e.setToastMessage({message:"Transform manipulator enabled! Select parts to interact.",duration:Je}),t(Vt,!0),i?await n():null==s?await a():await o(s)})),disableTransformWidget:useActionCallback((({reset:e})=>()=>{e(Vt),e(jt)})),setTransformWidgetOrientation:r,clearTransformWidgetOrientation:useActionCallback((({reset:e})=>()=>{e(kt),e(jt)})),setTransformWidgetPosition:o,clearTransformWidgetPosition:useActionCallback((({reset:e})=>()=>e(Ct))),invalidateTransforms:l,setIsInteractivelyTransforming:useActionCallback((({set:e})=>t=>{e(Pt,t)})),setDefaultWidgetPosition:a,setDefaultWidgetPositionToSelection:n,enableSelectionSync:useActionCallback((({set:e})=>()=>e(At,!0))),disableSelectionSync:useActionCallback((({reset:e})=>()=>e(At))),syncToSelection:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(mt),n=await e.getPromise(pt),a=undefined;if(await e.getPromise(At)){const e=null==n?void 0:n.boundingBox,a=null!=e&&null!=(null==t?void 0:t.boundingBox)&&equals(e,t.boundingBox);null==e||a||await o(s.BoundingBox.center(e))}})),orientToHitResult:useActionCallback((({reset:e})=>async t=>{e(At),null!=t?await o(null==t?void 0:t.position):(e(Ct),r(void 0))})),clearSelectedTransforms:useActionCallback((()=>async()=>{await t.execute(tt.CLEAR_SELECTED_TRANSFORMS,(e=>e.where((e=>e.withSelected())).clearTransforms())),await l(),c()})),clearAllTransforms:useActionCallback((()=>async()=>{await t.execute(tt.CLEAR_SELECTED_TRANSFORMS,(e=>e.where((e=>e.all())).clearTransforms())),await l(),c()})),applyTransformToItem:useActionCallback((({snapshot:e})=>async t=>{const n=await e.getPromise(M),a=await(null==n?void 0:n.scene()),o=await e.getPromise(Et(t));if(null==o)return void logger_warn(`There is no transform to apply to item ${t}.`);const l=s.Matrix4.transpose(i.toMatrix(i.toRadiansTransform(null==o?void 0:o.local)));return null==a?void 0:a.items((e=>e.where((e=>e.withItemId(t))).transform(l))).execute()}))}},useHitActions=()=>{const e=useCrossSectioningActions(),t=useMeasurementActions(),n=useTransformActions(),a=useActionCallback(retainSnapshot((({snapshot:e})=>async()=>{const n=await e.tryGetPromise(ve).then((e=>e.value)),a=await e.getPromise(De);null==n&&null!=(null==a?void 0:a.start)&&null!=a.end&&await t.resetMeasurement()}))),s=useActionCallback(retainSnapshot((({snapshot:e})=>async()=>{const t=await e.tryGetPromise(ve).then((e=>e.value));await n.orientToHitResult(t)}))),o=useActionCallback(retainSnapshot((({set:e,snapshot:t})=>async()=>{const n=await t.tryGetPromise(ve).then((e=>e.value));e(Re,n)}))),i=useActionCallback(retainSnapshot((({snapshot:e,set:t})=>async()=>{t(ge,await e.tryGetPromise(ve).then((e=>e.value)))})));return{tap:useActionCallback(retainSnapshot((({snapshot:t,set:n})=>async({detail:l},...r)=>{const c=await t.getPromise($e),u=await t.getPromise(ne),d=2!==(null==l?void 0:l.buttons)&&!(null==l?void 0:l.altKey);l.altKey||l.ctrlKey||l.metaKey||l.shiftKey;const m=d&&!u.hitPending&&!c,p=await t.tryGetPromise(ve).then((e=>e.value));n(fe,p),n(xe,l),await a(),m&&(r.forEach((e=>e())),await s()),await o(),await e.sectionCurrentHit(),await i()}))),longPress:useActionCallback(retainSnapshot((({snapshot:e,set:t,reset:n})=>async a=>{n(xe),t(he,a.detail),await e.tryGetPromise(ve),await o(),await i()})))}},_t=n.selector({key:"viewerToolkitHitState",get:({get:e})=>{const t=undefined,n=undefined,a=undefined,s=undefined,o=undefined;return{tapDetails:e(xe),longPressDetails:e(he),previousHitResult:e(fe),currentHitResult:e(ge)}}});var Dt=Object.freeze({__proto__:null,currentHitResult:ge,hitResult:ve,hitResultsLongPressDetails:he,hitResultsSkipNextTap:ye,hitResultsTapDetails:xe,hitState:_t,previousHitResult:fe,useHitActions:useHitActions});function useSelectionActions(){const e=useSceneViewItemActions(),t=useTransformActions(),n=useViewerSceneActions(),a=useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=undefined;(await e.getPromise(ot)).forEach((e=>t(st(e))))})),s=useActionCallback((({snapshot:e,reset:t,set:a})=>async(s,o)=>{var i,l;const r=await e.getPromise(st(s.id)),c=await e.getPromise(ot),u=null===(l=[...null!==(i=s.ancestors)&&void 0!==i?i:[]])||void 0===l?void 0:l.reverse().find((e=>!c.includes(e)));null!=r&&null!=u?(a(st(u),{id:u}),a(ot,(e=>[...e,u])),n.execute(tt.SELECTING_ANCESTOR,n.selectItemsTransform(u))):(null==o?void 0:o.clear)?(a(st(s.id),s),a(ot,[s.id]),n.execute(tt.SELECTING_ONLY_ITEM,n.clearSelectionTransform,n.selectItemsTransform(s.id))):(a(st(s.id),s),a(ot,(e=>[...e,s.id])),n.execute(tt.SELECTING_ITEMS,n.selectItemsTransform(s.id))),d(s),a(it,s),a(lt,!0),t(rt)})),o=useActionCallback((({reset:e,set:t})=>async a=>{e(st(a)),e(rt),t(ot,(e=>e.filter((e=>e!==a)))),n.execute(tt.DESELECTING_ITEMS,n.deselectItemsTransform(a))})),i=useActionCallback((({snapshot:e})=>async t=>{const n=await e.getPromise(st(t.id));null!=n?await o(n.id):await s(t)})),l=useActionCallback((({snapshot:n,reset:a,set:o})=>async(i,l={})=>{const r=await n.getPromise(st(i.id)),c=await n.getPromise(ot);if(c.filter((e=>{var t;return e!==i.id&&!(null===(t=i.ancestors)||void 0===t?void 0:t.includes(e))})).forEach((e=>a(st(e)))),a(rt),r)if(l.ignoreAncestorSelection)a(ot),a(st(r.id));else{const e=c.filter((e=>{var t;return e===i.id||(null===(t=i.ancestors)||void 0===t?void 0:t.includes(e))}));o(ot,e)}else a(ot);e.invalidateCachedItems(),t.clearTransformWidgetOrientation(),await s(i,{clear:!0})})),r=useActionCallback((({reset:e})=>async()=>{await a(),e(ot),e(it),e(lt),e(rt),t.clearTransformWidgetPosition(),t.clearTransformWidgetOrientation()})),c=useActionCallback((()=>async()=>{await r(),n.execute(tt.CLEAR_SELECTION,n.clearSelectionTransform)})),u=useActionCallback((({set:e})=>async t=>{e(rt,t)})),d=useActionCallback((({reset:e,set:t})=>e=>{}));return{select:s,toggleSelection:i,clearAndSelect:l,selectCurrentHit:useActionCallback(retainSnapshot((({snapshot:e})=>async()=>{const t=await e.tryGetPromise(ve).then((e=>e.value)),n=await e.getPromise(xe),a=(null==n?void 0:n.metaKey)||(null==n?void 0:n.ctrlKey)||(null==n?void 0:n.shiftKey);null==t||a?null!=t&&a?await i(t):await c():await l(t)}))),syncSelection:useActionCallback((({set:e,reset:t})=>async(n,s)=>{s.selected?(await a(),e(st(n.id),n),s.multiSelect?e(ot,(e=>[...e.filter((e=>e!==n.id)),n.id])):e(ot,[n.id]),d(n),e(it,n),e(lt,!1),e(rt,!!s.multiSelect)):(t(st(n.id)),t(rt),e(ot,(e=>e.filter((e=>e!==n.id)))))})),deselect:o,clearSelection:c,resetSelectionState:r,toggleLastSelectWasMultiSelect:u,selectForModelViewsPanel:d}}const zt=n.selector({key:"viewerToolkitSelectionState",get:({get:e})=>{const t=undefined,n=undefined,a=undefined,s=undefined;return{selectedItemIds:e(ot),lastSelected:e(it),highestSelectedAncestorId:e(dt)}}});var Ft=Object.freeze({__proto__:null,fetchedAndSelectedItems:gt,selectionBoundingBoxCenter:ht,selectionFirstSelectedItemInTreeId:ut,selectionHasMultipleSelected:ct,selectionHighestSelectedAncestor:dt,selectionIsActive:ft,selectionLastSelectWasMultiSelect:rt,selectionLastSelected:it,selectionLastSelectionFromViewer:lt,selectionPreviousVisibleSummary:mt,selectionSelectedItemIds:ot,selectionSelectedItems:st,selectionState:zt,selectionVisibleCount:xt,selectionVisibleSummary:pt,useSelectionActions:useSelectionActions});const Ht=255,Ut=n.atom({key:"sceneItemAdjustmentsSelectedColor",default:void 0}),Wt=n.atom({key:"sceneItemAdjustmentsSelectedOpacity",default:void 0}),Gt=n.atomFamily({key:"appliedItemMaterialOverride",default:void 0}),Kt=n.atom({key:"appliedItemMaterialOverrideIds",default:[]}),$t=n.selector({key:"sceneItemAdjustmentsLastSelectedOverride",get:({get:e})=>{const t=e(it);if(null!=t)return e(Gt(t.id))}}),qt=n.atom({key:"applyMaterialToAllUserAction",default:void 0}),Yt=n.atom({key:"showConfirmDialogWhenApplyingMaterialToAll",default:!0}),Xt=n.atom({key:"confirmApplyMaterialToAllDialogOpen",default:!1}),useSceneItemMaterialActions=()=>{const e=useViewerSceneActions(),t=useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=await e.getPromise(Kt);t(Ut),n.forEach((e=>t(Gt(e)))),t(Kt)}));return{updateColor:useActionCallback((({set:e})=>t=>{e(Ut,t)})),clearCurrentColor:useActionCallback((({reset:e})=>()=>{e(Ut)})),clearCurrentOpacity:useActionCallback((({reset:e})=>()=>{e(Wt)})),clear:useActionCallback((({snapshot:t,set:n,reset:a})=>async()=>{const s=await t.getPromise(ot);a(Ut),s.forEach((e=>a(Gt(e)))),n(Kt,(e=>e.filter((e=>!s.includes(e))))),await e.execute(tt.CLEAR_SELECTED_MATERIAL_OVERRIDES,(e=>e.where((e=>e.withSelected())).clearMaterialOverrides().select()))})),clearAll:useActionCallback((()=>async()=>{await t(),await e.execute(tt.CLEAR_ALL_MATERIAL_OVERRIDES,(e=>e.where((e=>e.all())).clearMaterialOverrides()),(e=>e.where((e=>e.withSelected())).select()))})),clearState:t,updateOpacity:useActionCallback((({set:e})=>t=>{e(Wt,t)})),apply:useActionCallback((({snapshot:t,set:n})=>async()=>{const a=await t.getPromise(Ut),s=await t.getPromise(Wt),o=await t.getPromise(ot),i=await t.getPromise($t),l=null!=a?a:i,r=null!=s?s:null==i?void 0:i.opacity;if(null!=l){const t=Object.assign(Object.assign({},l),{opacity:null!=r?r:l.opacity});await e.execute(tt.APPLY_MATERIAL_OVERRIDE_TO_SELECTION,(e=>e.where((e=>e.withSelected())).materialOverride(t))),o.forEach((e=>n(Gt(e),t))),n(Kt,(e=>[...e,...o]))}})),confirmApplyAll:useActionCallback((({set:e})=>t=>{e(Xt,!0),e(qt,(()=>t))})),cancelApplyAll:useActionCallback((({reset:e})=>()=>{e(Xt),e(qt)})),applyAll:useActionCallback((({snapshot:t,reset:n})=>async()=>{const a=await t.getPromise(Ut),s=await t.getPromise(Wt);if(null!=a){const o=await t.getPromise(Kt),i=Object.assign(Object.assign({},a),{opacity:null!=s?s:a.opacity});await e.execute(tt.APPLY_MATERIAL_OVERRIDE_TO_ALL,(e=>e.where((e=>e.all())).materialOverride(i))),o.forEach((e=>n(Gt(e))));const l=await t.getPromise(qt);null==l||l(i),n(Xt),n(qt)}})),hideConfirmApplyAllDialog:useActionCallback((({set:e})=>()=>{e(Yt,!1)}))}},Zt="#FFFFFF",Jt=n.atom({key:"viewerBackgroundSelectedColor",default:Zt}),VertexSceneItemMaterialApplyAll=({onApplyAll:t})=>{const a=useSceneItemMaterialActions(),s=n.useRecoilValueLoadable($t),i=n.useRecoilValue(Ut),l=n.useRecoilValue(Yt),r=u.useMemo((()=>"hasValue"===s.state?null!=i?i:s.contents:i),[s,i]);return e.jsx(o.VertexTooltip,{content:"Apply to All",children:e.jsx(o.VertexIconButton,{iconName:"square-dot-outline",iconSize:"sm",color:"secondary",disabled:null==r,onClick:async()=>{l?a.confirmApplyAll(t):(await a.applyAll(),null==t||t(r))}})})};function SceneItemMaterialApplyAllConfirmationDialog(){const t=useSceneItemMaterialActions(),s=n.useRecoilValue(Xt),[i,l]=a.useState(!1),onCloseDialog=()=>{t.cancelApplyAll(),l(!1)};return s?e.jsxs(o.VertexDialog,{open:!0,className:"text-sm",onClosed:onCloseDialog,onBackdropClick:onCloseDialog,children:[e.jsx("div",{slot:"heading",children:"Apply to All Parts"}),e.jsx("div",{className:"max-w-lg break-words pr-2",children:"This will apply the same material to all parts in the model. Any previous material changes will be lost."}),e.jsxs("div",{className:"flex mt-8 gap-2 items-center",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(o.VertexToggle,{"data-testid":"hide-confirmation-dialog-in-future-checkbox",variant:"check",className:"pt-0.5",checked:i,onValueChanged:e=>{l(e.detail)}}),"Don't show again this session"]}),e.jsxs("div",{className:"flex ml-auto gap-2",children:[e.jsx(o.VertexButton,{"data-testid":"cancel-apply-material-to-all",onClick:onCloseDialog,children:"Cancel"}),e.jsx(o.VertexButton,{color:"primary","data-testid":"confirm-apply-material-to-all",onClick:async()=>{await t.applyAll(),i&&t.hideConfirmApplyAllDialog()},children:"Apply"})]})]})]}):e.jsx(e.Fragment,{})}function createColorMaterialWithId(e,t=O.create()){return Object.assign({id:t},i.ColorMaterial.fromHex(e))}const VertexSceneItemMaterialColorPicker=({onApply:t})=>{const a=useSceneItemMaterialActions(),s=n.useRecoilValueLoadable($t),o=n.useRecoilValue(Ut),i=u.useMemo((()=>"hasValue"===s.state?null!=o?o:s.contents:o),[s,o]);return e.jsx(VertexColorPicker,{"data-testid":"selected-item-color-picker",value:null!=i?T.toHexString(i.diffuse):void 0,onValueChanged:()=>{a.apply(),null==t||t(i)},onInput:async e=>{a.updateColor(createColorMaterialWithId(e)),await a.apply()}})},VertexSceneItemMaterialOpacitySlider=({onApply:t})=>{const a=useSceneItemMaterialActions(),s=n.useRecoilValue(Wt),i=n.useRecoilValueLoadable($t),l=u.useMemo((()=>{var e,t;return"hasValue"===i.state?null!==(t=null!=s?s:null===(e=i.contents)||void 0===e?void 0:e.opacity)&&void 0!==t?t:Ht:null!=s?s:Ht}),[s,i]),r=useDebouncedCallback((()=>{a.apply()}),500),c=u.useCallback((e=>{a.updateOpacity(e.detail.value),r(e.detail.value)}),[r,a]),d=u.useMemo((()=>"hasValue"!==i.state||null==i.contents),[i]);return e.jsx(o.VertexTooltip,{className:"flex w-full",content:d?"Select a part and apply a color to enable opacity":`${Math.floor(l/Ht*100)}%`,placement:"top",children:e.jsx(VertexSlider,{"data-testid":"scene-item-adjustments-opacity-slider",leftLabel:"0%",rightLabel:"100%",disabled:d,value:null!=l?l:Ht,step:5,min:0,max:Ht,onValueChange:e=>{a.updateOpacity(e.detail.value),a.apply(),null==t||t(e.detail.value)},onValueInput:c})})};function VertexMaterialControls({onApplyMaterial:t,onApplyMaterialToAll:s,onApplyOpacity:o}){const i=useSceneItemMaterialActions(),l=n.useRecoilValue(it);return a.useEffect((()=>{i.clearCurrentColor(),i.clearCurrentOpacity()}),[null==l?void 0:l.id]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(VertexSceneItemMaterialColorPicker,{onApply:t}),e.jsx(VertexSceneItemMaterialApplyAll,{onApplyAll:s})]})]}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Opacity"}),e.jsx(VertexSceneItemMaterialOpacitySlider,{onApply:o}),e.jsx(SceneItemMaterialApplyAllConfirmationDialog,{})]})}const ResetButton=({id:t,tooltip:n,children:s})=>{const[i,l]=a.useState(!1);return e.jsx("div",{className:"ml-auto",children:e.jsxs(o.VertexDropdownMenu,{className:"flex items-stretch h-full","data-testid":`reset-button-dropdown-menu-${t}`,placement:"bottom-end",onMenuOpened:()=>l(!0),onMenuClosed:()=>l(!1),children:[e.jsx("div",{slot:"anchor",className:"flex items-center h-full",children:e.jsx(o.VertexTooltip,{content:n,disabled:i,placement:"bottom",children:e.jsxs(o.VertexButton,{className:Ce("p-1.5 rounded-md select-none hover:bg-neutral-300 active:bg-neutral-400 cursor-pointer",{"bg-neutral-300":i}),"data-testid":`reset-button-${t}`,variant:"plaintext",children:[e.jsx(o.VertexIcon,{className:"px-0.5",name:"reset",size:"sm"}),e.jsx(o.VertexIcon,{name:"chevron-down",size:"sm"})]})})}),e.jsx("div",{className:"whitespace-nowrap",children:s})]})})},VertexSceneItemMaterialClear=({onClear:t,onClearAll:a})=>{const s=useSceneItemMaterialActions(),i=n.useRecoilValue(ft);return e.jsx("div",{className:"ml-auto",children:e.jsxs(ResetButton,{id:"materials",tooltip:"Clear Materials",children:[e.jsx("div",{className:"pt-1"}),e.jsx(o.VertexMenuItem,{"data-testid":"clear-selected-materials",onClick:()=>{s.clear(),null==t||t()},disabled:!i,children:"Clear selected materials"}),e.jsx(o.VertexMenuItem,{"data-testid":"clear-all-materials",onClick:()=>{s.clearAll(),null==a||a()},children:"Clear all materials"})]})})};function VertexMaterialPanelSection({onClearMaterial:t,onClearAllMaterials:n,onApplyMaterial:a,onApplyMaterialToAll:s,onApplyOpacity:o}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Material",e.jsx(VertexSceneItemMaterialClear,{onClear:t,onClearAll:n})]}),children:e.jsx(VertexMaterialControls,{onApplyMaterial:a,onApplyMaterialToAll:s,onApplyOpacity:o})})}const Qt="#ffff00",en=35,tn=1,nn=n.atom({key:"selectionHighlightingSelectedColor",default:Qt}),an=n.atom({key:"selectionHighlightingSelectedOpacity",default:en}),sn=n.atom({key:"selectionHighlightingSelectedLineThickness",default:1}),VertexSelectionHighlightingColorPicker=({onUpdate:t})=>{const[a,s]=n.useRecoilState(nn);return e.jsx(VertexColorPicker,{"data-testid":"selection-highlighting-color-picker",value:a,onValueChanged:e=>{null==t||t(e.detail)},onInput:e=>s(e)})},VertexSelectionHighlightingLineThicknessSlider=({onUpdate:t})=>{const[a,s]=n.useRecoilState(sn);return e.jsx(VertexSlider,{id:"selection-highlighting-line-thickness","data-testid":"selection-highlighting-line-thickness-slider",leftLabel:"Off",rightLabel:"Thick",min:0,max:3,step:.5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{s(e.detail.value)},onValueChange:e=>{null==t||t(e.detail.value)}})},VertexSelectionHighlightingOpacitySlider=({onUpdate:t})=>{const[a,s]=n.useRecoilState(an);return e.jsx(VertexSlider,{id:"selection-highlighting-opacity","data-testid":"selection-highlighting-opacity-slider",leftLabel:"0%",rightLabel:"100%",min:0,max:100,step:5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{s(e.detail.value)},onValueChange:e=>{null==t||t(e.detail.value)}})};function VertexSelectionHighlightingControls({onUpdateSelectionHighlightColor:t,onUpdateSelectionHighlightOpacity:n,onUpdateSelectionHighlightLineThickness:a}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsx(VertexSelectionHighlightingColorPicker,{onUpdate:t}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Opacity"}),e.jsx(VertexSelectionHighlightingOpacitySlider,{onUpdate:n}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Line Thickness"}),e.jsx(VertexSelectionHighlightingLineThicknessSlider,{onUpdate:a})]})}const VertexSelectionHighlightingReset=({onReset:t})=>{const[a,s]=n.useRecoilState(nn),[i,l]=n.useRecoilState(an),[r,c]=n.useRecoilState(sn),u=a!==Qt||i!==en||1!==r;return e.jsx("div",{className:"ml-auto",children:e.jsx(o.VertexTooltip,{content:"Reset Selection Highlighting",children:e.jsx(o.VertexIconButton,{"data-testid":"selection-highlighting-reset",iconName:"reset",iconSize:"sm",onClick:()=>{s(Qt),l(en),c(1),null==t||t()},disabled:!u})})})};function VertexSelectionHighlightingPanelSection({onResetSelectionHighlighting:t,onUpdateSelectionHighlightColor:n,onUpdateSelectionHighlightOpacity:a,onUpdateSelectionHighlightLineThickness:s}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Selection Highlighting",e.jsx(VertexSelectionHighlightingReset,{onReset:t})]}),children:e.jsx(VertexSelectionHighlightingControls,{onUpdateSelectionHighlightColor:n,onUpdateSelectionHighlightOpacity:a,onUpdateSelectionHighlightLineThickness:s})})}const VertexViewerBackgroundColorPicker=({onUpdate:t})=>{const[a,s]=n.useRecoilState(Jt);return e.jsx(VertexColorPicker,{"data-testid":"viewer-background-color-picker",value:a,onValueChanged:e=>{null==t||t(e.detail)},onInput:e=>s(e)})};function VertexViewerBackgroundControls({onUpdateViewerBackgroundColor:t}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsx(VertexViewerBackgroundColorPicker,{onUpdate:t})]})}const VertexViewerBackgroundReset=({onReset:t})=>{const[a,s]=n.useRecoilState(Jt),i=a!==Zt;return e.jsx("div",{className:"ml-auto",children:e.jsx(o.VertexTooltip,{content:"Reset Background Color",children:e.jsx(o.VertexIconButton,{"data-testid":"viewer-background-reset",iconName:"reset",iconSize:"sm",onClick:()=>{s(Zt),null==t||t()},disabled:!i})})})};function VertexViewerBackgroundPanelSection({onResetViewerBackgroundColor:t,onUpdateViewerBackgroundColor:n}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Viewer Background",e.jsx(VertexViewerBackgroundReset,{onReset:t})]}),children:e.jsx(VertexViewerBackgroundControls,{onUpdateViewerBackgroundColor:n})})}const isInputElement=e=>{const t=e instanceof HTMLElement&&"VERTEX-AUTO-RESIZE-TEXTAREA"===e.tagName,n=e instanceof HTMLElement&&"VERTEX-TEXTFIELD"===e.tagName,a=e instanceof HTMLElement&&"true"===e.contentEditable,s=e instanceof HTMLElement&&"VERTEX-SCENE-TREE-SEARCH"===e.tagName,o=e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement,i=e instanceof HTMLElement&&"VERTEX-VIEWER-PIN-TOOL"===e.tagName,l=e instanceof HTMLElement&&"VERTEX-VIEWER-TRANSFORM-WIDGET"===e.tagName;return t||n||a||s||o||i||l},useRecoilReducer=({reducer:e,atom:t})=>{const a=undefined,s=undefined;return[n.useRecoilValue(t),useRecoilReducerDispatch({reducer:e,atom:t})]},useRecoilReducerDispatch=({reducer:e,atom:t})=>{const a=n.useRecoilCallback((({set:n})=>async a=>{n(t,(t=>e(t,a)))}),[]);return a},on=n.atom({key:"keyBindings",default:{applyBindings:[],bindings:{},pressed:{}}});function reducer(e,t){var n,a,s,o;switch(t.type){case"push-key-binding":const i=undefined;return null!=(null===(n=e.bindings[t.binding.keyBind])||void 0===n?void 0:n.find((e=>e.id===t.binding.id)))?e:Object.assign(Object.assign({},e),{bindings:Object.assign(Object.assign({},e.bindings),{[t.binding.keyBind]:[...null!==(a=e.bindings[t.binding.keyBind])&&void 0!==a?a:[],t.binding]})});case"remove-key-binding":const l=undefined;return null==(null===(s=e.bindings[t.binding.keyBind])||void 0===s?void 0:s.find((e=>e.id===t.binding.id)))?e:Object.assign(Object.assign({},e),{bindings:Object.assign(Object.assign({},e.bindings),{[t.binding.keyBind]:(null!==(o=e.bindings[t.binding.keyBind])&&void 0!==o?o:[]).filter((e=>e.id!==t.binding.id))})});case"add-apply-key-binding":return Object.assign(Object.assign({},e),{applyBindings:[...e.applyBindings,t.binding]});case"remove-apply-key-binding":return Object.assign(Object.assign({},e),{applyBindings:e.applyBindings.filter((e=>e.id!==t.id))});case"set-key-pressed":return Object.assign(Object.assign({},e),{applyBindings:e.applyBindings.map((t=>Object.assign(Object.assign({},t),{active:null!=t.keyBind&&allPressed(t.keyBind,e.pressed)}))),pressed:Object.assign(Object.assign({},e.pressed),{[t.key]:t.pressed}),lastPressed:t.pressed?t.key:void 0})}}const useKeyBindingState=()=>useRecoilReducer({reducer:reducer,atom:on});function pressedValue(e,t){return e.includes("!")?!t[e.replace("!","")]&&!t[e.replace("!","").toLowerCase()]:t[e]||t[e.toLowerCase()]}function isPressed(e,t){const n=e.split("||");return n.length>1?n.some((e=>pressedValue(e,t))):pressedValue(n[0],t)}function allPressed(e,t){const n=undefined;return e.split("+").every((e=>isPressed(e,t)))}function matchingSingleFnBindings(e,t,n){return e.filter((e=>!e.repeat)).filter((e=>{var a;return null!=e.keyBind&&null!=n&&(null===(a=e.keyBind)||void 0===a?void 0:a.includes(n))&&allPressed(e.keyBind,t)})).map((e=>e.fn))}function matchingOffBindings(e,t,n){return e.filter((e=>e.off&&e.active&&null!=e.keyBind&&null==n&&!allPressed(e.keyBind,t))).map((e=>e.off))}const useApplyKeyBinding=e=>{const[t,n]=useKeyBindingState();a.useEffect((()=>{const a=O.create();return n({type:"add-apply-key-binding",binding:Object.assign(Object.assign({},e),{id:a,active:null!=e.keyBind&&allPressed(e.keyBind,t.pressed)})}),()=>{n({type:"remove-apply-key-binding",id:a})}}),[e.fn,e.off,e.keyBind,e.repeat])},useStackKeyBinding=(e,t=[])=>{const[,n]=useKeyBindingState();a.useEffect((()=>{const t=null==e.addPredicate||e.addPredicate(),a=null!=e.cancelPredicate&&e.cancelPredicate();t&&n({type:"push-key-binding",binding:e}),a&&n({type:"remove-key-binding",binding:e})}),t)},useKeyBindings=({keydownRepeatInterval:e=25,keydownIgnorePredicate:t=isInputElement}={})=>{const[n,s]=useKeyBindingState(),o=a.useCallback((e=>{Object.keys(n.bindings).filter((t=>t.includes(e)&&allPressed(t,Object.assign(Object.assign({},n.pressed),{[e]:!0})))).forEach((e=>{const t=n.bindings[e],a=t.length>0?t[t.length-1]:void 0;null!=a&&(a.fn(),s({type:"remove-key-binding",binding:a}))}))}),[n]);a.useEffect((()=>{const handleKeyDown=e=>{if(!e.repeat&&!t(e.target)){s({type:"set-key-pressed",key:e.key,pressed:!0}),o(e.key);const t=Object.assign(Object.assign({},n.pressed),{[e.key]:!0}),a=matchingSingleFnBindings(n.applyBindings,t,e.key),i=matchingOffBindings(n.applyBindings,t,e.key);(a.length>0||i.length>0)&&e.preventDefault()}},handleKeyUp=e=>{s({type:"set-key-pressed",key:e.key,pressed:!1})};return window.addEventListener("keydown",handleKeyDown),window.addEventListener("keyup",handleKeyUp),()=>{window.removeEventListener("keydown",handleKeyDown),window.removeEventListener("keyup",handleKeyUp)}}),[o,n.applyBindings,n.pressed]),a.useEffect((()=>{const e=matchingSingleFnBindings(n.applyBindings,n.pressed,n.lastPressed),t=matchingOffBindings(n.applyBindings,n.pressed,n.lastPressed);e.forEach((e=>e())),t.forEach((e=>e()))}),[n.pressed,n.lastPressed]),a.useEffect((()=>{const t=n.applyBindings.filter((e=>e.repeat&&null!=e.keyBind&&allPressed(e.keyBind,n.pressed))).map((e=>e.fn));if(t.length>0){const n=setInterval((()=>{t.forEach((e=>e()))}),e);return()=>{clearInterval(n)}}return()=>{}}),[n.applyBindings,n.lastPressed])},VertexBoxSelectionButton=()=>{const t=useBoxSelectionActions(),a=n.useRecoilValue(Me);return useStackKeyBinding({id:"ExitBoxSelection",keyBind:"Escape",fn:t.disable,addPredicate:()=>a,cancelPredicate:()=>!a},[a]),e.jsx(o.VertexTooltip,{content:"Box Selection",children:e.jsx(o.VertexIconButton,{iconName:"box-cursor",iconColor:a?"primary":"secondary","data-testid":"viewer-toolbar-enable-box-selection-button",onClick:a?t.disable:t.enable})})},ln=1,VertexResizableContent=t=>{var{className:n,style:a,displayShadow:s,heading:i,id:l,initialScale:r,placement:c="left",children:u,onResize:d}=t,m=__rest(t,["className","style","displayShadow","heading","id","initialScale","placement","children","onResize"]);const p="left"===c||"right"===c,h="top"===c;function getHorizontalResizeDirection(){switch(c){case"left":return"right";case"right":return"left";default:return"none"}}function getVerticalResizeDirection(){return"top"===c?"top":"none"}const f=null!=r?r:1;return e.jsx(o.VertexResizable,Object.assign({id:l,"data-testid":`resizable-content-position-${c}`,className:Ce(n,"pointer-events-auto z-popover md:z-overlay bg-white bg-opacity-95 flex-grow-0 flex-shrink-0 border-neutral-300",{"border-r min-w-75 max-w-half":"left"===c,"sidebar-shadow-right":"left"===c&&s,"border-l min-w-75 max-w-half":"right"===c,"sidebar-shadow-left":"right"===c&&s,"border-t bottom-0 fixed":"top"===c,"min-h-12 sheet":h}),style:Object.assign({maxHeight:"top"===c?window.innerHeight:void 0},a),initialHorizontalScale:p?r:void 0,initialVerticalScale:h?f:void 0,horizontalDirection:getHorizontalResizeDirection(),verticalDirection:getVerticalResizeDirection(),position:"right"===c||"top"===c?"absolute":"relative",onResizeEnd:()=>null==d?void 0:d()},m,{children:e.jsxs("div",{className:"flex flex-col h-full w-full",children:["top"===c&&e.jsx("div",{className:"flex justify-center w-full",children:e.jsx("div",{className:"block md:hidden w-20 h-0.5 mt-0.5 bg-neutral-600 rounded"})}),i,e.jsx("div",{className:Ce("w-full flex flex-col h-0 flex-grow",{"right-0":"right"===c}),children:u})]})}))};function useDefaultKeybindings(){useApplyKeyBinding({fn:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromiseRequired(H),n={milliseconds:500},a=await t();await(null==a?void 0:a.camera().viewAll().render({animation:n}))})),keyBind:"f"})}function useLongPress({target:e,callback:t,delay:n=500,onMovement:a}){const[o,i]=u.useState(),[l,r]=u.useState();u.useEffect((()=>{const handleTouchStart=e=>{const a=e;null!=a.touches&&1===a.touches.length&&(null!=o&&clearTimeout(o),r(s.Point.create(a.touches[0].clientX,a.touches[0].clientY)),i(setTimeout((()=>null==t?void 0:t(a)),n)))},handleTouchMove=e=>{const t=e;null!=t.touches&&t.touches.length>0&&null!=o&&null!=l&&s.Point.distance(l,s.Point.create(t.touches[0].clientX,t.touches[0].clientY))>=2&&(clearTimeout(o),null==a||a())},handleTouchEnd=()=>{null!=o&&clearTimeout(o)};return null==e||e.addEventListener("touchstart",handleTouchStart),null==e||e.addEventListener("touchmove",handleTouchMove),null==e||e.addEventListener("touchend",handleTouchEnd),()=>{null==e||e.removeEventListener("touchstart",handleTouchStart),null==e||e.removeEventListener("touchmove",handleTouchMove),null==e||e.removeEventListener("touchend",handleTouchEnd)}}),[e,o,l])}function asBooleanAttribute(e){return!!e||void 0}const VertexContextMenu=({targetElement:t,menuType:s,disableBackdrop:i,openPredicate:l,onOpen:r,onClose:c,children:u})=>{const d=useContextMenuActions(),m=n.useRecoilValue(Pe),p=n.useRecoilValue(Oe),h=a.useMemo((()=>["bottom-end","top-start","top-end","right","left"]),[]),f=m===s;useStackKeyBinding({id:"ContextMenu",keyBind:"Escape",fn:d.clearActiveContextMenu,addPredicate:()=>null!=m&&m===s,cancelPredicate:()=>null==m},[m]);const g=a.useMemo((()=>null!=t?t:null!=l?window:void 0),[t,l]);return useLongPress({target:g,callback:e=>d.longPress(e,s,l,r),onMovement:()=>d.clearActiveContextMenu()}),a.useEffect((()=>{const handleWindowPointerDown=e=>{const t=undefined;if(!targetWithinMenu(e)&&2!==e.buttons&&m===s){const t=targetShouldSkipNextHit(e);d.clearActiveContextMenu(t)}};if(i)return window.addEventListener("pointerdown",handleWindowPointerDown),()=>{window.removeEventListener("pointerdown",handleWindowPointerDown)}}),[i,s,m]),a.useEffect((()=>{const handlePointerDown=e=>{d.pointerDown(e)},handlePointerUp=e=>{d.pointerUp(e,s,l,r)},handleContextMenu=e=>d.contextMenu(e,l);return null==g||g.addEventListener("pointerdown",handlePointerDown),null==g||g.addEventListener("pointerup",handlePointerUp),null==g||g.addEventListener("contextmenu",handleContextMenu),()=>{null==g||g.removeEventListener("pointerdown",handlePointerDown),null==g||g.removeEventListener("pointerup",handlePointerUp),null==g||g.removeEventListener("contextmenu",handleContextMenu)}}),[t,s,l]),e.jsx("div",{className:Ce({hidden:!f}),children:e.jsx(o.VertexMenu,{"data-testid":`${s}-context-menu`,open:asBooleanAttribute(f),position:p,fallbackPlacements:h,backdrop:!i,onMenuClosed:()=>{d.clearActiveContextMenu(),null==c||c()},children:e.jsx("div",{className:"pt-1",children:u})})})},VertexFitSelectedMenuItem=()=>{const t=n.useRecoilValue(ot),a=n.useRecoilValue(pt),s=useViewerCameraActions();return e.jsxs(o.VertexMenuItem,{"data-testid":"fit-selected-menu-option",onClick:()=>{null!=(null==a?void 0:a.boundingBox)&&s.flyToByBoundingBox(a.boundingBox)},disabled:asBooleanAttribute(0===t.length),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"fit-selected",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Fit Selected"})]})},VertexFlyToMenuItem=()=>{const t=useViewerCameraActions(),a=n.useRecoilValue(Re);return e.jsxs(o.VertexMenuItem,{"data-testid":"fly-to-part-menu-option",onClick:()=>{var e;const n=undefined,s=contextMenuItemIsRow(a)?null===(e=null==a?void 0:a.node.id)||void 0===e?void 0:e.hex:null==a?void 0:a.id;null!=s&&t.flyToById(s)},disabled:asBooleanAttribute(null==a),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"paper-airplane",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Fly To"})]})};function useSceneItemsOperations(){const e=n.useRecoilValue(M),t=undefined,s=undefined,o=undefined,i=undefined,l=undefined,r=undefined;return{sceneItemsOperation:a.useCallback((async(t,n)=>{const a=await(null==e?void 0:e.scene());null==n?await(null==a?void 0:a.items((e=>t(e.where((e=>e.all()))))).execute()):n.length>0&&await(null==a?void 0:a.items((e=>t(e.where((e=>e.withItemIds(n)))))).execute())}),[e]),showOnlySelected:a.useCallback((async()=>{const t=await(null==e?void 0:e.scene());null==t||t.items((e=>[e.where((e=>e.all())).hide(),e.where((e=>e.withSelected())).show()])).execute()}),[e]),hideSelected:a.useCallback((async()=>{const t=await(null==e?void 0:e.scene());null==t||t.items((e=>[e.where((e=>e.withSelected())).hide()])).execute()}),[e]),showOnlyItem:a.useCallback((async t=>{const n=await(null==e?void 0:e.scene());null==n||n.items((e=>[e.where((e=>e.all())).hide(),e.where((e=>e.withItemIds([t]))).show()])).execute()}),[e]),ghostSelected:a.useCallback((async()=>{const t=await(null==e?void 0:e.scene());null==t||t.items((e=>[e.where((e=>e.withSelected())).setPhantom(!0)])).execute()}),[e]),unGhostSelected:a.useCallback((async()=>{const t=await(null==e?void 0:e.scene());null==t||t.items((e=>[e.where((e=>e.withSelected())).setPhantom(!1)])).execute()}),[e])}}const VertexHideAllMenuItem=()=>{const t=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"hide-all-menu-option",onClick:()=>{t.sceneItemsOperation((e=>e.hide()))},children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Hide All Parts"})]})},VertexHidePartMenuItem=()=>{const t=n.useRecoilValue(Re),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"hide-menu-option",onClick:()=>{var e;const n=undefined,s=contextMenuItemIsRow(t)?null===(e=null==t?void 0:t.node.id)||void 0===e?void 0:e.hex:t.id;null!=s&&a.sceneItemsOperation((e=>e.hide()),[s])},disabled:asBooleanAttribute(null==t),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Hide Part"})]})},VertexHideSelectedMenuItem=()=>{const t=n.useRecoilValue(ot),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"hide-selected-menu-option",onClick:()=>a.hideSelected(),disabled:asBooleanAttribute(0===t.length),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Hide Selected"})]})},VertexShowAllMenuItem=()=>{const t=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"show-all-menu-option",onClick:()=>{t.sceneItemsOperation((e=>e.show()))},children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Show All Parts"})]})},VertexShowOnlyMenuItem=()=>{const t=n.useRecoilValue(Re),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"show-only-menu-option",onClick:()=>{var e;const n=undefined,s=contextMenuItemIsRow(t)?null===(e=null==t?void 0:t.node.id)||void 0===e?void 0:e.hex:null==t?void 0:t.id;null!=s&&a.showOnlyItem(s)},disabled:asBooleanAttribute(null==t),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Show Only Part"})]})},VertexShowOnlySelectedMenuItem=()=>{const t=n.useRecoilValue(ot),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"show-only-selected-menu-option",onClick:()=>a.showOnlySelected(),disabled:asBooleanAttribute(0===t.length),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Show Only Selected"})]})};n.atom({key:"sceneTreeLoaderVisible",default:!1});const rn=n.atom({key:"sceneTreeElement",default:void 0}),cn=n.atom({key:"sceneTreeController",default:void 0,dangerouslyAllowMutability:!0});function useSceneTreeActions(){const e=useSelectionActions(),t=useViewerCameraActions();return{toggleSelection:useActionCallback((({snapshot:t})=>async(n,a,s)=>{var o,i;if(!n.defaultPrevented&&0===n.button&&(n.altKey||((n.ctrlKey||n.metaKey)&&a.selected?await s.deselectItem(a):a.selected?await s.selectItem(a,{recurseParent:!0}):a.selected||await s.selectItem(a,{append:n.ctrlKey||n.metaKey,range:n.shiftKey})),null!=a.id)){const s=await t.getPromise(it);e.syncSelection({id:null===(o=a.id)||void 0===o?void 0:o.hex,ancestors:null!==(i=null==s?void 0:s.ancestors)&&void 0!==i?i:[]},{selected:!n.metaKey&&!n.ctrlKey||!a.selected,multiSelect:n.shiftKey||n.metaKey||n.ctrlKey})}})),toggleExpansion:useActionCallback((()=>(e,t,n)=>{n.toggleExpandItem(t)})),toggleVisibility:useActionCallback((()=>(e,t,n)=>{n.toggleItemVisibility(t)})),flyToRow:useActionCallback((({snapshot:e})=>async n=>{var a;const s=await e.getPromise(rn),o=await(null==s?void 0:s.getRowAtClientY(n));null!=(null===(a=null==o?void 0:o.node.id)||void 0===a?void 0:a.hex)&&await t.flyToById(o.node.id.hex)})),flyToFirstSelectedItem:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(rn),n=await e.getPromise(ut);null!=n&&(null==t||t.scrollToItem(n))})),setContextMenuItem:useActionCallback((({set:e,snapshot:t})=>async n=>{const a=await t.getPromise(rn),s=await(null==a?void 0:a.getRowAtClientY(n));e(Re,s)}))}}const VertexGhostSelectedMenuItem=()=>{const t=n.useRecoilValue(ot),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"ghost-selected-menu-option",onClick:()=>a.ghostSelected(),disabled:asBooleanAttribute(0===t.length),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-partial",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Ghost Selected"})]})},VertexUnghostSelectedMenuItem=()=>{const t=n.useRecoilValue(ot),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"unghost-selected-menu-option",onClick:()=>a.unGhostSelected(),disabled:asBooleanAttribute(0===t.length),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Unghost Selected"})]})},DefaultSceneTreeContextMenu=()=>e.jsxs("div",{className:"w-56",children:[e.jsx(VertexHideSelectedMenuItem,{}),e.jsx(VertexHideAllMenuItem,{}),e.jsx(VertexShowOnlyMenuItem,{}),e.jsx(VertexShowOnlySelectedMenuItem,{}),e.jsx(VertexShowAllMenuItem,{}),e.jsx(VertexGhostSelectedMenuItem,{}),e.jsx(VertexUnghostSelectedMenuItem,{}),e.jsx(o.VertexMenuDivider,{}),e.jsx(VertexFitSelectedMenuItem,{}),e.jsx(VertexFlyToMenuItem,{})]}),VertexSceneTreeContextMenu=({children:t})=>{const a=useSceneTreeActions(),s=n.useRecoilValue(rn),o=null!=t&&!1!==t;return e.jsx(VertexContextMenu,{menuType:"scene-tree",targetElement:s,onOpen:async(e,t)=>{const n=e;await a.setContextMenuItem(n.clientY)},disableBackdrop:!0,children:o?t:e.jsx(DefaultSceneTreeContextMenu,{})})},DefaultViewerContextMenu=()=>e.jsxs("div",{className:"w-56",children:[e.jsx(VertexHidePartMenuItem,{}),e.jsx(VertexHideSelectedMenuItem,{}),e.jsx(VertexHideAllMenuItem,{}),e.jsx(VertexShowOnlyMenuItem,{}),e.jsx(VertexShowOnlySelectedMenuItem,{}),e.jsx(VertexShowAllMenuItem,{}),e.jsx(VertexGhostSelectedMenuItem,{}),e.jsx(VertexUnghostSelectedMenuItem,{}),e.jsx(o.VertexMenuDivider,{}),e.jsx(VertexFitSelectedMenuItem,{}),e.jsx(VertexFlyToMenuItem,{})]}),VertexViewerContextMenu=({children:t})=>{const n=null!=t&&!1!==t,s=a.useCallback((e=>e.target instanceof HTMLElement&&"vertex-viewer"===e.target.id),[]);return e.jsx(VertexContextMenu,{menuType:"viewer",disableBackdrop:!0,openPredicate:s,children:n?t:e.jsx(DefaultViewerContextMenu,{})})},un=35,dn=n.atom({key:"sceneItemGhostingSelectedOpacity",default:un}),mn=n.atomFamily({key:"appliedItemPhantomState",default:void 0}),pn=n.atom({key:"appliedItemPhantomStateIds",default:[]}),xn=n.selector({key:"sceneItemGhostingLastSelectedPhantom",get:({get:e})=>{var t;const n=e(it);return null!=n&&(null!==(t=e(mn(n.id)))&&void 0!==t&&t)}}),VertexSceneItemGhostingOpacitySlider=({onApply:t})=>{const[a,s]=n.useRecoilState(dn);return e.jsx(VertexSlider,{id:"phantom-opacity","data-testid":"phantom-opacity-slider",leftLabel:"0%",rightLabel:"100%",min:0,max:100,step:5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{s(e.detail.value)},onValueChange:e=>{null==t||t(e.detail.value)}})},useSceneItemPhantomActions=()=>{const e=useViewerSceneActions(),t=useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=undefined;(await e.getPromise(pn)).forEach((e=>t(mn(e)))),t(pn)}));return{setPhantomState:useActionCallback((({snapshot:t,set:n})=>async a=>{const s=await t.getPromise(ot);s.forEach((e=>n(mn(e),a))),n(pn,(e=>[...e,...s])),await e.execute(tt.SET_PHANTOM_SELECTED_ITEMS,(e=>e.where((e=>e.withSelected())).setPhantom(a)))})),clearPhantomState:useActionCallback((({snapshot:t,set:n,reset:a})=>async()=>{const s=await t.getPromise(ot);s.forEach((e=>a(mn(e)))),n(pn,(e=>e.filter((e=>!s.includes(e))))),await e.execute(tt.CLEAR_PHANTOM_SELECTED_ITEMS,(e=>e.where((e=>e.withSelected())).clearPhantom()),(e=>e.where((e=>e.withSelected())).select()))})),clearAllPhantomState:useActionCallback((()=>async()=>{await t(),await e.execute(tt.CLEAR_PHANTOM_ALL,(e=>e.where((e=>e.all())).clearPhantom()),(e=>e.where((e=>e.withSelected())).select()))})),resetAllPhantomState:t}},VertexSceneItemGhostingToggle=({onApply:t})=>{const a=useSceneItemPhantomActions(),s=n.useRecoilValue(ft),i=n.useRecoilValueLoadable(xn);return e.jsx(o.VertexTooltip,{content:"Select a part to display as ghost",disabled:s,children:e.jsx(o.VertexToggle,{className:"flex items-center","data-testid":"phantom-state-toggle",variant:"switch",disabled:!s,checked:"hasValue"===i.state&&i.contents,onValueChanged:async e=>{await a.setPhantomState(e.detail),null==t||t(e.detail)}})})};function VertexGhostingControls({onApplyGhostingChange:t,onApplyOpacity:n}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center py-3",children:[e.jsx(VertexSceneItemGhostingToggle,{onApply:t}),e.jsx("span",{className:"pl-4 text-sm text-neutral-700",children:"Display as Ghost"})]}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Global Ghost Opacity"}),e.jsx(VertexSceneItemGhostingOpacitySlider,{onApply:n})]})}const VertexSceneItemGhostingClear=({onClear:t,onClearAll:a})=>{const s=useSceneItemPhantomActions(),i=n.useRecoilValue(xn);return e.jsx("div",{className:"ml-auto",children:e.jsxs(ResetButton,{id:"phantom",tooltip:"Clear Ghosting",children:[e.jsx("div",{className:"pt-1"}),e.jsx(o.VertexMenuItem,{"data-testid":"reset-selected-phantom",onClick:async()=>{await s.clearPhantomState(),null==t||t()},disabled:!i,children:"Clear ghosting for selected"}),e.jsx(o.VertexMenuItem,{"data-testid":"reset-all-phantom",onClick:async()=>{await s.clearAllPhantomState(),null==a||a()},children:"Clear ghosting for all"})]})})};function VertexGhostingPanelSection({onClearGhostState:t,onClearAllGhostState:n,onApplyGhostingChange:a,onApplyOpacity:s}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Ghosting",e.jsx(VertexSceneItemGhostingClear,{onClear:t,onClearAll:n})]}),children:e.jsx(VertexGhostingControls,{onApplyGhostingChange:a,onApplyOpacity:s})})}function VertexMeasurementContextMenu({onDelete:t}){const a=n.useRecoilValue(Ie);return e.jsx(VertexContextMenu,{menuType:"measurement",openPredicate:e=>e.target instanceof HTMLElement&&"VERTEX-VIEWER-MEASUREMENT-DISTANCE"===e.target.tagName,children:e.jsxs(o.VertexMenuItem,{"data-testid":"measurement-delete",onClick:()=>null!=a&&t(a.id),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"delete",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Delete"})]})})}function useDockedPlacement(e,t){const[n,a]=u.useState(s.Point.create(0,0));return u.useLayoutEffect((()=>{if(null!=e){const n=e.getBoundingClientRect(),o=s.Point.create(n.left,n.bottom),i=s.Point.create(n.right,n.bottom);a("left"===t?o:i)}}),[e,t]),n}function VertexMeasurementDetails({placement:t}){const a=useMeasurementActions(),s=n.useRecoilValue(M),i=n.useRecoilValue(L),r=useDockedPlacement(null!=s?s:null,t),c=n.useRecoilValue(qe),u=n.useRecoilValue(Ye),d=n.useRecoilValue(Xe),m=n.useRecoilValue(Ze),p=n.useRecoilValue(vt),h=n.useRecoilValue(yt);return e.jsx(o.VertexDraggablePopover,{className:"z-popover",boundaryPadding:16,boundarySelector:`#${i}`,position:r,children:e.jsxs("div",{className:"flex flex-col leading-4 min-w-40",children:[e.jsxs("div",{className:"pb-2 flex justify-between",children:[e.jsx("div",{className:"w-full",children:"Measurement"}),e.jsx("div",{className:Ce("-mt-1 relative",{hidden:!m}),children:e.jsx(o.VertexTooltip,{content:"Reset",placement:"left-start",children:e.jsx(o.VertexIconButton,{"data-testid":"measurement-details-reset",iconName:"reset",iconSize:"sm",onClick:a.resetMeasurement})})})]}),e.jsx(l.VertexViewerMeasurementDetails,{"data-testid":"measurement-details-viewer-measurement-details",className:Ce("gap-y-1.5 text-xs",{hidden:null==c}),measurementOutcome:c,measurementOverlays:u,distanceUnits:toUnitType(p),fractionalDigits:parseInt(h,10)}),e.jsx("div",{"data-testid":"measurement-details-message",className:Ce("text-xs",{hidden:null==d}),children:d})]})})}function useCallbackRef(e){var t;const[n,s]=a.useState((t=void 0,null)),o=undefined;return{element:n,callback:a.useCallback((e=>s(e)),[])}}function VertexPointToPointMeasurement({detailsPlacement:t,onPointToPointMeasurementChange:s}){const o=useMeasurementActions(),i=n.useRecoilValue(M),r=n.useRecoilValue(Be),c=n.useRecoilValue(De),u=n.useRecoilValue(vt),d=n.useRecoilValue(yt),{callback:m,element:p}=useCallbackRef();usePointToPointMeasurement(p);const h=a.useCallback((e=>{const t={start:e.detail.start,end:e.detail.end,invalid:!e.detail.valid};o.setEditedPointToPointMeasurement(t),null==s||s(t)}),[o]);return r?e.jsxs(e.Fragment,{children:[e.jsx(l.VertexViewerMeasurementDistance,{"data-testid":"point-to-point-measurement",ref:m,viewer:null!=i?i:void 0,mode:"replace",start:null==c?void 0:c.start,end:null==c?void 0:c.end,invalid:null==c?void 0:c.invalid,units:toUnitType(u),fractionalDigits:parseInt(d,10),showAxisReferenceLines:!0,onEditEnd:h}),e.jsx(VertexMeasurementDetails,{placement:t}),e.jsx(VertexMeasurementContextMenu,{onDelete:o.resetMeasurement})]}):e.jsx(e.Fragment,{})}function VertexPointToPointMeasurementTool(){const t=useMeasurementActions(),a=n.useRecoilValue(Be);return useStackKeyBinding({id:"ExitMeasurement",keyBind:"Escape",fn:t.disableEditMeasurement,addPredicate:()=>a,cancelPredicate:()=>!a},[a,t]),e.jsx(o.VertexTooltip,{content:"Point to Point Measurement",children:e.jsx(o.VertexIconButton,{iconName:"tape-measure","data-testid":"viewer-toolbar-point-to-point-measurement-button",iconColor:a?"primary":"secondary",onClick:t.toggleEditPointToPointMeasurement})})}const hn=n.atom({key:"viewerToolkitSdkConfig",default:void 0}),VertexPreciseMeasurement=({detailsPlacement:t,onEntitiesChanged:a,onOutcomeChanged:s})=>{var o,i,r,c;const u=n.useRecoilValue(M),d=n.useRecoilValue(hn),m=n.useRecoilValue(Fe),{callback:p,element:h}=useCallbackRef();return usePreciseMeasurementModel(h,a,s),m?e.jsxs(e.Fragment,{children:[e.jsx(l.VertexViewerMeasurementPrecise,{"data-testid":"precise-measurement-viewer-tool",ref:p,viewer:null!=u?u:void 0,config:JSON.stringify({network:{apiHost:null===(o=null==d?void 0:d.network)||void 0===o?void 0:o.apiHost,renderingHost:null===(i=null==d?void 0:d.network)||void 0===i?void 0:i.renderingHost,sceneTreeHost:null===(r=null==d?void 0:d.network)||void 0===r?void 0:r.sceneTreeHost,sceneViewHost:null===(c=null==d?void 0:d.network)||void 0===c?void 0:c.sceneViewHost}})}),e.jsx(VertexMeasurementDetails,{placement:t})]}):e.jsx(e.Fragment,{})};function VertexPreciseMeasurementTool(){const t=useMeasurementActions(),a=n.useRecoilValue(Fe);return e.jsx(o.VertexTooltip,{content:"Precise Measurement",children:e.jsx(o.VertexIconButton,{iconName:"ruler","data-testid":"viewer-toolbar-precise-measurement-button",iconColor:a?"primary":"secondary",onClick:t.toggleEditPreciseMeasurement})})}function VertexApplicationMessages(){const t=n.useRecoilValue(et),a=n.useRecoilValue(Qe);return e.jsxs(e.Fragment,{children:[null!=t&&e.jsx(o.VertexBanner,{className:"z-[16000]",duration:t.duration,open:!0,content:t.message,type:t.type},t.id),null!=a&&e.jsx(o.VertexToast,{placement:"bottom-left",className:"z-[16000]",duration:a.duration,open:!0,content:a.message,type:a.type},a.id)]})}const fn={binding:"{{row.node.name}}",label:"Name",metadataKeyName:"VERTEX_SCENE_ITEM_NAME"};function mapToColumn(e,t){return{label:"name"===e.toLowerCase()?"Name (Property)":e,binding:`{{row.metadata.${e}}}`,initialWidth:t,minWidth:t/2}}const gn=n.atom({key:"sceneTreeColumnsRefreshTrigger",default:0}),vn=n.selector({key:"sceneTreeColumnsAvailableColumns",get:async({get:e})=>{const t=e(cn);return e(gn),null!=t?await t.fetchMetadataKeys():[]}}),yn=n.selector({key:"sceneTreeColumnsAvailableSortedColumns",get:({get:e})=>e(vn).filter((e=>e!==fn.metadataKeyName)).sort(((e,t)=>e.localeCompare(t)))}),bn=n.atom({key:"sceneTreeColumnsVisibleMetadataColumnNames",default:[]}),Sn=n.selector({key:"sceneTreeColumnsActiveColumns",get:({get:e})=>{const t=e(bn),n=e(rn),a=null==n?void 0:n.clientWidth;if(null!=a&&a>0){const e=1/(t.length+1)*a,n=(a-e)/t.length;return t.reduce(((e,t)=>{const a=mapToColumn(t,n);return Object.assign(Object.assign({},e),{[a.label]:a})}),{Name:Object.assign(Object.assign({},fn),{initialWidth:e,minWidth:n})})}return{Name:fn}}}),wn=n.selector({key:"sceneTreeColumnsActiveColumnNames",get:({get:e})=>Object.keys(e(Sn))});function useSceneTreeColumnActions(){return{setActive:useActionCallback((({set:e,snapshot:t})=>async n=>{e(bn,n);const a=await t.getPromise(cn);null==a||a.setMetadataKeys(n)})),refreshKeyList:useActionCallback((({set:e})=>()=>{e(gn,(e=>e+1))}))}}const Vn=16,Cn=-8;var jn;function useOpenColumnPopover({buttonElement:e,horizontalOffset:t,verticalOffset:n}){const[a,s]=u.useState(!1),[o,i]=u.useState(),[l,r]=u.useState(),c=u.useCallback((()=>{if(a)s(!1);else{const a=null==e?void 0:e.getBoundingClientRect();if(null!=a){const e=null!=t?t:Vn,o=null!=n?n:Cn,l=a.x>window.innerWidth/2?jn.LEFT:jn.RIGHT;i({x:l===jn.LEFT?a.left-e:a.right+e,y:a.top+o}),r(l),s(!0)}}}),[a,e]),d=u.useCallback((()=>{s(!1)}),[]);return{open:a,position:o,direction:l,handleOpen:c,handleClose:d}}!function(e){e.LEFT="left",e.RIGHT="right"}(jn||(jn={}));const Tn=n.atom({key:"sceneTreeSearchActive",default:!1}),kn=n.atom({key:"sceneTreeColumnsPartial",default:!1}),An=n.atom({key:"sceneTreeSearchValue",default:void 0}),Pn=n.atom({key:"sceneTreeSearchExactMatch",default:!1}),En=n.atom({key:"sceneTreeSearchResultCount",default:0}),In=n.atom({key:"sceneTreeSearchActiveColumns",default:[]}),Rn=n.selector({key:"sceneTreeSearchNameColumnActive",get:({get:e})=>{const t=e(In);return 0===t.length||t.includes(fn.metadataKeyName)}});function useSceneTreeSearch({sceneTreeElement:e}){const t=useSceneTreeActions(),s=n.useRecoilValue(Tn),o=n.useSetRecoilState(En),i=n.useSetRecoilState(ut);a.useEffect((()=>{let t;return whenComponentReady(e,(()=>{var n;t=null===(n=null==e?void 0:e.controller)||void 0===n?void 0:n.stateChanged((e=>{void 0!==(null==e?void 0:e.totalFilteredRows)&&o(null==e?void 0:e.totalFilteredRows)}))})),()=>{null==t||t.dispose()}}),[e]),a.useEffect((()=>{if(null!=e){let n;return whenComponentReady(e,(()=>{var a;n=null===(a=null==e?void 0:e.controller)||void 0===a?void 0:a.stateChanged((e=>{var n;if(null!=(null==e?void 0:e.filterTerm)){const t=null==e?void 0:e.rows.find((e=>{var t;return null===(t=null==e?void 0:e.node)||void 0===t?void 0:t.selected}));i(null===(n=null==t?void 0:t.node.id)||void 0===n?void 0:n.hex)}else s&&t.flyToFirstSelectedItem()}))})),()=>{null==n||n.dispose()}}}),[e,null==e?void 0:e.controller,open])}function useSceneTreePartialResults({sceneTreeElement:e}){const t=n.useSetRecoilState(kn);a.useEffect((()=>{let n;return whenComponentReady(e,(()=>{var a;n=null===(a=null==e?void 0:e.controller)||void 0===a?void 0:a.stateChanged((e=>{t(!!(null==e?void 0:e.isPartialKeysResponse))}))})),()=>{null==n||n.dispose()}}),[e])}const useSceneTreeSearchActions=()=>{const e=useActionCallback((({set:e})=>t=>{e(In,t)})),t=useActionCallback((({snapshot:t})=>async(n,a,s,o)=>{const i=await t.getPromise(rn),l=await t.getPromise(Pn),r=await t.getPromise(In),c=r.length>0?a?[...r,n]:r.filter((e=>e!==n)):[...s,fn.metadataKeyName].filter((e=>e!==n));e(c),o&&(null==i||i.filterItems(o,{columns:c,exactMatch:l}))})),n=useActionCallback((({snapshot:e,set:t})=>async(n,a,s)=>{const o=await e.getPromise(rn),i=await e.getPromise(Pn),l=await e.getPromise(In),r=n.filter((e=>!a.includes(e))),c=a.filter((e=>!n.includes(e))),u=l.length>0?[...l.filter((e=>!r.includes(e))),...c]:[...a,fn.metadataKeyName],d=u.length>0?u:[...a,fn.metadataKeyName];t(In,d),s&&(null==o||o.filterItems(s,{columns:d,exactMatch:i}))})),a=useActionCallback((({set:e})=>t=>{e(Pn,t)}));return{setMetadataSearchKeys:e,updateMetadataSearchAfterSearchKeysChange:t,updateMetadataSearchAfterColumnVisibilityChange:n,setMetadataSearchExactMatch:a}};function useCacheableLoadable(e,t){const s=a.useRef(),[o,i]=a.useState(0),l=n.useRecoilValueLoadable(e);a.useEffect((()=>{"hasValue"===l.state&&(s.current=l.contents)}),[t,l]);const[r,c]=a.useMemo((()=>"hasValue"!==l.state&&null!=s.current?[s.current,!0]:"hasValue"===l.state?[l.contents,!1]:[void 0,!1]),[l.state,l.contents,o]),u=a.useCallback((()=>{s.current=void 0,i(o+1)}),[o]),d=undefined;return a.useMemo((()=>({data:r,state:l.state,cached:c,invalidate:u})),[u,r,c,l.state])}const VertexSceneTreeMetadataCheck=({checked:t,disabled:n,onChange:a,children:s})=>{const i="string"==typeof s?s.replace(" ","-"):"";return e.jsxs("div",{className:"flex items-center",children:[e.jsx(o.VertexToggle,{"data-testid":`scene-tree-metadata-check-${i}`,variant:"check",checked:t,disabled:n,onValueChanged:e=>null==a?void 0:a(e.detail)}),e.jsx("div",{className:"pl-2 py-1 text-[0.875rem] w-full","data-testid":`scene-tree-metadata-name-${i}`,onClick:()=>{n||null==a||a(!t)},children:s})]})},VertexSceneTreeColumnPopover=({onVisibleSceneTreeColumnsChange:t})=>{const a=useSceneTreeColumnActions(),s=useSceneTreeSearchActions(),i=n.useRecoilValue(rn);useSceneTreePartialResults({sceneTreeElement:null!=i?i:null});const r=n.useRecoilValue(An),c=useCacheableLoadable(yn),d=n.useRecoilValue(bn),m=n.useRecoilValue(kn),[p,h]=u.useState(d),[f,g]=u.useState(""),{element:v,callback:b}=useCallbackRef(),{open:S,position:w,direction:V,handleOpen:C,handleClose:j}=useOpenColumnPopover({buttonElement:v}),T=V===jn.LEFT?"left-end":"right-start",k=u.useMemo((()=>{if(null!=c.data){const e=c.data.filter((e=>p.indexOf(e)<0)),t=undefined;return[...[...p].sort(((e,t)=>e.localeCompare(t))),...e]}return[]}),[p,c.data]),A=u.useMemo((()=>k),[S,c.data]);return e.jsxs(e.Fragment,{children:[e.jsx(o.VertexTooltip,{content:"Configure Columns",placement:"top",children:e.jsx(o.VertexIconButton,{"data-testid":"scene-tree-column-popover-button",ref:b,iconName:"columns-add",iconSize:"sm",onClick:()=>{C()}})}),S&&e.jsx(o.VertexPopover,{"data-testid":"scene-tree-column-popover",open:S,backdrop:!1,position:w,resizeBehavior:"fixed",placement:T,className:"z-popover",children:e.jsxs("div",{className:Ce("flex flex-col bg-white border border-neutral-300 rounded",{hidden:!S}),children:[e.jsxs("div",{className:"flex items-center text-[0.875rem] p-3",children:[e.jsxs("div",{className:"pr-2",children:[e.jsx("div",{className:"text-[0.875rem]",children:"Assembly Properties"}),e.jsx("div",{className:"text-[0.75rem] text-neutral-700 mt-1.5",children:"Select up to six properties to appear in the Assembly panel."})]}),e.jsx(o.VertexIconButton,{"data-testid":"scene-tree-columns-popover-close-button",className:"ml-auto",iconName:"close",iconSize:"sm",onClick:()=>{g(""),j()}})]}),e.jsx(o.VertexTextfield,{className:"flex w-full px-2 overflow-hidden border-b border-neutral-300 pb-2",id:"scene-tree-available-columns-search-bar","data-testid":"scene-tree-available-columns-search-bar",multiline:!1,placeholder:"Filter properties",type:"text",onInputInput:e=>{const t=e.detail.value;null!=t&&g(t.toLowerCase())}}),m&&e.jsx(l.VertexSceneTreeNotificationBanner,{"data-testid":"partial-key-list-notification-banner",message:"loading"===c.state?"Refreshing results...":"Data loading, refresh for more.",actionLabel:"Refresh",onAction:()=>a.refreshKeyList()}),e.jsxs("div",{className:"max-h-64 p-3 overflow-y-auto",children:[e.jsx(VertexSceneTreeMetadataCheck,{checked:!0,disabled:!0,children:fn.label}),A.filter((e=>""===f||e.toLowerCase().includes(f))).map((t=>e.jsx(VertexSceneTreeMetadataCheck,{checked:p.includes(t),disabled:p.length>=6&&!p.includes(t),onChange:e=>{h(e?[...p,t]:p.filter((e=>e!==t)))},children:t},t)))]}),e.jsxs("div",{className:"flex items-center p-3 border-t border-neutral-300 space-x-4",children:[e.jsx("div",{className:"text-[0.75rem] text-[var(--vertex-ui-blue-700)] cursor-pointer","data-testid":"scene-tree-column-clear-selection",onClick:()=>h([]),children:"Clear selection"}),e.jsx("div",{className:"flex-grow"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(o.VertexButton,{"data-testid":"scene-tree-column-popover-cancel",color:"secondary",onClick:()=>{g(""),j()},children:"Cancel"}),e.jsx(o.VertexButton,{"data-testid":"scene-tree-column-popover-apply",color:"primary",onClick:async()=>{await s.updateMetadataSearchAfterColumnVisibilityChange(d,p,r),await a.setActive(p),null==t||t(p),g(""),j()},children:"Apply"})]})]})]})})]})},VertexSceneTreeSearchOptionsPopover=({onSearchedSceneTreeColumnsChange:t,onSearchForExactMatchChange:a})=>{const s=useSceneTreeSearchActions(),i=n.useRecoilValue(rn),l=n.useRecoilValue(Rn),r=n.useRecoilValue(In),c=n.useRecoilValue(An),u=n.useRecoilValue(Pn),d=n.useRecoilValue(bn),{element:m,callback:p}=useCallbackRef(),{open:h,position:f,direction:g,handleOpen:v,handleClose:b}=useOpenColumnPopover({buttonElement:m,horizontalOffset:40}),S=g===jn.LEFT?"left-end":"right-start",updateSearch=e=>{if(c){const t=r.length>0?r:[...d,fn.metadataKeyName];null==i||i.filterItems(c,{columns:t,exactMatch:e})}};return e.jsxs(e.Fragment,{children:[e.jsx(o.VertexTooltip,{content:"Search Options",placement:"top",children:e.jsx(o.VertexIconButton,{"data-testid":"scene-tree-search-options-popover-button",ref:p,iconName:"gear",iconSize:"sm",onClick:()=>{v()}})}),e.jsx(o.VertexPopover,{"data-testid":"scene-tree-search-options-popover",open:h,backdrop:!1,position:f,resizeBehavior:"fixed",placement:S,className:"z-popover",children:e.jsxs("div",{className:Ce("flex flex-col bg-white border border-neutral-300 rounded",{hidden:!h}),children:[e.jsxs("div",{className:"flex items-center text-[0.875rem] p-3 border-b border-neutral-300 pb-2",children:[e.jsx("div",{className:"pr-2 text-[0.875rem] whitespace-nowrap",children:"Column Properties Search"}),e.jsx(o.VertexIconButton,{className:"ml-auto",iconName:"close",iconSize:"sm",onClick:()=>{b()}})]}),e.jsxs("div",{className:"max-h-64 p-3 overflow-y-auto",children:[e.jsx("div",{className:"text-[0.875rem] pb-2 pr-2",children:"Select properties to perform the search on:"}),e.jsx(VertexSceneTreeMetadataCheck,{checked:l,disabled:0===r.length||r.every((e=>e===fn.metadataKeyName)),onChange:async e=>{await s.updateMetadataSearchAfterSearchKeysChange(fn.metadataKeyName,e,d,c),null==t||t()},children:fn.label},fn.metadataKeyName),d.map((n=>e.jsx(VertexSceneTreeMetadataCheck,{checked:r.includes(n),disabled:r.length>0&&r.every((e=>e===n)),onChange:async e=>{await s.updateMetadataSearchAfterSearchKeysChange(n,e,d,c),null==t||t()},children:n},n)))]}),e.jsxs("div",{className:"flex p-3 border-t border-neutral-300",children:[e.jsx(o.VertexToggle,{className:"flex items-center","data-testid":"filter-exact-match-toggle",variant:"switch",checked:u,onValueChanged:async e=>{s.setMetadataSearchExactMatch(e.detail),null==a||a(),updateSearch(e.detail)}}),e.jsx("span",{className:"pl-4 text-[0.875rem] text-neutral-800",children:"Return only exact matches"})]})]})})]})},VertexSceneTreeSearchBar=({onSearch:t,onClearSearch:a,onExitSearchMode:s,onSearchedSceneTreeColumnsChange:i,onSearchForExactMatchChange:r,children:c})=>{const d=useSceneTreeActions(),m=n.useRecoilValue(rn),[p,h]=n.useRecoilState(Tn),[f,g]=n.useRecoilState(An);useSceneTreeSearch({sceneTreeElement:null!=m?m:null});const{element:v,callback:b}=useCallbackRef(),S=null==f||""===f,w=S?"Exit Search":"Clear Search";return u.useEffect((()=>{p&&(null==v||v.setFocus())}),[v,p]),e.jsxs("div",{className:"flex w-full py-3 px-2",children:[e.jsx(l.VertexSceneTreeSearch,{"data-testid":"scene-tree-search-bar",ref:b,controller:null==m?void 0:m.controller,onBlur:()=>{S&&(h(!1),null==s||s())},onSearch:()=>{g(null==v?void 0:v.value),null==t||t(null==v?void 0:v.value)},children:c}),e.jsx("div",{className:"self-center px-1",onPointerDown:e=>{e.preventDefault()},children:e.jsx(VertexSceneTreeSearchOptionsPopover,{onSearchedSceneTreeColumnsChange:i,onSearchForExactMatchChange:r})}),e.jsx(o.VertexTooltip,{className:"self-center pr-1",content:w,children:e.jsx(o.VertexIconButton,{"data-testid":"scene-tree-search-close-button",iconName:"close-circle-fill",iconSize:"sm",variant:"plain",onPointerDown:e=>{e.preventDefault()},onClick:async()=>{S?(h(!1),await d.flyToFirstSelectedItem(),null==s||s()):(await(null==v?void 0:v.clear()),await(null==v?void 0:v.setFocus()),g(void 0),null==a||a())}})})]})};function VertexToolbarDivider(){return e.jsx("div",{"data-testid":"toolbar-divider",className:"h-6 w-px bg-neutral-300 mx-1"})}const VertexSceneTreeSearchInformationForToolbar=()=>{const t=useSelectionActions(),a=n.useRecoilValue(rn),s=n.useRecoilValue(An),i=n.useRecoilValue(En),l=undefined,r=undefined,c=`${i>=1e3?`${i}+`:`${i}`} ${1===i?"result":"results"}`;return e.jsxs(e.Fragment,{children:[e.jsx(VertexToolbarDivider,{}),e.jsxs("div",{className:"flex flex-row items-center overflow-hidden",children:[e.jsx("div",{className:"px-2 text-[0.8125rem] leading-4 text-neutral-900 truncate","data-testid":"search-result-info",children:`${c}`}),e.jsx(o.VertexTooltip,{className:"w-auto",content:"Select Results",placement:"top",children:e.jsx(o.VertexButton,{className:"h-6 rounded cursor-pointer","data-testid":"select-search-results-button",color:"secondary",variant:"text",size:"sm",onClick:async()=>{null!=a&&null!=s&&(await a.selectFilteredItems(s),t.toggleLastSelectWasMultiSelect(!0))},children:e.jsxs("div",{className:"flex h-6 items-center gap-1",children:[e.jsx(o.VertexIcon,{size:"sm",name:"check-circle"}),e.jsx("span",{className:"whitespace-nowrap",children:"Select Results"})]})})})]})]})},targetIsElement=(e,t)=>e instanceof Element&&e.tagName===t;function useRecoilRef({state:e}){const t=n.useRecoilCallback((({set:t})=>n=>{t(e,n)}),[]);return t}var Nn;function styleFromOptionalFont(e){return null!=e?{"--scene-tree-default-font-family":styleFromFontFace(e.fontFace),"--scene-tree-default-font-color":e.color}:{}}function styleFromOptionalBackgroundColors(e){const t=null==e?void 0:e.depthColors,n=null!=t?Object.keys(t).reduce(((e,n)=>Object.assign(Object.assign({},e),{[`--scene-tree-row-background-color-depth-${n}`]:t[parseInt(n)]})),{}):{};return null!=e?Object.assign(Object.assign({},n),{"--scene-tree-hovered-row-background-color":e.hovered,"--scene-tree-selected-row-background-color":e.selected,"--scene-tree-row-background-color":e.defaultColor}):{}}function styleFromFontFace(e){return e===Nn.ROBOTO_MONO?"var(--vertex-ui-font-family-monospace)":"var(--vertex-ui-font-family)"}!function(e){e.ROBOTO="ROBOTO",e.ROBOTO_MONO="ROBOTO_MONO"}(Nn||(Nn={}));const VertexEnterSceneTreeSearchModeButton=({onEnterSearchMode:t})=>{const a=n.useSetRecoilState(Tn);return e.jsx(o.VertexTooltip,{className:"flex ml-auto",content:"Scene Tree Search",children:e.jsx(o.VertexIconButton,{"data-testid":"enter-scene-tree-search-mode-button",iconName:"search",iconSize:"sm",onPointerDown:e=>{e.preventDefault()},onClick:()=>{a(!0),null==t||t()}})})},VertexSceneTreeSearch=({onEnterSearchMode:t,onExitSearchMode:a,onSearch:s,onClearSearch:o,onSearchedSceneTreeColumnsChange:i,onSearchForExactMatchChange:r,children:c})=>{const u=n.useRecoilValue(Tn);return e.jsxs(l.VertexSceneTreeToolbar,{className:"h-11 p-0 border-b border-neutral-300 box-content",slot:"header",children:[u&&e.jsx(VertexSceneTreeSearchBar,{onSearch:s,onClearSearch:o,onExitSearchMode:a,onSearchedSceneTreeColumnsChange:i,onSearchForExactMatchChange:r,children:c}),!u&&e.jsx("div",{className:"ml-auto mr-2",children:e.jsx(VertexEnterSceneTreeSearchModeButton,{onEnterSearchMode:t})})]})},VertexSceneTreeCollapseAll=()=>{const t=n.useRecoilValue(rn);return e.jsx(o.VertexTooltip,{className:"w-auto",content:"Collapse All",placement:"top",children:e.jsx(o.VertexIcon,{size:"sm",className:"h-6 w-6 hover:bg-neutral-300 rounded cursor-pointer","data-testid":"collapse-all-icon",name:"collapse-all",onClick:()=>{null==t||t.collapseAll()}})})},VertexSceneTreeExpandAll=()=>{const t=n.useRecoilValue(rn);return e.jsx(o.VertexTooltip,{className:"w-auto",content:"Expand All",placement:"top",children:e.jsx(o.VertexIcon,{size:"sm","data-testid":"expand-all-icon",className:"h-6 w-6 hover:bg-neutral-300 rounded cursor-pointer",name:"expand-all",onClick:()=>{null==t||t.expandAll()}})})},VertexSceneTreeToolbar=({onVisibleSceneTreeColumnsChange:t})=>{const a=n.useRecoilValue(An),s=null==a||""===a;return e.jsx(l.VertexSceneTreeToolbar,{className:"h-10 border-b border-neutral-300 box-border",children:e.jsxs("div",{className:"flex w-full text-neutral-700 items-center gap mx-2",children:[e.jsx(VertexSceneTreeExpandAll,{}),e.jsx(VertexSceneTreeCollapseAll,{}),!s&&e.jsx(VertexSceneTreeSearchInformationForToolbar,{}),e.jsx("div",{className:"ml-auto",children:e.jsx(VertexSceneTreeColumnPopover,{onVisibleSceneTreeColumnsChange:t})})]})})},VertexSceneTreeHeader=({onEnterSearchMode:t,onExitSearchMode:n,onSearch:a,onClearSearch:s,onVisibleSceneTreeColumnsChange:o,children:i})=>{const l=null!=i&&!1!==i;return e.jsx("div",{slot:"header",className:"flex flex-col",children:l?i:e.jsxs(e.Fragment,{children:[e.jsx(VertexSceneTreeSearch,{onEnterSearchMode:t,onExitSearchMode:n,onSearch:a,onClearSearch:s,children:e.jsx("div",{slot:"clear-icon"})}),e.jsx(VertexSceneTreeToolbar,{onVisibleSceneTreeColumnsChange:o})]})})},VertexSceneTreeTableLayout=t=>{const a=n.useRecoilValue(Sn),s=n.useRecoilValue(wn),o=[];return e.jsx(l.VertexSceneTreeTableLayout,Object.assign({"data-testid":"scene-tree-table-layout"},t,{children:s.map(((t,n)=>{var i;const r=a[t],c=null!==(i=o[n])&&void 0!==i?i:r.initialWidth;return e.jsxs(l.VertexSceneTreeTableColumn,{"data-testid":`scene-tree-table-column-${n}`,initialWidth:c,minWidth:r.minWidth,children:[e.jsx("template",{slot:"header",dangerouslySetInnerHTML:{__html:`\n <div class="text-sm text-neutral-800 my-2">\n <div class="${Ce("truncate",{"pl-2":0===n,"pr-2":n===s.length-1})}">\n ${r.label}\n </div>\n </div>\n `}}),e.jsx("template",{dangerouslySetInnerHTML:{__html:`\n <vertex-scene-tree-table-cell\n prop:value="${r.binding}"\n prop:selection-handler="{{row.data.handleSelection}}"\n prop:expansion-handler="{{row.data.handleExpansion}}"\n prop:visibility-handler="{{row.data.handleVisibility}}"\n ${0===n?"expand-toggle":""}\n ${n===s.length-1?"isolate-button visibility-toggle":""}>\n <div class="flex items-center gap-2">\n <vertex-tooltip \n class="truncate" \n prop:content="${null!=r.binding?r.binding:"--"}" \n placement="${n!==s.length-1?"right":"top"}">\n <div class="flex items-center w-full">\n <div class="truncate">${r.binding}</div>\n </div>\n </vertex-tooltip>\n </div>\n \n\n <div slot="placeholder" class="flex items-center w-full truncate">\n <div> -- </div>\n </div>\n </vertex-scene-tree-table-cell>\n `}})]},r.label)}))}))},VertexSceneTree=t=>{var{id:s,font:o,backgroundColors:i,children:r,style:c,onPointerDown:u,onClick:d,onToggleSelection:m,onToggleExpansion:p,onToggleVisibility:h,className:f,rowData:g}=t,v=__rest(t,["id","font","backgroundColors","children","style","onPointerDown","onClick","onToggleSelection","onToggleExpansion","onToggleVisibility","className","rowData"]);const b=useSceneTreeActions(),S=useSelectionActions(),w=n.useRecoilValue(hn),V=n.useRecoilValue(M),C=n.useRecoilValue(In),j=n.useRecoilValue(Pn),T=n.useRecoilValue(An),k=null==T||""===T,A=useRecoilRef({state:rn}),P=null!=r&&!1!==r,wrappedExpansionHandler=(e,t,n)=>{b.toggleExpansion(e,t,n),null==p||p(e,t,n)},wrappedSelectionHandler=(e,t,n)=>{b.toggleSelection(e,t,n),null==m||m(e,t,n)},wrappedVisibilityHandler=(e,t,n)=>{b.toggleVisibility(e,t,n),null==h||h(e,t,n)},handleClick=e=>{e.altKey&&b.flyToRow(e.clientY),null==d||d(e)},handlePointerDown=e=>{targetIsElement(e.target,"VERTEX-SCENE-TREE-TABLE-COLUMN")&&S.clearSelection(),null==u||u(e)},E=n.useSetRecoilState(cn),handleFirstRowRendered=e=>{var t;E(e.target.controller),null===(t=null==v?void 0:v.onFirstRowRendered)||void 0===t||t.call(v,e)},I=a.useMemo((()=>({metadataSearchKeys:C,exactMatch:j})),[C,j]);return e.jsx("div",{className:Ce("flex flex-col w-full h-full",f),children:e.jsx("div",{className:"flex group h-full",children:e.jsx(l.VertexSceneTree,Object.assign({id:null!=s?s:"vertex-scene-tree","data-testid":"vertex-scene-tree",config:w,ref:A,className:Ce("flex-1",{filtered:!k}),style:Object.assign(Object.assign(Object.assign({},styleFromOptionalFont(o)),styleFromOptionalBackgroundColors(i)),c),onConnectionError:e=>{logger_error("Scene Tree Connection Error: ",e.detail)},viewer:V,onPointerDown:handlePointerDown,onClick:handleClick,rowData:e=>{var t;const n=null!==(t=null==g?void 0:g(e))&&void 0!==t?t:{};return Object.assign({handleExpansion:wrappedExpansionHandler,handleSelection:wrappedSelectionHandler,handleVisibility:wrappedVisibilityHandler},n)},searchOptions:I},v,{onFirstRowRendered:handleFirstRowRendered,children:P?r:e.jsxs(e.Fragment,{children:[e.jsx(VertexSceneTreeHeader,{}),e.jsx(VertexSceneTreeTableLayout,{}),e.jsx(VertexSceneTreeContextMenu,{})]})}))})})},VertexDecimalPlaceSelector=({onApply:t})=>{const[a,s]=n.useRecoilState(yt);return e.jsxs(o.VertexSelect,{"data-testid":"decimal-place-select",className:"w-24",value:a,onOptionChanged:e=>{s(e.detail),null==t||t(e.detail)},children:[e.jsx("div",{className:"py-1.5 px-3",children:"0"}),e.jsx("div",{className:"py-1.5 px-3",children:"1"}),e.jsx("div",{className:"py-1.5 px-3",children:"2"}),e.jsx("div",{className:"py-1.5 px-3",children:"3"})]})},VertexLengthUnitSelector=({onApply:t})=>{const[a,s]=n.useRecoilState(vt);return e.jsxs(o.VertexSelect,{"data-testid":"length-unit-select",className:"w-40",value:a,onOptionChanged:e=>{s(e.detail),null==t||t(e.detail)},children:[e.jsx("div",{"data-value":"cm",className:"py-1.5 px-3",children:"centimeters"}),e.jsx("div",{"data-value":"mm",className:"py-1.5 px-3",children:"millimeters"}),e.jsx("div",{"data-value":"m",className:"py-1.5 px-3",children:"meters"}),e.jsx("div",{"data-value":"in",className:"py-1.5 px-3",children:"inches"}),e.jsx("div",{"data-value":"ft",className:"py-1.5 px-3",children:"feet"})]})};function VertexUnitsControls({onUnitChange:t,onDecimalPlaceChange:n}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Length Unit"}),e.jsx(VertexLengthUnitSelector,{onApply:t})]}),e.jsxs("div",{children:[e.jsx("div",{className:"pt-2 pb-2 text-sm text-neutral-700",children:"Decimals"}),e.jsx(VertexDecimalPlaceSelector,{onApply:n})]})]})}function VertexUnitsPanelSection({onUnitChange:t,onDecimalPlaceChange:n}){return e.jsx(PanelSection,{header:e.jsx("div",{className:"flex items-center text-base",children:"Units"}),children:e.jsx(VertexUnitsControls,{onUnitChange:t,onDecimalPlaceChange:n})})}const On=n.atom({key:"openedPanelActivePrimaryLeft",default:void 0}),Mn=n.atom({key:"openedPanelActivePrimaryRight",default:void 0});function usePanelActions(){return{openPrimary:useActionCallback((({set:e})=>(t,n)=>{e("left"===n?On:Mn,t)})),closePrimary:useActionCallback((({set:e})=>t=>{e("left"===t?On:Mn,void 0)}))}}function childrenAsArray(e){return Array.isArray(e)?e:[e]}function filterChildElements(e,t){return childrenAsArray(e).filter((e=>a.isValidElement(e)&&e.type===t))}function DefaultAppearancePanel(){return e.jsxs("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:[e.jsx(VertexMaterialPanelSection,{}),e.jsx(VertexGhostingPanelSection,{}),e.jsx(VertexFeatureEdgesPanelSection,{}),e.jsx(VertexViewerBackgroundPanelSection,{}),e.jsx(VertexSelectionHighlightingPanelSection,{}),e.jsx(VertexCrossSectionAppearancePanelSection,{})]})}function DefaultSettingsPanel(){return e.jsx("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:e.jsx(VertexUnitsPanelSection,{})})}const VertexTransformClear=({onClear:t,onClearAll:s})=>{const i=useTransformActions(),l=useCacheableLoadable(gt),r=n.useRecoilValue(dt),c=useCacheableLoadable(Et(null!=r?r:"")),u=a.useMemo((()=>{var e;const t=null===(e=l.data)||void 0===e?void 0:e.some((e=>{var t;return null!=(null===(t=null==e?void 0:e.override)||void 0===t?void 0:t.transform)})),n=null!=c.data;return t||n}),[l,c]);return e.jsx("div",{className:"ml-auto",children:e.jsxs(ResetButton,{id:"transforms",tooltip:"Clear Transforms",children:[e.jsx("div",{className:"pt-1"}),e.jsx(o.VertexMenuItem,{"data-testid":"clear-selected-transforms",onClick:async()=>{await i.clearSelectedTransforms(),null==t||t()},disabled:!u,children:"Clear selected transforms"}),e.jsx(o.VertexMenuItem,{"data-testid":"clear-all-transforms",onClick:async()=>{await i.clearAllTransforms(),null==s||s()},children:"Clear all transforms"})]})})},VertexTransformNumericField=({bottomLabel:t,value:s,step:o,min:i,max:l,disabled:r,testId:c,onBlur:u,onInput:d,onChange:m})=>{const p=a.useRef(null),h=n.useRecoilValue(yt),[f,g]=a.useState(!0);a.useEffect((()=>{var e;const t=null!=p.current&&Number.isNaN(p.current.valueAsNumber),n=f||t;null!=p.current&&n?p.current.value=null!==(e=null==s?void 0:s.toFixed(Number(h)))&&void 0!==e?e:"":g(!0)}),[s]);const v=a.useCallback((e=>{g(!1),null==m||m(e)}),[g,m]),b=a.useCallback((e=>{g(!0),null==u||u(e),null!=p.current&&null!=s&&(p.current.value=s.toFixed(Number(h)))}),[u,s,g]);return e.jsxs("div",{children:[e.jsx("div",{className:"truncate rounded-md w-full",children:e.jsx("input",{ref:p,className:"w-full truncate border border-neutral-400 rounded-md px-2 py-1.5 hover:border-neutral-500 focus:border-neutral-500 focus:outline-none",type:"number",step:o,min:i,max:l,"data-testid":c,disabled:r,defaultValue:Number.isNaN(s)?"":null==s?void 0:s.toFixed(Number(h)),onBlur:b,onInput:d,onChange:v})}),null!=t&&e.jsx("div",{className:"flex justify-center items-center pointer-events-none text-neutral-500",children:e.jsx("span",{children:t})})]})},VertexTransformInputs=({onUpdateTransform:t})=>{const a=n.useRecoilValue(vt),s=n.useRecoilValue(ct),o=n.useRecoilValue(rt),i=s||o,l=n.useRecoilValue(dt),{transform:r,error:c,update:u}=useEditItemTransform(l),d=i?void 0:r,m=useDebouncedCallback((async e=>{await u(e),null==t||t(e)}),50);function updateTransform(e){return t=>{if(null!=d){const n=parseFloat(t.currentTarget.value);Number.isNaN(n)||null==m||m(Object.assign(Object.assign({},d),e(n,d)))}}}function updatePosition(e){return updateTransform(((t,n)=>({position:Object.assign(Object.assign({},n.position),e(t))})))}function updateRotation(e){return updateTransform(((t,n)=>({rotation:Object.assign(Object.assign({},n.rotation),e(t))})))}function updateScale(){return updateTransform((e=>e>0?{scale:e}:{}))}function updateToDefaultValueIfInvalid(e,t){return n=>{const a=parseFloat(n.currentTarget.value),s=undefined;(isNaN(a)||!!(null==t?void 0:t(a)))&&null!=d&&m(A.defaults(e,d))}}return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 text-[0.8125rem]",children:[e.jsx("span",{className:"flex w-full items-center mt-3 mb-1",children:"Position"}),e.jsxs("div",{className:"flex flex-wrap w-full gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"X"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"position-x",value:null!=d?d.position.x:void 0,bottomLabel:a,disabled:null==d,onChange:updatePosition((e=>({x:e}))),onBlur:updateToDefaultValueIfInvalid({position:{x:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Y"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"position-y",value:null==d?void 0:d.position.y,bottomLabel:a,disabled:null==d,onChange:updatePosition((e=>({y:e}))),onBlur:updateToDefaultValueIfInvalid({position:{y:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Z"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"position-z",value:null==d?void 0:d.position.z,bottomLabel:a,disabled:null==d,onChange:updatePosition((e=>({z:e}))),onBlur:updateToDefaultValueIfInvalid({position:{z:0}})})})]})]})]}),e.jsxs("div",{className:"mb-2 text-[0.8125rem]",children:[e.jsx("span",{className:"flex w-full items-center mt-3 mb-1",children:"Rotation"}),e.jsxs("div",{className:"flex flex-wrap w-full gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"X"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"rotation-x",value:null==d?void 0:d.rotation.x,bottomLabel:"deg",disabled:null==d,onChange:updateRotation((e=>({x:e}))),onBlur:updateToDefaultValueIfInvalid({rotation:{x:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Y"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"rotation-y",value:null==d?void 0:d.rotation.y,bottomLabel:"deg",disabled:null==d,onChange:updateRotation((e=>({y:e}))),onBlur:updateToDefaultValueIfInvalid({rotation:{y:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Z"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"rotation-z",value:null==d?void 0:d.rotation.z,bottomLabel:"deg",disabled:null==d,onChange:updateRotation((e=>({z:e}))),onBlur:updateToDefaultValueIfInvalid({rotation:{z:0}})})})]})]})]}),e.jsxs("div",{className:"mb-2 text-[0.8125rem]",children:[e.jsx("span",{className:"flex w-full items-center mt-3 mb-1",children:"Scale"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"scale",value:null==d?void 0:d.scale,step:.1,min:.1,disabled:null==d,onChange:updateScale(),onBlur:updateToDefaultValueIfInvalid({scale:1},(e=>e<=0))})}),i&&e.jsx("div",{className:"bg-orange-100 rounded px-3 py-2 mt-6 mb-2",children:"Input based part transformation is not yet supported for multiple parts."}),null!=c&&e.jsx("div",{className:"bg-red-100 rounded px-3 py-2 mt-6 mb-2",children:"There was a problem retrieving data. Try selecting a different part."})]})]})},VertexTransformManipulatorToggle=({onToggleTransformsManipulator:t})=>{const a=useTransformActions(),s=n.useRecoilValue(Vt),i=n.useSetRecoilState(Rt);return e.jsx(o.VertexToggle,{className:"flex items-center","data-testid":"transform-widget-toggle",variant:"switch",checked:s,onValueChanged:async()=>{s?(a.disableTransformWidget(),null==t||t(!1)):(i("world"),await a.enableTransformWidget(),null==t||t(!0))}})};function VertexTransformControls({onToggleTransformsManipulator:t,onUpdateTransform:n}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center py-3",children:[e.jsx(VertexTransformManipulatorToggle,{onToggleTransformsManipulator:t}),e.jsx("span",{className:"pl-4 text-[0.8125rem] text-neutral-700",children:"Enable manipulator"})]}),e.jsx(VertexTransformInputs,{onUpdateTransform:n})]})}function VertexTransformPanelSection({onClearTransforms:t,onClearAllTransforms:n,onToggleTransformsManipulator:a,onUpdateTransform:s}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Manual Part Transforms",e.jsx(VertexTransformClear,{onClear:t,onClearAll:n})]}),children:e.jsx(VertexTransformControls,{onToggleTransformsManipulator:a,onUpdateTransform:s})})}function DefaultTransformsPanel(){return e.jsx("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:e.jsx(VertexTransformPanelSection,{})})}const Ln="Appearance",Bn="Settings",_n="Transforms",ViewerRightPanelHeader=({additionalHeaderMap:t})=>{const a=undefined,s=getHeading(n.useRecoilValue(Mn),t);return e.jsx("div",{className:"flex flex-col w-full items-center z-overlay pointer-events-none md:pointer-events-auto py-3 px-4 border-b border-neutral-300",children:e.jsx("div",{className:"items-center w-full leading-6 text-md align-center font-medium text-neutral-800",children:s})})};function getHeading(e,t={}){switch(e){case"appearance":return Ln;case"settings":return Bn;case"transforms":return _n;default:const n=null!=e?t[e]:void 0;return null!=n?n:"None"}}function VertexViewerRightOpenedPanel({children:t}){const s=n.useRecoilValue(Mn),o=a.useMemo((()=>filterChildElements(t,CustomPanelContent)),[t]),i=a.useMemo((()=>o.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.props.panelName]:t.props.panelTitle})),{})),[o]),l=a.useMemo((()=>["appearance","settings","transforms",...o.map((e=>e.props.panelName))]),[o]);return e.jsx(e.Fragment,{children:null!=s&&l.includes(s)&&e.jsxs(VertexResizableContent,{displayShadow:!0,heading:e.jsx(ViewerRightPanelHeader,{additionalHeaderMap:i}),placement:"right",children:["appearance"===s&&e.jsx(DefaultAppearancePanel,{}),"transforms"===s&&e.jsx(DefaultTransformsPanel,{}),"settings"===s&&e.jsx(DefaultSettingsPanel,{}),t]})})}function CustomPanelContent({panelName:t,children:a}){const s=n.useRecoilValue(Mn);return e.jsx(e.Fragment,{children:s===t&&a})}function Sidebar({children:t}){return e.jsx("div",{className:"pointer-events-auto flex flex-col items-center w-full border-neutral-300 py-2",children:t})}function SidebarIcon({name:t,iconName:n,active:s,responsive:i,disabled:l,content:r,tooltipPlacement:c,children:u,onSelect:d,onDeselect:m}){return e.jsx("div",{className:Ce({"text-[var(--vertex-ui-blue-700)]":s===t&&!l,"text-neutral-700 hover:text-neutral-800":s!==t&&!l,"cursor-pointer hover:bg-neutral-200":!l,"text-neutral-400":l,"rounded-full md:p-3":i,"p-3":!i&&null==u,"px-3 py-1":null!=u}),"data-testid":`${t}-sidebar-panel`,onClick:()=>{l||(s===t?m():d())},children:e.jsxs(o.VertexTooltip,{placement:null!=c?c:void 0,content:a.isValidElement(r)?void 0:r,children:[e.jsx("div",{slot:"content",children:r}),e.jsx("div",{className:"flex flex-col",children:null!=u?u:e.jsx(o.VertexIcon,{name:n})})]})})}function VertexViewerRightSidebar({children:t}){const a=usePanelActions(),s=useTransformActions(),o=n.useRecoilValue(Mn);return e.jsx("div",{className:"flex flex-col flex-shrink-0 items-center relative border-neutral-300 border-l bg-white h-full top-0 min-w-12 w-12",children:e.jsxs(Sidebar,{children:[t,e.jsx(SidebarIcon,{name:"appearance",active:o,iconName:"adjustments",tooltipPlacement:"right",content:"Appearance",onSelect:()=>{a.openPrimary("appearance","right")},onDeselect:()=>a.closePrimary("right")}),e.jsx(SidebarIcon,{name:"transforms",active:o,iconName:"show-only-nearby",tooltipPlacement:"right",content:"Transforms",onSelect:async()=>{a.openPrimary("transforms","right"),await s.enableTransformWidget(void 0,!0)},onDeselect:()=>a.closePrimary("right")}),e.jsx(SidebarIcon,{name:"settings",active:o,iconName:"gear",tooltipPlacement:"right",content:"Settings",onSelect:()=>{a.openPrimary("settings","right")},onDeselect:()=>a.closePrimary("right")})]})})}function CustomPanelIcon(t){const a=usePanelActions(),s=n.useRecoilValue(Mn),{panelName:o,tooltipContent:i,iconName:l}=t,r=__rest(t,["panelName","tooltipContent","iconName"]);if(null==l&&null==r.children)throw new Error('CustomPanelIcon must contain either a Vertex "iconName" or custom "children"');return e.jsx(SidebarIcon,Object.assign({},r,{name:o,iconName:null!=l?l:"help",active:s,content:i,onSelect:()=>{a.openPrimary(t.panelName,"right")},onDeselect:()=>{a.closePrimary("right")}}))}VertexViewerRightOpenedPanel.CustomPanelContent=CustomPanelContent,VertexViewerRightSidebar.CustomPanelIcon=CustomPanelIcon;const VertexPopupButton=t=>{var{open:n,children:a}=t,s=__rest(t,["open","children"]);const i=a.find((e=>e.type===Anchor)),l=a.filter((e=>e.type!==Anchor));return null==i?e.jsx(e.Fragment,{}):e.jsxs(o.VertexPopover,Object.assign({className:"flex",placement:"top",backdrop:!1,open:asBooleanAttribute(n)},s,{children:[i,e.jsx("div",{className:Ce("flex mb-1.5",{hidden:!n}),"data-testid":"align-plane-popover-menu",children:l})]}))},Anchor=({tooltipContent:t,children:n})=>e.jsx("div",{slot:"anchor",children:e.jsx(o.VertexTooltip,{className:"cursor-pointer",content:t,children:n})});function VertexViewerCrossSectionAlignmentPopoverMenu(){const t=useCrossSectioningActions(),a=n.useRecoilValue(de),s=n.useRecoilValue(ne),getBaseIcon=()=>`align-to-${null==s?void 0:s.mode}`;return useStackKeyBinding({id:"CrossSectionAlignment",keyBind:"Escape",fn:t.cancelCurrentHit,addPredicate:()=>{var e;return null!==(e=null==s?void 0:s.hitPending)&&void 0!==e&&e},cancelPredicate:()=>!(null==s?void 0:s.hitPending)},[null==s?void 0:s.hitPending]),e.jsxs(VertexPopupButton,{"data-testid":"section-alignment-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(a),onDismissed:t.closeAlignmentTools,children:[e.jsx(VertexPopupButton.Anchor,{tooltipContent:"Section Alignment",children:e.jsx(o.VertexIconButton,{"data-testid":"section-alignment-icon-button",iconName:getBaseIcon(),iconColor:"secondary",onClick:a?t.closeAlignmentTools:t.openAlignmentTools,children:e.jsx(o.VertexIcon,{"data-testid":"section-alignment-icon-chevron",name:"chevron-up",size:"sm"})})}),e.jsxs(l.VertexViewerToolbarGroup,{direction:"vertical",className:"flex justify-evenly items-center py-1 my-1 ring-1 ring-neutral-200 rounded bg-neutral-100 opacity-95",children:[e.jsx(o.VertexIconButton,{iconColor:"secondary",onClick:()=>t.updateAlignment("global"),className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2","data-testid":"section-alignment-align-global",iconName:"align-to-global",variant:"plain",children:e.jsx("div",{className:"text-base ml-2",children:"Align to Global"})}),e.jsx(o.VertexIconButton,{iconColor:"secondary",onClick:()=>t.updateAlignment("surface"),className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2","data-testid":"section-alignment-align-surface",iconName:"align-to-surface",variant:"plain",children:e.jsx("div",{className:"text-base ml-2",children:"Align to Surface"})})]})]})}function VertexViewerCrossSectionAxisPopoverMenu(){const t=useCrossSectioningActions(),s=n.useRecoilValue(me),i=n.useRecoilValue(te),r=n.useRecoilValueLoadable(ie),c=a.useMemo((()=>{const e=i.length>0&&"hasValue"===r.state?axis(i[0],xAxis(r.contents),yAxis(r.contents),zAxis(r.contents)):"x";return null!=e?`axis-${e}`:"axis-x"}),[r.state,r.contents,i]);return e.jsxs(VertexPopupButton,{"data-testid":"align-plane-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(s),onDismissed:t.closeAxisTools,children:[e.jsx(VertexPopupButton.Anchor,{tooltipContent:"Align Plane",children:e.jsx(o.VertexIconButton,{onClick:s?t.closeAxisTools:t.openAxisTools,iconName:c,"data-testid":"align-plane-icon",iconColor:"secondary",children:e.jsx(o.VertexIcon,{"data-testid":"align-plane-icon-chevron",name:"chevron-up",size:"sm"})})}),e.jsxs(l.VertexViewerToolbarGroup,{direction:"vertical",className:"flex justify-evenly items-center py-1 my-1 ring-1 ring-neutral-200 rounded bg-neutral-100 opacity-95",children:[e.jsx(o.VertexIconButton,{"data-testid":"align-plane-x-axis-button",className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2",onClick:()=>t.updateAxis("x"),variant:"plain",iconColor:"secondary",iconName:"axis-x",children:e.jsx("div",{className:"text-base ml-2",children:"X-axis Plane"})}),e.jsx(o.VertexIconButton,{className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2",variant:"plain",iconColor:"secondary",iconName:"axis-y","data-testid":"align-plane-y-axis-button",onClick:()=>t.updateAxis("y"),children:e.jsx("div",{className:"text-base ml-2",children:"Y-axis Plane"})}),e.jsx(o.VertexIconButton,{"data-testid":"align-plane-z-axis-button",className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2",onClick:()=>t.updateAxis("z"),variant:"plain",iconColor:"secondary",iconName:"axis-z",children:e.jsx("div",{className:"text-base ml-2",children:"Z-axis Plane"})})]})]})}function VertexViewerCrossSectionOffsetStepper({offset:t,onOffsetChange:s}){const i=n.useRecoilValue(vt),l=n.useRecoilValue(yt),[r,c]=a.useState(convertTo(t,i));a.useEffect((()=>{c(convertTo(t,i))}),[i,t]);const u=createDistanceFormatter(i,parseInt(l,10)),handleIncrementalUpdate=e=>{const t=convertFrom(r+e,i);s(t)},handleSubmit=e=>{e.preventDefault(),s(convertFrom(r,i))},handleBlur=()=>{s(convertFrom(r,i))};return e.jsx(o.VertexTooltip,{content:"Plane Offset",children:e.jsx("form",{"data-testid":"cross-section-stepper-form",onSubmit:handleSubmit,children:e.jsxs(o.VertexTextfield,{"data-testid":"cross-section-stepper-input",className:"viewer-toolbar-input w-32 border-none ring-0 bg-white",type:"text",value:u(parseFloat(t.toFixed(3))),onInputInput:e=>{c(null!=e.detail.value?parseFloat(e.detail.value):t)},onBlur:handleBlur,children:[e.jsx("div",{"data-testid":"cross-section-stepper-decrement",className:"py-1 cursor-pointer",slot:"left",onClick:()=>handleIncrementalUpdate(-1),children:e.jsx(o.VertexIcon,{name:"chevron-left",size:"sm"})}),e.jsx("div",{"data-testid":"cross-section-stepper-increment",className:"py-1 cursor-pointer",slot:"right",onClick:()=>handleIncrementalUpdate(1),children:e.jsx(o.VertexIcon,{name:"chevron-right",size:"sm"})})]})})})}VertexPopupButton.Anchor=Anchor;const Dn=400;function VertexViewerCrossSectionPopupMenu(){const t=useCrossSectioningActions(),s=n.useRecoilValue(ue),i=n.useRecoilValueLoadable(re),r=n.useRecoilValueLoadable(ce),c=a.useRef(),u=a.useMemo((()=>"hasValue"===i.state?i.contents:Z),[i.state,i.contents]),d=a.useMemo((()=>"hasValue"===r.state?r.contents:0),[r.state,r.contents]),handleCrossSectionValueChange=e=>{clearTimeout(c.current),c.current=window.setTimeout((()=>{t.endInteraction()}),Dn),t.beginInteraction(),t.updatePlanes(e)};return e.jsxs(VertexPopupButton,{"data-testid":"cross-section-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(s),onDismissed:t.closeAdditionalTools,children:[e.jsx(VertexPopupButton.Anchor,{tooltipContent:"Section Tools",children:e.jsx("div",{className:"-ml-px py-1.5",children:e.jsx(o.VertexIcon,{"data-testid":"cross-section-popover-icon",name:"chevron-up",size:"sm",onClick:s?t.closeAdditionalTools:t.openAdditionalTools})})}),e.jsxs(l.VertexViewerToolbarGroup,{className:"relative bottom-3 flex justify-evenly items-center p-1 ring-1 ring-neutral-200 rounded bg-neutral-100 opacity-95",children:[e.jsx(VertexViewerCrossSectionAlignmentPopoverMenu,{}),e.jsx(o.VertexTooltip,{className:"w-auto",content:"Reverse",children:e.jsx(o.VertexIconButton,{iconName:"flip","data-testid":"viewer-toolbar-flip-button",onClick:t.flipPlanes,iconColor:"secondary"})}),e.jsx(o.VertexTooltip,{className:"w-auto",content:"Align View to Plane",children:e.jsx(o.VertexIconButton,{"data-testid":"viewer-toolbar-align-view-to-plane-button",iconName:"align-view-to-plane",onClick:t.alignViewToPlane,iconColor:"secondary"})}),e.jsx(VertexToolbarDivider,{}),e.jsx(VertexViewerCrossSectionAxisPopoverMenu,{}),e.jsx("div",{className:"w-52 mx-2",children:e.jsx(VertexSlider,{value:d,defaultValue:u.default,disabled:asBooleanAttribute("hasValue"!==i.state),min:u.min,max:u.max,step:.01,onChange:handleCrossSectionValueChange})}),e.jsx("div",{className:"px-4",children:e.jsx(VertexViewerCrossSectionOffsetStepper,{offset:"hasValue"===r.state?r.contents:0,onOffsetChange:handleCrossSectionValueChange})})]})]})}const VertexViewerCrossSectionButton=()=>{const t=useCrossSectioningActions(),a=n.useRecoilValue(J);return e.jsxs(e.Fragment,{children:[e.jsx(o.VertexTooltip,{content:a?"Hide Section":"Show Section",children:e.jsx(o.VertexIconButton,{"data-testid":"viewer-toolbar-cross-section-button",iconName:"cross-section",iconColor:a?"primary":"secondary",onClick:()=>a?t.disable():t.enable()})}),e.jsx(VertexViewerCrossSectionPopupMenu,{})]})},VertexFitAllButton=()=>{const t=n.useRecoilValue(M);return e.jsx(o.VertexTooltip,{content:"Fit All",children:e.jsx(o.VertexIconButton,{iconName:"fit-all",iconColor:"secondary","data-testid":"viewer-toolbar-fit-all-button",onClick:async()=>{const e=await(null==t?void 0:t.scene());await(null==e?void 0:e.camera().viewAll().render({animation:{milliseconds:500}}))}})})},VertexPanButton=()=>{const t=n.useRecoilValue(M),s=n.useRecoilValue(B),[i,l]=n.useRecoilState(D),[r,c]=n.useRecoilState(_);return a.useEffect((()=>{null!=t&&s&&c(t.getBaseInteractionHandler())}),[t,s,c]),e.jsx(o.VertexTooltip,{content:"Pan",children:e.jsx(o.VertexIconButton,{iconName:"pan",iconColor:"pan"===i?"primary":"secondary","data-testid":"viewer-toolbar-pan-button",onClick:async()=>{if(l("pan"),null!=r){const e=await r;null==e||e.setPrimaryInteractionType("pan")}}})})},VertexRotateButton=()=>{const t=n.useRecoilValue(M),s=n.useRecoilValue(B),[i,l]=n.useRecoilState(D),[r,c]=n.useRecoilState(_);return a.useEffect((()=>{null!=t&&s&&c(t.getBaseInteractionHandler())}),[t,s,c]),e.jsx(o.VertexTooltip,{content:"Rotate",children:e.jsx(o.VertexIconButton,{iconName:"rotate",iconColor:"rotate"===i?"primary":"secondary","data-testid":"viewer-toolbar-rotate-button",onClick:async()=>{if(l("rotate"),null!=r){const e=await r;null==e||e.setPrimaryInteractionType("rotate")}}})})},VertexZoomButton=()=>{const t=n.useRecoilValue(M),s=n.useRecoilValue(B),[i,l]=n.useRecoilState(D),[r,c]=n.useRecoilState(_);return a.useEffect((()=>{null!=t&&s&&c(t.getBaseInteractionHandler())}),[t,s,c]),e.jsx(o.VertexTooltip,{content:"Zoom",children:e.jsx(o.VertexIconButton,{iconName:"zoom",iconColor:"zoom"===i?"primary":"secondary","data-testid":"viewer-toolbar-zoom-button",onClick:async()=>{if(l("zoom"),null!=r){const e=await r;null==e||e.setPrimaryInteractionType("zoom")}}})})},DefaultToolbar=()=>e.jsx(l.VertexViewerToolbar,{placement:"bottom-center",children:e.jsxs(l.VertexViewerToolbarGroup,{className:"p-1 border border-neutral-200 rounded bg-neutral-100 opacity-95",children:[e.jsx(VertexRotateButton,{}),e.jsx(VertexPanButton,{}),e.jsx(VertexZoomButton,{}),e.jsx(VertexFitAllButton,{}),e.jsx(VertexToolbarDivider,{}),e.jsx(VertexBoxSelectionButton,{}),e.jsx(VertexToolbarDivider,{}),e.jsx(VertexViewerCrossSectionButton,{}),e.jsx(VertexToolbarDivider,{}),e.jsx(VertexPointToPointMeasurementTool,{}),e.jsx(VertexPreciseMeasurementTool,{})]})}),VertexToolbar=({children:t})=>{const n=null!=t&&!1!==t;return e.jsx(l.VertexViewerToolbar,{placement:"bottom-center",children:n?e.jsx(l.VertexViewerToolbarGroup,{className:"p-1 border border-neutral-200 rounded bg-neutral-100 opacity-95",children:t}):e.jsx(DefaultToolbar,{})})};function VertexTransformWidget({transformWidgetElement:t,supportUndo:s,onPositionChange:o,onRotationChange:i}){const r=useTransformActions(),c=n.useRecoilValue(At),u=n.useRecoilValue(Vt),d=n.useRecoilValue(Ct),m=n.useRecoilValue(kt),p=n.useRecoilValueLoadable(Tt),h=n.useRecoilValue(vt),f=n.useRecoilValue(yt),g=a.useMemo((()=>"hasValue"===p.state?p.contents:m),[p,m]),v=a.useMemo((()=>{const e=undefined;return u&&(null!=g||c)}),[u,g,c]);return e.jsx(e.Fragment,{children:v&&e.jsx(l.VertexViewerTransformWidget,{id:"transform-widget","data-testid":"viewer-transform-widget",ref:t,position:d,rotation:null!=d?g:void 0,decimalPlaces:parseInt(f,10),distanceUnit:toUnitType(h),EXPERIMENTAL_undoKeybindings:null==s||s,onInteractionStarted:()=>{r.disableSelectionSync(),r.setIsInteractivelyTransforming(!0)},onInteractionEnded:()=>{r.invalidateTransforms(),r.setIsInteractivelyTransforming(!1)},onPositionChanged:async e=>{await r.setTransformWidgetPosition(e.detail),null==o||o(e.detail)},onRotationChanged:e=>{r.setTransformWidgetOrientation(e.detail),null==i||i(e.detail)}})})}const VertexViewerSceneReset=({onReset:t})=>{const n=useCrossSectioningActions(),a=useSelectionActions(),s=useTransformActions(),i=useViewerSceneActions(),handleReset=async()=>{await n.disable(),await a.resetSelectionState(),s.clearTransformWidgetPosition(),await s.invalidateTransforms(),null==t||t(),await i.reset()};return e.jsx(o.VertexTooltip,{content:"Reset View",children:e.jsx(o.VertexIconButton,{iconName:"reset",className:"flex bg-white opacity-70 hover:opacity-100 text-neutral-900 hover:text-neutral-700 hover:bg-neutral-200 rounded p-1 cursor-pointer","data-testid":"viewer-reset-tool-button",onClick:handleReset,variant:"plain"})})};function useViewerFrameActions(){const e=useTransformActions();return{frameDrawn:useActionCallback((({set:t,snapshot:n})=>async a=>{const s=await n.getPromise(pt);t(U,a.detail.scene),t(pt,a.detail.scene.sceneViewSummary.selectedVisibleSummary),t(mt,s);const o=undefined;await n.getPromise(Vt)&&await e.syncToSelection()}))}}const VertexBoxSelectionTool=()=>{const{element:t,callback:a}=useCallbackRef(),s=useBoxSelectionActions(),o=useTransformActions(),i=n.useRecoilValue(Le);return u.useEffect((()=>{const e=whenComponentReady(t,(()=>{var e;return[null===(e=null==t?void 0:t.model)||void 0===e?void 0:e.onDragComplete((()=>{"clearAndSelect"===i&&(o.clearTransformWidgetOrientation(),o.clearTransformWidgetPosition(),o.enableSelectionSync())}))]}));return()=>{null==e||e.then((e=>{null==e||e.forEach((e=>null==e?void 0:e.dispose()))}))}}),[t,i]),useApplyKeyBinding({keyBind:"Shift",fn:u.useCallback((()=>s.setOperationType("select")),[]),off:u.useCallback((()=>s.setOperationType("clearAndSelect")),[])}),e.jsx(l.VertexViewerBoxQueryTool,{ref:a,"data-testid":"viewer-box-query-tool",operationType:i})};function VertexViewerCameraTypeMenu({open:t,onOpen:a,onDismiss:s,onCameraTypeChange:i}){const l=useViewerCameraActions(),r=n.useRecoilValue(K);return e.jsxs(o.VertexMenu,{"data-testid":"camera-types-popover",className:"flex",placement:"bottom-end",open:asBooleanAttribute(t),onMenuClosed:s,children:[e.jsx("div",{slot:"anchor",children:e.jsx("div",{className:Ce("flex bg-white hover:opacity-100 hover:text-neutral-700 hover:bg-neutral-200 rounded",{"opacity-70 text-neutral-900":!t,"opacity-100 text-neutral-700 bg-neutral-200":t}),children:e.jsx(o.VertexTooltip,{content:"Change View",children:e.jsx(o.VertexIconButton,{"data-testid":"set-camera-mode-option",className:"p-1 cursor-pointer",variant:"plain",onClick:a,iconName:"orthographic"===r?"cube-orthographic":"cube-perspective",children:e.jsx(o.VertexIcon,{"data-testid":"change-camera-type-icon-button",name:"chevron-down",size:"sm"})})})})}),e.jsxs("div",{className:"w-36",children:[e.jsx("div",{className:"pt-1"}),e.jsxs(o.VertexMenuItem,{"data-testid":"set-perspective-view",onClick:()=>{l.updateCameraType("perspective"),null==i||i("perspective")},children:[e.jsx(o.VertexIcon,{slot:"icon","data-testid":"set-perspective-view-icon",name:"cube-perspective",size:"sm",className:Ce({"text-[var(--vertex-ui-blue-700)]":"perspective"===r})}),e.jsx("div",{className:Ce("ml-2 items-center",{"text-[var(--vertex-ui-blue-700)]":"perspective"===r}),children:"Perspective"})]}),e.jsxs(o.VertexMenuItem,{"data-testid":"set-orthographic-view",onClick:()=>{l.updateCameraType("orthographic"),null==i||i("orthographic")},children:[e.jsx(o.VertexIcon,{slot:"icon","data-testid":"set-orthographic-view-icon",name:"cube-orthographic",size:"sm",className:Ce({"text-[var(--vertex-ui-blue-700)]":"orthographic"===r})}),e.jsx("div",{className:Ce("ml-2 items-center",{"text-[var(--vertex-ui-blue-700)]":"orthographic"===r}),children:"Orthographic"})]})]})]})}const VertexViewerViewCube=t=>{var{placement:n,children:s}=t,o=__rest(t,["placement","children"]);const i=Array.isArray(s)?s:[s],r=i.filter((e=>!a.isValidElement(e)||e.type!==l.VertexViewerViewCube)).filter((e=>null!=e&&!1!==e)),c=i.find((e=>a.isValidElement(e)&&e.type===l.VertexViewerViewCube)),[u,d]=a.useState(!1);return e.jsxs(l.VertexViewerToolbar,{direction:"vertical","data-testid":"view-cube-toolbar",placement:null!=n?n:"top-right",children:[null!=c?c:e.jsx(l.VertexViewerViewCube,Object.assign({className:"m-7"},o)),0===r.length?e.jsxs("div",{className:"flex items-center justify-center mt-3 gap-1",children:[e.jsx(VertexViewerSceneReset,{}),e.jsx(VertexViewerCameraTypeMenu,{open:u,onDismiss:()=>d(!1),onOpen:()=>d(!0)})]}):e.jsx("div",{className:"mt-3",children:r})]})},VertexViewer=t=>{var{id:s,className:o,disableSelection:i,onTap:r,onLongpress:c,onFrameDrawn:u,onSceneReady:d,viewerRefCallback:m,children:p}=t,h=__rest(t,["id","className","disableSelection","onTap","onLongpress","onFrameDrawn","onSceneReady","viewerRefCallback","children"]);const f=n.useRecoilValue(hn),g=useRecoilRef({state:M}),v=useViewerCameraActions(),b=useHitActions(),S=useSelectionActions(),w=useViewerFrameActions(),[V,C]=n.useRecoilState(B),j=n.useRecoilValue(K),T=n.useRecoilValue(ne),k=n.useRecoilValue(Me),A=n.useSetRecoilState(F),[P,E]=n.useRecoilState(L);a.useEffect((()=>{null!=s&&E(s)}),[s]);const I=n.useRecoilValue(dn),R=a.useMemo((()=>({opacity:I/100})),[I]),N=n.useRecoilValue(ke),O=n.useRecoilValue(Ae),_=a.useMemo((()=>({color:N,width:O})),[N,O]),D=n.useRecoilValue(Jt),H=n.useRecoilValue(nn),U=n.useRecoilValue(an),W=n.useRecoilValue(sn),G=a.useMemo((()=>({color:H,opacity:U/100,lineWidth:W})),[H,U,W]),$=n.useRecoilValue(Fe),q=null!=p&&!1!==p;return useKeyBindings(),useDefaultKeybindings(),e.jsxs(l.VertexViewer,Object.assign({id:P,"data-testid":"vertex-viewer",ref:null!=m?m:g,className:Ce("flex w-full h-full",o,{"cursor-crosshair":T.hitPending}),style:{"--viewer-background":D},config:f,cameraType:V?j:void 0,onCameraTypeChanged:e=>{V&&v.updateCameraType(e.detail)},phantom:R,featureLines:_,selectionHighlighting:G,featureMaps:$?"final":void 0,onTap:e=>{const t=[...i?[]:[S.selectCurrentHit]];b.tap(e,...t),null==r||r(e)},onLongpress:e=>{b.longPress(e),null==c||c(e)},onFrameDrawn:e=>{w.frameDrawn(e),null==u||u(e)},onSceneReady:async e=>{var t;if(!V){C(!0);const n=await(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.scene());A(null==n?void 0:n.sceneViewId)}null==d||d(e)}},h,{children:[k&&e.jsx(VertexBoxSelectionTool,{}),q?p:e.jsxs(e.Fragment,{children:[e.jsx(VertexViewerViewCube,{}),e.jsx(VertexToolbar,{}),e.jsx(VertexViewerContextMenu,{})]})]}))};function toSdkConfig(e){return isOnlyNetworkConfig(e)?{network:e}:e}function isOnlyNetworkConfig(e){const t=undefined;return null!=e.renderingHost}const VertexViewerToolkitEventListener=({onHitStateChange:t,onSelectionStateChange:s})=>{const o=n.useRecoilValue(_t),i=n.useRecoilValue(zt);return a.useEffect((()=>{null==t||t(o)}),[o,t]),a.useEffect((()=>{null==s||s(i)}),[i,s]),e.jsx(e.Fragment,{})},VertexViewerToolkitRoot=t=>{var{override:s,autoDefineCustomElements:o,children:i,config:l}=t,u=__rest(t,["override","autoDefineCustomElements","children","config"]);return a.useEffect((()=>{(null==o||o)&&(c.defineCustomElements(),r.defineCustomElements())}),[o]),e.jsx(n.RecoilRoot,{override:s,children:e.jsxs(e.Fragment,{children:[e.jsx(VertexViewerToolkitEventListener,Object.assign({},u)),e.jsx(VertexViewerToolkitRootConfig,{config:l,children:i})]})})},VertexViewerToolkitRootConfig=({config:t,children:s})=>{const o=n.useSetRecoilState(hn);return a.useEffect((()=>{const e=null!=t?toSdkConfig(t):void 0;o(e)}),[t,o]),e.jsx(e.Fragment,{children:s})};var zn=Object.freeze({__proto__:null,get AssemblyFontFace(){return Nn}});exports.CrossSection=Se,exports.Hits=Dt,exports.SceneTree=zn,exports.Selection=Ft,exports.VertexApplicationMessages=VertexApplicationMessages,exports.VertexBoxSelectionButton=VertexBoxSelectionButton,exports.VertexContextMenu=VertexContextMenu,exports.VertexCrossSectionAppearanceColorPicker=VertexCrossSectionAppearanceColorPicker,exports.VertexCrossSectionAppearanceControls=VertexCrossSectionAppearanceControls,exports.VertexCrossSectionAppearanceLineThicknessSlider=VertexCrossSectionAppearanceLineThicknessSlider,exports.VertexCrossSectionAppearancePanelSection=VertexCrossSectionAppearancePanelSection,exports.VertexCrossSectionAppearanceReset=VertexCrossSectionAppearanceReset,exports.VertexDecimalPlaceSelector=VertexDecimalPlaceSelector,exports.VertexFeatureEdgesColorPicker=VertexFeatureEdgesColorPicker,exports.VertexFeatureEdgesControls=VertexFeatureEdgesControls,exports.VertexFeatureEdgesPanelSection=VertexFeatureEdgesPanelSection,exports.VertexFeatureEdgesReset=VertexFeatureEdgesReset,exports.VertexFeatureEdgesThicknessSlider=VertexFeatureEdgesThicknessSlider,exports.VertexFitAllButton=VertexFitAllButton,exports.VertexFitSelectedMenuItem=VertexFitSelectedMenuItem,exports.VertexFlyToMenuItem=VertexFlyToMenuItem,exports.VertexGhostingControls=VertexGhostingControls,exports.VertexGhostingPanelSection=VertexGhostingPanelSection,exports.VertexHideAllMenuItem=VertexHideAllMenuItem,exports.VertexHidePartMenuItem=VertexHidePartMenuItem,exports.VertexHideSelectedMenuItem=VertexHideSelectedMenuItem,exports.VertexLengthUnitSelector=VertexLengthUnitSelector,exports.VertexMaterialControls=VertexMaterialControls,exports.VertexMaterialPanelSection=VertexMaterialPanelSection,exports.VertexMeasurementContextMenu=VertexMeasurementContextMenu,exports.VertexMeasurementDetails=VertexMeasurementDetails,exports.VertexPanButton=VertexPanButton,exports.VertexPointToPointMeasurement=VertexPointToPointMeasurement,exports.VertexPointToPointMeasurementTool=VertexPointToPointMeasurementTool,exports.VertexPreciseMeasurement=VertexPreciseMeasurement,exports.VertexPreciseMeasurementTool=VertexPreciseMeasurementTool,exports.VertexResizableContent=VertexResizableContent,exports.VertexRotateButton=VertexRotateButton,exports.VertexSceneItemGhostingClear=VertexSceneItemGhostingClear,exports.VertexSceneItemGhostingOpacitySlider=VertexSceneItemGhostingOpacitySlider,exports.VertexSceneItemGhostingToggle=VertexSceneItemGhostingToggle,exports.VertexSceneItemMaterialClear=VertexSceneItemMaterialClear,exports.VertexSceneItemMaterialColorPicker=VertexSceneItemMaterialColorPicker,exports.VertexSceneItemMaterialOpacitySlider=VertexSceneItemMaterialOpacitySlider,exports.VertexSceneTree=VertexSceneTree,exports.VertexSceneTreeColumnPopover=VertexSceneTreeColumnPopover,exports.VertexSceneTreeContextMenu=VertexSceneTreeContextMenu,exports.VertexSceneTreeHeader=VertexSceneTreeHeader,exports.VertexSceneTreeSearchBar=VertexSceneTreeSearchBar,exports.VertexSceneTreeSearchInformationForToolbar=VertexSceneTreeSearchInformationForToolbar,exports.VertexSceneTreeSearchOptionsPopover=VertexSceneTreeSearchOptionsPopover,exports.VertexSceneTreeTableLayout=VertexSceneTreeTableLayout,exports.VertexSelectionHighlightingColorPicker=VertexSelectionHighlightingColorPicker,exports.VertexSelectionHighlightingControls=VertexSelectionHighlightingControls,exports.VertexSelectionHighlightingLineThicknessSlider=VertexSelectionHighlightingLineThicknessSlider,exports.VertexSelectionHighlightingOpacitySlider=VertexSelectionHighlightingOpacitySlider,exports.VertexSelectionHighlightingPanelSection=VertexSelectionHighlightingPanelSection,exports.VertexSelectionHighlightingReset=VertexSelectionHighlightingReset,exports.VertexShowAllMenuItem=VertexShowAllMenuItem,exports.VertexShowOnlyMenuItem=VertexShowOnlyMenuItem,exports.VertexShowOnlySelectedMenuItem=VertexShowOnlySelectedMenuItem,exports.VertexToolbar=VertexToolbar,exports.VertexToolbarDivider=VertexToolbarDivider,exports.VertexTransformClear=VertexTransformClear,exports.VertexTransformControls=VertexTransformControls,exports.VertexTransformInputs=VertexTransformInputs,exports.VertexTransformManipulatorToggle=VertexTransformManipulatorToggle,exports.VertexTransformPanelSection=VertexTransformPanelSection,exports.VertexTransformWidget=VertexTransformWidget,exports.VertexUnitsControls=VertexUnitsControls,exports.VertexUnitsPanelSection=VertexUnitsPanelSection,exports.VertexViewer=VertexViewer,exports.VertexViewerBackgroundColorPicker=VertexViewerBackgroundColorPicker,exports.VertexViewerBackgroundControls=VertexViewerBackgroundControls,exports.VertexViewerBackgroundPanelSection=VertexViewerBackgroundPanelSection,exports.VertexViewerBackgroundReset=VertexViewerBackgroundReset,exports.VertexViewerContextMenu=VertexViewerContextMenu,exports.VertexViewerCrossSectionButton=VertexViewerCrossSectionButton,exports.VertexViewerRightOpenedPanel=VertexViewerRightOpenedPanel,exports.VertexViewerRightSidebar=VertexViewerRightSidebar,exports.VertexViewerSceneReset=VertexViewerSceneReset,exports.VertexViewerToolkitRoot=VertexViewerToolkitRoot,exports.VertexViewerViewCube=VertexViewerViewCube,exports.VertexZoomButton=VertexZoomButton;
|
|
19
19
|
//# sourceMappingURL=bundle.cjs.js.map
|