@objectstack/console 9.3.0 → 9.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/AdapterProvider-BNNEwHx0.js +1 -0
- package/dist/assets/{AiPendingActionsPage-Y9r83gqj.js → AiPendingActionsPage-DOSHy962.js} +1 -1
- package/dist/assets/ApiConsolePage-CruwU0Up.js +1 -0
- package/dist/assets/{AppManagementPage-0JEALVYK.js → AppManagementPage-BohnYqad.js} +1 -1
- package/dist/assets/ApprovalsInboxPage-BGmv2uNL.js +1 -0
- package/dist/assets/{AuditLogPage-CXhNSVOU.js → AuditLogPage-KrpMMNiw.js} +1 -1
- package/dist/assets/{ComponentNavView-BI4O_zkC.js → ComponentNavView-JMyYlvFq.js} +1 -1
- package/dist/assets/ConsoleFloatingChatbot-C7wdj16w.js +1 -0
- package/dist/assets/DashboardView-DUqOAEyx.js +1 -0
- package/dist/assets/DashboardWidgetInspector-Dhe9hv9A.js +1 -0
- package/dist/assets/{DeveloperHubPage-D-UigRUA.js → DeveloperHubPage-D4ErhCeD.js} +1 -1
- package/dist/assets/ExpressionProvider-Cj6XEnZF.js +1 -0
- package/dist/assets/FlowRunsPage-CJsr4xgF.js +1 -0
- package/dist/assets/{IntegrationsPage-DsWyxKR6.js → IntegrationsPage-zbcGFqxM.js} +2 -2
- package/dist/assets/InterfaceListPage-BJRTel_h.js +1 -0
- package/dist/assets/ManagedByBadge-DOMbPlbf.js +1 -0
- package/dist/assets/MarketplaceInstalledPage-CSgqJuot.js +1 -0
- package/dist/assets/MarketplacePackagePage-0TU_eJIx.js +4 -0
- package/dist/assets/MarketplacePage-YO75QMEO.js +1 -0
- package/dist/assets/MetadataInspector-CamKLf7x.js +1 -0
- package/dist/assets/MetadataProvider-Bxendsnd.js +1 -0
- package/dist/assets/PageView-z1PfFaQS.js +1 -0
- package/dist/assets/ProfilePage-5QuBSV4z.js +1 -0
- package/dist/assets/PublicFormsPage-CMTz6MfD.js +1 -0
- package/dist/assets/{RecentItemsProvider-DiJIrHwK.js → RecentItemsProvider-gLV-GFpQ.js} +1 -1
- package/dist/assets/RecordDetailView-DOcGflPY.js +1 -0
- package/dist/assets/RecordFormPage-C1M3jdnG.js +1 -0
- package/dist/assets/ReportDefaultInspector-DDBJTAYx.js +1 -0
- package/dist/assets/ReportView-CItKDFSn.js +2 -0
- package/dist/assets/RuntimeDraftBar-QF3pF8K2.js +1 -0
- package/dist/assets/SearchResultsPage-Mdphx8Ca.js +1 -0
- package/dist/assets/{SettingsHub-B4oSx4ed.js → SettingsHub-CtfOIqOJ.js} +1 -1
- package/dist/assets/SettingsView-One2JiPG.js +1 -0
- package/dist/assets/{SystemHubPage-Di6eqozE.js → SystemHubPage-Dzi5_s3T.js} +1 -1
- package/dist/assets/appRoute-D5vwtoc_.js +1 -0
- package/dist/assets/data-adapter-Dl2IvbPC.js +1 -0
- package/dist/assets/{framework-crD8qZlm.js → framework-D7UWfRl4.js} +10 -10
- package/dist/assets/{highlighted-body-OFNGDK62-B3OlR_Nx.js → highlighted-body-OFNGDK62-Dgcl8-h_.js} +1 -1
- package/dist/assets/index-BjfDho4T.js +4 -0
- package/dist/assets/index-CJFqfWpW.css +2 -0
- package/dist/assets/infrastructure-ckitl7Ev.js +3 -0
- package/dist/assets/marketplaceApi-Do90JxGv.js +1 -0
- package/dist/assets/mergeServerFields-Co1NIO7_.js +7 -0
- package/dist/assets/mermaid-GHXKKRXX-BY4z2Mh6.js +1 -0
- package/dist/assets/metadata-admin-B-99o4dC.js +19 -0
- package/dist/assets/plugin-calendar-DSvXqOQV.js +1 -0
- package/dist/assets/plugin-charts-EoSn84Ag.js +7 -0
- package/dist/assets/plugin-chatbot-D6s22V14.js +120 -0
- package/dist/assets/plugin-dashboard-PEMuLOVn.js +5 -0
- package/dist/assets/plugin-form-MXrWd_1Z.js +1 -0
- package/dist/assets/plugin-gantt-CB1bbY8J.js +23 -0
- package/dist/assets/plugin-grid-D9HjQh3d.js +6 -0
- package/dist/assets/plugin-kanban-BxxI6fit.js +1 -0
- package/dist/assets/{plugin-map-C8Jxhxs1.js → plugin-map-B-TiJAz8.js} +1 -1
- package/dist/assets/plugin-markdown-BUIHw2kZ.js +113 -0
- package/dist/assets/plugin-report-jQPIUbaf.js +59 -0
- package/dist/assets/plugin-timeline-BNRp2sKQ.js +1 -0
- package/dist/assets/plugin-view-BeiRMGis.js +1 -0
- package/dist/assets/plugins-views-D0zS0yz2.js +4 -0
- package/dist/assets/resolveActionParams-eRBdMG9b.js +9 -0
- package/dist/assets/skeletons-DNzeXHI1.js +1 -0
- package/dist/assets/{src-Tw2eleSi.js → src-LBsSMdO2.js} +1 -1
- package/dist/assets/{types-BkFEpiv3.js → types-D2P-aXxM.js} +1 -1
- package/dist/assets/ui-components-Clv7N77v.js +42 -0
- package/dist/assets/{ui-layout-KICrO2Oe.js → ui-layout-DYMEUX5t.js} +1 -1
- package/dist/assets/useActionModal-VGsmP3uO.js +1 -0
- package/dist/assets/usePackageL10n-shLsxEAx.js +1 -0
- package/dist/assets/utils-bipVuqQL.js +1 -0
- package/dist/assets/vendor-markdown-BXE1apAC.js +46 -0
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/dist/assets/ApiConsolePage-Dwbms0Zh.js +0 -1
- package/dist/assets/ApprovalsInboxPage-B-drSsxQ.js +0 -1
- package/dist/assets/ConsoleFloatingChatbot-CiODZIcp.js +0 -1
- package/dist/assets/FlowRunsPage-_UeeNdBc.js +0 -1
- package/dist/assets/ProfilePage-T27zVrMO.js +0 -1
- package/dist/assets/PublicFormsPage-Pd453sW6.js +0 -1
- package/dist/assets/SettingsView-CkQEI5DW.js +0 -1
- package/dist/assets/assistantBus-B-xBT6j1.js +0 -1
- package/dist/assets/data-adapter-3AJO7A2o.js +0 -1
- package/dist/assets/index-Cf7NsvAk.css +0 -2
- package/dist/assets/index-CiI7zDDo.js +0 -32
- package/dist/assets/infrastructure-CxityHZF.js +0 -3
- package/dist/assets/mergeServerFields-DUkbynPg.js +0 -7
- package/dist/assets/mermaid-GHXKKRXX-CBocchJ2.js +0 -1
- package/dist/assets/plugin-calendar-ed7RoEFF.js +0 -1
- package/dist/assets/plugin-charts-QabQJ_NJ.js +0 -7
- package/dist/assets/plugin-chatbot-Cy3tiXkg.js +0 -120
- package/dist/assets/plugin-dashboard-PA0xf59v.js +0 -5
- package/dist/assets/plugin-form-BABEMaum.js +0 -1
- package/dist/assets/plugin-gantt-BNjfLkTR.js +0 -1
- package/dist/assets/plugin-grid-BxyuFeJP.js +0 -6
- package/dist/assets/plugin-kanban-D4yCkUn_.js +0 -1
- package/dist/assets/plugin-markdown-CR5TpghH.js +0 -7
- package/dist/assets/plugin-report-rz8HUIsi.js +0 -59
- package/dist/assets/plugin-timeline-DQHQwtdw.js +0 -1
- package/dist/assets/plugin-view-BykLknWa.js +0 -1
- package/dist/assets/plugins-views-CBO5qxO-.js +0 -4
- package/dist/assets/ui-components-BrY5joKQ.js +0 -42
- package/dist/assets/vendor-markdown-C9mPywRm.js +0 -38
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,g as r,m as i,t as a}from"./vendor-react-DR370ovB.js";import{F as o,G as s,lt as c,mt as l,ut as u}from"./framework-crD8qZlm.js";import{A as d,N as f,P as p,k as m}from"./vendor-objectstack-RB3xvhcR.js";import{P as h,jt as g,rc as _}from"./ui-components-BrY5joKQ.js";var v=e(n(),1),y=v.createContext(null);function b(e,t){let n=Array.isArray(e)?e[0]:e?e.x:0,r=Array.isArray(e)?e[1]:e?e.y:0,i=Array.isArray(t)?t[0]:t?t.x:0,a=Array.isArray(t)?t[1]:t?t.y:0;return n===i&&r===a}function x(e,t){if(e===t)return!0;if(!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!x(e[n],t[n]))return!1;return!0}else if(Array.isArray(t))return!1;if(typeof e==`object`&&typeof t==`object`){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!t.hasOwnProperty(r)||!x(e[r],t[r]))return!1;return!0}return!1}function S(e){return{longitude:e.center.lng,latitude:e.center.lat,zoom:e.zoom,pitch:e.pitch,bearing:e.bearing,padding:e.padding}}function C(e,t){let n=t.viewState||t,r={};if(`longitude`in n&&`latitude`in n&&(n.longitude!==e.center.lng||n.latitude!==e.center.lat)){let t=e.center.constructor;r.center=new t(n.longitude,n.latitude)}return`zoom`in n&&n.zoom!==e.zoom&&(r.zoom=n.zoom),`bearing`in n&&n.bearing!==e.bearing&&(r.bearing=n.bearing),`pitch`in n&&n.pitch!==e.pitch&&(r.pitch=n.pitch),n.padding&&e.padding&&!x(n.padding,e.padding)&&(r.padding=n.padding),r}var w=[`type`,`source`,`source-layer`,`minzoom`,`maxzoom`,`filter`,`layout`];function T(e){if(!e)return null;if(typeof e==`string`||(`toJS`in e&&(e=e.toJS()),!e.layers))return e;let t={};for(let n of e.layers)t[n.id]=n;let n=e.layers.map(e=>{let n=null;`interactive`in e&&(n=Object.assign({},e),delete n.interactive);let r=t[e.ref];if(r){n||=Object.assign({},e),delete n.ref;for(let e of w)e in r&&(n[e]=r[e])}return n||e});return{...e,layers:n}}var E={version:8,sources:{},layers:[]},D={minZoom:0,maxZoom:22,minPitch:0,maxPitch:85,maxBounds:[-180,-85.051129,180,85.051129],projection:`mercator`,renderWorldCopies:!0},O={mousedown:`onMouseDown`,mouseup:`onMouseUp`,mouseover:`onMouseOver`,mousemove:`onMouseMove`,click:`onClick`,dblclick:`onDblClick`,mouseenter:`onMouseEnter`,mouseleave:`onMouseLeave`,mouseout:`onMouseOut`,contextmenu:`onContextMenu`,touchstart:`onTouchStart`,touchend:`onTouchEnd`,touchmove:`onTouchMove`,touchcancel:`onTouchCancel`},k={movestart:`onMoveStart`,move:`onMove`,moveend:`onMoveEnd`,dragstart:`onDragStart`,drag:`onDrag`,dragend:`onDragEnd`,zoomstart:`onZoomStart`,zoom:`onZoom`,zoomend:`onZoomEnd`,rotatestart:`onRotateStart`,rotate:`onRotate`,rotateend:`onRotateEnd`,pitchstart:`onPitchStart`,pitch:`onPitch`,pitchend:`onPitchEnd`},A={wheel:`onWheel`,boxzoomstart:`onBoxZoomStart`,boxzoomend:`onBoxZoomEnd`,boxzoomcancel:`onBoxZoomCancel`,resize:`onResize`,load:`onLoad`,render:`onRender`,idle:`onIdle`,remove:`onRemove`,data:`onData`,styledata:`onStyleData`,sourcedata:`onSourceData`,error:`onError`},j=[`minZoom`,`maxZoom`,`minPitch`,`maxPitch`,`maxBounds`,`projection`,`renderWorldCopies`],M=[`scrollZoom`,`boxZoom`,`dragRotate`,`dragPan`,`keyboard`,`doubleClickZoom`,`touchZoomRotate`,`touchPitch`],N=class e{constructor(e,t,n){this._map=null,this._internalUpdate=!1,this._hoveredFeatures=null,this._propsedCameraUpdate=null,this._styleComponents={},this._onEvent=e=>{let t=this.props[A[e.type]];t?t(e):e.type===`error`&&console.error(e.error)},this._onCameraEvent=e=>{if(this._internalUpdate)return;e.viewState=this._propsedCameraUpdate||S(this._map.transform);let t=this.props[k[e.type]];t&&t(e)},this._onCameraUpdate=e=>this._internalUpdate?e:(this._propsedCameraUpdate=S(e),C(e,this.props)),this._onPointerEvent=e=>{(e.type===`mousemove`||e.type===`mouseout`)&&this._updateHover(e);let t=this.props[O[e.type]];t&&(this.props.interactiveLayerIds&&e.type!==`mouseover`&&e.type!==`mouseout`&&(e.features=this._hoveredFeatures||this._queryRenderedFeatures(e.point)),t(e),delete e.features)},this._MapClass=e,this.props=t,this._initialize(n)}get map(){return this._map}setProps(e){let t=this.props;this.props=e;let n=this._updateSettings(e,t),r=this._updateSize(e),i=this._updateViewState(e);this._updateStyle(e,t),this._updateStyleComponents(e),this._updateHandlers(e,t),(n||r||i&&!this._map.isMoving())&&this.redraw()}static reuse(t,n){let r=e.savedMaps.pop();if(!r)return null;let i=r.map,a=i.getContainer();for(n.className=a.className;a.childNodes.length>0;)n.appendChild(a.childNodes[0]);i._container=n;let o=i._resizeObserver;o&&(o.disconnect(),o.observe(n)),r.setProps({...t,styleDiffing:!1}),i.resize();let{initialViewState:s}=t;return s&&(s.bounds?i.fitBounds(s.bounds,{...s.fitBoundsOptions,duration:0}):r._updateViewState(s)),i.isStyleLoaded()?i.fire(`load`):i.once(`style.load`,()=>i.fire(`load`)),i._update(),r}_initialize(e){let{props:t}=this,{mapStyle:n=E}=t,r={...t,...t.initialViewState,container:e,style:T(n)},i=r.initialViewState||r.viewState||r;if(Object.assign(r,{center:[i.longitude||0,i.latitude||0],zoom:i.zoom||0,pitch:i.pitch||0,bearing:i.bearing||0}),t.gl){let e=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=()=>(HTMLCanvasElement.prototype.getContext=e,t.gl)}let a=new this._MapClass(r);i.padding&&a.setPadding(i.padding),t.cursor&&(a.getCanvas().style.cursor=t.cursor),a.transformCameraUpdate=this._onCameraUpdate,a.on(`style.load`,()=>{this._styleComponents={light:a.getLight(),sky:a.getSky(),projection:a.getProjection?.(),terrain:a.getTerrain()},this._updateStyleComponents(this.props)}),a.on(`sourcedata`,()=>{this._updateStyleComponents(this.props)});for(let e in O)a.on(e,this._onPointerEvent);for(let e in k)a.on(e,this._onCameraEvent);for(let e in A)a.on(e,this._onEvent);this._map=a}recycle(){this.map.getContainer().querySelector(`[mapboxgl-children]`)?.remove(),e.savedMaps.push(this)}destroy(){this._map.remove()}redraw(){let e=this._map;e.style&&(e._frame&&=(e._frame.cancel(),null),e._render())}_updateSize(e){let{viewState:t}=e;if(t){let e=this._map;if(t.width!==e.transform.width||t.height!==e.transform.height)return e.resize(),!0}return!1}_updateViewState(e){let t=this._map,n=t.transform;if(!t.isMoving()){let r=C(n,e);if(Object.keys(r).length>0)return this._internalUpdate=!0,t.jumpTo(r),this._internalUpdate=!1,!0}return!1}_updateSettings(e,t){let n=this._map,r=!1;for(let i of j)if((i in e||i in t)&&!x(e[i],t[i])){r=!0;let t=i in e?e[i]:D[i];n[`set${i[0].toUpperCase()}${i.slice(1)}`]?.call(n,t)}return r}_updateStyle(e,t){if(e.cursor!==t.cursor&&(this._map.getCanvas().style.cursor=e.cursor||``),e.mapStyle!==t.mapStyle){let{mapStyle:t=E,styleDiffing:n=!0}=e,r={diff:n};`localIdeographFontFamily`in e&&(r.localIdeographFontFamily=e.localIdeographFontFamily),this._map.setStyle(T(t),r)}}_updateStyleComponents({light:e,projection:t,sky:n,terrain:r}){let i=this._map,a=this._styleComponents;i.style?._loaded&&(e&&!x(e,a.light)&&(a.light=e,i.setLight(e)),t&&!x(t,a.projection)&&t!==a.projection?.type&&(a.projection=typeof t==`string`?{type:t}:t,i.setProjection?.(a.projection)),n&&!x(n,a.sky)&&(a.sky=n,i.setSky(n)),r!==void 0&&!x(r,a.terrain)&&(!r||i.getSource(r.source))&&(a.terrain=r,i.setTerrain(r)))}_updateHandlers(e,t){let n=this._map;for(let r of M){let i=e[r]??!0;x(i,t[r]??!0)||(i?n[r].enable(i):n[r].disable())}}_queryRenderedFeatures(e){let t=this._map,{interactiveLayerIds:n=[]}=this.props;try{return t.queryRenderedFeatures(e,{layers:n.filter(t.getLayer.bind(t))})}catch{return[]}}_updateHover(e){let{props:t}=this;if(t.interactiveLayerIds&&(t.onMouseMove||t.onMouseEnter||t.onMouseLeave)){let t=e.type,n=this._hoveredFeatures?.length>0,r=this._queryRenderedFeatures(e.point),i=r.length>0;!i&&n&&(e.type=`mouseleave`,this._onPointerEvent(e)),this._hoveredFeatures=r,i&&!n&&(e.type=`mouseenter`,this._onPointerEvent(e)),e.type=t}else this._hoveredFeatures=null}};N.savedMaps=[];var P=[`setMaxBounds`,`setMinZoom`,`setMaxZoom`,`setMinPitch`,`setMaxPitch`,`setRenderWorldCopies`,`setProjection`,`setStyle`,`addSource`,`removeSource`,`addLayer`,`removeLayer`,`setLayerZoomRange`,`setFilter`,`setPaintProperty`,`setLayoutProperty`,`setLight`,`setTerrain`,`setFog`,`remove`];function F(e){if(!e)return null;let t=e.map,n={getMap:()=>t};for(let e of I(t))!(e in n)&&!P.includes(e)&&(n[e]=t[e].bind(t));return n}function I(e){let t=new Set,n=e;for(;n;){for(let r of Object.getOwnPropertyNames(n))r[0]!==`_`&&typeof e[r]==`function`&&r!==`fire`&&r!==`setEventedParent`&&t.add(r);n=Object.getPrototypeOf(n)}return Array.from(t)}var L=typeof document<`u`?v.useLayoutEffect:v.useEffect;function R(e,t){let{RTLTextPlugin:n,maxParallelImageRequests:r,workerCount:i,workerUrl:a}=t;if(n&&e.getRTLTextPluginStatus&&e.getRTLTextPluginStatus()===`unavailable`){let{pluginUrl:t,lazy:r=!0}=typeof n==`string`?{pluginUrl:n}:n;e.setRTLTextPlugin(t,e=>{e&&console.error(e)},r)}r!==void 0&&e.setMaxParallelImageRequests(r),i!==void 0&&e.setWorkerCount(i),a!==void 0&&e.setWorkerUrl(a)}var z=v.createContext(null);function B(t,n){let r=(0,v.useContext)(y),[a,o]=(0,v.useState)(null),s=(0,v.useRef)(),{current:c}=(0,v.useRef)({mapLib:null,map:null});(0,v.useEffect)(()=>{let n=t.mapLib,a=!0,l;return Promise.resolve(n||i(()=>import(`./maplibre-gl-C3Ve5bV1.js`).then(t=>e(t.default,1)),[],import.meta.url)).then(e=>{if(!a)return;if(!e)throw Error(`Invalid mapLib`);let n=`Map`in e?e:e.default;if(!n.Map)throw Error(`Invalid mapLib`);R(n,t),t.reuseMaps&&(l=N.reuse(t,s.current)),l||=new N(n.Map,t,s.current),c.map=F(l),c.mapLib=n,o(l),r?.onMapMount(c.map,t.id)}).catch(e=>{let{onError:n}=t;n?n({type:`error`,target:null,originalEvent:null,error:e}):console.error(e)}),()=>{a=!1,l&&(r?.onMapUnmount(t.id),t.reuseMaps?l.recycle():l.destroy())}},[]),L(()=>{a&&a.setProps(t)}),(0,v.useImperativeHandle)(n,()=>c.map,[a]);let l=(0,v.useMemo)(()=>({position:`relative`,width:`100%`,height:`100%`,...t.style}),[t.style]);return v.createElement(`div`,{id:t.id,ref:s,style:l},a&&v.createElement(z.Provider,{value:c},v.createElement(`div`,{"mapboxgl-children":``,style:{height:`100%`}},t.children)))}var ee=v.forwardRef(B),V=e(r(),1),H=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function U(e,t){if(!e||!t)return;let n=e.style;for(let e in t){let r=t[e];Number.isFinite(r)&&!H.test(e)?n[e]=`${r}px`:n[e]=r}}function W(e,t){if(e===t)return null;let n=G(e),r=G(t),i=[];for(let e of r)n.has(e)||i.push(e);for(let e of n)r.has(e)||i.push(e);return i.length===0?null:i}function G(e){return new Set(e?e.trim().split(/\s+/):[])}var K=(0,v.memo)((0,v.forwardRef)((e,t)=>{let{map:n,mapLib:r}=(0,v.useContext)(z),i=(0,v.useRef)({props:e}),a=(0,v.useMemo)(()=>{let t=!1;v.Children.forEach(e.children,e=>{e&&(t=!0)});let n={...e,element:t?document.createElement(`div`):void 0},o=new r.Marker(n);return o.setLngLat([e.longitude,e.latitude]),o.getElement().addEventListener(`click`,e=>{i.current.props.onClick?.({type:`click`,target:o,originalEvent:e})}),o.on(`dragstart`,e=>{let t=e;t.lngLat=a.getLngLat(),i.current.props.onDragStart?.(t)}),o.on(`drag`,e=>{let t=e;t.lngLat=a.getLngLat(),i.current.props.onDrag?.(t)}),o.on(`dragend`,e=>{let t=e;t.lngLat=a.getLngLat(),i.current.props.onDragEnd?.(t)}),o},[]);(0,v.useEffect)(()=>(a.addTo(n.getMap()),()=>{a.remove()}),[]);let{longitude:o,latitude:s,offset:c,style:l,draggable:u=!1,popup:d=null,rotation:f=0,rotationAlignment:p=`auto`,pitchAlignment:m=`auto`}=e;(0,v.useEffect)(()=>{U(a.getElement(),l)},[l]),(0,v.useImperativeHandle)(t,()=>a,[]);let h=i.current.props;(a.getLngLat().lng!==o||a.getLngLat().lat!==s)&&a.setLngLat([o,s]),c&&!b(a.getOffset(),c)&&a.setOffset(c),a.isDraggable()!==u&&a.setDraggable(u),a.getRotation()!==f&&a.setRotation(f),a.getRotationAlignment()!==p&&a.setRotationAlignment(p),a.getPitchAlignment()!==m&&a.setPitchAlignment(m),a.getPopup()!==d&&a.setPopup(d);let g=W(h.className,e.className);if(g)for(let e of g)a.toggleClassName(e);return i.current.props=e,(0,V.createPortal)(e.children,a.getElement())})),te=(0,v.memo)((0,v.forwardRef)((e,t)=>{let{map:n,mapLib:r}=(0,v.useContext)(z),i=(0,v.useMemo)(()=>document.createElement(`div`),[]),a=(0,v.useRef)({props:e}),o=(0,v.useMemo)(()=>{let t={...e},n=new r.Popup(t);return n.setLngLat([e.longitude,e.latitude]),n.once(`open`,e=>{a.current.props.onOpen?.(e)}),n},[]);if((0,v.useEffect)(()=>{let e=e=>{a.current.props.onClose?.(e)};return o.on(`close`,e),o.setDOMContent(i).addTo(n.getMap()),()=>{o.off(`close`,e),o.isOpen()&&o.remove()}},[]),(0,v.useEffect)(()=>{U(o.getElement(),e.style)},[e.style]),(0,v.useImperativeHandle)(t,()=>o,[]),o.isOpen()){let t=a.current.props;(o.getLngLat().lng!==e.longitude||o.getLngLat().lat!==e.latitude)&&o.setLngLat([e.longitude,e.latitude]),e.offset&&!x(t.offset,e.offset)&&o.setOffset(e.offset),(t.anchor!==e.anchor||t.maxWidth!==e.maxWidth)&&(o.options.anchor=e.anchor,o.setMaxWidth(e.maxWidth));let n=W(t.className,e.className);if(n)for(let e of n)o.toggleClassName(e);a.current.props=e}return(0,V.createPortal)(e.children,i)}));function q(e,t,n,r){let i=(0,v.useContext)(z),a=(0,v.useMemo)(()=>e(i),[]);return(0,v.useEffect)(()=>{let e=r||n||t,o=typeof t==`function`&&typeof n==`function`?t:null,s=typeof n==`function`?n:typeof t==`function`?t:null,{map:c}=i;return c.hasControl(a)||(c.addControl(a,e?.position),o&&o(i)),()=>{s&&s(i),c.hasControl(a)&&c.removeControl(a)}},[]),a}function J(e){let t=q(({mapLib:t})=>new t.AttributionControl(e),{position:e.position});return(0,v.useEffect)(()=>{U(t._container,e.style)},[e.style]),null}(0,v.memo)(J);function Y(e){let t=q(({mapLib:t})=>new t.FullscreenControl({container:e.containerId&&document.getElementById(e.containerId)}),{position:e.position});return(0,v.useEffect)(()=>{U(t._controlContainer,e.style)},[e.style]),null}(0,v.memo)(Y);function X(e,t){let n=(0,v.useRef)({props:e}),r=q(({mapLib:t})=>{let r=new t.GeolocateControl(e),i=r._setupUI;return r._setupUI=()=>{r._container.hasChildNodes()||i()},r.on(`geolocate`,e=>{n.current.props.onGeolocate?.(e)}),r.on(`error`,e=>{n.current.props.onError?.(e)}),r.on(`outofmaxbounds`,e=>{n.current.props.onOutOfMaxBounds?.(e)}),r.on(`trackuserlocationstart`,e=>{n.current.props.onTrackUserLocationStart?.(e)}),r.on(`trackuserlocationend`,e=>{n.current.props.onTrackUserLocationEnd?.(e)}),r},{position:e.position});return n.current.props=e,(0,v.useImperativeHandle)(t,()=>r,[]),(0,v.useEffect)(()=>{U(r._container,e.style)},[e.style]),null}(0,v.memo)((0,v.forwardRef)(X));function Z(e){let t=q(({mapLib:t})=>new t.NavigationControl(e),{position:e.position});return(0,v.useEffect)(()=>{U(t._container,e.style)},[e.style]),null}var ne=(0,v.memo)(Z);function re(e){let t=q(({mapLib:t})=>new t.ScaleControl(e),{position:e.position}),n=(0,v.useRef)(e),r=n.current;n.current=e;let{style:i}=e;return e.maxWidth!==void 0&&e.maxWidth!==r.maxWidth&&(t.options.maxWidth=e.maxWidth),e.unit!==void 0&&e.unit!==r.unit&&t.setUnit(e.unit),(0,v.useEffect)(()=>{U(t._container,i)},[i]),null}(0,v.memo)(re);function ie(e){let t=q(({mapLib:t})=>new t.TerrainControl(e),{position:e.position});return(0,v.useEffect)(()=>{U(t._container,e.style)},[e.style]),null}(0,v.memo)(ie);function ae(e){let t=q(({mapLib:t})=>new t.LogoControl(e),{position:e.position});return(0,v.useEffect)(()=>{U(t._container,e.style)},[e.style]),null}(0,v.memo)(ae);var Q=a(),oe=d({latitudeField:f().optional(),longitudeField:f().optional(),locationField:f().optional(),titleField:f().optional(),descriptionField:f().optional(),zoom:m().optional(),center:p([m(),m()]).optional()});function se(e){return e.data?e.data:e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function ce(e){if(e){if(typeof e==`string`){let t=e.split(` `),n=t[0],r=t[1]?.toLowerCase()===`desc`?`desc`:`asc`;return{[n]:r}}if(Array.isArray(e))return e.reduce((e,t)=>(t.field&&t.order&&(e[t.field]=t.order),e),{})}}function le(e){if(e.locationField||e.latitudeField)return{locationField:e.locationField,latitudeField:e.latitudeField,longitudeField:e.longitudeField,titleField:e.titleField||`name`,descriptionField:e.descriptionField,zoom:e.zoom,center:e.center};let t=null;if(e.filter&&typeof e.filter==`object`&&`map`in e.filter?t=e.filter.map:e.map&&(t=e.map),t){let e=oe.safeParse(t);return e.success||console.warn(`[ObjectMap] Invalid map configuration:`,e.error.format()),t}return{latitudeField:`latitude`,longitudeField:`longitude`,locationField:`location`,titleField:`name`,descriptionField:`description`,zoom:10,center:[0,0]}}function ue(e,t){if(t.latitudeField&&t.longitudeField){let n=e[t.latitudeField],r=e[t.longitudeField];if(typeof n==`number`&&typeof r==`number`)return[n,r]}if(t.locationField){let n=e[t.locationField];if(typeof n==`object`&&n){let e=n.lat||n.latitude,t=n.lng||n.lon||n.longitude;if(typeof e==`number`&&typeof t==`number`)return[e,t]}if(typeof n==`string`){let e=n.split(`,`).map(e=>parseFloat(e.trim()));if(e.length===2&&!isNaN(e[0])&&!isNaN(e[1]))return[e[0],e[1]]}if(Array.isArray(n)&&n.length===2){let e=parseFloat(n[0]),t=parseFloat(n[1]);if(!isNaN(e)&&!isNaN(t))return[e,t]}}return null}function de(e,t,n=50){if(e.length<=1||t>=15)return e.map(e=>({id:e.id,coordinates:e.coordinates,markers:[e],isCluster:!1}));let r=n/2**t,i=new Map;e.forEach(e=>{let t=`${Math.floor(e.coordinates[0]/r)}:${Math.floor(e.coordinates[1]/r)}`;i.has(t)||i.set(t,[]),i.get(t).push(e)});let a=[];return i.forEach((e,t)=>{if(e.length===1)a.push({id:e[0].id,coordinates:e[0].coordinates,markers:e,isCluster:!1});else{let n=e.reduce((e,t)=>e+t.coordinates[0],0)/e.length,r=e.reduce((e,t)=>e+t.coordinates[1],0)/e.length;a.push({id:`cluster-${t}`,coordinates:[n,r],markers:e,isCluster:!0})}}),a}var fe=({schema:e,dataSource:t,className:n,onMarkerClick:r,onRowClick:i,onEdit:a,onDelete:s,enableClustering:l,clusterRadius:d=50,...f})=>{let[p,m]=(0,v.useState)([]),[y,b]=(0,v.useState)(!0),[x,S]=(0,v.useState)(null),[C,w]=(0,v.useState)(null),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(``),k=g(),A=(0,v.useRef)(null),[j,M]=(0,v.useState)(null),[N,P]=(0,v.useState)(null),[F,I]=(0,v.useState)(!1),L=(0,v.useCallback)(()=>{if(typeof navigator>`u`||!navigator.geolocation){P(`Geolocation is not available in this browser.`);return}I(!0),P(null),navigator.geolocation.getCurrentPosition(e=>{let{longitude:t,latitude:n}=e.coords;M({lng:t,lat:n}),I(!1);try{A.current?.flyTo({center:[t,n],zoom:12,duration:800})}catch{}},e=>{I(!1),P(e.message||`Unable to retrieve location.`)},{enableHighAccuracy:!1,timeout:8e3,maximumAge:6e4})},[]),R=se(e),z=(0,v.useMemo)(()=>R,[JSON.stringify(R)]),B=le(e),V=z?.provider===`value`;(0,v.useEffect)(()=>{(async()=>{try{if(b(!0),f.data){let e=f.data;if(Array.isArray(e)){m(e),b(!1);return}}if(e.data){let t=e.data;if(Array.isArray(t)){m(t),b(!1);return}}if(V&&z?.provider===`value`){m(z.items),b(!1);return}if(!t||typeof t.find!=`function`)throw Error(`DataSource required for object/api providers`);if(z?.provider===`object`){let n=z.object,r=c(C?.fields);m(u(await t.find(n,{$filter:e.filter,$orderby:ce(e.sort),...r.length>0?{$expand:r}:{}})))}else z?.provider===`api`&&(console.warn(`API provider not yet implemented for ObjectMap`),m([]));b(!1)}catch(e){S(e),b(!1)}})()},[z,t,V,e.filter,e.sort,C]),(0,v.useEffect)(()=>{!V&&t&&(async()=>{try{if(!t)return;let n=z?.provider===`object`?z.object:e.objectName;if(!n)return;w(await t.getObjectSchema(n))}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[e.objectName,t,V,z]);let{markers:H,invalidCount:U}=(0,v.useMemo)(()=>{let e=0;return{markers:p.map((t,n)=>{let r=ue(t,B);if(!r)return e++,null;let i=B.titleField?t[B.titleField]:`Marker`,a=B.descriptionField?t[B.descriptionField]:void 0,[o,s]=r;return!isFinite(o)||!isFinite(s)||o<-90||o>90||s<-180||s>180?(e++,null):{id:t.id||t._id||`marker-${n}`,title:i,description:a,coordinates:[s,o],data:t}}).filter(e=>e!==null),invalidCount:e}},[p,B]),W=(0,v.useMemo)(()=>H.find(e=>e.id===T),[H,T]),[G,q]=(0,v.useState)(B.zoom||3),J=o({navigation:e.navigation,objectName:e.objectName,onRowClick:i}),Y=(0,v.useMemo)(()=>{if(!D.trim())return H;let e=D.toLowerCase();return H.filter(t=>t.title?.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e))},[H,D]),X=(0,v.useMemo)(()=>l??(e.enableClustering||Y.length>100)?de(Y,G,d):Y.map(e=>({id:e.id,coordinates:e.coordinates,markers:[e],isCluster:!1})),[Y,G,l,d,e]),Z=(0,v.useMemo)(()=>{if(!Y.length)return{longitude:B.center?.[1]||0,latitude:B.center?.[0]||0,zoom:B.zoom||2};let e=Y.map(e=>e.coordinates[0]),t=Y.map(e=>e.coordinates[1]),n=Math.min(...e),r=Math.max(...e),i=Math.min(...t),a=Math.max(...t);return{longitude:(n+r)/2,latitude:(i+a)/2,zoom:B.zoom||3}},[Y,B]);return y?(0,Q.jsx)(`div`,{className:_(`min-w-0 overflow-hidden`,n),children:(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-96 bg-muted rounded-lg border`,children:(0,Q.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading map...`})})}):x?(0,Q.jsx)(`div`,{className:_(`min-w-0 overflow-hidden`,n),children:(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-96 bg-muted rounded-lg border`,children:(0,Q.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,x.message]})})}):(0,Q.jsxs)(`div`,{className:_(`min-w-0 overflow-hidden`,n),children:[U>0&&(0,Q.jsx)(`div`,{className:`mb-2 p-2 text-sm text-yellow-800 bg-yellow-50 border border-yellow-200 rounded`,children:`${U} record${U===1?``:`s`} with missing or invalid coordinates excluded from the map.`}),H.length>0&&(0,Q.jsx)(`div`,{className:`mb-2`,children:(0,Q.jsx)(`input`,{type:`text`,value:D,onChange:e=>O(e.target.value),placeholder:`Search locations…`,className:`w-full px-3 py-2 text-sm border rounded-md bg-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring`})}),(0,Q.jsxs)(`div`,{className:`relative border rounded-lg overflow-hidden bg-muted h-[300px] sm:h-[400px] md:h-[500px] lg:h-[600px] w-full`,children:[(0,Q.jsxs)(ee,{ref:e=>{A.current=e},initialViewState:Z,style:{width:`100%`,height:`100%`},mapStyle:`https://demotiles.maplibre.org/style.json`,touchZoomRotate:!0,dragRotate:!0,touchPitch:!0,onZoom:e=>q(Math.round(e.viewState.zoom)),children:[(0,Q.jsx)(ne,{position:`top-right`,showCompass:!0,showZoom:!0}),(0,Q.jsx)(`button`,{type:`button`,onClick:L,disabled:F,className:`absolute top-2 left-2 z-10 inline-flex items-center justify-center size-9 rounded-md bg-background/95 border shadow-sm hover:bg-background disabled:opacity-50`,"aria-label":`Show my location`,"data-testid":`map-geolocate`,children:(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:F?`⏳`:`🧭`})}),j&&(0,Q.jsx)(K,{longitude:j.lng,latitude:j.lat,anchor:`center`,children:(0,Q.jsx)(`div`,{className:`size-3 rounded-full bg-blue-500 ring-4 ring-blue-500/30 shadow`,"aria-label":`Your location`,"data-testid":`map-user-location`})}),X.map(e=>e.isCluster?(0,Q.jsx)(K,{longitude:e.coordinates[0],latitude:e.coordinates[1],anchor:`center`,onClick:t=>{t.originalEvent.stopPropagation();try{let t=Math.min(20,Math.max(G+2,8));A.current?.flyTo({center:[e.coordinates[0],e.coordinates[1]],zoom:t,duration:600})}catch{}},children:(0,Q.jsx)(`div`,{className:`flex items-center justify-center rounded-full bg-primary text-primary-foreground font-bold text-xs cursor-pointer hover:scale-110 transition-transform shadow-md`,style:{width:Math.min(48,24+e.markers.length*2),height:Math.min(48,24+e.markers.length*2)},title:`${e.markers.length} markers`,"data-testid":`map-cluster`,children:e.markers.length})},e.id):(0,Q.jsx)(K,{longitude:e.coordinates[0],latitude:e.coordinates[1],anchor:`bottom`,onClick:t=>{t.originalEvent.stopPropagation();let n=e.markers[0];E(n.id),J.handleClick(n.data),r?.(n.data)},children:(0,Q.jsx)(`div`,{className:`text-2xl cursor-pointer hover:scale-110 transition-transform`,children:`📍`})},e.id)),W&&!k&&(0,Q.jsx)(te,{longitude:W.coordinates[0],latitude:W.coordinates[1],anchor:`top`,onClose:()=>E(null),closeOnClick:!1,children:(0,Q.jsxs)(`div`,{className:`p-2 min-w-[150px] sm:min-w-[200px]`,children:[(0,Q.jsx)(`h3`,{className:`font-bold text-sm mb-1`,children:W.title}),W.description&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:W.description}),(0,Q.jsxs)(`div`,{className:`mt-2 text-xs flex gap-2`,children:[a&&(0,Q.jsx)(`button`,{className:`text-blue-500 hover:underline`,onClick:()=>a(W.data),children:`Edit`}),s&&(0,Q.jsx)(`button`,{className:`text-red-500 hover:underline`,onClick:()=>s(W.data),children:`Delete`})]})]})})]}),W&&k&&(0,Q.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0 z-30 bg-background border-t shadow-lg rounded-t-2xl p-4 pb-[max(env(safe-area-inset-bottom),1rem)]`,role:`dialog`,"aria-label":`Location details`,"data-testid":`map-mobile-record-sheet`,children:[(0,Q.jsx)(`div`,{className:`mx-auto mb-2 h-1 w-10 rounded-full bg-muted`,"aria-hidden":`true`}),(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold truncate`,children:W.title}),W.description&&(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground line-clamp-3`,children:W.description})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>E(null),className:`text-muted-foreground hover:text-foreground text-lg leading-none px-2`,"aria-label":`Close details`,"data-testid":`map-mobile-record-close`,children:`×`})]}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs`,children:[a&&(0,Q.jsx)(`button`,{className:`px-3 py-1.5 rounded-md border bg-card hover:bg-accent`,onClick:()=>a(W.data),children:`Edit`}),s&&(0,Q.jsx)(`button`,{className:`px-3 py-1.5 rounded-md border border-destructive/30 text-destructive hover:bg-destructive/10`,onClick:()=>s(W.data),children:`Delete`})]})]}),N&&(0,Q.jsx)(`div`,{className:`absolute top-2 left-14 right-2 z-10 text-xs px-3 py-1.5 rounded-md bg-destructive/10 text-destructive border border-destructive/30`,children:N})]}),J.isOverlay&&(0,Q.jsx)(h,{...J,title:`Location Details`,children:e=>(0,Q.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,Q.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})},pe=t({ObjectMap:()=>fe,ObjectMapRenderer:()=>$}),$=({schema:e,...t})=>{let{dataSource:n}=s()||{};return(0,Q.jsx)(fe,{schema:e,dataSource:n,...t})};console.log(`Registering object-map...`),l.register(`object-map`,$,{namespace:`plugin-map`,label:`Object Map`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`map`,type:`object`,label:`Map Config`,description:`latitudeField, longitudeField, titleField`}]}),l.register(`map`,$,{namespace:`view`,label:`Map View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`map`,type:`object`,label:`Map Config`,description:`latitudeField, longitudeField, titleField`}]});export{pe as t};
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,g as r,m as i,t as a}from"./vendor-react-DR370ovB.js";import{F as o,G as s,lt as c,mt as l,ut as u}from"./framework-D7UWfRl4.js";import{A as d,N as f,P as p,k as m}from"./vendor-objectstack-RB3xvhcR.js";import{I as h,Nt as g,lc as _}from"./ui-components-Clv7N77v.js";var v=e(n(),1),y=v.createContext(null);function b(e,t){let n=Array.isArray(e)?e[0]:e?e.x:0,r=Array.isArray(e)?e[1]:e?e.y:0,i=Array.isArray(t)?t[0]:t?t.x:0,a=Array.isArray(t)?t[1]:t?t.y:0;return n===i&&r===a}function x(e,t){if(e===t)return!0;if(!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!x(e[n],t[n]))return!1;return!0}else if(Array.isArray(t))return!1;if(typeof e==`object`&&typeof t==`object`){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!t.hasOwnProperty(r)||!x(e[r],t[r]))return!1;return!0}return!1}function S(e){return{longitude:e.center.lng,latitude:e.center.lat,zoom:e.zoom,pitch:e.pitch,bearing:e.bearing,padding:e.padding}}function C(e,t){let n=t.viewState||t,r={};if(`longitude`in n&&`latitude`in n&&(n.longitude!==e.center.lng||n.latitude!==e.center.lat)){let t=e.center.constructor;r.center=new t(n.longitude,n.latitude)}return`zoom`in n&&n.zoom!==e.zoom&&(r.zoom=n.zoom),`bearing`in n&&n.bearing!==e.bearing&&(r.bearing=n.bearing),`pitch`in n&&n.pitch!==e.pitch&&(r.pitch=n.pitch),n.padding&&e.padding&&!x(n.padding,e.padding)&&(r.padding=n.padding),r}var w=[`type`,`source`,`source-layer`,`minzoom`,`maxzoom`,`filter`,`layout`];function T(e){if(!e)return null;if(typeof e==`string`||(`toJS`in e&&(e=e.toJS()),!e.layers))return e;let t={};for(let n of e.layers)t[n.id]=n;let n=e.layers.map(e=>{let n=null;`interactive`in e&&(n=Object.assign({},e),delete n.interactive);let r=t[e.ref];if(r){n||=Object.assign({},e),delete n.ref;for(let e of w)e in r&&(n[e]=r[e])}return n||e});return{...e,layers:n}}var E={version:8,sources:{},layers:[]},D={minZoom:0,maxZoom:22,minPitch:0,maxPitch:85,maxBounds:[-180,-85.051129,180,85.051129],projection:`mercator`,renderWorldCopies:!0},O={mousedown:`onMouseDown`,mouseup:`onMouseUp`,mouseover:`onMouseOver`,mousemove:`onMouseMove`,click:`onClick`,dblclick:`onDblClick`,mouseenter:`onMouseEnter`,mouseleave:`onMouseLeave`,mouseout:`onMouseOut`,contextmenu:`onContextMenu`,touchstart:`onTouchStart`,touchend:`onTouchEnd`,touchmove:`onTouchMove`,touchcancel:`onTouchCancel`},k={movestart:`onMoveStart`,move:`onMove`,moveend:`onMoveEnd`,dragstart:`onDragStart`,drag:`onDrag`,dragend:`onDragEnd`,zoomstart:`onZoomStart`,zoom:`onZoom`,zoomend:`onZoomEnd`,rotatestart:`onRotateStart`,rotate:`onRotate`,rotateend:`onRotateEnd`,pitchstart:`onPitchStart`,pitch:`onPitch`,pitchend:`onPitchEnd`},A={wheel:`onWheel`,boxzoomstart:`onBoxZoomStart`,boxzoomend:`onBoxZoomEnd`,boxzoomcancel:`onBoxZoomCancel`,resize:`onResize`,load:`onLoad`,render:`onRender`,idle:`onIdle`,remove:`onRemove`,data:`onData`,styledata:`onStyleData`,sourcedata:`onSourceData`,error:`onError`},j=[`minZoom`,`maxZoom`,`minPitch`,`maxPitch`,`maxBounds`,`projection`,`renderWorldCopies`],M=[`scrollZoom`,`boxZoom`,`dragRotate`,`dragPan`,`keyboard`,`doubleClickZoom`,`touchZoomRotate`,`touchPitch`],N=class e{constructor(e,t,n){this._map=null,this._internalUpdate=!1,this._hoveredFeatures=null,this._propsedCameraUpdate=null,this._styleComponents={},this._onEvent=e=>{let t=this.props[A[e.type]];t?t(e):e.type===`error`&&console.error(e.error)},this._onCameraEvent=e=>{if(this._internalUpdate)return;e.viewState=this._propsedCameraUpdate||S(this._map.transform);let t=this.props[k[e.type]];t&&t(e)},this._onCameraUpdate=e=>this._internalUpdate?e:(this._propsedCameraUpdate=S(e),C(e,this.props)),this._onPointerEvent=e=>{(e.type===`mousemove`||e.type===`mouseout`)&&this._updateHover(e);let t=this.props[O[e.type]];t&&(this.props.interactiveLayerIds&&e.type!==`mouseover`&&e.type!==`mouseout`&&(e.features=this._hoveredFeatures||this._queryRenderedFeatures(e.point)),t(e),delete e.features)},this._MapClass=e,this.props=t,this._initialize(n)}get map(){return this._map}setProps(e){let t=this.props;this.props=e;let n=this._updateSettings(e,t),r=this._updateSize(e),i=this._updateViewState(e);this._updateStyle(e,t),this._updateStyleComponents(e),this._updateHandlers(e,t),(n||r||i&&!this._map.isMoving())&&this.redraw()}static reuse(t,n){let r=e.savedMaps.pop();if(!r)return null;let i=r.map,a=i.getContainer();for(n.className=a.className;a.childNodes.length>0;)n.appendChild(a.childNodes[0]);i._container=n;let o=i._resizeObserver;o&&(o.disconnect(),o.observe(n)),r.setProps({...t,styleDiffing:!1}),i.resize();let{initialViewState:s}=t;return s&&(s.bounds?i.fitBounds(s.bounds,{...s.fitBoundsOptions,duration:0}):r._updateViewState(s)),i.isStyleLoaded()?i.fire(`load`):i.once(`style.load`,()=>i.fire(`load`)),i._update(),r}_initialize(e){let{props:t}=this,{mapStyle:n=E}=t,r={...t,...t.initialViewState,container:e,style:T(n)},i=r.initialViewState||r.viewState||r;if(Object.assign(r,{center:[i.longitude||0,i.latitude||0],zoom:i.zoom||0,pitch:i.pitch||0,bearing:i.bearing||0}),t.gl){let e=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=()=>(HTMLCanvasElement.prototype.getContext=e,t.gl)}let a=new this._MapClass(r);i.padding&&a.setPadding(i.padding),t.cursor&&(a.getCanvas().style.cursor=t.cursor),a.transformCameraUpdate=this._onCameraUpdate,a.on(`style.load`,()=>{this._styleComponents={light:a.getLight(),sky:a.getSky(),projection:a.getProjection?.(),terrain:a.getTerrain()},this._updateStyleComponents(this.props)}),a.on(`sourcedata`,()=>{this._updateStyleComponents(this.props)});for(let e in O)a.on(e,this._onPointerEvent);for(let e in k)a.on(e,this._onCameraEvent);for(let e in A)a.on(e,this._onEvent);this._map=a}recycle(){this.map.getContainer().querySelector(`[mapboxgl-children]`)?.remove(),e.savedMaps.push(this)}destroy(){this._map.remove()}redraw(){let e=this._map;e.style&&(e._frame&&=(e._frame.cancel(),null),e._render())}_updateSize(e){let{viewState:t}=e;if(t){let e=this._map;if(t.width!==e.transform.width||t.height!==e.transform.height)return e.resize(),!0}return!1}_updateViewState(e){let t=this._map,n=t.transform;if(!t.isMoving()){let r=C(n,e);if(Object.keys(r).length>0)return this._internalUpdate=!0,t.jumpTo(r),this._internalUpdate=!1,!0}return!1}_updateSettings(e,t){let n=this._map,r=!1;for(let i of j)if((i in e||i in t)&&!x(e[i],t[i])){r=!0;let t=i in e?e[i]:D[i];n[`set${i[0].toUpperCase()}${i.slice(1)}`]?.call(n,t)}return r}_updateStyle(e,t){if(e.cursor!==t.cursor&&(this._map.getCanvas().style.cursor=e.cursor||``),e.mapStyle!==t.mapStyle){let{mapStyle:t=E,styleDiffing:n=!0}=e,r={diff:n};`localIdeographFontFamily`in e&&(r.localIdeographFontFamily=e.localIdeographFontFamily),this._map.setStyle(T(t),r)}}_updateStyleComponents({light:e,projection:t,sky:n,terrain:r}){let i=this._map,a=this._styleComponents;i.style?._loaded&&(e&&!x(e,a.light)&&(a.light=e,i.setLight(e)),t&&!x(t,a.projection)&&t!==a.projection?.type&&(a.projection=typeof t==`string`?{type:t}:t,i.setProjection?.(a.projection)),n&&!x(n,a.sky)&&(a.sky=n,i.setSky(n)),r!==void 0&&!x(r,a.terrain)&&(!r||i.getSource(r.source))&&(a.terrain=r,i.setTerrain(r)))}_updateHandlers(e,t){let n=this._map;for(let r of M){let i=e[r]??!0;x(i,t[r]??!0)||(i?n[r].enable(i):n[r].disable())}}_queryRenderedFeatures(e){let t=this._map,{interactiveLayerIds:n=[]}=this.props;try{return t.queryRenderedFeatures(e,{layers:n.filter(t.getLayer.bind(t))})}catch{return[]}}_updateHover(e){let{props:t}=this;if(t.interactiveLayerIds&&(t.onMouseMove||t.onMouseEnter||t.onMouseLeave)){let t=e.type,n=this._hoveredFeatures?.length>0,r=this._queryRenderedFeatures(e.point),i=r.length>0;!i&&n&&(e.type=`mouseleave`,this._onPointerEvent(e)),this._hoveredFeatures=r,i&&!n&&(e.type=`mouseenter`,this._onPointerEvent(e)),e.type=t}else this._hoveredFeatures=null}};N.savedMaps=[];var P=[`setMaxBounds`,`setMinZoom`,`setMaxZoom`,`setMinPitch`,`setMaxPitch`,`setRenderWorldCopies`,`setProjection`,`setStyle`,`addSource`,`removeSource`,`addLayer`,`removeLayer`,`setLayerZoomRange`,`setFilter`,`setPaintProperty`,`setLayoutProperty`,`setLight`,`setTerrain`,`setFog`,`remove`];function F(e){if(!e)return null;let t=e.map,n={getMap:()=>t};for(let e of I(t))!(e in n)&&!P.includes(e)&&(n[e]=t[e].bind(t));return n}function I(e){let t=new Set,n=e;for(;n;){for(let r of Object.getOwnPropertyNames(n))r[0]!==`_`&&typeof e[r]==`function`&&r!==`fire`&&r!==`setEventedParent`&&t.add(r);n=Object.getPrototypeOf(n)}return Array.from(t)}var L=typeof document<`u`?v.useLayoutEffect:v.useEffect;function R(e,t){let{RTLTextPlugin:n,maxParallelImageRequests:r,workerCount:i,workerUrl:a}=t;if(n&&e.getRTLTextPluginStatus&&e.getRTLTextPluginStatus()===`unavailable`){let{pluginUrl:t,lazy:r=!0}=typeof n==`string`?{pluginUrl:n}:n;e.setRTLTextPlugin(t,e=>{e&&console.error(e)},r)}r!==void 0&&e.setMaxParallelImageRequests(r),i!==void 0&&e.setWorkerCount(i),a!==void 0&&e.setWorkerUrl(a)}var z=v.createContext(null);function B(t,n){let r=(0,v.useContext)(y),[a,o]=(0,v.useState)(null),s=(0,v.useRef)(),{current:c}=(0,v.useRef)({mapLib:null,map:null});(0,v.useEffect)(()=>{let n=t.mapLib,a=!0,l;return Promise.resolve(n||i(()=>import(`./maplibre-gl-C3Ve5bV1.js`).then(t=>e(t.default,1)),[],import.meta.url)).then(e=>{if(!a)return;if(!e)throw Error(`Invalid mapLib`);let n=`Map`in e?e:e.default;if(!n.Map)throw Error(`Invalid mapLib`);R(n,t),t.reuseMaps&&(l=N.reuse(t,s.current)),l||=new N(n.Map,t,s.current),c.map=F(l),c.mapLib=n,o(l),r?.onMapMount(c.map,t.id)}).catch(e=>{let{onError:n}=t;n?n({type:`error`,target:null,originalEvent:null,error:e}):console.error(e)}),()=>{a=!1,l&&(r?.onMapUnmount(t.id),t.reuseMaps?l.recycle():l.destroy())}},[]),L(()=>{a&&a.setProps(t)}),(0,v.useImperativeHandle)(n,()=>c.map,[a]);let l=(0,v.useMemo)(()=>({position:`relative`,width:`100%`,height:`100%`,...t.style}),[t.style]);return v.createElement(`div`,{id:t.id,ref:s,style:l},a&&v.createElement(z.Provider,{value:c},v.createElement(`div`,{"mapboxgl-children":``,style:{height:`100%`}},t.children)))}var ee=v.forwardRef(B),V=e(r(),1),H=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function U(e,t){if(!e||!t)return;let n=e.style;for(let e in t){let r=t[e];Number.isFinite(r)&&!H.test(e)?n[e]=`${r}px`:n[e]=r}}function W(e,t){if(e===t)return null;let n=G(e),r=G(t),i=[];for(let e of r)n.has(e)||i.push(e);for(let e of n)r.has(e)||i.push(e);return i.length===0?null:i}function G(e){return new Set(e?e.trim().split(/\s+/):[])}var K=(0,v.memo)((0,v.forwardRef)((e,t)=>{let{map:n,mapLib:r}=(0,v.useContext)(z),i=(0,v.useRef)({props:e}),a=(0,v.useMemo)(()=>{let t=!1;v.Children.forEach(e.children,e=>{e&&(t=!0)});let n={...e,element:t?document.createElement(`div`):void 0},o=new r.Marker(n);return o.setLngLat([e.longitude,e.latitude]),o.getElement().addEventListener(`click`,e=>{i.current.props.onClick?.({type:`click`,target:o,originalEvent:e})}),o.on(`dragstart`,e=>{let t=e;t.lngLat=a.getLngLat(),i.current.props.onDragStart?.(t)}),o.on(`drag`,e=>{let t=e;t.lngLat=a.getLngLat(),i.current.props.onDrag?.(t)}),o.on(`dragend`,e=>{let t=e;t.lngLat=a.getLngLat(),i.current.props.onDragEnd?.(t)}),o},[]);(0,v.useEffect)(()=>(a.addTo(n.getMap()),()=>{a.remove()}),[]);let{longitude:o,latitude:s,offset:c,style:l,draggable:u=!1,popup:d=null,rotation:f=0,rotationAlignment:p=`auto`,pitchAlignment:m=`auto`}=e;(0,v.useEffect)(()=>{U(a.getElement(),l)},[l]),(0,v.useImperativeHandle)(t,()=>a,[]);let h=i.current.props;(a.getLngLat().lng!==o||a.getLngLat().lat!==s)&&a.setLngLat([o,s]),c&&!b(a.getOffset(),c)&&a.setOffset(c),a.isDraggable()!==u&&a.setDraggable(u),a.getRotation()!==f&&a.setRotation(f),a.getRotationAlignment()!==p&&a.setRotationAlignment(p),a.getPitchAlignment()!==m&&a.setPitchAlignment(m),a.getPopup()!==d&&a.setPopup(d);let g=W(h.className,e.className);if(g)for(let e of g)a.toggleClassName(e);return i.current.props=e,(0,V.createPortal)(e.children,a.getElement())})),te=(0,v.memo)((0,v.forwardRef)((e,t)=>{let{map:n,mapLib:r}=(0,v.useContext)(z),i=(0,v.useMemo)(()=>document.createElement(`div`),[]),a=(0,v.useRef)({props:e}),o=(0,v.useMemo)(()=>{let t={...e},n=new r.Popup(t);return n.setLngLat([e.longitude,e.latitude]),n.once(`open`,e=>{a.current.props.onOpen?.(e)}),n},[]);if((0,v.useEffect)(()=>{let e=e=>{a.current.props.onClose?.(e)};return o.on(`close`,e),o.setDOMContent(i).addTo(n.getMap()),()=>{o.off(`close`,e),o.isOpen()&&o.remove()}},[]),(0,v.useEffect)(()=>{U(o.getElement(),e.style)},[e.style]),(0,v.useImperativeHandle)(t,()=>o,[]),o.isOpen()){let t=a.current.props;(o.getLngLat().lng!==e.longitude||o.getLngLat().lat!==e.latitude)&&o.setLngLat([e.longitude,e.latitude]),e.offset&&!x(t.offset,e.offset)&&o.setOffset(e.offset),(t.anchor!==e.anchor||t.maxWidth!==e.maxWidth)&&(o.options.anchor=e.anchor,o.setMaxWidth(e.maxWidth));let n=W(t.className,e.className);if(n)for(let e of n)o.toggleClassName(e);a.current.props=e}return(0,V.createPortal)(e.children,i)}));function q(e,t,n,r){let i=(0,v.useContext)(z),a=(0,v.useMemo)(()=>e(i),[]);return(0,v.useEffect)(()=>{let e=r||n||t,o=typeof t==`function`&&typeof n==`function`?t:null,s=typeof n==`function`?n:typeof t==`function`?t:null,{map:c}=i;return c.hasControl(a)||(c.addControl(a,e?.position),o&&o(i)),()=>{s&&s(i),c.hasControl(a)&&c.removeControl(a)}},[]),a}function J(e){let t=q(({mapLib:t})=>new t.AttributionControl(e),{position:e.position});return(0,v.useEffect)(()=>{U(t._container,e.style)},[e.style]),null}(0,v.memo)(J);function Y(e){let t=q(({mapLib:t})=>new t.FullscreenControl({container:e.containerId&&document.getElementById(e.containerId)}),{position:e.position});return(0,v.useEffect)(()=>{U(t._controlContainer,e.style)},[e.style]),null}(0,v.memo)(Y);function X(e,t){let n=(0,v.useRef)({props:e}),r=q(({mapLib:t})=>{let r=new t.GeolocateControl(e),i=r._setupUI;return r._setupUI=()=>{r._container.hasChildNodes()||i()},r.on(`geolocate`,e=>{n.current.props.onGeolocate?.(e)}),r.on(`error`,e=>{n.current.props.onError?.(e)}),r.on(`outofmaxbounds`,e=>{n.current.props.onOutOfMaxBounds?.(e)}),r.on(`trackuserlocationstart`,e=>{n.current.props.onTrackUserLocationStart?.(e)}),r.on(`trackuserlocationend`,e=>{n.current.props.onTrackUserLocationEnd?.(e)}),r},{position:e.position});return n.current.props=e,(0,v.useImperativeHandle)(t,()=>r,[]),(0,v.useEffect)(()=>{U(r._container,e.style)},[e.style]),null}(0,v.memo)((0,v.forwardRef)(X));function Z(e){let t=q(({mapLib:t})=>new t.NavigationControl(e),{position:e.position});return(0,v.useEffect)(()=>{U(t._container,e.style)},[e.style]),null}var ne=(0,v.memo)(Z);function re(e){let t=q(({mapLib:t})=>new t.ScaleControl(e),{position:e.position}),n=(0,v.useRef)(e),r=n.current;n.current=e;let{style:i}=e;return e.maxWidth!==void 0&&e.maxWidth!==r.maxWidth&&(t.options.maxWidth=e.maxWidth),e.unit!==void 0&&e.unit!==r.unit&&t.setUnit(e.unit),(0,v.useEffect)(()=>{U(t._container,i)},[i]),null}(0,v.memo)(re);function ie(e){let t=q(({mapLib:t})=>new t.TerrainControl(e),{position:e.position});return(0,v.useEffect)(()=>{U(t._container,e.style)},[e.style]),null}(0,v.memo)(ie);function ae(e){let t=q(({mapLib:t})=>new t.LogoControl(e),{position:e.position});return(0,v.useEffect)(()=>{U(t._container,e.style)},[e.style]),null}(0,v.memo)(ae);var Q=a(),oe=d({latitudeField:f().optional(),longitudeField:f().optional(),locationField:f().optional(),titleField:f().optional(),descriptionField:f().optional(),zoom:m().optional(),center:p([m(),m()]).optional()});function se(e){return e.data?e.data:e.staticData?{provider:`value`,items:e.staticData}:e.objectName?{provider:`object`,object:e.objectName}:null}function ce(e){if(e){if(typeof e==`string`){let t=e.split(` `),n=t[0],r=t[1]?.toLowerCase()===`desc`?`desc`:`asc`;return{[n]:r}}if(Array.isArray(e))return e.reduce((e,t)=>(t.field&&t.order&&(e[t.field]=t.order),e),{})}}function le(e){if(e.locationField||e.latitudeField)return{locationField:e.locationField,latitudeField:e.latitudeField,longitudeField:e.longitudeField,titleField:e.titleField||`name`,descriptionField:e.descriptionField,zoom:e.zoom,center:e.center};let t=null;if(e.filter&&typeof e.filter==`object`&&`map`in e.filter?t=e.filter.map:e.map&&(t=e.map),t){let e=oe.safeParse(t);return e.success||console.warn(`[ObjectMap] Invalid map configuration:`,e.error.format()),t}return{latitudeField:`latitude`,longitudeField:`longitude`,locationField:`location`,titleField:`name`,descriptionField:`description`,zoom:10,center:[0,0]}}function ue(e,t){if(t.latitudeField&&t.longitudeField){let n=e[t.latitudeField],r=e[t.longitudeField];if(typeof n==`number`&&typeof r==`number`)return[n,r]}if(t.locationField){let n=e[t.locationField];if(typeof n==`object`&&n){let e=n.lat||n.latitude,t=n.lng||n.lon||n.longitude;if(typeof e==`number`&&typeof t==`number`)return[e,t]}if(typeof n==`string`){let e=n.split(`,`).map(e=>parseFloat(e.trim()));if(e.length===2&&!isNaN(e[0])&&!isNaN(e[1]))return[e[0],e[1]]}if(Array.isArray(n)&&n.length===2){let e=parseFloat(n[0]),t=parseFloat(n[1]);if(!isNaN(e)&&!isNaN(t))return[e,t]}}return null}function de(e,t,n=50){if(e.length<=1||t>=15)return e.map(e=>({id:e.id,coordinates:e.coordinates,markers:[e],isCluster:!1}));let r=n/2**t,i=new Map;e.forEach(e=>{let t=`${Math.floor(e.coordinates[0]/r)}:${Math.floor(e.coordinates[1]/r)}`;i.has(t)||i.set(t,[]),i.get(t).push(e)});let a=[];return i.forEach((e,t)=>{if(e.length===1)a.push({id:e[0].id,coordinates:e[0].coordinates,markers:e,isCluster:!1});else{let n=e.reduce((e,t)=>e+t.coordinates[0],0)/e.length,r=e.reduce((e,t)=>e+t.coordinates[1],0)/e.length;a.push({id:`cluster-${t}`,coordinates:[n,r],markers:e,isCluster:!0})}}),a}var fe=({schema:e,dataSource:t,className:n,onMarkerClick:r,onRowClick:i,onEdit:a,onDelete:s,enableClustering:l,clusterRadius:d=50,...f})=>{let[p,m]=(0,v.useState)([]),[y,b]=(0,v.useState)(!0),[x,S]=(0,v.useState)(null),[C,w]=(0,v.useState)(null),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(``),k=g(),A=(0,v.useRef)(null),[j,M]=(0,v.useState)(null),[N,P]=(0,v.useState)(null),[F,I]=(0,v.useState)(!1),L=(0,v.useCallback)(()=>{if(typeof navigator>`u`||!navigator.geolocation){P(`Geolocation is not available in this browser.`);return}I(!0),P(null),navigator.geolocation.getCurrentPosition(e=>{let{longitude:t,latitude:n}=e.coords;M({lng:t,lat:n}),I(!1);try{A.current?.flyTo({center:[t,n],zoom:12,duration:800})}catch{}},e=>{I(!1),P(e.message||`Unable to retrieve location.`)},{enableHighAccuracy:!1,timeout:8e3,maximumAge:6e4})},[]),R=se(e),z=(0,v.useMemo)(()=>R,[JSON.stringify(R)]),B=le(e),V=z?.provider===`value`;(0,v.useEffect)(()=>{(async()=>{try{if(b(!0),f.data){let e=f.data;if(Array.isArray(e)){m(e),b(!1);return}}if(e.data){let t=e.data;if(Array.isArray(t)){m(t),b(!1);return}}if(V&&z?.provider===`value`){m(z.items),b(!1);return}if(!t||typeof t.find!=`function`)throw Error(`DataSource required for object/api providers`);if(z?.provider===`object`){let n=z.object,r=c(C?.fields);m(u(await t.find(n,{$filter:e.filter,$orderby:ce(e.sort),...r.length>0?{$expand:r}:{}})))}else z?.provider===`api`&&(console.warn(`API provider not yet implemented for ObjectMap`),m([]));b(!1)}catch(e){S(e),b(!1)}})()},[z,t,V,e.filter,e.sort,C]),(0,v.useEffect)(()=>{!V&&t&&(async()=>{try{if(!t)return;let n=z?.provider===`object`?z.object:e.objectName;if(!n)return;w(await t.getObjectSchema(n))}catch(e){console.error(`Failed to fetch object schema:`,e)}})()},[e.objectName,t,V,z]);let{markers:H,invalidCount:U}=(0,v.useMemo)(()=>{let e=0;return{markers:p.map((t,n)=>{let r=ue(t,B);if(!r)return e++,null;let i=B.titleField?t[B.titleField]:`Marker`,a=B.descriptionField?t[B.descriptionField]:void 0,[o,s]=r;return!isFinite(o)||!isFinite(s)||o<-90||o>90||s<-180||s>180?(e++,null):{id:t.id||t._id||`marker-${n}`,title:i,description:a,coordinates:[s,o],data:t}}).filter(e=>e!==null),invalidCount:e}},[p,B]),W=(0,v.useMemo)(()=>H.find(e=>e.id===T),[H,T]),[G,q]=(0,v.useState)(B.zoom||3),J=o({navigation:e.navigation,objectName:e.objectName,onRowClick:i}),Y=(0,v.useMemo)(()=>{if(!D.trim())return H;let e=D.toLowerCase();return H.filter(t=>t.title?.toLowerCase().includes(e)||t.description?.toLowerCase().includes(e))},[H,D]),X=(0,v.useMemo)(()=>l??(e.enableClustering||Y.length>100)?de(Y,G,d):Y.map(e=>({id:e.id,coordinates:e.coordinates,markers:[e],isCluster:!1})),[Y,G,l,d,e]),Z=(0,v.useMemo)(()=>{if(!Y.length)return{longitude:B.center?.[1]||0,latitude:B.center?.[0]||0,zoom:B.zoom||2};let e=Y.map(e=>e.coordinates[0]),t=Y.map(e=>e.coordinates[1]),n=Math.min(...e),r=Math.max(...e),i=Math.min(...t),a=Math.max(...t);return{longitude:(n+r)/2,latitude:(i+a)/2,zoom:B.zoom||3}},[Y,B]);return y?(0,Q.jsx)(`div`,{className:_(`min-w-0 overflow-hidden`,n),children:(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-96 bg-muted rounded-lg border`,children:(0,Q.jsx)(`div`,{className:`text-muted-foreground`,children:`Loading map...`})})}):x?(0,Q.jsx)(`div`,{className:_(`min-w-0 overflow-hidden`,n),children:(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-96 bg-muted rounded-lg border`,children:(0,Q.jsxs)(`div`,{className:`text-destructive`,children:[`Error: `,x.message]})})}):(0,Q.jsxs)(`div`,{className:_(`min-w-0 overflow-hidden`,n),children:[U>0&&(0,Q.jsx)(`div`,{className:`mb-2 p-2 text-sm text-yellow-800 bg-yellow-50 border border-yellow-200 rounded`,children:`${U} record${U===1?``:`s`} with missing or invalid coordinates excluded from the map.`}),H.length>0&&(0,Q.jsx)(`div`,{className:`mb-2`,children:(0,Q.jsx)(`input`,{type:`text`,value:D,onChange:e=>O(e.target.value),placeholder:`Search locations…`,className:`w-full px-3 py-2 text-sm border rounded-md bg-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring`})}),(0,Q.jsxs)(`div`,{className:`relative border rounded-lg overflow-hidden bg-muted h-[300px] sm:h-[400px] md:h-[500px] lg:h-[600px] w-full`,children:[(0,Q.jsxs)(ee,{ref:e=>{A.current=e},initialViewState:Z,style:{width:`100%`,height:`100%`},mapStyle:`https://demotiles.maplibre.org/style.json`,touchZoomRotate:!0,dragRotate:!0,touchPitch:!0,onZoom:e=>q(Math.round(e.viewState.zoom)),children:[(0,Q.jsx)(ne,{position:`top-right`,showCompass:!0,showZoom:!0}),(0,Q.jsx)(`button`,{type:`button`,onClick:L,disabled:F,className:`absolute top-2 left-2 z-10 inline-flex items-center justify-center size-9 rounded-md bg-background/95 border shadow-sm hover:bg-background disabled:opacity-50`,"aria-label":`Show my location`,"data-testid":`map-geolocate`,children:(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:F?`⏳`:`🧭`})}),j&&(0,Q.jsx)(K,{longitude:j.lng,latitude:j.lat,anchor:`center`,children:(0,Q.jsx)(`div`,{className:`size-3 rounded-full bg-blue-500 ring-4 ring-blue-500/30 shadow`,"aria-label":`Your location`,"data-testid":`map-user-location`})}),X.map(e=>e.isCluster?(0,Q.jsx)(K,{longitude:e.coordinates[0],latitude:e.coordinates[1],anchor:`center`,onClick:t=>{t.originalEvent.stopPropagation();try{let t=Math.min(20,Math.max(G+2,8));A.current?.flyTo({center:[e.coordinates[0],e.coordinates[1]],zoom:t,duration:600})}catch{}},children:(0,Q.jsx)(`div`,{className:`flex items-center justify-center rounded-full bg-primary text-primary-foreground font-bold text-xs cursor-pointer hover:scale-110 transition-transform shadow-md`,style:{width:Math.min(48,24+e.markers.length*2),height:Math.min(48,24+e.markers.length*2)},title:`${e.markers.length} markers`,"data-testid":`map-cluster`,children:e.markers.length})},e.id):(0,Q.jsx)(K,{longitude:e.coordinates[0],latitude:e.coordinates[1],anchor:`bottom`,onClick:t=>{t.originalEvent.stopPropagation();let n=e.markers[0];E(n.id),J.handleClick(n.data),r?.(n.data)},children:(0,Q.jsx)(`div`,{className:`text-2xl cursor-pointer hover:scale-110 transition-transform`,children:`📍`})},e.id)),W&&!k&&(0,Q.jsx)(te,{longitude:W.coordinates[0],latitude:W.coordinates[1],anchor:`top`,onClose:()=>E(null),closeOnClick:!1,children:(0,Q.jsxs)(`div`,{className:`p-2 min-w-[150px] sm:min-w-[200px]`,children:[(0,Q.jsx)(`h3`,{className:`font-bold text-sm mb-1`,children:W.title}),W.description&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:W.description}),(0,Q.jsxs)(`div`,{className:`mt-2 text-xs flex gap-2`,children:[a&&(0,Q.jsx)(`button`,{className:`text-blue-500 hover:underline`,onClick:()=>a(W.data),children:`Edit`}),s&&(0,Q.jsx)(`button`,{className:`text-red-500 hover:underline`,onClick:()=>s(W.data),children:`Delete`})]})]})})]}),W&&k&&(0,Q.jsxs)(`div`,{className:`absolute inset-x-0 bottom-0 z-30 bg-background border-t shadow-lg rounded-t-2xl p-4 pb-[max(env(safe-area-inset-bottom),1rem)]`,role:`dialog`,"aria-label":`Location details`,"data-testid":`map-mobile-record-sheet`,children:[(0,Q.jsx)(`div`,{className:`mx-auto mb-2 h-1 w-10 rounded-full bg-muted`,"aria-hidden":`true`}),(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold truncate`,children:W.title}),W.description&&(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground line-clamp-3`,children:W.description})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>E(null),className:`text-muted-foreground hover:text-foreground text-lg leading-none px-2`,"aria-label":`Close details`,"data-testid":`map-mobile-record-close`,children:`×`})]}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs`,children:[a&&(0,Q.jsx)(`button`,{className:`px-3 py-1.5 rounded-md border bg-card hover:bg-accent`,onClick:()=>a(W.data),children:`Edit`}),s&&(0,Q.jsx)(`button`,{className:`px-3 py-1.5 rounded-md border border-destructive/30 text-destructive hover:bg-destructive/10`,onClick:()=>s(W.data),children:`Delete`})]})]}),N&&(0,Q.jsx)(`div`,{className:`absolute top-2 left-14 right-2 z-10 text-xs px-3 py-1.5 rounded-md bg-destructive/10 text-destructive border border-destructive/30`,children:N})]}),J.isOverlay&&(0,Q.jsx)(h,{...J,title:`Location Details`,children:e=>(0,Q.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,Q.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})},pe=t({ObjectMap:()=>fe,ObjectMapRenderer:()=>$}),$=({schema:e,...t})=>{let{dataSource:n}=s()||{};return(0,Q.jsx)(fe,{schema:e,dataSource:n,...t})};console.log(`Registering object-map...`),l.register(`object-map`,$,{namespace:`plugin-map`,label:`Object Map`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`map`,type:`object`,label:`Map Config`,description:`latitudeField, longitudeField, titleField`}]}),l.register(`map`,$,{namespace:`view`,label:`Map View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`map`,type:`object`,label:`Map Config`,description:`latitudeField, longitudeField, titleField`}]});export{pe as t};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,m as r,t as i}from"./vendor-react-DR370ovB.js";import{mt as a}from"./framework-D7UWfRl4.js";import{Mt as o}from"./ui-components-Clv7N77v.js";import{a as s,f as c,i as l,m as u,n as d,p as f,r as p,t as m}from"./vendor-markdown-BXE1apAC.js";var h=t({MarkdownRenderer:()=>y,markdownComponents:()=>b}),g=e(n(),1),_=i(),v=g.lazy(()=>r(()=>Promise.resolve().then(()=>w),void 0,import.meta.url)),y=({schema:e})=>(0,_.jsx)(g.Suspense,{fallback:(0,_.jsx)(o,{className:`w-full h-[200px]`}),children:(0,_.jsx)(v,{content:e.content||``,className:e.className})});a.register(`markdown`,y,{namespace:`plugin-markdown`,label:`Markdown`,category:`plugin`,inputs:[{name:`content`,type:`string`,label:`Markdown Content`,required:!0,inputType:`textarea`},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{content:`# Hello World
|
|
2
|
+
|
|
3
|
+
This is a **markdown** component with *formatting* support.
|
|
4
|
+
|
|
5
|
+
- Item 1
|
|
6
|
+
- Item 2
|
|
7
|
+
- Item 3`}});var b={markdown:y},x=`os-markdown-styles`,S=`
|
|
8
|
+
.os-markdown .md-anchor {
|
|
9
|
+
margin-left: 0.4ch;
|
|
10
|
+
color: var(--muted-foreground);
|
|
11
|
+
text-decoration: none;
|
|
12
|
+
opacity: 0;
|
|
13
|
+
transition: opacity 0.12s ease-in-out;
|
|
14
|
+
}
|
|
15
|
+
.os-markdown :is(h1,h2,h3,h4,h5,h6):hover .md-anchor { opacity: 0.6; }
|
|
16
|
+
.os-markdown .md-anchor:hover { opacity: 1; }
|
|
17
|
+
|
|
18
|
+
/* highlight.js tokens — light */
|
|
19
|
+
.os-markdown .hljs-comment,
|
|
20
|
+
.os-markdown .hljs-quote { color: var(--muted-foreground); font-style: italic; }
|
|
21
|
+
.os-markdown .hljs-keyword,
|
|
22
|
+
.os-markdown .hljs-selector-tag,
|
|
23
|
+
.os-markdown .hljs-literal,
|
|
24
|
+
.os-markdown .hljs-doctag { color: #8250df; }
|
|
25
|
+
.os-markdown .hljs-string,
|
|
26
|
+
.os-markdown .hljs-regexp,
|
|
27
|
+
.os-markdown .hljs-addition { color: #0a7d33; }
|
|
28
|
+
.os-markdown .hljs-number,
|
|
29
|
+
.os-markdown .hljs-symbol,
|
|
30
|
+
.os-markdown .hljs-bullet { color: #0550ae; }
|
|
31
|
+
.os-markdown .hljs-title,
|
|
32
|
+
.os-markdown .hljs-section,
|
|
33
|
+
.os-markdown .hljs-name,
|
|
34
|
+
.os-markdown .hljs-built_in { color: #6639ba; }
|
|
35
|
+
.os-markdown .hljs-attr,
|
|
36
|
+
.os-markdown .hljs-attribute,
|
|
37
|
+
.os-markdown .hljs-variable,
|
|
38
|
+
.os-markdown .hljs-template-variable { color: #953800; }
|
|
39
|
+
.os-markdown .hljs-type,
|
|
40
|
+
.os-markdown .hljs-class .hljs-title { color: #0550ae; }
|
|
41
|
+
.os-markdown .hljs-meta { color: var(--muted-foreground); }
|
|
42
|
+
.os-markdown .hljs-deletion { color: #b35900; }
|
|
43
|
+
.os-markdown .hljs-emphasis { font-style: italic; }
|
|
44
|
+
.os-markdown .hljs-strong { font-weight: 600; }
|
|
45
|
+
|
|
46
|
+
/* highlight.js tokens — dark */
|
|
47
|
+
.dark .os-markdown .hljs-keyword,
|
|
48
|
+
.dark .os-markdown .hljs-selector-tag,
|
|
49
|
+
.dark .os-markdown .hljs-literal,
|
|
50
|
+
.dark .os-markdown .hljs-doctag { color: #d2a8ff; }
|
|
51
|
+
.dark .os-markdown .hljs-string,
|
|
52
|
+
.dark .os-markdown .hljs-regexp,
|
|
53
|
+
.dark .os-markdown .hljs-addition { color: #7ee787; }
|
|
54
|
+
.dark .os-markdown .hljs-number,
|
|
55
|
+
.dark .os-markdown .hljs-symbol,
|
|
56
|
+
.dark .os-markdown .hljs-bullet { color: #79c0ff; }
|
|
57
|
+
.dark .os-markdown .hljs-title,
|
|
58
|
+
.dark .os-markdown .hljs-section,
|
|
59
|
+
.dark .os-markdown .hljs-name,
|
|
60
|
+
.dark .os-markdown .hljs-built_in { color: #d2a8ff; }
|
|
61
|
+
.dark .os-markdown .hljs-attr,
|
|
62
|
+
.dark .os-markdown .hljs-attribute,
|
|
63
|
+
.dark .os-markdown .hljs-variable,
|
|
64
|
+
.dark .os-markdown .hljs-template-variable { color: #ffa657; }
|
|
65
|
+
.dark .os-markdown .hljs-type,
|
|
66
|
+
.dark .os-markdown .hljs-class .hljs-title { color: #79c0ff; }
|
|
67
|
+
.dark .os-markdown .hljs-deletion { color: #ffa198; }
|
|
68
|
+
|
|
69
|
+
/* GitHub-style alert callouts (icon = CSS pseudo-element, no SVG) */
|
|
70
|
+
.os-markdown .markdown-alert {
|
|
71
|
+
margin: 1em 0;
|
|
72
|
+
padding: 0.6em 1em;
|
|
73
|
+
border-left: 0.25em solid var(--border);
|
|
74
|
+
border-radius: 0.375rem;
|
|
75
|
+
background: color-mix(in srgb, var(--muted) 40%, transparent);
|
|
76
|
+
}
|
|
77
|
+
.os-markdown .markdown-alert > :first-child { margin-top: 0; }
|
|
78
|
+
.os-markdown .markdown-alert > :last-child { margin-bottom: 0; }
|
|
79
|
+
.os-markdown .markdown-alert-title {
|
|
80
|
+
display: flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
font-weight: 600;
|
|
83
|
+
line-height: 1;
|
|
84
|
+
text-transform: capitalize;
|
|
85
|
+
}
|
|
86
|
+
.os-markdown .markdown-alert-title::before {
|
|
87
|
+
margin-right: 0.5ch;
|
|
88
|
+
font-weight: 700;
|
|
89
|
+
}
|
|
90
|
+
.os-markdown .markdown-alert-note { border-left-color: #0969da; }
|
|
91
|
+
.os-markdown .markdown-alert-note .markdown-alert-title { color: #0969da; }
|
|
92
|
+
.os-markdown .markdown-alert-note .markdown-alert-title::before { content: "ⓘ"; }
|
|
93
|
+
.os-markdown .markdown-alert-tip { border-left-color: #1a7f37; }
|
|
94
|
+
.os-markdown .markdown-alert-tip .markdown-alert-title { color: #1a7f37; }
|
|
95
|
+
.os-markdown .markdown-alert-tip .markdown-alert-title::before { content: "💡"; }
|
|
96
|
+
.os-markdown .markdown-alert-important { border-left-color: #8250df; }
|
|
97
|
+
.os-markdown .markdown-alert-important .markdown-alert-title { color: #8250df; }
|
|
98
|
+
.os-markdown .markdown-alert-important .markdown-alert-title::before { content: "❖"; }
|
|
99
|
+
.os-markdown .markdown-alert-warning { border-left-color: #9a6700; }
|
|
100
|
+
.os-markdown .markdown-alert-warning .markdown-alert-title { color: #9a6700; }
|
|
101
|
+
.os-markdown .markdown-alert-warning .markdown-alert-title::before { content: "⚠"; }
|
|
102
|
+
.os-markdown .markdown-alert-caution { border-left-color: var(--destructive); }
|
|
103
|
+
.os-markdown .markdown-alert-caution .markdown-alert-title { color: var(--destructive); }
|
|
104
|
+
.os-markdown .markdown-alert-caution .markdown-alert-title::before { content: "⛔"; }
|
|
105
|
+
.dark .os-markdown .markdown-alert-note { border-left-color: #4493f8; }
|
|
106
|
+
.dark .os-markdown .markdown-alert-note .markdown-alert-title { color: #4493f8; }
|
|
107
|
+
.dark .os-markdown .markdown-alert-tip { border-left-color: #3fb950; }
|
|
108
|
+
.dark .os-markdown .markdown-alert-tip .markdown-alert-title { color: #3fb950; }
|
|
109
|
+
.dark .os-markdown .markdown-alert-important { border-left-color: #ab7df8; }
|
|
110
|
+
.dark .os-markdown .markdown-alert-important .markdown-alert-title { color: #ab7df8; }
|
|
111
|
+
.dark .os-markdown .markdown-alert-warning { border-left-color: #d29922; }
|
|
112
|
+
.dark .os-markdown .markdown-alert-warning .markdown-alert-title { color: #d29922; }
|
|
113
|
+
`;function C(){if(typeof document>`u`||document.getElementById(x))return;let e=document.createElement(`style`);e.id=x,e.textContent=S,document.head.appendChild(e)}var w=t({default:()=>A}),T=e=>(e??[]).filter(e=>!(Array.isArray(e)&&e[0]===`className`)),E={...u,clobberPrefix:``,tagNames:[...u.tagNames??[],`span`,`div`],attributes:{...u.attributes,"*":[...u.attributes?.[`*`]??[],`className`],a:[...T(u.attributes?.a),`ariaHidden`,`tabIndex`]}};function D(){let e=e=>typeof e==`string`?e.split(/\s+/).filter(Boolean):Array.isArray(e)?e:[],t=n=>{if(!n||typeof n!=`object`)return;let r=n.properties;if(r&&(typeof r.class==`string`||typeof r.className==`string`)&&(r.className=[...e(r.className),...e(r.class)],delete r.class),Array.isArray(n.children))for(let e of n.children)t(e)};return e=>t(e)}var O=[c,l],k=[p,D,[d,{detect:!0,ignoreMissing:!0}],[m,{behavior:`append`,properties:{className:[`md-anchor`],ariaHidden:!0,tabIndex:-1},content:{type:`text`,value:`#`}}],[f,E]];function A({content:e,className:t}){return C(),(0,_.jsx)(`div`,{"data-slot":`markdown`,className:((...e)=>e.filter(Boolean).join(` `))(`prose prose-sm dark:prose-invert max-w-none`,`prose-headings:font-semibold prose-headings:tracking-tight`,`prose-h1:text-3xl prose-h2:text-2xl prose-h3:text-xl`,`prose-p:leading-relaxed prose-p:text-foreground`,`prose-a:text-primary prose-a:no-underline hover:prose-a:underline`,`prose-code:text-foreground prose-code:bg-muted prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-code:before:content-none prose-code:after:content-none`,`prose-pre:bg-muted prose-pre:text-foreground prose-pre:border`,`prose-blockquote:border-l-primary prose-blockquote:text-muted-foreground`,`prose-strong:text-foreground prose-strong:font-semibold`,`prose-ul:list-disc prose-ol:list-decimal`,`prose-li:text-foreground prose-li:marker:text-muted-foreground`,`prose-table:border prose-th:border prose-th:bg-muted prose-td:border`,`prose-img:rounded-md prose-img:border`,`os-markdown`,t),children:(0,_.jsx)(s,{remarkPlugins:O,rehypePlugins:k,disallowedElements:[`script`,`style`,`iframe`,`object`,`embed`],unwrapDisallowed:!0,children:e})})}export{h as n,y as t};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,t as r}from"./vendor-react-DR370ovB.js";import{B as i,H as a,mt as o,nt as s,rt as c}from"./framework-D7UWfRl4.js";import{$n as l,Jn as u,Mt as d,Pi as f,Qr as p,Rr as m,Xn as h,Yn as g,Zn as _,d as ee,g as te,hr as v,ja as y,qn as b,zi as ne,zo as x}from"./ui-components-Clv7N77v.js";var S=e(n(),1),C=r(),w=({schema:e})=>{let{title:t,description:n,data:r,columns:i}=e;e.chart?.type;let a=!!e.chart;return(0,C.jsxs)(b,{className:`h-full flex flex-col ${e.className||``}`,children:[(0,C.jsxs)(h,{children:[t&&(0,C.jsx)(_,{children:t}),n&&(0,C.jsx)(g,{children:n})]}),(0,C.jsxs)(u,{className:`flex-1 overflow-auto space-y-4`,children:[a&&(()=>{let t=e.chart?.type,n=t?o.get(t):null;return n||=o.get(`chart`),n?(0,C.jsx)(`div`,{className:`min-h-[300px] border rounded-lg p-4 bg-background/50`,children:(0,C.jsx)(n,{schema:{...e.chart,data:e.chart.data||r}})}):(0,C.jsxs)(`div`,{className:`min-h-[100px] border rounded-md p-4 bg-muted/20 text-muted-foreground flex items-center justify-center`,children:[`Unknown component type: `,t||`chart`]})})(),r&&r.length>0&&(0,C.jsx)(`div`,{className:`border rounded-lg`,children:(()=>{let e=o.get(`grid`)||o.get(`table`);return e?(0,C.jsx)(e,{schema:{type:`grid`,rowData:r,columnDefs:i,domLayout:`autoHeight`}}):(0,C.jsx)(`div`,{className:`overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm text-left`,children:[(0,C.jsx)(`thead`,{className:`text-xs uppercase bg-muted`,children:(0,C.jsx)(`tr`,{children:i?.map(e=>(0,C.jsx)(`th`,{className:`px-6 py-3`,children:e.headerName||e.label||e.field},e.field))})}),(0,C.jsx)(`tbody`,{children:r.map((e,t)=>(0,C.jsx)(`tr`,{className:`bg-background border-b`,children:i?.map(t=>(0,C.jsx)(`td`,{className:`px-6 py-4`,children:e[t.field]},t.field))},t))})]})})})()})]})]})};function T(e,t,n){let r=e.fields||[],i=r.map(e=>e.label||e.name),a=t.map(e=>r.map(t=>{let n=e[t.name];return n=M(n),typeof n==`string`&&(n.includes(`,`)||n.includes(`"`)||n.includes(`
|
|
2
|
+
`))?`"${n.replace(/"/g,`""`)}"`:n??``}));F([...n?.includeHeaders===!1?[]:[i.join(`,`)],...a.map(e=>e.join(`,`))].join(`
|
|
3
|
+
`),n?.filename||`${e.title||`report`}.csv`,`text/csv`)}function E(e,t,n){let r={title:e.title,description:e.description,generatedAt:new Date().toISOString(),data:t};F(JSON.stringify(r,null,2),n?.filename||`${e.title||`report`}.json`,`application/json`)}function D(e,t,n){let r=e.fields||[],i=P(n?.orientation),a=N(n?.pageSize);F(`<!DOCTYPE html>
|
|
4
|
+
<html>
|
|
5
|
+
<head>
|
|
6
|
+
<meta charset="utf-8">
|
|
7
|
+
<title>${j(e.title||`Report`)}</title>
|
|
8
|
+
<style>
|
|
9
|
+
@page { size: ${a} ${i}; margin: 20mm; }
|
|
10
|
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #333; }
|
|
11
|
+
h1 { font-size: 24px; margin-bottom: 8px; }
|
|
12
|
+
.description { color: #666; margin-bottom: 24px; }
|
|
13
|
+
.meta { color: #999; font-size: 12px; margin-bottom: 16px; }
|
|
14
|
+
table { width: 100%; border-collapse: collapse; margin-top: 16px; }
|
|
15
|
+
th { background: #f5f5f5; text-align: left; padding: 8px 12px; border: 1px solid #ddd; font-weight: 600; }
|
|
16
|
+
td { padding: 8px 12px; border: 1px solid #ddd; }
|
|
17
|
+
tr:nth-child(even) { background: #fafafa; }
|
|
18
|
+
</style>
|
|
19
|
+
</head>
|
|
20
|
+
<body>
|
|
21
|
+
<h1>${j(e.title||`Report`)}</h1>
|
|
22
|
+
${e.description?`<p class="description">${j(e.description)}</p>`:``}
|
|
23
|
+
<p class="meta">Generated: ${new Date().toLocaleString()}</p>
|
|
24
|
+
<table>
|
|
25
|
+
<thead><tr>${r.map(e=>`<th>${j(e.label||e.name)}</th>`).join(``)}</tr></thead>
|
|
26
|
+
<tbody>${t.map(e=>`<tr>${r.map(t=>`<td>${j(String(e[t.name]??``))}</td>`).join(``)}</tr>`).join(``)}</tbody>
|
|
27
|
+
</table>
|
|
28
|
+
</body>
|
|
29
|
+
</html>`,n?.filename||`${e.title||`report`}.html`,`text/html`)}function O(e,t,n){let r=e.fields||[],i=P(n?.orientation),a=N(n?.pageSize),o=window.open(``,`_blank`);if(!o){D(e,t,{...n,format:`html`,filename:n?.filename?.replace(/\.pdf$/,`.html`)||`${e.title||`report`}.html`});return}o.document.write(`<!DOCTYPE html>
|
|
30
|
+
<html>
|
|
31
|
+
<head>
|
|
32
|
+
<meta charset="utf-8">
|
|
33
|
+
<title>${j(e.title||`Report`)}</title>
|
|
34
|
+
<style>
|
|
35
|
+
@page { size: ${a} ${i}; margin: 20mm; }
|
|
36
|
+
@media print { .no-print { display: none; } }
|
|
37
|
+
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #333; }
|
|
38
|
+
h1 { font-size: 24px; margin-bottom: 8px; }
|
|
39
|
+
.description { color: #666; margin-bottom: 24px; }
|
|
40
|
+
.meta { color: #999; font-size: 12px; margin-bottom: 16px; }
|
|
41
|
+
table { width: 100%; border-collapse: collapse; margin-top: 16px; }
|
|
42
|
+
th { background: #f5f5f5; text-align: left; padding: 8px 12px; border: 1px solid #ddd; font-weight: 600; }
|
|
43
|
+
td { padding: 8px 12px; border: 1px solid #ddd; }
|
|
44
|
+
tr:nth-child(even) { background: #fafafa; }
|
|
45
|
+
</style>
|
|
46
|
+
</head>
|
|
47
|
+
<body>
|
|
48
|
+
<h1>${j(e.title||`Report`)}</h1>
|
|
49
|
+
${e.description?`<p class="description">${j(e.description)}</p>`:``}
|
|
50
|
+
<p class="meta">Generated: ${new Date().toLocaleString()}</p>
|
|
51
|
+
<table>
|
|
52
|
+
<thead><tr>${r.map(e=>`<th>${j(e.label||e.name)}</th>`).join(``)}</tr></thead>
|
|
53
|
+
<tbody>${t.map(e=>`<tr>${r.map(t=>`<td>${j(String(e[t.name]??``))}</td>`).join(``)}</tr>`).join(``)}</tbody>
|
|
54
|
+
</table>
|
|
55
|
+
</body>
|
|
56
|
+
</html>`),o.document.close(),o.onload=()=>{o.print()}}function k(e,t,n){let r=e.fields||[],i=r.map(e=>e.label||e.name),a=t.map(e=>r.map(t=>{let n=e[t.name];return n=M(n),typeof n==`string`&&(n.includes(`,`)||n.includes(`"`)||n.includes(`
|
|
57
|
+
`)||n.includes(` `))?`"${n.replace(/"/g,`""`)}"`:n??``}));F(``+[...n?.includeHeaders===!1?[]:[i.join(` `)],...a.map(e=>e.join(` `))].join(`
|
|
58
|
+
`),n?.filename||`${e.title||`report`}.tsv`,`text/tab-separated-values`)}function A(e,t,n,r){switch(e){case`csv`:T(t,n,r);break;case`json`:E(t,n,r);break;case`html`:D(t,n,r);break;case`pdf`:O(t,n,r);break;case`excel`:k(t,n,r);break;default:console.warn(`Unsupported export format: ${e}`)}}function j(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function M(e){if(typeof e==`string`&&e.length>0){let t=e.charAt(0);if(t===`=`||t===`+`||t===`-`||t===`@`||t===`|`)return`\t${e}`}return e}function N(e){return[`A4`,`A3`,`Letter`,`Legal`].includes(e||``)?e:`A4`}function P(e){return e===`landscape`?`landscape`:`portrait`}function F(e,t,n){let r=new Blob([e],{type:`${n};charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}function I(e,t){if(e==null||e===``)return``;let n=t?.type,r=t?.format;if(n===`date`||r===`date`||re(e))return ie(e);if(n===`number`||typeof e==`number`){let t=typeof e==`number`?e:Number(e);return isNaN(t)?String(e):r===`currency`||r===`currency_cny`?`¥${t.toLocaleString(`en-US`,{minimumFractionDigits:0,maximumFractionDigits:0})}`:r===`currency_usd`?`$${t.toLocaleString(`en-US`,{minimumFractionDigits:0,maximumFractionDigits:0})}`:r===`percent`?`${t.toLocaleString(`en-US`,{minimumFractionDigits:1,maximumFractionDigits:1})}%`:t.toLocaleString(`en-US`)}return String(e)}function re(e){return typeof e==`string`?/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2})?/.test(e):!1}function ie(e){try{let t=new Date(e);return isNaN(t.getTime())?String(e):`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}catch{return String(e)}}function ae(e,t){if(!t||t.length===0||!e||e.length===0)return null;let n=t[0],r=n.field,i=new Map;for(let t of e){let e=String(t[r]??`(empty)`);i.has(e)||i.set(e,[]),i.get(e).push(t)}let a=[];for(let[e,t]of i)a.push({key:e,label:`${n.label||r}: ${e}`,rows:t});let o=n.sort===`desc`?-1:1;return a.sort((e,t)=>e.key.localeCompare(t.key)*o),a}var L=({schema:e,onRefresh:t})=>{let{report:n,data:r,showToolbar:a=!0,allowExport:s=!0,allowPrint:c=!0,loading:p=!1}=e,m=e=>{if(!n){console.warn(`ReportViewer: Cannot export, no report defined`);return}A(e,n,r||[],n.exportConfigs?.[e])},y=()=>{window.print()},w=()=>{t?.()},T=(e,t)=>{if(!r)return 0;let n=r.map(t=>Number(t[e])||0);switch(t){case`count`:return r.length;case`sum`:return n.reduce((e,t)=>e+t,0);case`avg`:return n.length>0?(n.reduce((e,t)=>e+t,0)/n.length).toFixed(2):0;case`min`:return n.length>0?Math.min(...n):0;case`max`:return n.length>0?Math.max(...n):0;default:return``}},E=(e,t)=>{let r=n?.conditionalFormatting;if(!(!r||!Array.isArray(r)))for(let n of r){if(n.field!==e)continue;let r=String(t??``),i=String(n.value??``),a=!1;switch(n.operator){case`equals`:a=r===i;break;case`not_equals`:a=r!==i;break;case`contains`:a=r.includes(i);break;case`greater_than`:a=Number(t)>Number(n.value);break;case`less_than`:a=Number(t)<Number(n.value);break}if(a){let e={};return n.backgroundColor&&(e.backgroundColor=n.backgroundColor),n.textColor&&(e.color=n.textColor),e}}},D=(e,t)=>{if(e==null||e===``)return``;if(t.renderAs===`badge`&&(!t.type||t.type===`string`||t.type===`text`))return(0,C.jsx)(l,{className:t.colorMap?.[String(e)]||``,children:String(e)});if(t.aggregation)return I(e,t);if(t.type){let n={...t};return t.colorMap&&!n.options&&(n.options=Object.entries(t.colorMap).map(([e,t])=>({value:e,label:e,color:t}))),(0,C.jsx)(ee(te(n)),{value:e,field:n})}return I(e,t)};return n?(0,C.jsxs)(`div`,{className:`space-y-4`,children:[a&&(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-2 p-4 bg-card rounded-lg border`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h2`,{className:`text-lg font-semibold`,children:n.title}),n.description&&(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n.refreshInterval&&(0,C.jsxs)(v,{variant:`outline`,size:`sm`,onClick:w,children:[(0,C.jsx)(f,{className:`h-4 w-4 mr-2`}),`Refresh`]}),c&&(0,C.jsxs)(v,{variant:`outline`,size:`sm`,onClick:y,children:[(0,C.jsx)(ne,{className:`h-4 w-4 mr-2`}),`Print`]}),s&&n.showExportButtons&&(0,C.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,C.jsxs)(v,{variant:`outline`,size:`sm`,onClick:()=>m(`pdf`),children:[(0,C.jsx)(x,{className:`h-4 w-4 mr-2`}),`PDF`]}),(0,C.jsxs)(v,{variant:`outline`,size:`sm`,onClick:()=>m(`excel`),children:[(0,C.jsx)(x,{className:`h-4 w-4 mr-2`}),`Excel`]}),(0,C.jsxs)(v,{variant:`outline`,size:`sm`,onClick:()=>m(`csv`),children:[(0,C.jsx)(x,{className:`h-4 w-4 mr-2`}),`CSV`]})]})]})]}),(0,C.jsxs)(b,{children:[(0,C.jsxs)(h,{children:[!a&&n.title&&(0,C.jsx)(_,{children:n.title}),!a&&n.description&&(0,C.jsx)(g,{children:n.description})]}),(0,C.jsxs)(u,{className:`space-y-6`,children:[p&&(0,C.jsxs)(`div`,{className:`space-y-6`,children:[(0,C.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[1,2,3].map(e=>(0,C.jsx)(b,{children:(0,C.jsxs)(u,{className:`p-4 space-y-2`,children:[(0,C.jsx)(d,{className:`h-4 w-20`}),(0,C.jsx)(d,{className:`h-8 w-28`})]})},e))}),(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsx)(d,{className:`h-10 w-full`}),[1,2,3,4,5].map(e=>(0,C.jsx)(d,{className:`h-8 w-full`},e))]})]}),!p&&n.sections?.map((e,t)=>e.visible===!1?null:(0,C.jsxs)(`div`,{className:`space-y-2`,children:[e.title&&e.type!==`header`&&(0,C.jsx)(`h3`,{className:`text-lg font-semibold border-b pb-2`,children:e.title}),e.type===`header`&&e.title&&(0,C.jsx)(`div`,{className:`text-2xl font-bold py-4`,children:e.title}),e.type===`summary`&&(0,C.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:n.fields?.filter(e=>e.showInSummary).map((e,t)=>(0,C.jsx)(b,{children:(0,C.jsxs)(u,{className:`p-4`,children:[(0,C.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:e.label||e.name}),(0,C.jsx)(`div`,{className:`text-2xl font-bold`,children:I(T(e.name,e.aggregation),e)})]})},t))}),e.type===`chart`&&e.chart&&(0,C.jsx)(`div`,{className:`min-h-[300px]`,children:(()=>{let t=e.chart.type,n=!!e.chart.chartType;!t&&n&&(t=`chart`),t&&o.get(t)||(t=`chart`);let a=t===`chart`?{xAxisKey:e.chart.xAxisKey||e.chart.xAxisField||`name`,series:e.chart.series||(e.chart.yAxisFields?e.chart.yAxisFields.map(e=>({dataKey:e})):[]),chartType:e.chart.chartType||`bar`}:{};return(0,C.jsx)(i,{schema:{...e.chart,type:t,...a,data:r||e.chart.data,className:e.chart.className||`w-full h-[350px]`}})})()}),e.type===`table`&&(0,C.jsx)(`div`,{className:`border rounded-lg overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm min-w-[600px]`,children:[(0,C.jsx)(`thead`,{className:`bg-muted`,children:(0,C.jsx)(`tr`,{children:e.columns?.map((e,t)=>(0,C.jsx)(`th`,{className:`px-4 py-2 font-medium ${e.type===`number`?`text-right`:`text-left`}`,children:e.label||e.name},t))})}),(0,C.jsx)(`tbody`,{children:(()=>{let t=ae(r||[],n.groupBy||[]);return t?t.map(t=>(0,C.jsxs)(S.Fragment,{children:[(0,C.jsx)(`tr`,{className:`bg-muted/60`,children:(0,C.jsxs)(`td`,{colSpan:e.columns?.length||1,className:`px-4 py-2 font-semibold text-sm`,children:[t.label,` (`,t.rows.length,`)`]})}),t.rows.map((t,n)=>(0,C.jsx)(`tr`,{className:`border-t hover:bg-muted/50 even:bg-muted/20`,children:e.columns?.map((e,n)=>(0,C.jsx)(`td`,{className:`px-4 py-2 ${e.type===`number`?`text-right tabular-nums`:``}`,style:E(e.name,t[e.name]),children:D(t[e.name],e)},n))},n))]},t.key)):r?.map((t,n)=>(0,C.jsx)(`tr`,{className:`border-t hover:bg-muted/50 even:bg-muted/20`,children:e.columns?.map((e,n)=>(0,C.jsx)(`td`,{className:`px-4 py-2 ${e.type===`number`?`text-right tabular-nums`:``}`,style:E(e.name,t[e.name]),children:D(t[e.name],e)},n))},n))})()})]})}),e.type===`text`&&e.text&&(0,C.jsx)(`div`,{className:`prose max-w-none`,children:(0,C.jsx)(`p`,{children:e.text})}),e.type===`page-break`&&(0,C.jsx)(`div`,{className:`border-t-2 border-dashed my-8 print:page-break-after-always`}),e.content&&(0,C.jsx)(i,{schema:e.content})]},t)),!n.sections&&r&&r.length>0&&(0,C.jsx)(`div`,{className:`border rounded-lg overflow-x-auto`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm min-w-[600px]`,children:[(0,C.jsx)(`thead`,{className:`bg-muted`,children:(0,C.jsx)(`tr`,{children:n.fields?.map((e,t)=>(0,C.jsx)(`th`,{className:`px-4 py-2 font-medium ${e.type===`number`?`text-right`:`text-left`}`,children:e.label||e.name},t))})}),(0,C.jsx)(`tbody`,{children:r.map((e,t)=>(0,C.jsx)(`tr`,{className:`border-t hover:bg-muted/50 even:bg-muted/20`,children:n.fields?.map((t,n)=>(0,C.jsx)(`td`,{className:`px-4 py-2 ${t.type===`number`?`text-right tabular-nums`:``}`,style:E(t.name,e[t.name]),children:D(e[t.name],t)},n))},t))})]})})]})]})]}):(0,C.jsx)(b,{children:(0,C.jsx)(u,{className:`p-8 text-center text-muted-foreground`,children:`No report to display`})})};function R(e,t){let n=e&&Object.keys(e).length>0,r=t&&Object.keys(t).length>0;if(n&&r)return{$and:[e,t]};if(n)return e;if(r)return t}function z(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.dataset==`string`&&t.dataset.length>0?!0:t.type===`joined`&&Array.isArray(t.blocks)&&t.blocks.some(e=>typeof e?.dataset==`string`)}function B(e,t){return e?typeof e==`string`?e:typeof e==`object`&&typeof e.default==`string`?e.default:t:t}function V(e){return e==null?`—`:typeof e==`number`?Number.isInteger(e)?String(e):e.toLocaleString(void 0,{maximumFractionDigits:2}):String(e)}function H(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&!!e):[]}function U(e,t,n,r,i,a){let[o,s]=S.useState({status:`idle`,rows:[]}),c=JSON.stringify(r??null),l=JSON.stringify(a??null),u=`${e}|${t.join(`,`)}|${n.join(`,`)}|${c}|${l}`;return S.useEffect(()=>{let o=i;if(!o||typeof o.queryDataset!=`function`){s({status:`error`,rows:[],error:`This data source does not support dataset queries.`});return}if(!e||n.length===0){s({status:`idle`,rows:[]});return}let c=!1;return s({status:`loading`,rows:[]}),o.queryDataset(e,{dimensions:t,measures:n,...r&&Object.keys(r).length>0?{runtimeFilter:r}:{},...a?{totals:{groupings:a}}:{}}).then(e=>{c||s({status:`ok`,rows:Array.isArray(e?.rows)?e.rows:[],totals:Array.isArray(e?.totals)?e.totals:void 0})}).catch(e=>{c||s({status:`error`,rows:[],error:String(e?.message??e)})}),()=>{c=!0}},[u]),o}function W({dataset:e}){return(0,C.jsxs)(`div`,{className:`flex items-center justify-center rounded-md border border-dashed bg-muted/20 p-4 text-xs text-muted-foreground`,children:[`This report binds the “`,e,`” dataset — choose at least one measure (values) to render.`]})}function G({status:e,error:t}){return e===`error`?(0,C.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive`,children:[(0,C.jsx)(m,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),(0,C.jsx)(`span`,{className:`break-words`,children:t})]}):(0,C.jsxs)(`div`,{className:`flex items-center gap-2 p-4 text-xs text-muted-foreground`,children:[(0,C.jsx)(y,{className:`h-4 w-4 animate-spin`}),` Running report…`]})}function K(){return(0,C.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-md border border-dashed bg-muted/20 p-6 text-xs text-muted-foreground`,children:[(0,C.jsx)(p,{className:`h-6 w-6`}),` The dataset returned no rows for this report’s scope.`]})}var q=`cursor-pointer hover:bg-accent/40`;function J({dataset:e,rows:t,values:n,runtimeFilter:r,dataSource:i,onDrill:a}){let o=U(e,t,n,r,i);if(n.length===0)return(0,C.jsx)(W,{dataset:e});if(o.status===`loading`||o.status===`idle`)return(0,C.jsx)(G,{status:o.status});if(o.status===`error`)return(0,C.jsx)(G,{status:`error`,error:o.error});if(o.rows.length===0)return(0,C.jsx)(K,{});let s=!!a&&t.length>0,c=n=>{let i={};for(let e of t)i[e]=n[e];a({dataset:e,groupKey:i,runtimeFilter:r})},l=[...t,...n];return(0,C.jsx)(`div`,{className:`overflow-auto max-h-[70vh] rounded-md border`,children:(0,C.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,C.jsx)(`thead`,{className:`bg-muted/40`,children:(0,C.jsx)(`tr`,{children:l.map(e=>(0,C.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium whitespace-nowrap`,children:e},e))})}),(0,C.jsx)(`tbody`,{children:o.rows.map((e,t)=>(0,C.jsx)(`tr`,{className:`border-t${s?` ${q}`:``}`,"data-testid":s?`dataset-drill-row`:void 0,onClick:s?()=>c(e):void 0,children:l.map(t=>(0,C.jsx)(`td`,{className:`px-2 py-1 tabular-nums whitespace-nowrap`,children:V(e[t])},t))},t))})]})})}function Y(e,t){return e.map(e=>String(t[e]??`∅`)).join(``)}function X(e,t){return e.map(e=>V(t[e])).join(` / `)}function Z({dataset:e,rows:t,columnsAcross:n,values:r,runtimeFilter:i,dataSource:a,onDrill:o}){let s=U(e,[...t,...n],r,i,a,[t,n,[]]),c=S.useMemo(()=>{if(s.status!==`ok`)return null;let e=[],r=[],i=new Set,a=new Set,o=new Map;for(let c of s.rows){let s=Y(t,c),l=Y(n,c);if(!i.has(s)){i.add(s);let n={};for(let e of t)n[e]=c[e];e.push({id:s,label:X(t,c),key:n})}if(!a.has(l)){a.add(l);let e={};for(let t of n)e[t]=c[t];r.push({id:l,label:X(n,c),key:e})}o.set(`${s}${l}`,c)}return{rowHeaders:e,colHeaders:r,cells:o}},[s,t,n]);if(r.length===0)return(0,C.jsx)(W,{dataset:e});if(s.status===`loading`||s.status===`idle`)return(0,C.jsx)(G,{status:s.status});if(s.status===`error`)return(0,C.jsx)(G,{status:`error`,error:s.error});if(!c||c.rowHeaders.length===0)return(0,C.jsx)(K,{});let l=!!o,u=(t,n)=>{o({dataset:e,groupKey:{...t,...n},runtimeFilter:i})},d=c.colHeaders.flatMap(e=>r.map(t=>({col:e,measure:t,header:r.length===1?e.label:`${e.label} · ${t}`}))),f=e=>s.totals?.find(t=>Array.isArray(t.dimensions)&&t.dimensions.join(`,`)===e.join(`,`))?.rows,p=new Map;for(let e of f(t)??[])p.set(Y(t,e),e);let m=new Map;for(let e of f(n)??[])m.set(Y(n,e),e);let h=f([])?.[0],g=p.size>0,_=m.size>0;return(0,C.jsx)(`div`,{className:`overflow-auto max-h-[70vh] rounded-md border`,"data-testid":`dataset-matrix`,children:(0,C.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,C.jsx)(`thead`,{className:`bg-muted/40`,children:(0,C.jsxs)(`tr`,{children:[t.map(e=>(0,C.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium whitespace-nowrap`,children:e},e)),d.map(e=>(0,C.jsx)(`th`,{className:`px-2 py-1.5 text-right font-medium whitespace-nowrap`,children:e.header},`${e.col.id}-${e.measure}`)),g&&r.map(e=>(0,C.jsx)(`th`,{className:`px-2 py-1.5 text-right font-medium whitespace-nowrap`,"data-testid":`matrix-total-col-header`,children:r.length===1?`Total`:`Total · ${e}`},`total-${e}`))]})}),(0,C.jsxs)(`tbody`,{children:[c.rowHeaders.map(e=>(0,C.jsxs)(`tr`,{className:`border-t`,children:[t.map(t=>(0,C.jsx)(`td`,{className:`px-2 py-1 whitespace-nowrap font-medium`,children:V(e.key[t])},t)),d.map(t=>{let n=c.cells.get(`${e.id}${t.col.id}`),r=n?.[t.measure],i=l&&n!=null;return(0,C.jsx)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap${i?` ${q}`:``}`,"data-testid":i?`dataset-drill-cell`:void 0,onClick:i?()=>u(e.key,t.col.key):void 0,children:V(r)},`${t.col.id}-${t.measure}`)}),g&&r.map(t=>(0,C.jsx)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap font-medium`,"data-testid":`matrix-row-total`,children:V(p.get(e.id)?.[t])},`total-${t}`))]},e.id)),_&&(0,C.jsxs)(`tr`,{className:`border-t bg-muted/30 font-medium`,"data-testid":`matrix-total-row`,children:[t.length>0&&(0,C.jsx)(`td`,{colSpan:t.length,className:`px-2 py-1 whitespace-nowrap`,children:`Total`}),d.map(e=>(0,C.jsx)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap`,children:V(m.get(e.col.id)?.[e.measure])},`${e.col.id}-${e.measure}`)),g&&r.map(e=>(0,C.jsx)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap`,"data-testid":`matrix-grand-total`,children:V(h?.[e])},`grand-${e}`))]})]})]})})}var Q=({report:e,dataSource:t,runtimeFilter:n,onDrill:r,className:i})=>{let a=R(e.runtimeFilter??e.filter,n),o=e.drilldown===!1?void 0:r;if(e.type===`joined`&&Array.isArray(e.blocks))return(0,C.jsx)(`div`,{className:i,"data-testid":`dataset-joined-report`,"data-report-name":e.name,style:{display:`flex`,flexDirection:`column`,gap:24},children:e.blocks.map((e,n)=>{let r=R(a,e.runtimeFilter??e.filter),i=H(e.columns),s=e.type===`matrix`&&i.length>0?(0,C.jsx)(Z,{dataset:String(e.dataset??``),rows:H(e.rows),columnsAcross:i,values:H(e.values),runtimeFilter:r,dataSource:t,onDrill:o}):(0,C.jsx)(J,{dataset:String(e.dataset??``),rows:H(e.rows),values:H(e.values),runtimeFilter:r,dataSource:t,onDrill:o});return(0,C.jsxs)(`section`,{"data-testid":`dataset-report-block`,"data-block-id":e.name??`block-${n}`,className:`flex flex-col gap-2 rounded-lg border bg-card p-4`,children:[(0,C.jsxs)(`header`,{className:`flex flex-col gap-0.5`,children:[(0,C.jsx)(`h3`,{className:`text-sm font-semibold`,children:B(e.label,e.name??`Block ${n+1}`)}),e.description?(0,C.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:B(e.description,``)}):null]}),s]},e.name??`block-${n}`)})});let s=H(e.columns);return e.type===`matrix`&&s.length>0?(0,C.jsx)(`div`,{className:i,"data-testid":`dataset-report`,"data-report-name":e.name,children:(0,C.jsx)(Z,{dataset:String(e.dataset??``),rows:H(e.rows),columnsAcross:s,values:H(e.values),runtimeFilter:a,dataSource:t,onDrill:o})}):(0,C.jsx)(`div`,{className:i,"data-testid":`dataset-report`,"data-report-name":e.name,children:(0,C.jsx)(J,{dataset:String(e.dataset??``),rows:H(e.rows),values:H(e.values),runtimeFilter:a,dataSource:t,onDrill:o})})},$=e=>{let{dataSource:t,rows:n,runtimeFilter:r,onDrill:i,className:o}=e,l=S.useContext(a),u=t??l?.dataSource,d=e.schema;return d&&typeof d==`object`&&d.type===`spec-report`&&d.report&&typeof d.report==`object`&&(d=d.report),z(d)?(0,C.jsx)(Q,{report:d,dataSource:u,runtimeFilter:r,onDrill:i,className:o}):s(d)?(0,C.jsx)(`div`,{className:o,"data-testid":`report-presentation-bridge`,children:(0,C.jsx)(L,{schema:{type:`report-viewer`,report:c(d),data:n??[],showToolbar:!1}})}):(0,C.jsx)(w,{schema:d})};async function oe(e,t){let{dataSource:n,resource:r,queryParams:i,format:a,exportConfig:o}=t,s=a||e.defaultExportFormat||`pdf`;try{let t=(await n.find(r,i)).data||[];return A(s,e,t,{format:s,...e.exportConfigs?.[s],...o}),{success:!0,recordCount:t.length,format:s}}catch(e){return{success:!1,recordCount:0,format:s,error:e.message}}}function se(e,t,n={}){let{columns:r,filename:i,includeAggregationRow:a=!1}=n,o=r||(e.fields||[]).map(le),s=o.map(e=>e.header),c=t.map((e,t)=>o.map(n=>{if(n.formula)return n.formula.replace(/\{ROW\}/g,String(t+2));let r=e[n.name];return ue(r,n.numberFormat)}));if(a&&t.length>0){let n=o.map((n,r)=>{let i=(e.fields||[]).find(e=>e.name===n.name);if(i?.aggregation){let e=fe(r),n=t.length+1;switch(i.aggregation){case`sum`:return`=SUM(${e}2:${e}${n})`;case`avg`:return`=AVERAGE(${e}2:${e}${n})`;case`count`:return`=COUNTA(${e}2:${e}${n})`;case`min`:return`=MIN(${e}2:${e}${n})`;case`max`:return`=MAX(${e}2:${e}${n})`;default:return``}}return``});c.push(n)}me(``+[s.join(` `),...c.map(e=>e.join(` `))].join(`
|
|
59
|
+
`),i||`${e.title||`report`}.tsv`,`text/tab-separated-values`)}function ce(e,t,n,r){return async()=>{let i=e.schedule;if(!i?.enabled)return[];let a=i.formats||[e.defaultExportFormat||`pdf`],o=[];for(let r of a){let i=await oe(e,{dataSource:t,resource:n,format:r});o.push(i)}return r(e,i),o}}function le(e){return{name:e.name,header:e.label||e.name}}function ue(e,t){return e==null?``:typeof e==`number`&&t?e.toLocaleString(`en-US`,de(t)):pe(String(e))}function de(e){if(e.includes(`%`))return{style:`percent`,minimumFractionDigits:0};let t=(e.match(/0/g)||[]).length;return{minimumFractionDigits:Math.max(0,t-1),maximumFractionDigits:Math.max(0,t-1)}}function fe(e){let t=``,n=e;for(;n>=0;)t=String.fromCharCode(n%26+65)+t,n=Math.floor(n/26)-1;return t}function pe(e){if(e.length>0){let t=e.charAt(0);if(t===`=`||t===`+`||t===`-`||t===`@`||t===`|`)return`'${e}`}return e}function me(e,t,n){let r=new Blob([e],{type:`${n};charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}var he=t({DatasetReportRenderer:()=>Q,LegacyReportRenderer:()=>w,ReportRenderer:()=>$,ReportViewer:()=>L,createScheduleTrigger:()=>ce,exportAsCSV:()=>T,exportAsExcel:()=>k,exportAsHTML:()=>D,exportAsJSON:()=>E,exportAsPDF:()=>O,exportExcelWithFormulas:()=>se,exportReport:()=>A,exportWithLiveData:()=>oe,formatValue:()=>I,isDatasetReport:()=>z,mergeFilters:()=>R});o.register(`report`,$,{namespace:`report`,label:`Report`,category:`Report`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`description`,type:`string`,label:`Description`},{name:`chart`,type:`code`,label:`Chart Configuration`}]}),o.register(`spec-report`,$,{namespace:`report`,label:`Spec Report`,category:`Report`,inputs:[{name:`dataset`,type:`string`,label:`Dataset`},{name:`type`,type:`string`,label:`Report Type`}]}),o.register(`report-viewer`,L,{namespace:`report`,label:`Report Viewer`,category:`Report`,inputs:[{name:`report`,type:`code`,label:`Report Definition`},{name:`showToolbar`,type:`boolean`,label:`Show Toolbar`}]});export{he as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,t as r}from"./vendor-react-DR370ovB.js";import{F as i,G as a,W as o,lt as s,mt as c,r as l,ut as u}from"./framework-D7UWfRl4.js";import{A as d,N as f,y as p}from"./vendor-objectstack-RB3xvhcR.js";import{I as m,dc as h,lc as g,uc as _}from"./ui-components-Clv7N77v.js";import{i as v}from"./vendor-ui-utils-rQOI1gAo.js";import{a as y}from"./plugin-grid-D9HjQh3d.js";var b=e(n(),1),x=r(),S=10080*60*1e3;function C(e){let t=e.flatMap(e=>(e.items||[]).flatMap(e=>[e.startDate,e.endDate])),n=Math.min(...t.map(e=>new Date(e).getTime())),r=Math.max(...t.map(e=>new Date(e).getTime()));return{minDate:new Date(n).toISOString().split(`T`)[0],maxDate:new Date(r).toISOString().split(`T`)[0]}}function w(e,t,n,r){let i=new Date(e).getTime(),a=new Date(t).getTime(),o=new Date(n).getTime(),s=new Date(r).getTime()-o,c=i-o,l=a-i;return{start:c/s*100,width:l/s*100}}function T(e,t){let n=new Date(e);return t===`short`?n.toLocaleDateString():t===`long`?n.toLocaleDateString(`en-US`,{year:`numeric`,month:`long`,day:`numeric`}):n.toISOString().split(`T`)[0]}function E({label:e,color:t}){let n=t?{backgroundColor:`${t}22`,color:t,borderColor:`${t}55`}:void 0;return(0,x.jsx)(`span`,{className:g(`inline-flex items-center rounded-full border px-2 py-0.5 text-xs font-medium`,!t&&`bg-muted text-muted-foreground border-transparent`),style:n,children:e})}function D(e){let t=[];for(let n of e){let e=n.group==null?``:String(n.group),r=t[t.length-1];r&&r.key===e?r.items.push(n):t.push({key:e,items:[n]})}return t}var O=({schema:e,className:t,...n})=>{let{variant:r=`vertical`,items:i=[],dateFormat:a=`short`,onItemClick:o}=e;if(r===`vertical`){let e=D(i),r=e.some(e=>e.key!==``),s=(e,t)=>{let n=e.color?{backgroundColor:`${e.color}33`,borderColor:e.color}:void 0,r=e.time?T(e.time,a):e.startDate?T(e.startDate,a):``,i=e.endDate&&e.endDate!==e.startDate?T(e.endDate,a):``,s=Array.isArray(e.meta)?e.meta:[];return(0,x.jsxs)(I,{density:`compact`,className:g(e.className,o&&`cursor-pointer`),onClick:()=>o?.(e),children:[(0,x.jsx)(R,{variant:e.color?`default`:e.variant||`default`,style:n,children:e.icon&&(0,x.jsx)(`span`,{className:`text-xs`,children:e.icon})}),(0,x.jsxs)(z,{children:[(r||i)&&(0,x.jsxs)(V,{dateTime:e.time||e.startDate,className:`!mb-1 text-xs`,children:[r,i&&(0,x.jsxs)(`span`,{className:`text-muted-foreground/70`,children:[` → `,i]})]}),e.title&&(0,x.jsx)(B,{className:`text-sm sm:text-base mb-1`,children:e.title}),s.length>0&&(0,x.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1 mb-1`,children:s.map(e=>(0,x.jsx)(E,{label:e.label,color:e.color},e.key))}),e.description&&(0,x.jsx)(H,{className:`text-sm text-muted-foreground line-clamp-2 sm:line-clamp-none`,children:e.description}),e.content&&_(e.content)]})]},t)};return r?(0,x.jsx)(`div`,{className:g(`px-4 sm:px-6 py-2`,t),...n,children:e.map((e,t)=>(0,x.jsxs)(`section`,{className:`mb-4`,children:[(0,x.jsxs)(`header`,{className:`sticky top-0 z-10 -mx-4 sm:-mx-6 px-4 sm:px-6 py-1.5 backdrop-blur bg-background/90 text-xs font-semibold uppercase tracking-wide text-muted-foreground border-b`,children:[(0,x.jsx)(`span`,{children:e.key}),(0,x.jsx)(`span`,{className:`ml-2 text-muted-foreground/60 font-normal normal-case`,children:e.items.length})]}),(0,x.jsx)(P,{className:`mt-3`,children:e.items.map((e,n)=>s(e,`${t}-${n}`))})]},`${e.key}-${t}`))}):(0,x.jsx)(P,{className:t,...n,children:i.map((e,t)=>s(e,t))})}if(r===`horizontal`)return(0,x.jsx)(U,{className:g(`overflow-x-auto [-webkit-overflow-scrolling:touch]`,t),...n,children:i.map((e,t)=>(0,x.jsxs)(W,{className:g(e.className,o&&`cursor-pointer`),onClick:()=>o?.(e),children:[(0,x.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,x.jsx)(R,{variant:e.variant||`default`,children:e.icon&&(0,x.jsx)(`span`,{className:`text-xs`,children:e.icon})}),(0,x.jsxs)(`div`,{className:`mt-4 text-center`,children:[e.time&&(0,x.jsx)(V,{dateTime:e.time,children:T(e.time,a)}),e.title&&(0,x.jsx)(B,{children:e.title}),e.description&&(0,x.jsx)(H,{className:`text-center line-clamp-2 sm:line-clamp-none`,children:e.description}),e.content&&_(e.content)]})]}),t<i.length-1&&(0,x.jsx)(`div`,{className:`absolute left-full w-16 border-t-2 border-gray-200 top-3`})]},t))});if(r===`gantt`){let r=C(i),s=e.minDate||r.minDate,c=e.maxDate||r.maxDate,l=e.timeScale||`month`,u=(()=>{let e=[],t=new Date(s),n=new Date(c);if(l===`month`){let r=new Date(t);for(;r<=n;)e.push(r.toLocaleDateString(`en-US`,{month:`short`,year:`numeric`})),r.setMonth(r.getMonth()+1)}else if(l===`week`){let r=new Date(t);for(;r<=n;)e.push(`Week ${Math.ceil((r.getTime()-t.getTime())/S)+1}`),r.setDate(r.getDate()+7)}else if(l===`day`){let r=new Date(t);for(;r<=n;)e.push(r.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})),r.setDate(r.getDate()+1)}return e})();return(0,x.jsxs)(G,{className:g(`overflow-x-auto [-webkit-overflow-scrolling:touch]`,t),...n,children:[(0,x.jsxs)(K,{children:[(0,x.jsx)(q,{className:`flex items-center px-2 sm:px-4 py-2 sm:py-3`,children:(0,x.jsx)(`span`,{className:`font-semibold text-xs sm:text-sm`,children:e.rowLabel||`Items`})}),(0,x.jsx)(J,{children:(0,x.jsx)(`div`,{className:`flex h-full`,children:u.map((e,t)=>(0,x.jsx)(`div`,{className:`flex-1 px-1 sm:px-2 py-2 sm:py-3 border-r text-xs font-medium text-center`,children:e},t))})})]}),(0,x.jsx)(`div`,{children:(0,x.jsxs)(`div`,{className:`flex`,children:[(0,x.jsx)(q,{children:i.map((e,t)=>(0,x.jsx)(Y,{children:(0,x.jsx)(X,{title:e.label,className:`truncate`,children:e.label})},t))}),(0,x.jsx)(J,{className:`relative`,children:i.map((e,t)=>(0,x.jsx)(Y,{className:`relative`,children:(e.items||[]).map((n,r)=>{let i=w(n.startDate,n.endDate,s,c);return(0,x.jsx)(Z,{start:i.start,width:i.width,variant:n.variant||`default`,onClick:()=>o?.(n,e,t,r),title:`${n.title||``}\n${T(n.startDate,a)} - ${T(n.endDate,a)}`,children:(0,x.jsx)(Q,{children:n.title})},r)})},t))})]})})]})}return null};c.register(`timeline`,O,{namespace:`plugin-timeline`,label:`Timeline`,category:`data-display`,inputs:[{name:`variant`,type:`enum`,enum:[`vertical`,`horizontal`,`gantt`],label:`Timeline Variant`,defaultValue:`vertical`},{name:`items`,type:`array`,label:`Timeline Items`,description:`For vertical/horizontal: Array of { time, title, description, variant, icon, content }. For gantt: Array of { label, items: [{ title, startDate, endDate, variant }] }`},{name:`dateFormat`,type:`enum`,enum:[`short`,`long`,`iso`],label:`Date Format`,defaultValue:`short`},{name:`timeScale`,type:`enum`,enum:[`day`,`week`,`month`],label:`Time Scale (Gantt only)`,defaultValue:`month`},{name:`rowLabel`,type:`string`,label:`Row Label (Gantt only)`,defaultValue:`Items`},{name:`minDate`,type:`string`,label:`Min Date (Gantt only)`,description:`Override auto-calculated min date (YYYY-MM-DD)`},{name:`maxDate`,type:`string`,label:`Max Date (Gantt only)`,description:`Override auto-calculated max date (YYYY-MM-DD)`},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{variant:`vertical`,dateFormat:`short`,items:[{time:`2024-01-15`,title:`Project Started`,description:`Kickoff meeting and initial planning`,variant:`success`,icon:`🚀`},{time:`2024-02-01`,title:`First Milestone`,description:`Completed initial design phase`,variant:`info`,icon:`🎨`},{time:`2024-03-15`,title:`Beta Release`,description:`Released beta version to testers`,variant:`warning`,icon:`⚡`},{time:`2024-04-01`,title:`Launch`,description:`Official product launch`,variant:`success`,icon:`🎉`}]},examples:{vertical:{variant:`vertical`,dateFormat:`long`,items:[{time:`2024-01-15`,title:`Project Started`,description:`Kickoff meeting and initial planning`,variant:`success`},{time:`2024-02-01`,title:`First Milestone`,description:`Completed initial design phase`,variant:`info`}]},horizontal:{variant:`horizontal`,dateFormat:`short`,items:[{time:`2024-01-01`,title:`Q1`,description:`First quarter`,variant:`default`},{time:`2024-04-01`,title:`Q2`,description:`Second quarter`,variant:`info`},{time:`2024-07-01`,title:`Q3`,description:`Third quarter`,variant:`warning`},{time:`2024-10-01`,title:`Q4`,description:`Fourth quarter`,variant:`success`}]},gantt:{variant:`gantt`,dateFormat:`short`,timeScale:`month`,rowLabel:`Projects`,items:[{label:`Backend Development`,items:[{title:`API Design`,startDate:`2024-01-01`,endDate:`2024-01-31`,variant:`success`},{title:`Implementation`,startDate:`2024-02-01`,endDate:`2024-03-31`,variant:`info`}]},{label:`Frontend Development`,items:[{title:`UI Design`,startDate:`2024-01-15`,endDate:`2024-02-15`,variant:`warning`},{title:`Component Dev`,startDate:`2024-02-15`,endDate:`2024-04-15`,variant:`default`}]},{label:`Testing`,items:[{title:`QA Phase`,startDate:`2024-03-01`,endDate:`2024-04-30`,variant:`danger`}]}]}}});var k={"timeline.bucket.overdue":`Overdue`,"timeline.bucket.today":`Today`,"timeline.bucket.tomorrow":`Tomorrow`,"timeline.bucket.thisWeek":`This week`,"timeline.bucket.nextWeek":`Next week`,"timeline.bucket.later":`Later`,"timeline.bucket.noDate":`No date`,"timeline.bucket.unassigned":`Unassigned`,"timeline.relative.today":`Today`,"timeline.relative.tomorrow":`Tomorrow`,"timeline.relative.yesterday":`Yesterday`,"timeline.relative.inDays":`In {{n}} days`,"timeline.relative.daysAgo":`{{n}} days ago`},A=`timeline.bucket.today`;function j(e,t){let n=k[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n}function ee(){try{let e=l();return e.t(A)===A?{t:j}:{t:e.t}}catch{return{t:j}}}function te(){try{return h()}catch{return{fieldOptionLabel:(e,t,n,r)=>r,translateOptions:(e,t,n)=>n,fieldLabel:(e,t,n)=>n}}}var ne=d({mapping:d({title:f().optional(),date:f().optional(),description:f().optional(),variant:f().optional()}).optional(),objectName:f().optional(),titleField:f().optional(),dateField:f().optional(),startDateField:f().optional(),endDateField:f().optional(),descriptionField:f().optional(),groupByField:f().optional(),colorField:f().optional(),scale:p([`hour`,`day`,`week`,`month`,`quarter`,`year`]).optional()}),M=({schema:e,dataSource:t,className:n,onRowClick:r,onItemClick:a,...c})=>{let[l,d]=(0,b.useState)([]),[f,p]=(0,b.useState)(()=>{let t=Array.isArray(e.items)&&e.items.length>0,n=Array.isArray(c.data)&&c.data.length>0;return!t&&!n&&!!e.objectName}),[h,g]=(0,b.useState)(null),[_,v]=(0,b.useState)(0),[S,C]=(0,b.useState)(null),w=e.timeline;(0,b.useEffect)(()=>{let t=ne.safeParse(e);t.success||console.warn(`[ObjectTimeline] Invalid timeline configuration:`,t.error.format())},[e]);let T=o(e.bind);(0,b.useEffect)(()=>{let n=!0;return(async()=>{if(!(!t||typeof t.getObjectSchema!=`function`||!e.objectName))try{let r=await t.getObjectSchema(e.objectName);n&&C(r)}catch(e){console.warn(`Failed to fetch object def for ObjectTimeline`,e)}})(),()=>{n=!1}},[e.objectName,t]),(0,b.useEffect)(()=>{e.objectName&&!T&&!e.items&&!c.data?(async()=>{if(!t||typeof t.find!=`function`||!e.objectName){p(!1);return}p(!0);try{let n=s(S?.fields);d(u(await t.find(e.objectName,{options:{$top:100},...n.length>0?{$expand:n}:{}})))}catch(e){console.error(e),g(e)}finally{p(!1)}})():p(!1)},[e.objectName,t,T,e.items,c.data,_,S]);let E=c.data||T||l,{t:D}=ee(),{fieldOptionLabel:k}=te(),A=w?.titleField??e.mapping?.title??e.titleField??`name`,j=w?.startDateField??e.mapping?.date??e.startDateField??e.dateField??`date`,M=w?.endDateField??e.endDateField??j,N=e.mapping?.description??e.descriptionField??`description`,P=e.mapping?.variant??`variant`,F=w?.groupByField??e.groupByField,I=w?.colorField??e.colorField,L=(0,b.useMemo)(()=>{if(e.items)return e.items;if(!E||!Array.isArray(E))return[];let t=S?.fields??{},n=e.objectName||``,r=e=>{if(!e||!t[e]?.options)return{};let n={};for(let r of t[e].options)r&&r.value!=null&&(n[String(r.value)]=r);return n},i=r(I),a=Array.isArray(w?.metaFields)?w.metaFields.filter(e=>typeof e==`string`&&e):[`status`,`priority`].filter(e=>t[e]),o={};for(let e of a)o[e]=r(e);let s=e=>{if(e==null||e===``)return;let t=i[String(e)];if(t?.color)return String(t.color);let n=String(e);if(/^#([0-9a-f]{3}){1,2}$/i.test(n)||n.startsWith(`rgb`)||n.startsWith(`hsl`))return n},c=(e,t,r)=>{if(t==null||t===``)return null;let i=r[String(t)];return{label:i?.label?k(n,e,String(t),i.label):String(t),color:i?.color}},l=E.map(e=>{let t=e[j],r=e[M],i=I?e[I]:void 0,l=F?e[F]:void 0,u=[];if(n)for(let t of a){let n=c(t,e[t],o[t]||{});n&&u.push({key:t,label:n.label,color:n.color})}return{title:e[A],time:t,startDate:t,endDate:r,description:e[N],variant:e[P]||`default`,color:s(i),group:l,meta:u,_data:e}});l.sort((e,t)=>(e.startDate?new Date(e.startDate).getTime():1/0)-(t.startDate?new Date(t.startDate).getTime():1/0));let u=new Date,d=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),f=d(u),p=864e5,m=f-(u.getDay()+6)%7*p+7*p,h=m+7*p,g=e=>{if(!e)return D(`timeline.bucket.noDate`);let t=d(new Date(e));return Number.isNaN(t)?D(`timeline.bucket.noDate`):t<f?D(`timeline.bucket.overdue`):t===f?D(`timeline.bucket.today`):t===f+p?D(`timeline.bucket.tomorrow`):D(t<m?`timeline.bucket.thisWeek`:t<h?`timeline.bucket.nextWeek`:`timeline.bucket.later`)};if(F&&!l.every(e=>e.group==null||e.group===``)){let e=r(F);return l.map(t=>{let n=c(F,t.group,e);return{...t,group:n?n.label:t.group!=null&&t.group!==``?String(t.group):D(`timeline.bucket.unassigned`)}})}return l.map(e=>({...e,group:g(e.startDate)}))},[e.items,E,S,e.objectName,A,j,M,N,P,I,F,D,k]),{ref:R,isRefreshing:z,pullDistance:B}=y({onRefresh:(0,b.useCallback)(async()=>{v(e=>e+1)},[]),enabled:!!e.objectName&&!!t}),V=i({navigation:e.navigation,objectName:e.objectName,onRowClick:r??a}),H=w?.scale??e.scale,U={...e,items:L||[],className:n||e.className,...H?{timeScale:H}:{},onItemClick:e=>{let t=e._data||e;V.handleClick(t),a?.(t)}};return h?(0,x.jsxs)(`div`,{className:`p-4 text-destructive`,"data-testid":`timeline-error`,role:`alert`,children:[`Error loading timeline: `,h.message]}):f&&(!L||L.length===0)?(0,x.jsxs)(`div`,{className:`flex flex-col h-full min-h-[200px] p-4 gap-3`,"data-testid":`timeline-loading`,role:`status`,"aria-live":`polite`,"aria-busy":`true`,children:[(0,x.jsx)(`span`,{className:`sr-only`,children:`Loading timeline…`}),[0,1,2,3].map(e=>(0,x.jsxs)(`div`,{className:`flex items-start gap-3`,style:{opacity:Math.max(.3,1-e*.18)},children:[(0,x.jsx)(`div`,{className:`h-3 w-3 rounded-full bg-muted/70 animate-pulse mt-1.5 shrink-0`}),(0,x.jsxs)(`div`,{className:`flex-1 space-y-2`,children:[(0,x.jsx)(`div`,{className:`h-4 w-1/3 rounded bg-muted/70 animate-pulse`}),(0,x.jsx)(`div`,{className:`h-3 w-2/3 rounded bg-muted/50 animate-pulse`})]})]},e))]}):(0,x.jsxs)(`div`,{ref:R,className:`relative overflow-auto h-full min-w-0`,children:[B>0&&(0,x.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:B},children:z?`Refreshing…`:`Pull to refresh`}),(0,x.jsx)(O,{schema:U}),V.isOverlay&&(0,x.jsx)(m,{...V,title:`Timeline Item`,children:e=>(0,x.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,x.jsxs)(`div`,{className:`flex flex-col`,children:[(0,x.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,x.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})},N=t({ObjectTimeline:()=>M,ObjectTimelineRenderer:()=>$,Timeline:()=>P,TimelineContent:()=>z,TimelineDescription:()=>H,TimelineGantt:()=>G,TimelineGanttBar:()=>Z,TimelineGanttBarContent:()=>Q,TimelineGanttGrid:()=>J,TimelineGanttHeader:()=>K,TimelineGanttLabel:()=>X,TimelineGanttRow:()=>Y,TimelineGanttRowLabels:()=>q,TimelineHorizontal:()=>U,TimelineHorizontalItem:()=>W,TimelineItem:()=>I,TimelineMarker:()=>R,TimelineRenderer:()=>O,TimelineTime:()=>V,TimelineTitle:()=>B,timelineItemVariants:()=>F,timelineMarkerVariants:()=>L}),P=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`ol`,{ref:n,className:g(`relative ml-3 border-l border-gray-200`,e),...t}));P.displayName=`Timeline`;var F=v(`ml-6`,{variants:{density:{default:`mb-10`,compact:`mb-3`,comfortable:`mb-6`}},defaultVariants:{density:`default`}}),I=b.forwardRef(({className:e,density:t,...n},r)=>(0,x.jsx)(`li`,{ref:r,className:g(F({density:t}),e),...n}));I.displayName=`TimelineItem`;var L=v(`absolute -left-3 w-6 h-6 rounded-full border-2 flex items-center justify-center`,{variants:{variant:{default:`bg-blue-200 border-blue-400`,success:`bg-emerald-200 border-emerald-500`,warning:`bg-amber-200 border-amber-500`,danger:`bg-red-200 border-red-500`,info:`bg-purple-200 border-purple-500`,todo:`bg-slate-200 border-slate-400`,"in-progress":`bg-blue-200 border-blue-500`,done:`bg-emerald-200 border-emerald-500`}},defaultVariants:{variant:`default`}}),R=b.forwardRef(({className:e,variant:t=`default`,...n},r)=>(0,x.jsx)(`div`,{ref:r,className:g(L({variant:t}),e),...n}));R.displayName=`TimelineMarker`;var z=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`div`,{ref:n,className:e,...t}));z.displayName=`TimelineContent`;var B=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`h3`,{ref:n,className:g(`font-semibold text-lg mb-1`,e),...t}));B.displayName=`TimelineTitle`;var V=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`time`,{ref:n,className:g(`text-sm font-normal text-gray-500 mb-2 block`,e),...t}));V.displayName=`TimelineTime`;var H=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`p`,{ref:n,className:g(`text-base text-gray-700`,e),...t}));H.displayName=`TimelineDescription`;var U=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`div`,{ref:n,className:g(`relative flex overflow-x-auto py-8`,e),...t}));U.displayName=`TimelineHorizontal`;var W=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`div`,{ref:n,className:g(`shrink-0 w-64 relative`,e),...t}));W.displayName=`TimelineHorizontalItem`;var G=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`div`,{ref:n,className:g(`relative w-full border rounded-lg overflow-hidden`,e),...t}));G.displayName=`TimelineGantt`;var K=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`div`,{ref:n,className:g(`flex border-b bg-gray-50`,e),...t}));K.displayName=`TimelineGanttHeader`;var q=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`div`,{ref:n,className:g(`w-48 border-r bg-white`,e),...t}));q.displayName=`TimelineGanttRowLabels`;var J=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`div`,{ref:n,className:g(`flex-1 overflow-x-auto`,e),...t}));J.displayName=`TimelineGanttGrid`;var Y=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`div`,{ref:n,className:g(`flex items-center border-b min-h-12`,e),...t}));Y.displayName=`TimelineGanttRow`;var X=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`div`,{ref:n,className:g(`px-4 py-2 font-medium text-sm truncate`,e),...t}));X.displayName=`TimelineGanttLabel`;var Z=b.forwardRef(({className:e,start:t=0,width:n=100,variant:r=`default`,...i},a)=>(0,x.jsx)(`div`,{ref:a,className:g(`absolute h-8 rounded-md transition-colors cursor-pointer`,{default:`bg-blue-500 hover:bg-blue-600`,success:`bg-green-500 hover:bg-green-600`,warning:`bg-yellow-500 hover:bg-yellow-600`,danger:`bg-red-500 hover:bg-red-600`,info:`bg-purple-500 hover:bg-purple-600`}[r],e),style:{left:`${t}%`,width:`${n}%`},...i}));Z.displayName=`TimelineGanttBar`;var Q=b.forwardRef(({className:e,...t},n)=>(0,x.jsx)(`div`,{ref:n,className:g(`px-2 py-1 text-white text-xs font-medium truncate`,e),...t}));Q.displayName=`TimelineGanttBarContent`;var $=({schema:e,...t})=>{let{dataSource:n}=a()||{};return(0,x.jsx)(M,{schema:e,dataSource:n,...t})};c.register(`object-timeline`,$,{namespace:`plugin-timeline`,label:`Object Timeline`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`variant`,type:`enum`,enum:[`vertical`,`horizontal`,`gantt`],defaultValue:`vertical`}]}),c.register(`timeline`,$,{namespace:`view`,label:`Timeline View`,category:`view`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`variant`,type:`enum`,enum:[`vertical`,`horizontal`,`gantt`],defaultValue:`vertical`}]});export{N as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{B as r,H as i,lt as a,mt as o,r as s}from"./framework-D7UWfRl4.js";import{$n as c,$t as l,Aa as u,At as d,Bn as f,Bt as p,Cn as m,Cs as h,Dn as g,En as _,G as v,Gi as y,Hi as ee,Hn as b,Ht as x,I as S,Io as C,Jo as w,Ki as T,Kn as E,Ln as D,Ma as O,Na as te,Ns as k,On as A,Ot as ne,Qs as j,Rn as re,Si as ie,Sn as M,So as ae,Sr as N,Ta as oe,Ti as P,Tn as F,Ut as I,Vn as se,Vr as ce,Vt as L,Wt as R,Ya as z,Yi as B,Zr as V,_n as H,_r as le,ao as ue,at as de,bi as fe,bn as pe,cc as me,ci as he,cn as ge,di as _e,do as U,ec as ve,en as ye,fn as be,gn as xe,hn as Se,hr as W,io as Ce,it as G,jt as K,kn as we,kt as Te,lc as q,mn as Ee,ni as De,nn as J,nt as Oe,on as ke,pn as Ae,ro as je,sn as Me,tn as Ne,un as Y,vi as X,vn as Pe,wn as Z,ws as Fe,xn as Ie,yi as Le,yn as Re,za as ze,zn as Be}from"./ui-components-Clv7N77v.js";import{i as Ve}from"./vendor-ui-utils-rQOI1gAo.js";import{t as He}from"./plugin-form-MXrWd_1Z.js";import{_ as Ue,a as We,c as Ge,d as Ke,g as qe,h as Je,n as Ye,o as Xe,p as Ze,r as Qe,s as $e,t as et,u as tt}from"./vendor-dndkit-DMFEUxSy.js";import{r as nt}from"./plugin-grid-D9HjQh3d.js";var Q=e(t(),1),$=n(),rt={list:`List`,detail:`Detail`,grid:`Grid`,kanban:`Kanban`,calendar:`Calendar`,timeline:`Timeline`,map:`Map`,gallery:`Gallery`,gantt:`Gantt`},it={list:O,detail:ae,grid:Ce,kanban:ze,calendar:k,timeline:me,map:oe,gallery:z,gantt:he},at=Ve(`flex gap-4`,{variants:{position:{top:`flex-col`,bottom:`flex-col-reverse`,left:`flex-row`,right:`flex-row-reverse`}},defaultVariants:{position:`top`}}),ot=Ve(`w-full`,{variants:{orientation:{horizontal:`w-full`,vertical:`w-48`}},defaultVariants:{orientation:`horizontal`}}),st=Ve(`flex gap-2`,{variants:{orientation:{horizontal:`flex-row flex-wrap`,vertical:`flex-col`}},defaultVariants:{orientation:`horizontal`}}),ct=Ve(``,{variants:{orientation:{horizontal:``,vertical:`flex h-auto flex-col items-stretch`}},defaultVariants:{orientation:`horizontal`}});function lt(e){return e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}var ut={Home:`House`};function dt(e){if(!e)return null;let t=lt(e);return le[ut[t]||t]||null}function ft(e){return e.label?e.label:rt[e.type]||e.type}function pt(e){return e.icon?dt(e.icon):it[e.type]||null}function mt(e){return e.activeView?e.activeView:e.defaultView?e.defaultView:e.views?.[0]?.type}var ht={share:X,settings:Le,duplicate:w,delete:ce},gt={share:`Share`,settings:`Settings`,duplicate:`Duplicate`,delete:`Delete`},_t=({schema:e,className:t,onViewChange:n,onCreateView:i,onViewAction:a,createViewLabel:o=`Create view`,...s})=>{let c=Q.useMemo(()=>e.storageKey?e.storageKey:`view-switcher${e.id?`-${e.id}`:``}`,[e.id,e.storageKey]),[l,u]=Q.useState(()=>mt(e));Q.useEffect(()=>{if(e.activeView){u(e.activeView);return}if(e.persistPreference)try{let t=localStorage.getItem(c);if(t){let n=e.views.find(e=>e.type===t)?.type;n&&u(n)}}catch{}},[e.activeView,e.persistPreference,e.views,c]),Q.useEffect(()=>{if(!(!e.persistPreference||!l||e.activeView))try{localStorage.setItem(c,l)}catch{}},[l,e.activeView,e.persistPreference,c]);let d=Q.useCallback(t=>{n?.(t),e.onViewChange&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(e.onViewChange,{detail:{view:t}}))},[n,e.onViewChange]),f=Q.useCallback(e=>{u(e),d(e)},[d]),m=l||e.views?.[0]?.type,h=m||``,g=e.views.find(e=>e.type===m)||e.views?.[0],_=e.variant||`tabs`,v=e.position||`top`,y=v===`left`||v===`right`,b=y?`vertical`:`horizontal`,S=e.viewActions&&e.viewActions.length>0?(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:e.viewActions.map((e,t)=>{let n=e.icon&&dt(e.icon)||ht[e.type];return(0,$.jsx)(W,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>a?.(e.type,m),title:gt[e.type]||e.type,children:n?(0,$.jsx)(n,{className:`h-3.5 w-3.5`}):null},`action-${e.type}-${t}`)})}):null,C=e.allowCreateView?(0,$.jsx)(W,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>i?.(),title:o,children:(0,$.jsx)(ee,{className:`h-3.5 w-3.5`})}):null,w=(0,$.jsxs)(`div`,{className:q(ot({orientation:b}),`flex items-center gap-1`),children:[_===`dropdown`&&(0,$.jsxs)(p,{value:h,onValueChange:e=>f(e),children:[(0,$.jsx)(I,{className:q(`w-full`,y?`h-10`:`h-9`),children:(0,$.jsx)(R,{placeholder:`Select view`})}),(0,$.jsx)(L,{children:e.views.map((e,t)=>(0,$.jsx)(x,{value:e.type,children:ft(e)},`${e.type}-${t}`))})]}),_===`buttons`&&(0,$.jsx)(`div`,{className:q(st({orientation:b})),children:e.views.map((e,t)=>{let n=e.type===m,r=pt(e);return(0,$.jsxs)(W,{type:`button`,size:`sm`,variant:n?`secondary`:`ghost`,className:q(`justify-start gap-2`,y?`w-full`:``),onClick:()=>f(e.type),children:[r?(0,$.jsx)(r,{className:`h-4 w-4`}):null,(0,$.jsx)(`span`,{children:ft(e)})]},`${e.type}-${t}`)})}),_===`tabs`&&(0,$.jsx)(Oe,{value:h,onValueChange:e=>f(e),children:(0,$.jsx)(G,{className:q(ct({orientation:b})),children:e.views.map((e,t)=>{let n=pt(e);return(0,$.jsxs)(de,{value:e.type,className:q(`gap-2`,y?`justify-start`:``),children:[n?(0,$.jsx)(n,{className:`h-4 w-4`}):null,(0,$.jsx)(`span`,{children:ft(e)})]},`${e.type}-${t}`)})})}),S,C]}),T=g?.schema?Array.isArray(g.schema)?(0,$.jsx)(`div`,{className:`space-y-4`,children:g.schema.map((e,t)=>(0,$.jsx)(r,{schema:e,...s},`${g.type}-${t}`))}):(0,$.jsx)(r,{schema:g.schema,...s}):null;return(0,$.jsxs)(`div`,{className:q(at({position:v}),t),children:[(0,$.jsx)(`div`,{className:q(`shrink-0`,y?`flex flex-col`:`flex`),children:w}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,children:T})]})},vt=r,yt=({schema:e,dataSource:t,className:n,views:r,activeViewId:i,onViewChange:o,onRowClick:s,onEdit:c,renderListView:l,toolbarAddon:u,onCreateView:d,onViewAction:f})=>{let[p,m]=(0,Q.useState)(null),h=(0,Q.useRef)(null);h.current=p;let[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(`create`),[x,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(!(!t?.onMutation||!e.objectName)&&!l)return t.onMutation(t=>{t.resource===e.objectName&&T(e=>e+1)})},[t,e.objectName,l]);let[E,O]=(0,Q.useState)([]),[te,k]=(0,Q.useState)(!1),[A,ne]=(0,Q.useState)({}),[j,ie]=(0,Q.useState)([]),M=e.listViews,ae=M!=null&&Object.keys(M).length>0,[N,oe]=(0,Q.useState)(()=>e.defaultListView&&M?.[e.defaultListView]?e.defaultListView:M&&Object.keys(M)[0]||``),P=(0,Q.useMemo)(()=>!ae||!N?null:M[N]||null,[ae,N,M]),F=(0,Q.useMemo)(()=>r&&r.length>0?r:null,[r]),I=F!=null&&F.length>0,ce=i||F?.[0]?.id,L=F?.find(e=>e.id===ce)||F?.[0],R=(0,Q.useMemo)(()=>P?.type?P.type:L?.type?L.type:e.defaultViewType||`grid`,[P,L,e.defaultViewType]),z=e.navigation;(0,Q.useEffect)(()=>{let n=!0;return e.objectName&&t&&(async()=>{try{let r=await t.getObjectSchema(e.objectName);n&&m(r)}catch(e){console.error(`Failed to fetch object schema:`,e)}})(),()=>{n=!1}},[e.objectName,t]),(0,Q.useEffect)(()=>{let n=!0;return(async()=>{if(!l&&R!==`grid`&&!(!t||!e.objectName)){k(!0);try{let r=P?.filter||L?.filter||e.table?.defaultFilters||[],i=Object.entries(A).filter(([,e])=>e!==void 0&&e!==``&&e!==null).map(([e,t])=>[e,`=`,t]),o=[];o=r.length>0&&i.length>0?[`and`,...r,...i]:i.length===1?i[0]:i.length>1?[`and`,...i]:r;let s=j.length>0?j.map(e=>({field:e.field,order:e.direction})):P?.sort||L?.sort||e.table?.defaultSort||void 0,c=a(h.current?.fields),l=await t.find(e.objectName,{$filter:o.length>0?o:void 0,$orderby:s,$top:100,...c.length>0?{$expand:c}:{}}),u=[];Array.isArray(l)?u=l:l&&typeof l==`object`&&(Array.isArray(l.data)?u=l.data:Array.isArray(l.records)?u=l.records:Array.isArray(l.value)&&(u=l.value)),n&&O(u)}catch(e){console.error(`ObjectView data fetch error:`,e)}finally{n&&k(!1)}}})(),()=>{n=!1}},[e.objectName,t,R,A,j,w,P,L,l]);let B=e.layout||`drawer`,V=e.operations||e.table?.operations||{create:!0,read:!0,update:!0,delete:!0},le=(0,Q.useCallback)(()=>{B===`page`&&e.onNavigate?e.onNavigate(`new`,`edit`):(y(`create`),C(null),_(!0))},[B,e]),ue=(0,Q.useCallback)(t=>{if(c){c(t);return}if(B===`page`&&e.onNavigate){let n=t.id||t._id;e.onNavigate(n,`edit`)}else y(`edit`),C(t),_(!0)},[B,e,c]),fe=(0,Q.useCallback)(t=>{if(B===`page`&&e.onNavigate){let n=t.id||t._id;e.onNavigate(n,`view`)}else y(`view`),C(t),_(!0)},[B,e]),me=(0,Q.useCallback)(t=>{if(s){s(t);return}if(z){if(z.mode===`none`||z.preventNavigation)return;if(z.mode===`new_window`||z.openNewTab){let n=t.id||t._id,r=`/${e.objectName}/${encodeURIComponent(String(n))}`;window.open(r,`_blank`);return}if(z.mode===`drawer`){y(`view`),C(t),_(!0);return}if(z.mode===`modal`){y(`view`),C(t),_(!0);return}if(z.mode===`page`){let n=t.id||t._id;e.onNavigate&&e.onNavigate(n,`view`);return}if(z.mode===`split`||z.mode===`popover`){y(`view`),C(t),_(!0);return}}V.read!==!1&&fe(t)},[s,z,V.read,fe,e]),he=(0,Q.useCallback)(e=>{T(e=>e+1)},[]),ge=(0,Q.useCallback)(e=>{T(e=>e+1)},[]),_e=(0,Q.useCallback)(()=>{_(!1),C(null),T(e=>e+1)},[]),U=(0,Q.useCallback)(()=>{_(!1),C(null)},[]);(0,Q.useCallback)(()=>{T(e=>e+1)},[]);let ve=(0,Q.useMemo)(()=>!I||!F||F.length<=1?null:{type:`view-switcher`,variant:`tabs`,position:`top`,persistPreference:!0,storageKey:`view-pref-${e.objectName}`,defaultView:L?.type||`grid`,activeView:L?.type||`grid`,views:F.map(e=>({type:e.type,label:e.label,icon:{kanban:`kanban`,calendar:`calendar`,map:`map`,gallery:`layout-grid`,timeline:`activity`,gantt:`gantt-chart`,grid:`table`,list:`list`,detail:`file-text`,chart:`bar-chart-3`}[e.type]||`table`})),allowCreateView:e.allowCreateView,viewActions:e.viewActions},[I,F,L,e.objectName,e.allowCreateView,e.viewActions]),ye=(0,Q.useCallback)(e=>{if(!F)return;let t=F.find(t=>t.type===e);t&&o&&o(t.id)},[F,o]),be=(0,Q.useCallback)(e=>{oe(e)},[]);(0,Q.useMemo)(()=>{if(e.showFilters===!1)return null;let t=e.filterableFields,n=p?.fields||{},r=(t?t.map(e=>[e,n[e]||{label:e}]):Object.entries(n).filter(([,e])=>!e.hidden).slice(0,8)).map(([e,t])=>{let n=t.type||`text`,r=`text`,i;return n===`number`||n===`currency`||n===`percent`?r=`number`:n===`boolean`||n===`toggle`?r=`boolean`:n===`date`||n===`datetime`?r=`date`:n===`select`||n===`status`||t.options?(r=`select`,i=(t.options||[]).map(e=>typeof e==`string`?{label:e,value:e}:{label:e.label,value:e.value})):(n===`lookup`||n===`master_detail`||n===`user`||n===`owner`)&&t.options&&t.options.length>0&&(r=`multi-select`,i=(t.options||[]).map(e=>typeof e==`string`?{label:e,value:e}:{label:e.label,value:e.value})),{field:e,label:t.label||e,type:r,placeholder:`Filter ${t.label||e}...`,...i?{options:i}:{}}});return r.length===0?null:{type:`filter-ui`,layout:`popover`,showClear:!0,showApply:!0,filters:r,values:A}},[e.showFilters,e.filterableFields,p,A]);let xe=e.showSort;(0,Q.useMemo)(()=>{if(xe===!1)return null;let e=p?.fields||{},t=Object.entries(e).filter(([,e])=>!e.hidden).slice(0,10).map(([e,t])=>({field:e,label:t.label||e}));return t.length===0?null:{type:`sort-ui`,variant:`dropdown`,multiple:!1,fields:t,sort:j}},[p,j,xe]);let Se=(0,Q.useCallback)(t=>{let n={objectName:e.objectName,fields:P?.columns||L?.columns||e.table?.fields,className:`h-full w-full`,showSearch:L?.showSearch??e.showSearch??!1,showSort:L?.showSort??e.showSort??!1,showFilters:L?.showFilters??e.showFilters??!1,striped:L?.striped??!1,bordered:L?.bordered??!1,color:L?.color},r=P?.options||L||{};switch(t){case`kanban`:{let e=r.kanban||{},t=e.groupByField||e.groupField||`status`,i=(Array.isArray(e.columns)&&e.columns.length>0?e.columns:n.fields)||[],{columns:a,groupByField:o,groupField:s,titleField:c,...l}=e;return{type:`object-kanban`,...n,groupBy:t,groupField:t,titleField:e.titleField||`name`,cardFields:i,...l}}case`calendar`:return{type:`object-calendar`,...n,startDateField:r.calendar?.startDateField||`start_date`,endDateField:r.calendar?.endDateField||`end_date`,titleField:r.calendar?.titleField||`name`,...r.calendar||{}};case`gallery`:return{type:`object-gallery`,...n,imageField:r.gallery?.imageField,titleField:r.gallery?.titleField||`name`,subtitleField:r.gallery?.subtitleField,...r.gallery||{}};case`timeline`:return{type:`object-timeline`,...n,dateField:r.timeline?.dateField||`created_at`,titleField:r.timeline?.titleField||`name`,...r.timeline||{}};case`gantt`:return{type:`object-gantt`,...n,startDateField:r.gantt?.startDateField||`start_date`,endDateField:r.gantt?.endDateField||`end_date`,progressField:r.gantt?.progressField||`progress`,dependenciesField:r.gantt?.dependenciesField||`dependencies`,...r.gantt||{}};case`map`:return{type:`object-map`,...n,locationField:r.map?.locationField||`location`,...r.map||{}};case`chart`:{let t=r.chart||{},n=Array.isArray(t.yAxisFields)&&t.yAxisFields[0]||t.valueField||`value`,i=t.xAxisField||t.categoryField||`name`;return{type:`object-chart`,objectName:e.objectName,chartType:t.chartType||`bar`,aggregate:{field:n,function:t.aggregation||`count`,groupBy:i},xAxisKey:i,series:[{dataKey:n,label:n}],className:`h-[400px] w-full`}}default:return null}},[e.objectName,e.table?.fields,P,L]),Ce=(0,Q.useMemo)(()=>({type:`object-grid`,objectName:e.objectName,title:e.table?.title,description:e.table?.description,fields:P?.columns||L?.columns||e.table?.fields,columns:P?.columns||L?.columns||e.table?.columns,operations:{...V,create:!1},defaultFilters:P?.filter||L?.filter||e.table?.defaultFilters,defaultSort:P?.sort||L?.sort||e.table?.defaultSort,pageSize:e.table?.pageSize,selectable:e.table?.selectable,striped:L?.striped??e.table?.striped,bordered:L?.bordered??e.table?.bordered,className:e.table?.className}),[e,V,P,L]),K=()=>{let t=x?x.id||x._id:void 0;return{type:`object-form`,objectName:e.objectName,mode:v,recordId:t,title:e.form?.title,description:e.form?.description,fields:e.form?.fields,customFields:e.form?.customFields,groups:e.form?.groups,layout:e.form?.layout,columns:e.form?.columns,showSubmit:e.form?.showSubmit,submitText:e.form?.submitText,showCancel:e.form?.showCancel,cancelText:e.form?.cancelText,showReset:e.form?.showReset,initialValues:e.form?.initialValues,readOnly:e.form?.readOnly||v===`view`,className:e.form?.className,subforms:e.form?.subforms,onSuccess:_e,onCancel:U}},we=()=>{if(e.form?.title)return e.form.title;let t=p?.label||e.objectName;switch(v){case`create`:return`Create ${t}`;case`edit`:return`Edit ${t}`;case`view`:return`View ${t}`;default:return t}},Te=(0,Q.useMemo)(()=>{let e=z?.width;return e?typeof e==`number`?`max-w-[${e}px]`:`max-w-[${e}]`:``},[z]),Ee=()=>(0,$.jsx)(H,{open:g,onOpenChange:_,direction:`right`,children:(0,$.jsxs)(Pe,{className:q(`w-full sm:max-w-2xl`,Te),children:[(0,$.jsxs)(pe,{children:[(0,$.jsx)(Ie,{children:we()}),e.form?.description&&(0,$.jsx)(Re,{children:e.form.description})]}),(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 pb-4`,children:(0,$.jsx)(He,{schema:K(),dataSource:t})})]})}),De=()=>(0,$.jsx)(D,{open:g,onOpenChange:_,children:(0,$.jsxs)(re,{className:q(`max-w-2xl max-h-[90vh] overflow-y-auto`,Te),children:[(0,$.jsxs)(se,{children:[(0,$.jsx)(b,{children:we()}),e.form?.description&&(0,$.jsx)(Be,{children:e.form.description})]}),(0,$.jsx)(He,{schema:K(),dataSource:t})]})}),J=(0,Q.useMemo)(()=>Object.keys(A).some(e=>A[e]!==void 0&&A[e]!==``&&A[e]!==null)?Object.entries(A).filter(([,e])=>e!==void 0&&e!==``&&e!==null).map(([e,t])=>({field:e,operator:`equals`,value:t})):P?.filter||L?.filter||e.table?.defaultFilters,[A,P,L,e.table?.defaultFilters]),ke=(0,Q.useMemo)(()=>j.length>0?j:P?.sort||L?.sort||e.table?.defaultSort,[j,P,L,e.table?.defaultSort]),Ae=()=>{let n=`${e.objectName}-${N||L?.id||`default`}-${R}-${w}`;if(l)return l({schema:{type:`list-view`,objectName:e.objectName,viewType:R,fields:P?.columns||L?.columns||e.table?.fields,filters:J,sort:ke,rowHeight:L?.rowHeight,densityMode:L?.densityMode,groupBy:L?.groupBy,groupBy2:L?.groupBy2,grouping:L?.grouping,options:P?.options||L,showSearch:L?.showSearch??e.showSearch,showFilters:L?.showFilters??e.showFilters,showSort:L?.showSort??e.showSort,showHideFields:L?.showHideFields??e.showHideFields,showGroup:L?.showGroup??e.showGroup,showColor:L?.showColor??e.showColor,showDensity:L?.showDensity??e.showDensity,compactToolbar:L?.compactToolbar??e.compactToolbar,allowExport:L?.allowExport??e.allowExport,striped:L?.striped??e.striped,bordered:L?.bordered??e.bordered,color:L?.color??e.color,inlineEdit:L?.inlineEdit??e.inlineEdit,wrapHeaders:L?.wrapHeaders??e.wrapHeaders,clickIntoRecordDetails:L?.clickIntoRecordDetails??e.clickIntoRecordDetails,addRecordViaForm:L?.addRecordViaForm??e.addRecordViaForm,addDeleteRecordsInline:L?.addDeleteRecordsInline??e.addDeleteRecordsInline,collapseAllByDefault:L?.collapseAllByDefault??e.collapseAllByDefault,fieldTextColor:L?.fieldTextColor??e.fieldTextColor,prefixField:L?.prefixField??e.prefixField,showDescription:L?.showDescription??e.showDescription,navigation:L?.navigation??e.navigation,selection:L?.selection??e.selection,pagination:L?.pagination??e.pagination,searchableFields:L?.searchableFields??e.searchableFields,filterableFields:L?.filterableFields??e.filterableFields,resizable:L?.resizable??e.resizable,hiddenFields:L?.hiddenFields??e.hiddenFields,rowActions:L?.rowActions??e.rowActions,rowActionDefs:L?.rowActionDefs??e.rowActionDefs,bulkActions:L?.bulkActions??e.bulkActions,sharing:L?.sharing??e.sharing,addRecord:L?.addRecord??e.addRecord,conditionalFormatting:L?.conditionalFormatting??e.conditionalFormatting,quickFilters:L?.quickFilters??e.quickFilters,userFilters:L?.userFilters??e.userFilters,showRecordCount:L?.showRecordCount??e.showRecordCount,allowPrinting:L?.allowPrinting??e.allowPrinting,virtualScroll:L?.virtualScroll??e.virtualScroll,emptyState:L?.emptyState??e.emptyState,aria:L?.aria??e.aria,tabs:e.tabs,refreshTrigger:w},dataSource:t,onEdit:ue,onRowClick:me,className:`h-full`,refreshKey:w});if(R!==`grid`){let e=Se(R);if(e&&vt)return(0,$.jsx)(vt,{schema:e,dataSource:t,data:E,loading:te},n);if(!vt)return(0,$.jsx)(`div`,{className:`flex items-center justify-center h-40 text-muted-foreground`,children:(0,$.jsxs)(`p`,{children:[`SchemaRenderer not available. Install @object-ui/react to render `,R,` views.`]})})}return(0,$.jsx)(nt,{schema:Ce,dataSource:t,onRowClick:me,onEdit:V.update===!1?void 0:ue,onDelete:V.delete===!1?void 0:he,onBulkDelete:V.delete===!1?void 0:ge},n)},je=()=>{if(!ae)return null;let e=Object.entries(M);return e.length<=1?null:(0,$.jsx)(Oe,{value:N,onValueChange:be,className:`w-full`,children:(0,$.jsx)(G,{className:`w-auto`,children:e.map(([e,t])=>(0,$.jsx)(de,{value:e,className:`text-sm`,children:t.label||e},e))})})},Me=()=>{let t=e.showCreate!==!1&&V.create!==!1,n=e.showViewSwitcher===!0,r=je();return!r&&!n&&!t&&!u?null:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r,(n||t||u)&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:n&&ve&&(0,$.jsx)(_t,{schema:ve,onViewChange:ye,onCreateView:d,onViewAction:f,className:`overflow-x-auto`})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[u,t&&(0,$.jsxs)(W,{size:`sm`,onClick:le,children:[(0,$.jsx)(ee,{className:`h-4 w-4`}),`Create`]})]})]})]})},Ne=z?.mode===`modal`?`modal`:z?.mode===`drawer`?`drawer`:z?.mode===`split`?`split`:z?.mode===`popover`?`popover`:B,Y=e=>(0,$.jsx)(`div`,{className:`space-y-3`,children:(0,$.jsx)(He,{schema:K(),dataSource:t})}),X=(0,Q.useCallback)(e=>{e||U()},[U]);if(Ne===`split`){let t=p?.label||e.objectName;return(0,$.jsxs)(`div`,{className:q(`flex flex-col h-full min-w-0 overflow-hidden`,n),children:[(e.title||e.description)&&(0,$.jsxs)(`div`,{className:`mb-4 shrink-0`,children:[e.title&&(0,$.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:e.title}),e.description&&(0,$.jsx)(`p`,{className:`text-muted-foreground mt-1`,children:e.description})]}),(0,$.jsx)(`div`,{className:`mb-4 shrink-0`,children:Me()}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:g&&x?(0,$.jsx)(S,{isOpen:g,selectedRecord:x,mode:`split`,close:U,setIsOpen:X,width:z?.width,isOverlay:!0,title:`${t} Detail`,mainContent:(0,$.jsx)(`div`,{className:`h-full overflow-auto`,children:Ae()}),children:Y}):Ae()})]})}return(0,$.jsxs)(`div`,{className:q(`flex flex-col h-full min-w-0 overflow-hidden`,n),children:[(e.title||e.description)&&(0,$.jsxs)(`div`,{className:`mb-4 shrink-0`,children:[e.title&&(0,$.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:e.title}),e.description&&(0,$.jsx)(`p`,{className:`text-muted-foreground mt-1`,children:e.description})]}),(0,$.jsx)(`div`,{className:`mb-4 shrink-0`,children:Me()}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:Ae()}),Ne===`drawer`&&Ee(),Ne===`modal`&&De(),Ne===`popover`&&g&&x&&(0,$.jsx)(S,{isOpen:g,selectedRecord:x,mode:`popover`,close:U,setIsOpen:X,width:z?.width,isOverlay:!0,title:we(),children:Y})]})},bt=Ve(`flex`,{variants:{layout:{inline:`flex-col space-y-4`,popover:`items-center`,drawer:`items-center`}},defaultVariants:{layout:`inline`}}),xt=e=>e==null||e===``?!0:Array.isArray(e)?e.length===0:typeof e==`object`?Object.values(e).every(e=>e==null||e===``):!1,St=e=>Array.isArray(e)?{start:e[0]||``,end:e[1]||``}:e&&typeof e==`object`?{start:e.start||``,end:e.end||``}:{start:``,end:``},Ct=({schema:e,className:t,onChange:n})=>{let[r,i]=Q.useState(e.values||{}),[a,o]=Q.useState(!1);Q.useEffect(()=>{e.values&&i(e.values)},[e.values]);let s=Q.useCallback(t=>{n?.(t),e.onChange&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(e.onChange,{detail:{values:t}}))},[n,e.onChange]),c=Q.useCallback((t,n)=>{let a={...r,[t]:n};i(a),e.showApply||s(a)},[s,e.showApply,r]),u=Q.useCallback(()=>{let t={};if(i(t),e.showApply){s(t);return}s(t)},[s,e.showApply]),d=Q.useCallback(()=>{s(r),o(!1)},[s,r]),f=Q.useMemo(()=>Object.values(r).filter(e=>!xt(e)).length,[r]),m=e=>{let t=e.label||e.field,n=e.placeholder||`Filter by ${t}`;switch(e.type){case`number`:return(0,$.jsx)(J,{type:`number`,value:r[e.field]??``,placeholder:n,onChange:t=>{let n=t.target.value,r=n===``?``:Number(n);c(e.field,r)}});case`select`:return(0,$.jsxs)(p,{value:r[e.field]===void 0?``:String(r[e.field]),onValueChange:t=>{let n=e.options?.find(e=>String(e.value)===t);c(e.field,n?n.value:t)},children:[(0,$.jsx)(I,{children:(0,$.jsx)(R,{placeholder:n})}),(0,$.jsx)(L,{children:e.options?.map(e=>(0,$.jsx)(x,{value:String(e.value),children:e.label},String(e.value)))})]});case`multi-select`:{let t=r[e.field],n=Array.isArray(t)?t:t?[t]:[];return(0,$.jsx)(`div`,{className:`max-h-40 overflow-y-auto space-y-0.5 border rounded-md p-2`,children:e.options?.map(t=>{let r=n.map(String).includes(String(t.value));return(0,$.jsxs)(`label`,{className:q(`flex items-center gap-2 text-sm py-1 px-1.5 rounded cursor-pointer`,r?`bg-primary/5 text-primary`:`hover:bg-muted`),children:[(0,$.jsx)(E,{checked:r,onCheckedChange:r=>{let i=r?[...n,t.value]:n.filter(e=>String(e)!==String(t.value));c(e.field,i)}}),(0,$.jsx)(`span`,{className:`truncate`,children:t.label})]},String(t.value))})})}case`date`:return(0,$.jsx)(J,{type:`date`,value:r[e.field]??``,onChange:t=>c(e.field,t.target.value)});case`date-range`:{let t=St(r[e.field]);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{type:`date`,value:t.start??``,onChange:n=>{c(e.field,{...t,start:n.target.value})}}),(0,$.jsx)(J,{type:`date`,value:t.end??``,onChange:n=>{c(e.field,{...t,end:n.target.value})}})]})}case`boolean`:return(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(E,{checked:!!r[e.field],onCheckedChange:t=>c(e.field,!!t)}),(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Enabled`})]});default:return(0,$.jsx)(J,{value:r[e.field]??``,placeholder:n,onChange:t=>c(e.field,t.target.value)})}},h=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:e.filters.map(e=>(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(ke,{className:`text-xs text-muted-foreground`,children:e.label||e.field}),m(e)]},e.field))}),(e.showApply||e.showClear)&&(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t pt-3`,children:[e.showClear&&(0,$.jsx)(W,{type:`button`,variant:`ghost`,size:`sm`,onClick:u,children:`Clear`}),e.showApply&&(0,$.jsx)(W,{type:`button`,size:`sm`,onClick:d,children:`Apply`})]})]}),g=e.layout||`inline`;return g===`popover`?(0,$.jsx)(`div`,{className:q(bt({layout:g}),t),children:(0,$.jsxs)(l,{open:a,onOpenChange:o,children:[(0,$.jsx)(Ne,{asChild:!0,children:(0,$.jsxs)(W,{type:`button`,variant:f>0?`secondary`:`outline`,size:`sm`,className:`gap-2`,children:[(0,$.jsx)(_e,{className:`h-4 w-4`}),`Filters`,f>0&&(0,$.jsx)(`span`,{className:`inline-flex h-5 min-w-[20px] items-center justify-center rounded-full bg-primary/10 px-1 text-xs font-medium text-primary`,children:f})]})}),(0,$.jsx)(ye,{align:`start`,className:`w-[520px] p-4`,children:h})]})}):g===`drawer`?(0,$.jsxs)(`div`,{className:q(bt({layout:g}),t),children:[(0,$.jsxs)(W,{type:`button`,variant:f>0?`secondary`:`outline`,size:`sm`,className:`gap-2`,onClick:()=>o(!0),children:[(0,$.jsx)(_e,{className:`h-4 w-4`}),`Filters`,f>0&&(0,$.jsx)(`span`,{className:`inline-flex h-5 min-w-[20px] items-center justify-center rounded-full bg-primary/10 px-1 text-xs font-medium text-primary`,children:f})]}),(0,$.jsx)(H,{open:a,onOpenChange:o,children:(0,$.jsxs)(Pe,{children:[(0,$.jsxs)(pe,{children:[(0,$.jsx)(Ie,{children:`Filters`}),(0,$.jsx)(Re,{children:`Refine the data with advanced filters.`})]}),(0,$.jsx)(`div`,{className:`px-4 pb-6`,children:h})]})})]}):(0,$.jsxs)(`div`,{className:q(bt({layout:g}),t),children:[h,!e.showApply&&e.showClear&&(0,$.jsxs)(W,{type:`button`,variant:`ghost`,size:`sm`,className:`gap-2`,onClick:u,children:[(0,$.jsx)(N,{className:`h-3.5 w-3.5`}),`Clear filters`]})]})},wt=Ve(``,{variants:{variant:{buttons:`flex flex-wrap gap-2`,dropdown:`flex flex-wrap items-center gap-3`,builder:`space-y-3`}},defaultVariants:{variant:`dropdown`}}),Tt=e=>e?e.map(e=>({field:e.field,direction:e.direction})):[],Et=e=>e.map(e=>({id:`${e.field}-${e.direction}`,field:e.field,order:e.direction})),Dt=e=>e.filter(e=>e.field).map(e=>({field:e.field,direction:e.order})),Ot=({schema:e,className:t,onChange:n})=>{let[r,i]=Q.useState(()=>Tt(e.sort)),[a,o]=Q.useState(()=>Et(Tt(e.sort)));Q.useEffect(()=>{let t=Tt(e.sort);i(t),o(Et(t))},[e.sort]);let s=Q.useCallback(t=>{i(t),n?.(t),e.onChange&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(e.onChange,{detail:{sort:t}}))},[n,e.onChange]),c=Q.useCallback(t=>{let n=r.find(e=>e.field===t),i=!!e.multiple;if(!n){s(i?[...r,{field:t,direction:`asc`}]:[{field:t,direction:`asc`}]);return}if(n.direction===`asc`){s(r.map(e=>e.field===t?{...e,direction:`desc`}:e));return}s(r.filter(e=>e.field!==t))},[s,e.multiple,r]);if((e.variant||`dropdown`)===`buttons`)return(0,$.jsx)(`div`,{className:q(wt({variant:`buttons`}),t),children:e.fields.map(e=>{let t=r.find(t=>t.field===e.field);return(0,$.jsxs)(W,{type:`button`,variant:t?`secondary`:`outline`,size:`sm`,onClick:()=>c(e.field),className:`gap-2`,children:[(0,$.jsx)(`span`,{children:e.label||e.field}),t&&(0,$.jsx)(j,{className:q(`h-3.5 w-3.5 motion-safe:transition-transform motion-safe:duration-200`,t.direction===`desc`&&`rotate-180`),"aria-label":t.direction===`asc`?`ascending`:`descending`})]},e.field)})});if(e.multiple)return(0,$.jsx)(`div`,{className:q(wt({variant:`builder`}),t),children:(0,$.jsx)(v,{fields:e.fields.map(e=>({value:e.field,label:e.label||e.field})),value:a,onChange:e=>{o(e),s(Dt(e))}})});let l=r[0];return(0,$.jsxs)(`div`,{className:q(wt({variant:`dropdown`}),t),children:[(0,$.jsxs)(p,{value:l?.field||``,onValueChange:e=>{if(!e){s([]);return}s([{field:e,direction:l?.direction||`asc`}])},children:[(0,$.jsx)(I,{className:`w-56`,children:(0,$.jsx)(R,{placeholder:`Select field`})}),(0,$.jsx)(L,{children:e.fields.map(e=>(0,$.jsx)(x,{value:e.field,children:e.label||e.field},e.field))})]}),(0,$.jsxs)(p,{value:l?.direction||`asc`,onValueChange:e=>{l?.field&&s([{field:l.field,direction:e}])},children:[(0,$.jsx)(I,{className:`w-36`,children:(0,$.jsx)(R,{})}),(0,$.jsxs)(L,{children:[(0,$.jsx)(x,{value:`asc`,children:`Ascending`}),(0,$.jsx)(x,{value:`desc`,children:`Descending`})]})]})]})};function kt(){if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)return crypto.randomUUID();if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`){let e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}return Math.random().toString(36).slice(2)+Math.random().toString(36).slice(2)}function At(e,t,n,r){return`${e}/share/${t}/${n}?mode=readonly&token=${r}`}var jt=({objectName:e,viewId:t=`default`,baseUrl:n,onShare:r,className:i})=>{let[a,o]=Q.useState(null),[s,d]=Q.useState(!1),[f,p]=Q.useState(!1),[m,h]=Q.useState(``),[g,_]=Q.useState(``),v=n??(typeof window<`u`?window.location.origin:``),y=Q.useCallback(()=>{let n=At(v,e,t,kt());o(n),d(!1);let i=g?new Date(Date.now()+parseInt(g,10)*864e5).toISOString():void 0;r?.(n,{password:m||void 0,expiresAt:i})},[v,e,t,r,m,g]),ee=Q.useCallback(async()=>{if(a)try{await navigator.clipboard.writeText(a),d(!0),setTimeout(()=>d(!1),2e3)}catch{let e=document.createElement(`textarea`);e.value=a,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e),d(!0),setTimeout(()=>d(!1),2e3)}},[a]);return(0,$.jsxs)(l,{open:f,onOpenChange:p,children:[(0,$.jsx)(Ne,{asChild:!0,children:(0,$.jsxs)(W,{variant:`outline`,size:`sm`,className:q(`gap-2`,i),children:[(0,$.jsx)(X,{className:`h-4 w-4`}),`Share`]})}),(0,$.jsxs)(ye,{className:`w-96 space-y-4`,align:`end`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h4`,{className:`text-sm font-medium`,children:`Share View`}),(0,$.jsx)(c,{variant:`secondary`,className:`text-xs`,children:`Read-only`})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Generate a public link to share this view. Recipients can view data without logging in.`})]}),a?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{value:a,readOnly:!0,className:`h-8 text-xs`,onClick:e=>e.target.select()}),(0,$.jsx)(W,{variant:`outline`,size:`sm`,onClick:ee,className:`shrink-0 gap-1`,children:s?(0,$.jsx)(Fe,{className:`h-4 w-4 text-green-500`}):(0,$.jsx)(w,{className:`h-4 w-4`})})]}),(m||g)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[m&&(0,$.jsxs)(c,{variant:`outline`,className:`text-xs gap-1`,children:[(0,$.jsx)(u,{className:`h-3 w-3`}),`Password protected`]}),g&&(0,$.jsxs)(c,{variant:`outline`,className:`text-xs gap-1`,children:[(0,$.jsx)(k,{className:`h-3 w-3`}),`Expires in `,g,` day`,g===`1`?``:`s`]})]})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[(0,$.jsx)(u,{className:`h-3.5 w-3.5`}),`Password protection (optional)`]}),(0,$.jsx)(J,{type:`password`,value:m,onChange:e=>h(e.target.value),placeholder:`Enter password...`,className:`h-8 text-xs`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[(0,$.jsx)(k,{className:`h-3.5 w-3.5`}),`Expires after (optional)`]}),(0,$.jsxs)(`select`,{value:g,onChange:e=>_(e.target.value),className:`w-full h-8 text-xs rounded-md border border-input bg-background px-3`,children:[(0,$.jsx)(`option`,{value:``,children:`Never`}),(0,$.jsx)(`option`,{value:`1`,children:`1 day`}),(0,$.jsx)(`option`,{value:`7`,children:`7 days`}),(0,$.jsx)(`option`,{value:`30`,children:`30 days`}),(0,$.jsx)(`option`,{value:`90`,children:`90 days`})]})]}),(0,$.jsxs)(W,{onClick:y,className:`w-full gap-2`,size:`sm`,children:[(0,$.jsx)(X,{className:`h-4 w-4`}),`Generate Link`]})]})]})]})};function Mt(){try{let{t:e}=s();return(t,n,r)=>{let i=e(t,r);return!i||i===t?n:i}}catch{return(e,t)=>t}}var Nt={private:0,team:1,organization:2,public:3},Pt=8,Ft=({id:e,disabled:t,children:n})=>{let{attributes:r,listeners:i,setNodeRef:a,transform:o,transition:s,isDragging:c}=Xe({id:e,disabled:t,attributes:{role:`tab`,roleDescription:`view tab`,tabIndex:0}});return(0,$.jsx)($.Fragment,{children:n({setNodeRef:a,style:{transform:Ue.Transform.toString(o),transition:s,zIndex:c?10:void 0,opacity:c?.5:void 0},listeners:i,attributes:r,isDragging:c})})},It=({views:e,activeViewId:t,onViewChange:n,viewTypeIcons:r={},config:i={},onAddView:a,onRenameView:o,onDuplicateView:s,onDeleteView:c,onSetDefaultView:l,onShareView:f,onSaveAsView:p,onPinView:v,onReorderViews:b,onChangeViewType:x,onConfigView:S,onManageViews:E,availableViewTypes:D,hasUnsavedChanges:O=!1,onResetChanges:k,className:j})=>{let{showAddButton:re=!0,inlineRename:ie=!0,contextMenu:ae=!0,reorderable:N=!1,maxVisibleTabs:oe=4,showIndicators:I=!0,showSaveAsView:se=!0,showPinnedSection:L=!0,showVisibilityGroups:R=!1}=i,z=Mt(),[H,le]=(0,Q.useState)(null),[de,pe]=(0,Q.useState)(``),me=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{H&&me.current&&(me.current.focus(),me.current.select())},[H]);let he=(0,Q.useCallback)(t=>{if(!ie||!o)return;let n=e.find(e=>e.id===t);n&&(n.readonly||(le(t),pe(n.label)))},[ie,o,e]),_e=(0,Q.useCallback)(()=>{H&&de.trim()&&o&&o(H,de.trim()),le(null),pe(``)},[H,de,o]),ye=(0,Q.useCallback)(()=>{le(null),pe(``)},[]),Ce=(0,Q.useMemo)(()=>e.length>0&&e.every(e=>!!e.readonly),[e]),G=(0,Q.useMemo)(()=>{let t=[...e];return t.sort((e,t)=>{if(L){let n=+!!e.isPinned,r=+!!t.isPinned;if(n!==r)return r-n}if(R){let n=Nt[e.visibility||`public`]??Nt.public,r=Nt[t.visibility||`public`]??Nt.public;if(n!==r)return n-r}return 0}),t},[e,L,R]),{visibleViews:Oe,overflowViews:ke}=(0,Q.useMemo)(()=>{let e=G.slice(0,oe),n=G.slice(oe),r=n.findIndex(e=>e.id===t);if(r===-1)return{visibleViews:e,overflowViews:n};let i=n[r],a=e.length>0?[...e.slice(0,-1),i]:[i],o=e.length>0?e[e.length-1]:null,s=n.filter((e,t)=>t!==r);return o&&s.unshift(o),{visibleViews:a,overflowViews:s}},[G,oe,t]),Ne=qe(Je(Ke,{activationConstraint:{distance:Pt}}),Je(tt)),Pe=(0,Q.useCallback)(e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!b)return;let r=G.findIndex(e=>e.id===t.id),i=G.findIndex(e=>e.id===n.id);r===-1||i===-1||b(Ye(G,r,i).map(e=>e.id))},[G,b]),Fe=V,Ie=(0,Q.useCallback)(e=>{if(!R||e===0)return!1;let t=Oe[e-1],n=Oe[e],r=e=>e.visibility===`private`;return r(t)&&!r(n)},[R,Oe]),Le=(e,i)=>{let a=e.id===t,d=r[e.type]||Fe,p=H===e.id,ee=I&&(e.hasActiveFilters||e.hasActiveSort),C=Ie(i),O=!!e.readonly,k=(e=>R?e.visibility===`private`?(0,$.jsx)(u,{"data-testid":`view-tab-visibility-${e.id}`,className:`h-3 w-3 text-muted-foreground shrink-0`}):e.visibility?(0,$.jsx)(ue,{"data-testid":`view-tab-visibility-${e.id}`,className:`h-3 w-3 text-muted-foreground shrink-0`}):null:null)(e),j=t=>(0,$.jsxs)(`div`,{"data-testid":`view-tab-${e.id}`,role:`tab`,tabIndex:0,"aria-selected":a,onClick:()=>!p&&n(e.id),onDoubleClick:()=>he(e.id),onKeyDown:t=>{!p&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e.id))},...t?.listeners??{},...t?.attributes??{},className:q(`group/tab inline-flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors whitespace-nowrap relative outline-none focus-visible:ring-2 focus-visible:ring-ring`,t?.isDragging?`cursor-grabbing`:`cursor-pointer`,a?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground hover:border-border`),children:[N&&b&&(0,$.jsx)(`span`,{"data-testid":`view-tab-drag-handle-${e.id}`,"aria-hidden":`true`,className:q(`text-muted-foreground transition-opacity pointer-events-none`,`opacity-0 group-hover/tab:opacity-100`,t?.isDragging&&`opacity-100`),children:(0,$.jsx)(je,{className:`h-3 w-3`})}),L&&e.isPinned&&(0,$.jsx)(T,{"data-testid":`view-tab-pin-indicator-${e.id}`,className:`h-3 w-3 text-primary shrink-0`}),k,(0,$.jsx)(d,{className:`h-3.5 w-3.5`}),p?(0,$.jsx)(J,{ref:me,"data-testid":`view-tab-rename-input-${e.id}`,value:de,onChange:e=>pe(e.target.value),onBlur:_e,onKeyDown:e=>{e.key===`Enter`&&_e(),e.key===`Escape`&&ye()},className:`h-5 w-24 px-1 py-0 text-sm border-none focus-visible:ring-1`,onClick:e=>e.stopPropagation()}):(0,$.jsx)(`span`,{children:e.label}),O&&!Ce&&(0,$.jsxs)(ne,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(u,{"data-testid":`view-tab-readonly-${e.id}`,"aria-label":z(`view.readonlyAriaLabel`,`Read-only view`),className:`h-3 w-3 text-muted-foreground shrink-0`})}),(0,$.jsx)(Te,{side:`bottom`,className:`text-xs`,children:e.readonlyReason||z(`view.readonlyTooltip`,`System view — defined in code, read-only.`)})]}),ee&&(0,$.jsxs)(ne,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsxs)(`span`,{"data-testid":`view-tab-indicator-${e.id}`,className:`ml-1 inline-flex items-center gap-0.5 h-4 px-1 rounded-full bg-primary/10 text-primary shrink-0`,children:[e.hasActiveFilters&&(0,$.jsx)(U,{className:`h-2.5 w-2.5`}),e.hasActiveSort&&(0,$.jsx)(ve,{className:`h-2.5 w-2.5`})]})}),(0,$.jsx)(Te,{side:`bottom`,className:`text-xs`,children:[e.hasActiveFilters&&`Active filters`,e.hasActiveSort&&`Active sort`].filter(Boolean).join(`, `)})]}),e.isDefault&&(0,$.jsx)(De,{className:`h-3 w-3 text-amber-500 fill-amber-500 shrink-0`}),a&&(S||o||s||c)&&(0,$.jsxs)(Me,{children:[(0,$.jsx)(xe,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"data-testid":`view-tab-actions-${e.id}`,className:`ml-0.5 h-4 w-4 flex items-center justify-center rounded hover:bg-accent shrink-0 opacity-70 hover:opacity-100 transition-opacity`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),"aria-label":z(`view.tabActionsFor`,`View actions for ${e.label}`,{name:e.label}),children:(0,$.jsx)(h,{className:`h-3 w-3`})})}),(0,$.jsxs)(ge,{align:`start`,className:`min-w-[180px]`,onClick:e=>e.stopPropagation(),children:[S&&!O&&(0,$.jsxs)(Y,{"data-testid":`view-tab-menu-config-${e.id}`,onClick:()=>S(e.id),children:[(0,$.jsx)(fe,{className:`h-4 w-4 mr-2`}),` Edit view config`]}),o&&!O&&(0,$.jsxs)(Y,{"data-testid":`view-tab-menu-rename-${e.id}`,onClick:()=>he(e.id),children:[(0,$.jsx)(B,{className:`h-4 w-4 mr-2`}),` Rename`]}),s&&(0,$.jsxs)(Y,{"data-testid":`view-tab-menu-duplicate-${e.id}`,onClick:()=>s(e.id),children:[(0,$.jsx)(w,{className:`h-4 w-4 mr-2`}),` Duplicate view`]}),f&&(0,$.jsxs)(Y,{"data-testid":`view-tab-menu-share-${e.id}`,onClick:()=>f(e.id),children:[(0,$.jsx)(X,{className:`h-4 w-4 mr-2`}),` Share view`]}),l&&!O&&(0,$.jsxs)(Y,{"data-testid":`view-tab-menu-default-${e.id}`,onClick:()=>l(e.id),children:[(0,$.jsx)(De,{className:`h-4 w-4 mr-2`}),` Set as default`]}),v&&!O&&(0,$.jsx)(Y,{"data-testid":`view-tab-menu-pin-${e.id}`,onClick:()=>v(e.id,!e.isPinned),children:e.isPinned?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(y,{className:`h-4 w-4 mr-2`}),` Unpin view`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{className:`h-4 w-4 mr-2`}),` Pin view`]})}),x&&!O&&D&&D.length>0&&(0,$.jsxs)(Ae,{children:[(0,$.jsxs)(Se,{"data-testid":`view-tab-menu-change-type-${e.id}`,children:[(0,$.jsx)(ze,{className:`h-4 w-4 mr-2`}),` Change view type`]}),(0,$.jsx)(Ee,{children:D.map(t=>{let n=r[t.type]||Fe;return(0,$.jsxs)(Y,{"data-testid":`view-tab-menu-type-${e.id}-${t.type}`,disabled:t.type===e.type,onClick:()=>x(e.id,t.type),children:[(0,$.jsx)(n,{className:`h-4 w-4 mr-2`}),(0,$.jsx)(`span`,{children:t.label})]},t.type)})})]}),c&&!O&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(be,{}),(0,$.jsxs)(Y,{"data-testid":`view-tab-menu-delete-${e.id}`,onClick:()=>c(e.id),className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(ce,{className:`h-4 w-4 mr-2`}),` Delete view`]})]}),E&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(be,{}),(0,$.jsxs)(Y,{"data-testid":`view-tab-menu-manage-${e.id}`,onClick:E,children:[(0,$.jsx)(te,{className:`h-4 w-4 mr-2`}),` Manage all views…`]})]})]})]})]}),re=t=>!ae||p?t:(0,$.jsxs)(M,{children:[(0,$.jsx)(we,{asChild:!0,children:t}),(0,$.jsxs)(m,{children:[o&&!O&&(0,$.jsxs)(Z,{"data-testid":`context-menu-rename-${e.id}`,onClick:()=>he(e.id),children:[(0,$.jsx)(B,{className:`h-4 w-4 mr-2`}),` Rename`]}),s&&(0,$.jsxs)(Z,{"data-testid":`context-menu-duplicate-${e.id}`,onClick:()=>s(e.id),children:[(0,$.jsx)(w,{className:`h-4 w-4 mr-2`}),` Duplicate View`]}),f&&(0,$.jsxs)(Z,{"data-testid":`context-menu-share-${e.id}`,onClick:()=>f(e.id),children:[(0,$.jsx)(X,{className:`h-4 w-4 mr-2`}),` Share View`]}),l&&!O&&(0,$.jsxs)(Z,{"data-testid":`context-menu-default-${e.id}`,onClick:()=>l(e.id),children:[(0,$.jsx)(De,{className:`h-4 w-4 mr-2`}),` Set as Default`]}),v&&!O&&(0,$.jsx)(Z,{"data-testid":`context-menu-pin-${e.id}`,onClick:()=>v(e.id,!e.isPinned),children:e.isPinned?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(y,{className:`h-4 w-4 mr-2`}),` Unpin View`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{className:`h-4 w-4 mr-2`}),` Pin View`]})}),x&&!O&&D&&D.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{}),(0,$.jsxs)(_,{children:[(0,$.jsxs)(A,{"data-testid":`context-menu-change-type-${e.id}`,children:[(0,$.jsx)(ze,{className:`h-4 w-4 mr-2`}),` Change View Type`]}),(0,$.jsx)(g,{"data-testid":`context-menu-type-submenu-${e.id}`,children:D.map(t=>{let n=r[t.type]||Fe;return(0,$.jsxs)(Z,{"data-testid":`context-menu-type-${e.id}-${t.type}`,disabled:t.type===e.type,onClick:()=>x(e.id,t.type),children:[(0,$.jsx)(n,{className:`h-4 w-4 mr-2`}),(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{children:t.label}),t.description&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t.description})]})]},t.type)})})]})]}),c&&!O&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{}),(0,$.jsxs)(Z,{"data-testid":`context-menu-delete-${e.id}`,onClick:()=>c(e.id),className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(ce,{className:`h-4 w-4 mr-2`}),` Delete View`]})]}),E&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{}),(0,$.jsxs)(Z,{"data-testid":`context-menu-manage-${e.id}`,onClick:E,children:[(0,$.jsx)(te,{className:`h-4 w-4 mr-2`}),` Manage all views…`]})]})]})]});return N&&b?(0,$.jsxs)(Q.Fragment,{children:[C&&(0,$.jsx)(`div`,{"data-testid":`view-tab-visibility-separator`,className:`w-px h-5 bg-border mx-1 self-center shrink-0`}),(0,$.jsx)(Ft,{id:e.id,children:({setNodeRef:e,style:t,listeners:n,attributes:r,isDragging:i})=>(0,$.jsx)(`div`,{ref:e,style:t,className:q(`flex`,i&&`z-10`),children:re(j({listeners:n,attributes:r,isDragging:i}))})})]},e.id):(0,$.jsxs)(Q.Fragment,{children:[C&&(0,$.jsx)(`div`,{"data-testid":`view-tab-visibility-separator`,className:`w-px h-5 bg-border mx-1 self-center shrink-0`}),re(j())]},e.id)},Re=(0,$.jsx)($.Fragment,{children:Oe.map((e,t)=>Le(e,t))});return(0,$.jsx)(d,{children:(0,$.jsxs)(`div`,{"data-testid":`view-tab-bar`,className:q(`flex items-center gap-0.5 -mb-px`,j),children:[N&&b?(0,$.jsx)(Ge,{sensors:Ne,collisionDetection:Ze,onDragEnd:Pe,children:(0,$.jsx)(et,{items:Oe.map(e=>e.id),strategy:Qe,children:(0,$.jsx)(`div`,{"data-testid":`view-tab-sortable-container`,className:`flex items-center gap-0.5`,children:Re})})}):Re,ke.length>0&&(0,$.jsxs)(Me,{children:[(0,$.jsx)(xe,{asChild:!0,children:(0,$.jsxs)(`button`,{"data-testid":`view-tab-overflow`,className:`inline-flex items-center gap-1 px-2 py-2 text-sm text-muted-foreground hover:text-foreground transition-colors`,children:[(0,$.jsx)(C,{className:`h-4 w-4`}),(0,$.jsxs)(`span`,{className:`text-xs`,children:[ke.length,` more`]})]})}),(0,$.jsxs)(ge,{align:`end`,children:[E&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Y,{"data-testid":`view-tab-overflow-manage`,onClick:E,className:`font-medium`,children:[(0,$.jsx)(te,{className:`h-4 w-4 mr-2`}),` Manage all views…`]}),(0,$.jsx)(be,{})]}),ke.map(e=>{let t=r[e.type]||Fe;return(0,$.jsxs)(Y,{"data-testid":`view-tab-overflow-${e.id}`,onClick:()=>n(e.id),children:[e.isPinned&&(0,$.jsx)(T,{className:`h-3 w-3 mr-1 text-primary shrink-0`}),(0,$.jsx)(t,{className:`h-4 w-4 mr-2`}),e.label,I&&(e.hasActiveFilters||e.hasActiveSort)&&(0,$.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-0.5 h-4 px-1 rounded-full bg-primary/10 text-primary`,children:[e.hasActiveFilters&&(0,$.jsx)(U,{className:`h-2.5 w-2.5`}),e.hasActiveSort&&(0,$.jsx)(ve,{className:`h-2.5 w-2.5`})]})]},e.id)})]})]}),re&&a&&(0,$.jsxs)(ne,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(`button`,{"data-testid":`view-tab-add`,onClick:a,className:`inline-flex items-center px-2 py-2 text-muted-foreground hover:text-foreground transition-colors`,children:(0,$.jsx)(ee,{className:`h-4 w-4`})})}),(0,$.jsx)(Te,{children:`Add View`})]}),se&&O&&(0,$.jsxs)(`div`,{"data-testid":`view-tab-save-as`,className:`flex items-center gap-1 ml-2 text-xs text-amber-600 dark:text-amber-400`,children:[(0,$.jsx)(P,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Unsaved changes`}),p&&(0,$.jsx)(W,{variant:`ghost`,size:`sm`,"data-testid":`view-tab-save-as-btn`,className:`h-6 px-2 text-xs`,onClick:p,children:`Save as View`}),k&&(0,$.jsx)(W,{variant:`ghost`,size:`sm`,"data-testid":`view-tab-reset-btn`,className:`h-6 px-2 text-xs`,onClick:k,children:`Reset`})]})]})})},Lt=V,Rt=({view:e,isActive:t,Icon:n,isRenaming:r,onStartRename:i,onCommitRename:a,onCancelRename:o,onRowClick:s,onDelete:c,onDuplicate:l,onSetDefault:f,onSetPinned:p,onConfigView:m})=>{let{attributes:h,listeners:g,setNodeRef:_,transform:v,transition:ee,isDragging:b}=Xe({id:e.id}),x={transform:Ue.Transform.toString(v),transition:ee,opacity:b?.5:1},S=(0,Q.useRef)(null),[E,D]=(0,Q.useState)(e.label),O=!!e.readonly;(0,Q.useEffect)(()=>{r&&(D(e.label),requestAnimationFrame(()=>{S.current?.focus(),S.current?.select()}))},[r,e.label]);let te=(0,Q.useCallback)(()=>{let t=E.trim();t&&t!==e.label?a(e.id,t):o()},[E,e.id,e.label,a,o]);return(0,$.jsxs)(`li`,{ref:_,style:x,"data-testid":`manage-views-row-${e.id}`,className:q(`group/row flex items-center gap-2 px-2 py-2 rounded-md border border-transparent`,`hover:bg-accent/50 transition-colors`,t&&`bg-accent/40 border-border`,b&&`shadow-md bg-background border-border z-10`),children:[(0,$.jsx)(`button`,{type:`button`,...h,...g,"aria-label":`Drag to reorder`,"data-testid":`manage-views-drag-${e.id}`,className:`shrink-0 h-6 w-5 flex items-center justify-center text-muted-foreground/40 hover:text-muted-foreground cursor-grab active:cursor-grabbing rounded hover:bg-accent`,onClick:e=>e.stopPropagation(),children:(0,$.jsx)(je,{className:`h-4 w-4`})}),(0,$.jsx)(n,{className:`shrink-0 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,onClick:()=>{r||s?.(e.id)},children:r?(0,$.jsx)(J,{ref:S,value:E,onChange:e=>D(e.target.value),onBlur:te,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),te()):e.key===`Escape`&&(e.preventDefault(),o())},onClick:e=>e.stopPropagation(),className:`h-7 text-sm`,"data-testid":`manage-views-rename-input-${e.id}`}):(0,$.jsxs)(`button`,{type:`button`,className:`w-full text-left text-sm font-medium truncate cursor-pointer flex items-center gap-1.5`,onDoubleClick:t=>{t.stopPropagation(),O||i(e.id)},title:e.label,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.label}),O&&(0,$.jsx)(u,{"aria-label":`Read-only view`,"data-testid":`manage-views-readonly-${e.id}`,className:`h-3 w-3 text-muted-foreground shrink-0`}),e.isDefault&&(0,$.jsxs)(`span`,{className:`ml-1 inline-flex items-center text-[10px] uppercase tracking-wide text-muted-foreground`,title:`Default view`,children:[(0,$.jsx)(De,{className:`h-3 w-3 mr-0.5 fill-current`}),` default`]})]})}),p&&!r&&!O&&(0,$.jsx)(d,{delayDuration:300,children:(0,$.jsxs)(ne,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":e.isPinned?`Unpin view`:`Pin view`,"data-testid":`manage-views-pin-${e.id}`,onClick:t=>{t.stopPropagation(),p(e.id,!e.isPinned)},className:q(`shrink-0 h-7 w-7 inline-flex items-center justify-center rounded hover:bg-accent transition-colors`,e.isPinned?`text-amber-500`:`text-muted-foreground/40 opacity-0 group-hover/row:opacity-100`),children:e.isPinned?(0,$.jsx)(T,{className:`h-4 w-4 fill-current`}):(0,$.jsx)(T,{className:`h-4 w-4`})})}),(0,$.jsx)(Te,{side:`top`,children:e.isPinned?`Unpin view`:`Pin view`})]})}),f&&!r&&!e.isDefault&&!O&&(0,$.jsx)(d,{delayDuration:300,children:(0,$.jsxs)(ne,{children:[(0,$.jsx)(K,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":`Set as default`,"data-testid":`manage-views-default-${e.id}`,onClick:t=>{t.stopPropagation(),f(e.id)},className:`shrink-0 h-7 w-7 inline-flex items-center justify-center rounded hover:bg-accent text-muted-foreground/40 hover:text-foreground opacity-0 group-hover/row:opacity-100 transition-colors`,children:(0,$.jsx)(De,{className:`h-4 w-4`})})}),(0,$.jsx)(Te,{side:`top`,children:`Set as default`})]})}),!r&&(c||l||m||f)&&(0,$.jsxs)(Me,{children:[(0,$.jsx)(xe,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":`Actions for ${e.label}`,"data-testid":`manage-views-actions-${e.id}`,onClick:e=>e.stopPropagation(),className:`shrink-0 h-7 w-7 inline-flex items-center justify-center rounded hover:bg-accent text-muted-foreground opacity-60 group-hover/row:opacity-100 transition-opacity`,children:(0,$.jsx)(C,{className:`h-4 w-4`})})}),(0,$.jsxs)(ge,{align:`end`,className:`min-w-[180px]`,children:[!O&&(0,$.jsxs)(Y,{"data-testid":`manage-views-action-rename-${e.id}`,onClick:()=>i(e.id),children:[(0,$.jsx)(B,{className:`h-4 w-4 mr-2`}),` Rename`]}),l&&(0,$.jsxs)(Y,{"data-testid":`manage-views-action-duplicate-${e.id}`,onClick:()=>l(e.id),children:[(0,$.jsx)(w,{className:`h-4 w-4 mr-2`}),` Duplicate`]}),m&&!O&&(0,$.jsxs)(Y,{"data-testid":`manage-views-action-config-${e.id}`,onClick:()=>m(e.id),children:[(0,$.jsx)(B,{className:`h-4 w-4 mr-2`}),` Edit configuration…`]}),f&&!e.isDefault&&!O&&(0,$.jsxs)(Y,{"data-testid":`manage-views-action-default-${e.id}`,onClick:()=>f(e.id),children:[(0,$.jsx)(De,{className:`h-4 w-4 mr-2`}),` Set as default`]}),p&&!O&&(0,$.jsx)(Y,{"data-testid":`manage-views-action-pin-${e.id}`,onClick:()=>p(e.id,!e.isPinned),children:e.isPinned?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(y,{className:`h-4 w-4 mr-2`}),` Unpin`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{className:`h-4 w-4 mr-2`}),` Pin`]})}),c&&!O&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(be,{}),(0,$.jsxs)(Y,{"data-testid":`manage-views-action-delete-${e.id}`,onClick:()=>c(e.id),className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(ce,{className:`h-4 w-4 mr-2`}),` Delete`]})]})]})]}),r&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`Save name`,onMouseDown:e=>e.preventDefault(),onClick:te,className:`h-7 w-7 inline-flex items-center justify-center rounded hover:bg-accent text-emerald-600`,children:(0,$.jsx)(Fe,{className:`h-4 w-4`})}),(0,$.jsx)(`button`,{type:`button`,"aria-label":`Cancel rename`,onMouseDown:e=>e.preventDefault(),onClick:o,className:`h-7 w-7 inline-flex items-center justify-center rounded hover:bg-accent text-muted-foreground`,children:(0,$.jsx)(N,{className:`h-4 w-4`})})]})]})},zt=({open:e,onOpenChange:t,views:n,activeViewId:r,viewTypeIcons:i={},onRename:a,onDelete:o,onDuplicate:s,onSetDefault:c,onSetPinned:l,onReorder:u,onAddView:d,onConfigView:p})=>{let[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(()=>n.map(e=>e.id));(0,Q.useEffect)(()=>{y(n.map(e=>e.id))},[n]),(0,Q.useEffect)(()=>{e||(_(null),h(``))},[e]);let x=(0,Q.useMemo)(()=>{let e=new Map(n.map(e=>[e.id,e]));return v.map(t=>e.get(t)).filter(Boolean)},[v,n]),S=(0,Q.useMemo)(()=>{if(!m.trim())return x;let e=m.toLowerCase();return x.filter(t=>t.label.toLowerCase().includes(e))},[x,m]),C=qe(Je(Ke,{activationConstraint:{distance:5}}),Je(tt,{coordinateGetter:We})),w=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id)return;let r=v.indexOf(String(t.id)),i=v.indexOf(String(n.id));if(r<0||i<0)return;let a=Ye(v,r,i);y(a),u?.(a)},T=e=>{t(!1),requestAnimationFrame(()=>p?.(e))};return(0,$.jsx)(D,{open:e,onOpenChange:t,children:(0,$.jsxs)(re,{className:`sm:max-w-[560px] p-0 gap-0 overflow-hidden`,"data-testid":`manage-views-dialog`,children:[(0,$.jsxs)(se,{className:`px-5 pt-5 pb-3`,children:[(0,$.jsx)(b,{className:`text-base`,children:`Manage views`}),(0,$.jsx)(Be,{className:`text-xs`,children:`Reorder, rename, pin, or delete every view in this object.`})]}),(0,$.jsx)(`div`,{className:`px-5 pb-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(ie,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none`}),(0,$.jsx)(J,{value:m,onChange:e=>h(e.target.value),placeholder:`Search views`,className:`pl-8 h-9`,"data-testid":`manage-views-search`})]})}),(0,$.jsx)(`div`,{className:`px-3 pb-3 max-h-[55vh] overflow-y-auto`,"data-testid":`manage-views-list`,children:S.length===0?(0,$.jsx)(`div`,{className:`text-center text-sm text-muted-foreground py-10`,children:`No views match your search.`}):(0,$.jsx)(Ge,{sensors:C,collisionDetection:Ze,onDragEnd:w,children:(0,$.jsx)(et,{items:S.map(e=>e.id),strategy:$e,children:(0,$.jsx)(`ul`,{className:`space-y-0.5`,children:S.map(e=>(0,$.jsx)(Rt,{view:e,Icon:i[e.type]||Lt,isActive:e.id===r,isRenaming:g===e.id,onStartRename:e=>_(e),onCancelRename:()=>_(null),onCommitRename:(e,t)=>{_(null),a?.(e,t)},onDelete:o,onDuplicate:s,onSetDefault:c,onSetPinned:l,onConfigView:p?T:void 0},e.id))})})})}),(0,$.jsxs)(f,{className:`border-t bg-muted/30 px-5 py-3 flex sm:justify-between gap-2`,children:[d?(0,$.jsxs)(W,{variant:`ghost`,size:`sm`,onClick:()=>{t(!1),requestAnimationFrame(()=>d())},"data-testid":`manage-views-add`,className:`text-sm`,children:[(0,$.jsx)(ee,{className:`h-4 w-4 mr-1.5`}),` Add new view`]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(W,{size:`sm`,onClick:()=>t(!1),"data-testid":`manage-views-done`,children:`Done`})]})]})})};function Bt(e){let t=(e||``).toLowerCase();return[`integer`,`int`,`float`,`double`,`number`,`currency`,`money`,`percent`,`rating`].includes(t)?`number`:[`date`,`datetime`,`datetime_tz`,`timestamp`,`time`].includes(t)?`date`:[`boolean`,`bool`,`checkbox`,`switch`].includes(t)?`boolean`:[`select`,`picklist`,`single_select`,`multi_select`,`enum`,`status`,`lookup`,`master_detail`,`user`,`owner`].includes(t)?`select`:`text`}function Vt(e){return e.fields?Object.entries(e.fields).filter(([e,t])=>!(e.startsWith(`_`)||t?.hidden)).map(([e,t])=>({value:e,label:t.label||e,type:Bt(t.type),options:t.options,rawType:t.type,rawName:e})):[]}var Ht=new Set([`image`,`image_url`,`photo`,`picture`,`avatar`,`file`,`attachment`,`attachments`,`media`,`url`,`link`]),Ut=[`image`,`photo`,`picture`,`avatar`,`thumbnail`,`thumb`,`logo`,`cover`,`banner`,`icon`,`attachment`];function Wt(e){if(!e)return!1;let t=(e.rawType||e.type||``).toLowerCase();if(Ht.has(t))return!0;let n=(e.rawName||e.name||e.key||e.value||``).toLowerCase();return n?Ut.some(e=>n.includes(e)):!1}var Gt=new Set([`geolocation`,`geo`,`geo_point`,`geopoint`,`location`,`latlng`,`lnglat`]);function Kt(e,t){if(!e)return!1;let n=(e.rawType||e.type||``).toLowerCase();if(Gt.has(n))return!0;let r=(e.rawName||e.name||e.key||e.value||``).toLowerCase();return r?t===`latitude`?/(^|[_-])lat([^a-z]|itude)?($|[_-])/.test(r)||r===`lat`:/(^|[_-])(lng|lon|long)([^a-z]|gitude)?($|[_-])/.test(r)||r===`lng`||r===`lon`:!1}function qt(e,t){if(e.length!==0){for(let n of t){let t=e.find(e=>e.value.toLowerCase().includes(n));if(t)return t.value}return e[0]?.value}}var Jt=[`status`,`stage`,`state`,`priority`,`category`,`type`],Yt=[`start_date`,`startdate`,`due_date`,`duedate`,`event_date`,`date`,`created_at`,`createdat`,`created`],Xt=[`end_date`,`enddate`,`finish_date`,`completion_date`,`closed_at`],Zt=i,Qt=({schema:e})=>(0,$.jsx)(yt,{schema:e,dataSource:(0,Q.useContext)(Zt)?.dataSource??null});o.register(`object-view`,Qt,{namespace:`plugin-view`,label:`Object View`,category:`view`,icon:`LayoutDashboard`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`title`,type:`string`,label:`Title`},{name:`description`,type:`string`,label:`Description`},{name:`layout`,type:`enum`,label:`Form Layout`,enum:[`drawer`,`modal`,`page`]},{name:`defaultViewType`,type:`enum`,label:`Default View Type`,enum:[`grid`,`kanban`,`gallery`,`calendar`,`timeline`,`gantt`,`map`]},{name:`defaultListView`,type:`string`,label:`Default Named View`},{name:`showSearch`,type:`boolean`,label:`Show Search`},{name:`showFilters`,type:`boolean`,label:`Show Filters`},{name:`showCreate`,type:`boolean`,label:`Show Create Button`},{name:`showRefresh`,type:`boolean`,label:`Show Refresh Button`},{name:`showViewSwitcher`,type:`boolean`,label:`Show View Switcher`},{name:`listViews`,type:`object`,label:`Named List Views`},{name:`navigation`,type:`object`,label:`Navigation Config`},{name:`searchableFields`,type:`array`,label:`Searchable Fields`},{name:`filterableFields`,type:`array`,label:`Filterable Fields`}],defaultProps:{layout:`drawer`,defaultViewType:`grid`,showSearch:!0,showFilters:!0,showCreate:!0,showRefresh:!0,showViewSwitcher:!0}}),o.register(`view`,Qt,{namespace:`plugin-view`,label:`View`,category:`view`}),o.register(`view-switcher`,_t,{namespace:`view`,label:`View Switcher`,category:`view`,icon:`LayoutGrid`,inputs:[{name:`views`,type:`array`,label:`Views`,required:!0},{name:`defaultView`,type:`string`,label:`Default View`},{name:`activeView`,type:`string`,label:`Active View`},{name:`variant`,type:`enum`,label:`Variant`,enum:[`tabs`,`buttons`,`dropdown`]},{name:`position`,type:`enum`,label:`Position`,enum:[`top`,`bottom`,`left`,`right`]},{name:`persistPreference`,type:`boolean`,label:`Persist Preference`},{name:`storageKey`,type:`string`,label:`Storage Key`},{name:`onViewChange`,type:`string`,label:`On View Change Event`}],defaultProps:{variant:`tabs`,position:`top`,defaultView:`grid`,views:[{type:`grid`,label:`Grid`,schema:{type:`text`,content:`Grid view`}},{type:`list`,label:`List`,schema:{type:`text`,content:`List view`}}]}}),o.register(`filter-ui`,Ct,{namespace:`view`,label:`Filter UI`,category:`view`,icon:`SlidersHorizontal`,inputs:[{name:`filters`,type:`array`,label:`Filters`,required:!0},{name:`values`,type:`object`,label:`Values`},{name:`onChange`,type:`string`,label:`On Change Event`},{name:`showClear`,type:`boolean`,label:`Show Clear Button`},{name:`showApply`,type:`boolean`,label:`Show Apply Button`},{name:`layout`,type:`enum`,label:`Layout`,enum:[`inline`,`popover`,`drawer`]}],defaultProps:{layout:`inline`,showApply:!1,showClear:!0,filters:[{field:`name`,label:`Name`,type:`text`,placeholder:`Search name`},{field:`status`,label:`Status`,type:`select`,options:[{label:`Open`,value:`open`},{label:`Closed`,value:`closed`}]},{field:`created_at`,label:`Created`,type:`date`}]}}),o.register(`sort-ui`,Ot,{namespace:`view`,label:`Sort UI`,category:`view`,icon:`ArrowUpDown`,inputs:[{name:`fields`,type:`array`,label:`Fields`,required:!0},{name:`sort`,type:`array`,label:`Sort`},{name:`onChange`,type:`string`,label:`On Change Event`},{name:`multiple`,type:`boolean`,label:`Allow Multiple`},{name:`variant`,type:`enum`,label:`Variant`,enum:[`dropdown`,`buttons`]}],defaultProps:{variant:`dropdown`,multiple:!0,fields:[{field:`name`,label:`Name`},{field:`created_at`,label:`Created At`}],sort:[{field:`name`,direction:`asc`}]}}),o.register(`shared-view-link`,jt,{namespace:`view`,label:`Shared View Link`,category:`view`,icon:`Share2`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`viewId`,type:`string`,label:`View ID`},{name:`baseUrl`,type:`string`,label:`Base URL`}],defaultProps:{objectName:`objects`,viewId:`default`}}),o.register(`view:simple`,({schema:e,className:t,children:n,dataSource:r,...i})=>(0,$.jsx)(`div`,{className:t,style:e.props?.columns?{display:`grid`,gridTemplateColumns:`repeat(${e.props.columns}, 1fr)`,gap:`1rem`}:void 0,...i,children:n}),{namespace:`plugin-view`,label:`Simple View`,category:`view`});export{Kt as a,zt as c,Vt as i,It as l,Jt as n,Wt as o,Yt as r,qt as s,Xt as t,yt as u};
|